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

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

Issue 1315063008: Sync: Remove NonBlockingDataTypeManager and any ProfileSyncService code related to it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | « chrome/browser/sync/profile_sync_service.h ('k') | components/sync_driver.gypi » ('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 "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 <vector> 9 #include <vector>
10 10
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 430 }
431 431
432 void ProfileSyncService::UnregisterAuthNotifications() { 432 void ProfileSyncService::UnregisterAuthNotifications() {
433 if (signin()) 433 if (signin())
434 signin()->RemoveObserver(this); 434 signin()->RemoveObserver(this);
435 oauth2_token_service_->RemoveObserver(this); 435 oauth2_token_service_->RemoveObserver(this);
436 } 436 }
437 437
438 void ProfileSyncService::RegisterDataTypeController( 438 void ProfileSyncService::RegisterDataTypeController(
439 sync_driver::DataTypeController* data_type_controller) { 439 sync_driver::DataTypeController* data_type_controller) {
440 DCHECK_EQ( 440 DCHECK_EQ(data_type_controllers_.count(data_type_controller->type()), 0U);
441 directory_data_type_controllers_.count(data_type_controller->type()), 441 data_type_controllers_[data_type_controller->type()] = data_type_controller;
442 0U);
443 DCHECK(!GetRegisteredNonBlockingDataTypes().Has(
444 data_type_controller->type()));
445 directory_data_type_controllers_[data_type_controller->type()] =
446 data_type_controller;
447 }
448
449 void ProfileSyncService::RegisterNonBlockingType(syncer::ModelType type) {
450 DCHECK_EQ(directory_data_type_controllers_.count(type), 0U)
451 << "Duplicate registration of type " << ModelTypeToString(type);
452
453 // TODO(rlarocque): Set the enable flag properly when crbug.com/368834 is
454 // fixed and we have some way of telling whether or not this type should be
455 // enabled.
456 non_blocking_data_type_manager_.RegisterType(type, false);
457 }
458
459 void ProfileSyncService::InitializeNonBlockingType(
460 syncer::ModelType type,
461 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
462 const base::WeakPtr<syncer_v2::ModelTypeProcessorImpl>& type_processor) {
463 non_blocking_data_type_manager_.InitializeType(
464 type, task_runner, type_processor);
465 } 442 }
466 443
467 bool ProfileSyncService::IsDataTypeControllerRunning( 444 bool ProfileSyncService::IsDataTypeControllerRunning(
468 syncer::ModelType type) const { 445 syncer::ModelType type) const {
469 DataTypeController::TypeMap::const_iterator iter = 446 DataTypeController::TypeMap::const_iterator iter =
470 directory_data_type_controllers_.find(type); 447 data_type_controllers_.find(type);
471 if (iter == directory_data_type_controllers_.end()) { 448 if (iter == data_type_controllers_.end()) {
472 return false; 449 return false;
473 } 450 }
474 return iter->second->state() == DataTypeController::RUNNING; 451 return iter->second->state() == DataTypeController::RUNNING;
475 } 452 }
476 453
477 sync_driver::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() { 454 sync_driver::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() {
478 if (!IsDataTypeControllerRunning(syncer::SESSIONS)) 455 if (!IsDataTypeControllerRunning(syncer::SESSIONS))
479 return NULL; 456 return NULL;
480 return sessions_sync_manager_.get(); 457 return sessions_sync_manager_.get();
481 } 458 }
(...skipping 12 matching lines...) Expand all
494 return device_info_sync_service_.get(); 471 return device_info_sync_service_.get();
495 } 472 }
496 473
497 sync_driver::LocalDeviceInfoProvider* 474 sync_driver::LocalDeviceInfoProvider*
498 ProfileSyncService::GetLocalDeviceInfoProvider() const { 475 ProfileSyncService::GetLocalDeviceInfoProvider() const {
499 return local_device_.get(); 476 return local_device_.get();
500 } 477 }
501 478
502 void ProfileSyncService::GetDataTypeControllerStates( 479 void ProfileSyncService::GetDataTypeControllerStates(
503 DataTypeController::StateMap* state_map) const { 480 DataTypeController::StateMap* state_map) const {
504 for (DataTypeController::TypeMap::const_iterator iter = 481 for (DataTypeController::TypeMap::const_iterator iter =
505 directory_data_type_controllers_.begin(); 482 data_type_controllers_.begin();
506 iter != directory_data_type_controllers_.end(); 483 iter != data_type_controllers_.end(); ++iter)
507 ++iter)
508 (*state_map)[iter->first] = iter->second.get()->state(); 484 (*state_map)[iter->first] = iter->second.get()->state();
509 } 485 }
510 486
511 SyncCredentials ProfileSyncService::GetCredentials() { 487 SyncCredentials ProfileSyncService::GetCredentials() {
512 SyncCredentials credentials; 488 SyncCredentials credentials;
513 if (backend_mode_ == SYNC) { 489 if (backend_mode_ == SYNC) {
514 credentials.email = signin_->GetEffectiveUsername(); 490 credentials.email = signin_->GetEffectiveUsername();
515 DCHECK(!credentials.email.empty()); 491 DCHECK(!credentials.email.empty());
516 credentials.sync_token = access_token_; 492 credentials.sync_token = access_token_;
517 493
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 FROM_HERE, base::Bind(&DeleteSyncDataFolder, directory_path_)); 832 FROM_HERE, base::Bind(&DeleteSyncDataFolder, directory_path_));
857 } 833 }
858 return; 834 return;
859 } 835 }
860 836
861 if (reason == syncer::ShutdownReason::STOP_SYNC 837 if (reason == syncer::ShutdownReason::STOP_SYNC
862 || reason == syncer::ShutdownReason::DISABLE_SYNC) { 838 || reason == syncer::ShutdownReason::DISABLE_SYNC) {
863 RemoveClientFromServer(); 839 RemoveClientFromServer();
864 } 840 }
865 841
866 non_blocking_data_type_manager_.DisconnectSyncBackend();
867
868 // First, we spin down the backend to stop change processing as soon as 842 // First, we spin down the backend to stop change processing as soon as
869 // possible. 843 // possible.
870 base::Time shutdown_start_time = base::Time::Now(); 844 base::Time shutdown_start_time = base::Time::Now();
871 backend_->StopSyncingForShutdown(); 845 backend_->StopSyncingForShutdown();
872 846
873 // Stop all data type controllers, if needed. Note that until Stop 847 // Stop all data type controllers, if needed. Note that until Stop
874 // completes, it is possible in theory to have a ChangeProcessor apply a 848 // completes, it is possible in theory to have a ChangeProcessor apply a
875 // change from a native model. In that case, it will get applied to the sync 849 // change from a native model. In that case, it will get applied to the sync
876 // database (which doesn't get destroyed until we destroy the backend below) 850 // database (which doesn't get destroyed until we destroy the backend below)
877 // as an unsynced change. That will be persisted, and committed on restart. 851 // as an unsynced change. That will be persisted, and committed on restart.
878 if (directory_data_type_manager_) { 852 if (data_type_manager_) {
879 if (directory_data_type_manager_->state() != DataTypeManager::STOPPED) { 853 if (data_type_manager_->state() != DataTypeManager::STOPPED) {
880 // When aborting as part of shutdown, we should expect an aborted sync 854 // When aborting as part of shutdown, we should expect an aborted sync
881 // configure result, else we'll dcheck when we try to read the sync error. 855 // configure result, else we'll dcheck when we try to read the sync error.
882 expect_sync_configuration_aborted_ = true; 856 expect_sync_configuration_aborted_ = true;
883 directory_data_type_manager_->Stop(); 857 data_type_manager_->Stop();
884 } 858 }
885 directory_data_type_manager_.reset(); 859 data_type_manager_.reset();
886 } 860 }
887 861
888 // Shutdown the migrator before the backend to ensure it doesn't pull a null 862 // Shutdown the migrator before the backend to ensure it doesn't pull a null
889 // snapshot. 863 // snapshot.
890 migrator_.reset(); 864 migrator_.reset();
891 sync_js_controller_.AttachJsBackend(WeakHandle<syncer::JsBackend>()); 865 sync_js_controller_.AttachJsBackend(WeakHandle<syncer::JsBackend>());
892 866
893 // Move aside the backend so nobody else tries to use it while we are 867 // Move aside the backend so nobody else tries to use it while we are
894 // shutting it down. 868 // shutting it down.
895 scoped_ptr<SyncBackendHost> doomed_backend(backend_.release()); 869 scoped_ptr<SyncBackendHost> doomed_backend(backend_.release());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 954
981 void ProfileSyncService::NotifySyncCycleCompleted() { 955 void ProfileSyncService::NotifySyncCycleCompleted() {
982 FOR_EACH_OBSERVER(sync_driver::SyncServiceObserver, observers_, 956 FOR_EACH_OBSERVER(sync_driver::SyncServiceObserver, observers_,
983 OnSyncCycleCompleted()); 957 OnSyncCycleCompleted());
984 } 958 }
985 959
986 void ProfileSyncService::ClearStaleErrors() { 960 void ProfileSyncService::ClearStaleErrors() {
987 ClearUnrecoverableError(); 961 ClearUnrecoverableError();
988 last_actionable_error_ = SyncProtocolError(); 962 last_actionable_error_ = SyncProtocolError();
989 // Clear the data type errors as well. 963 // Clear the data type errors as well.
990 if (directory_data_type_manager_.get()) 964 if (data_type_manager_.get())
991 directory_data_type_manager_->ResetDataTypeErrors(); 965 data_type_manager_->ResetDataTypeErrors();
992
993 } 966 }
994 967
995 void ProfileSyncService::ClearUnrecoverableError() { 968 void ProfileSyncService::ClearUnrecoverableError() {
996 unrecoverable_error_reason_ = ERROR_REASON_UNSET; 969 unrecoverable_error_reason_ = ERROR_REASON_UNSET;
997 unrecoverable_error_message_.clear(); 970 unrecoverable_error_message_.clear();
998 unrecoverable_error_location_ = tracked_objects::Location(); 971 unrecoverable_error_location_ = tracked_objects::Location();
999 } 972 }
1000 973
1001 // An invariant has been violated. Transition to an error state where we try 974 // An invariant has been violated. Transition to an error state where we try
1002 // to do as little work as possible, to avoid further corruption or crashes. 975 // to do as little work as possible, to avoid further corruption or crashes.
(...skipping 27 matching lines...) Expand all
1030 base::ThreadTaskRunnerHandle::Get()->PostTask( 1003 base::ThreadTaskRunnerHandle::Get()->PostTask(
1031 FROM_HERE, 1004 FROM_HERE,
1032 base::Bind( 1005 base::Bind(
1033 &ProfileSyncService::ShutdownImpl, weak_factory_.GetWeakPtr(), 1006 &ProfileSyncService::ShutdownImpl, weak_factory_.GetWeakPtr(),
1034 delete_sync_database ? syncer::DISABLE_SYNC : syncer::STOP_SYNC)); 1007 delete_sync_database ? syncer::DISABLE_SYNC : syncer::STOP_SYNC));
1035 } 1008 }
1036 1009
1037 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { 1010 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) {
1038 if (!backend_initialized_) 1011 if (!backend_initialized_)
1039 return; 1012 return;
1040 directory_data_type_manager_->ReenableType(type); 1013 data_type_manager_->ReenableType(type);
1041 } 1014 }
1042 1015
1043 void ProfileSyncService::UpdateBackendInitUMA(bool success) { 1016 void ProfileSyncService::UpdateBackendInitUMA(bool success) {
1044 if (backend_mode_ != SYNC) 1017 if (backend_mode_ != SYNC)
1045 return; 1018 return;
1046 1019
1047 is_first_time_sync_configure_ = !HasSyncSetupCompleted(); 1020 is_first_time_sync_configure_ = !HasSyncSetupCompleted();
1048 1021
1049 if (is_first_time_sync_configure_) { 1022 if (is_first_time_sync_configure_) {
1050 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); 1023 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success);
(...skipping 17 matching lines...) Expand all
1068 1041
1069 if (last_backup_time_) { 1042 if (last_backup_time_) {
1070 DCHECK(device_info_sync_service_); 1043 DCHECK(device_info_sync_service_);
1071 device_info_sync_service_->UpdateLocalDeviceBackupTime(*last_backup_time_); 1044 device_info_sync_service_->UpdateLocalDeviceBackupTime(*last_backup_time_);
1072 } 1045 }
1073 1046
1074 if (protocol_event_observers_.might_have_observers()) { 1047 if (protocol_event_observers_.might_have_observers()) {
1075 backend_->RequestBufferedProtocolEventsAndEnableForwarding(); 1048 backend_->RequestBufferedProtocolEventsAndEnableForwarding();
1076 } 1049 }
1077 1050
1078 non_blocking_data_type_manager_.ConnectSyncBackend(
1079 backend_->GetSyncContextProxy());
1080
1081 if (type_debug_info_observers_.might_have_observers()) { 1051 if (type_debug_info_observers_.might_have_observers()) {
1082 backend_->EnableDirectoryTypeDebugInfoForwarding(); 1052 backend_->EnableDirectoryTypeDebugInfoForwarding();
1083 } 1053 }
1084 1054
1085 // If we have a cached passphrase use it to decrypt/encrypt data now that the 1055 // If we have a cached passphrase use it to decrypt/encrypt data now that the
1086 // backend is initialized. We want to call this before notifying observers in 1056 // backend is initialized. We want to call this before notifying observers in
1087 // case this operation affects the "passphrase required" status. 1057 // case this operation affects the "passphrase required" status.
1088 ConsumeCachedPassphraseIfPossible(); 1058 ConsumeCachedPassphraseIfPossible();
1089 1059
1090 // The very first time the backend initializes is effectively the first time 1060 // The very first time the backend initializes is effectively the first time
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 1118
1149 SigninClient* signin_client = 1119 SigninClient* signin_client =
1150 ChromeSigninClientFactory::GetForProfile(profile_); 1120 ChromeSigninClientFactory::GetForProfile(profile_);
1151 DCHECK(signin_client); 1121 DCHECK(signin_client);
1152 std::string signin_scoped_device_id = 1122 std::string signin_scoped_device_id =
1153 signin_client->GetSigninScopedDeviceId(); 1123 signin_client->GetSigninScopedDeviceId();
1154 1124
1155 // Initialize local device info. 1125 // Initialize local device info.
1156 local_device_->Initialize(cache_guid, signin_scoped_device_id); 1126 local_device_->Initialize(cache_guid, signin_scoped_device_id);
1157 1127
1158 DVLOG(1) << "Setting preferred types for non-blocking DTM";
1159 non_blocking_data_type_manager_.SetPreferredTypes(GetPreferredDataTypes());
1160
1161 if (backend_mode_ == BACKUP || backend_mode_ == ROLLBACK) 1128 if (backend_mode_ == BACKUP || backend_mode_ == ROLLBACK)
1162 ConfigureDataTypeManager(); 1129 ConfigureDataTypeManager();
1163 else 1130 else
1164 PostBackendInitialization(); 1131 PostBackendInitialization();
1165 } 1132 }
1166 1133
1167 void ProfileSyncService::OnSyncCycleCompleted() { 1134 void ProfileSyncService::OnSyncCycleCompleted() {
1168 UpdateLastSyncedTime(); 1135 UpdateLastSyncedTime();
1169 if (IsDataTypeControllerRunning(syncer::SESSIONS)) { 1136 if (IsDataTypeControllerRunning(syncer::SESSIONS)) {
1170 // Trigger garbage collection of old sessions now that we've downloaded 1137 // Trigger garbage collection of old sessions now that we've downloaded
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 if (HasUnrecoverableError()) { 1258 if (HasUnrecoverableError()) {
1292 // When unrecoverable error is detected we post a task to shutdown the 1259 // When unrecoverable error is detected we post a task to shutdown the
1293 // backend. The task might not have executed yet. 1260 // backend. The task might not have executed yet.
1294 return; 1261 return;
1295 } 1262 }
1296 1263
1297 DVLOG(1) << "Passphrase required with reason: " 1264 DVLOG(1) << "Passphrase required with reason: "
1298 << syncer::PassphraseRequiredReasonToString(reason); 1265 << syncer::PassphraseRequiredReasonToString(reason);
1299 passphrase_required_reason_ = reason; 1266 passphrase_required_reason_ = reason;
1300 1267
1301 const syncer::ModelTypeSet types = GetPreferredDirectoryDataTypes(); 1268 // TODO(stanisc): http://crbug.com/351005: Does this support USS types?
1302 if (directory_data_type_manager_) { 1269 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1270 if (data_type_manager_) {
1303 // Reconfigure without the encrypted types (excluded implicitly via the 1271 // Reconfigure without the encrypted types (excluded implicitly via the
1304 // failed datatypes handler). 1272 // failed datatypes handler).
1305 directory_data_type_manager_->Configure(types, 1273 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO);
1306 syncer::CONFIGURE_REASON_CRYPTO);
1307 } 1274 }
1308 1275
1309 // TODO(rlarocque): Support non-blocking types. http://crbug.com/351005.
1310
1311 // Notify observers that the passphrase status may have changed. 1276 // Notify observers that the passphrase status may have changed.
1312 NotifyObservers(); 1277 NotifyObservers();
1313 } 1278 }
1314 1279
1315 void ProfileSyncService::OnPassphraseAccepted() { 1280 void ProfileSyncService::OnPassphraseAccepted() {
1316 DVLOG(1) << "Received OnPassphraseAccepted."; 1281 DVLOG(1) << "Received OnPassphraseAccepted.";
1317 1282
1318 // If the pending keys were resolved via keystore, it's possible we never 1283 // If the pending keys were resolved via keystore, it's possible we never
1319 // consumed our cached passphrase. Clear it now. 1284 // consumed our cached passphrase. Clear it now.
1320 if (!cached_passphrase_.empty()) 1285 if (!cached_passphrase_.empty())
1321 cached_passphrase_.clear(); 1286 cached_passphrase_.clear();
1322 1287
1323 // Reset passphrase_required_reason_ since we know we no longer require the 1288 // Reset passphrase_required_reason_ since we know we no longer require the
1324 // passphrase. We do this here rather than down in ResolvePassphraseRequired() 1289 // passphrase. We do this here rather than down in ResolvePassphraseRequired()
1325 // because that can be called by OnPassphraseRequired() if no encrypted data 1290 // because that can be called by OnPassphraseRequired() if no encrypted data
1326 // types are enabled, and we don't want to clobber the true passphrase error. 1291 // types are enabled, and we don't want to clobber the true passphrase error.
1327 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 1292 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
1328 1293
1329 // Make sure the data types that depend on the passphrase are started at 1294 // Make sure the data types that depend on the passphrase are started at
1330 // this time. 1295 // this time.
1331 const syncer::ModelTypeSet types = GetPreferredDirectoryDataTypes(); 1296 // TODO(stanisc): http://crbug.com/351005: Does this support USS types?
1332 if (directory_data_type_manager_) { 1297 const syncer::ModelTypeSet types = GetPreferredDataTypes();
1298 if (data_type_manager_) {
1333 // Re-enable any encrypted types if necessary. 1299 // Re-enable any encrypted types if necessary.
1334 directory_data_type_manager_->Configure(types, 1300 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CRYPTO);
1335 syncer::CONFIGURE_REASON_CRYPTO);
1336 } 1301 }
1337 1302
1338 // TODO(rlarocque): Support non-blocking types. http://crbug.com/351005.
1339
1340 NotifyObservers(); 1303 NotifyObservers();
1341 } 1304 }
1342 1305
1343 void ProfileSyncService::OnEncryptedTypesChanged( 1306 void ProfileSyncService::OnEncryptedTypesChanged(
1344 syncer::ModelTypeSet encrypted_types, 1307 syncer::ModelTypeSet encrypted_types,
1345 bool encrypt_everything) { 1308 bool encrypt_everything) {
1346 encrypted_types_ = encrypted_types; 1309 encrypted_types_ = encrypted_types;
1347 encrypt_everything_ = encrypt_everything; 1310 encrypt_everything_ = encrypt_everything;
1348 DCHECK(encrypt_everything_allowed_ || !encrypt_everything_); 1311 DCHECK(encrypt_everything_allowed_ || !encrypt_everything_);
1349 DVLOG(1) << "Encrypted types changed to " 1312 DVLOG(1) << "Encrypted types changed to "
(...skipping 11 matching lines...) Expand all
1361 encryption_pending_ = false; 1324 encryption_pending_ = false;
1362 // This is to nudge the integration tests when encryption is 1325 // This is to nudge the integration tests when encryption is
1363 // finished. 1326 // finished.
1364 NotifyObservers(); 1327 NotifyObservers();
1365 } 1328 }
1366 } 1329 }
1367 1330
1368 void ProfileSyncService::OnMigrationNeededForTypes( 1331 void ProfileSyncService::OnMigrationNeededForTypes(
1369 syncer::ModelTypeSet types) { 1332 syncer::ModelTypeSet types) {
1370 DCHECK(backend_initialized_); 1333 DCHECK(backend_initialized_);
1371 DCHECK(directory_data_type_manager_.get()); 1334 DCHECK(data_type_manager_.get());
1372 1335
1373 // Migrator must be valid, because we don't sync until it is created and this 1336 // Migrator must be valid, because we don't sync until it is created and this
1374 // callback originates from a sync cycle. 1337 // callback originates from a sync cycle.
1375 migrator_->MigrateTypes(types); 1338 migrator_->MigrateTypes(types);
1376 } 1339 }
1377 1340
1378 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) { 1341 void ProfileSyncService::OnActionableError(const SyncProtocolError& error) {
1379 last_actionable_error_ = error; 1342 last_actionable_error_ = error;
1380 DCHECK_NE(last_actionable_error_.action, 1343 DCHECK_NE(last_actionable_error_.action,
1381 syncer::UNKNOWN_ACTION); 1344 syncer::UNKNOWN_ACTION);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 // updated nigori state. Time to cache the nigori state, and catch up the 1411 // updated nigori state. Time to cache the nigori state, and catch up the
1449 // active data types. 1412 // active data types.
1450 sync_prefs_.SetSavedNigoriStateForPassphraseEncryptionTransition( 1413 sync_prefs_.SetSavedNigoriStateForPassphraseEncryptionTransition(
1451 nigori_state); 1414 nigori_state);
1452 sync_prefs_.SetPassphraseEncryptionTransitionInProgress(true); 1415 sync_prefs_.SetPassphraseEncryptionTransitionInProgress(true);
1453 BeginConfigureCatchUpBeforeClear(); 1416 BeginConfigureCatchUpBeforeClear();
1454 } 1417 }
1455 1418
1456 void ProfileSyncService::BeginConfigureCatchUpBeforeClear() { 1419 void ProfileSyncService::BeginConfigureCatchUpBeforeClear() {
1457 DCHECK_EQ(backend_mode_, SYNC); 1420 DCHECK_EQ(backend_mode_, SYNC);
1458 DCHECK(directory_data_type_manager_); 1421 DCHECK(data_type_manager_);
1459 DCHECK(!saved_nigori_state_); 1422 DCHECK(!saved_nigori_state_);
1460 saved_nigori_state_ = 1423 saved_nigori_state_ =
1461 sync_prefs_.GetSavedNigoriStateForPassphraseEncryptionTransition().Pass(); 1424 sync_prefs_.GetSavedNigoriStateForPassphraseEncryptionTransition().Pass();
1462 const syncer::ModelTypeSet types = GetActiveDataTypes(); 1425 const syncer::ModelTypeSet types = GetActiveDataTypes();
1463 catch_up_configure_in_progress_ = true; 1426 catch_up_configure_in_progress_ = true;
1464 directory_data_type_manager_->Configure(types, 1427 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CATCH_UP);
1465 syncer::CONFIGURE_REASON_CATCH_UP);
1466 } 1428 }
1467 1429
1468 void ProfileSyncService::ClearAndRestartSyncForPassphraseEncryption() { 1430 void ProfileSyncService::ClearAndRestartSyncForPassphraseEncryption() {
1469 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 1431 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1470 backend_->ClearServerData(base::Bind( 1432 backend_->ClearServerData(base::Bind(
1471 &ProfileSyncService::OnClearServerDataDone, weak_factory_.GetWeakPtr())); 1433 &ProfileSyncService::OnClearServerDataDone, weak_factory_.GetWeakPtr()));
1472 } 1434 }
1473 1435
1474 void ProfileSyncService::OnClearServerDataDone() { 1436 void ProfileSyncService::OnClearServerDataDone() {
1475 DCHECK(sync_prefs_.GetPassphraseEncryptionTransitionInProgress()); 1437 DCHECK(sync_prefs_.GetPassphraseEncryptionTransitionInProgress());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 if (HasUnrecoverableError()) { 1575 if (HasUnrecoverableError()) {
1614 return UNRECOVERABLE_ERROR; 1576 return UNRECOVERABLE_ERROR;
1615 } else if (!backend_) { 1577 } else if (!backend_) {
1616 return NOT_ENABLED; 1578 return NOT_ENABLED;
1617 } else if (backend_mode_ == BACKUP) { 1579 } else if (backend_mode_ == BACKUP) {
1618 return BACKUP_USER_DATA; 1580 return BACKUP_USER_DATA;
1619 } else if (backend_mode_ == ROLLBACK) { 1581 } else if (backend_mode_ == ROLLBACK) {
1620 return ROLLBACK_USER_DATA; 1582 return ROLLBACK_USER_DATA;
1621 } else if (backend_.get() && !HasSyncSetupCompleted()) { 1583 } else if (backend_.get() && !HasSyncSetupCompleted()) {
1622 return SETUP_INCOMPLETE; 1584 return SETUP_INCOMPLETE;
1623 } else if ( 1585 } else if (backend_ && HasSyncSetupCompleted() && data_type_manager_ &&
1624 backend_.get() && HasSyncSetupCompleted() && 1586 data_type_manager_->state() == DataTypeManager::STOPPED) {
1625 directory_data_type_manager_.get() &&
1626 directory_data_type_manager_->state() == DataTypeManager::STOPPED) {
1627 return DATATYPES_NOT_INITIALIZED; 1587 return DATATYPES_NOT_INITIALIZED;
1628 } else if (IsSyncActive()) { 1588 } else if (IsSyncActive()) {
1629 return INITIALIZED; 1589 return INITIALIZED;
1630 } 1590 }
1631 return UNKNOWN_ERROR; 1591 return UNKNOWN_ERROR;
1632 } 1592 }
1633 1593
1634 std::string ProfileSyncService::QuerySyncStatusSummaryString() { 1594 std::string ProfileSyncService::QuerySyncStatusSummaryString() {
1635 SyncStatusSummary status = QuerySyncStatusSummary(); 1595 SyncStatusSummary status = QuerySyncStatusSummary();
1636 1596
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 if (!setup_in_progress && backend_initialized()) 1660 if (!setup_in_progress && backend_initialized())
1701 ReconfigureDatatypeManager(); 1661 ReconfigureDatatypeManager();
1702 NotifyObservers(); 1662 NotifyObservers();
1703 } 1663 }
1704 1664
1705 bool ProfileSyncService::IsSyncAllowed() const { 1665 bool ProfileSyncService::IsSyncAllowed() const {
1706 return IsSyncAllowedByFlag() && !IsManaged(); 1666 return IsSyncAllowedByFlag() && !IsManaged();
1707 } 1667 }
1708 1668
1709 bool ProfileSyncService::IsSyncActive() const { 1669 bool ProfileSyncService::IsSyncActive() const {
1710 return backend_initialized_ && backend_mode_ == SYNC && 1670 return backend_initialized_ && backend_mode_ == SYNC && data_type_manager_ &&
1711 directory_data_type_manager_ && 1671 data_type_manager_->state() != DataTypeManager::STOPPED;
1712 directory_data_type_manager_->state() != DataTypeManager::STOPPED;
1713 } 1672 }
1714 1673
1715 bool ProfileSyncService::IsSignedIn() const { 1674 bool ProfileSyncService::IsSignedIn() const {
1716 // Sync is logged in if there is a non-empty effective account id. 1675 // Sync is logged in if there is a non-empty effective account id.
1717 return !signin_->GetAccountIdToUse().empty(); 1676 return !signin_->GetAccountIdToUse().empty();
1718 } 1677 }
1719 1678
1720 bool ProfileSyncService::backend_initialized() const { 1679 bool ProfileSyncService::backend_initialized() const {
1721 return backend_initialized_; 1680 return backend_initialized_;
1722 } 1681 }
1723 1682
1724 ProfileSyncService::BackendMode ProfileSyncService::backend_mode() const { 1683 ProfileSyncService::BackendMode ProfileSyncService::backend_mode() const {
1725 return backend_mode_; 1684 return backend_mode_;
1726 } 1685 }
1727 1686
1728 bool ProfileSyncService::ConfigurationDone() const { 1687 bool ProfileSyncService::ConfigurationDone() const {
1729 return directory_data_type_manager_ && 1688 return data_type_manager_ &&
1730 directory_data_type_manager_->state() == DataTypeManager::CONFIGURED; 1689 data_type_manager_->state() == DataTypeManager::CONFIGURED;
1731 } 1690 }
1732 1691
1733 bool ProfileSyncService::waiting_for_auth() const { 1692 bool ProfileSyncService::waiting_for_auth() const {
1734 return is_auth_in_progress_; 1693 return is_auth_in_progress_;
1735 } 1694 }
1736 1695
1737 const syncer::Experiments& ProfileSyncService::current_experiments() const { 1696 const syncer::Experiments& ProfileSyncService::current_experiments() const {
1738 return current_experiments_; 1697 return current_experiments_;
1739 } 1698 }
1740 1699
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 bool sync_everything, 1799 bool sync_everything,
1841 syncer::ModelTypeSet chosen_types) { 1800 syncer::ModelTypeSet chosen_types) {
1842 if (!backend_.get() && !HasUnrecoverableError()) { 1801 if (!backend_.get() && !HasUnrecoverableError()) {
1843 NOTREACHED(); 1802 NOTREACHED();
1844 return; 1803 return;
1845 } 1804 }
1846 1805
1847 UpdateSelectedTypesHistogram(sync_everything, chosen_types); 1806 UpdateSelectedTypesHistogram(sync_everything, chosen_types);
1848 sync_prefs_.SetKeepEverythingSynced(sync_everything); 1807 sync_prefs_.SetKeepEverythingSynced(sync_everything);
1849 1808
1850 if (directory_data_type_manager_.get()) 1809 if (data_type_manager_)
1851 directory_data_type_manager_->ResetDataTypeErrors(); 1810 data_type_manager_->ResetDataTypeErrors();
1852 ChangePreferredDataTypes(chosen_types); 1811 ChangePreferredDataTypes(chosen_types);
1853 } 1812 }
1854 1813
1855 void ProfileSyncService::ChangePreferredDataTypes( 1814 void ProfileSyncService::ChangePreferredDataTypes(
1856 syncer::ModelTypeSet preferred_types) { 1815 syncer::ModelTypeSet preferred_types) {
1857 1816
1858 DVLOG(1) << "ChangePreferredDataTypes invoked"; 1817 DVLOG(1) << "ChangePreferredDataTypes invoked";
1859 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1818 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1860 // Will only enable those types that are registered and preferred. 1819 // Will only enable those types that are registered and preferred.
1861 sync_prefs_.SetPreferredDataTypes(registered_types, preferred_types); 1820 sync_prefs_.SetPreferredDataTypes(registered_types, preferred_types);
1862 1821
1863 // Now reconfigure the DTM. 1822 // Now reconfigure the DTM.
1864 ReconfigureDatatypeManager(); 1823 ReconfigureDatatypeManager();
1865
1866 // TODO(rlarocque): Reconfigure the NonBlockingDataTypeManager, too. Blocked
1867 // on crbug.com/368834. Until that bug is fixed, it's difficult to tell
1868 // which types should be enabled and when.
1869 } 1824 }
1870 1825
1871 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const { 1826 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const {
1872 if (!IsSyncActive() || !ConfigurationDone()) 1827 if (!IsSyncActive() || !ConfigurationDone())
1873 return syncer::ModelTypeSet(); 1828 return syncer::ModelTypeSet();
1874 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); 1829 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes();
1875 const syncer::ModelTypeSet failed_types = 1830 const syncer::ModelTypeSet failed_types =
1876 data_type_status_table_.GetFailedTypes(); 1831 data_type_status_table_.GetFailedTypes();
1877 return Difference(preferred_types, failed_types); 1832 return Difference(preferred_types, failed_types);
1878 } 1833 }
1879 1834
1880 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { 1835 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const {
1881 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1836 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1882 const syncer::ModelTypeSet preferred_types = 1837 const syncer::ModelTypeSet preferred_types =
1883 sync_prefs_.GetPreferredDataTypes(registered_types); 1838 sync_prefs_.GetPreferredDataTypes(registered_types);
1884 const syncer::ModelTypeSet enforced_types = 1839 const syncer::ModelTypeSet enforced_types =
1885 Intersection(GetDataTypesFromPreferenceProviders(), registered_types); 1840 Intersection(GetDataTypesFromPreferenceProviders(), registered_types);
1886 return Union(preferred_types, enforced_types); 1841 return Union(preferred_types, enforced_types);
1887 } 1842 }
1888 1843
1889 syncer::ModelTypeSet
1890 ProfileSyncService::GetPreferredDirectoryDataTypes() const {
1891 const syncer::ModelTypeSet registered_directory_types =
1892 GetRegisteredDirectoryDataTypes();
1893 const syncer::ModelTypeSet preferred_types =
1894 sync_prefs_.GetPreferredDataTypes(registered_directory_types);
1895 const syncer::ModelTypeSet enforced_types =
1896 Intersection(GetDataTypesFromPreferenceProviders(),
1897 registered_directory_types);
1898 return Union(preferred_types, enforced_types);
1899 }
1900
1901 syncer::ModelTypeSet
1902 ProfileSyncService::GetPreferredNonBlockingDataTypes() const {
1903 return sync_prefs_.GetPreferredDataTypes(GetRegisteredNonBlockingDataTypes());
1904 }
1905
1906 syncer::ModelTypeSet ProfileSyncService::GetForcedDataTypes() const { 1844 syncer::ModelTypeSet ProfileSyncService::GetForcedDataTypes() const {
1907 // TODO(treib,zea): When SyncPrefs also implements SyncTypePreferenceProvider, 1845 // TODO(treib,zea): When SyncPrefs also implements SyncTypePreferenceProvider,
1908 // we'll need another way to distinguish user-choosable types from 1846 // we'll need another way to distinguish user-choosable types from
1909 // programmatically-enabled types. 1847 // programmatically-enabled types.
1910 return GetDataTypesFromPreferenceProviders(); 1848 return GetDataTypesFromPreferenceProviders();
1911 } 1849 }
1912 1850
1913 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const { 1851 syncer::ModelTypeSet ProfileSyncService::GetRegisteredDataTypes() const {
1914 return Union(GetRegisteredDirectoryDataTypes(),
1915 GetRegisteredNonBlockingDataTypes());
1916 }
1917
1918 syncer::ModelTypeSet
1919 ProfileSyncService::GetRegisteredDirectoryDataTypes() const {
1920 syncer::ModelTypeSet registered_types; 1852 syncer::ModelTypeSet registered_types;
1921 // The directory_data_type_controllers_ are determined by command-line flags; 1853 // The data_type_controllers_ are determined by command-line flags;
1922 // that's effectively what controls the values returned here. 1854 // that's effectively what controls the values returned here.
1923 for (DataTypeController::TypeMap::const_iterator it = 1855 for (DataTypeController::TypeMap::const_iterator it =
1924 directory_data_type_controllers_.begin(); 1856 data_type_controllers_.begin();
1925 it != directory_data_type_controllers_.end(); ++it) { 1857 it != data_type_controllers_.end(); ++it) {
1926 registered_types.Put(it->first); 1858 registered_types.Put(it->first);
1927 } 1859 }
1928 return registered_types; 1860 return registered_types;
1929 } 1861 }
1930 1862
1931 syncer::ModelTypeSet
1932 ProfileSyncService::GetRegisteredNonBlockingDataTypes() const {
1933 return non_blocking_data_type_manager_.GetRegisteredTypes();
1934 }
1935
1936 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { 1863 bool ProfileSyncService::IsUsingSecondaryPassphrase() const {
1937 syncer::PassphraseType passphrase_type = GetPassphraseType(); 1864 syncer::PassphraseType passphrase_type = GetPassphraseType();
1938 return passphrase_type == syncer::FROZEN_IMPLICIT_PASSPHRASE || 1865 return passphrase_type == syncer::FROZEN_IMPLICIT_PASSPHRASE ||
1939 passphrase_type == syncer::CUSTOM_PASSPHRASE; 1866 passphrase_type == syncer::CUSTOM_PASSPHRASE;
1940 } 1867 }
1941 1868
1942 syncer::PassphraseType ProfileSyncService::GetPassphraseType() const { 1869 syncer::PassphraseType ProfileSyncService::GetPassphraseType() const {
1943 return backend_->GetPassphraseType(); 1870 return backend_->GetPassphraseType();
1944 } 1871 }
1945 1872
1946 base::Time ProfileSyncService::GetExplicitPassphraseTime() const { 1873 base::Time ProfileSyncService::GetExplicitPassphraseTime() const {
1947 return backend_->GetExplicitPassphraseTime(); 1874 return backend_->GetExplicitPassphraseTime();
1948 } 1875 }
1949 1876
1950 bool ProfileSyncService::IsCryptographerReady( 1877 bool ProfileSyncService::IsCryptographerReady(
1951 const syncer::BaseTransaction* trans) const { 1878 const syncer::BaseTransaction* trans) const {
1952 return backend_.get() && backend_->IsCryptographerReady(trans); 1879 return backend_.get() && backend_->IsCryptographerReady(trans);
1953 } 1880 }
1954 1881
1955 void ProfileSyncService::ConfigureDataTypeManager() { 1882 void ProfileSyncService::ConfigureDataTypeManager() {
1956 // Don't configure datatypes if the setup UI is still on the screen - this 1883 // Don't configure datatypes if the setup UI is still on the screen - this
1957 // is to help multi-screen setting UIs (like iOS) where they don't want to 1884 // is to help multi-screen setting UIs (like iOS) where they don't want to
1958 // start syncing data until the user is done configuring encryption options, 1885 // start syncing data until the user is done configuring encryption options,
1959 // etc. ReconfigureDatatypeManager() will get called again once the UI calls 1886 // etc. ReconfigureDatatypeManager() will get called again once the UI calls
1960 // SetSetupInProgress(false). 1887 // SetSetupInProgress(false).
1961 if (backend_mode_ == SYNC && startup_controller_->setup_in_progress()) 1888 if (backend_mode_ == SYNC && startup_controller_->setup_in_progress())
1962 return; 1889 return;
1963 1890
1964 bool restart = false; 1891 bool restart = false;
1965 if (!directory_data_type_manager_) { 1892 if (!data_type_manager_) {
1966 restart = true; 1893 restart = true;
1967 directory_data_type_manager_.reset( 1894 data_type_manager_.reset(factory_->CreateDataTypeManager(
1968 factory_->CreateDataTypeManager(debug_info_listener_, 1895 debug_info_listener_, &data_type_controllers_, this, backend_.get(),
1969 &directory_data_type_controllers_, 1896 this));
1970 this,
1971 backend_.get(),
1972 this));
1973 1897
1974 // We create the migrator at the same time. 1898 // We create the migrator at the same time.
1975 migrator_.reset( 1899 migrator_.reset(new browser_sync::BackendMigrator(
1976 new browser_sync::BackendMigrator( 1900 profile_->GetDebugName(), GetUserShare(), this,
1977 profile_->GetDebugName(), GetUserShare(), 1901 data_type_manager_.get(),
1978 this, directory_data_type_manager_.get(), 1902 base::Bind(&ProfileSyncService::StartSyncingWithServer,
1979 base::Bind(&ProfileSyncService::StartSyncingWithServer, 1903 base::Unretained(this))));
1980 base::Unretained(this))));
1981 } 1904 }
1982 1905
1983 syncer::ModelTypeSet types; 1906 syncer::ModelTypeSet types;
1984 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN; 1907 syncer::ConfigureReason reason = syncer::CONFIGURE_REASON_UNKNOWN;
1985 if (backend_mode_ == BACKUP || backend_mode_ == ROLLBACK) { 1908 if (backend_mode_ == BACKUP || backend_mode_ == ROLLBACK) {
1986 types = syncer::BackupTypes(); 1909 types = syncer::BackupTypes();
1987 reason = syncer::CONFIGURE_REASON_BACKUP_ROLLBACK; 1910 reason = syncer::CONFIGURE_REASON_BACKUP_ROLLBACK;
1988 } else { 1911 } else {
1989 types = GetPreferredDirectoryDataTypes(); 1912 types = GetPreferredDataTypes();
1990 if (!HasSyncSetupCompleted()) { 1913 if (!HasSyncSetupCompleted()) {
1991 reason = syncer::CONFIGURE_REASON_NEW_CLIENT; 1914 reason = syncer::CONFIGURE_REASON_NEW_CLIENT;
1992 } else if (restart) { 1915 } else if (restart) {
1993 // Datatype downloads on restart are generally due to newly supported 1916 // Datatype downloads on restart are generally due to newly supported
1994 // datatypes (although it's also possible we're picking up where a failed 1917 // datatypes (although it's also possible we're picking up where a failed
1995 // previous configuration left off). 1918 // previous configuration left off).
1996 // TODO(sync): consider detecting configuration recovery and setting 1919 // TODO(sync): consider detecting configuration recovery and setting
1997 // the reason here appropriately. 1920 // the reason here appropriately.
1998 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; 1921 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
1999 } else { 1922 } else {
2000 // The user initiated a reconfiguration (either to add or remove types). 1923 // The user initiated a reconfiguration (either to add or remove types).
2001 reason = syncer::CONFIGURE_REASON_RECONFIGURATION; 1924 reason = syncer::CONFIGURE_REASON_RECONFIGURATION;
2002 } 1925 }
2003 } 1926 }
2004 1927
2005 directory_data_type_manager_->Configure(types, reason); 1928 data_type_manager_->Configure(types, reason);
2006 } 1929 }
2007 1930
2008 syncer::UserShare* ProfileSyncService::GetUserShare() const { 1931 syncer::UserShare* ProfileSyncService::GetUserShare() const {
2009 if (backend_.get() && backend_initialized_) { 1932 if (backend_.get() && backend_initialized_) {
2010 return backend_->GetUserShare(); 1933 return backend_->GetUserShare();
2011 } 1934 }
2012 NOTREACHED(); 1935 NOTREACHED();
2013 return NULL; 1936 return NULL;
2014 } 1937 }
2015 1938
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 type_status->SetString("value", "Passive"); 2033 type_status->SetString("value", "Passive");
2111 } else if (throttled_types.Has(type) && passive_types.Has(type)) { 2034 } else if (throttled_types.Has(type) && passive_types.Has(type)) {
2112 type_status->SetString("status", "warning"); 2035 type_status->SetString("status", "warning");
2113 type_status->SetString("value", "Passive, Throttled"); 2036 type_status->SetString("value", "Passive, Throttled");
2114 } else if (passive_types.Has(type)) { 2037 } else if (passive_types.Has(type)) {
2115 type_status->SetString("status", "warning"); 2038 type_status->SetString("status", "warning");
2116 type_status->SetString("value", "Passive"); 2039 type_status->SetString("value", "Passive");
2117 } else if (throttled_types.Has(type)) { 2040 } else if (throttled_types.Has(type)) {
2118 type_status->SetString("status", "warning"); 2041 type_status->SetString("status", "warning");
2119 type_status->SetString("value", "Throttled"); 2042 type_status->SetString("value", "Throttled");
2120 } else if (GetRegisteredNonBlockingDataTypes().Has(type)) {
2121 type_status->SetString("status", "ok");
2122 type_status->SetString("value", "Non-Blocking");
2123 } else if (active_types.Has(type)) { 2043 } else if (active_types.Has(type)) {
2124 type_status->SetString("status", "ok"); 2044 type_status->SetString("status", "ok");
2125 type_status->SetString("value", "Active: " + 2045 type_status->SetString("value", "Active: " +
2126 ModelSafeGroupToString(routing_info[type])); 2046 ModelSafeGroupToString(routing_info[type]));
2127 } else { 2047 } else {
2128 type_status->SetString("status", "warning"); 2048 type_status->SetString("status", "warning");
2129 type_status->SetString("value", "Disabled by User"); 2049 type_status->SetString("value", "Disabled by User");
2130 } 2050 }
2131 2051
2132 int live_count = detailed_status.num_entries_by_type[type] - 2052 int live_count = detailed_status.num_entries_by_type[type] -
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2448 if (awaiting_types_.Empty()) { 2368 if (awaiting_types_.Empty()) {
2449 callback_.Run(result_accumulator_.Pass()); 2369 callback_.Run(result_accumulator_.Pass());
2450 callback_.Reset(); 2370 callback_.Reset();
2451 } 2371 }
2452 } 2372 }
2453 2373
2454 } // namespace 2374 } // namespace
2455 2375
2456 void ProfileSyncService::GetAllNodes( 2376 void ProfileSyncService::GetAllNodes(
2457 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback) { 2377 const base::Callback<void(scoped_ptr<base::ListValue>)>& callback) {
2458 ModelTypeSet directory_types = GetRegisteredDirectoryDataTypes(); 2378 // TODO(stanisc): crbug.com/328606: Make this work for USS datatypes.
2459 directory_types.PutAll(syncer::ControlTypes()); 2379 ModelTypeSet all_types = GetRegisteredDataTypes();
2380 all_types.PutAll(syncer::ControlTypes());
2460 scoped_refptr<GetAllNodesRequestHelper> helper = 2381 scoped_refptr<GetAllNodesRequestHelper> helper =
2461 new GetAllNodesRequestHelper(directory_types, callback); 2382 new GetAllNodesRequestHelper(all_types, callback);
2462 2383
2463 if (!backend_initialized_) { 2384 if (!backend_initialized_) {
2464 // If there's no backend available to fulfill the request, handle it here. 2385 // If there's no backend available to fulfill the request, handle it here.
2465 ScopedVector<base::ListValue> empty_results; 2386 ScopedVector<base::ListValue> empty_results;
2466 std::vector<ModelType> type_vector; 2387 std::vector<ModelType> type_vector;
2467 for (ModelTypeSet::Iterator it = directory_types.First(); 2388 for (ModelTypeSet::Iterator it = all_types.First(); it.Good(); it.Inc()) {
2468 it.Good(); it.Inc()) {
2469 type_vector.push_back(it.Get()); 2389 type_vector.push_back(it.Get());
2470 empty_results.push_back(new base::ListValue()); 2390 empty_results.push_back(new base::ListValue());
2471 } 2391 }
2472 helper->OnReceivedNodesForTypes(type_vector, empty_results.Pass()); 2392 helper->OnReceivedNodesForTypes(type_vector, empty_results.Pass());
2473 } else { 2393 } else {
2474 backend_->GetAllNodesForTypes( 2394 backend_->GetAllNodesForTypes(
2475 directory_types, 2395 all_types,
2476 base::Bind(&GetAllNodesRequestHelper::OnReceivedNodesForTypes, helper)); 2396 base::Bind(&GetAllNodesRequestHelper::OnReceivedNodesForTypes, helper));
2477 } 2397 }
2478 } 2398 }
2479 2399
2480 bool ProfileSyncService::HasObserver( 2400 bool ProfileSyncService::HasObserver(
2481 const sync_driver::SyncServiceObserver* observer) const { 2401 const sync_driver::SyncServiceObserver* observer) const {
2482 return observers_.HasObserver(observer); 2402 return observers_.HasObserver(observer);
2483 } 2403 }
2484 2404
2485 base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() { 2405 base::WeakPtr<syncer::JsController> ProfileSyncService::GetJsController() {
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 } 2715 }
2796 2716
2797 std::string ProfileSyncService::unrecoverable_error_message() const { 2717 std::string ProfileSyncService::unrecoverable_error_message() const {
2798 return unrecoverable_error_message_; 2718 return unrecoverable_error_message_;
2799 } 2719 }
2800 2720
2801 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2721 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2802 const { 2722 const {
2803 return unrecoverable_error_location_; 2723 return unrecoverable_error_location_;
2804 } 2724 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | components/sync_driver.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698