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

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

Issue 2716413003: Initial clear server data impl (Closed)
Patch Set: Responding to Pavel's comments. Created 3 years, 9 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 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 1192
1193 // Shutdown sync, delete the Directory, then restart, restoring the cached 1193 // Shutdown sync, delete the Directory, then restart, restoring the cached
1194 // nigori state. 1194 // nigori state.
1195 ShutdownImpl(syncer::DISABLE_SYNC); 1195 ShutdownImpl(syncer::DISABLE_SYNC);
1196 startup_controller_->TryStart(); 1196 startup_controller_->TryStart();
1197 UMA_HISTOGRAM_ENUMERATION("Sync.ClearServerDataEvents", 1197 UMA_HISTOGRAM_ENUMERATION("Sync.ClearServerDataEvents",
1198 syncer::CLEAR_SERVER_DATA_SUCCEEDED, 1198 syncer::CLEAR_SERVER_DATA_SUCCEEDED,
1199 syncer::CLEAR_SERVER_DATA_MAX); 1199 syncer::CLEAR_SERVER_DATA_MAX);
1200 } 1200 }
1201 1201
1202 void ProfileSyncService::ClearServerDataForTest(const base::Closure& callback) {
1203 DCHECK(thread_checker_.CalledOnValidThread());
1204 // Sync has a restriction that the engine must be in configuration mode
1205 // in order to run clear server data.
1206 engine_->StartConfiguration();
1207 engine_->ClearServerData(callback);
1208 }
1209
1202 void ProfileSyncService::OnConfigureDone( 1210 void ProfileSyncService::OnConfigureDone(
1203 const DataTypeManager::ConfigureResult& result) { 1211 const DataTypeManager::ConfigureResult& result) {
1204 DCHECK(thread_checker_.CalledOnValidThread()); 1212 DCHECK(thread_checker_.CalledOnValidThread());
1205 configure_status_ = result.status; 1213 configure_status_ = result.status;
1206 data_type_status_table_ = result.data_type_status_table; 1214 data_type_status_table_ = result.data_type_status_table;
1207 1215
1208 // We should have cleared our cached passphrase before we get here (in 1216 // We should have cleared our cached passphrase before we get here (in
1209 // OnEngineInitialized()). 1217 // OnEngineInitialized()).
1210 DCHECK(crypto_->cached_passphrase().empty()); 1218 DCHECK(crypto_->cached_passphrase().empty());
1211 1219
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 } 1387 }
1380 1388
1381 bool ProfileSyncService::IsFirstSetupInProgress() const { 1389 bool ProfileSyncService::IsFirstSetupInProgress() const {
1382 DCHECK(thread_checker_.CalledOnValidThread()); 1390 DCHECK(thread_checker_.CalledOnValidThread());
1383 return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress(); 1391 return !IsFirstSetupComplete() && startup_controller_->IsSetupInProgress();
1384 } 1392 }
1385 1393
1386 std::unique_ptr<syncer::SyncSetupInProgressHandle> 1394 std::unique_ptr<syncer::SyncSetupInProgressHandle>
1387 ProfileSyncService::GetSetupInProgressHandle() { 1395 ProfileSyncService::GetSetupInProgressHandle() {
1388 DCHECK(thread_checker_.CalledOnValidThread()); 1396 DCHECK(thread_checker_.CalledOnValidThread());
1397
1398 LOG(WARNING) << "GetHandle, count="
1399 << (outstanding_setup_in_progress_handles_ + 1);
1400
1389 if (++outstanding_setup_in_progress_handles_ == 1) { 1401 if (++outstanding_setup_in_progress_handles_ == 1) {
1390 DCHECK(!startup_controller_->IsSetupInProgress()); 1402 DCHECK(!startup_controller_->IsSetupInProgress());
1391 startup_controller_->SetSetupInProgress(true); 1403 startup_controller_->SetSetupInProgress(true);
1392 1404
1393 NotifyObservers(); 1405 NotifyObservers();
1394 } 1406 }
1395 1407
1396 return std::unique_ptr<syncer::SyncSetupInProgressHandle>( 1408 return std::unique_ptr<syncer::SyncSetupInProgressHandle>(
1397 new syncer::SyncSetupInProgressHandle( 1409 new syncer::SyncSetupInProgressHandle(
1398 base::Bind(&ProfileSyncService::OnSetupInProgressHandleDestroyed, 1410 base::Bind(&ProfileSyncService::OnSetupInProgressHandleDestroyed,
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 2419
2408 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() 2420 tracked_objects::Location ProfileSyncService::unrecoverable_error_location()
2409 const { 2421 const {
2410 DCHECK(thread_checker_.CalledOnValidThread()); 2422 DCHECK(thread_checker_.CalledOnValidThread());
2411 return unrecoverable_error_location_; 2423 return unrecoverable_error_location_;
2412 } 2424 }
2413 2425
2414 void ProfileSyncService::OnSetupInProgressHandleDestroyed() { 2426 void ProfileSyncService::OnSetupInProgressHandleDestroyed() {
2415 DCHECK_GT(outstanding_setup_in_progress_handles_, 0); 2427 DCHECK_GT(outstanding_setup_in_progress_handles_, 0);
2416 2428
2429 LOG(WARNING) << "GetHandle, count="
2430 << (outstanding_setup_in_progress_handles_ - 1);
2431
2417 // Don't re-start Sync until all outstanding handles are destroyed. 2432 // Don't re-start Sync until all outstanding handles are destroyed.
2418 if (--outstanding_setup_in_progress_handles_ != 0) 2433 if (--outstanding_setup_in_progress_handles_ != 0)
2419 return; 2434 return;
2420 2435
2421 DCHECK(startup_controller_->IsSetupInProgress()); 2436 DCHECK(startup_controller_->IsSetupInProgress());
2422 startup_controller_->SetSetupInProgress(false); 2437 startup_controller_->SetSetupInProgress(false);
2423 2438
2424 if (IsEngineInitialized()) 2439 if (IsEngineInitialized())
2425 ReconfigureDatatypeManager(); 2440 ReconfigureDatatypeManager();
2426 NotifyObservers(); 2441 NotifyObservers();
2427 } 2442 }
2428
2429 } // namespace browser_sync 2443 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698