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

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

Issue 10584019: sync: Remove ClearUserData command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 6 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // |profile| may be NULL in unit tests. 121 // |profile| may be NULL in unit tests.
122 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), 122 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL),
123 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), 123 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL),
124 sync_service_url_(kDevServerUrl), 124 sync_service_url_(kDevServerUrl),
125 backend_initialized_(false), 125 backend_initialized_(false),
126 is_auth_in_progress_(false), 126 is_auth_in_progress_(false),
127 signin_(signin_manager), 127 signin_(signin_manager),
128 unrecoverable_error_reason_(ERROR_REASON_UNSET), 128 unrecoverable_error_reason_(ERROR_REASON_UNSET),
129 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 129 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
130 expect_sync_configuration_aborted_(false), 130 expect_sync_configuration_aborted_(false),
131 clear_server_data_state_(CLEAR_NOT_STARTED),
132 encrypted_types_(browser_sync::Cryptographer::SensitiveTypes()), 131 encrypted_types_(browser_sync::Cryptographer::SensitiveTypes()),
133 encrypt_everything_(false), 132 encrypt_everything_(false),
134 encryption_pending_(false), 133 encryption_pending_(false),
135 auto_start_enabled_(start_behavior == AUTO_START), 134 auto_start_enabled_(start_behavior == AUTO_START),
136 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 135 failed_datatypes_handler_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
137 configure_status_(DataTypeManager::UNKNOWN), 136 configure_status_(DataTypeManager::UNKNOWN),
138 setup_in_progress_(false) { 137 setup_in_progress_(false) {
139 #if defined(OS_ANDROID) 138 #if defined(OS_ANDROID)
140 chrome::VersionInfo version_info; 139 chrome::VersionInfo version_info;
141 if (version_info.IsOfficialBuild()) { 140 if (version_info.IsOfficialBuild()) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 data_type_controllers_.end() || 263 data_type_controllers_.end() ||
265 data_type_controllers_.find(syncable::SESSIONS)->second->state() != 264 data_type_controllers_.find(syncable::SESSIONS)->second->state() !=
266 DataTypeController::RUNNING) { 265 DataTypeController::RUNNING) {
267 return NULL; 266 return NULL;
268 } 267 }
269 return static_cast<browser_sync::SessionDataTypeController*>( 268 return static_cast<browser_sync::SessionDataTypeController*>(
270 data_type_controllers_.find( 269 data_type_controllers_.find(
271 syncable::SESSIONS)->second.get())->GetModelAssociator(); 270 syncable::SESSIONS)->second.get())->GetModelAssociator();
272 } 271 }
273 272
274 void ProfileSyncService::ResetClearServerDataState() {
275 clear_server_data_state_ = CLEAR_NOT_STARTED;
276 }
277
278 ProfileSyncService::ClearServerDataState
279 ProfileSyncService::GetClearServerDataState() {
280 return clear_server_data_state_;
281 }
282
283 void ProfileSyncService::GetDataTypeControllerStates( 273 void ProfileSyncService::GetDataTypeControllerStates(
284 browser_sync::DataTypeController::StateMap* state_map) const { 274 browser_sync::DataTypeController::StateMap* state_map) const {
285 for (browser_sync::DataTypeController::TypeMap::const_iterator iter = 275 for (browser_sync::DataTypeController::TypeMap::const_iterator iter =
286 data_type_controllers_.begin(); iter != data_type_controllers_.end(); 276 data_type_controllers_.begin(); iter != data_type_controllers_.end();
287 ++iter) 277 ++iter)
288 (*state_map)[iter->first] = iter->second.get()->state(); 278 (*state_map)[iter->first] = iter->second.get()->state();
289 } 279 }
290 280
291 void ProfileSyncService::InitSettings() { 281 void ProfileSyncService::InitSettings() {
292 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 282 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 last_auth_error_ = GoogleServiceAuthError::None(); 503 last_auth_error_ = GoogleServiceAuthError::None();
514 504
515 if (sync_global_error_.get()) { 505 if (sync_global_error_.get()) {
516 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( 506 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
517 sync_global_error_.get()); 507 sync_global_error_.get());
518 RemoveObserver(sync_global_error_.get()); 508 RemoveObserver(sync_global_error_.get());
519 sync_global_error_.reset(NULL); 509 sync_global_error_.reset(NULL);
520 } 510 }
521 } 511 }
522 512
523 void ProfileSyncService::ClearServerData() {
524 clear_server_data_state_ = CLEAR_CLEARING;
525 clear_server_data_timer_.Start(FROM_HERE,
526 base::TimeDelta::FromSeconds(kSyncClearDataTimeoutInSeconds), this,
527 &ProfileSyncService::OnClearServerDataTimeout);
528 backend_->RequestClearServerData();
529 }
530
531 void ProfileSyncService::DisableForUser() { 513 void ProfileSyncService::DisableForUser() {
532 // Clear prefs (including SyncSetupHasCompleted) before shutting down so 514 // Clear prefs (including SyncSetupHasCompleted) before shutting down so
533 // PSS clients don't think we're set up while we're shutting down. 515 // PSS clients don't think we're set up while we're shutting down.
534 sync_prefs_.ClearPreferences(); 516 sync_prefs_.ClearPreferences();
535 invalidator_storage_.Clear(); 517 invalidator_storage_.Clear();
536 ClearUnrecoverableError(); 518 ClearUnrecoverableError();
537 ShutdownImpl(true); 519 ShutdownImpl(true);
538 520
539 // TODO(atwilson): Don't call SignOut() on *any* platform - move this into 521 // TODO(atwilson): Don't call SignOut() on *any* platform - move this into
540 // the UI layer if needed (sync activity should never result in the user 522 // the UI layer if needed (sync activity should never result in the user
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 UpdateAuthErrorState(ConnectionStatusToAuthError(status)); 815 UpdateAuthErrorState(ConnectionStatusToAuthError(status));
834 } 816 }
835 817
836 void ProfileSyncService::OnStopSyncingPermanently() { 818 void ProfileSyncService::OnStopSyncingPermanently() {
837 UpdateAuthErrorState( 819 UpdateAuthErrorState(
838 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE)); 820 GoogleServiceAuthError(GoogleServiceAuthError::SERVICE_UNAVAILABLE));
839 sync_prefs_.SetStartSuppressed(true); 821 sync_prefs_.SetStartSuppressed(true);
840 DisableForUser(); 822 DisableForUser();
841 } 823 }
842 824
843 void ProfileSyncService::OnClearServerDataTimeout() {
844 if (clear_server_data_state_ != CLEAR_SUCCEEDED &&
845 clear_server_data_state_ != CLEAR_FAILED) {
846 clear_server_data_state_ = CLEAR_FAILED;
847 NotifyObservers();
848 }
849 }
850
851 void ProfileSyncService::OnClearServerDataFailed() {
852 clear_server_data_timer_.Stop();
853
854 // Only once clear has succeeded there is no longer a need to transition to
855 // a failed state as sync is disabled locally. Also, no need to fire off
856 // the observers if the state didn't change (i.e. it was FAILED before).
857 if (clear_server_data_state_ != CLEAR_SUCCEEDED &&
858 clear_server_data_state_ != CLEAR_FAILED) {
859 clear_server_data_state_ = CLEAR_FAILED;
860 NotifyObservers();
861 }
862 }
863
864 void ProfileSyncService::OnClearServerDataSucceeded() {
865 clear_server_data_timer_.Stop();
866
867 // Even if the timout fired, we still transition to the succeeded state as
868 // we want UI to update itself and no longer allow the user to press "clear"
869 if (clear_server_data_state_ != CLEAR_SUCCEEDED) {
870 clear_server_data_state_ = CLEAR_SUCCEEDED;
871 NotifyObservers();
872 }
873 }
874
875 void ProfileSyncService::OnPassphraseRequired( 825 void ProfileSyncService::OnPassphraseRequired(
876 sync_api::PassphraseRequiredReason reason, 826 sync_api::PassphraseRequiredReason reason,
877 const sync_pb::EncryptedData& pending_keys) { 827 const sync_pb::EncryptedData& pending_keys) {
878 DCHECK(backend_.get()); 828 DCHECK(backend_.get());
879 DCHECK(backend_->IsNigoriEnabled()); 829 DCHECK(backend_->IsNigoriEnabled());
880 830
881 // TODO(lipalani) : add this check to other locations as well. 831 // TODO(lipalani) : add this check to other locations as well.
882 if (HasUnrecoverableError()) { 832 if (HasUnrecoverableError()) {
883 // When unrecoverable error is detected we post a task to shutdown the 833 // When unrecoverable error is detected we post a task to shutdown the
884 // backend. The task might not have executed yet. 834 // backend. The task might not have executed yet.
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru. 1652 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine d-behaviour-after-directly-calling-the-destru.
1703 ProfileSyncService* old_this = this; 1653 ProfileSyncService* old_this = this;
1704 this->~ProfileSyncService(); 1654 this->~ProfileSyncService();
1705 new(old_this) ProfileSyncService( 1655 new(old_this) ProfileSyncService(
1706 new ProfileSyncComponentsFactoryImpl(profile, 1656 new ProfileSyncComponentsFactoryImpl(profile,
1707 CommandLine::ForCurrentProcess()), 1657 CommandLine::ForCurrentProcess()),
1708 profile, 1658 profile,
1709 signin, 1659 signin,
1710 behavior); 1660 behavior);
1711 } 1661 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_startup_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698