blob: a8c7933d65c0cc5ba2baab20bb9a7a3d06013e2c (
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
|
// Copyright 2015 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 "sync/api/model_type_service.h"
#include "sync/api/model_type_change_processor.h"
namespace syncer_v2 {
ModelTypeService::ModelTypeService(
const ChangeProcessorFactory& change_processor_factory,
syncer::ModelType type)
: change_processor_factory_(change_processor_factory), type_(type) {}
ModelTypeService::~ModelTypeService() {}
ModelTypeChangeProcessor* ModelTypeService::change_processor() const {
return change_processor_.get();
}
ModelTypeChangeProcessor* ModelTypeService::GetOrCreateChangeProcessor() {
if (!change_processor_) {
change_processor_ = change_processor_factory_.Run(type(), this);
DCHECK(change_processor_);
OnChangeProcessorSet();
}
return change_processor_.get();
}
void ModelTypeService::clear_change_processor() {
change_processor_.reset();
}
ModelTypeChangeProcessor* ModelTypeService::OnSyncStarting(
const ModelTypeChangeProcessor::StartCallback& start_callback) {
ModelTypeChangeProcessor* processor = GetOrCreateChangeProcessor();
DCHECK(processor);
processor->OnSyncStarting(start_callback);
return processor;
}
syncer::ModelType ModelTypeService::type() const {
return type_;
}
} // namespace syncer_v2
|