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

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

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

Powered by Google App Engine
This is Rietveld 408576698