| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // syncapi that need to be fulfilled on a browser thread, for example | 22 // syncapi that need to be fulfilled on a browser thread, for example |
| 23 // autofill on the DB thread. | 23 // autofill on the DB thread. |
| 24 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc). | 24 // TODO(sync): Try to generalize other ModelWorkers (e.g. history, etc). |
| 25 class BrowserThreadModelWorker : public syncer::ModelSafeWorker { | 25 class BrowserThreadModelWorker : public syncer::ModelSafeWorker { |
| 26 public: | 26 public: |
| 27 BrowserThreadModelWorker(content::BrowserThread::ID thread, | 27 BrowserThreadModelWorker(content::BrowserThread::ID thread, |
| 28 syncer::ModelSafeGroup group, | 28 syncer::ModelSafeGroup group, |
| 29 syncer::WorkerLoopDestructionObserver* observer); | 29 syncer::WorkerLoopDestructionObserver* observer); |
| 30 | 30 |
| 31 // syncer::ModelSafeWorker implementation. Called on the sync thread. | 31 // syncer::ModelSafeWorker implementation. Called on the sync thread. |
| 32 virtual void RegisterForLoopDestruction() override; | 32 void RegisterForLoopDestruction() override; |
| 33 virtual syncer::ModelSafeGroup GetModelSafeGroup() override; | 33 syncer::ModelSafeGroup GetModelSafeGroup() override; |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 virtual ~BrowserThreadModelWorker(); | 36 ~BrowserThreadModelWorker() override; |
| 37 | 37 |
| 38 virtual syncer::SyncerError DoWorkAndWaitUntilDoneImpl( | 38 syncer::SyncerError DoWorkAndWaitUntilDoneImpl( |
| 39 const syncer::WorkCallback& work) override; | 39 const syncer::WorkCallback& work) override; |
| 40 | 40 |
| 41 // Marked pure virtual so subclasses have to override, but there is | 41 // Marked pure virtual so subclasses have to override, but there is |
| 42 // an implementation that subclasses should use. This is so that | 42 // an implementation that subclasses should use. This is so that |
| 43 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks. | 43 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks. |
| 44 virtual void CallDoWorkAndSignalTask( | 44 virtual void CallDoWorkAndSignalTask( |
| 45 const syncer::WorkCallback& work, | 45 const syncer::WorkCallback& work, |
| 46 base::WaitableEvent* done, | 46 base::WaitableEvent* done, |
| 47 syncer::SyncerError* error) = 0; | 47 syncer::SyncerError* error) = 0; |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 content::BrowserThread::ID thread_; | 50 content::BrowserThread::ID thread_; |
| 51 syncer::ModelSafeGroup group_; | 51 syncer::ModelSafeGroup group_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); | 53 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Subclass BrowserThreadModelWorker so that we can distinguish them | 56 // Subclass BrowserThreadModelWorker so that we can distinguish them |
| 57 // from stack traces alone. | 57 // from stack traces alone. |
| 58 | 58 |
| 59 class DatabaseModelWorker : public BrowserThreadModelWorker { | 59 class DatabaseModelWorker : public BrowserThreadModelWorker { |
| 60 public: | 60 public: |
| 61 explicit DatabaseModelWorker(syncer::WorkerLoopDestructionObserver* observer); | 61 explicit DatabaseModelWorker(syncer::WorkerLoopDestructionObserver* observer); |
| 62 | 62 |
| 63 protected: | 63 protected: |
| 64 virtual void CallDoWorkAndSignalTask( | 64 void CallDoWorkAndSignalTask(const syncer::WorkCallback& work, |
| 65 const syncer::WorkCallback& work, | 65 base::WaitableEvent* done, |
| 66 base::WaitableEvent* done, | 66 syncer::SyncerError* error) override; |
| 67 syncer::SyncerError* error) override; | |
| 68 | 67 |
| 69 private: | 68 private: |
| 70 virtual ~DatabaseModelWorker(); | 69 ~DatabaseModelWorker() override; |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 class FileModelWorker : public BrowserThreadModelWorker { | 72 class FileModelWorker : public BrowserThreadModelWorker { |
| 74 public: | 73 public: |
| 75 explicit FileModelWorker(syncer::WorkerLoopDestructionObserver* observer); | 74 explicit FileModelWorker(syncer::WorkerLoopDestructionObserver* observer); |
| 76 | 75 |
| 77 protected: | 76 protected: |
| 78 virtual void CallDoWorkAndSignalTask( | 77 void CallDoWorkAndSignalTask(const syncer::WorkCallback& work, |
| 79 const syncer::WorkCallback& work, | 78 base::WaitableEvent* done, |
| 80 base::WaitableEvent* done, | 79 syncer::SyncerError* error) override; |
| 81 syncer::SyncerError* error) override; | |
| 82 | 80 |
| 83 private: | 81 private: |
| 84 virtual ~FileModelWorker(); | 82 ~FileModelWorker() override; |
| 85 }; | 83 }; |
| 86 | 84 |
| 87 } // namespace browser_sync | 85 } // namespace browser_sync |
| 88 | 86 |
| 89 #endif // CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ | 87 #endif // CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ |
| OLD | NEW |