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 @@
* 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 @@
* @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.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 @@
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 @@
@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 @@
@Override
public void onPageFinished(WebView view, String url) {
+ LogTag.logPageFinishedLoading(
+ url, SystemClock.uptimeMillis() - mLoadStartTime);
mInLoad = false;
if (mInForeground && !mActivity.didUserStopLoading()