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

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

Issue 10071033: RefCounted types should not have public destructors, chrome/browser/ part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implementation ordering fixes as well Created 8 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 a879e2ba2f5af5dc679301befaa3cd704743971b..18b62595dc60995013fddf144fc45959795b7ca0 100644
--- a/chrome/browser/sync/glue/frontend_data_type_controller.cc
+++ b/chrome/browser/sync/glue/frontend_data_type_controller.cc
@@ -20,13 +20,6 @@ using content::BrowserThread;
namespace browser_sync {
-FrontendDataTypeController::FrontendDataTypeController()
- : profile_sync_factory_(NULL),
- profile_(NULL),
- sync_service_(NULL),
- state_(NOT_RUNNING) {
-}
-
FrontendDataTypeController::FrontendDataTypeController(
ProfileSyncComponentsFactory* profile_sync_factory,
Profile* profile,
@@ -41,10 +34,6 @@ FrontendDataTypeController::FrontendDataTypeController(
DCHECK(sync_service);
}
-FrontendDataTypeController::~FrontendDataTypeController() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-}
-
void FrontendDataTypeController::Start(const StartCallback& start_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!start_callback.is_null());
@@ -73,6 +62,82 @@ void FrontendDataTypeController::Start(const StartCallback& start_callback) {
DCHECK_EQ(state_, RUNNING);
}
+void FrontendDataTypeController::Stop() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ State prev_state = state_;
+ state_ = STOPPING;
+
+ // If Stop() is called while Start() is waiting for the datatype model to
+ // load, abort the start.
+ if (prev_state == MODEL_STARTING) {
+ StartFailed(ABORTED, SyncError());
+ // We can just return here since we haven't performed association if we're
+ // still in MODEL_STARTING.
+ return;
+ }
+ DCHECK(start_callback_.is_null());
+
+ CleanUpState();
+
+ sync_service_->DeactivateDataType(type());
+
+ if (model_associator()) {
+ SyncError error; // Not used.
+ error = model_associator()->DisassociateModels();
+ }
+
+ set_model_associator(NULL);
+ change_processor_.reset();
+
+ state_ = NOT_RUNNING;
+}
+
+browser_sync::ModelSafeGroup FrontendDataTypeController::model_safe_group()
+ const {
+ return browser_sync::GROUP_UI;
+}
+
+std::string FrontendDataTypeController::name() const {
+ // For logging only.
+ return syncable::ModelTypeToString(type());
+}
+
+DataTypeController::State FrontendDataTypeController::state() const {
+ return state_;
+}
+
+void FrontendDataTypeController::OnUnrecoverableError(
+ const tracked_objects::Location& from_here, const std::string& message) {
+ RecordUnrecoverableError(from_here, message);
+
+ // The ProfileSyncService will invoke our Stop() method in response to this.
+ // We dont know the current state of the caller. Posting a task will allow
+ // the caller to unwind the stack before we process unrecoverable error.
+ MessageLoop::current()->PostTask(from_here,
+ base::Bind(&ProfileSyncService::OnUnrecoverableError,
+ sync_service_->AsWeakPtr(),
+ from_here,
+ message));
+}
+
+void FrontendDataTypeController::OnSingleDatatypeUnrecoverableError(
+ const tracked_objects::Location& from_here, const std::string& message) {
+ RecordUnrecoverableError(from_here, message);
+ sync_service_->OnDisableDatatype(type(), from_here, message);
+}
+
+FrontendDataTypeController::FrontendDataTypeController()
+ : profile_sync_factory_(NULL),
+ profile_(NULL),
+ sync_service_(NULL),
+ state_(NOT_RUNNING) {
+}
+
+FrontendDataTypeController::~FrontendDataTypeController() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
bool FrontendDataTypeController::StartModels() {
DCHECK_EQ(state_, MODEL_STARTING);
// By default, no additional services need to be started before we can proceed
@@ -120,6 +185,10 @@ bool FrontendDataTypeController::Associate() {
return state_ == RUNNING;
}
+void FrontendDataTypeController::CleanUpState() {
+ // Do nothing by default.
+}
+
void FrontendDataTypeController::StartFailed(StartResult result,
const SyncError& error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -155,75 +224,6 @@ void FrontendDataTypeController::FinishStart(StartResult result) {
callback.Run(result, SyncError());
}
-void FrontendDataTypeController::Stop() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- State prev_state = state_;
- state_ = STOPPING;
-
- // If Stop() is called while Start() is waiting for the datatype model to
- // load, abort the start.
- if (prev_state == MODEL_STARTING) {
- StartFailed(ABORTED, SyncError());
- // We can just return here since we haven't performed association if we're
- // still in MODEL_STARTING.
- return;
- }
- DCHECK(start_callback_.is_null());
-
- CleanUpState();
-
- sync_service_->DeactivateDataType(type());
-
- if (model_associator()) {
- SyncError error; // Not used.
- error = model_associator()->DisassociateModels();
- }
-
- set_model_associator(NULL);
- change_processor_.reset();
-
- state_ = NOT_RUNNING;
-}
-
-void FrontendDataTypeController::CleanUpState() {
- // Do nothing by default.
-}
-
-browser_sync::ModelSafeGroup FrontendDataTypeController::model_safe_group()
- const {
- return browser_sync::GROUP_UI;
-}
-
-std::string FrontendDataTypeController::name() const {
- // For logging only.
- return syncable::ModelTypeToString(type());
-}
-
-DataTypeController::State FrontendDataTypeController::state() const {
- return state_;
-}
-
-void FrontendDataTypeController::OnUnrecoverableError(
- const tracked_objects::Location& from_here, const std::string& message) {
- RecordUnrecoverableError(from_here, message);
-
- // The ProfileSyncService will invoke our Stop() method in response to this.
- // We dont know the current state of the caller. Posting a task will allow
- // the caller to unwind the stack before we process unrecoverable error.
- MessageLoop::current()->PostTask(from_here,
- base::Bind(&ProfileSyncService::OnUnrecoverableError,
- sync_service_->AsWeakPtr(),
- from_here,
- message));
-}
-
-void FrontendDataTypeController::OnSingleDatatypeUnrecoverableError(
- const tracked_objects::Location& from_here, const std::string& message) {
- RecordUnrecoverableError(from_here, message);
- sync_service_->OnDisableDatatype(type(), from_here, message);
-}
-
void FrontendDataTypeController::RecordAssociationTime(base::TimeDelta time) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
#define PER_DATA_TYPE_MACRO(type_str) \
@@ -231,6 +231,7 @@ void FrontendDataTypeController::RecordAssociationTime(base::TimeDelta time) {
SYNC_DATA_TYPE_HISTOGRAM(type());
#undef PER_DATA_TYPE_MACRO
}
+
void FrontendDataTypeController::RecordStartFailure(StartResult result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
UMA_HISTOGRAM_ENUMERATION("Sync.DataTypeStartFailures", type(),

Powered by Google App Engine
This is Rietveld 408576698