| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.sync; | 5 package org.chromium.chrome.browser.sync; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; |
| 7 import android.app.Activity; | 8 import android.app.Activity; |
| 8 import android.content.Context; | 9 import android.content.Context; |
| 9 | 10 |
| 10 import org.chromium.base.ActivityState; | 11 import org.chromium.base.ActivityState; |
| 11 import org.chromium.base.ApplicationStatus; | 12 import org.chromium.base.ApplicationStatus; |
| 12 import org.chromium.base.ApplicationStatus.ActivityStateListener; | 13 import org.chromium.base.ApplicationStatus.ActivityStateListener; |
| 13 import org.chromium.base.Log; | 14 import org.chromium.base.Log; |
| 14 import org.chromium.base.ThreadUtils; | 15 import org.chromium.base.ThreadUtils; |
| 15 import org.chromium.base.VisibleForTesting; | 16 import org.chromium.base.VisibleForTesting; |
| 16 import org.chromium.base.metrics.RecordHistogram; | 17 import org.chromium.base.metrics.RecordHistogram; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 /** | 55 /** |
| 55 * An identifier for the generator in UniqueIdentificationGeneratorFactory t
o be used to | 56 * An identifier for the generator in UniqueIdentificationGeneratorFactory t
o be used to |
| 56 * generate the sync sessions ID. The generator is registered in the Applica
tion's onCreate | 57 * generate the sync sessions ID. The generator is registered in the Applica
tion's onCreate |
| 57 * method. | 58 * method. |
| 58 */ | 59 */ |
| 59 public static final String GENERATOR_ID = "SYNC"; | 60 public static final String GENERATOR_ID = "SYNC"; |
| 60 | 61 |
| 61 @VisibleForTesting | 62 @VisibleForTesting |
| 62 public static final String SESSION_TAG_PREFIX = "session_sync"; | 63 public static final String SESSION_TAG_PREFIX = "session_sync"; |
| 63 | 64 |
| 65 // TODO(crbug.com/635567): Fix this properly. |
| 66 @SuppressLint("StaticFieldLeak") |
| 64 private static SyncController sInstance; | 67 private static SyncController sInstance; |
| 65 private static boolean sInitialized; | 68 private static boolean sInitialized; |
| 66 | 69 |
| 67 private final Context mContext; | 70 private final Context mContext; |
| 68 private final ChromeSigninController mChromeSigninController; | 71 private final ChromeSigninController mChromeSigninController; |
| 69 private final ProfileSyncService mProfileSyncService; | 72 private final ProfileSyncService mProfileSyncService; |
| 70 private final SyncNotificationController mSyncNotificationController; | 73 private final SyncNotificationController mSyncNotificationController; |
| 71 | 74 |
| 72 private SyncController(Context context) { | 75 private SyncController(Context context) { |
| 73 mContext = context; | 76 mContext = context; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 UniqueIdentificationGeneratorFactory.getInstance(GENERATOR_ID); | 236 UniqueIdentificationGeneratorFactory.getInstance(GENERATOR_ID); |
| 234 String uniqueTag = generator.getUniqueId(null); | 237 String uniqueTag = generator.getUniqueId(null); |
| 235 if (uniqueTag.isEmpty()) { | 238 if (uniqueTag.isEmpty()) { |
| 236 Log.e(TAG, "Unable to get unique tag for sync. " | 239 Log.e(TAG, "Unable to get unique tag for sync. " |
| 237 + "This may lead to unexpected tab sync behavior."); | 240 + "This may lead to unexpected tab sync behavior."); |
| 238 return; | 241 return; |
| 239 } | 242 } |
| 240 mProfileSyncService.setSessionsId(SESSION_TAG_PREFIX + uniqueTag); | 243 mProfileSyncService.setSessionsId(SESSION_TAG_PREFIX + uniqueTag); |
| 241 } | 244 } |
| 242 } | 245 } |
| OLD | NEW |