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

Unified Diff: chrome/browser/sync/glue/non_frontend_data_type_controller.cc

Issue 8305006: Fix an incorrect DCHECK caused by incorrect stop behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Upload before commit. Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/non_frontend_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
index f4468843ac16dd48e845e770bc24b7a2da692912..484270b5afe15e1d4d8ccbea0dd386c2bd2bd241 100644
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc
@@ -124,8 +124,7 @@ void NonFrontendDataTypeController::StartAssociation() {
void NonFrontendDataTypeController::StartFailed(StartResult result,
const SyncError& error) {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
- model_associator_.reset();
- change_processor_.reset();
+ StopAssociation();
StartDone(result,
result == ASSOCIATION_FAILED ? DISABLED : NOT_RUNNING,
error);
@@ -180,31 +179,39 @@ void NonFrontendDataTypeController::StartDoneImpl(
// locking (see implementation in AutofillProfileDataTypeController).
void NonFrontendDataTypeController::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK_NE(state_, NOT_RUNNING);
// If Stop() is called while Start() is waiting for association to
// complete, we need to abort the association and wait for the DB
// thread to finish the StartImpl() task.
- if (state_ == ASSOCIATING) {
- state_ = STOPPING;
- {
- base::AutoLock lock(abort_association_lock_);
- abort_association_ = true;
- if (model_associator_.get())
- model_associator_->AbortAssociation();
- }
- // Wait for the model association to abort.
- abort_association_complete_.Wait();
- StartDoneImpl(ABORTED, STOPPING, SyncError());
- } else if (state_ == MODEL_STARTING) {
- state_ = STOPPING;
- // If Stop() is called while Start() is waiting for the models to start,
- // abort the start. We don't need to continue on since it means we haven't
- // kicked off the association, and once we call StopModels, we never will.
- StartDoneImpl(ABORTED, NOT_RUNNING, SyncError());
- return;
- } else {
- state_ = STOPPING;
-
- StopModels();
+ switch (state_) {
+ case ASSOCIATING:
+ state_ = STOPPING;
+ {
+ base::AutoLock lock(abort_association_lock_);
+ abort_association_ = true;
+ if (model_associator_.get())
+ model_associator_->AbortAssociation();
+ }
+ // Wait for the model association to abort.
+ abort_association_complete_.Wait();
+ StartDoneImpl(ABORTED, STOPPING, SyncError());
+ break;
+ case MODEL_STARTING:
+ state_ = STOPPING;
+ // If Stop() is called while Start() is waiting for the models to start,
+ // abort the start. We don't need to continue on since it means we haven't
+ // kicked off the association, and once we call StopModels, we never will.
+ StartDoneImpl(ABORTED, NOT_RUNNING, SyncError());
+ return;
+ case DISABLED:
+ state_ = NOT_RUNNING;
+ StopModels();
+ return;
+ default:
+ DCHECK_EQ(state_, RUNNING);
+ state_ = STOPPING;
+ StopModels();
+ break;
}
DCHECK(!start_callback_.get());
« no previous file with comments | « no previous file | chrome/browser/sync/glue/non_frontend_data_type_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698