Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / sync / glue / history_model_worker.h
blob7a7419157b0cd8a6364ae5d1a9ec870b4af98b79
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_HISTORY_MODEL_WORKER_H_
6 #define CHROME_BROWSER_SYNC_GLUE_HISTORY_MODEL_WORKER_H_
8 #include "sync/internal_api/public/engine/model_safe_worker.h"
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/task/cancelable_task_tracker.h"
16 #include "components/history/core/browser/history_db_task.h"
17 #include "components/history/core/browser/history_service.h"
19 namespace history {
20 class HistoryService;
23 namespace browser_sync {
25 // A syncer::ModelSafeWorker for history models that accepts requests
26 // from the syncapi that need to be fulfilled on the history thread.
27 class HistoryModelWorker : public syncer::ModelSafeWorker {
28 public:
29 explicit HistoryModelWorker(
30 const base::WeakPtr<history::HistoryService>& history_service,
31 syncer::WorkerLoopDestructionObserver* observer);
33 // syncer::ModelSafeWorker implementation. Called on syncapi SyncerThread.
34 void RegisterForLoopDestruction() override;
35 syncer::ModelSafeGroup GetModelSafeGroup() override;
37 // Called on history DB thread to register HistoryModelWorker to observe
38 // destruction of history backend loop.
39 void RegisterOnDBThread();
41 protected:
42 syncer::SyncerError DoWorkAndWaitUntilDoneImpl(
43 const syncer::WorkCallback& work) override;
45 private:
46 ~HistoryModelWorker() override;
48 const base::WeakPtr<history::HistoryService> history_service_;
49 // Helper object to make sure we don't leave tasks running on the history
50 // thread.
51 scoped_ptr<base::CancelableTaskTracker> cancelable_tracker_;
52 DISALLOW_COPY_AND_ASSIGN(HistoryModelWorker);
55 } // namespace browser_sync
57 #endif // CHROME_BROWSER_SYNC_GLUE_HISTORY_MODEL_WORKER_H_