| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 6 #define COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 6 #define COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // If not stopped, calls ScheduleWork() to schedule |work| and waits until it | 59 // If not stopped, calls ScheduleWork() to schedule |work| and waits until it |
| 60 // is done or abandoned. Otherwise, returns CANNOT_DO_WORK. | 60 // is done or abandoned. Otherwise, returns CANNOT_DO_WORK. |
| 61 SyncerError DoWorkAndWaitUntilDone(WorkCallback work); | 61 SyncerError DoWorkAndWaitUntilDone(WorkCallback work); |
| 62 | 62 |
| 63 // Soft stop worker by setting stopped_ flag. Called when sync is disabled | 63 // Soft stop worker by setting stopped_ flag. Called when sync is disabled |
| 64 // or browser is shutting down. Called on UI loop. | 64 // or browser is shutting down. Called on UI loop. |
| 65 virtual void RequestStop(); | 65 virtual void RequestStop(); |
| 66 | 66 |
| 67 virtual ModelSafeGroup GetModelSafeGroup() = 0; | 67 virtual ModelSafeGroup GetModelSafeGroup() = 0; |
| 68 | 68 |
| 69 // Returns true if called on the thread this worker works on. | 69 // Returns true if called on the sequence this worker works on. |
| 70 virtual bool IsOnModelThread() = 0; | 70 virtual bool IsOnModelSequence() = 0; |
| 71 | 71 |
| 72 protected: | 72 protected: |
| 73 ModelSafeWorker(); | 73 ModelSafeWorker(); |
| 74 virtual ~ModelSafeWorker(); | 74 virtual ~ModelSafeWorker(); |
| 75 | 75 |
| 76 private: | 76 private: |
| 77 friend class base::RefCountedThreadSafe<ModelSafeWorker>; | 77 friend class base::RefCountedThreadSafe<ModelSafeWorker>; |
| 78 | 78 |
| 79 // Schedules |work| on the appropriate thread. | 79 // Schedules |work| on the appropriate sequence. |
| 80 virtual void ScheduleWork(base::OnceClosure work) = 0; | 80 virtual void ScheduleWork(base::OnceClosure work) = 0; |
| 81 | 81 |
| 82 void DoWork(WorkCallback work, | 82 void DoWork(WorkCallback work, |
| 83 base::ScopedClosureRunner scoped_closure_runner, | 83 base::ScopedClosureRunner scoped_closure_runner, |
| 84 SyncerError* error, | 84 SyncerError* error, |
| 85 bool* did_run); | 85 bool* did_run); |
| 86 | 86 |
| 87 // Synchronizes access to all members. | 87 // Synchronizes access to all members. |
| 88 base::Lock lock_; | 88 base::Lock lock_; |
| 89 | 89 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 115 const ModelSafeRoutingInfo& routing_info); | 115 const ModelSafeRoutingInfo& routing_info); |
| 116 | 116 |
| 117 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); | 117 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); |
| 118 | 118 |
| 119 ModelSafeGroup GetGroupForModelType(const ModelType type, | 119 ModelSafeGroup GetGroupForModelType(const ModelType type, |
| 120 const ModelSafeRoutingInfo& routes); | 120 const ModelSafeRoutingInfo& routes); |
| 121 | 121 |
| 122 } // namespace syncer | 122 } // namespace syncer |
| 123 | 123 |
| 124 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 124 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| OLD | NEW |