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 21 matching lines...) Expand all Loading... | |
32 #include "components/invalidation/public/invalidation_service.h" | 32 #include "components/invalidation/public/invalidation_service.h" |
33 #include "components/pref_registry/pref_registry_syncable.h" | 33 #include "components/pref_registry/pref_registry_syncable.h" |
34 #include "components/prefs/json_pref_store.h" | 34 #include "components/prefs/json_pref_store.h" |
35 #include "components/signin/core/browser/about_signin_internals.h" | 35 #include "components/signin/core/browser/about_signin_internals.h" |
36 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
37 #include "components/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" |
38 #include "components/signin/core/browser/signin_metrics.h" | 38 #include "components/signin/core/browser/signin_metrics.h" |
39 #include "components/strings/grit/components_strings.h" | 39 #include "components/strings/grit/components_strings.h" |
40 #include "components/sync/api/model_type_store.h" | 40 #include "components/sync/api/model_type_store.h" |
41 #include "components/sync/api/sync_error.h" | 41 #include "components/sync/api/sync_error.h" |
42 #include "components/sync/base/bind_to_task_runner.h" | |
42 #include "components/sync/base/cryptographer.h" | 43 #include "components/sync/base/cryptographer.h" |
43 #include "components/sync/base/passphrase_type.h" | 44 #include "components/sync/base/passphrase_type.h" |
44 #include "components/sync/base/stop_source.h" | 45 #include "components/sync/base/stop_source.h" |
45 #include "components/sync/base/sync_db_util.h" | 46 #include "components/sync/base/sync_db_util.h" |
46 #include "components/sync/core/configure_reason.h" | 47 #include "components/sync/core/configure_reason.h" |
47 #include "components/sync/core/http_bridge_network_resources.h" | 48 #include "components/sync/core/http_bridge_network_resources.h" |
48 #include "components/sync/core/network_resources.h" | 49 #include "components/sync/core/network_resources.h" |
49 #include "components/sync/core/shared_model_type_processor.h" | 50 #include "components/sync/core/shared_model_type_processor.h" |
50 #include "components/sync/core/sync_encryption_handler.h" | 51 #include "components/sync/core/sync_encryption_handler.h" |
51 #include "components/sync/device_info/device_info.h" | 52 #include "components/sync/device_info/device_info.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 OnCommitCountersUpdated(type, counters)); | 540 OnCommitCountersUpdated(type, counters)); |
540 } | 541 } |
541 | 542 |
542 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( | 543 void ProfileSyncService::OnDirectoryTypeUpdateCounterUpdated( |
543 syncer::ModelType type, | 544 syncer::ModelType type, |
544 const syncer::UpdateCounters& counters) { | 545 const syncer::UpdateCounters& counters) { |
545 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, | 546 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
546 OnUpdateCountersUpdated(type, counters)); | 547 OnUpdateCountersUpdated(type, counters)); |
547 } | 548 } |
548 | 549 |
549 void ProfileSyncService::OnDirectoryTypeStatusCounterUpdated( | 550 void ProfileSyncService::OnDatatypeStatusCounterUpdated( |
550 syncer::ModelType type, | 551 syncer::ModelType type, |
551 const syncer::StatusCounters& counters) { | 552 const syncer::StatusCounters& counters) { |
552 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, | 553 FOR_EACH_OBSERVER(syncer::TypeDebugInfoObserver, type_debug_info_observers_, |
553 OnStatusCountersUpdated(type, counters)); | 554 OnStatusCountersUpdated(type, counters)); |
554 } | 555 } |
555 | 556 |
556 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) { | 557 void ProfileSyncService::OnDataTypeRequestsSyncStartup(syncer::ModelType type) { |
557 DCHECK(syncer::UserTypes().Has(type)); | 558 DCHECK(syncer::UserTypes().Has(type)); |
558 | 559 |
559 if (!GetPreferredDataTypes().Has(type)) { | 560 if (!GetPreferredDataTypes().Has(type)) { |
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1802 | 1803 |
1803 void ProfileSyncService::GetModelSafeRoutingInfo( | 1804 void ProfileSyncService::GetModelSafeRoutingInfo( |
1804 syncer::ModelSafeRoutingInfo* out) const { | 1805 syncer::ModelSafeRoutingInfo* out) const { |
1805 if (backend_.get() && backend_initialized_) { | 1806 if (backend_.get() && backend_initialized_) { |
1806 backend_->GetModelSafeRoutingInfo(out); | 1807 backend_->GetModelSafeRoutingInfo(out); |
1807 } else { | 1808 } else { |
1808 NOTREACHED(); | 1809 NOTREACHED(); |
1809 } | 1810 } |
1810 } | 1811 } |
1811 | 1812 |
1812 base::Value* ProfileSyncService::GetTypeStatusMap() const { | 1813 base::Value* ProfileSyncService::GetTypeStatusMap() { |
1813 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 1814 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
1814 | 1815 |
1815 if (!backend_.get() || !backend_initialized_) { | 1816 if (!backend_.get() || !backend_initialized_) { |
1816 return result.release(); | 1817 return result.release(); |
1817 } | 1818 } |
1818 | 1819 |
1819 DataTypeStatusTable::TypeErrorMap error_map = | 1820 DataTypeStatusTable::TypeErrorMap error_map = |
1820 data_type_status_table_.GetAllErrors(); | 1821 data_type_status_table_.GetAllErrors(); |
1821 ModelTypeSet active_types; | 1822 ModelTypeSet active_types; |
1822 ModelTypeSet passive_types; | 1823 ModelTypeSet passive_types; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1885 type_status->SetString("value", "Throttled"); | 1886 type_status->SetString("value", "Throttled"); |
1886 } else if (active_types.Has(type)) { | 1887 } else if (active_types.Has(type)) { |
1887 type_status->SetString("status", "ok"); | 1888 type_status->SetString("status", "ok"); |
1888 type_status->SetString( | 1889 type_status->SetString( |
1889 "value", "Active: " + ModelSafeGroupToString(routing_info[type])); | 1890 "value", "Active: " + ModelSafeGroupToString(routing_info[type])); |
1890 } else { | 1891 } else { |
1891 type_status->SetString("status", "warning"); | 1892 type_status->SetString("status", "warning"); |
1892 type_status->SetString("value", "Disabled by User"); | 1893 type_status->SetString("value", "Disabled by User"); |
1893 } | 1894 } |
1894 | 1895 |
1895 int live_count = detailed_status.num_entries_by_type[type] - | 1896 const auto& dtc_iter = data_type_controllers_.find(type); |
1896 detailed_status.num_to_delete_entries_by_type[type]; | 1897 if (dtc_iter != data_type_controllers_.end()) { |
1897 type_status->SetInteger("num_entries", | 1898 // OnDatatypeStatusCounterUpdated that posts back to the UI thread. |
maxbogue
2016/10/06 17:16:32
"OnDatatypeStatusCounterUpdated that posts back to
Gang Wu
2016/10/07 03:59:43
Done.
| |
1898 detailed_status.num_entries_by_type[type]); | 1899 dtc_iter->second->GetStatusCounters(BindToCurrentThread( |
1899 type_status->SetInteger("num_live", live_count); | 1900 base::Bind(&ProfileSyncService::OnDatatypeStatusCounterUpdated, |
1901 base::Unretained(this)))); | |
1902 } | |
1900 | 1903 |
1901 result->Append(std::move(type_status)); | 1904 result->Append(std::move(type_status)); |
1902 } | 1905 } |
1903 return result.release(); | 1906 return result.release(); |
1904 } | 1907 } |
1905 | 1908 |
1906 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { | 1909 void ProfileSyncService::ConsumeCachedPassphraseIfPossible() { |
1907 // If no cached passphrase, or sync backend hasn't started up yet, just exit. | 1910 // If no cached passphrase, or sync backend hasn't started up yet, just exit. |
1908 // If the backend isn't running yet, OnBackendInitialized() will call this | 1911 // If the backend isn't running yet, OnBackendInitialized() will call this |
1909 // method again after the backend starts up. | 1912 // method again after the backend starts up. |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2491 | 2494 |
2492 DCHECK(startup_controller_->IsSetupInProgress()); | 2495 DCHECK(startup_controller_->IsSetupInProgress()); |
2493 startup_controller_->SetSetupInProgress(false); | 2496 startup_controller_->SetSetupInProgress(false); |
2494 | 2497 |
2495 if (IsBackendInitialized()) | 2498 if (IsBackendInitialized()) |
2496 ReconfigureDatatypeManager(); | 2499 ReconfigureDatatypeManager(); |
2497 NotifyObservers(); | 2500 NotifyObservers(); |
2498 } | 2501 } |
2499 | 2502 |
2500 } // namespace browser_sync | 2503 } // namespace browser_sync |
OLD | NEW |