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

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 408003002: [Sync] Fix namespace for sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 5 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 | Annotate | Revision Log
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 "chrome/browser/sync/profile_sync_service.h" 5 #include "chrome/browser/sync/profile_sync_service.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 #include "sync/internal_api/public/util/sync_string_conversions.h" 95 #include "sync/internal_api/public/util/sync_string_conversions.h"
96 #include "sync/js/js_event_details.h" 96 #include "sync/js/js_event_details.h"
97 #include "sync/util/cryptographer.h" 97 #include "sync/util/cryptographer.h"
98 #include "ui/base/l10n/l10n_util.h" 98 #include "ui/base/l10n/l10n_util.h"
99 #include "ui/base/l10n/time_format.h" 99 #include "ui/base/l10n/time_format.h"
100 100
101 #if defined(OS_ANDROID) 101 #if defined(OS_ANDROID)
102 #include "sync/internal_api/public/read_transaction.h" 102 #include "sync/internal_api/public/read_transaction.h"
103 #endif 103 #endif
104 104
105 using browser_sync::ChangeProcessor;
106 using browser_sync::DataTypeController;
107 using browser_sync::DataTypeManager;
108 using browser_sync::FailedDataTypesHandler;
109 using browser_sync::NotificationServiceSessionsRouter; 105 using browser_sync::NotificationServiceSessionsRouter;
110 using browser_sync::ProfileSyncServiceStartBehavior; 106 using browser_sync::ProfileSyncServiceStartBehavior;
111 using browser_sync::SyncBackendHost; 107 using browser_sync::SyncBackendHost;
108 using sync_driver::ChangeProcessor;
109 using sync_driver::DataTypeController;
110 using sync_driver::DataTypeManager;
111 using sync_driver::FailedDataTypesHandler;
112 using syncer::ModelType; 112 using syncer::ModelType;
113 using syncer::ModelTypeSet; 113 using syncer::ModelTypeSet;
114 using syncer::JsBackend; 114 using syncer::JsBackend;
115 using syncer::JsController; 115 using syncer::JsController;
116 using syncer::JsEventDetails; 116 using syncer::JsEventDetails;
117 using syncer::JsEventHandler; 117 using syncer::JsEventHandler;
118 using syncer::ModelSafeRoutingInfo; 118 using syncer::ModelSafeRoutingInfo;
119 using syncer::SyncCredentials; 119 using syncer::SyncCredentials;
120 using syncer::SyncProtocolError; 120 using syncer::SyncProtocolError;
121 using syncer::WeakHandle; 121 using syncer::WeakHandle;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 if (HasSyncingBackend()) { 489 if (HasSyncingBackend()) {
490 browser_sync::SyncedDeviceTracker* device_tracker = 490 browser_sync::SyncedDeviceTracker* device_tracker =
491 backend_->GetSyncedDeviceTracker(); 491 backend_->GetSyncedDeviceTracker();
492 if (device_tracker) { 492 if (device_tracker) {
493 device_tracker->RemoveObserver(observer); 493 device_tracker->RemoveObserver(observer);
494 } 494 }
495 } 495 }
496 } 496 }
497 497
498 void ProfileSyncService::GetDataTypeControllerStates( 498 void ProfileSyncService::GetDataTypeControllerStates(
499 browser_sync::DataTypeController::StateMap* state_map) const { 499 DataTypeController::StateMap* state_map) const {
500 for (browser_sync::DataTypeController::TypeMap::const_iterator iter = 500 for (DataTypeController::TypeMap::const_iterator iter =
501 directory_data_type_controllers_.begin(); 501 directory_data_type_controllers_.begin();
502 iter != directory_data_type_controllers_.end(); 502 iter != directory_data_type_controllers_.end();
503 ++iter) 503 ++iter)
504 (*state_map)[iter->first] = iter->second.get()->state(); 504 (*state_map)[iter->first] = iter->second.get()->state();
505 } 505 }
506 506
507 SyncCredentials ProfileSyncService::GetCredentials() { 507 SyncCredentials ProfileSyncService::GetCredentials() {
508 SyncCredentials credentials; 508 SyncCredentials credentials;
509 if (backend_mode_ == SYNC) { 509 if (backend_mode_ == SYNC) {
510 credentials.email = signin_->GetEffectiveUsername(); 510 credentials.email = signin_->GetEffectiveUsername();
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 break; 1450 break;
1451 default: 1451 default:
1452 NOTREACHED(); 1452 NOTREACHED();
1453 } 1453 }
1454 NotifyObservers(); 1454 NotifyObservers();
1455 1455
1456 backup_rollback_controller_.Start(base::TimeDelta()); 1456 backup_rollback_controller_.Start(base::TimeDelta());
1457 } 1457 }
1458 1458
1459 void ProfileSyncService::OnConfigureDone( 1459 void ProfileSyncService::OnConfigureDone(
1460 const browser_sync::DataTypeManager::ConfigureResult& result) { 1460 const DataTypeManager::ConfigureResult& result) {
1461 // We should have cleared our cached passphrase before we get here (in 1461 // We should have cleared our cached passphrase before we get here (in
1462 // OnBackendInitialized()). 1462 // OnBackendInitialized()).
1463 DCHECK(cached_passphrase_.empty()); 1463 DCHECK(cached_passphrase_.empty());
1464 1464
1465 configure_status_ = result.status; 1465 configure_status_ = result.status;
1466 1466
1467 if (backend_mode_ != SYNC) { 1467 if (backend_mode_ != SYNC) {
1468 if (configure_status_ == DataTypeManager::OK || 1468 if (configure_status_ == DataTypeManager::OK ||
1469 configure_status_ == DataTypeManager::PARTIAL_SUCCESS) { 1469 configure_status_ == DataTypeManager::PARTIAL_SUCCESS) {
1470 StartSyncingWithServer(); 1470 StartSyncingWithServer();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 void ProfileSyncService::UpdateSelectedTypesHistogram( 1709 void ProfileSyncService::UpdateSelectedTypesHistogram(
1710 bool sync_everything, const syncer::ModelTypeSet chosen_types) const { 1710 bool sync_everything, const syncer::ModelTypeSet chosen_types) const {
1711 if (!HasSyncSetupCompleted() || 1711 if (!HasSyncSetupCompleted() ||
1712 sync_everything != sync_prefs_.HasKeepEverythingSynced()) { 1712 sync_everything != sync_prefs_.HasKeepEverythingSynced()) {
1713 UMA_HISTOGRAM_BOOLEAN("Sync.SyncEverything", sync_everything); 1713 UMA_HISTOGRAM_BOOLEAN("Sync.SyncEverything", sync_everything);
1714 } 1714 }
1715 1715
1716 // Only log the data types that are shown in the sync settings ui. 1716 // Only log the data types that are shown in the sync settings ui.
1717 // Note: the order of these types must match the ordering of 1717 // Note: the order of these types must match the ordering of
1718 // the respective types in ModelType 1718 // the respective types in ModelType
1719 const browser_sync::user_selectable_type::UserSelectableSyncType 1719 const sync_driver::user_selectable_type::UserSelectableSyncType
1720 user_selectable_types[] = { 1720 user_selectable_types[] = {
1721 browser_sync::user_selectable_type::BOOKMARKS, 1721 sync_driver::user_selectable_type::BOOKMARKS,
1722 browser_sync::user_selectable_type::PREFERENCES, 1722 sync_driver::user_selectable_type::PREFERENCES,
1723 browser_sync::user_selectable_type::PASSWORDS, 1723 sync_driver::user_selectable_type::PASSWORDS,
1724 browser_sync::user_selectable_type::AUTOFILL, 1724 sync_driver::user_selectable_type::AUTOFILL,
1725 browser_sync::user_selectable_type::THEMES, 1725 sync_driver::user_selectable_type::THEMES,
1726 browser_sync::user_selectable_type::TYPED_URLS, 1726 sync_driver::user_selectable_type::TYPED_URLS,
1727 browser_sync::user_selectable_type::EXTENSIONS, 1727 sync_driver::user_selectable_type::EXTENSIONS,
1728 browser_sync::user_selectable_type::APPS, 1728 sync_driver::user_selectable_type::APPS,
1729 browser_sync::user_selectable_type::PROXY_TABS 1729 sync_driver::user_selectable_type::PROXY_TABS
1730 }; 1730 };
1731 1731
1732 COMPILE_ASSERT(32 == syncer::MODEL_TYPE_COUNT, UpdateCustomConfigHistogram); 1732 COMPILE_ASSERT(32 == syncer::MODEL_TYPE_COUNT, UpdateCustomConfigHistogram);
1733 1733
1734 if (!sync_everything) { 1734 if (!sync_everything) {
1735 const syncer::ModelTypeSet current_types = GetPreferredDataTypes(); 1735 const syncer::ModelTypeSet current_types = GetPreferredDataTypes();
1736 1736
1737 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes(); 1737 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes();
1738 syncer::ModelTypeSet::Iterator it = type_set.First(); 1738 syncer::ModelTypeSet::Iterator it = type_set.First();
1739 1739
1740 DCHECK_EQ(arraysize(user_selectable_types), type_set.Size()); 1740 DCHECK_EQ(arraysize(user_selectable_types), type_set.Size());
1741 1741
1742 for (size_t i = 0; i < arraysize(user_selectable_types) && it.Good(); 1742 for (size_t i = 0; i < arraysize(user_selectable_types) && it.Good();
1743 ++i, it.Inc()) { 1743 ++i, it.Inc()) {
1744 const syncer::ModelType type = it.Get(); 1744 const syncer::ModelType type = it.Get();
1745 if (chosen_types.Has(type) && 1745 if (chosen_types.Has(type) &&
1746 (!HasSyncSetupCompleted() || !current_types.Has(type))) { 1746 (!HasSyncSetupCompleted() || !current_types.Has(type))) {
1747 // Selected type has changed - log it. 1747 // Selected type has changed - log it.
1748 UMA_HISTOGRAM_ENUMERATION( 1748 UMA_HISTOGRAM_ENUMERATION(
1749 "Sync.CustomSync", 1749 "Sync.CustomSync",
1750 user_selectable_types[i], 1750 user_selectable_types[i],
1751 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); 1751 sync_driver::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1);
1752 } 1752 }
1753 } 1753 }
1754 } 1754 }
1755 } 1755 }
1756 1756
1757 #if defined(OS_CHROMEOS) 1757 #if defined(OS_CHROMEOS)
1758 void ProfileSyncService::RefreshSpareBootstrapToken( 1758 void ProfileSyncService::RefreshSpareBootstrapToken(
1759 const std::string& passphrase) { 1759 const std::string& passphrase) {
1760 browser_sync::SystemEncryptor encryptor; 1760 browser_sync::SystemEncryptor encryptor;
1761 syncer::Cryptographer temp_cryptographer(&encryptor); 1761 syncer::Cryptographer temp_cryptographer(&encryptor);
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 browser_sync::SyncedDeviceTracker* device_tracker = 2658 browser_sync::SyncedDeviceTracker* device_tracker =
2659 backend_->GetSyncedDeviceTracker(); 2659 backend_->GetSyncedDeviceTracker();
2660 if (device_tracker) 2660 if (device_tracker)
2661 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); 2661 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_);
2662 } 2662 }
2663 } 2663 }
2664 2664
2665 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { 2665 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
2666 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); 2666 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
2667 } 2667 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698