Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / glue / browser_thread_model_worker.h
blob241f5fcc8cc426ba92462ba66dccb9b130da4da4
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 CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/compiler_specific.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "sync/internal_api/public/engine/model_safe_worker.h"
13 #include "sync/internal_api/public/util/syncer_error.h"
15 namespace base {
16 class WaitableEvent;
19 namespace browser_sync {
21 // A syncer::ModelSafeWorker for models that accept requests from the
22 // syncapi that need to be fulfilled on a browser thread, for example
23 // autofill on the DB thread.
24 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc).
25 class BrowserThreadModelWorker : public syncer::ModelSafeWorker {
26 public:
27 BrowserThreadModelWorker(content::BrowserThread::ID thread,
28 syncer::ModelSafeGroup group,
29 syncer::WorkerLoopDestructionObserver* observer);
31 // syncer::ModelSafeWorker implementation. Called on the sync thread.
32 void RegisterForLoopDestruction() override;
33 syncer::ModelSafeGroup GetModelSafeGroup() override;
35 protected:
36 ~BrowserThreadModelWorker() override;
38 syncer::SyncerError DoWorkAndWaitUntilDoneImpl(
39 const syncer::WorkCallback& work) override;
41 // Marked pure virtual so subclasses have to override, but there is
42 // an implementation that subclasses should use. This is so that
43 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks.
44 virtual void CallDoWorkAndSignalTask(
45 const syncer::WorkCallback& work,
46 base::WaitableEvent* done,
47 syncer::SyncerError* error) = 0;
49 private:
50 content::BrowserThread::ID thread_;
51 syncer::ModelSafeGroup group_;
53 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker);
56 // Subclass BrowserThreadModelWorker so that we can distinguish them
57 // from stack traces alone.
59 class DatabaseModelWorker : public BrowserThreadModelWorker {
60 public:
61 explicit DatabaseModelWorker(syncer::WorkerLoopDestructionObserver* observer);
63 protected:
64 void CallDoWorkAndSignalTask(const syncer::WorkCallback& work,
65 base::WaitableEvent* done,
66 syncer::SyncerError* error) override;
68 private:
69 ~DatabaseModelWorker() override;
72 class FileModelWorker : public BrowserThreadModelWorker {
73 public:
74 explicit FileModelWorker(syncer::WorkerLoopDestructionObserver* observer);
76 protected:
77 void CallDoWorkAndSignalTask(const syncer::WorkCallback& work,
78 base::WaitableEvent* done,
79 syncer::SyncerError* error) override;
81 private:
82 ~FileModelWorker() override;
85 } // namespace browser_sync
87 #endif // CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_