Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 OnCommitCountersUpdated(type, counters)); | 549 OnCommitCountersUpdated(type, counters)); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( | 552 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( |
| 553 syncer::ModelType type, | 553 syncer::ModelType type, |
| 554 const syncer::UpdateCounters& counters) { | 554 const syncer::UpdateCounters& counters) { |
| 555 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, | 555 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
| 556 OnUpdateCountersUpdated(type, counters)); | 556 OnUpdateCountersUpdated(type, counters)); |
| 557 } | 557 } |
| 558 | 558 |
| 559 void ProfileSyncService::OnDirectoryTypeStatusCounterUpdated( | 559 void ProfileSyncService::OnDatatypeStatusCounterUpdated( |
| 560 syncer::ModelType type, | 560 syncer::ModelType type, |
| 561 const syncer::StatusCounters& counters) { | 561 std::unique_ptr<syncer::StatusCounters> counters) { |
| 562 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, | 562 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
| 563 OnStatusCountersUpdated(type, counters)); | 563 OnStatusCountersUpdated(type, std::move(counters))); |
|
pavely
2016/09/30 00:01:51
This macro expands into a loop with function invoc
Gang Wu
2016/10/01 07:14:09
my bad, will update.
| |
| 564 } | 564 } |
| 565 | 565 |
| 566 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) { | 566 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) { |
| 567 DCHECK(syncer::UserTypes().Has(type)); | 567 DCHECK(syncer::UserTypes().Has(type)); |
| 568 | 568 |
| 569 if (!GetPreferredDataTypes().Has(type)) { | 569 if (!GetPreferredDataTypes().Has(type)) { |
| 570 // We can get here as datatype SyncableServices are typically wired up | 570 // We can get here as datatype SyncableServices are typically wired up |
| 571 // to the native datatype even if sync isn't enabled. | 571 // to the native datatype even if sync isn't enabled. |
| 572 DVLOG(1) << "Dropping sync startup request because type " | 572 DVLOG(1) << "Dropping sync startup request because type " |
| 573 << syncer::ModelTypeToString(type) << "not enabled."; | 573 << syncer::ModelTypeToString(type) << "not enabled."; |
| (...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1814 | 1814 |
| 1815 void ProfileSyncService::GetModelSafeRoutingInfo( | 1815 void ProfileSyncService::GetModelSafeRoutingInfo( |
| 1816 syncer::ModelSafeRoutingInfo* out) const { | 1816 syncer::ModelSafeRoutingInfo* out) const { |
| 1817 if (backend_.get() && backend_initialized_) { | 1817 if (backend_.get() && backend_initialized_) { |
| 1818 backend_->GetModelSafeRoutingInfo(out); | 1818 backend_->GetModelSafeRoutingInfo(out); |
| 1819 } else { | 1819 } else { |
| 1820 NOTREACHED(); | 1820 NOTREACHED(); |
| 1821 } | 1821 } |
| 1822 } | 1822 } |
| 1823 | 1823 |
| 1824 base::Value* ProfileSyncService::GetTypeStatusMap() const { | 1824 base::Value* ProfileSyncService::GetTypeStatusMap() { |
| 1825 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 1825 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
| 1826 | 1826 |
| 1827 if (!backend_.get() || !backend_initialized_) { | 1827 if (!backend_.get() || !backend_initialized_) { |
| 1828 return result.release(); | 1828 return result.release(); |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 DataTypeStatusTable::TypeErrorMap error_map = | 1831 DataTypeStatusTable::TypeErrorMap error_map = |
| 1832 data_type_status_table_.GetAllErrors(); | 1832 data_type_status_table_.GetAllErrors(); |
| 1833 ModelTypeSet active_types; | 1833 ModelTypeSet active_types; |
| 1834 ModelTypeSet passive_types; | 1834 ModelTypeSet passive_types; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1897 type_status->SetString("value", "Throttled"); | 1897 type_status->SetString("value", "Throttled"); |
| 1898 } else if (active_types.Has(type)) { | 1898 } else if (active_types.Has(type)) { |
| 1899 type_status->SetString("status", "ok"); | 1899 type_status->SetString("status", "ok"); |
| 1900 type_status->SetString( | 1900 type_status->SetString( |
| 1901 "value", "Active: " + ModelSafeGroupToString(routing_info[type])); | 1901 "value", "Active: " + ModelSafeGroupToString(routing_info[type])); |
| 1902 } else { | 1902 } else { |
| 1903 type_status->SetString("status", "warning"); | 1903 type_status->SetString("status", "warning"); |
| 1904 type_status->SetString("value", "Disabled by User"); | 1904 type_status->SetString("value", "Disabled by User"); |
| 1905 } | 1905 } |
| 1906 | 1906 |
| 1907 int live_count = detailed_status.num_entries_by_type[type] - | 1907 const auto& dtc_iter = data_type_controllers_.find(type); |
| 1908 detailed_status.num_to_delete_entries_by_type[type]; | 1908 if (dtc_iter != data_type_controllers_.end()) { |
| 1909 type_status->SetInteger("num_entries", | 1909 dtc_iter->second->GetStatusCounters( |
| 1910 detailed_status.num_entries_by_type[type]); | 1910 base::Bind(&ProfileSyncService::OnDatatypeStatusCounterUpdated, |
| 1911 type_status->SetInteger("num_live", live_count); | 1911 base::Unretained(this))); |
| 1912 } | |
| 1912 | 1913 |
| 1913 result->Append(std::move(type_status)); | 1914 result->Append(std::move(type_status)); |
| 1914 } | 1915 } |
| 1915 return result.release(); | 1916 return result.release(); |
| 1916 } | 1917 } |
| 1917 | 1918 |
| 1918 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { | 1919 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { |
| 1919 // If no cached passphrase, or sync backend hasn't started up yet, just exit. | 1920 // If no cached passphrase, or sync backend hasn't started up yet, just exit. |
| 1920 // If the backend isn't running yet, OnBackendInitialized() will call this | 1921 // If the backend isn't running yet, OnBackendInitialized() will call this |
| 1921 // method again after the backend starts up. | 1922 // method again after the backend starts up. |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2503 if (--outstanding_setup_in_progress_handles_ != 0) | 2504 if (--outstanding_setup_in_progress_handles_ != 0) |
| 2504 return; | 2505 return; |
| 2505 | 2506 |
| 2506 DCHECK(startup_controller_->IsSetupInProgress()); | 2507 DCHECK(startup_controller_->IsSetupInProgress()); |
| 2507 startup_controller_->SetSetupInProgress(false); | 2508 startup_controller_->SetSetupInProgress(false); |
| 2508 | 2509 |
| 2509 if (IsBackendInitialized()) | 2510 if (IsBackendInitialized()) |
| 2510 ReconfigureDatatypeManager(); | 2511 ReconfigureDatatypeManager(); |
| 2511 NotifyObservers(); | 2512 NotifyObservers(); |
| 2512 } | 2513 } |
| OLD | NEW |