Bug 813677 - Only send about:home telemetry pings when showing about:home. r=mfinkle

This commit is contained in:
Wes Johnston 2012-11-26 14:57:11 -08:00
parent 6cb2fce1f0
commit a200a3bb38
3 changed files with 12 additions and 7 deletions

View File

@ -58,6 +58,7 @@ abstract public class BrowserApp extends GeckoApp
public static BrowserToolbar mBrowserToolbar; public static BrowserToolbar mBrowserToolbar;
private AboutHomeContent mAboutHomeContent; private AboutHomeContent mAboutHomeContent;
private Boolean mAboutHomeShowing = null; private Boolean mAboutHomeShowing = null;
protected Telemetry.Timer mAboutHomeStartupTimer = null;
private static final int ADDON_MENU_OFFSET = 1000; private static final int ADDON_MENU_OFFSET = 1000;
private class MenuItemInfo { private class MenuItemInfo {
@ -202,6 +203,8 @@ abstract public class BrowserApp extends GeckoApp
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
mAboutHomeStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_ABOUTHOME");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
LinearLayout actionBar = (LinearLayout) getActionBarLayout(); LinearLayout actionBar = (LinearLayout) getActionBarLayout();
@ -271,10 +274,12 @@ abstract public class BrowserApp extends GeckoApp
Tab tab = Tabs.getInstance().loadUrl("about:home", Tabs.LOADURL_NEW_TAB); Tab tab = Tabs.getInstance().loadUrl("about:home", Tabs.LOADURL_NEW_TAB);
} else { } else {
hideAboutHome(); hideAboutHome();
mAboutHomeStartupTimer.cancel();
} }
} else { } else {
int flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED; int flags = Tabs.LOADURL_NEW_TAB | Tabs.LOADURL_USER_ENTERED;
Tabs.getInstance().loadUrl(uri, flags); Tabs.getInstance().loadUrl(uri, flags);
mAboutHomeStartupTimer.cancel();
} }
} }
@ -670,9 +675,9 @@ abstract public class BrowserApp extends GeckoApp
} }
}); });
mAboutHomeContent.setLoadCompleteCallback(new AboutHomeContent.VoidCallback() { mAboutHomeContent.setLoadCompleteCallback(new AboutHomeContent.VoidCallback() {
public void callback() { public void callback() {
mAboutHomeStartupTimer.stop(); mAboutHomeStartupTimer.stop();
} }
}); });
} else { } else {
mAboutHomeContent.update(EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES, mAboutHomeContent.update(EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES,

View File

@ -190,7 +190,6 @@ abstract public class GeckoApp
protected int mRestoreMode = RESTORE_NONE; protected int mRestoreMode = RESTORE_NONE;
protected boolean mInitialized = false; protected boolean mInitialized = false;
protected Telemetry.Timer mAboutHomeStartupTimer;
private Telemetry.Timer mJavaUiStartupTimer; private Telemetry.Timer mJavaUiStartupTimer;
private Telemetry.Timer mGeckoReadyStartupTimer; private Telemetry.Timer mGeckoReadyStartupTimer;
@ -1470,7 +1469,6 @@ abstract public class GeckoApp
// The clock starts...now. Better hurry! // The clock starts...now. Better hurry!
mJavaUiStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_JAVAUI"); mJavaUiStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_JAVAUI");
mAboutHomeStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_ABOUTHOME");
mGeckoReadyStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_GECKOREADY"); mGeckoReadyStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_GECKOREADY");
((GeckoApplication)getApplication()).initialize(); ((GeckoApplication)getApplication()).initialize();

View File

@ -27,8 +27,6 @@ public class Telemetry {
GeckoEvent event = GeckoEvent event =
GeckoEvent.createBroadcastEvent("Telemetry:Add", jsonData.toString()); GeckoEvent.createBroadcastEvent("Telemetry:Add", jsonData.toString());
GeckoAppShell.sendEventToGecko(event); GeckoAppShell.sendEventToGecko(event);
Log.v(LOGTAG, "Sending telemetry: " + jsonData.toString());
} catch (JSONException e) { } catch (JSONException e) {
Log.e(LOGTAG, "JSON exception: ", e); Log.e(LOGTAG, "JSON exception: ", e);
} }
@ -45,6 +43,10 @@ public class Telemetry {
mHasFinished = false; mHasFinished = false;
} }
public void cancel() {
mHasFinished = true;
}
public void stop() { public void stop() {
// Only the first stop counts. // Only the first stop counts.
if (mHasFinished) { if (mHasFinished) {