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

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

Issue 420633002: [Sync] Cleanup datatype configuration error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 6 years, 4 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 | Annotate | Revision Log
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 <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 1460
1461 void ProfileSyncService::OnConfigureDone( 1461 void ProfileSyncService::OnConfigureDone(
1462 const DataTypeManager::ConfigureResult& result) { 1462 const DataTypeManager::ConfigureResult& result) {
1463 // We should have cleared our cached passphrase before we get here (in 1463 // We should have cleared our cached passphrase before we get here (in
1464 // OnBackendInitialized()). 1464 // OnBackendInitialized()).
1465 DCHECK(cached_passphrase_.empty()); 1465 DCHECK(cached_passphrase_.empty());
1466 1466
1467 configure_status_ = result.status; 1467 configure_status_ = result.status;
1468 1468
1469 if (backend_mode_ != SYNC) { 1469 if (backend_mode_ != SYNC) {
1470 if (configure_status_ == DataTypeManager::OK || 1470 if (configure_status_ == DataTypeManager::OK) {
1471 configure_status_ == DataTypeManager::PARTIAL_SUCCESS) {
1472 StartSyncingWithServer(); 1471 StartSyncingWithServer();
1473 } else if (!expect_sync_configuration_aborted_) { 1472 } else if (!expect_sync_configuration_aborted_) {
1474 DVLOG(1) << "Backup/rollback backend failed to configure."; 1473 DVLOG(1) << "Backup/rollback backend failed to configure.";
1475 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); 1474 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD);
1476 } 1475 }
1477 1476
1478 return; 1477 return;
1479 } 1478 }
1480 1479
1481 if (!sync_configure_start_time_.is_null()) { 1480 if (!sync_configure_start_time_.is_null()) {
1482 if (result.status == DataTypeManager::OK || 1481 if (result.status == DataTypeManager::OK) {
1483 result.status == DataTypeManager::PARTIAL_SUCCESS) {
1484 base::Time sync_configure_stop_time = base::Time::Now(); 1482 base::Time sync_configure_stop_time = base::Time::Now();
1485 base::TimeDelta delta = sync_configure_stop_time - 1483 base::TimeDelta delta = sync_configure_stop_time -
1486 sync_configure_start_time_; 1484 sync_configure_start_time_;
1487 if (is_first_time_sync_configure_) { 1485 if (is_first_time_sync_configure_) {
1488 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta); 1486 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceInitialConfigureTime", delta);
1489 } else { 1487 } else {
1490 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime", 1488 UMA_HISTOGRAM_LONG_TIMES("Sync.ServiceSubsequentConfigureTime",
1491 delta); 1489 delta);
1492 } 1490 }
1493 } 1491 }
1494 sync_configure_start_time_ = base::Time(); 1492 sync_configure_start_time_ = base::Time();
1495 } 1493 }
1496 1494
1497 // Notify listeners that configuration is done. 1495 // Notify listeners that configuration is done.
1498 content::NotificationService::current()->Notify( 1496 content::NotificationService::current()->Notify(
1499 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, 1497 chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
1500 content::Source<ProfileSyncService>(this), 1498 content::Source<ProfileSyncService>(this),
1501 content::NotificationService::NoDetails()); 1499 content::NotificationService::NoDetails());
1502 1500
1503 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_; 1501 DVLOG(1) << "PSS OnConfigureDone called with status: " << configure_status_;
1504 // The possible status values: 1502 // The possible status values:
1505 // ABORT - Configuration was aborted. This is not an error, if 1503 // ABORT - Configuration was aborted. This is not an error, if
1506 // initiated by user. 1504 // initiated by user.
1507 // OK - Everything succeeded. 1505 // OK - Some or all types succeeded.
1508 // PARTIAL_SUCCESS - Some datatypes failed to start.
1509 // Everything else is an UnrecoverableError. So treat it as such. 1506 // Everything else is an UnrecoverableError. So treat it as such.
1510 1507
1511 // First handle the abort case. 1508 // First handle the abort case.
1512 if (configure_status_ == DataTypeManager::ABORTED && 1509 if (configure_status_ == DataTypeManager::ABORTED &&
1513 expect_sync_configuration_aborted_) { 1510 expect_sync_configuration_aborted_) {
1514 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; 1511 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted";
1515 expect_sync_configuration_aborted_ = false; 1512 expect_sync_configuration_aborted_ = false;
1516 return; 1513 return;
1517 } 1514 }
1518 1515
1519 // Handle unrecoverable error. 1516 // Handle unrecoverable error.
1520 if (configure_status_ != DataTypeManager::OK && 1517 if (configure_status_ != DataTypeManager::OK) {
1521 configure_status_ != DataTypeManager::PARTIAL_SUCCESS) {
1522 // Something catastrophic had happened. We should only have one 1518 // Something catastrophic had happened. We should only have one
1523 // error representing it. 1519 // error representing it.
1524 DCHECK_EQ(result.failed_data_types.size(), 1520 syncer::SyncError error =
1525 static_cast<unsigned int>(1)); 1521 failed_data_types_handler_.GetUnrecoverableError();
1526 syncer::SyncError error = result.failed_data_types.begin()->second;
1527 DCHECK(error.IsSet()); 1522 DCHECK(error.IsSet());
1528 std::string message = 1523 std::string message =
1529 "Sync configuration failed with status " + 1524 "Sync configuration failed with status " +
1530 DataTypeManager::ConfigureStatusToString(configure_status_) + 1525 DataTypeManager::ConfigureStatusToString(configure_status_) +
1531 " during " + syncer::ModelTypeToString(error.model_type()) + 1526 " caused by " +
1527 syncer::ModelTypeSetToString(
1528 failed_data_types_handler_.GetUnrecoverableErrorTypes()) +
1532 ": " + error.message(); 1529 ": " + error.message();
1533 LOG(ERROR) << "ProfileSyncService error: " << message; 1530 LOG(ERROR) << "ProfileSyncService error: " << message;
1534 OnInternalUnrecoverableError(error.location(), 1531 OnInternalUnrecoverableError(error.location(),
1535 message, 1532 message,
1536 true, 1533 true,
1537 ERROR_REASON_CONFIGURATION_FAILURE); 1534 ERROR_REASON_CONFIGURATION_FAILURE);
1538 return; 1535 return;
1539 } 1536 }
1540 1537
1541 // We should never get in a state where we have no encrypted datatypes 1538 // We should never get in a state where we have no encrypted datatypes
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 browser_sync::SyncedDeviceTracker* device_tracker = 2657 browser_sync::SyncedDeviceTracker* device_tracker =
2661 backend_->GetSyncedDeviceTracker(); 2658 backend_->GetSyncedDeviceTracker();
2662 if (device_tracker) 2659 if (device_tracker)
2663 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); 2660 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_);
2664 } 2661 }
2665 } 2662 }
2666 2663
2667 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { 2664 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
2668 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); 2665 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
2669 } 2666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698