Skip to content

Commit

Permalink
WIP - fix crash of double added observer
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBarabash committed Jun 10, 2020
1 parent d8fd634 commit e80f429
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ public boolean shouldLoadDevices() {
//mainActivity.mBraveSyncWorker.InitV2(mSyncScreensObserver);
mainActivity.mBraveSyncWorker.InitScreensObserver(mSyncScreensObserver);

// TODO, AB: need to split sync state observer and devices observer
mainActivity.mBraveSyncWorker.HandleShowSetupUI();
}
// TODO(sergz): Uncomment sync service impl when we fully migrate on sync v2
Expand Down
7 changes: 5 additions & 2 deletions browser/android/brave_sync_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DLOG(ERROR) << "[BraveSync] " << __func__ << " ProfileSyncServiceFactory::GetFor
// See PeopleHandler::HandleShowSetupUI
void BraveSyncWorker::HandleShowSetupUI(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller) {

DLOG(ERROR) << "[BraveSync] " << __func__ << " 000";
syncer::SyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile_);

Expand All @@ -133,10 +133,13 @@ void BraveSyncWorker::HandleShowSetupUI(JNIEnv* env,
DeviceInfoSyncServiceFactory::GetForProfile(profile_)
->GetDeviceInfoTracker();
DCHECK(tracker);
if (tracker) {
if (tracker && !device_info_tracker_observer_.IsObserving(tracker) ) {
device_info_tracker_observer_.Add(tracker);
}

// TODO, AB: call SetSyncRequested(true) and sync_service_observer_ must be set and only if sync is not enabled
// The point when it is invoked when sync is enabled is above on the stack

// Mark Sync as requested by the user. It might already be requested, but
// it's not if this is either the first time the user is setting up Sync, or
// Sync was set up but then was reset via the dashboard. This also pokes the
Expand Down

0 comments on commit e80f429

Please sign in to comment.