зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1273689 - Move session measurement calls to CorePingDelegate. r=sebastian
MozReview-Commit-ID: EPLUd5Uq0Pc --HG-- extra : rebase_source : ad7f650414c15ac44b64acb371a04f3cfea3d0e2
This commit is contained in:
Родитель
3013ee94dd
Коммит
9022a32d3c
|
@ -79,7 +79,6 @@ import org.mozilla.gecko.tabs.TabsPanel;
|
||||||
import org.mozilla.gecko.telemetry.TelemetryUploadService;
|
import org.mozilla.gecko.telemetry.TelemetryUploadService;
|
||||||
import org.mozilla.gecko.telemetry.TelemetryCorePingUploadDelegate;
|
import org.mozilla.gecko.telemetry.TelemetryCorePingUploadDelegate;
|
||||||
import org.mozilla.gecko.telemetry.measurements.SearchCountMeasurements;
|
import org.mozilla.gecko.telemetry.measurements.SearchCountMeasurements;
|
||||||
import org.mozilla.gecko.telemetry.measurements.SessionMeasurements;
|
|
||||||
import org.mozilla.gecko.toolbar.AutocompleteHandler;
|
import org.mozilla.gecko.toolbar.AutocompleteHandler;
|
||||||
import org.mozilla.gecko.toolbar.BrowserToolbar;
|
import org.mozilla.gecko.toolbar.BrowserToolbar;
|
||||||
import org.mozilla.gecko.toolbar.BrowserToolbar.TabEditingState;
|
import org.mozilla.gecko.toolbar.BrowserToolbar.TabEditingState;
|
||||||
|
@ -316,8 +315,6 @@ public class BrowserApp extends GeckoApp
|
||||||
@NonNull
|
@NonNull
|
||||||
private SearchEngineManager mSearchEngineManager; // Contains reference to Context - DO NOT LEAK!
|
private SearchEngineManager mSearchEngineManager; // Contains reference to Context - DO NOT LEAK!
|
||||||
|
|
||||||
private final SessionMeasurements mSessionMeasurements = new SessionMeasurements();
|
|
||||||
|
|
||||||
private boolean mHasResumed;
|
private boolean mHasResumed;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1001,7 +998,6 @@ public class BrowserApp extends GeckoApp
|
||||||
|
|
||||||
// Needed for Adjust to get accurate session measurements
|
// Needed for Adjust to get accurate session measurements
|
||||||
AdjustConstants.getAdjustHelper().onResume();
|
AdjustConstants.getAdjustHelper().onResume();
|
||||||
mSessionMeasurements.recordSessionStart();
|
|
||||||
|
|
||||||
if (!mHasResumed) {
|
if (!mHasResumed) {
|
||||||
EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener) this,
|
EventDispatcher.getInstance().unregisterGeckoThreadListener((GeckoEventListener) this,
|
||||||
|
@ -1026,10 +1022,6 @@ public class BrowserApp extends GeckoApp
|
||||||
// Needed for Adjust to get accurate session measurements
|
// Needed for Adjust to get accurate session measurements
|
||||||
AdjustConstants.getAdjustHelper().onPause();
|
AdjustConstants.getAdjustHelper().onPause();
|
||||||
|
|
||||||
// onStart/onStop is ideal over onResume/onPause. However, onStop is not guaranteed to be called and
|
|
||||||
// dealing with that possibility adds a lot of complexity that we don't want to handle at this point.
|
|
||||||
mSessionMeasurements.recordSessionEnd(this);
|
|
||||||
|
|
||||||
if (mHasResumed) {
|
if (mHasResumed) {
|
||||||
// Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
|
// Register for Prompt:ShowTop so we can foreground this activity even if it's hidden.
|
||||||
EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this,
|
EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this,
|
||||||
|
@ -3915,10 +3907,6 @@ public class BrowserApp extends GeckoApp
|
||||||
return mSearchEngineManager;
|
return mSearchEngineManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionMeasurements getSessionMeasurementDelegate() {
|
|
||||||
return mSessionMeasurements;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For use from tests only.
|
// For use from tests only.
|
||||||
@RobocopTarget
|
@RobocopTarget
|
||||||
public ReadingListHelper getReadingListHelper() {
|
public ReadingListHelper getReadingListHelper() {
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class TelemetryCorePingUploadDelegate extends BrowserAppDelegate {
|
||||||
"Gecko" + TelemetryCorePingUploadDelegate.class.getSimpleName(), 0, 23);
|
"Gecko" + TelemetryCorePingUploadDelegate.class.getSimpleName(), 0, 23);
|
||||||
|
|
||||||
private TelemetryDispatcher telemetryDispatcher; // lazy
|
private TelemetryDispatcher telemetryDispatcher; // lazy
|
||||||
|
private final SessionMeasurements sessionMeasurements = new SessionMeasurements();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart(final BrowserApp browserApp) {
|
public void onStart(final BrowserApp browserApp) {
|
||||||
|
@ -49,6 +50,18 @@ public class TelemetryCorePingUploadDelegate extends BrowserAppDelegate {
|
||||||
searchEngineManager.getEngine(new UploadTelemetryCorePingCallback(browserApp));
|
searchEngineManager.getEngine(new UploadTelemetryCorePingCallback(browserApp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume(BrowserApp browserApp) {
|
||||||
|
sessionMeasurements.recordSessionStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause(BrowserApp browserApp) {
|
||||||
|
// onStart/onStop is ideal over onResume/onPause. However, onStop is not guaranteed to be called and
|
||||||
|
// dealing with that possibility adds a lot of complexity that we don't want to handle at this point.
|
||||||
|
sessionMeasurements.recordSessionEnd(browserApp);
|
||||||
|
}
|
||||||
|
|
||||||
@WorkerThread // via constructor
|
@WorkerThread // via constructor
|
||||||
private TelemetryDispatcher getTelemetryDispatcher(final BrowserApp browserApp) {
|
private TelemetryDispatcher getTelemetryDispatcher(final BrowserApp browserApp) {
|
||||||
if (telemetryDispatcher == null) {
|
if (telemetryDispatcher == null) {
|
||||||
|
@ -107,7 +120,7 @@ public class TelemetryCorePingUploadDelegate extends BrowserAppDelegate {
|
||||||
// Each profile can have different telemetry data so we intentionally grab the shared prefs for the profile.
|
// Each profile can have different telemetry data so we intentionally grab the shared prefs for the profile.
|
||||||
final SharedPreferences sharedPrefs = getSharedPreferences(activity);
|
final SharedPreferences sharedPrefs = getSharedPreferences(activity);
|
||||||
final SessionMeasurements.SessionMeasurementsContainer sessionMeasurementsContainer =
|
final SessionMeasurements.SessionMeasurementsContainer sessionMeasurementsContainer =
|
||||||
activity.getSessionMeasurementDelegate().getAndResetSessionMeasurements(activity);
|
sessionMeasurements.getAndResetSessionMeasurements(activity);
|
||||||
final TelemetryCorePingBuilder pingBuilder = new TelemetryCorePingBuilder(activity)
|
final TelemetryCorePingBuilder pingBuilder = new TelemetryCorePingBuilder(activity)
|
||||||
.setClientID(clientID)
|
.setClientID(clientID)
|
||||||
.setDefaultSearchEngine(TelemetryCorePingBuilder.getEngineIdentifier(engine))
|
.setDefaultSearchEngine(TelemetryCorePingBuilder.getEngineIdentifier(engine))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче