| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_ENGINE_MODEL_SAFE_WORKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" |
| 13 #include "base/callback_old.h" | 14 #include "base/callback_old.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "chrome/browser/sync/syncable/model_type.h" | 16 #include "chrome/browser/sync/syncable/model_type.h" |
| 17 #include "chrome/browser/sync/util/unrecoverable_error_info.h" |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 class DictionaryValue; | 20 class DictionaryValue; |
| 19 } // namespace | 21 } // namespace |
| 20 | 22 |
| 21 namespace browser_sync { | 23 namespace browser_sync { |
| 22 | 24 |
| 25 typedef base::Callback<UnrecoverableErrorInfo(void)> WorkCallback; |
| 26 |
| 23 enum ModelSafeGroup { | 27 enum ModelSafeGroup { |
| 24 GROUP_PASSIVE = 0, // Models that are just "passively" being synced; e.g. | 28 GROUP_PASSIVE = 0, // Models that are just "passively" being synced; e.g. |
| 25 // changes to these models don't need to be pushed to a | 29 // changes to these models don't need to be pushed to a |
| 26 // native model. | 30 // native model. |
| 27 GROUP_UI, // Models that live on UI thread and are being synced. | 31 GROUP_UI, // Models that live on UI thread and are being synced. |
| 28 GROUP_DB, // Models that live on DB thread and are being synced. | 32 GROUP_DB, // Models that live on DB thread and are being synced. |
| 29 GROUP_FILE, // Models that live on FILE thread and are being synced. | 33 GROUP_FILE, // Models that live on FILE thread and are being synced. |
| 30 GROUP_HISTORY, // Models that live on history thread and are being | 34 GROUP_HISTORY, // Models that live on history thread and are being |
| 31 // synced. | 35 // synced. |
| 32 GROUP_PASSWORD, // Models that live on the password thread and are | 36 GROUP_PASSWORD, // Models that live on the password thread and are |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 // cause an embedding application model to fall out of sync with the | 49 // cause an embedding application model to fall out of sync with the |
| 46 // syncable::Directory due to a race. | 50 // syncable::Directory due to a race. |
| 47 class ModelSafeWorker : public base::RefCountedThreadSafe<ModelSafeWorker> { | 51 class ModelSafeWorker : public base::RefCountedThreadSafe<ModelSafeWorker> { |
| 48 public: | 52 public: |
| 49 ModelSafeWorker(); | 53 ModelSafeWorker(); |
| 50 virtual ~ModelSafeWorker(); | 54 virtual ~ModelSafeWorker(); |
| 51 | 55 |
| 52 // Any time the Syncer performs model modifications (e.g employing a | 56 // Any time the Syncer performs model modifications (e.g employing a |
| 53 // WriteTransaction), it should be done by this method to ensure it is done | 57 // WriteTransaction), it should be done by this method to ensure it is done |
| 54 // from a model-safe thread. | 58 // from a model-safe thread. |
| 55 virtual void DoWorkAndWaitUntilDone(Callback0::Type* work); | 59 virtual UnrecoverableErrorInfo DoWorkAndWaitUntilDone( |
| 60 const WorkCallback& work); |
| 56 | 61 |
| 57 virtual ModelSafeGroup GetModelSafeGroup(); | 62 virtual ModelSafeGroup GetModelSafeGroup(); |
| 58 | 63 |
| 59 private: | 64 private: |
| 60 friend class base::RefCountedThreadSafe<ModelSafeWorker>; | 65 friend class base::RefCountedThreadSafe<ModelSafeWorker>; |
| 61 | 66 |
| 62 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker); | 67 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorker); |
| 63 }; | 68 }; |
| 64 | 69 |
| 65 // A map that details which ModelSafeGroup each syncable::ModelType | 70 // A map that details which ModelSafeGroup each syncable::ModelType |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) = 0; | 107 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) = 0; |
| 103 protected: | 108 protected: |
| 104 virtual ~ModelSafeWorkerRegistrar() {} | 109 virtual ~ModelSafeWorkerRegistrar() {} |
| 105 private: | 110 private: |
| 106 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorkerRegistrar); | 111 DISALLOW_COPY_AND_ASSIGN(ModelSafeWorkerRegistrar); |
| 107 }; | 112 }; |
| 108 | 113 |
| 109 } // namespace browser_sync | 114 } // namespace browser_sync |
| 110 | 115 |
| 111 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ | 116 #endif // CHROME_BROWSER_SYNC_ENGINE_MODEL_SAFE_WORKER_H_ |
| OLD | NEW |