OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/sync/engine/mock_model_safe_workers.h" | |
6 | |
7 namespace browser_sync { | |
8 | |
9 ModelSafeGroup MockUIModelWorker::GetModelSafeGroup() { return GROUP_UI; } | |
10 | |
11 ModelSafeGroup MockDBModelWorker::GetModelSafeGroup() { return GROUP_DB; } | |
12 | |
13 ModelSafeGroup MockFileModelWorker::GetModelSafeGroup() { return GROUP_FILE; } | |
14 | |
15 MockModelSafeWorkerRegistrar::~MockModelSafeWorkerRegistrar() {} | |
16 | |
17 // static | |
18 MockModelSafeWorkerRegistrar* | |
19 MockModelSafeWorkerRegistrar::PassiveBookmarks() { | |
20 ModelSafeRoutingInfo routes; | |
21 routes[syncable::BOOKMARKS] = GROUP_PASSIVE; | |
22 MockModelSafeWorkerRegistrar* m = new MockModelSafeWorkerRegistrar(routes); | |
23 m->passive_worker_ = new ModelSafeWorker(); | |
24 return m; | |
25 } | |
26 | |
27 MockModelSafeWorkerRegistrar* MockModelSafeWorkerRegistrar::PassiveForTypes( | |
28 const syncable::ModelTypeBitSet& set) { | |
29 ModelSafeRoutingInfo routes; | |
30 for (int i = syncable::UNSPECIFIED ; i < syncable::MODEL_TYPE_COUNT; ++i) { | |
31 syncable::ModelType type = syncable::ModelTypeFromInt(i); | |
32 if (set[type]) { | |
33 routes[type] = GROUP_PASSIVE; | |
34 } | |
35 } | |
36 MockModelSafeWorkerRegistrar* m = new MockModelSafeWorkerRegistrar(routes); | |
37 m->passive_worker_ = new ModelSafeWorker(); | |
38 return m; | |
39 } | |
40 | |
41 | |
42 void MockModelSafeWorkerRegistrar::GetWorkers( | |
43 std::vector<ModelSafeWorker*>* out) { | |
44 if (passive_worker_.get()) | |
45 out->push_back(passive_worker_.get()); | |
46 } | |
47 | |
48 void MockModelSafeWorkerRegistrar::GetModelSafeRoutingInfo( | |
49 ModelSafeRoutingInfo* out) { | |
50 *out = routes_; | |
51 } | |
52 | |
53 MockModelSafeWorkerRegistrar::MockModelSafeWorkerRegistrar( | |
54 const ModelSafeRoutingInfo& routes) { | |
55 routes_ = routes; | |
56 } | |
57 | |
58 } // namespace browser_sync | |
OLD | NEW |