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

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

Issue 1368683003: USS SyncContextProxy / data type activation refactoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed CR feedback Created 5 years, 2 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
« no previous file with comments | « sync/sessions/model_type_registry.h ('k') | sync/sessions/model_type_registry_unittest.cc » ('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/observer_list.h" 8 #include "base/observer_list.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "sync/engine/commit_queue.h" 10 #include "sync/engine/commit_queue.h"
11 #include "sync/engine/directory_commit_contributor.h" 11 #include "sync/engine/directory_commit_contributor.h"
12 #include "sync/engine/directory_update_handler.h" 12 #include "sync/engine/directory_update_handler.h"
13 #include "sync/engine/model_type_processor.h" 13 #include "sync/engine/model_type_processor.h"
14 #include "sync/engine/model_type_processor_impl.h" 14 #include "sync/engine/model_type_processor_impl.h"
15 #include "sync/engine/model_type_worker.h" 15 #include "sync/engine/model_type_worker.h"
16 #include "sync/internal_api/public/non_blocking_sync_common.h" 16 #include "sync/internal_api/public/activation_context.h"
17 #include "sync/sessions/directory_type_debug_info_emitter.h" 17 #include "sync/sessions/directory_type_debug_info_emitter.h"
18 #include "sync/util/cryptographer.h" 18 #include "sync/util/cryptographer.h"
19 19
20 namespace syncer { 20 namespace syncer {
21 21
22 namespace { 22 namespace {
23 23
24 class ModelTypeProcessorProxy : public syncer_v2::ModelTypeProcessor { 24 class ModelTypeProcessorProxy : public syncer_v2::ModelTypeProcessor {
25 public: 25 public:
26 ModelTypeProcessorProxy( 26 ModelTypeProcessorProxy(
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 DCHECK(inserted2) << "Attempt to override existing type handler in map"; 181 DCHECK(inserted2) << "Attempt to override existing type handler in map";
182 } 182 }
183 183
184 enabled_directory_types_ = GetRoutingInfoTypes(routing_info); 184 enabled_directory_types_ = GetRoutingInfoTypes(routing_info);
185 DCHECK(Intersection(GetEnabledDirectoryTypes(), 185 DCHECK(Intersection(GetEnabledDirectoryTypes(),
186 GetEnabledNonBlockingTypes()).Empty()); 186 GetEnabledNonBlockingTypes()).Empty());
187 } 187 }
188 188
189 void ModelTypeRegistry::ConnectSyncTypeToWorker( 189 void ModelTypeRegistry::ConnectSyncTypeToWorker(
190 ModelType type, 190 ModelType type,
191 const syncer_v2::DataTypeState& data_type_state, 191 scoped_ptr<syncer_v2::ActivationContext> activation_context) {
192 const syncer_v2::UpdateResponseDataList& saved_pending_updates,
193 const scoped_refptr<base::SequencedTaskRunner>& type_task_runner,
194 const base::WeakPtr<syncer_v2::ModelTypeProcessor>& type_processor) {
195 DVLOG(1) << "Enabling an off-thread sync type: " << ModelTypeToString(type); 192 DVLOG(1) << "Enabling an off-thread sync type: " << ModelTypeToString(type);
196 193
197 // Initialize Worker -> Processor communication channel. 194 // Initialize Worker -> Processor communication channel.
198 scoped_ptr<syncer_v2::ModelTypeProcessor> processor_proxy( 195 scoped_ptr<syncer_v2::ModelTypeProcessor> processor_proxy(
199 new ModelTypeProcessorProxy(type_processor, type_task_runner)); 196 new ModelTypeProcessorProxy(activation_context->type_processor,
197 activation_context->type_task_runner));
200 scoped_ptr<Cryptographer> cryptographer_copy; 198 scoped_ptr<Cryptographer> cryptographer_copy;
201 if (encrypted_types_.Has(type)) 199 if (encrypted_types_.Has(type))
202 cryptographer_copy.reset(new Cryptographer(*cryptographer_)); 200 cryptographer_copy.reset(new Cryptographer(*cryptographer_));
203 201
204 scoped_ptr<syncer_v2::ModelTypeWorker> worker(new syncer_v2::ModelTypeWorker( 202 scoped_ptr<syncer_v2::ModelTypeWorker> worker(new syncer_v2::ModelTypeWorker(
205 type, data_type_state, saved_pending_updates, cryptographer_copy.Pass(), 203 type, activation_context->data_type_state,
204 activation_context->saved_pending_updates, cryptographer_copy.Pass(),
206 nudge_handler_, processor_proxy.Pass())); 205 nudge_handler_, processor_proxy.Pass()));
207 206
208 // Initialize Processor -> Worker communication channel. 207 // Initialize Processor -> Worker communication channel.
209 scoped_ptr<syncer_v2::CommitQueue> commit_queue_proxy(new CommitQueueProxy( 208 scoped_ptr<syncer_v2::CommitQueue> commit_queue_proxy(new CommitQueueProxy(
210 worker->AsWeakPtr(), scoped_refptr<base::SequencedTaskRunner>( 209 worker->AsWeakPtr(), scoped_refptr<base::SequencedTaskRunner>(
211 base::ThreadTaskRunnerHandle::Get()))); 210 base::ThreadTaskRunnerHandle::Get())));
212 type_task_runner->PostTask( 211 activation_context->type_task_runner->PostTask(
213 FROM_HERE, base::Bind(&syncer_v2::ModelTypeProcessor::OnConnect, 212 FROM_HERE, base::Bind(&syncer_v2::ModelTypeProcessor::OnConnect,
214 type_processor, base::Passed(&commit_queue_proxy))); 213 activation_context->type_processor,
214 base::Passed(&commit_queue_proxy)));
215 215
216 DCHECK(update_handler_map_.find(type) == update_handler_map_.end()); 216 DCHECK(update_handler_map_.find(type) == update_handler_map_.end());
217 DCHECK(commit_contributor_map_.find(type) == commit_contributor_map_.end()); 217 DCHECK(commit_contributor_map_.find(type) == commit_contributor_map_.end());
218 218
219 update_handler_map_.insert(std::make_pair(type, worker.get())); 219 update_handler_map_.insert(std::make_pair(type, worker.get()));
220 commit_contributor_map_.insert(std::make_pair(type, worker.get())); 220 commit_contributor_map_.insert(std::make_pair(type, worker.get()));
221 221
222 // The container takes ownership. 222 // The container takes ownership.
223 model_type_workers_.push_back(worker.Pass()); 223 model_type_workers_.push_back(worker.Pass());
224 224
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 ModelTypeSet enabled_off_thread_types; 350 ModelTypeSet enabled_off_thread_types;
351 for (ScopedVector<syncer_v2::ModelTypeWorker>::const_iterator it = 351 for (ScopedVector<syncer_v2::ModelTypeWorker>::const_iterator it =
352 model_type_workers_.begin(); 352 model_type_workers_.begin();
353 it != model_type_workers_.end(); ++it) { 353 it != model_type_workers_.end(); ++it) {
354 enabled_off_thread_types.Put((*it)->GetModelType()); 354 enabled_off_thread_types.Put((*it)->GetModelType());
355 } 355 }
356 return enabled_off_thread_types; 356 return enabled_off_thread_types;
357 } 357 }
358 358
359 } // namespace syncer 359 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/sessions/model_type_registry.h ('k') | sync/sessions/model_type_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698