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

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

Issue 2503423004: [Sync] Move sync's ModelSafeWorker implementations to engine/. (Closed)
Patch Set: Rebase. 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
deleted file mode 100644
index c812f9a9b54ed6b95cf0c974a3d07f778f2eac48..0000000000000000000000000000000000000000
--- a/components/sync/driver/glue/ui_model_worker.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/sync/driver/glue/ui_model_worker.h"
-
-#include <utility>
-
-#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 {
-
-namespace {
-
-void CallDoWorkAndSignalEvent(const WorkCallback& work,
- syncer::ScopedEventSignal scoped_event_signal,
- SyncerError* error_info) {
- *error_info = work.Run();
- // The event in |scoped_event_signal| is signaled at the end of this scope.
-}
-
-} // namespace
-
-UIModelWorker::UIModelWorker(
- scoped_refptr<base::SingleThreadTaskRunner> ui_thread)
- : ui_thread_(std::move(ui_thread)) {}
-
-SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl(
- const WorkCallback& work) {
- SyncerError error_info;
- if (ui_thread_->BelongsToCurrentThread()) {
- DLOG(WARNING) << "DoWorkAndWaitUntilDone called from "
- << "ui_loop_. Probably a nested invocation?";
- 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)),
- &error_info))) {
- DLOG(WARNING) << "Could not post work to UI loop.";
- error_info = CANNOT_DO_WORK;
- return error_info;
- }
- work_done_or_abandoned.Wait();
-
- return error_info;
-}
-
-ModelSafeGroup UIModelWorker::GetModelSafeGroup() {
- return GROUP_UI;
-}
-
-bool UIModelWorker::IsOnModelThread() {
- return ui_thread_->BelongsToCurrentThread();
-}
-
-UIModelWorker::~UIModelWorker() {}
-
-} // namespace syncer
« no previous file with comments | « components/sync/driver/glue/ui_model_worker.h ('k') | components/sync/driver/glue/ui_model_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698