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

Unified Diff: components/sync_driver/glue/ui_model_worker.cc

Issue 2203673002: [Sync] Move //components/sync_driver to //components/sync/driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sd-a
Patch Set: Full change rebased on static lib. Created 4 years, 4 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: 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 7dfb5f00140b721662a21fa3d9445d42399eee37..0000000000000000000000000000000000000000
--- a/components/sync_driver/glue/ui_model_worker.cc
+++ /dev/null
@@ -1,78 +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 "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/message_loop/message_loop.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
-#include "base/threading/thread_restrictions.h"
-
-namespace browser_sync {
-
-namespace {
-
-// A simple callback to signal a waitable event after running a closure.
-void CallDoWorkAndSignalCallback(const syncer::WorkCallback& work,
- base::WaitableEvent* work_done,
- syncer::SyncerError* error_info) {
- if (work.is_null()) {
- // This can happen during tests or cases where there are more than just the
- // default UIModelWorker in existence and it gets destroyed before
- // the main UI loop has terminated. There is no easy way to assert the
- // loop is running / not running at the moment, so we just provide cancel
- // semantics here and short-circuit.
- // TODO(timsteele): Maybe we should have the message loop destruction
- // observer fire when the loop has ended, just a bit before it
- // actually gets destroyed.
- return;
- }
-
- *error_info = work.Run();
-
- work_done->Signal(); // Unblock the syncer thread that scheduled us.
-}
-
-} // namespace
-
-UIModelWorker::UIModelWorker(
- const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
- syncer::WorkerLoopDestructionObserver* observer)
- : syncer::ModelSafeWorker(observer), ui_thread_(ui_thread) {}
-
-void UIModelWorker::RegisterForLoopDestruction() {
- CHECK(ui_thread_->BelongsToCurrentThread());
- SetWorkingLoopToCurrent();
-}
-
-syncer::SyncerError UIModelWorker::DoWorkAndWaitUntilDoneImpl(
- const syncer::WorkCallback& work) {
- syncer::SyncerError error_info;
- if (ui_thread_->BelongsToCurrentThread()) {
- DLOG(WARNING) << "DoWorkAndWaitUntilDone called from "
- << "ui_loop_. Probably a nested invocation?";
- return work.Run();
- }
-
- if (!ui_thread_->PostTask(FROM_HERE,
- base::Bind(&CallDoWorkAndSignalCallback, work,
- work_done_or_stopped(), &error_info))) {
- DLOG(WARNING) << "Could not post work to UI loop.";
- error_info = syncer::CANNOT_DO_WORK;
- return error_info;
- }
- work_done_or_stopped()->Wait();
-
- return error_info;
-}
-
-syncer::ModelSafeGroup UIModelWorker::GetModelSafeGroup() {
- return syncer::GROUP_UI;
-}
-
-UIModelWorker::~UIModelWorker() {}
-
-} // namespace browser_sync
« 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