Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 syncable::ModelTypeSet types; | 407 syncable::ModelTypeSet types; |
| 408 // If sync setup hasn't finished, we don't want to initialize routing info | 408 // If sync setup hasn't finished, we don't want to initialize routing info |
| 409 // for any data types so that we don't download updates for types that the | 409 // for any data types so that we don't download updates for types that the |
| 410 // user chooses not to sync on the first DownloadUpdatesCommand. | 410 // user chooses not to sync on the first DownloadUpdatesCommand. |
| 411 if (HasSyncSetupCompleted()) { | 411 if (HasSyncSetupCompleted()) { |
| 412 GetPreferredDataTypes(&types); | 412 GetPreferredDataTypes(&types); |
| 413 } | 413 } |
| 414 | 414 |
| 415 SyncCredentials credentials = GetCredentials(); | 415 SyncCredentials credentials = GetCredentials(); |
| 416 | 416 |
| 417 backend_->Initialize(sync_service_url_, | 417 backend_->Initialize(this, |
| 418 sync_service_url_, | |
| 418 types, | 419 types, |
| 419 profile_->GetRequestContext(), | 420 profile_->GetRequestContext(), |
| 420 credentials, | 421 credentials, |
| 421 delete_sync_data_folder, | 422 delete_sync_data_folder, |
| 422 notifier_options_); | 423 notifier_options_); |
| 423 } | 424 } |
| 424 | 425 |
| 425 void ProfileSyncService::CreateBackend() { | 426 void ProfileSyncService::CreateBackend() { |
| 426 backend_.reset(new SyncBackendHost(this, profile_)); | 427 backend_.reset(new SyncBackendHost(profile_)); |
| 427 } | 428 } |
| 428 | 429 |
| 429 void ProfileSyncService::StartUp() { | 430 void ProfileSyncService::StartUp() { |
| 430 // Don't start up multiple times. | 431 // Don't start up multiple times. |
| 431 if (backend_.get()) { | 432 if (backend_.get()) { |
| 432 VLOG(1) << "Skipping bringing up backend host."; | 433 VLOG(1) << "Skipping bringing up backend host."; |
| 433 return; | 434 return; |
| 434 } | 435 } |
| 435 | 436 |
| 436 DCHECK(AreCredentialsAvailable()); | 437 DCHECK(AreCredentialsAvailable()); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { | 1007 bool ProfileSyncService::IsUsingSecondaryPassphrase() const { |
| 1007 return backend_.get() && (backend_->IsUsingExplicitPassphrase() || | 1008 return backend_.get() && (backend_->IsUsingExplicitPassphrase() || |
| 1008 (tried_implicit_gaia_remove_when_bug_62103_fixed_ && | 1009 (tried_implicit_gaia_remove_when_bug_62103_fixed_ && |
| 1009 observed_passphrase_required_)); | 1010 observed_passphrase_required_)); |
| 1010 } | 1011 } |
| 1011 | 1012 |
| 1012 bool ProfileSyncService::IsCryptographerReady() const { | 1013 bool ProfileSyncService::IsCryptographerReady() const { |
| 1013 return backend_.get() && backend_->IsCryptographerReady(); | 1014 return backend_.get() && backend_->IsCryptographerReady(); |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1017 SyncBackendHost* ProfileSyncService::GetBackendForTest() { | |
| 1018 // We don't check |backend_initialized_|; we assume the test class | |
| 1019 // knows what it's doing. | |
| 1020 return backend_.get(); | |
| 1021 } | |
| 1022 | |
| 1016 void ProfileSyncService::ConfigureDataTypeManager() { | 1023 void ProfileSyncService::ConfigureDataTypeManager() { |
| 1017 if (!data_type_manager_.get()) { | 1024 if (!data_type_manager_.get()) { |
| 1018 data_type_manager_.reset( | 1025 data_type_manager_.reset( |
| 1019 factory_->CreateDataTypeManager(backend_.get(), | 1026 factory_->CreateDataTypeManager(backend_.get(), |
| 1020 data_type_controllers_)); | 1027 data_type_controllers_)); |
| 1021 registrar_.Add(this, | 1028 registrar_.Add(this, |
| 1022 NotificationType::SYNC_CONFIGURE_START, | 1029 NotificationType::SYNC_CONFIGURE_START, |
| 1023 Source<DataTypeManager>(data_type_manager_.get())); | 1030 Source<DataTypeManager>(data_type_manager_.get())); |
| 1024 registrar_.Add(this, | 1031 registrar_.Add(this, |
| 1025 NotificationType::SYNC_CONFIGURE_DONE, | 1032 NotificationType::SYNC_CONFIGURE_DONE, |
| 1026 Source<DataTypeManager>(data_type_manager_.get())); | 1033 Source<DataTypeManager>(data_type_manager_.get())); |
| 1027 } | 1034 } |
| 1028 | 1035 |
| 1029 syncable::ModelTypeSet types; | 1036 syncable::ModelTypeSet types; |
| 1030 GetPreferredDataTypes(&types); | 1037 GetPreferredDataTypes(&types); |
| 1031 data_type_manager_->Configure(types); | 1038 data_type_manager_->Configure(types); |
| 1032 } | 1039 } |
| 1033 | 1040 |
| 1041 ProfileSyncService::UserShareHandle | |
| 1042 ProfileSyncService::GetUserShareHandle() const { | |
| 1043 if (backend_.get() && backend_initialized_) { | |
| 1044 return backend_->GetUserShareHandle(); | |
| 1045 } | |
| 1046 NOTREACHED(); | |
| 1047 return NULL; | |
| 1048 } | |
| 1049 | |
| 1050 const browser_sync::sessions::SyncSessionSnapshot* | |
| 1051 ProfileSyncService::GetLastSessionSnapshot() const { | |
| 1052 if (backend_.get() && backend_initialized_) { | |
| 1053 return backend_->GetLastSessionSnapshot(); | |
| 1054 } | |
| 1055 NOTREACHED(); | |
| 1056 return NULL; | |
| 1057 } | |
| 1058 | |
| 1059 bool ProfileSyncService::HasUnsyncedItems() const { | |
| 1060 if (backend_.get() && backend_initialized_) { | |
| 1061 return backend_->HasUnsyncedItems(); | |
| 1062 } | |
| 1063 NOTREACHED(); | |
| 1064 return false; | |
| 1065 } | |
| 1066 | |
| 1067 void ProfileSyncService::GetModelSafeRoutingInfo( | |
| 1068 browser_sync::ModelSafeRoutingInfo* out) { | |
| 1069 if (backend_.get() && backend_initialized_) { | |
| 1070 backend_->GetModelSafeRoutingInfo(out); | |
|
tim (not reviewing)
2011/01/21 18:17:00
return; ?
akalin
2011/01/21 21:21:09
Done.
| |
| 1071 } | |
| 1072 NOTREACHED(); | |
| 1073 } | |
| 1074 | |
| 1075 syncable::AutofillMigrationState | |
| 1076 ProfileSyncService::GetAutofillMigrationState() { | |
| 1077 if (backend_.get() && backend_initialized_) { | |
| 1078 return backend_->GetAutofillMigrationState(); | |
| 1079 } | |
| 1080 NOTREACHED(); | |
| 1081 return syncable::NOT_DETERMINED; | |
| 1082 } | |
| 1083 | |
| 1084 void ProfileSyncService::SetAutofillMigrationState( | |
| 1085 syncable::AutofillMigrationState state) { | |
| 1086 if (backend_.get() && backend_initialized_) { | |
| 1087 backend_->SetAutofillMigrationState(state); | |
| 1088 } else { | |
| 1089 NOTREACHED(); | |
| 1090 } | |
| 1091 } | |
| 1092 | |
| 1093 syncable::AutofillMigrationDebugInfo | |
| 1094 ProfileSyncService::GetAutofillMigrationDebugInfo() { | |
| 1095 if (backend_.get() && backend_initialized_) { | |
| 1096 return backend_->GetAutofillMigrationDebugInfo(); | |
| 1097 } | |
| 1098 NOTREACHED(); | |
| 1099 syncable::AutofillMigrationDebugInfo debug_info = { 0 }; | |
| 1100 return debug_info; | |
| 1101 } | |
| 1102 | |
| 1103 void ProfileSyncService::SetAutofillMigrationDebugInfo( | |
| 1104 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, | |
| 1105 const syncable::AutofillMigrationDebugInfo& info) { | |
| 1106 if (backend_.get() && backend_initialized_) { | |
| 1107 backend_->SetAutofillMigrationDebugInfo(property_to_set, info); | |
| 1108 } else { | |
| 1109 NOTREACHED(); | |
| 1110 } | |
| 1111 } | |
| 1112 | |
| 1034 void ProfileSyncService::ActivateDataType( | 1113 void ProfileSyncService::ActivateDataType( |
| 1035 DataTypeController* data_type_controller, | 1114 DataTypeController* data_type_controller, |
| 1036 ChangeProcessor* change_processor) { | 1115 ChangeProcessor* change_processor) { |
| 1037 if (!backend_.get()) { | 1116 if (!backend_.get()) { |
| 1038 NOTREACHED(); | 1117 NOTREACHED(); |
| 1039 return; | 1118 return; |
| 1040 } | 1119 } |
| 1041 DCHECK(backend_initialized_); | 1120 DCHECK(backend_initialized_); |
| 1042 change_processor->Start(profile(), backend_->GetUserShareHandle()); | 1121 change_processor->Start(profile(), backend_->GetUserShareHandle()); |
| 1043 backend_->ActivateDataType(data_type_controller, change_processor); | 1122 backend_->ActivateDataType(data_type_controller, change_processor); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1224 // is initialized, all enabled data types are consistent with one | 1303 // is initialized, all enabled data types are consistent with one |
| 1225 // another, and no unrecoverable error has transpired. | 1304 // another, and no unrecoverable error has transpired. |
| 1226 if (unrecoverable_error_detected_) | 1305 if (unrecoverable_error_detected_) |
| 1227 return false; | 1306 return false; |
| 1228 | 1307 |
| 1229 if (!data_type_manager_.get()) | 1308 if (!data_type_manager_.get()) |
| 1230 return false; | 1309 return false; |
| 1231 | 1310 |
| 1232 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1311 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 1233 } | 1312 } |
| OLD | NEW |