Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / sync_driver / glue / ui_model_worker.h
blob1a2269c48c2b30e40ceab533daac246cd2846ea0
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/synchronization/condition_variable.h"
12 #include "base/synchronization/lock.h"
13 #include "sync/internal_api/public/engine/model_safe_worker.h"
14 #include "sync/internal_api/public/util/unrecoverable_error_info.h"
16 namespace browser_sync {
18 // A syncer::ModelSafeWorker for UI models (e.g. bookmarks) that
19 // accepts work requests from the syncapi that need to be fulfilled
20 // from the MessageLoop home to the native model.
21 class UIModelWorker : public syncer::ModelSafeWorker {
22 public:
23 UIModelWorker(const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
24 syncer::WorkerLoopDestructionObserver* observer);
26 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread.
27 void RegisterForLoopDestruction() override;
28 syncer::ModelSafeGroup GetModelSafeGroup() override;
30 protected:
31 syncer::SyncerError DoWorkAndWaitUntilDoneImpl(
32 const syncer::WorkCallback& work) override;
34 private:
35 ~UIModelWorker() override;
37 // A reference to the UI thread's task runner.
38 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
40 DISALLOW_COPY_AND_ASSIGN(UIModelWorker);
43 } // namespace browser_sync
45 #endif // COMPONENTS_SYNC_DRIVER_GLUE_UI_MODEL_WORKER_H_