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

Side by Side Diff: sync/sessions/model_type_registry.cc

Issue 254473008: sync: Introduce classes for per-type counters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « sync/sessions/model_type_registry.h ('k') | sync/sync_core.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sessions/model_type_registry.h" 5 #include "sync/sessions/model_type_registry.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "sync/engine/directory_commit_contributor.h" 9 #include "sync/engine/directory_commit_contributor.h"
10 #include "sync/engine/directory_type_debug_info_emitter.h"
11 #include "sync/engine/directory_update_handler.h" 10 #include "sync/engine/directory_update_handler.h"
12 #include "sync/engine/non_blocking_type_processor_core.h" 11 #include "sync/engine/non_blocking_type_processor_core.h"
13 #include "sync/internal_api/public/non_blocking_type_processor.h" 12 #include "sync/internal_api/public/non_blocking_type_processor.h"
13 #include "sync/sessions/directory_type_debug_info_emitter.h"
14 14
15 namespace syncer { 15 namespace syncer {
16 16
17 ModelTypeRegistry::ModelTypeRegistry() : directory_(NULL) {} 17 ModelTypeRegistry::ModelTypeRegistry() : directory_(NULL) {}
18 18
19 ModelTypeRegistry::ModelTypeRegistry( 19 ModelTypeRegistry::ModelTypeRegistry(
20 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, 20 const std::vector<scoped_refptr<ModelSafeWorker> >& workers,
21 syncable::Directory* directory) 21 syncable::Directory* directory)
22 : directory_(directory) { 22 : directory_(directory) {
23 for (size_t i = 0u; i < workers.size(); ++i) { 23 for (size_t i = 0u; i < workers.size(); ++i) {
(...skipping 26 matching lines...) Expand all
50 // Create new ones and add them to the appropriate containers. 50 // Create new ones and add them to the appropriate containers.
51 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin(); 51 for (ModelSafeRoutingInfo::const_iterator routing_iter = routing_info.begin();
52 routing_iter != routing_info.end(); ++routing_iter) { 52 routing_iter != routing_info.end(); ++routing_iter) {
53 ModelType type = routing_iter->first; 53 ModelType type = routing_iter->first;
54 ModelSafeGroup group = routing_iter->second; 54 ModelSafeGroup group = routing_iter->second;
55 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator 55 std::map<ModelSafeGroup, scoped_refptr<ModelSafeWorker> >::iterator
56 worker_it = workers_map_.find(group); 56 worker_it = workers_map_.find(group);
57 DCHECK(worker_it != workers_map_.end()); 57 DCHECK(worker_it != workers_map_.end());
58 scoped_refptr<ModelSafeWorker> worker = worker_it->second; 58 scoped_refptr<ModelSafeWorker> worker = worker_it->second;
59 59
60 DirectoryTypeDebugInfoEmitter* emitter =
61 new DirectoryTypeDebugInfoEmitter(directory_, type,
62 &type_debug_info_observers_);
60 DirectoryCommitContributor* committer = 63 DirectoryCommitContributor* committer =
61 new DirectoryCommitContributor(directory_, type); 64 new DirectoryCommitContributor(directory_, type);
62 DirectoryUpdateHandler* updater = 65 DirectoryUpdateHandler* updater =
63 new DirectoryUpdateHandler(directory_, type, worker); 66 new DirectoryUpdateHandler(directory_, type, worker);
64 DirectoryTypeDebugInfoEmitter* emitter =
65 new DirectoryTypeDebugInfoEmitter(directory_, type);
66 67
67 // These containers take ownership of their contents. 68 // These containers take ownership of their contents.
68 directory_commit_contributors_.push_back(committer); 69 directory_commit_contributors_.push_back(committer);
69 directory_update_handlers_.push_back(updater); 70 directory_update_handlers_.push_back(updater);
70 directory_type_debug_info_emitters_.push_back(emitter); 71 directory_type_debug_info_emitters_.push_back(emitter);
71 72
72 bool inserted1 = 73 bool inserted1 =
73 update_handler_map_.insert(std::make_pair(type, updater)).second; 74 update_handler_map_.insert(std::make_pair(type, updater)).second;
74 DCHECK(inserted1) << "Attempt to override existing type handler in map"; 75 DCHECK(inserted1) << "Attempt to override existing type handler in map";
75 76
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 ModelTypeSet enabled_off_thread_types; 168 ModelTypeSet enabled_off_thread_types;
168 for (ScopedVector<NonBlockingTypeProcessorCore>::const_iterator it = 169 for (ScopedVector<NonBlockingTypeProcessorCore>::const_iterator it =
169 non_blocking_type_processor_cores_.begin(); 170 non_blocking_type_processor_cores_.begin();
170 it != non_blocking_type_processor_cores_.end(); ++it) { 171 it != non_blocking_type_processor_cores_.end(); ++it) {
171 enabled_off_thread_types.Put((*it)->GetModelType()); 172 enabled_off_thread_types.Put((*it)->GetModelType());
172 } 173 }
173 return enabled_off_thread_types; 174 return enabled_off_thread_types;
174 } 175 }
175 176
176 } // namespace syncer 177 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/model_type_registry.h ('k') | sync/sync_core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698