1 // Copyright (c) 2011 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. 4 5 #ifndef CHROME_BROWSER_SYNC_GLUE_HISTORY_MODEL_WORKER_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_HISTORY_MODEL_WORKER_H_ 7 #pragma once 8 9 #include "chrome/browser/sync/engine/model_safe_worker.h" 10 11 #include "base/basictypes.h" 12 #include "base/callback.h" 13 #include "base/memory/ref_counted.h" 14 #include "content/browser/cancelable_request.h" 15 16 class HistoryService; 17 18 namespace base { 19 class WaitableEvent; 20 } 21 22 namespace browser_sync { 23 24 // A ModelSafeWorker for history models that accepts requests 25 // from the syncapi that need to be fulfilled on the history thread. 26 class HistoryModelWorker : public browser_sync::ModelSafeWorker, 27 public CancelableRequestConsumerBase { 28 public: 29 explicit HistoryModelWorker(HistoryService* history_service); 30 virtual ~HistoryModelWorker(); 31 32 // ModelSafeWorker implementation. Called on syncapi SyncerThread. 33 virtual void DoWorkAndWaitUntilDone(Callback0::Type* work); 34 virtual ModelSafeGroup GetModelSafeGroup(); 35 virtual bool CurrentThreadIsWorkThread(); 36 37 // CancelableRequestConsumerBase implementation. 38 virtual void OnRequestAdded(CancelableRequestProvider* provider, 39 CancelableRequestProvider::Handle handle) {} 40 41 virtual void OnRequestRemoved(CancelableRequestProvider* provider, 42 CancelableRequestProvider::Handle handle) {} 43 44 virtual void WillExecute(CancelableRequestProvider* provider, 45 CancelableRequestProvider::Handle handle) {} 46 47 virtual void DidExecute(CancelableRequestProvider* provider, 48 CancelableRequestProvider::Handle handle) {} 49 50 private: 51 scoped_refptr<HistoryService> history_service_; 52 DISALLOW_COPY_AND_ASSIGN(HistoryModelWorker); 53 }; 54 55 } // namespace browser_sync 56 57 #endif // CHROME_BROWSER_SYNC_GLUE_HISTORY_MODEL_WORKER_H_ 58