diff options
Diffstat (limited to 'WebKit/android/jni/WebCoreResourceLoader.cpp')
-rw-r--r-- | WebKit/android/jni/WebCoreResourceLoader.cpp | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp index 2e349e8..b335b49 100644 --- a/WebKit/android/jni/WebCoreResourceLoader.cpp +++ b/WebKit/android/jni/WebCoreResourceLoader.cpp @@ -1,18 +1,27 @@ /* -** Copyright 2006, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ + * Copyright 2006, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #define LOG_TAG "webcoreglue" @@ -32,8 +41,7 @@ #include "WebCoreJni.h" #ifdef ANDROID_INSTRUMENT -#include "Frame.h" -#include "SystemTime.h" +#include "TimeCounter.h" #endif #include <utils/misc.h> @@ -41,41 +49,8 @@ #include <SkTypes.h> #include <stdlib.h> -#ifdef ANDROID_INSTRUMENT -static uint32_t sTotalTimeUsed = 0; - -namespace WebCore { -void Frame::resetResourceLoadTimeCounter() -{ - sTotalTimeUsed = 0; -} - -void Frame::reportResourceLoadTimeCounter() -{ - LOG(LOG_DEBUG, "WebCore", "*-* Total native 3 (resource load) time: %d ms\n", - sTotalTimeUsed); -} -} -#endif - namespace android { -#ifdef ANDROID_INSTRUMENT -class TimeCounterRC { -public: - TimeCounterRC() { - mStartTime = WebCore::get_thread_msec(); - } - - ~TimeCounterRC() { - sTotalTimeUsed += WebCore::get_thread_msec() - mStartTime; - } - -private: - uint32_t mStartTime; -}; -#endif - // ---------------------------------------------------------------------------- static struct resourceloader_t { @@ -144,7 +119,7 @@ bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url) void WebCoreResourceLoader::SetResponseHeader(JNIEnv* env, jobject obj, jint nativeResponse, jstring key, jstring val) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse; @@ -163,7 +138,7 @@ jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url jstring encoding, jlong expireTime) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif LOG_ASSERT(url, "Must have a url in the response!"); WebCore::KURL kurl(to_string(env, url)); @@ -196,7 +171,7 @@ jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url void WebCoreResourceLoader::ReceivedResponse(JNIEnv* env, jobject obj, jint nativeResponse) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); LOG_ASSERT(handle, "nativeReceivedResponse must take a valid handle!"); @@ -214,7 +189,7 @@ void WebCoreResourceLoader::ReceivedResponse(JNIEnv* env, jobject obj, jint nati void WebCoreResourceLoader::AddData(JNIEnv* env, jobject obj, jbyteArray dataArray, jint length) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif LOGV("webcore_resourceloader data(%d)", length); @@ -237,7 +212,7 @@ void WebCoreResourceLoader::AddData(JNIEnv* env, jobject obj, jbyteArray dataArr void WebCoreResourceLoader::Finished(JNIEnv* env, jobject obj) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif LOGV("webcore_resourceloader finished"); WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); @@ -254,7 +229,7 @@ jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj, jstring baseUrl, jstring redirectTo, jint nativeResponse) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif LOGV("webcore_resourceloader redirectedToUrl"); WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); @@ -290,7 +265,7 @@ void WebCoreResourceLoader::Error(JNIEnv* env, jobject obj, jint id, jstring des jstring failingUrl) { #ifdef ANDROID_INSTRUMENT - TimeCounterRC counter; + TimeCounterAuto counter(TimeCounter::ResourceTimeCounter); #endif LOGV("webcore_resourceloader error"); WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj); |