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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 | 1463 |
1464 void ProfileSyncService::OnConfigureDone( | 1464 void ProfileSyncService::OnConfigureDone( |
1465 const DataTypeManager::ConfigureResult& result) { | 1465 const DataTypeManager::ConfigureResult& result) { |
1466 // We should have cleared our cached passphrase before we get here (in | 1466 // We should have cleared our cached passphrase before we get here (in |
1467 // OnBackendInitialized()). | 1467 // OnBackendInitialized()). |
1468 DCHECK(cached_passphrase_.empty()); | 1468 DCHECK(cached_passphrase_.empty()); |
1469 | 1469 |
1470 configure_status_ = result.status; | 1470 configure_status_ = result.status; |
1471 | 1471 |
1472 if (backend_mode_ != SYNC) { | 1472 if (backend_mode_ != SYNC) { |
1473 if (configure_status_ == DataTypeManager::OK) { | 1473 if (configure_status_ == DataTypeManager::OK || |
| 1474 configure_status_ == DataTypeManager::PARTIAL_SUCCESS) { |
1474 StartSyncingWithServer(); | 1475 StartSyncingWithServer(); |
1475 } else if (!expect_sync_configuration_aborted_) { | 1476 } else if (!expect_sync_configuration_aborted_) { |
1476 DVLOG(1) << "Backup/rollback backend failed to configure."; | 1477 DVLOG(1) << "Backup/rollback backend failed to configure."; |
1477 ShutdownImpl(syncer::STOP_SYNC); | 1478 ShutdownImpl(syncer::STOP_SYNC); |
1478 } | 1479 } |
1479 | 1480 |
1480 return; | 1481 return; |
1481 } | 1482 } |
1482 | 1483 |
1483 if (!sync_configure_start_time_.is_null()) { | 1484 if (!sync_configure_start_time_.is_null()) { |
1484 if (result.status == DataTypeManager::OK) { | 1485 if (result.status == DataTypeManager::OK || |
| 1486 result.status == DataTypeManager::PARTIAL_SUCCESS) { |
1485 base::Time sync_configure_stop_time = base::Time::Now(); | 1487 base::Time sync_configure_stop_time = base::Time::Now(); |
1486 base::TimeDelta delta = sync_configure_stop_time - | 1488 base::TimeDelta delta = sync_configure_stop_time - |
1487 sync_configure_start_time_; | 1489 sync_configure_start_time_; |
1488 if (is_first_time_sync_configure_) { | 1490 if (is_first_time_sync_configure_) { |
1489 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); | 1491 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); |
1490 } else { | 1492 } else { |
1491 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", | 1493 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", |
1492 delta); | 1494 delta); |
1493 } | 1495 } |
1494 } | 1496 } |
1495 sync_configure_start_time_ = base::Time(); | 1497 sync_configure_start_time_ = base::Time(); |
1496 } | 1498 } |
1497 | 1499 |
1498 // Notify listeners that configuration is done. | 1500 // Notify listeners that configuration is done. |
1499 content::NotificationService::current()->Notify( | 1501 content::NotificationService::current()->Notify( |
1500 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | 1502 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |
1501 content::Source<ProfileSyncService>(this), | 1503 content::Source<ProfileSyncService>(this), |
1502 content::NotificationService::NoDetails()); | 1504 content::NotificationService::NoDetails()); |
1503 | 1505 |
1504 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; | 1506 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; |
1505 // The possible status values: | 1507 // The possible status values: |
1506 // ABORT - Configuration was aborted. This is not an error, if | 1508 // ABORT - Configuration was aborted. This is not an error, if |
1507 // initiated by user. | 1509 // initiated by user. |
1508 // OK - Some or all types succeeded. | 1510 // OK - Everything succeeded. |
| 1511 // PARTIAL_SUCCESS - Some datatypes failed to start. |
1509 // Everything else is an UnrecoverableError. So treat it as such. | 1512 // Everything else is an UnrecoverableError. So treat it as such. |
1510 | 1513 |
1511 // First handle the abort case. | 1514 // First handle the abort case. |
1512 if (configure_status_ == DataTypeManager::ABORTED && | 1515 if (configure_status_ == DataTypeManager::ABORTED && |
1513 expect_sync_configuration_aborted_) { | 1516 expect_sync_configuration_aborted_) { |
1514 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; | 1517 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; |
1515 expect_sync_configuration_aborted_ = false; | 1518 expect_sync_configuration_aborted_ = false; |
1516 return; | 1519 return; |
1517 } | 1520 } |
1518 | 1521 |
1519 // Handle unrecoverable error. | 1522 // Handle unrecoverable error. |
1520 if (configure_status_ != DataTypeManager::OK) { | 1523 if (configure_status_ != DataTypeManager::OK && |
| 1524 configure_status_ != DataTypeManager::PARTIAL_SUCCESS) { |
1521 // Something catastrophic had happened. We should only have one | 1525 // Something catastrophic had happened. We should only have one |
1522 // error representing it. | 1526 // error representing it. |
1523 syncer::SyncError error = | 1527 DCHECK_EQ(result.failed_data_types.size(), |
1524 failed_data_types_handler_.GetUnrecoverableError(); | 1528 static_cast<unsigned int>(1)); |
| 1529 syncer::SyncError error = result.failed_data_types.begin()->second; |
1525 DCHECK(error.IsSet()); | 1530 DCHECK(error.IsSet()); |
1526 std::string message = | 1531 std::string message = |
1527 "Sync configuration failed with status " + | 1532 "Sync configuration failed with status " + |
1528 DataTypeManager::ConfigureStatusToString(configure_status_) + | 1533 DataTypeManager::ConfigureStatusToString(configure_status_) + |
1529 " caused by " + | 1534 " during " + syncer::ModelTypeToString(error.model_type()) + |
1530 syncer::ModelTypeSetToString( | |
1531 failed_data_types_handler_.GetUnrecoverableErrorTypes()) + | |
1532 ": " + error.message(); | 1535 ": " + error.message(); |
1533 LOG(ERROR) << "ProfileSyncService error: " << message; | 1536 LOG(ERROR) << "ProfileSyncService error: " << message; |
1534 OnInternalUnrecoverableError(error.location(), | 1537 OnInternalUnrecoverableError(error.location(), |
1535 message, | 1538 message, |
1536 true, | 1539 true, |
1537 ERROR_REASON_CONFIGURATION_FAILURE); | 1540 ERROR_REASON_CONFIGURATION_FAILURE); |
1538 return; | 1541 return; |
1539 } | 1542 } |
1540 | 1543 |
1541 // We should never get in a state where we have no encrypted datatypes | 1544 // We should never get in a state where we have no encrypted datatypes |
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 browser_sync::SyncedDeviceTracker* device_tracker = | 2695 browser_sync::SyncedDeviceTracker* device_tracker = |
2693 backend_->GetSyncedDeviceTracker(); | 2696 backend_->GetSyncedDeviceTracker(); |
2694 if (device_tracker) | 2697 if (device_tracker) |
2695 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); | 2698 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); |
2696 } | 2699 } |
2697 } | 2700 } |
2698 | 2701 |
2699 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2702 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
2700 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); | 2703 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); |
2701 } | 2704 } |
OLD | NEW |