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

Unified Diff: chrome/browser/sync/glue/ui_model_worker.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/ui_model_worker.cc
diff --git a/chrome/browser/sync/glue/ui_model_worker.cc b/chrome/browser/sync/glue/ui_model_worker.cc
index 096693d94717e09f636c8ef29df5a37dea0b5592..75d7d50f0330d30ffa17837d402ed2b549ecbd52 100644
--- a/chrome/browser/sync/glue/ui_model_worker.cc
+++ b/chrome/browser/sync/glue/ui_model_worker.cc
@@ -44,6 +44,35 @@ void CallDoWorkAndSignalCallback(const WorkCallback& work,
} // namespace
+UIModelWorker::UIModelWorker()
+ : state_(WORKING),
+ syncapi_has_shutdown_(false),
+ syncapi_event_(&lock_) {
+}
+
+void UIModelWorker::Stop() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ base::AutoLock lock(lock_);
+ DCHECK_EQ(state_, WORKING);
+
+ // We're on our own now, the beloved UI MessageLoop is no longer running.
+ // Any tasks scheduled or to be scheduled on the UI MessageLoop will not run.
+ state_ = RUNNING_MANUAL_SHUTDOWN_PUMP;
+
+ // Drain any final tasks manually until the SyncerThread tells us it has
+ // totally finished. There should only ever be 0 or 1 tasks Run() here.
+ while (!syncapi_has_shutdown_) {
+ if (!pending_work_.is_null())
+ pending_work_.Run(); // OnTaskCompleted will set reset |pending_work_|.
+
+ // Wait for either a new task or SyncerThread termination.
+ syncapi_event_.Wait();
+ }
+
+ state_ = STOPPED;
+}
+
SyncerError UIModelWorker::DoWorkAndWaitUntilDone(
const WorkCallback& work) {
// In most cases, this method is called in WORKING state. It is possible this
@@ -82,14 +111,8 @@ SyncerError UIModelWorker::DoWorkAndWaitUntilDone(
return error_info;
}
-UIModelWorker::UIModelWorker()
- : state_(WORKING),
- syncapi_has_shutdown_(false),
- syncapi_event_(&lock_) {
-}
-
-UIModelWorker::~UIModelWorker() {
- DCHECK_EQ(state_, STOPPED);
+ModelSafeGroup UIModelWorker::GetModelSafeGroup() {
+ return GROUP_UI;
}
void UIModelWorker::OnSyncerShutdownComplete() {
@@ -105,31 +128,8 @@ void UIModelWorker::OnSyncerShutdownComplete() {
syncapi_event_.Signal();
}
-void UIModelWorker::Stop() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- base::AutoLock lock(lock_);
- DCHECK_EQ(state_, WORKING);
-
- // We're on our own now, the beloved UI MessageLoop is no longer running.
- // Any tasks scheduled or to be scheduled on the UI MessageLoop will not run.
- state_ = RUNNING_MANUAL_SHUTDOWN_PUMP;
-
- // Drain any final tasks manually until the SyncerThread tells us it has
- // totally finished. There should only ever be 0 or 1 tasks Run() here.
- while (!syncapi_has_shutdown_) {
- if (!pending_work_.is_null())
- pending_work_.Run(); // OnTaskCompleted will set reset |pending_work_|.
-
- // Wait for either a new task or SyncerThread termination.
- syncapi_event_.Wait();
- }
-
- state_ = STOPPED;
-}
-
-ModelSafeGroup UIModelWorker::GetModelSafeGroup() {
- return GROUP_UI;
+UIModelWorker::~UIModelWorker() {
+ DCHECK_EQ(state_, STOPPED);
}
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/ui_model_worker.h ('k') | chrome/browser/sync/profile_sync_service_autofill_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698