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

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

Issue 8065016: [Sync] Refactor non-frontend DTC to handle new API properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some comments addressed 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
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 8897b69e39873ea1149645a6a4b202e595056254..c1cc49d47790e2e9dea646e6fd5e1f784713d24c 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());
}
@@ -153,6 +152,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.
@@ -167,9 +172,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
@@ -272,15 +277,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);

Powered by Google App Engine
This is Rietveld 408576698