Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_MOCK_MODEL_SAFE_WORKERS_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_MOCK_MODEL_SAFE_WORKERS_H_ |
| 6 #define CHROME_BROWSER_SYNC_ENGINE_MOCK_MODEL_SAFE_WORKERS_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_MOCK_MODEL_SAFE_WORKERS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/scoped_vector.h" | |
|
akalin
2011/01/20 00:47:57
needed?
tim (not reviewing)
2011/01/25 03:23:05
Done.
| |
| 9 #include "chrome/browser/sync/engine/model_safe_worker.h" | 10 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 10 | 11 |
| 11 namespace browser_sync { | 12 namespace browser_sync { |
| 12 | 13 |
| 13 class MockUIModelWorker : public ModelSafeWorker { | 14 class MockUIModelWorker : public ModelSafeWorker { |
| 14 public: | 15 public: |
| 15 virtual ModelSafeGroup GetModelSafeGroup() { return GROUP_UI; } | 16 virtual ModelSafeGroup GetModelSafeGroup() { return GROUP_UI; } |
| 16 virtual bool CurrentThreadIsWorkThread() { return true; } | 17 virtual bool CurrentThreadIsWorkThread() { return true; } |
| 17 }; | 18 }; |
| 18 | 19 |
| 19 class MockDBModelWorker : public ModelSafeWorker { | 20 class MockDBModelWorker : public ModelSafeWorker { |
| 20 public: | 21 public: |
| 21 virtual ModelSafeGroup GetModelSafeGroup() { return GROUP_DB; } | 22 virtual ModelSafeGroup GetModelSafeGroup() { return GROUP_DB; } |
| 22 virtual bool CurrentThreadIsWorkThread() { return true; } | 23 virtual bool CurrentThreadIsWorkThread() { return true; } |
| 23 }; | 24 }; |
| 24 | 25 |
| 26 class MockModelSafeWorkerRegistrar : public ModelSafeWorkerRegistrar { | |
| 27 public: | |
| 28 virtual ~MockModelSafeWorkerRegistrar() {} | |
| 29 static MockModelSafeWorkerRegistrar* PassiveBookmarks() { | |
| 30 ModelSafeRoutingInfo routes; | |
| 31 routes[syncable::BOOKMARKS] = GROUP_PASSIVE; | |
| 32 MockModelSafeWorkerRegistrar* m = new MockModelSafeWorkerRegistrar(routes); | |
| 33 m->passive_worker_ = new ModelSafeWorker(); | |
| 34 return m; | |
| 35 } | |
| 36 virtual void GetWorkers(std::vector<ModelSafeWorker*>* out) { | |
| 37 if (passive_worker_.get()) | |
| 38 out->push_back(passive_worker_.get()); | |
| 39 } | |
| 40 | |
| 41 virtual void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { | |
| 42 *out = routes_; | |
| 43 } | |
| 44 private: | |
| 45 explicit MockModelSafeWorkerRegistrar(const ModelSafeRoutingInfo& routes) { | |
| 46 routes_ = routes; | |
| 47 } | |
| 48 scoped_refptr<ModelSafeWorker> passive_worker_; | |
| 49 ModelSafeRoutingInfo routes_; | |
| 50 }; | |
| 51 | |
| 25 } // namespace browser_sync | 52 } // namespace browser_sync |
| 26 | 53 |
| 27 #endif // CHROME_BROWSER_SYNC_ENGINE_MOCK_MODEL_SAFE_WORKERS_H_ | 54 #endif // CHROME_BROWSER_SYNC_ENGINE_MOCK_MODEL_SAFE_WORKERS_H_ |
| 28 | 55 |
| OLD | NEW |