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

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

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Chromeos fix 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 } else { 669 } else {
670 startup_controller_->TryStart(); 670 startup_controller_->TryStart();
671 } 671 }
672 } 672 }
673 673
674 void ProfileSyncService::Shutdown() { 674 void ProfileSyncService::Shutdown() {
675 DCHECK(thread_checker_.CalledOnValidThread()); 675 DCHECK(thread_checker_.CalledOnValidThread());
676 UnregisterAuthNotifications(); 676 UnregisterAuthNotifications();
677 677
678 ShutdownImpl(syncer::BROWSER_SHUTDOWN); 678 ShutdownImpl(syncer::BROWSER_SHUTDOWN);
679 NotifyShutdown();
679 if (sync_error_controller_) { 680 if (sync_error_controller_) {
680 // Destroy the SyncErrorController when the service shuts down for good. 681 // Destroy the SyncErrorController when the service shuts down for good.
681 RemoveObserver(sync_error_controller_.get()); 682 RemoveObserver(sync_error_controller_.get());
682 sync_error_controller_.reset(); 683 sync_error_controller_.reset();
683 } 684 }
684 685
685 if (sync_thread_) 686 if (sync_thread_)
686 sync_thread_->Stop(); 687 sync_thread_->Stop();
687 } 688 }
688 689
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 ReconfigureDatatypeManager(); 791 ReconfigureDatatypeManager();
791 } 792 }
792 } 793 }
793 794
794 void ProfileSyncService::UpdateLastSyncedTime() { 795 void ProfileSyncService::UpdateLastSyncedTime() {
795 sync_prefs_.SetLastSyncedTime(base::Time::Now()); 796 sync_prefs_.SetLastSyncedTime(base::Time::Now());
796 } 797 }
797 798
798 void ProfileSyncService::NotifySyncCycleCompleted() { 799 void ProfileSyncService::NotifySyncCycleCompleted() {
799 for (auto& observer : observers_) 800 for (auto& observer : observers_)
800 observer.OnSyncCycleCompleted(); 801 observer.OnSyncCycleCompleted(this);
801 } 802 }
802 803
803 void ProfileSyncService::NotifyForeignSessionUpdated() { 804 void ProfileSyncService::NotifyForeignSessionUpdated() {
804 for (auto& observer : observers_) 805 for (auto& observer : observers_)
805 observer.OnForeignSessionUpdated(); 806 observer.OnForeignSessionUpdated(this);
807 }
808
809 void ProfileSyncService::NotifyShutdown() {
810 for (auto& observer : observers_)
811 observer.OnSyncShutdown(this);
806 } 812 }
807 813
808 void ProfileSyncService::ClearStaleErrors() { 814 void ProfileSyncService::ClearStaleErrors() {
809 ClearUnrecoverableError(); 815 ClearUnrecoverableError();
810 last_actionable_error_ = SyncProtocolError(); 816 last_actionable_error_ = SyncProtocolError();
811 // Clear the data type errors as well. 817 // Clear the data type errors as well.
812 if (data_type_manager_.get()) 818 if (data_type_manager_.get())
813 data_type_manager_->ResetDataTypeErrors(); 819 data_type_manager_->ResetDataTypeErrors();
814 } 820 }
815 821
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); 1218 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta);
1213 } else { 1219 } else {
1214 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta); 1220 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta);
1215 } 1221 }
1216 } 1222 }
1217 sync_configure_start_time_ = base::Time(); 1223 sync_configure_start_time_ = base::Time();
1218 } 1224 }
1219 1225
1220 // Notify listeners that configuration is done. 1226 // Notify listeners that configuration is done.
1221 for (auto& observer : observers_) 1227 for (auto& observer : observers_)
1222 observer.OnSyncConfigurationCompleted(); 1228 observer.OnSyncConfigurationCompleted(this);
1223 1229
1224 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; 1230 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_;
1225 // The possible status values: 1231 // The possible status values:
1226 // ABORT - Configuration was aborted. This is not an error, if 1232 // ABORT - Configuration was aborted. This is not an error, if
1227 // initiated by user. 1233 // initiated by user.
1228 // OK - Some or all types succeeded. 1234 // OK - Some or all types succeeded.
1229 // Everything else is an UnrecoverableError. So treat it as such. 1235 // Everything else is an UnrecoverableError. So treat it as such.
1230 1236
1231 // First handle the abort case. 1237 // First handle the abort case.
1232 if (configure_status_ == DataTypeManager::ABORTED && 1238 if (configure_status_ == DataTypeManager::ABORTED &&
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 2420
2415 DCHECK(startup_controller_->IsSetupInProgress()); 2421 DCHECK(startup_controller_->IsSetupInProgress());
2416 startup_controller_->SetSetupInProgress(false); 2422 startup_controller_->SetSetupInProgress(false);
2417 2423
2418 if (IsEngineInitialized()) 2424 if (IsEngineInitialized())
2419 ReconfigureDatatypeManager(); 2425 ReconfigureDatatypeManager();
2420 NotifyObservers(); 2426 NotifyObservers();
2421 } 2427 }
2422 2428
2423 } // namespace browser_sync 2429 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/profile_sync_service.h ('k') | components/browser_sync/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698