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

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2649133012: [Sync] Calculate active types and track catch up in DTMI not PSS. (Closed)
Patch Set: Fix ProfileSyncServiceTest. Created 3 years, 10 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 "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 encrypt_everything_(false), 206 encrypt_everything_(false),
207 encryption_pending_(false), 207 encryption_pending_(false),
208 configure_status_(DataTypeManager::UNKNOWN), 208 configure_status_(DataTypeManager::UNKNOWN),
209 oauth2_token_service_(init_params.oauth2_token_service), 209 oauth2_token_service_(init_params.oauth2_token_service),
210 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), 210 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy),
211 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), 211 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED),
212 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), 212 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()),
213 gaia_cookie_manager_service_(init_params.gaia_cookie_manager_service), 213 gaia_cookie_manager_service_(init_params.gaia_cookie_manager_service),
214 network_resources_(new syncer::HttpBridgeNetworkResources), 214 network_resources_(new syncer::HttpBridgeNetworkResources),
215 start_behavior_(init_params.start_behavior), 215 start_behavior_(init_params.start_behavior),
216 catch_up_configure_in_progress_(false),
217 passphrase_prompt_triggered_by_version_(false), 216 passphrase_prompt_triggered_by_version_(false),
218 sync_enabled_weak_factory_(this), 217 sync_enabled_weak_factory_(this),
219 weak_factory_(this) { 218 weak_factory_(this) {
220 DCHECK(thread_checker_.CalledOnValidThread()); 219 DCHECK(thread_checker_.CalledOnValidThread());
221 DCHECK(sync_client_); 220 DCHECK(sync_client_);
222 std::string last_version = sync_prefs_.GetLastRunVersion(); 221 std::string last_version = sync_prefs_.GetLastRunVersion();
223 std::string current_version = PRODUCT_VERSION; 222 std::string current_version = PRODUCT_VERSION;
224 sync_prefs_.SetLastRunVersion(current_version); 223 sync_prefs_.SetLastRunVersion(current_version);
225 224
226 // Check for a major version change. Note that the versions have format 225 // Check for a major version change. Note that the versions have format
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 785
787 // Clear various state. 786 // Clear various state.
788 expect_sync_configuration_aborted_ = false; 787 expect_sync_configuration_aborted_ = false;
789 is_auth_in_progress_ = false; 788 is_auth_in_progress_ = false;
790 engine_initialized_ = false; 789 engine_initialized_ = false;
791 cached_passphrase_.clear(); 790 cached_passphrase_.clear();
792 encryption_pending_ = false; 791 encryption_pending_ = false;
793 encrypt_everything_ = false; 792 encrypt_everything_ = false;
794 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); 793 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes();
795 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 794 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
796 catch_up_configure_in_progress_ = false;
797 access_token_.clear(); 795 access_token_.clear();
798 request_access_token_retry_timer_.Stop(); 796 request_access_token_retry_timer_.Stop();
799 last_snapshot_ = syncer::SyncCycleSnapshot(); 797 last_snapshot_ = syncer::SyncCycleSnapshot();
800 // Revert to "no auth error". 798 // Revert to "no auth error".
801 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) 799 if (last_auth_error_.state() != GoogleServiceAuthError::NONE)
802 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); 800 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone());
803 801
804 NotifyObservers(); 802 NotifyObservers();
805 803
806 // Mark this as a clean shutdown(without crash). 804 // Mark this as a clean shutdown(without crash).
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 } 1311 }
1314 1312
1315 void ProfileSyncService::BeginConfigureCatchUpBeforeClear() { 1313 void ProfileSyncService::BeginConfigureCatchUpBeforeClear() {
1316 DCHECK(data_type_manager_); 1314 DCHECK(data_type_manager_);
1317 DCHECK(!saved_nigori_state_); 1315 DCHECK(!saved_nigori_state_);
1318 saved_nigori_state_ = 1316 saved_nigori_state_ =
1319 base::MakeUnique<syncer::SyncEncryptionHandler::NigoriState>(); 1317 base::MakeUnique<syncer::SyncEncryptionHandler::NigoriState>();
1320 sync_prefs_.GetNigoriSpecificsForPassphraseTransition( 1318 sync_prefs_.GetNigoriSpecificsForPassphraseTransition(
1321 &saved_nigori_state_->nigori_specifics); 1319 &saved_nigori_state_->nigori_specifics);
1322 const syncer::ModelTypeSet types = GetActiveDataTypes(); 1320 const syncer::ModelTypeSet types = GetActiveDataTypes();
1323 catch_up_configure_in_progress_ = true;
1324 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CATCH_UP); 1321 data_type_manager_->Configure(types, syncer::CONFIGURE_REASON_CATCH_UP);
1325 } 1322 }
1326 1323
1327 void ProfileSyncService::ClearAndRestartSyncForPassphraseEncryption() { 1324 void ProfileSyncService::ClearAndRestartSyncForPassphraseEncryption() {
1328 DCHECK(thread_checker_.CalledOnValidThread()); 1325 DCHECK(thread_checker_.CalledOnValidThread());
1329 engine_->ClearServerData( 1326 engine_->ClearServerData(
1330 base::Bind(&ProfileSyncService::OnClearServerDataDone, 1327 base::Bind(&ProfileSyncService::OnClearServerDataDone,
1331 sync_enabled_weak_factory_.GetWeakPtr())); 1328 sync_enabled_weak_factory_.GetWeakPtr()));
1332 } 1329 }
1333 1330
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 // First handle the abort case. 1382 // First handle the abort case.
1386 if (configure_status_ == DataTypeManager::ABORTED && 1383 if (configure_status_ == DataTypeManager::ABORTED &&
1387 expect_sync_configuration_aborted_) { 1384 expect_sync_configuration_aborted_) {
1388 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; 1385 DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted";
1389 expect_sync_configuration_aborted_ = false; 1386 expect_sync_configuration_aborted_ = false;
1390 return; 1387 return;
1391 } 1388 }
1392 1389
1393 // Handle unrecoverable error. 1390 // Handle unrecoverable error.
1394 if (configure_status_ != DataTypeManager::OK) { 1391 if (configure_status_ != DataTypeManager::OK) {
1395 if (catch_up_configure_in_progress_) { 1392 if (result.was_catch_up_configure) {
1396 // Record catchup configuration failure. 1393 // Record catchup configuration failure.
1397 UMA_HISTOGRAM_ENUMERATION(kClearServerDataEventsHistogramName, 1394 UMA_HISTOGRAM_ENUMERATION(kClearServerDataEventsHistogramName,
1398 CLEAR_SERVER_DATA_CATCHUP_FAILED, 1395 CLEAR_SERVER_DATA_CATCHUP_FAILED,
1399 CLEAR_SERVER_DATA_MAX); 1396 CLEAR_SERVER_DATA_MAX);
1400 } 1397 }
1401 // Something catastrophic had happened. We should only have one 1398 // Something catastrophic had happened. We should only have one
1402 // error representing it. 1399 // error representing it.
1403 syncer::SyncError error = data_type_status_table_.GetUnrecoverableError(); 1400 syncer::SyncError error = data_type_status_table_.GetUnrecoverableError();
1404 DCHECK(error.IsSet()); 1401 DCHECK(error.IsSet());
1405 std::string message = 1402 std::string message =
(...skipping 23 matching lines...) Expand all
1429 NotifyObservers(); 1426 NotifyObservers();
1430 1427
1431 if (migrator_.get() && migrator_->state() != BackendMigrator::IDLE) { 1428 if (migrator_.get() && migrator_->state() != BackendMigrator::IDLE) {
1432 // Migration in progress. Let the migrator know we just finished 1429 // Migration in progress. Let the migrator know we just finished
1433 // configuring something. It will be up to the migrator to call 1430 // configuring something. It will be up to the migrator to call
1434 // StartSyncingWithServer() if migration is now finished. 1431 // StartSyncingWithServer() if migration is now finished.
1435 migrator_->OnConfigureDone(result); 1432 migrator_->OnConfigureDone(result);
1436 return; 1433 return;
1437 } 1434 }
1438 1435
1439 if (catch_up_configure_in_progress_) { 1436 if (result.was_catch_up_configure) {
1440 catch_up_configure_in_progress_ = false;
1441 ClearAndRestartSyncForPassphraseEncryption(); 1437 ClearAndRestartSyncForPassphraseEncryption();
1442 return; 1438 return;
1443 } 1439 }
1444 1440
1445 StartSyncingWithServer(); 1441 StartSyncingWithServer();
1446 } 1442 }
1447 1443
1448 void ProfileSyncService::OnConfigureStart() { 1444 void ProfileSyncService::OnConfigureStart() {
1449 DCHECK(thread_checker_.CalledOnValidThread()); 1445 DCHECK(thread_checker_.CalledOnValidThread());
1450 sync_configure_start_time_ = base::Time::Now(); 1446 sync_configure_start_time_ = base::Time::Now();
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1728 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
1733 // Will only enable those types that are registered and preferred. 1729 // Will only enable those types that are registered and preferred.
1734 sync_prefs_.SetPreferredDataTypes(registered_types, preferred_types); 1730 sync_prefs_.SetPreferredDataTypes(registered_types, preferred_types);
1735 1731
1736 // Now reconfigure the DTM. 1732 // Now reconfigure the DTM.
1737 ReconfigureDatatypeManager(); 1733 ReconfigureDatatypeManager();
1738 } 1734 }
1739 1735
1740 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const { 1736 syncer::ModelTypeSet ProfileSyncService::GetActiveDataTypes() const {
1741 DCHECK(thread_checker_.CalledOnValidThread()); 1737 DCHECK(thread_checker_.CalledOnValidThread());
1742 if (!IsSyncActive() || !ConfigurationDone()) 1738 if (!data_type_manager_)
1743 return syncer::ModelTypeSet(); 1739 return syncer::ModelTypeSet();
1744 const syncer::ModelTypeSet preferred_types = GetPreferredDataTypes(); 1740 return data_type_manager_->GetActiveDataTypes();
1745 const syncer::ModelTypeSet failed_types =
1746 data_type_status_table_.GetFailedTypes();
1747 return Difference(preferred_types, failed_types);
1748 } 1741 }
1749 1742
1750 syncer::SyncClient* ProfileSyncService::GetSyncClient() const { 1743 syncer::SyncClient* ProfileSyncService::GetSyncClient() const {
1751 DCHECK(thread_checker_.CalledOnValidThread()); 1744 DCHECK(thread_checker_.CalledOnValidThread());
1752 return sync_client_.get(); 1745 return sync_client_.get();
1753 } 1746 }
1754 1747
1755 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const { 1748 syncer::ModelTypeSet ProfileSyncService::GetPreferredDataTypes() const {
1756 DCHECK(thread_checker_.CalledOnValidThread()); 1749 DCHECK(thread_checker_.CalledOnValidThread());
1757 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 1750 const syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2635 2628
2636 DCHECK(startup_controller_->IsSetupInProgress()); 2629 DCHECK(startup_controller_->IsSetupInProgress());
2637 startup_controller_->SetSetupInProgress(false); 2630 startup_controller_->SetSetupInProgress(false);
2638 2631
2639 if (IsEngineInitialized()) 2632 if (IsEngineInitialized())
2640 ReconfigureDatatypeManager(); 2633 ReconfigureDatatypeManager();
2641 NotifyObservers(); 2634 NotifyObservers();
2642 } 2635 }
2643 2636
2644 } // namespace browser_sync 2637 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698