Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: sync/api/model_type_service.cc

Issue 1763953002: [USS] Change the place where SharedModelTypeProcessor got created (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sky's review Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "sync/api/model_type_service.h" 5 #include "sync/api/model_type_service.h"
6 6
7 #include "sync/api/model_type_change_processor.h"
8
7 namespace syncer_v2 { 9 namespace syncer_v2 {
8 10
9 ModelTypeService::ModelTypeService() {} 11 ModelTypeService::ModelTypeService(
12 const ChangeProcessorFactory& change_processor_factory)
13 : change_processor_factory_(change_processor_factory) {}
10 14
11 ModelTypeService::~ModelTypeService() {} 15 ModelTypeService::~ModelTypeService() {}
12 16
13 ModelTypeChangeProcessor* ModelTypeService::change_processor() const { 17 ModelTypeChangeProcessor* ModelTypeService::change_processor() const {
14 return change_processor_.get(); 18 return change_processor_.get();
15 } 19 }
16 20
17 void ModelTypeService::set_change_processor( 21 ModelTypeChangeProcessor* ModelTypeService::GetOrCreateChangeProcessor() {
18 scoped_ptr<ModelTypeChangeProcessor> change_processor) { 22 if (!change_processor_) {
19 DCHECK(!change_processor_); 23 change_processor_ = change_processor_factory_.Run(type(), this);
skym 2016/03/24 22:51:37 Cool! I didn't know this worked.
Gang Wu 2016/03/25 02:07:00 Done.
20 change_processor_.swap(change_processor); 24 DCHECK(change_processor_);
21 OnChangeProcessorSet(); 25 OnChangeProcessorSet();
26 }
27 return change_processor_.get();
22 } 28 }
23 29
24 void ModelTypeService::clear_change_processor() { 30 void ModelTypeService::clear_change_processor() {
25 change_processor_.reset(); 31 change_processor_.reset();
26 } 32 }
27 33
34 ModelTypeChangeProcessor* ModelTypeService::OnSyncStarting(
35 const ModelTypeChangeProcessor::StartCallback& start_callback) {
36 ModelTypeChangeProcessor* processor = GetOrCreateChangeProcessor();
37 DCHECK(processor);
38 processor->OnSyncStarting(start_callback);
39 return processor;
40 }
41
28 } // namespace syncer_v2 42 } // namespace syncer_v2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698