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

Unified Diff: components/sync/driver/glue/ui_model_worker.cc

Issue 2496723003: [Sync] Signal UIModelWorker to abort on sync shutdown. (Closed)
Patch Set: Created 4 years, 1 month 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: components/sync/driver/glue/ui_model_worker.cc
diff --git a/components/sync/driver/glue/ui_model_worker.cc b/components/sync/driver/glue/ui_model_worker.cc
index c812f9a9b54ed6b95cf0c974a3d07f778f2eac48..6afb5c78d6bfbaeb4f1da7e52d5ed0c9477f1151 100644
--- a/components/sync/driver/glue/ui_model_worker.cc
+++ b/components/sync/driver/glue/ui_model_worker.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
-#include "base/synchronization/waitable_event.h"
#include "components/sync/base/scoped_event_signal.h"
namespace syncer {
@@ -26,8 +25,11 @@ void CallDoWorkAndSignalEvent(const WorkCallback& work,
} // namespace
UIModelWorker::UIModelWorker(
- scoped_refptr<base::SingleThreadTaskRunner> ui_thread)
- : ui_thread_(std::move(ui_thread)) {}
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread)
fdoray 2016/11/11 15:40:28 Pass scoped_refptr by value https://chromium.googl
maxbogue 2016/11/12 03:19:52 Huh. We do that wrong all over sync code apparentl
+ : ui_thread_(ui_thread),
+ work_done_or_abandoned_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
fdoray 2016/11/11 15:40:28 Should be base::WaitableEvent::ResetPolicy::MANUAL
maxbogue 2016/11/12 03:19:52 Sorta right but for the wrong reason. Needs to be
+ base::WaitableEvent::InitialState::NOT_SIGNALED) {
+}
SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl(
const WorkCallback& work) {
@@ -38,26 +40,25 @@ SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl(
return work.Run();
}
- // Signaled when the task is deleted, i.e. after it runs or when it is
- // abandoned.
- base::WaitableEvent work_done_or_abandoned(
- base::WaitableEvent::ResetPolicy::AUTOMATIC,
- base::WaitableEvent::InitialState::NOT_SIGNALED);
-
if (!ui_thread_->PostTask(FROM_HERE,
base::Bind(&CallDoWorkAndSignalEvent, work,
base::Passed(syncer::ScopedEventSignal(
- &work_done_or_abandoned)),
+ &work_done_or_abandoned_)),
&error_info))) {
DLOG(WARNING) << "Could not post work to UI loop.";
error_info = CANNOT_DO_WORK;
return error_info;
}
- work_done_or_abandoned.Wait();
+ work_done_or_abandoned_.Wait();
return error_info;
}
+void UIModelWorker::RequestStop() {
+ ModelSafeWorker::RequestStop();
+ work_done_or_abandoned_.Signal();
fdoray 2016/11/11 15:40:28 In sync_integration_tests, this is called before t
maxbogue 2016/11/12 03:19:52 Done.
+}
+
ModelSafeGroup UIModelWorker::GetModelSafeGroup() {
return GROUP_UI;
}

Powered by Google App Engine
This is Rietveld 408576698