Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: chrome/browser/sync/glue/browser_thread_model_worker.h

Issue 14046031: Worker changes to prepare for lock-free shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "sync/internal_api/public/engine/model_safe_worker.h" 12 #include "sync/internal_api/public/engine/model_safe_worker.h"
13 #include "sync/internal_api/public/util/syncer_error.h" 13 #include "sync/internal_api/public/util/syncer_error.h"
14 14
15 namespace base { 15 namespace base {
16 class WaitableEvent; 16 class WaitableEvent;
17 } 17 }
18 18
19 namespace browser_sync { 19 namespace browser_sync {
20 20
21 // A syncer::ModelSafeWorker for models that accept requests from the 21 // A syncer::ModelSafeWorker for models that accept requests from the
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. TODO(sync): Try to generalize other 23 // autofill on the DB thread.
24 // 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::WorkerObserver* observer);
29 30
30 // syncer::ModelSafeWorker implementation. Called on the sync thread. 31 // syncer::ModelSafeWorker implementation. Called on the sync thread.
31 virtual syncer::SyncerError DoWorkAndWaitUntilDone( 32 virtual void RegisterForLoopDestruction() OVERRIDE;
32 const syncer::WorkCallback& work) OVERRIDE;
33 virtual syncer::ModelSafeGroup GetModelSafeGroup() OVERRIDE; 33 virtual syncer::ModelSafeGroup GetModelSafeGroup() OVERRIDE;
34 34
35 protected: 35 protected:
36 virtual ~BrowserThreadModelWorker(); 36 virtual ~BrowserThreadModelWorker();
37 37
38 virtual syncer::SyncerError DoWorkAndWaitUntilDone(
39 const syncer::WorkCallback& work,
40 base::WaitableEvent* done) OVERRIDE;
41
38 // Marked pure virtual so subclasses have to override, but there is 42 // Marked pure virtual so subclasses have to override, but there is
39 // an implementation that subclasses should use. This is so that 43 // an implementation that subclasses should use. This is so that
40 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks. 44 // (subclass)::CallDoWorkAndSignalTask shows up in callstacks.
41 virtual void CallDoWorkAndSignalTask( 45 virtual void CallDoWorkAndSignalTask(
42 const syncer::WorkCallback& work, 46 const syncer::WorkCallback& work,
43 base::WaitableEvent* done, 47 base::WaitableEvent* done,
44 syncer::SyncerError* error) = 0; 48 syncer::SyncerError* error) = 0;
45 49
46 private: 50 private:
47 content::BrowserThread::ID thread_; 51 content::BrowserThread::ID thread_;
48 syncer::ModelSafeGroup group_; 52 syncer::ModelSafeGroup group_;
49 53
50 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker); 54 DISALLOW_COPY_AND_ASSIGN(BrowserThreadModelWorker);
51 }; 55 };
52 56
53 // Subclass BrowserThreadModelWorker so that we can distinguish them 57 // Subclass BrowserThreadModelWorker so that we can distinguish them
54 // from stack traces alone. 58 // from stack traces alone.
55 59
56 class DatabaseModelWorker : public BrowserThreadModelWorker { 60 class DatabaseModelWorker : public BrowserThreadModelWorker {
57 public: 61 public:
58 DatabaseModelWorker(); 62 DatabaseModelWorker(syncer::WorkerObserver* observer);
59 63
60 protected: 64 protected:
61 virtual void CallDoWorkAndSignalTask( 65 virtual void CallDoWorkAndSignalTask(
62 const syncer::WorkCallback& work, 66 const syncer::WorkCallback& work,
63 base::WaitableEvent* done, 67 base::WaitableEvent* done,
64 syncer::SyncerError* error) OVERRIDE; 68 syncer::SyncerError* error) OVERRIDE;
65 69
66 private: 70 private:
67 virtual ~DatabaseModelWorker(); 71 virtual ~DatabaseModelWorker();
68 }; 72 };
69 73
70 class FileModelWorker : public BrowserThreadModelWorker { 74 class FileModelWorker : public BrowserThreadModelWorker {
71 public: 75 public:
72 FileModelWorker(); 76 FileModelWorker(syncer::WorkerObserver* observer);
73 77
74 protected: 78 protected:
75 virtual void CallDoWorkAndSignalTask( 79 virtual void CallDoWorkAndSignalTask(
76 const syncer::WorkCallback& work, 80 const syncer::WorkCallback& work,
77 base::WaitableEvent* done, 81 base::WaitableEvent* done,
78 syncer::SyncerError* error) OVERRIDE; 82 syncer::SyncerError* error) OVERRIDE;
79 83
80 private: 84 private:
81 virtual ~FileModelWorker(); 85 virtual ~FileModelWorker();
82 }; 86 };
83 87
84 } // namespace browser_sync 88 } // namespace browser_sync
85 89
86 #endif // CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_ 90 #endif // CHROME_BROWSER_SYNC_GLUE_BROWSER_THREAD_MODEL_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698