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 34399e121eb297550687110492d2ded019b2bdc5..9aa0b8ef204b4498c9351ceafaaa5cd0fa2a42b2 100644 |
--- a/chrome/browser/sync/glue/non_frontend_data_type_controller.cc |
+++ b/chrome/browser/sync/glue/non_frontend_data_type_controller.cc |
@@ -60,8 +60,7 @@ void NonFrontendDataTypeController::Start(StartCallback* start_callback) { |
state_ = MODEL_STARTING; |
if (!StartModels()) { |
// If we are waiting for some external service to load before associating |
- // or we failed to start the models, we exit early. state_ will control |
- // what we perform next. |
+ // or we failed to start the models, we exit early. |
DCHECK(state_ == NOT_RUNNING || state_ == MODEL_STARTING); |
return; |
} |
@@ -116,7 +115,7 @@ void NonFrontendDataTypeController::StartAssociation() { |
} |
profile_sync_service_->ActivateDataType(type(), model_safe_group(), |
- change_processor_.get()); |
+ change_processor()); |
StartDone(!sync_has_nodes ? OK_FIRST_RUN : OK, RUNNING, SyncError()); |
} |
@@ -152,6 +151,12 @@ void NonFrontendDataTypeController::StartDoneImpl( |
DataTypeController::State new_state, |
const SyncError& error) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (state_ == NOT_RUNNING) { |
+ // Already stopped. just return. |
+ DCHECK(!start_callback_.get()); |
+ return; |
+ } |
+ DCHECK(start_callback_.get()); |
state_ = new_state; |
if (state_ != RUNNING) { |
// Start failed. |
@@ -166,9 +171,9 @@ void NonFrontendDataTypeController::StartDoneImpl( |
callback->Run(result, error); |
} |
-// TODO(sync): Blocking the UI thread at shutdown is bad. If we had a way of |
-// distinguishing chrome shutdown from sync shutdown, we should be able to avoid |
-// this (http://crbug.com/55662). |
+// TODO(sync): Blocking the UI thread at shutdown is bad. The new API avoids |
+// this. Once all non-frontend datatypes use the new API, we can get rid of this |
+// locking (see implementation in AutofillProfileDataTypeController). |
void NonFrontendDataTypeController::Stop() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
// If Stop() is called while Start() is waiting for association to |
@@ -270,15 +275,27 @@ ProfileSyncService* NonFrontendDataTypeController::profile_sync_service() |
return profile_sync_service_; |
} |
+void NonFrontendDataTypeController::set_start_callback( |
+ StartCallback* callback) { |
+ start_callback_.reset(callback); |
+} |
void NonFrontendDataTypeController::set_state(State state) { |
state_ = state; |
} |
+AssociatorInterface* NonFrontendDataTypeController::associator() const { |
+ return model_associator_.get(); |
+} |
+ |
void NonFrontendDataTypeController::set_model_associator( |
AssociatorInterface* associator) { |
model_associator_.reset(associator); |
} |
+ChangeProcessor* NonFrontendDataTypeController::change_processor() const { |
+ return change_processor_.get(); |
+} |
+ |
void NonFrontendDataTypeController::set_change_processor( |
ChangeProcessor* change_processor) { |
change_processor_.reset(change_processor); |