From: Kristian Monsen Date: Tue, 2 Feb 2010 13:37:09 +0000 (+0000) Subject: Logging page load time X-Git-Tag: android-x86-2.2~142^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=4dce3bf588b7eaf4de555a93b67f5ddf9bc1ba77;p=android-x86%2Fpackages-apps-Browser.git Logging page load time Added a log message when a page is loaded. It will handle redirects as a new page load. --- diff --git a/src/com/android/browser/LogTag.java b/src/com/android/browser/LogTag.java index 2be3134..38fea47 100644 --- a/src/com/android/browser/LogTag.java +++ b/src/com/android/browser/LogTag.java @@ -16,7 +16,6 @@ package com.android.browser; -import android.util.Log; import android.util.EventLog; public class LogTag { @@ -36,11 +35,14 @@ public class LogTag { * Log when a page has finished loading with how much * time the browser used to load the page. * + * Note that a redirect will restart the timer, so this time is not + * always how long it takes for the user to load a page. + * * @param url the url of that page that finished loading. * @param duration the time the browser spent loading the page. */ public static void logPageFinishedLoading(String url, long duration) { - EventLog.writeEvent(EventLogTags.BROWSER_BOOKMARK_ADDED, url + "|" + EventLog.writeEvent(EventLogTags.BROWSER_PAGE_LOADED, url + "|" + duration); } @@ -51,7 +53,7 @@ public class LogTag { * @param duration the time spent on the webpage. */ public static void logTimeOnPage(String url, long duration) { - EventLog.writeEvent(EventLogTags.BROWSER_BOOKMARK_ADDED, url + "|" + EventLog.writeEvent(EventLogTags.BROWSER_TIMEONPAGE, url + "|" + duration); } } diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index 5db4848..c939a13 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -37,6 +37,7 @@ import android.net.http.SslError; import android.os.AsyncTask; import android.os.Bundle; import android.os.Message; +import android.os.SystemClock; import android.provider.Browser; import android.speech.RecognizerResultsIntent; import android.util.Log; @@ -97,6 +98,8 @@ class Tab { private boolean mInForeground; // If true, the tab is in loading state. private boolean mInLoad; + // The time the load started, used to find load page time + private long mLoadStartTime; // Application identifier used to find tabs that another application wants // to reuse. private String mAppId; @@ -317,6 +320,7 @@ class Tab { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { mInLoad = true; + mLoadStartTime = SystemClock.uptimeMillis(); if (mVoiceSearchData != null && !url.equals(mVoiceSearchData.mLastVoiceSearchUrl)) { mVoiceSearchData = null; @@ -370,6 +374,8 @@ class Tab { @Override public void onPageFinished(WebView view, String url) { + LogTag.logPageFinishedLoading( + url, SystemClock.uptimeMillis() - mLoadStartTime); mInLoad = false; if (mInForeground && !mActivity.didUserStopLoading()