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

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

Issue 19982002: sync: Remove SyncSourceInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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
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 10 matching lines...) Expand all
21 #include "sync/util/data_type_histogram.h" 21 #include "sync/util/data_type_histogram.h"
22 #include "sync/util/logging.h" 22 #include "sync/util/logging.h"
23 23
24 using base::TimeDelta; 24 using base::TimeDelta;
25 using base::TimeTicks; 25 using base::TimeTicks;
26 26
27 namespace syncer { 27 namespace syncer {
28 28
29 using sessions::SyncSession; 29 using sessions::SyncSession;
30 using sessions::SyncSessionSnapshot; 30 using sessions::SyncSessionSnapshot;
31 using sessions::SyncSourceInfo;
32 using sync_pb::GetUpdatesCallerInfo; 31 using sync_pb::GetUpdatesCallerInfo;
33 32
34 namespace { 33 namespace {
35 34
36 bool ShouldRequestEarlyExit(const SyncProtocolError& error) { 35 bool ShouldRequestEarlyExit(const SyncProtocolError& error) {
37 switch (error.error_type) { 36 switch (error.error_type) {
38 case SYNC_SUCCESS: 37 case SYNC_SUCCESS:
39 case MIGRATION_DONE: 38 case MIGRATION_DONE:
40 case THROTTLED: 39 case THROTTLED:
41 case TRANSIENT_ERROR: 40 case TRANSIENT_ERROR:
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 ModelTypeSet SyncSchedulerImpl::GetEnabledAndUnthrottledTypes() { 240 ModelTypeSet SyncSchedulerImpl::GetEnabledAndUnthrottledTypes() {
242 ModelTypeSet enabled_types = 241 ModelTypeSet enabled_types =
243 GetRoutingInfoTypes(session_context_->routing_info()); 242 GetRoutingInfoTypes(session_context_->routing_info());
244 ModelTypeSet throttled_types = 243 ModelTypeSet throttled_types =
245 nudge_tracker_.GetThrottledTypes(); 244 nudge_tracker_.GetThrottledTypes();
246 return Difference(enabled_types, throttled_types); 245 return Difference(enabled_types, throttled_types);
247 } 246 }
248 247
249 void SyncSchedulerImpl::SendInitialSnapshot() { 248 void SyncSchedulerImpl::SendInitialSnapshot() {
250 DCHECK(CalledOnValidThread()); 249 DCHECK(CalledOnValidThread());
251 scoped_ptr<SyncSession> dummy( 250 scoped_ptr<SyncSession> dummy(SyncSession::Build(session_context_, this));
252 SyncSession::Build(session_context_, this, SyncSourceInfo()));
253 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); 251 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED);
254 event.snapshot = dummy->TakeSnapshot(); 252 event.snapshot = dummy->TakeSnapshot();
255 session_context_->NotifyListeners(event); 253 session_context_->NotifyListeners(event);
256 } 254 }
257 255
258 namespace { 256 namespace {
259 257
260 // Helper to extract the routing info corresponding to types in 258 // Helper to extract the routing info corresponding to types in
261 // |types_to_download| from |current_routes|. 259 // |types_to_download| from |current_routes|.
262 void BuildModelSafeParams( 260 void BuildModelSafeParams(
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 460 }
463 return ""; 461 return "";
464 } 462 }
465 463
466 void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) { 464 void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) {
467 DCHECK(CalledOnValidThread()); 465 DCHECK(CalledOnValidThread());
468 DCHECK(CanRunNudgeJobNow(priority)); 466 DCHECK(CanRunNudgeJobNow(priority));
469 467
470 DVLOG(2) << "Will run normal mode sync cycle with routing info " 468 DVLOG(2) << "Will run normal mode sync cycle with routing info "
471 << ModelSafeRoutingInfoToString(session_context_->routing_info()); 469 << ModelSafeRoutingInfoToString(session_context_->routing_info());
472 scoped_ptr<SyncSession> session( 470 scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this));
473 SyncSession::Build(
474 session_context_,
475 this,
476 nudge_tracker_.GetSourceInfo()));
477 bool premature_exit = !syncer_->NormalSyncShare( 471 bool premature_exit = !syncer_->NormalSyncShare(
478 GetEnabledAndUnthrottledTypes(), 472 GetEnabledAndUnthrottledTypes(),
479 nudge_tracker_, 473 nudge_tracker_,
480 session.get()); 474 session.get());
481 AdjustPolling(FORCE_RESET); 475 AdjustPolling(FORCE_RESET);
482 // Don't run poll job till the next time poll timer fires. 476 // Don't run poll job till the next time poll timer fires.
483 do_poll_after_credentials_updated_ = false; 477 do_poll_after_credentials_updated_ = false;
484 478
485 bool success = !premature_exit 479 bool success = !premature_exit
486 && !sessions::HasSyncerError( 480 && !sessions::HasSyncerError(
(...skipping 18 matching lines...) Expand all
505 DCHECK(CalledOnValidThread()); 499 DCHECK(CalledOnValidThread());
506 DCHECK_EQ(mode_, CONFIGURATION_MODE); 500 DCHECK_EQ(mode_, CONFIGURATION_MODE);
507 501
508 if (!CanRunJobNow(priority)) { 502 if (!CanRunJobNow(priority)) {
509 SDVLOG(2) << "Unable to run configure job right now."; 503 SDVLOG(2) << "Unable to run configure job right now.";
510 return false; 504 return false;
511 } 505 }
512 506
513 SDVLOG(2) << "Will run configure SyncShare with routes " 507 SDVLOG(2) << "Will run configure SyncShare with routes "
514 << ModelSafeRoutingInfoToString(session_context_->routing_info()); 508 << ModelSafeRoutingInfoToString(session_context_->routing_info());
515 SyncSourceInfo source_info(pending_configure_params_->source, 509 scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this));
516 ModelSafeRoutingInfoToInvalidationMap(
517 session_context_->routing_info(),
518 std::string()));
519 scoped_ptr<SyncSession> session(
520 SyncSession::Build(session_context_, this, source_info));
521 bool premature_exit = !syncer_->ConfigureSyncShare( 510 bool premature_exit = !syncer_->ConfigureSyncShare(
522 GetRoutingInfoTypes(session_context_->routing_info()), 511 GetRoutingInfoTypes(session_context_->routing_info()),
512 pending_configure_params_->source,
523 session.get()); 513 session.get());
524 AdjustPolling(FORCE_RESET); 514 AdjustPolling(FORCE_RESET);
525 // Don't run poll job till the next time poll timer fires. 515 // Don't run poll job till the next time poll timer fires.
526 do_poll_after_credentials_updated_ = false; 516 do_poll_after_credentials_updated_ = false;
527 517
528 bool success = !premature_exit 518 bool success = !premature_exit
529 && !sessions::HasSyncerError( 519 && !sessions::HasSyncerError(
530 session->status_controller().model_neutral_state()); 520 session->status_controller().model_neutral_state());
531 521
532 if (success) { 522 if (success) {
(...skipping 25 matching lines...) Expand all
558 SDVLOG(2) << "Sync cycle failed. Will back off for " 548 SDVLOG(2) << "Sync cycle failed. Will back off for "
559 << wait_interval_->length.InMilliseconds() << "ms."; 549 << wait_interval_->length.InMilliseconds() << "ms.";
560 RestartWaiting(); 550 RestartWaiting();
561 } 551 }
562 } 552 }
563 553
564 void SyncSchedulerImpl::DoPollSyncSessionJob() { 554 void SyncSchedulerImpl::DoPollSyncSessionJob() {
565 ModelSafeRoutingInfo r; 555 ModelSafeRoutingInfo r;
566 ModelTypeInvalidationMap invalidation_map = 556 ModelTypeInvalidationMap invalidation_map =
567 ModelSafeRoutingInfoToInvalidationMap(r, std::string()); 557 ModelSafeRoutingInfoToInvalidationMap(r, std::string());
568 SyncSourceInfo info(GetUpdatesCallerInfo::PERIODIC, invalidation_map);
569 base::AutoReset<bool> protector(&no_scheduling_allowed_, true); 558 base::AutoReset<bool> protector(&no_scheduling_allowed_, true);
570 559
571 if (!CanRunJobNow(NORMAL_PRIORITY)) { 560 if (!CanRunJobNow(NORMAL_PRIORITY)) {
572 SDVLOG(2) << "Unable to run a poll job right now."; 561 SDVLOG(2) << "Unable to run a poll job right now.";
573 return; 562 return;
574 } 563 }
575 564
576 if (mode_ != NORMAL_MODE) { 565 if (mode_ != NORMAL_MODE) {
577 SDVLOG(2) << "Not running poll job in configure mode."; 566 SDVLOG(2) << "Not running poll job in configure mode.";
578 return; 567 return;
579 } 568 }
580 569
581 SDVLOG(2) << "Polling with routes " 570 SDVLOG(2) << "Polling with routes "
582 << ModelSafeRoutingInfoToString(session_context_->routing_info()); 571 << ModelSafeRoutingInfoToString(session_context_->routing_info());
583 scoped_ptr<SyncSession> session( 572 scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this));
584 SyncSession::Build(session_context_, this, info));
585 syncer_->PollSyncShare( 573 syncer_->PollSyncShare(
586 GetEnabledAndUnthrottledTypes(), 574 GetEnabledAndUnthrottledTypes(),
587 session.get()); 575 session.get());
588 576
589 AdjustPolling(UPDATE_INTERVAL); 577 AdjustPolling(UPDATE_INTERVAL);
590 578
591 if (IsCurrentlyThrottled()) { 579 if (IsCurrentlyThrottled()) {
592 SDVLOG(2) << "Poll request got us throttled."; 580 SDVLOG(2) << "Poll request got us throttled.";
593 // The OnSilencedUntil() call set up the WaitInterval for us. All we need 581 // The OnSilencedUntil() call set up the WaitInterval for us. All we need
594 // to do is start the timer. 582 // to do is start the timer.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 906
919 #undef SDVLOG_LOC 907 #undef SDVLOG_LOC
920 908
921 #undef SDVLOG 909 #undef SDVLOG
922 910
923 #undef SLOG 911 #undef SLOG
924 912
925 #undef ENUM_CASE 913 #undef ENUM_CASE
926 914
927 } // namespace syncer 915 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698