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

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

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 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/sync_scheduler.h ('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 10 matching lines...) Expand all
21 #include "sync/util/logging.h" 21 #include "sync/util/logging.h"
22 22
23 using base::TimeDelta; 23 using base::TimeDelta;
24 using base::TimeTicks; 24 using base::TimeTicks;
25 25
26 namespace syncer { 26 namespace syncer {
27 27
28 using sessions::SyncSession; 28 using sessions::SyncSession;
29 using sessions::SyncSessionSnapshot; 29 using sessions::SyncSessionSnapshot;
30 using sessions::SyncSourceInfo; 30 using sessions::SyncSourceInfo;
31 using syncable::ModelTypeSet;
32 using syncable::ModelTypeSetToString;
33 using syncable::ModelTypePayloadMap;
34 using sync_pb::GetUpdatesCallerInfo; 31 using sync_pb::GetUpdatesCallerInfo;
35 32
36 namespace { 33 namespace {
37 bool ShouldRequestEarlyExit( 34 bool ShouldRequestEarlyExit(
38 const syncer::SyncProtocolError& error) { 35 const syncer::SyncProtocolError& error) {
39 switch (error.error_type) { 36 switch (error.error_type) {
40 case syncer::SYNC_SUCCESS: 37 case syncer::SYNC_SUCCESS:
41 case syncer::MIGRATION_DONE: 38 case syncer::MIGRATION_DONE:
42 case syncer::THROTTLED: 39 case syncer::THROTTLED:
43 case syncer::TRANSIENT_ERROR: 40 case syncer::TRANSIENT_ERROR:
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return job.is_canary_job ? CONTINUE : SAVE; 314 return job.is_canary_job ? CONTINUE : SAVE;
318 } 315 }
319 316
320 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob( 317 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob(
321 const SyncSessionJob& job) { 318 const SyncSessionJob& job) {
322 DCHECK_EQ(MessageLoop::current(), sync_loop_); 319 DCHECK_EQ(MessageLoop::current(), sync_loop_);
323 if (job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES) 320 if (job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES)
324 return CONTINUE; 321 return CONTINUE;
325 322
326 // See if our type is throttled. 323 // See if our type is throttled.
327 syncable::ModelTypeSet throttled_types = 324 syncer::ModelTypeSet throttled_types =
328 session_context_->throttled_data_type_tracker()->GetThrottledTypes(); 325 session_context_->throttled_data_type_tracker()->GetThrottledTypes();
329 if (job.purpose == SyncSessionJob::NUDGE && 326 if (job.purpose == SyncSessionJob::NUDGE &&
330 job.session->source().updates_source == GetUpdatesCallerInfo::LOCAL) { 327 job.session->source().updates_source == GetUpdatesCallerInfo::LOCAL) {
331 syncable::ModelTypeSet requested_types; 328 syncer::ModelTypeSet requested_types;
332 for (ModelTypePayloadMap::const_iterator i = 329 for (ModelTypePayloadMap::const_iterator i =
333 job.session->source().types.begin(); 330 job.session->source().types.begin();
334 i != job.session->source().types.end(); 331 i != job.session->source().types.end();
335 ++i) { 332 ++i) {
336 requested_types.Put(i->first); 333 requested_types.Put(i->first);
337 } 334 }
338 335
339 if (!requested_types.Empty() && throttled_types.HasAll(requested_types)) 336 if (!requested_types.Empty() && throttled_types.HasAll(requested_types))
340 return SAVE; 337 return SAVE;
341 } 338 }
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 const TimeDelta& delay, 455 const TimeDelta& delay,
459 NudgeSource source, ModelTypeSet types, 456 NudgeSource source, ModelTypeSet types,
460 const tracked_objects::Location& nudge_location) { 457 const tracked_objects::Location& nudge_location) {
461 DCHECK_EQ(MessageLoop::current(), sync_loop_); 458 DCHECK_EQ(MessageLoop::current(), sync_loop_);
462 SDVLOG_LOC(nudge_location, 2) 459 SDVLOG_LOC(nudge_location, 2)
463 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " 460 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, "
464 << "source " << GetNudgeSourceString(source) << ", " 461 << "source " << GetNudgeSourceString(source) << ", "
465 << "types " << ModelTypeSetToString(types); 462 << "types " << ModelTypeSetToString(types);
466 463
467 ModelTypePayloadMap types_with_payloads = 464 ModelTypePayloadMap types_with_payloads =
468 syncable::ModelTypePayloadMapFromEnumSet(types, std::string()); 465 syncer::ModelTypePayloadMapFromEnumSet(types, std::string());
469 SyncScheduler::ScheduleNudgeImpl(delay, 466 SyncScheduler::ScheduleNudgeImpl(delay,
470 GetUpdatesFromNudgeSource(source), 467 GetUpdatesFromNudgeSource(source),
471 types_with_payloads, 468 types_with_payloads,
472 false, 469 false,
473 nudge_location); 470 nudge_location);
474 } 471 }
475 472
476 void SyncScheduler::ScheduleNudgeWithPayloadsAsync( 473 void SyncScheduler::ScheduleNudgeWithPayloadsAsync(
477 const TimeDelta& delay, 474 const TimeDelta& delay,
478 NudgeSource source, const ModelTypePayloadMap& types_with_payloads, 475 NudgeSource source, const ModelTypePayloadMap& types_with_payloads,
479 const tracked_objects::Location& nudge_location) { 476 const tracked_objects::Location& nudge_location) {
480 DCHECK_EQ(MessageLoop::current(), sync_loop_); 477 DCHECK_EQ(MessageLoop::current(), sync_loop_);
481 SDVLOG_LOC(nudge_location, 2) 478 SDVLOG_LOC(nudge_location, 2)
482 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " 479 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, "
483 << "source " << GetNudgeSourceString(source) << ", " 480 << "source " << GetNudgeSourceString(source) << ", "
484 << "payloads " 481 << "payloads "
485 << syncable::ModelTypePayloadMapToString(types_with_payloads); 482 << syncer::ModelTypePayloadMapToString(types_with_payloads);
486 483
487 SyncScheduler::ScheduleNudgeImpl(delay, 484 SyncScheduler::ScheduleNudgeImpl(delay,
488 GetUpdatesFromNudgeSource(source), 485 GetUpdatesFromNudgeSource(source),
489 types_with_payloads, 486 types_with_payloads,
490 false, 487 false,
491 nudge_location); 488 nudge_location);
492 } 489 }
493 490
494 void SyncScheduler::ScheduleNudgeImpl( 491 void SyncScheduler::ScheduleNudgeImpl(
495 const TimeDelta& delay, 492 const TimeDelta& delay,
496 GetUpdatesCallerInfo::GetUpdatesSource source, 493 GetUpdatesCallerInfo::GetUpdatesSource source,
497 const ModelTypePayloadMap& types_with_payloads, 494 const ModelTypePayloadMap& types_with_payloads,
498 bool is_canary_job, const tracked_objects::Location& nudge_location) { 495 bool is_canary_job, const tracked_objects::Location& nudge_location) {
499 DCHECK_EQ(MessageLoop::current(), sync_loop_); 496 DCHECK_EQ(MessageLoop::current(), sync_loop_);
500 497
501 SDVLOG_LOC(nudge_location, 2) 498 SDVLOG_LOC(nudge_location, 2)
502 << "In ScheduleNudgeImpl with delay " 499 << "In ScheduleNudgeImpl with delay "
503 << delay.InMilliseconds() << " ms, " 500 << delay.InMilliseconds() << " ms, "
504 << "source " << GetUpdatesSourceString(source) << ", " 501 << "source " << GetUpdatesSourceString(source) << ", "
505 << "payloads " 502 << "payloads "
506 << syncable::ModelTypePayloadMapToString(types_with_payloads) 503 << syncer::ModelTypePayloadMapToString(types_with_payloads)
507 << (is_canary_job ? " (canary)" : ""); 504 << (is_canary_job ? " (canary)" : "");
508 505
509 SyncSourceInfo info(source, types_with_payloads); 506 SyncSourceInfo info(source, types_with_payloads);
510 507
511 SyncSession* session(CreateSyncSession(info)); 508 SyncSession* session(CreateSyncSession(info));
512 SyncSessionJob job(SyncSessionJob::NUDGE, TimeTicks::Now() + delay, 509 SyncSessionJob job(SyncSessionJob::NUDGE, TimeTicks::Now() + delay,
513 make_linked_ptr(session), is_canary_job, 510 make_linked_ptr(session), is_canary_job,
514 nudge_location); 511 nudge_location);
515 512
516 session = NULL; 513 session = NULL;
(...skipping 30 matching lines...) Expand all
547 void GetModelSafeParamsForTypes(ModelTypeSet types, 544 void GetModelSafeParamsForTypes(ModelTypeSet types,
548 const ModelSafeRoutingInfo& current_routes, 545 const ModelSafeRoutingInfo& current_routes,
549 const std::vector<ModelSafeWorker*>& current_workers, 546 const std::vector<ModelSafeWorker*>& current_workers,
550 ModelSafeRoutingInfo* result_routes, 547 ModelSafeRoutingInfo* result_routes,
551 std::vector<ModelSafeWorker*>* result_workers) { 548 std::vector<ModelSafeWorker*>* result_workers) {
552 bool passive_group_added = false; 549 bool passive_group_added = false;
553 550
554 typedef std::vector<ModelSafeWorker*>::const_iterator iter; 551 typedef std::vector<ModelSafeWorker*>::const_iterator iter;
555 for (ModelTypeSet::Iterator it = types.First(); 552 for (ModelTypeSet::Iterator it = types.First();
556 it.Good(); it.Inc()) { 553 it.Good(); it.Inc()) {
557 const syncable::ModelType t = it.Get(); 554 const syncer::ModelType t = it.Get();
558 ModelSafeRoutingInfo::const_iterator route = current_routes.find(t); 555 ModelSafeRoutingInfo::const_iterator route = current_routes.find(t);
559 DCHECK(route != current_routes.end()); 556 DCHECK(route != current_routes.end());
560 ModelSafeGroup group = route->second; 557 ModelSafeGroup group = route->second;
561 558
562 (*result_routes)[t] = group; 559 (*result_routes)[t] = group;
563 iter w_tmp_it = std::find_if(current_workers.begin(), current_workers.end(), 560 iter w_tmp_it = std::find_if(current_workers.begin(), current_workers.end(),
564 ModelSafeWorkerGroupIs(group)); 561 ModelSafeWorkerGroupIs(group));
565 if (w_tmp_it != current_workers.end()) { 562 if (w_tmp_it != current_workers.end()) {
566 iter result_workers_it = std::find_if( 563 iter result_workers_it = std::find_if(
567 result_workers->begin(), result_workers->end(), 564 result_workers->begin(), result_workers->end(),
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 1131
1135 #undef SDVLOG_LOC 1132 #undef SDVLOG_LOC
1136 1133
1137 #undef SDVLOG 1134 #undef SDVLOG
1138 1135
1139 #undef SLOG 1136 #undef SLOG
1140 1137
1141 #undef ENUM_CASE 1138 #undef ENUM_CASE
1142 1139
1143 } // namespace syncer 1140 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler.h ('k') | sync/engine/sync_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698