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

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

Issue 6811003: [Sync] Make generic non-frontend thread datatype controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copy paste :( Created 9 years, 8 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/frontend_data_type_controller.cc
diff --git a/chrome/browser/sync/glue/frontend_data_type_controller.cc b/chrome/browser/sync/glue/frontend_data_type_controller.cc
index 5e324f9f1de8147d2e14e153c454596979fd4b91..edec12ce9388ed79c9745f67414c7b3697974569 100644
--- a/chrome/browser/sync/glue/frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/frontend_data_type_controller.cc
@@ -103,15 +103,46 @@ bool FrontendDataTypeController::Associate() {
return true;
}
+void FrontendDataTypeController::StartFailed(StartResult result,
+ const tracked_objects::Location& location) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ CleanUpState();
+ model_associator_.reset();
+ change_processor_.reset();
+ state_ = NOT_RUNNING;
+ RecordStartFailure(result);
+
+ // We have to release the callback before we call it, since it's possible
+ // invoking the callback will trigger a call to STOP(), which will get
+ // confused by the non-NULL start_callback_.
+ scoped_ptr<StartCallback> callback(start_callback_.release());
+ callback->Run(result, location);
+}
+
+void FrontendDataTypeController::FinishStart(StartResult result,
+ const tracked_objects::Location& location) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // We have to release the callback before we call it, since it's possible
+ // invoking the callback will trigger a call to STOP(), which will get
+ // confused by the non-NULL start_callback_.
+ scoped_ptr<StartCallback> callback(start_callback_.release());
+ callback->Run(result, location);
+}
+
void FrontendDataTypeController::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// If Stop() is called while Start() is waiting for the datatype model to
// load, abort the start.
- if (state_ == MODEL_STARTING)
- FinishStart(ABORTED, FROM_HERE);
+ if (state_ == MODEL_STARTING) {
+ StartFailed(ABORTED, FROM_HERE);
+ // We can just return here since we haven't performed association if we're
+ // still in MODEL_STARTING.
+ return;
+ }
DCHECK(!start_callback_.get());
- CleanupState();
+ CleanUpState();
if (change_processor_ != NULL)
sync_service_->DeactivateDataType(this, change_processor_.get());
@@ -125,7 +156,7 @@ void FrontendDataTypeController::Stop() {
state_ = NOT_RUNNING;
}
-void FrontendDataTypeController::CleanupState() {
+void FrontendDataTypeController::CleanUpState() {
// Do nothing by default.
}
@@ -150,23 +181,4 @@ void FrontendDataTypeController::OnUnrecoverableError(
sync_service_->OnUnrecoverableError(from_here, message);
}
-void FrontendDataTypeController::FinishStart(StartResult result,
- const tracked_objects::Location& location) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- start_callback_->Run(result, location);
- start_callback_.reset();
-}
-
-void FrontendDataTypeController::StartFailed(StartResult result,
- const tracked_objects::Location& location) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- CleanupState();
- model_associator_.reset();
- change_processor_.reset();
- state_ = NOT_RUNNING;
- start_callback_->Run(result, location);
- start_callback_.reset();
- RecordStartFailure(result);
-}
-
} // namespace browser_sync

Powered by Google App Engine
This is Rietveld 408576698