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

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

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

Powered by Google App Engine
This is Rietveld 408576698