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

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

Issue 310103004: Add integraton test for sync backup/rollback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup includes Created 6 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 ProfileSyncServiceStartBehavior start_behavior) 175 ProfileSyncServiceStartBehavior start_behavior)
176 : OAuth2TokenService::Consumer("sync"), 176 : OAuth2TokenService::Consumer("sync"),
177 last_auth_error_(AuthError::AuthErrorNone()), 177 last_auth_error_(AuthError::AuthErrorNone()),
178 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), 178 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED),
179 factory_(factory), 179 factory_(factory),
180 profile_(profile), 180 profile_(profile),
181 sync_prefs_(profile_->GetPrefs()), 181 sync_prefs_(profile_->GetPrefs()),
182 sync_service_url_(kDevServerUrl), 182 sync_service_url_(kDevServerUrl),
183 is_first_time_sync_configure_(false), 183 is_first_time_sync_configure_(false),
184 backend_initialized_(false), 184 backend_initialized_(false),
185 is_syncing_(false),
185 sync_disabled_by_admin_(false), 186 sync_disabled_by_admin_(false),
186 is_auth_in_progress_(false), 187 is_auth_in_progress_(false),
187 signin_(signin_wrapper), 188 signin_(signin_wrapper),
188 unrecoverable_error_reason_(ERROR_REASON_UNSET), 189 unrecoverable_error_reason_(ERROR_REASON_UNSET),
189 expect_sync_configuration_aborted_(false), 190 expect_sync_configuration_aborted_(false),
190 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), 191 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()),
191 encrypt_everything_(false), 192 encrypt_everything_(false),
192 encryption_pending_(false), 193 encryption_pending_(false),
193 configure_status_(DataTypeManager::UNKNOWN), 194 configure_status_(DataTypeManager::UNKNOWN),
194 oauth2_token_service_(oauth2_token_service), 195 oauth2_token_service_(oauth2_token_service),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // kSyncKeepEverythingSynced was not properly set. Set it and the preferred 337 // kSyncKeepEverythingSynced was not properly set. Set it and the preferred
337 // types now, before we configure. 338 // types now, before we configure.
338 UMA_HISTOGRAM_COUNTS("Sync.DatatypePrefRecovery", 1); 339 UMA_HISTOGRAM_COUNTS("Sync.DatatypePrefRecovery", 1);
339 sync_prefs_.SetKeepEverythingSynced(true); 340 sync_prefs_.SetKeepEverythingSynced(true);
340 syncer::ModelTypeSet registered_types = GetRegisteredDataTypes(); 341 syncer::ModelTypeSet registered_types = GetRegisteredDataTypes();
341 sync_prefs_.SetPreferredDataTypes(registered_types, 342 sync_prefs_.SetPreferredDataTypes(registered_types,
342 registered_types); 343 registered_types);
343 } 344 }
344 345
345 void ProfileSyncService::StartSyncingWithServer() { 346 void ProfileSyncService::StartSyncingWithServer() {
346 if (backend_) 347 if (backend_) {
348 is_syncing_ = true;
347 backend_->StartSyncingWithServer(); 349 backend_->StartSyncingWithServer();
350 }
348 } 351 }
349 352
350 void ProfileSyncService::RegisterAuthNotifications() { 353 void ProfileSyncService::RegisterAuthNotifications() {
351 oauth2_token_service_->AddObserver(this); 354 oauth2_token_service_->AddObserver(this);
352 if (signin()) 355 if (signin())
353 signin()->AddObserver(this); 356 signin()->AddObserver(this);
354 } 357 }
355 358
356 void ProfileSyncService::UnregisterAuthNotifications() { 359 void ProfileSyncService::UnregisterAuthNotifications() {
357 if (signin()) 360 if (signin())
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 weak_factory_.InvalidateWeakPtrs(); 823 weak_factory_.InvalidateWeakPtrs();
821 824
822 if (backend_mode_ == SYNC) 825 if (backend_mode_ == SYNC)
823 startup_controller_.Reset(GetRegisteredDataTypes()); 826 startup_controller_.Reset(GetRegisteredDataTypes());
824 827
825 // Clear various flags. 828 // Clear various flags.
826 backend_mode_ = IDLE; 829 backend_mode_ = IDLE;
827 expect_sync_configuration_aborted_ = false; 830 expect_sync_configuration_aborted_ = false;
828 is_auth_in_progress_ = false; 831 is_auth_in_progress_ = false;
829 backend_initialized_ = false; 832 backend_initialized_ = false;
833 is_syncing_ = false;
830 cached_passphrase_.clear(); 834 cached_passphrase_.clear();
831 access_token_.clear(); 835 access_token_.clear();
832 encryption_pending_ = false; 836 encryption_pending_ = false;
833 encrypt_everything_ = false; 837 encrypt_everything_ = false;
834 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); 838 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes();
835 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; 839 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED;
836 request_access_token_retry_timer_.Stop(); 840 request_access_token_retry_timer_.Stop();
837 // Revert to "no auth error". 841 // Revert to "no auth error".
838 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) 842 if (last_auth_error_.state() != GoogleServiceAuthError::NONE)
839 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); 843 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone());
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1880 // previous configuration left off). 1884 // previous configuration left off).
1881 // TODO(sync): consider detecting configuration recovery and setting 1885 // TODO(sync): consider detecting configuration recovery and setting
1882 // the reason here appropriately. 1886 // the reason here appropriately.
1883 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE; 1887 reason = syncer::CONFIGURE_REASON_NEWLY_ENABLED_DATA_TYPE;
1884 } else { 1888 } else {
1885 // The user initiated a reconfiguration (either to add or remove types). 1889 // The user initiated a reconfiguration (either to add or remove types).
1886 reason = syncer::CONFIGURE_REASON_RECONFIGURATION; 1890 reason = syncer::CONFIGURE_REASON_RECONFIGURATION;
1887 } 1891 }
1888 } 1892 }
1889 1893
1894 is_syncing_ = false;
1890 directory_data_type_manager_->Configure(types, reason); 1895 directory_data_type_manager_->Configure(types, reason);
1891 } 1896 }
1892 1897
1893 syncer::UserShare* ProfileSyncService::GetUserShare() const { 1898 syncer::UserShare* ProfileSyncService::GetUserShare() const {
1894 if (backend_.get() && backend_initialized_) { 1899 if (backend_.get() && backend_initialized_) {
1895 return backend_->GetUserShare(); 1900 return backend_->GetUserShare();
1896 } 1901 }
1897 NOTREACHED(); 1902 NOTREACHED();
1898 return NULL; 1903 return NULL;
1899 } 1904 }
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 network_resources_ = network_resources.Pass(); 2473 network_resources_ = network_resources.Pass();
2469 } 2474 }
2470 2475
2471 bool ProfileSyncService::HasSyncingBackend() const { 2476 bool ProfileSyncService::HasSyncingBackend() const {
2472 return backend_mode_ != SYNC ? false : backend_ != NULL; 2477 return backend_mode_ != SYNC ? false : backend_ != NULL;
2473 } 2478 }
2474 2479
2475 void ProfileSyncService::SetBackupStartDelayForTest(base::TimeDelta delay) { 2480 void ProfileSyncService::SetBackupStartDelayForTest(base::TimeDelta delay) {
2476 backup_start_delay_ = delay; 2481 backup_start_delay_ = delay;
2477 } 2482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698