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

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 if (HasSyncingEngine()) { 706 if (HasSyncingEngine()) {
707 RequestAccessToken(); 707 RequestAccessToken();
708 } else { 708 } else {
709 startup_controller_->TryStart(); 709 startup_controller_->TryStart();
710 } 710 }
711 } 711 }
712 712
713 void ProfileSyncService::Shutdown() { 713 void ProfileSyncService::Shutdown() {
714 DCHECK(thread_checker_.CalledOnValidThread()); 714 DCHECK(thread_checker_.CalledOnValidThread());
715 UnregisterAuthNotifications(); 715 UnregisterAuthNotifications();
716 NotifyShutdown();
skym 2017/01/26 17:00:37 Having this right before ShutdownImpl(...), which
Steven Holte 2017/01/26 20:31:47 Done.
716 717
717 ShutdownImpl(syncer::BROWSER_SHUTDOWN); 718 ShutdownImpl(syncer::BROWSER_SHUTDOWN);
718 if (sync_error_controller_) { 719 if (sync_error_controller_) {
719 // Destroy the SyncErrorController when the service shuts down for good. 720 // Destroy the SyncErrorController when the service shuts down for good.
720 RemoveObserver(sync_error_controller_.get()); 721 RemoveObserver(sync_error_controller_.get());
skym 2017/01/26 17:00:37 Ugh. I guess this could be done with the OnSyncShu
Steven Holte 2017/01/26 20:31:47 Acknowledged.
721 sync_error_controller_.reset(); 722 sync_error_controller_.reset();
722 } 723 }
723 724
724 if (sync_thread_) 725 if (sync_thread_)
725 sync_thread_->Stop(); 726 sync_thread_->Stop();
726 } 727 }
727 728
728 void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) { 729 void ProfileSyncService::ShutdownImpl(syncer::ShutdownReason reason) {
729 if (!engine_) { 730 if (!engine_) {
730 if (reason == syncer::ShutdownReason::DISABLE_SYNC && sync_thread_) { 731 if (reason == syncer::ShutdownReason::DISABLE_SYNC && sync_thread_) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 void ProfileSyncService::NotifySyncCycleCompleted() { 848 void ProfileSyncService::NotifySyncCycleCompleted() {
848 for (auto& observer : observers_) 849 for (auto& observer : observers_)
849 observer.OnSyncCycleCompleted(); 850 observer.OnSyncCycleCompleted();
850 } 851 }
851 852
852 void ProfileSyncService::NotifyForeignSessionUpdated() { 853 void ProfileSyncService::NotifyForeignSessionUpdated() {
853 for (auto& observer : observers_) 854 for (auto& observer : observers_)
854 observer.OnForeignSessionUpdated(); 855 observer.OnForeignSessionUpdated();
855 } 856 }
856 857
858 void ProfileSyncService::NotifyShutdown() {
859 for (auto& observer : observers_)
860 observer.OnSyncShutdown(this);
861 }
862
857 void ProfileSyncService::ClearStaleErrors() { 863 void ProfileSyncService::ClearStaleErrors() {
858 ClearUnrecoverableError(); 864 ClearUnrecoverableError();
859 last_actionable_error_ = SyncProtocolError(); 865 last_actionable_error_ = SyncProtocolError();
860 // Clear the data type errors as well. 866 // Clear the data type errors as well.
861 if (data_type_manager_.get()) 867 if (data_type_manager_.get())
862 data_type_manager_->ResetDataTypeErrors(); 868 data_type_manager_->ResetDataTypeErrors();
863 } 869 }
864 870
865 void ProfileSyncService::ClearUnrecoverableError() { 871 void ProfileSyncService::ClearUnrecoverableError() {
866 unrecoverable_error_reason_ = ERROR_REASON_UNSET; 872 unrecoverable_error_reason_ = ERROR_REASON_UNSET;
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); 1372 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta);
1367 } else { 1373 } else {
1368 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta); 1374 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta);
1369 } 1375 }
1370 } 1376 }
1371 sync_configure_start_time_ = base::Time(); 1377 sync_configure_start_time_ = base::Time();
1372 } 1378 }
1373 1379
1374 // Notify listeners that configuration is done. 1380 // Notify listeners that configuration is done.
1375 for (auto& observer : observers_) 1381 for (auto& observer : observers_)
1376 observer.OnSyncConfigurationCompleted(); 1382 observer.OnSyncConfigurationCompleted(this);
1377 1383
1378 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; 1384 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_;
1379 // The possible status values: 1385 // The possible status values:
1380 // ABORT - Configuration was aborted. This is not an error, if 1386 // ABORT - Configuration was aborted. This is not an error, if
1381 // initiated by user. 1387 // initiated by user.
1382 // OK - Some or all types succeeded. 1388 // OK - Some or all types succeeded.
1383 // Everything else is an UnrecoverableError. So treat it as such. 1389 // Everything else is an UnrecoverableError. So treat it as such.
1384 1390
1385 // First handle the abort case. 1391 // First handle the abort case.
1386 if (configure_status_ == DataTypeManager::ABORTED && 1392 if (configure_status_ == DataTypeManager::ABORTED &&
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 2641
2636 DCHECK(startup_controller_->IsSetupInProgress()); 2642 DCHECK(startup_controller_->IsSetupInProgress());
2637 startup_controller_->SetSetupInProgress(false); 2643 startup_controller_->SetSetupInProgress(false);
2638 2644
2639 if (IsEngineInitialized()) 2645 if (IsEngineInitialized())
2640 ReconfigureDatatypeManager(); 2646 ReconfigureDatatypeManager();
2641 NotifyObservers(); 2647 NotifyObservers();
2642 } 2648 }
2643 2649
2644 } // namespace browser_sync 2650 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698