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

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

Issue 10559104: sync: Process 'control' data separately (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename, cleanup, fix tests Created 8 years, 6 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/engine/resolve_conflicts_command.cc ('k') | sync/engine/sync_scheduler_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 (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.h" 5 #include "sync/engine/sync_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 } 543 }
544 544
545 // Helper to extract the routing info and workers corresponding to types in 545 // Helper to extract the routing info and workers corresponding to types in
546 // |types| from |current_routes| and |current_workers|. 546 // |types| from |current_routes| and |current_workers|.
547 void GetModelSafeParamsForTypes(ModelTypeSet types, 547 void GetModelSafeParamsForTypes(ModelTypeSet types,
548 const ModelSafeRoutingInfo& current_routes, 548 const ModelSafeRoutingInfo& current_routes,
549 const std::vector<ModelSafeWorker*>& current_workers, 549 const std::vector<ModelSafeWorker*>& current_workers,
550 ModelSafeRoutingInfo* result_routes, 550 ModelSafeRoutingInfo* result_routes,
551 std::vector<ModelSafeWorker*>* result_workers) { 551 std::vector<ModelSafeWorker*>* result_workers) {
552 bool passive_group_added = false; 552 bool passive_group_added = false;
553 bool control_group_added = false;
553 554
554 typedef std::vector<ModelSafeWorker*>::const_iterator iter; 555 typedef std::vector<ModelSafeWorker*>::const_iterator iter;
555 for (ModelTypeSet::Iterator it = types.First(); 556 for (ModelTypeSet::Iterator it = types.First();
556 it.Good(); it.Inc()) { 557 it.Good(); it.Inc()) {
557 const syncable::ModelType t = it.Get(); 558 const syncable::ModelType t = it.Get();
558 ModelSafeRoutingInfo::const_iterator route = current_routes.find(t); 559 ModelSafeRoutingInfo::const_iterator route = current_routes.find(t);
559 DCHECK(route != current_routes.end()); 560 DCHECK(route != current_routes.end());
560 ModelSafeGroup group = route->second; 561 ModelSafeGroup group = route->second;
561 562
562 (*result_routes)[t] = group; 563 (*result_routes)[t] = group;
563 iter w_tmp_it = std::find_if(current_workers.begin(), current_workers.end(), 564 iter w_tmp_it = std::find_if(current_workers.begin(), current_workers.end(),
564 ModelSafeWorkerGroupIs(group)); 565 ModelSafeWorkerGroupIs(group));
565 if (w_tmp_it != current_workers.end()) { 566 if (w_tmp_it != current_workers.end()) {
566 iter result_workers_it = std::find_if( 567 iter result_workers_it = std::find_if(
567 result_workers->begin(), result_workers->end(), 568 result_workers->begin(), result_workers->end(),
568 ModelSafeWorkerGroupIs(group)); 569 ModelSafeWorkerGroupIs(group));
569 if (result_workers_it == result_workers->end()) 570 if (result_workers_it == result_workers->end())
570 result_workers->push_back(*w_tmp_it); 571 result_workers->push_back(*w_tmp_it);
571 572
572 if (group == GROUP_PASSIVE) 573 if (group == GROUP_PASSIVE)
573 passive_group_added = true; 574 passive_group_added = true;
575 if (group == GROUP_CONTROL)
576 control_group_added = true;
574 } else { 577 } else {
575 NOTREACHED(); 578 NOTREACHED();
576 } 579 }
577 } 580 }
578 581
579 // Always add group passive. 582 // Always add group passive.
580 if (passive_group_added == false) { 583 if (passive_group_added == false) {
581 iter it = std::find_if(current_workers.begin(), current_workers.end(), 584 iter it = std::find_if(current_workers.begin(), current_workers.end(),
582 ModelSafeWorkerGroupIs(GROUP_PASSIVE)); 585 ModelSafeWorkerGroupIs(GROUP_PASSIVE));
583 if (it != current_workers.end()) 586 if (it != current_workers.end())
584 result_workers->push_back(*it); 587 result_workers->push_back(*it);
585 else 588 else
586 NOTREACHED(); 589 NOTREACHED();
587 } 590 }
591 if (control_group_added == false) {
592 iter it = std::find_if(current_workers.begin(), current_workers.end(),
593 ModelSafeWorkerGroupIs(GROUP_CONTROL));
594 if (it != current_workers.end())
595 result_workers->push_back(*it);
596 else
597 NOTREACHED();
598 }
588 } 599 }
589 600
590 void SyncScheduler::ScheduleConfiguration( 601 void SyncScheduler::ScheduleConfiguration(
591 ModelTypeSet types, 602 ModelTypeSet types,
592 GetUpdatesCallerInfo::GetUpdatesSource source) { 603 GetUpdatesCallerInfo::GetUpdatesSource source) {
593 DCHECK_EQ(MessageLoop::current(), sync_loop_); 604 DCHECK_EQ(MessageLoop::current(), sync_loop_);
594 DCHECK(IsConfigRelatedUpdateSourceValue(source)); 605 DCHECK(IsConfigRelatedUpdateSourceValue(source));
595 SDVLOG(2) << "Scheduling a config"; 606 SDVLOG(2) << "Scheduling a config";
596 607
597 ModelSafeRoutingInfo routes; 608 ModelSafeRoutingInfo routes;
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 1145
1135 #undef SDVLOG_LOC 1146 #undef SDVLOG_LOC
1136 1147
1137 #undef SDVLOG 1148 #undef SDVLOG
1138 1149
1139 #undef SLOG 1150 #undef SLOG
1140 1151
1141 #undef ENUM_CASE 1152 #undef ENUM_CASE
1142 1153
1143 } // csync 1154 } // csync
OLDNEW
« no previous file with comments | « sync/engine/resolve_conflicts_command.cc ('k') | sync/engine/sync_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698