blob: a8cff05864ff936baa594f70f1df7cb3b84d0e9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync_driver/non_blocking_data_type_manager.h"
#include "base/sequenced_task_runner.h"
#include "components/sync_driver/non_blocking_data_type_controller.h"
#include "sync/engine/model_type_sync_proxy_impl.h"
namespace sync_driver {
NonBlockingDataTypeManager::NonBlockingDataTypeManager() {
}
NonBlockingDataTypeManager::~NonBlockingDataTypeManager() {
}
void NonBlockingDataTypeManager::RegisterType(
syncer::ModelType type,
bool enabled) {
DCHECK_EQ(0U, non_blocking_data_type_controllers_.count(type))
<< "Duplicate registration of type " << ModelTypeToString(type);
non_blocking_data_type_controllers_.insert(
type, make_scoped_ptr(new NonBlockingDataTypeController(type, enabled)));
}
void NonBlockingDataTypeManager::InitializeType(
syncer::ModelType type,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const base::WeakPtr<syncer_v2::ModelTypeSyncProxyImpl>& proxy_impl) {
NonBlockingDataTypeControllerMap::const_iterator it =
non_blocking_data_type_controllers_.find(type);
DCHECK(it != non_blocking_data_type_controllers_.end());
it->second->InitializeType(task_runner, proxy_impl);
}
void NonBlockingDataTypeManager::ConnectSyncBackend(
scoped_ptr<syncer_v2::SyncContextProxy> proxy) {
for (NonBlockingDataTypeControllerMap::const_iterator it =
non_blocking_data_type_controllers_.begin();
it != non_blocking_data_type_controllers_.end(); ++it) {
it->second->InitializeSyncContext(proxy->Clone());
}
}
void NonBlockingDataTypeManager::DisconnectSyncBackend() {
for (NonBlockingDataTypeControllerMap::const_iterator it =
non_blocking_data_type_controllers_.begin();
it != non_blocking_data_type_controllers_.end(); ++it) {
it->second->ClearSyncContext();
}
}
void NonBlockingDataTypeManager::SetPreferredTypes(
syncer::ModelTypeSet preferred_types) {
for (NonBlockingDataTypeControllerMap::const_iterator it =
non_blocking_data_type_controllers_.begin();
it != non_blocking_data_type_controllers_.end(); ++it) {
it->second->SetIsPreferred(preferred_types.Has(it->first));
}
}
syncer::ModelTypeSet NonBlockingDataTypeManager::GetRegisteredTypes() const {
syncer::ModelTypeSet result;
for (NonBlockingDataTypeControllerMap::const_iterator it =
non_blocking_data_type_controllers_.begin();
it != non_blocking_data_type_controllers_.end(); ++it) {
result.Put(it->first);
}
return result;
}
} // namespace sync_driver
|