Bug 1273689 - Factor out getSharedPreferences call. r=sebastian
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 31 May 2016 14:07:26 -0700
changeset 338905 ab5501b1b7d5ebdae96199d1bc6ceaf3defe35f9
parent 338904 6d3576194df89669978874205caacd4ef5196451
child 338906 e28024927ff6727dd04f58244fe663f9a0290043
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1273689
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1273689 - Factor out getSharedPreferences call. r=sebastian The same preferences will be used by the new code & the old code. MozReview-Commit-ID: BXuSQjhhXQq
mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingUploadDelegate.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingUploadDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/TelemetryCorePingUploadDelegate.java
@@ -53,16 +53,20 @@ public class TelemetryCorePingUploadDele
     private TelemetryDispatcher getTelemetryDispatcher(final BrowserApp browserApp) {
         if (telemetryDispatcher == null) {
             final String profilePath = browserApp.getProfile().getDir().getAbsolutePath();
             telemetryDispatcher = new TelemetryDispatcher(profilePath);
         }
         return telemetryDispatcher;
     }
 
+    private SharedPreferences getSharedPreferences(final BrowserApp activity) {
+        return GeckoSharedPrefs.forProfileName(activity, activity.getProfile().getName());
+    }
+
     private class UploadTelemetryCorePingCallback implements SearchEngineManager.SearchEngineCallback {
         private final WeakReference<BrowserApp> activityWeakReference;
 
         private UploadTelemetryCorePingCallback(final BrowserApp activity) {
             this.activityWeakReference = new WeakReference<>(activity);
         }
 
         // May be called from any thread.
@@ -96,17 +100,17 @@ public class TelemetryCorePingUploadDele
                     try {
                         clientID = profile.getClientId();
                     } catch (final IOException e) {
                         Log.w(LOGTAG, "Unable to get client ID to generate core ping: " + e);
                         return;
                     }
 
                     // Each profile can have different telemetry data so we intentionally grab the shared prefs for the profile.
-                    final SharedPreferences sharedPrefs = GeckoSharedPrefs.forProfileName(activity, profile.getName());
+                    final SharedPreferences sharedPrefs = getSharedPreferences(activity);
                     final SessionMeasurements.SessionMeasurementsContainer sessionMeasurementsContainer =
                             activity.getSessionMeasurementDelegate().getAndResetSessionMeasurements(activity);
                     final TelemetryCorePingBuilder pingBuilder = new TelemetryCorePingBuilder(activity)
                             .setClientID(clientID)
                             .setDefaultSearchEngine(TelemetryCorePingBuilder.getEngineIdentifier(engine))
                             .setProfileCreationDate(TelemetryCorePingBuilder.getProfileCreationDate(activity, profile))
                             .setSequenceNumber(TelemetryCorePingBuilder.getAndIncrementSequenceNumber(sharedPrefs))
                             .setSessionCount(sessionMeasurementsContainer.sessionCount)