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

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

Issue 2427913002: Reduce usage of FOR_EACH_OBSERVER macro in components/invalidation (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | components/invalidation/impl/invalidation_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const { 522 bool ProfileSyncService::IsEncryptedDatatypeEnabled() const {
523 if (encryption_pending()) 523 if (encryption_pending())
524 return true; 524 return true;
525 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); 525 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes();
526 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes(); 526 const syncer::ModelTypeSet encrypted_types = GetEncryptedDataTypes();
527 DCHECK(encrypted_types.Has(syncer::PASSWORDS)); 527 DCHECK(encrypted_types.Has(syncer::PASSWORDS));
528 return !Intersection(preferred_types, encrypted_types).Empty(); 528 return !Intersection(preferred_types, encrypted_types).Empty();
529 } 529 }
530 530
531 void ProfileSyncService::OnProtocolEvent(const syncer::ProtocolEvent& event) { 531 void ProfileSyncService::OnProtocolEvent(const syncer::ProtocolEvent& event) {
532 FOR_EACH_OBSERVER(ProtocolEventObserver, protocol_event_observers_, 532 for (auto& observer : protocol_event_observers_)
533 OnProtocolEvent(event)); 533 observer.OnProtocolEvent(event);
534 } 534 }
535 535
536 void ProfileSyncService::OnDirectoryTypeCommitCounterUpdated( 536 void ProfileSyncService::OnDirectoryTypeCommitCounterUpdated(
537 syncer::ModelType type, 537 syncer::ModelType type,
538 const syncer::CommitCounters& counters) { 538 const syncer::CommitCounters& counters) {
539 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, 539 for (auto& observer : type_debug_info_observers_)
540 OnCommitCountersUpdated(type, counters)); 540 observer.OnCommitCountersUpdated(type, counters);
541 } 541 }
542 542
543 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( 543 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated(
544 syncer::ModelType type, 544 syncer::ModelType type,
545 const syncer::UpdateCounters& counters) { 545 const syncer::UpdateCounters& counters) {
546 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, 546 for (auto& observer : type_debug_info_observers_)
547 OnUpdateCountersUpdated(type, counters)); 547 observer.OnUpdateCountersUpdated(type, counters);
548 } 548 }
549 549
550 void ProfileSyncService::OnDatatypeStatusCounterUpdated( 550 void ProfileSyncService::OnDatatypeStatusCounterUpdated(
551 syncer::ModelType type, 551 syncer::ModelType type,
552 const syncer::StatusCounters& counters) { 552 const syncer::StatusCounters& counters) {
553 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, 553 for (auto& observer : type_debug_info_observers_)
554 OnStatusCountersUpdated(type, counters)); 554 observer.OnStatusCountersUpdated(type, counters);
555 } 555 }
556 556
557 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) { 557 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) {
558 DCHECK(syncer::UserTypes().Has(type)); 558 DCHECK(syncer::UserTypes().Has(type));
559 559
560 if (!GetPreferredDataTypes().Has(type)) { 560 if (!GetPreferredDataTypes().Has(type)) {
561 // We can get here as datatype SyncableServices are typically wired up 561 // We can get here as datatype SyncableServices are typically wired up
562 // to the native datatype even if sync isn't enabled. 562 // to the native datatype even if sync isn't enabled.
563 DVLOG(1) << "Dropping sync startup request because type " 563 DVLOG(1) << "Dropping sync startup request because type "
564 << syncer::ModelTypeToString(type) << "not enabled."; 564 << syncer::ModelTypeToString(type) << "not enabled.";
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 if (IsBackendInitialized()) { 824 if (IsBackendInitialized()) {
825 ReconfigureDatatypeManager(); 825 ReconfigureDatatypeManager();
826 } 826 }
827 } 827 }
828 828
829 void ProfileSyncService::UpdateLastSyncedTime() { 829 void ProfileSyncService::UpdateLastSyncedTime() {
830 sync_prefs_.SetLastSyncedTime(base::Time::Now()); 830 sync_prefs_.SetLastSyncedTime(base::Time::Now());
831 } 831 }
832 832
833 void ProfileSyncService::NotifyObservers() { 833 void ProfileSyncService::NotifyObservers() {
834 FOR_EACH_OBSERVER(syncer::SyncServiceObserver, observers_, OnStateChanged()); 834 for (auto& observer : observers_)
835 observer.OnStateChanged();
835 } 836 }
836 837
837 void ProfileSyncService::NotifySyncCycleCompleted() { 838 void ProfileSyncService::NotifySyncCycleCompleted() {
838 FOR_EACH_OBSERVER(syncer::SyncServiceObserver, observers_, 839 for (auto& observer : observers_)
839 OnSyncCycleCompleted()); 840 observer.OnSyncCycleCompleted();
840 } 841 }
841 842
842 void ProfileSyncService::NotifyForeignSessionUpdated() { 843 void ProfileSyncService::NotifyForeignSessionUpdated() {
843 FOR_EACH_OBSERVER(syncer::SyncServiceObserver, observers_, 844 for (auto& observer : observers_)
844 OnForeignSessionUpdated()); 845 observer.OnForeignSessionUpdated();
845 } 846 }
846 847
847 void ProfileSyncService::ClearStaleErrors() { 848 void ProfileSyncService::ClearStaleErrors() {
848 ClearUnrecoverableError(); 849 ClearUnrecoverableError();
849 last_actionable_error_ = SyncProtocolError(); 850 last_actionable_error_ = SyncProtocolError();
850 // Clear the data type errors as well. 851 // Clear the data type errors as well.
851 if (data_type_manager_.get()) 852 if (data_type_manager_.get())
852 data_type_manager_->ResetDataTypeErrors(); 853 data_type_manager_->ResetDataTypeErrors();
853 } 854 }
854 855
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 if (is_first_time_sync_configure_) { 1323 if (is_first_time_sync_configure_) {
1323 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); 1324 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta);
1324 } else { 1325 } else {
1325 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta); 1326 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", delta);
1326 } 1327 }
1327 } 1328 }
1328 sync_configure_start_time_ = base::Time(); 1329 sync_configure_start_time_ = base::Time();
1329 } 1330 }
1330 1331
1331 // Notify listeners that configuration is done. 1332 // Notify listeners that configuration is done.
1332 FOR_EACH_OBSERVER(syncer::SyncServiceObserver, observers_, 1333 for (auto& observer : observers_)
1333 OnSyncConfigurationCompleted()); 1334 observer.OnSyncConfigurationCompleted();
1334 1335
1335 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; 1336 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_;
1336 // The possible status values: 1337 // The possible status values:
1337 // ABORT - Configuration was aborted. This is not an error, if 1338 // ABORT - Configuration was aborted. This is not an error, if
1338 // initiated by user. 1339 // initiated by user.
1339 // OK - Some or all types succeeded. 1340 // OK - Some or all types succeeded.
1340 // Everything else is an UnrecoverableError. So treat it as such. 1341 // Everything else is an UnrecoverableError. So treat it as such.
1341 1342
1342 // First handle the abort case. 1343 // First handle the abort case.
1343 if (configure_status_ == DataTypeManager::ABORTED && 1344 if (configure_status_ == DataTypeManager::ABORTED &&
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 2499
2499 DCHECK(startup_controller_->IsSetupInProgress()); 2500 DCHECK(startup_controller_->IsSetupInProgress());
2500 startup_controller_->SetSetupInProgress(false); 2501 startup_controller_->SetSetupInProgress(false);
2501 2502
2502 if (IsBackendInitialized()) 2503 if (IsBackendInitialized())
2503 ReconfigureDatatypeManager(); 2504 ReconfigureDatatypeManager();
2504 NotifyObservers(); 2505 NotifyObservers();
2505 } 2506 }
2506 2507
2507 } // namespace browser_sync 2508 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | components/invalidation/impl/invalidation_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698