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

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: Removed variable active_groups that was no longer needed. 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;
312 active_groups.insert(GROUP_PASSIVE);
313 for (ModelTypeSet::Iterator iter = types_to_download.First(); iter.Good(); 309 for (ModelTypeSet::Iterator iter = types_to_download.First(); iter.Good();
314 iter.Inc()) { 310 iter.Inc()) {
315 ModelType type = iter.Get(); 311 ModelType type = iter.Get();
316 ModelSafeRoutingInfo::const_iterator route = current_routes.find(type); 312 ModelSafeRoutingInfo::const_iterator route = current_routes.find(type);
317 DCHECK(route != current_routes.end()); 313 DCHECK(route != current_routes.end());
318 ModelSafeGroup group = route->second; 314 ModelSafeGroup group = route->second;
319 (*result_routes)[type] = group; 315 (*result_routes)[type] = group;
320 active_groups.insert(group);
321 }
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 } 316 }
328 } 317 }
329 318
330 } // namespace. 319 } // namespace.
331 320
332 bool SyncSchedulerImpl::ScheduleConfiguration( 321 bool SyncSchedulerImpl::ScheduleConfiguration(
333 const ConfigurationParams& params) { 322 const ConfigurationParams& params) {
334 DCHECK_EQ(MessageLoop::current(), sync_loop_); 323 DCHECK_EQ(MessageLoop::current(), sync_loop_);
335 DCHECK(IsConfigRelatedUpdateSourceValue(params.source)); 324 DCHECK(IsConfigRelatedUpdateSourceValue(params.source));
336 DCHECK_EQ(CONFIGURATION_MODE, mode_); 325 DCHECK_EQ(CONFIGURATION_MODE, mode_);
337 DCHECK(!params.ready_task.is_null()); 326 DCHECK(!params.ready_task.is_null());
338 SDVLOG(2) << "Reconfiguring syncer."; 327 SDVLOG(2) << "Reconfiguring syncer.";
339 328
340 // Only one configuration is allowed at a time. Verify we're not waiting 329 // Only one configuration is allowed at a time. Verify we're not waiting
341 // for a pending configure job. 330 // for a pending configure job.
342 DCHECK(!wait_interval_.get() || !wait_interval_->pending_configure_job.get()); 331 DCHECK(!wait_interval_.get() || !wait_interval_->pending_configure_job.get());
343 332
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; 333 ModelSafeRoutingInfo restricted_routes;
348 std::vector<ModelSafeWorker*> restricted_workers;
349 BuildModelSafeParams(params.types_to_download, 334 BuildModelSafeParams(params.types_to_download,
350 params.routing_info, 335 params.routing_info,
351 session_context_->workers(), 336 &restricted_routes);
352 &restricted_routes,
353 &restricted_workers);
354 session_context_->set_routing_info(params.routing_info); 337 session_context_->set_routing_info(params.routing_info);
355 338
356 // Only reconfigure if we have types to download. 339 // Only reconfigure if we have types to download.
357 if (!params.types_to_download.Empty()) { 340 if (!params.types_to_download.Empty()) {
358 DCHECK(!restricted_routes.empty()); 341 DCHECK(!restricted_routes.empty());
359 linked_ptr<SyncSession> session(new SyncSession( 342 linked_ptr<SyncSession> session(new SyncSession(
360 session_context_, 343 session_context_,
361 this, 344 this,
362 SyncSourceInfo(params.source, 345 SyncSourceInfo(params.source,
363 ModelSafeRoutingInfoToStateMap( 346 ModelSafeRoutingInfoToStateMap(
364 restricted_routes, 347 restricted_routes,
365 std::string())), 348 std::string())),
366 restricted_routes, 349 restricted_routes,
367 restricted_workers)); 350 session_context_->workers()));
368 SyncSessionJob job(SyncSessionJob::CONFIGURATION, 351 SyncSessionJob job(SyncSessionJob::CONFIGURATION,
369 TimeTicks::Now(), 352 TimeTicks::Now(),
370 session, 353 session,
371 false, 354 false,
372 params, 355 params,
373 FROM_HERE); 356 FROM_HERE);
374 DoSyncSessionJob(job); 357 DoSyncSessionJob(job);
375 358
376 // If we failed, the job would have been saved as the pending configure 359 // If we failed, the job would have been saved as the pending configure
377 // job and a wait interval would have been set. 360 // job and a wait interval would have been set.
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1159
1177 #undef SDVLOG_LOC 1160 #undef SDVLOG_LOC
1178 1161
1179 #undef SDVLOG 1162 #undef SDVLOG
1180 1163
1181 #undef SLOG 1164 #undef SLOG
1182 1165
1183 #undef ENUM_CASE 1166 #undef ENUM_CASE
1184 1167
1185 } // namespace syncer 1168 } // 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