Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java

Issue 2697933002: Remove factory methods from ChromeApplication. (Closed)
Patch Set: Add some comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 9
10 import org.chromium.base.ActivityState; 10 import org.chromium.base.ActivityState;
11 import org.chromium.base.ApplicationStatus; 11 import org.chromium.base.ApplicationStatus;
12 import org.chromium.base.ApplicationStatus.ActivityStateListener; 12 import org.chromium.base.ApplicationStatus.ActivityStateListener;
13 import org.chromium.base.Log; 13 import org.chromium.base.Log;
14 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
15 import org.chromium.base.VisibleForTesting; 15 import org.chromium.base.VisibleForTesting;
16 import org.chromium.base.metrics.RecordHistogram; 16 import org.chromium.base.metrics.RecordHistogram;
17 import org.chromium.chrome.browser.ChromeApplication; 17 import org.chromium.chrome.browser.AppGlobals;
18 import org.chromium.chrome.browser.childaccounts.ChildAccountService; 18 import org.chromium.chrome.browser.childaccounts.ChildAccountService;
19 import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator; 19 import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
20 import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory ; 20 import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory ;
21 import org.chromium.chrome.browser.invalidation.InvalidationController; 21 import org.chromium.chrome.browser.invalidation.InvalidationController;
22 import org.chromium.chrome.browser.signin.AccountManagementFragment; 22 import org.chromium.chrome.browser.signin.AccountManagementFragment;
23 import org.chromium.chrome.browser.signin.SigninManager; 23 import org.chromium.chrome.browser.signin.SigninManager;
24 import org.chromium.chrome.browser.sync.ui.PassphraseActivity; 24 import org.chromium.chrome.browser.sync.ui.PassphraseActivity;
25 import org.chromium.components.signin.ChromeSigninController; 25 import org.chromium.components.signin.ChromeSigninController;
26 import org.chromium.components.sync.AndroidSyncSettings; 26 import org.chromium.components.sync.AndroidSyncSettings;
27 import org.chromium.components.sync.ModelType; 27 import org.chromium.components.sync.ModelType;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // When the application gets paused, tell sync to flush the directory to disk. 94 // When the application gets paused, tell sync to flush the directory to disk.
95 ApplicationStatus.registerStateListenerForAllActivities(new ActivityStat eListener() { 95 ApplicationStatus.registerStateListenerForAllActivities(new ActivityStat eListener() {
96 @Override 96 @Override
97 public void onActivityStateChange(Activity activity, int newState) { 97 public void onActivityStateChange(Activity activity, int newState) {
98 if (newState == ActivityState.PAUSED) { 98 if (newState == ActivityState.PAUSED) {
99 mProfileSyncService.flushDirectory(); 99 mProfileSyncService.flushDirectory();
100 } 100 }
101 } 101 }
102 }); 102 });
103 103
104 GmsCoreSyncListener gmsCoreSyncListener = 104 GmsCoreSyncListener gmsCoreSyncListener = AppGlobals.get().createGmsCore SyncListener();
105 ((ChromeApplication) context.getApplicationContext()).createGmsC oreSyncListener();
106 if (gmsCoreSyncListener != null) { 105 if (gmsCoreSyncListener != null) {
107 mProfileSyncService.addSyncStateChangedListener(gmsCoreSyncListener) ; 106 mProfileSyncService.addSyncStateChangedListener(gmsCoreSyncListener) ;
108 } 107 }
109 108
110 SigninManager.get(mContext).addSignInStateObserver(new SigninManager.Sig nInStateObserver() { 109 SigninManager.get(mContext).addSignInStateObserver(new SigninManager.Sig nInStateObserver() {
111 @Override 110 @Override
112 public void onSignedIn() { 111 public void onSignedIn() {
113 mProfileSyncService.requestStart(); 112 mProfileSyncService.requestStart();
114 } 113 }
115 114
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 UniqueIdentificationGeneratorFactory.getInstance(GENERATOR_ID); 232 UniqueIdentificationGeneratorFactory.getInstance(GENERATOR_ID);
234 String uniqueTag = generator.getUniqueId(null); 233 String uniqueTag = generator.getUniqueId(null);
235 if (uniqueTag.isEmpty()) { 234 if (uniqueTag.isEmpty()) {
236 Log.e(TAG, "Unable to get unique tag for sync. " 235 Log.e(TAG, "Unable to get unique tag for sync. "
237 + "This may lead to unexpected tab sync behavior."); 236 + "This may lead to unexpected tab sync behavior.");
238 return; 237 return;
239 } 238 }
240 mProfileSyncService.setSessionsId(SESSION_TAG_PREFIX + uniqueTag); 239 mProfileSyncService.setSessionsId(SESSION_TAG_PREFIX + uniqueTag);
241 } 240 }
242 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698