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
7namespace browser_sync {
8
9ModelSafeGroup MockUIModelWorker::GetModelSafeGroup() { return GROUP_UI; }
10bool MockUIModelWorker::CurrentThreadIsWorkThread() { return true; }
11
12ModelSafeGroup MockDBModelWorker::GetModelSafeGroup() { return GROUP_DB; }
13bool MockDBModelWorker::CurrentThreadIsWorkThread() { return true; }
14
15MockModelSafeWorkerRegistrar::~MockModelSafeWorkerRegistrar() {}
16
17// static
18MockModelSafeWorkerRegistrar*
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
27MockModelSafeWorkerRegistrar* 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
42void MockModelSafeWorkerRegistrar::GetWorkers(
43    std::vector<ModelSafeWorker*>* out) {
44  if (passive_worker_.get())
45    out->push_back(passive_worker_.get());
46}
47
48void MockModelSafeWorkerRegistrar::GetModelSafeRoutingInfo(
49    ModelSafeRoutingInfo* out) {
50  *out = routes_;
51}
52
53MockModelSafeWorkerRegistrar::MockModelSafeWorkerRegistrar(
54    const ModelSafeRoutingInfo& routes) {
55  routes_ = routes;
56}
57
58}  // namespace browser_sync
59