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

Side by Side Diff: sync/engine/sync_scheduler_impl.cc

Issue 10947039: Removed safe worker calculation from SyncScheduler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reintroduced workers param to the SyncSession constructor. Created 8 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/engine/sync_scheduler_impl.h" 5 #include "sync/engine/sync_scheduler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 scoped_ptr<SyncSession> dummy(new SyncSession(session_context_, this, 293 scoped_ptr<SyncSession> dummy(new SyncSession(session_context_, this,
294 SyncSourceInfo(), ModelSafeRoutingInfo(), 294 SyncSourceInfo(), ModelSafeRoutingInfo(),
295 std::vector<ModelSafeWorker*>())); 295 std::vector<ModelSafeWorker*>()));
296 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); 296 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED);
297 event.snapshot = dummy->TakeSnapshot(); 297 event.snapshot = dummy->TakeSnapshot();
298 session_context_->NotifyListeners(event); 298 session_context_->NotifyListeners(event);
299 } 299 }
300 300
301 namespace { 301 namespace {
302 302
303 // Helper to extract the routing info and workers corresponding to types in 303 // Helper to extract the routing info corresponding to types in
304 // |types| from |current_routes| and |current_workers|. 304 // |types| from |current_routes|.
305 void BuildModelSafeParams( 305 void BuildModelSafeParams(
306 ModelTypeSet types_to_download, 306 ModelTypeSet types_to_download,
307 const ModelSafeRoutingInfo& current_routes, 307 const ModelSafeRoutingInfo& current_routes,
308 const std::vector<ModelSafeWorker*>& current_workers, 308 ModelSafeRoutingInfo* result_routes) {
309 ModelSafeRoutingInfo* result_routes,
310 std::vector<ModelSafeWorker*>* result_workers) {
311 std::set<ModelSafeGroup> active_groups; 309 std::set<ModelSafeGroup> active_groups;
312 active_groups.insert(GROUP_PASSIVE); 310 active_groups.insert(GROUP_PASSIVE);
313 for (ModelTypeSet::Iterator iter = types_to_download.First(); iter.Good(); 311 for (ModelTypeSet::Iterator iter = types_to_download.First(); iter.Good();
314 iter.Inc()) { 312 iter.Inc()) {
315 ModelType type = iter.Get(); 313 ModelType type = iter.Get();
316 ModelSafeRoutingInfo::const_iterator route = current_routes.find(type); 314 ModelSafeRoutingInfo::const_iterator route = current_routes.find(type);
317 DCHECK(route != current_routes.end()); 315 DCHECK(route != current_routes.end());
318 ModelSafeGroup group = route->second; 316 ModelSafeGroup group = route->second;
319 (*result_routes)[type] = group; 317 (*result_routes)[type] = group;
320 active_groups.insert(group); 318 active_groups.insert(group);
rlarocque 2012/09/20 00:41:24 Can you remove active_groups?
321 } 319 }
322
323 for(std::vector<ModelSafeWorker*>::const_iterator iter =
324 current_workers.begin(); iter != current_workers.end(); ++iter) {
325 if (active_groups.count((*iter)->GetModelSafeGroup()) > 0)
326 result_workers->push_back(*iter);
327 }
328 } 320 }
329 321
330 } // namespace. 322 } // namespace.
331 323
332 bool SyncSchedulerImpl::ScheduleConfiguration( 324 bool SyncSchedulerImpl::ScheduleConfiguration(
333 const ConfigurationParams& params) { 325 const ConfigurationParams& params) {
334 DCHECK_EQ(MessageLoop::current(), sync_loop_); 326 DCHECK_EQ(MessageLoop::current(), sync_loop_);
335 DCHECK(IsConfigRelatedUpdateSourceValue(params.source)); 327 DCHECK(IsConfigRelatedUpdateSourceValue(params.source));
336 DCHECK_EQ(CONFIGURATION_MODE, mode_); 328 DCHECK_EQ(CONFIGURATION_MODE, mode_);
337 DCHECK(!params.ready_task.is_null()); 329 DCHECK(!params.ready_task.is_null());
338 SDVLOG(2) << "Reconfiguring syncer."; 330 SDVLOG(2) << "Reconfiguring syncer.";
339 331
340 // Only one configuration is allowed at a time. Verify we're not waiting 332 // Only one configuration is allowed at a time. Verify we're not waiting
341 // for a pending configure job. 333 // for a pending configure job.
342 DCHECK(!wait_interval_.get() || !wait_interval_->pending_configure_job.get()); 334 DCHECK(!wait_interval_.get() || !wait_interval_->pending_configure_job.get());
343 335
344 // TODO(sync): now that ModelChanging commands only use those workers within
345 // the routing info, we don't really need |restricted_workers|. Remove it.
346 // crbug.com/133030
347 ModelSafeRoutingInfo restricted_routes; 336 ModelSafeRoutingInfo restricted_routes;
348 std::vector<ModelSafeWorker*> restricted_workers;
349 BuildModelSafeParams(params.types_to_download, 337 BuildModelSafeParams(params.types_to_download,
350 params.routing_info, 338 params.routing_info,
351 session_context_->workers(), 339 &restricted_routes);
352 &restricted_routes,
353 &restricted_workers);
354 session_context_->set_routing_info(params.routing_info); 340 session_context_->set_routing_info(params.routing_info);
355 341
356 // Only reconfigure if we have types to download. 342 // Only reconfigure if we have types to download.
357 if (!params.types_to_download.Empty()) { 343 if (!params.types_to_download.Empty()) {
358 DCHECK(!restricted_routes.empty()); 344 DCHECK(!restricted_routes.empty());
359 linked_ptr<SyncSession> session(new SyncSession( 345 linked_ptr<SyncSession> session(new SyncSession(
360 session_context_, 346 session_context_,
361 this, 347 this,
362 SyncSourceInfo(params.source, 348 SyncSourceInfo(params.source,
363 ModelSafeRoutingInfoToStateMap( 349 ModelSafeRoutingInfoToStateMap(
364 restricted_routes, 350 restricted_routes,
365 std::string())), 351 std::string())),
366 restricted_routes, 352 restricted_routes,
367 restricted_workers)); 353 session_context_->workers()));
368 SyncSessionJob job(SyncSessionJob::CONFIGURATION, 354 SyncSessionJob job(SyncSessionJob::CONFIGURATION,
369 TimeTicks::Now(), 355 TimeTicks::Now(),
370 session, 356 session,
371 false, 357 false,
372 params, 358 params,
373 FROM_HERE); 359 FROM_HERE);
374 DoSyncSessionJob(job); 360 DoSyncSessionJob(job);
375 361
376 // If we failed, the job would have been saved as the pending configure 362 // If we failed, the job would have been saved as the pending configure
377 // job and a wait interval would have been set. 363 // job and a wait interval would have been set.
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1162
1177 #undef SDVLOG_LOC 1163 #undef SDVLOG_LOC
1178 1164
1179 #undef SDVLOG 1165 #undef SDVLOG
1180 1166
1181 #undef SLOG 1167 #undef SLOG
1182 1168
1183 #undef ENUM_CASE 1169 #undef ENUM_CASE
1184 1170
1185 } // namespace syncer 1171 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698