Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 return !Intersection(preferred_types, encrypted_types).Empty(); | 347 return !Intersection(preferred_types, encrypted_types).Empty(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void ProfileSyncService::OnSyncConfigureDone( | 350 void ProfileSyncService::OnSyncConfigureDone( |
| 351 DataTypeManager::ConfigureResult result) { | 351 DataTypeManager::ConfigureResult result) { |
| 352 if (failed_datatypes_handler_.UpdateFailedDatatypes(result)) { | 352 if (failed_datatypes_handler_.UpdateFailedDatatypes(result)) { |
| 353 ReconfigureDatatypeManager(); | 353 ReconfigureDatatypeManager(); |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 void ProfileSyncService::OnSyncConfigureRetry() { | |
| 358 if (wizard_.IsVisible()) { | |
|
Andrew T Wilson (Slow)
2012/01/27 00:19:03
Instead of forwarding this to the SyncSetupWizard
lipalani1
2012/01/27 02:54:29
Done.
| |
| 359 wizard_.Step(SyncSetupWizard::CONFIGURE_RETRY); | |
|
Andrew T Wilson (Slow)
2012/01/27 00:19:03
Soon, SyncSetupWizard will be going away. Instead,
lipalani1
2012/01/27 02:54:29
Done.
| |
| 360 } | |
| 361 | |
| 362 // If the wizard is not visible nothing more to do. We just wait until | |
| 363 // configure succeeds. | |
| 364 } | |
| 365 | |
| 366 | |
| 357 void ProfileSyncService::StartUp() { | 367 void ProfileSyncService::StartUp() { |
| 358 // Don't start up multiple times. | 368 // Don't start up multiple times. |
| 359 if (backend_.get()) { | 369 if (backend_.get()) { |
| 360 DVLOG(1) << "Skipping bringing up backend host."; | 370 DVLOG(1) << "Skipping bringing up backend host."; |
| 361 return; | 371 return; |
| 362 } | 372 } |
| 363 | 373 |
| 364 DCHECK(AreCredentialsAvailable()); | 374 DCHECK(AreCredentialsAvailable()); |
| 365 | 375 |
| 366 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); | 376 last_synced_time_ = sync_prefs_.GetLastSyncedTime(); |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1328 NotifyObservers(); | 1338 NotifyObservers(); |
| 1329 // TODO(sync): Maybe toast? | 1339 // TODO(sync): Maybe toast? |
| 1330 break; | 1340 break; |
| 1331 } | 1341 } |
| 1332 case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: { | 1342 case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: { |
| 1333 DataTypeManager::ConfigureResult* result = | 1343 DataTypeManager::ConfigureResult* result = |
| 1334 content::Details<DataTypeManager::ConfigureResult>(details).ptr(); | 1344 content::Details<DataTypeManager::ConfigureResult>(details).ptr(); |
| 1335 | 1345 |
| 1336 DataTypeManager::ConfigureStatus status = result->status; | 1346 DataTypeManager::ConfigureStatus status = result->status; |
| 1337 DVLOG(1) << "PSS SYNC_CONFIGURE_DONE called with status: " << status; | 1347 DVLOG(1) << "PSS SYNC_CONFIGURE_DONE called with status: " << status; |
| 1348 | |
| 1349 // The possible status values: | |
| 1350 // ABORT - Configuration was aborted. This is not an error, if | |
| 1351 // initiated by user.. | |
| 1352 // RETRY - Configure failed but we are retrying. | |
| 1353 // OK - Everything succeeded. | |
| 1354 // PARTIAL_SUCCESS - Some datatypes failed to start. | |
| 1355 // Everything else is an UnrecoverableError. So treat it as such. | |
| 1356 | |
| 1357 // First handle the abort case. | |
| 1338 if (status == DataTypeManager::ABORTED && | 1358 if (status == DataTypeManager::ABORTED && |
| 1339 expect_sync_configuration_aborted_) { | 1359 expect_sync_configuration_aborted_) { |
| 1340 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; | 1360 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; |
| 1341 expect_sync_configuration_aborted_ = false; | 1361 expect_sync_configuration_aborted_ = false; |
| 1342 return; | 1362 return; |
| 1343 } | 1363 } |
| 1364 | |
| 1365 // Handle retry case. | |
| 1366 if (status == DataTypeManager::RETRY) { | |
| 1367 OnSyncConfigureRetry(); | |
| 1368 return; | |
| 1369 } | |
| 1370 | |
| 1371 // Hanlde unrecoverable error. | |
|
Andrew T Wilson (Slow)
2012/01/27 00:19:03
nit: Hanlde->Handle
lipalani1
2012/01/27 02:54:29
Done.
| |
| 1344 if (status != DataTypeManager::OK && | 1372 if (status != DataTypeManager::OK && |
| 1345 status != DataTypeManager::PARTIAL_SUCCESS) { | 1373 status != DataTypeManager::PARTIAL_SUCCESS) { |
| 1346 // Something catastrophic had happened. We should only have one | 1374 // Something catastrophic had happened. We should only have one |
| 1347 // error representing it. | 1375 // error representing it. |
| 1348 DCHECK(result->errors.size() == 1); | 1376 DCHECK(result->errors.size() == 1); |
| 1349 SyncError error = result->errors.front(); | 1377 SyncError error = result->errors.front(); |
| 1350 DCHECK(error.IsSet()); | 1378 DCHECK(error.IsSet()); |
| 1351 std::string message = | 1379 std::string message = |
| 1352 "Sync configuration failed with status " + | 1380 "Sync configuration failed with status " + |
| 1353 DataTypeManager::ConfigureStatusToString(status) + | 1381 DataTypeManager::ConfigureStatusToString(status) + |
| 1354 " during " + syncable::ModelTypeToString(error.type()) + | 1382 " during " + syncable::ModelTypeToString(error.type()) + |
| 1355 ": " + error.message(); | 1383 ": " + error.message(); |
| 1356 LOG(ERROR) << "ProfileSyncService error: " | 1384 LOG(ERROR) << "ProfileSyncService error: " |
| 1357 << message; | 1385 << message; |
| 1358 // TODO: Don't | 1386 // TODO: Don't |
| 1359 OnUnrecoverableError(error.location(), message); | 1387 OnUnrecoverableError(error.location(), message); |
| 1360 return; | 1388 return; |
| 1361 } | 1389 } |
| 1362 | 1390 |
| 1391 // Now handle partial success and full success. | |
| 1363 MessageLoop::current()->PostTask(FROM_HERE, | 1392 MessageLoop::current()->PostTask(FROM_HERE, |
| 1364 base::Bind(&ProfileSyncService::OnSyncConfigureDone, | 1393 base::Bind(&ProfileSyncService::OnSyncConfigureDone, |
| 1365 weak_factory_.GetWeakPtr(), *result)); | 1394 weak_factory_.GetWeakPtr(), *result)); |
| 1366 | 1395 |
| 1367 // We should never get in a state where we have no encrypted datatypes | 1396 // We should never get in a state where we have no encrypted datatypes |
| 1368 // enabled, and yet we still think we require a passphrase for decryption. | 1397 // enabled, and yet we still think we require a passphrase for decryption. |
| 1369 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1398 DCHECK(!(IsPassphraseRequiredForDecryption() && |
| 1370 !IsEncryptedDatatypeEnabled())); | 1399 !IsEncryptedDatatypeEnabled())); |
| 1371 | 1400 |
| 1372 // This must be done before we start syncing with the server to avoid | 1401 // This must be done before we start syncing with the server to avoid |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1560 << "Unrecoverable error."; | 1589 << "Unrecoverable error."; |
| 1561 } else { | 1590 } else { |
| 1562 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " | 1591 DVLOG(0) << "ConfigureDataTypeManager not invoked because backend is not " |
| 1563 << "initialized"; | 1592 << "initialized"; |
| 1564 } | 1593 } |
| 1565 } | 1594 } |
| 1566 | 1595 |
| 1567 const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() { | 1596 const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() { |
| 1568 return failed_datatypes_handler_; | 1597 return failed_datatypes_handler_; |
| 1569 } | 1598 } |
| OLD | NEW |