use of org.chromium.chrome.browser.sync.ProfileSyncService in project AndroidChromium by JackyAndroid.
the class ChromeActivity method createContextReporterIfNeeded.
private void createContextReporterIfNeeded() {
if (mContextReporter != null || getActivityTab() == null)
return;
final SyncController syncController = SyncController.get(this);
final ProfileSyncService syncService = ProfileSyncService.get();
if (syncController != null && syncController.isSyncingUrlsWithKeystorePassphrase()) {
assert syncService != null;
mContextReporter = ((ChromeApplication) getApplicationContext()).createGsaHelper().getContextReporter(this);
if (mSyncStateChangedListener != null) {
syncService.removeSyncStateChangedListener(mSyncStateChangedListener);
mSyncStateChangedListener = null;
}
return;
} else {
ContextReporter.reportSyncStatus(syncService);
}
if (mSyncStateChangedListener == null && syncService != null) {
mSyncStateChangedListener = new ProfileSyncService.SyncStateChangedListener() {
@Override
public void syncStateChanged() {
createContextReporterIfNeeded();
}
};
syncService.addSyncStateChangedListener(mSyncStateChangedListener);
}
}
use of org.chromium.chrome.browser.sync.ProfileSyncService in project AndroidChromium by JackyAndroid.
the class InvalidationController method ensureStartedAndUpdateRegisteredTypes.
/**
* Updates the sync invalidation types that the client is registered for based on the preferred
* sync types. Starts the client if needed.
*/
public void ensureStartedAndUpdateRegisteredTypes() {
ProfileSyncService syncService = ProfileSyncService.get();
if (syncService == null)
return;
mStarted = true;
// Ensure GCM has been initialized.
ensureGcmIsInitialized();
// Do not apply changes to {@link #mSessionInvalidationsEnabled} yet because the timer task
// may be scheduled far into the future.
mEnableSessionInvalidationsTimer.resume();
HashSet<Integer> typesToRegister = new HashSet<Integer>();
typesToRegister.addAll(syncService.getPreferredDataTypes());
if (!mSessionInvalidationsEnabled) {
typesToRegister.remove(ModelType.SESSIONS);
typesToRegister.remove(ModelType.FAVICON_TRACKING);
typesToRegister.remove(ModelType.FAVICON_IMAGES);
}
Intent registerIntent = InvalidationIntentProtocol.createRegisterIntent(ChromeSigninController.get(mContext).getSignedInUser(), typesToRegister);
registerIntent.setClass(mContext, InvalidationClientService.getRegisteredClass());
mContext.startService(registerIntent);
}
Aggregations