| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // If not stopped, call DoWorkAndWaitUntilDoneImpl() to do work. Otherwise | 57 // If not stopped, call DoWorkAndWaitUntilDoneImpl() to do work. Otherwise |
| 58 // return CANNOT_DO_WORK. | 58 // return CANNOT_DO_WORK. |
| 59 SyncerError DoWorkAndWaitUntilDone(const WorkCallback& work); | 59 SyncerError DoWorkAndWaitUntilDone(const WorkCallback& work); |
| 60 | 60 |
| 61 // Soft stop worker by setting stopped_ flag. Called when sync is disabled | 61 // Soft stop worker by setting stopped_ flag. Called when sync is disabled |
| 62 // or browser is shutting down. Called on UI loop. | 62 // or browser is shutting down. Called on UI loop. |
| 63 virtual void RequestStop(); | 63 virtual void RequestStop(); |
| 64 | 64 |
| 65 virtual ModelSafeGroup GetModelSafeGroup() = 0; | 65 virtual ModelSafeGroup GetModelSafeGroup() = 0; |
| 66 | 66 |
| 67 // Returns true if called on the thread this worker works on. |
| 68 virtual bool IsOnModelThread() = 0; |
| 69 |
| 67 protected: | 70 protected: |
| 68 ModelSafeWorker(); | 71 ModelSafeWorker(); |
| 69 virtual ~ModelSafeWorker(); | 72 virtual ~ModelSafeWorker(); |
| 70 | 73 |
| 71 // Any time the Syncer performs model modifications (e.g employing a | 74 // Any time the Syncer performs model modifications (e.g employing a |
| 72 // WriteTransaction), it should be done by this method to ensure it is done | 75 // WriteTransaction), it should be done by this method to ensure it is done |
| 73 // from a model-safe thread. | 76 // from a model-safe thread. |
| 74 virtual SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) = 0; | 77 virtual SyncerError DoWorkAndWaitUntilDoneImpl(const WorkCallback& work) = 0; |
| 75 | 78 |
| 76 // Return true if the worker was stopped. Thread safe. | 79 // Return true if the worker was stopped. Thread safe. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 98 const ModelSafeRoutingInfo& routing_info); | 101 const ModelSafeRoutingInfo& routing_info); |
| 99 | 102 |
| 100 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); | 103 ModelTypeSet GetRoutingInfoTypes(const ModelSafeRoutingInfo& routing_info); |
| 101 | 104 |
| 102 ModelSafeGroup GetGroupForModelType(const ModelType type, | 105 ModelSafeGroup GetGroupForModelType(const ModelType type, |
| 103 const ModelSafeRoutingInfo& routes); | 106 const ModelSafeRoutingInfo& routes); |
| 104 | 107 |
| 105 } // namespace syncer | 108 } // namespace syncer |
| 106 | 109 |
| 107 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 110 #endif // COMPONENTS_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| OLD | NEW |