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

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: Fix compile and chrome/ usage 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 is_first_time_sync_configure_(false), 203 is_first_time_sync_configure_(false),
204 backend_initialized_(false), 204 backend_initialized_(false),
205 sync_disabled_by_admin_(false), 205 sync_disabled_by_admin_(false),
206 is_auth_in_progress_(false), 206 is_auth_in_progress_(false),
207 signin_(signin_wrapper.Pass()), 207 signin_(signin_wrapper.Pass()),
208 unrecoverable_error_reason_(ERROR_REASON_UNSET), 208 unrecoverable_error_reason_(ERROR_REASON_UNSET),
209 expect_sync_configuration_aborted_(false), 209 expect_sync_configuration_aborted_(false),
210 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), 210 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
211 encrypt_everything_(false), 211 encrypt_everything_(false),
212 encryption_pending_(false), 212 encryption_pending_(false),
213 configure_status_(DataTypeManager::UNKNOWN), 213 configure_status_(sync_driver::DataTypeManager::UNKNOWN),
214 oauth2_token_service_(oauth2_token_service), 214 oauth2_token_service_(oauth2_token_service),
215 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), 215 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
216 weak_factory_(this), 216 weak_factory_(this),
217 startup_controller_weak_factory_(this), 217 startup_controller_weak_factory_(this),
218 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), 218 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED),
219 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), 219 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
220 network_resources_(new syncer::HttpBridgeNetworkResources), 220 network_resources_(new syncer::HttpBridgeNetworkResources),
221 startup_controller_( 221 startup_controller_(
222 start_behavior, 222 start_behavior,
223 oauth2_token_service, 223 oauth2_token_service,
(...skipping 265 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 sync_driver::DataTypeController::StateMap* state_map) const {
maxbogue 2014/07/21 22:14:21 Is the prefix necessary? There's a using line at t
Nicolas Zea 2014/07/21 22:23:31 Done, here and below.
500 for (browser_sync::DataTypeController::TypeMap::const_iterator iter = 500 for (sync_driver::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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 // possible. 813 // possible.
814 base::Time shutdown_start_time = base::Time::Now(); 814 base::Time shutdown_start_time = base::Time::Now();
815 backend_->StopSyncingForShutdown(); 815 backend_->StopSyncingForShutdown();
816 816
817 // Stop all data type controllers, if needed. Note that until Stop 817 // Stop all data type controllers, if needed. Note that until Stop
818 // completes, it is possible in theory to have a ChangeProcessor apply a 818 // completes, it is possible in theory to have a ChangeProcessor apply a
819 // change from a native model. In that case, it will get applied to the sync 819 // change from a native model. In that case, it will get applied to the sync
820 // database (which doesn't get destroyed until we destroy the backend below) 820 // database (which doesn't get destroyed until we destroy the backend below)
821 // as an unsynced change. That will be persisted, and committed on restart. 821 // as an unsynced change. That will be persisted, and committed on restart.
822 if (directory_data_type_manager_) { 822 if (directory_data_type_manager_) {
823 if (directory_data_type_manager_->state() != DataTypeManager::STOPPED) { 823 if (directory_data_type_manager_->state() !=
824 sync_driver::DataTypeManager::STOPPED) {
824 // When aborting as part of shutdown, we should expect an aborted sync 825 // When aborting as part of shutdown, we should expect an aborted sync
825 // configure result, else we'll dcheck when we try to read the sync error. 826 // configure result, else we'll dcheck when we try to read the sync error.
826 expect_sync_configuration_aborted_ = true; 827 expect_sync_configuration_aborted_ = true;
827 directory_data_type_manager_->Stop(); 828 directory_data_type_manager_->Stop();
828 } 829 }
829 directory_data_type_manager_.reset(); 830 directory_data_type_manager_.reset();
830 } 831 }
831 832
832 // Shutdown the migrator before the backend to ensure it doesn't pull a null 833 // Shutdown the migrator before the backend to ensure it doesn't pull a null
833 // snapshot. 834 // snapshot.
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 break; 1451 break;
1451 default: 1452 default:
1452 NOTREACHED(); 1453 NOTREACHED();
1453 } 1454 }
1454 NotifyObservers(); 1455 NotifyObservers();
1455 1456
1456 backup_rollback_controller_.Start(base::TimeDelta()); 1457 backup_rollback_controller_.Start(base::TimeDelta());
1457 } 1458 }
1458 1459
1459 void ProfileSyncService::OnConfigureDone( 1460 void ProfileSyncService::OnConfigureDone(
1460 const browser_sync::DataTypeManager::ConfigureResult& result) { 1461 const sync_driver::DataTypeManager::ConfigureResult& result) {
1461 // We should have cleared our cached passphrase before we get here (in 1462 // We should have cleared our cached passphrase before we get here (in
1462 // OnBackendInitialized()). 1463 // OnBackendInitialized()).
1463 DCHECK(cached_passphrase_.empty()); 1464 DCHECK(cached_passphrase_.empty());
1464 1465
1465 configure_status_ = result.status; 1466 configure_status_ = result.status;
1466 1467
1467 if (backend_mode_ != SYNC) { 1468 if (backend_mode_ != SYNC) {
1468 if (configure_status_ == DataTypeManager::OK || 1469 if (configure_status_ == DataTypeManager::OK ||
1469 configure_status_ == DataTypeManager::PARTIAL_SUCCESS) { 1470 configure_status_ == DataTypeManager::PARTIAL_SUCCESS) {
1470 StartSyncingWithServer(); 1471 StartSyncingWithServer();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 void ProfileSyncService::UpdateSelectedTypesHistogram( 1710 void ProfileSyncService::UpdateSelectedTypesHistogram(
1710 bool sync_everything, const syncer::ModelTypeSet chosen_types) const { 1711 bool sync_everything, const syncer::ModelTypeSet chosen_types) const {
1711 if (!HasSyncSetupCompleted() || 1712 if (!HasSyncSetupCompleted() ||
1712 sync_everything != sync_prefs_.HasKeepEverythingSynced()) { 1713 sync_everything != sync_prefs_.HasKeepEverythingSynced()) {
1713 UMA_HISTOGRAM_BOOLEAN("Sync.SyncEverything", sync_everything); 1714 UMA_HISTOGRAM_BOOLEAN("Sync.SyncEverything", sync_everything);
1714 } 1715 }
1715 1716
1716 // Only log the data types that are shown in the sync settings ui. 1717 // 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 1718 // Note: the order of these types must match the ordering of
1718 // the respective types in ModelType 1719 // the respective types in ModelType
1719 const browser_sync::user_selectable_type::UserSelectableSyncType 1720 const sync_driver::user_selectable_type::UserSelectableSyncType
1720 user_selectable_types[] = { 1721 user_selectable_types[] = {
1721 browser_sync::user_selectable_type::BOOKMARKS, 1722 sync_driver::user_selectable_type::BOOKMARKS,
1722 browser_sync::user_selectable_type::PREFERENCES, 1723 sync_driver::user_selectable_type::PREFERENCES,
1723 browser_sync::user_selectable_type::PASSWORDS, 1724 sync_driver::user_selectable_type::PASSWORDS,
1724 browser_sync::user_selectable_type::AUTOFILL, 1725 sync_driver::user_selectable_type::AUTOFILL,
1725 browser_sync::user_selectable_type::THEMES, 1726 sync_driver::user_selectable_type::THEMES,
1726 browser_sync::user_selectable_type::TYPED_URLS, 1727 sync_driver::user_selectable_type::TYPED_URLS,
1727 browser_sync::user_selectable_type::EXTENSIONS, 1728 sync_driver::user_selectable_type::EXTENSIONS,
1728 browser_sync::user_selectable_type::APPS, 1729 sync_driver::user_selectable_type::APPS,
1729 browser_sync::user_selectable_type::PROXY_TABS 1730 sync_driver::user_selectable_type::PROXY_TABS
1730 }; 1731 };
1731 1732
1732 COMPILE_ASSERT(32 == syncer::MODEL_TYPE_COUNT, UpdateCustomConfigHistogram); 1733 COMPILE_ASSERT(32 == syncer::MODEL_TYPE_COUNT, UpdateCustomConfigHistogram);
1733 1734
1734 if (!sync_everything) { 1735 if (!sync_everything) {
1735 const syncer::ModelTypeSet current_types = GetPreferredDataTypes(); 1736 const syncer::ModelTypeSet current_types = GetPreferredDataTypes();
1736 1737
1737 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes(); 1738 syncer::ModelTypeSet type_set = syncer::UserSelectableTypes();
1738 syncer::ModelTypeSet::Iterator it = type_set.First(); 1739 syncer::ModelTypeSet::Iterator it = type_set.First();
1739 1740
1740 DCHECK_EQ(arraysize(user_selectable_types), type_set.Size()); 1741 DCHECK_EQ(arraysize(user_selectable_types), type_set.Size());
1741 1742
1742 for (size_t i = 0; i < arraysize(user_selectable_types) && it.Good(); 1743 for (size_t i = 0; i < arraysize(user_selectable_types) && it.Good();
1743 ++i, it.Inc()) { 1744 ++i, it.Inc()) {
1744 const syncer::ModelType type = it.Get(); 1745 const syncer::ModelType type = it.Get();
1745 if (chosen_types.Has(type) && 1746 if (chosen_types.Has(type) &&
1746 (!HasSyncSetupCompleted() || !current_types.Has(type))) { 1747 (!HasSyncSetupCompleted() || !current_types.Has(type))) {
1747 // Selected type has changed - log it. 1748 // Selected type has changed - log it.
1748 UMA_HISTOGRAM_ENUMERATION( 1749 UMA_HISTOGRAM_ENUMERATION(
1749 "Sync.CustomSync", 1750 "Sync.CustomSync",
1750 user_selectable_types[i], 1751 user_selectable_types[i],
1751 browser_sync::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1); 1752 sync_driver::user_selectable_type::SELECTABLE_DATATYPE_COUNT + 1);
1752 } 1753 }
1753 } 1754 }
1754 } 1755 }
1755 } 1756 }
1756 1757
1757 #if defined(OS_CHROMEOS) 1758 #if defined(OS_CHROMEOS)
1758 void ProfileSyncService::RefreshSpareBootstrapToken( 1759 void ProfileSyncService::RefreshSpareBootstrapToken(
1759 const std::string& passphrase) { 1760 const std::string& passphrase) {
1760 browser_sync::SystemEncryptor encryptor; 1761 browser_sync::SystemEncryptor encryptor;
1761 syncer::Cryptographer temp_cryptographer(&encryptor); 1762 syncer::Cryptographer temp_cryptographer(&encryptor);
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 browser_sync::SyncedDeviceTracker* device_tracker = 2659 browser_sync::SyncedDeviceTracker* device_tracker =
2659 backend_->GetSyncedDeviceTracker(); 2660 backend_->GetSyncedDeviceTracker();
2660 if (device_tracker) 2661 if (device_tracker)
2661 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); 2662 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_);
2662 } 2663 }
2663 } 2664 }
2664 2665
2665 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { 2666 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
2666 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); 2667 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
2667 } 2668 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698