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

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

Issue 534733002: Revert "[Sync] Move DataTypeStatusTable ownership into DataTypeManager." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 955
956 void ProfileSyncService::NotifySyncCycleCompleted() { 956 void ProfileSyncService::NotifySyncCycleCompleted() {
957 FOR_EACH_OBSERVER(ProfileSyncServiceBase::Observer, observers_, 957 FOR_EACH_OBSERVER(ProfileSyncServiceBase::Observer, observers_,
958 OnSyncCycleCompleted()); 958 OnSyncCycleCompleted());
959 } 959 }
960 960
961 void ProfileSyncService::ClearStaleErrors() { 961 void ProfileSyncService::ClearStaleErrors() {
962 ClearUnrecoverableError(); 962 ClearUnrecoverableError();
963 last_actionable_error_ = SyncProtocolError(); 963 last_actionable_error_ = SyncProtocolError();
964 // Clear the data type errors as well. 964 // Clear the data type errors as well.
965 if (directory_data_type_manager_.get()) 965 data_type_status_table_.Reset();
966 directory_data_type_manager_->ResetDataTypeErrors();
967
968 } 966 }
969 967
970 void ProfileSyncService::ClearUnrecoverableError() { 968 void ProfileSyncService::ClearUnrecoverableError() {
971 unrecoverable_error_reason_ = ERROR_REASON_UNSET; 969 unrecoverable_error_reason_ = ERROR_REASON_UNSET;
972 unrecoverable_error_message_.clear(); 970 unrecoverable_error_message_.clear();
973 unrecoverable_error_location_ = tracked_objects::Location(); 971 unrecoverable_error_location_ = tracked_objects::Location();
974 } 972 }
975 973
976 void ProfileSyncService::RegisterNewDataType(syncer::ModelType data_type) { 974 void ProfileSyncService::RegisterNewDataType(syncer::ModelType data_type) {
977 if (directory_data_type_controllers_.count(data_type) > 0) 975 if (directory_data_type_controllers_.count(data_type) > 0)
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 syncer::ModelTypeSet encrypted_types, 1403 syncer::ModelTypeSet encrypted_types,
1406 bool encrypt_everything) { 1404 bool encrypt_everything) {
1407 encrypted_types_ = encrypted_types; 1405 encrypted_types_ = encrypted_types;
1408 encrypt_everything_ = encrypt_everything; 1406 encrypt_everything_ = encrypt_everything;
1409 DVLOG(1) << "Encrypted types changed to " 1407 DVLOG(1) << "Encrypted types changed to "
1410 << syncer::ModelTypeSetToString(encrypted_types_) 1408 << syncer::ModelTypeSetToString(encrypted_types_)
1411 << " (encrypt everything is set to " 1409 << " (encrypt everything is set to "
1412 << (encrypt_everything_ ? "true" : "false") << ")"; 1410 << (encrypt_everything_ ? "true" : "false") << ")";
1413 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); 1411 DCHECK(encrypted_types_.Has(syncer::PASSWORDS));
1414 1412
1415 NotifyObservers(); 1413 // If sessions are encrypted, full history sync is not possible, and
1414 // delete directives are unnecessary.
1415 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
1416 encrypted_types_.Has(syncer::SESSIONS)) {
1417 syncer::SyncError error(
1418 FROM_HERE,
1419 syncer::SyncError::DATATYPE_POLICY_ERROR,
1420 "Delete directives not supported with encryption.",
1421 syncer::HISTORY_DELETE_DIRECTIVES);
1422 DataTypeStatusTable::TypeErrorMap error_map;
1423 error_map[error.model_type()] = error;
1424 data_type_status_table_.UpdateFailedDataTypes(error_map);
1425 ReconfigureDatatypeManager();
1426 }
1416 } 1427 }
1417 1428
1418 void ProfileSyncService::OnEncryptionComplete() { 1429 void ProfileSyncService::OnEncryptionComplete() {
1419 DVLOG(1) << "Encryption complete"; 1430 DVLOG(1) << "Encryption complete";
1420 if (encryption_pending_ && encrypt_everything_) { 1431 if (encryption_pending_ && encrypt_everything_) {
1421 encryption_pending_ = false; 1432 encryption_pending_ = false;
1422 // This is to nudge the integration tests when encryption is 1433 // This is to nudge the integration tests when encryption is
1423 // finished. 1434 // finished.
1424 NotifyObservers(); 1435 NotifyObservers();
1425 } 1436 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 } else if (error.action == syncer::ROLLBACK_DONE) { 1504 } else if (error.action == syncer::ROLLBACK_DONE) {
1494 // Shut down ROLLBACK backend and delete backup DB. 1505 // Shut down ROLLBACK backend and delete backup DB.
1495 ShutdownImpl(syncer::DISABLE_SYNC); 1506 ShutdownImpl(syncer::DISABLE_SYNC);
1496 sync_prefs_.ClearFirstSyncTime(); 1507 sync_prefs_.ClearFirstSyncTime();
1497 } 1508 }
1498 } 1509 }
1499 1510
1500 void ProfileSyncService::OnConfigureDone( 1511 void ProfileSyncService::OnConfigureDone(
1501 const DataTypeManager::ConfigureResult& result) { 1512 const DataTypeManager::ConfigureResult& result) {
1502 configure_status_ = result.status; 1513 configure_status_ = result.status;
1503 data_type_status_table_ = result.data_type_status_table;
1504 1514
1505 if (backend_mode_ != SYNC) { 1515 if (backend_mode_ != SYNC) {
1506 if (configure_status_ == DataTypeManager::OK) { 1516 if (configure_status_ == DataTypeManager::OK) {
1507 StartSyncingWithServer(); 1517 StartSyncingWithServer();
1508 1518
1509 // Backup is done after models are associated. 1519 // Backup is done after models are associated.
1510 if (backend_mode_ == BACKUP) 1520 if (backend_mode_ == BACKUP)
1511 backup_finished_ = true; 1521 backup_finished_ = true;
1512 1522
1513 // Asynchronously check whether sync needs to start. 1523 // Asynchronously check whether sync needs to start.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 bool sync_everything, 1833 bool sync_everything,
1824 syncer::ModelTypeSet chosen_types) { 1834 syncer::ModelTypeSet chosen_types) {
1825 if (!backend_.get() && !HasUnrecoverableError()) { 1835 if (!backend_.get() && !HasUnrecoverableError()) {
1826 NOTREACHED(); 1836 NOTREACHED();
1827 return; 1837 return;
1828 } 1838 }
1829 1839
1830 UpdateSelectedTypesHistogram(sync_everything, chosen_types); 1840 UpdateSelectedTypesHistogram(sync_everything, chosen_types);
1831 sync_prefs_.SetKeepEverythingSynced(sync_everything); 1841 sync_prefs_.SetKeepEverythingSynced(sync_everything);
1832 1842
1833 if (directory_data_type_manager_.get()) 1843 data_type_status_table_.Reset();
1834 directory_data_type_manager_->ResetDataTypeErrors(); 1844 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
1845 encrypted_types_.Has(syncer::SESSIONS)) {
1846 syncer::SyncError error(
1847 FROM_HERE,
1848 syncer::SyncError::DATATYPE_POLICY_ERROR,
1849 "Delete directives not supported with encryption.",
1850 syncer::HISTORY_DELETE_DIRECTIVES);
1851 DataTypeStatusTable::TypeErrorMap error_map;
1852 error_map[error.model_type()] = error;
1853 data_type_status_table_.UpdateFailedDataTypes(error_map);
1854 }
1835 ChangePreferredDataTypes(chosen_types); 1855 ChangePreferredDataTypes(chosen_types);
1836 AcknowledgeSyncedTypes(); 1856 AcknowledgeSyncedTypes();
1837 NotifyObservers(); 1857 NotifyObservers();
1838 } 1858 }
1839 1859
1840 void ProfileSyncService::ChangePreferredDataTypes( 1860 void ProfileSyncService::ChangePreferredDataTypes(
1841 syncer::ModelTypeSet preferred_types) { 1861 syncer::ModelTypeSet preferred_types) {
1842 1862
1843 DVLOG(1) << "ChangePreferredDataTypes invoked"; 1863 DVLOG(1) << "ChangePreferredDataTypes invoked";
1844 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1864 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 return; 1979 return;
1960 1980
1961 bool restart = false; 1981 bool restart = false;
1962 if (!directory_data_type_manager_) { 1982 if (!directory_data_type_manager_) {
1963 restart = true; 1983 restart = true;
1964 directory_data_type_manager_.reset( 1984 directory_data_type_manager_.reset(
1965 factory_->CreateDataTypeManager(debug_info_listener_, 1985 factory_->CreateDataTypeManager(debug_info_listener_,
1966 &directory_data_type_controllers_, 1986 &directory_data_type_controllers_,
1967 this, 1987 this,
1968 backend_.get(), 1988 backend_.get(),
1969 this)); 1989 this,
1990 &data_type_status_table_));
1970 1991
1971 // We create the migrator at the same time. 1992 // We create the migrator at the same time.
1972 migrator_.reset( 1993 migrator_.reset(
1973 new browser_sync::BackendMigrator( 1994 new browser_sync::BackendMigrator(
1974 profile_->GetDebugName(), GetUserShare(), 1995 profile_->GetDebugName(), GetUserShare(),
1975 this, directory_data_type_manager_.get(), 1996 this, directory_data_type_manager_.get(),
1976 base::Bind(&ProfileSyncService::StartSyncingWithServer, 1997 base::Bind(&ProfileSyncService::StartSyncingWithServer,
1977 base::Unretained(this)))); 1998 base::Unretained(this))));
1978 } 1999 }
1979 2000
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 true)); 2781 true));
2761 } 2782 }
2762 2783
2763 bool ProfileSyncService::NeedBackup() const { 2784 bool ProfileSyncService::NeedBackup() const {
2764 return need_backup_; 2785 return need_backup_;
2765 } 2786 }
2766 2787
2767 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { 2788 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
2768 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); 2789 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
2769 } 2790 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698