Added a log message when a page is loaded. It will handle redirects as a new page load.
package com.android.browser;
package com.android.browser;
-import android.util.Log;
import android.util.EventLog;
public class LogTag {
import android.util.EventLog;
public class LogTag {
* Log when a page has finished loading with how much
* time the browser used to load the page.
*
* 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) {
* @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 + "|"
* @param duration the time spent on the webpage.
*/
public static void logTimeOnPage(String url, long duration) {
* @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 + "|"
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Message;
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;
import android.provider.Browser;
import android.speech.RecognizerResultsIntent;
import android.util.Log;
private boolean mInForeground;
// If true, the tab is in loading state.
private boolean mInLoad;
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;
// Application identifier used to find tabs that another application wants
// to reuse.
private String mAppId;
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
mInLoad = true;
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
mInLoad = true;
+ mLoadStartTime = SystemClock.uptimeMillis();
if (mVoiceSearchData != null
&& !url.equals(mVoiceSearchData.mLastVoiceSearchUrl)) {
mVoiceSearchData = null;
if (mVoiceSearchData != null
&& !url.equals(mVoiceSearchData.mLastVoiceSearchUrl)) {
mVoiceSearchData = null;
@Override
public void onPageFinished(WebView view, String url) {
@Override
public void onPageFinished(WebView view, String url) {
+ LogTag.logPageFinishedLoading(
+ url, SystemClock.uptimeMillis() - mLoadStartTime);
mInLoad = false;
if (mInForeground && !mActivity.didUserStopLoading()
mInLoad = false;
if (mInForeground && !mActivity.didUserStopLoading()