OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 7 #include <stddef.h> |
8 #include <map> | 8 #include <map> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <set> | 10 #include <set> |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 void ProfileSyncService::Observe(int type, | 1256 void ProfileSyncService::Observe(int type, |
1257 const NotificationSource& source, | 1257 const NotificationSource& source, |
1258 const NotificationDetails& details) { | 1258 const NotificationDetails& details) { |
1259 switch (type) { | 1259 switch (type) { |
1260 case chrome::NOTIFICATION_SYNC_CONFIGURE_START: { | 1260 case chrome::NOTIFICATION_SYNC_CONFIGURE_START: { |
1261 NotifyObservers(); | 1261 NotifyObservers(); |
1262 // TODO(sync): Maybe toast? | 1262 // TODO(sync): Maybe toast? |
1263 break; | 1263 break; |
1264 } | 1264 } |
1265 case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: { | 1265 case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: { |
1266 DataTypeManager::ConfigureResult* result = | 1266 DataTypeManager::ConfigureResultWithErrorLocation* result_with_location = |
1267 Details<DataTypeManager::ConfigureResult>(details).ptr(); | 1267 Details<DataTypeManager::ConfigureResultWithErrorLocation>( |
| 1268 details).ptr(); |
1268 | 1269 |
1269 DataTypeManager::ConfigureStatus status = result->status; | 1270 DataTypeManager::ConfigureResult result = result_with_location->result; |
1270 VLOG(1) << "PSS SYNC_CONFIGURE_DONE called with status: " << status; | 1271 VLOG(1) << "PSS SYNC_CONFIGURE_DONE called with result: " << result; |
1271 if (status == DataTypeManager::ABORTED && | 1272 if (result == DataTypeManager::ABORTED && |
1272 expect_sync_configuration_aborted_) { | 1273 expect_sync_configuration_aborted_) { |
1273 VLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; | 1274 VLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; |
1274 expect_sync_configuration_aborted_ = false; | 1275 expect_sync_configuration_aborted_ = false; |
1275 return; | 1276 return; |
1276 } | 1277 } |
1277 // Clear out the gaia password if it is already there. | 1278 // Clear out the gaia password if it is already there. |
1278 gaia_password_ = std::string(); | 1279 gaia_password_ = std::string(); |
1279 if (status != DataTypeManager::OK) { | 1280 if (result != DataTypeManager::OK) { |
1280 VLOG(0) << "ProfileSyncService::Observe: Unrecoverable error detected"; | 1281 VLOG(0) << "ProfileSyncService::Observe: Unrecoverable error detected"; |
1281 std::string message = | 1282 std::string message = StringPrintf("Sync Configuration failed with %d", |
1282 "Sync Configuration failed while configuring " + | 1283 result); |
1283 syncable::ModelTypeSetToString(result->failed_types) + | 1284 OnUnrecoverableError(*(result_with_location->location), message); |
1284 ": " + DataTypeManager::ConfigureStatusToString(status); | |
1285 OnUnrecoverableError(result->location, message); | |
1286 cached_passphrase_ = CachedPassphrase(); | 1285 cached_passphrase_ = CachedPassphrase(); |
1287 return; | 1286 return; |
1288 } | 1287 } |
1289 | 1288 |
1290 // If the user had entered a custom passphrase use it now. | 1289 // If the user had entered a custom passphrase use it now. |
1291 if (!cached_passphrase_.value.empty()) { | 1290 if (!cached_passphrase_.value.empty()) { |
1292 // Don't hold on to the passphrase in raw form longer than needed. | 1291 // Don't hold on to the passphrase in raw form longer than needed. |
1293 SetPassphrase(cached_passphrase_.value, | 1292 SetPassphrase(cached_passphrase_.value, |
1294 cached_passphrase_.is_explicit, | 1293 cached_passphrase_.is_explicit, |
1295 cached_passphrase_.is_creation); | 1294 cached_passphrase_.is_creation); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 // is initialized, all enabled data types are consistent with one | 1419 // is initialized, all enabled data types are consistent with one |
1421 // another, and no unrecoverable error has transpired. | 1420 // another, and no unrecoverable error has transpired. |
1422 if (unrecoverable_error_detected_) | 1421 if (unrecoverable_error_detected_) |
1423 return false; | 1422 return false; |
1424 | 1423 |
1425 if (!data_type_manager_.get()) | 1424 if (!data_type_manager_.get()) |
1426 return false; | 1425 return false; |
1427 | 1426 |
1428 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1427 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
1429 } | 1428 } |
OLD | NEW |