[sync] Eliminate SYNC_CONFIGURE_DONE notification
This CL ports the listeners of the SYNC_CONFIGURE_DONE notification to instead
observe the equivalent SyncServiceObserver callback and eliminates that
notification from the codebase.
The concrete motivation is to remove //content dependencies from
ProfileSyncService in order to enable clean integration on iOS.
BUG=518825
TBR=jochen
Review URL: https://codereview.chromium.org/1422813002
Cr-Commit-Position: refs/heads/master@{#356560}
diff --git a/chrome/browser/android/foreign_session_helper.cc b/chrome/browser/android/foreign_session_helper.cc
index 5388d83..058b196 100644
--- a/chrome/browser/android/foreign_session_helper.cc
+++ b/chrome/browser/android/foreign_session_helper.cc
@@ -151,11 +151,14 @@
}
ForeignSessionHelper::ForeignSessionHelper(Profile* profile)
- : profile_(profile) {
+ : profile_(profile), scoped_observer_(this) {
ProfileSyncService* service = ProfileSyncServiceFactory::GetInstance()->
GetForProfile(profile);
- registrar_.Add(this, chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
- content::Source<ProfileSyncService>(service));
+
+ // NOTE: The ProfileSyncService can be null in tests.
+ if (service)
+ scoped_observer_.Add(service);
+
registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
content::Source<Profile>(profile));
}
@@ -187,24 +190,30 @@
callback_.Reset(env, callback);
}
-void ForeignSessionHelper::Observe(
- int type, const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void ForeignSessionHelper::FireForeignSessionCallback() {
if (callback_.is_null())
return;
JNIEnv* env = AttachCurrentThread();
+ Java_ForeignSessionCallback_onUpdated(env, callback_.obj());
+}
+void ForeignSessionHelper::Observe(
+ int type, const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
switch (type) {
- case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE:
case chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED:
- Java_ForeignSessionCallback_onUpdated(env, callback_.obj());
+ FireForeignSessionCallback();
break;
default:
NOTREACHED();
}
}
+void ForeignSessionHelper::OnSyncConfigurationCompleted() {
+ FireForeignSessionCallback();
+}
+
jboolean ForeignSessionHelper::GetForeignSessions(JNIEnv* env,
jobject obj,
jobject result) {