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

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

Issue 7545012: Merge 94530 - [Sync] Add RequestCleanupDisabledTypes() method to SyncManager (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/engine/sync_scheduler.h" 5 #include "chrome/browser/sync/engine/sync_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/tracked.h" 14 #include "base/tracked.h"
15 #include "chrome/browser/sync/engine/syncer.h" 15 #include "chrome/browser/sync/engine/syncer.h"
16 #include "chrome/browser/sync/protocol/sync.pb.h"
16 #include "chrome/browser/sync/protocol/proto_enum_conversions.h" 17 #include "chrome/browser/sync/protocol/proto_enum_conversions.h"
17 #include "chrome/browser/sync/util/logging.h" 18 #include "chrome/browser/sync/util/logging.h"
18 19
19 using base::TimeDelta; 20 using base::TimeDelta;
20 using base::TimeTicks; 21 using base::TimeTicks;
21 22
22 namespace browser_sync { 23 namespace browser_sync {
23 24
24 using sessions::SyncSession; 25 using sessions::SyncSession;
25 using sessions::SyncSessionSnapshot; 26 using sessions::SyncSessionSnapshot;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 69 }
69 70
70 const char* SyncScheduler::SyncSessionJob::GetPurposeString( 71 const char* SyncScheduler::SyncSessionJob::GetPurposeString(
71 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { 72 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) {
72 switch (purpose) { 73 switch (purpose) {
73 ENUM_CASE(UNKNOWN); 74 ENUM_CASE(UNKNOWN);
74 ENUM_CASE(POLL); 75 ENUM_CASE(POLL);
75 ENUM_CASE(NUDGE); 76 ENUM_CASE(NUDGE);
76 ENUM_CASE(CLEAR_USER_DATA); 77 ENUM_CASE(CLEAR_USER_DATA);
77 ENUM_CASE(CONFIGURATION); 78 ENUM_CASE(CONFIGURATION);
79 ENUM_CASE(CLEANUP_DISABLED_TYPES);
78 } 80 }
79 NOTREACHED(); 81 NOTREACHED();
80 return ""; 82 return "";
81 } 83 }
82 84
83 TimeDelta SyncScheduler::DelayProvider::GetDelay( 85 TimeDelta SyncScheduler::DelayProvider::GetDelay(
84 const base::TimeDelta& last_delay) { 86 const base::TimeDelta& last_delay) {
85 return SyncScheduler::GetRecommendedDelay(last_delay); 87 return SyncScheduler::GetRecommendedDelay(last_delay);
86 } 88 }
87 89
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // We just changed our mode. See if there are any pending jobs that we could 247 // We just changed our mode. See if there are any pending jobs that we could
246 // execute in the new mode. 248 // execute in the new mode.
247 DoPendingJobIfPossible(false); 249 DoPendingJobIfPossible(false);
248 } 250 }
249 251
250 SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval( 252 SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval(
251 const SyncSessionJob& job) { 253 const SyncSessionJob& job) {
252 DCHECK_EQ(MessageLoop::current(), sync_loop_); 254 DCHECK_EQ(MessageLoop::current(), sync_loop_);
253 DCHECK(wait_interval_.get()); 255 DCHECK(wait_interval_.get());
254 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA); 256 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA);
257 DCHECK_NE(job.purpose, SyncSessionJob::CLEANUP_DISABLED_TYPES);
255 258
256 SVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " 259 SVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode "
257 << WaitInterval::GetModeString(wait_interval_->mode) 260 << WaitInterval::GetModeString(wait_interval_->mode)
258 << (wait_interval_->had_nudge ? " (had nudge)" : "") 261 << (wait_interval_->had_nudge ? " (had nudge)" : "")
259 << (job.is_canary_job ? " (canary)" : ""); 262 << (job.is_canary_job ? " (canary)" : "");
260 263
261 if (job.purpose == SyncSessionJob::POLL) 264 if (job.purpose == SyncSessionJob::POLL)
262 return DROP; 265 return DROP;
263 266
264 DCHECK(job.purpose == SyncSessionJob::NUDGE || 267 DCHECK(job.purpose == SyncSessionJob::NUDGE ||
265 job.purpose == SyncSessionJob::CONFIGURATION); 268 job.purpose == SyncSessionJob::CONFIGURATION);
266 if (wait_interval_->mode == WaitInterval::THROTTLED) 269 if (wait_interval_->mode == WaitInterval::THROTTLED)
267 return SAVE; 270 return SAVE;
268 271
269 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF); 272 DCHECK_EQ(wait_interval_->mode, WaitInterval::EXPONENTIAL_BACKOFF);
270 if (job.purpose == SyncSessionJob::NUDGE) { 273 if (job.purpose == SyncSessionJob::NUDGE) {
271 if (mode_ == CONFIGURATION_MODE) 274 if (mode_ == CONFIGURATION_MODE)
272 return SAVE; 275 return SAVE;
273 276
274 // If we already had one nudge then just drop this nudge. We will retry 277 // If we already had one nudge then just drop this nudge. We will retry
275 // later when the timer runs out. 278 // later when the timer runs out.
276 return wait_interval_->had_nudge ? DROP : CONTINUE; 279 return wait_interval_->had_nudge ? DROP : CONTINUE;
277 } 280 }
278 // This is a config job. 281 // This is a config job.
279 return job.is_canary_job ? CONTINUE : SAVE; 282 return job.is_canary_job ? CONTINUE : SAVE;
280 } 283 }
281 284
282 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob( 285 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob(
283 const SyncSessionJob& job) { 286 const SyncSessionJob& job) {
284 DCHECK_EQ(MessageLoop::current(), sync_loop_); 287 DCHECK_EQ(MessageLoop::current(), sync_loop_);
285 if (job.purpose == SyncSessionJob::CLEAR_USER_DATA) 288 if (job.purpose == SyncSessionJob::CLEAR_USER_DATA ||
289 job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES)
286 return CONTINUE; 290 return CONTINUE;
287 291
288 if (wait_interval_.get()) 292 if (wait_interval_.get())
289 return DecideWhileInWaitInterval(job); 293 return DecideWhileInWaitInterval(job);
290 294
291 if (mode_ == CONFIGURATION_MODE) { 295 if (mode_ == CONFIGURATION_MODE) {
292 if (job.purpose == SyncSessionJob::NUDGE) 296 if (job.purpose == SyncSessionJob::NUDGE)
293 return SAVE; 297 return SAVE;
294 else if (job.purpose == SyncSessionJob::CONFIGURATION) 298 else if (job.purpose == SyncSessionJob::CONFIGURATION)
295 return CONTINUE; 299 return CONTINUE;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 354
351 DCHECK(job.purpose == SyncSessionJob::NUDGE || job.purpose == 355 DCHECK(job.purpose == SyncSessionJob::NUDGE || job.purpose ==
352 SyncSessionJob::CONFIGURATION); 356 SyncSessionJob::CONFIGURATION);
353 357
354 SaveJob(job); 358 SaveJob(job);
355 return false; 359 return false;
356 } 360 }
357 361
358 void SyncScheduler::SaveJob(const SyncSessionJob& job) { 362 void SyncScheduler::SaveJob(const SyncSessionJob& job) {
359 DCHECK_EQ(MessageLoop::current(), sync_loop_); 363 DCHECK_EQ(MessageLoop::current(), sync_loop_);
360 DCHECK(job.purpose != SyncSessionJob::CLEAR_USER_DATA); 364 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA);
365 // TODO(sync): Should we also check that job.purpose !=
366 // CLEANUP_DISABLED_TYPES? (See http://crbug.com/90868.)
361 if (job.purpose == SyncSessionJob::NUDGE) { 367 if (job.purpose == SyncSessionJob::NUDGE) {
362 SVLOG(2) << "Saving a nudge job"; 368 SVLOG(2) << "Saving a nudge job";
363 InitOrCoalescePendingJob(job); 369 InitOrCoalescePendingJob(job);
364 } else if (job.purpose == SyncSessionJob::CONFIGURATION){ 370 } else if (job.purpose == SyncSessionJob::CONFIGURATION){
365 SVLOG(2) << "Saving a configuration job"; 371 SVLOG(2) << "Saving a configuration job";
366 DCHECK(wait_interval_.get()); 372 DCHECK(wait_interval_.get());
367 DCHECK(mode_ == CONFIGURATION_MODE); 373 DCHECK(mode_ == CONFIGURATION_MODE);
368 374
369 SyncSession* old = job.session.get(); 375 SyncSession* old = job.session.get();
370 SyncSession* s(new SyncSession(session_context_.get(), this, 376 SyncSession* s(new SyncSession(session_context_.get(), this,
371 old->source(), old->routing_info(), old->workers())); 377 old->source(), old->routing_info(), old->workers()));
372 SyncSessionJob new_job(job.purpose, TimeTicks::Now(), 378 SyncSessionJob new_job(job.purpose, TimeTicks::Now(),
373 make_linked_ptr(s), false, job.from_here); 379 make_linked_ptr(s), false, job.from_here);
374 wait_interval_->pending_configure_job.reset(new SyncSessionJob(new_job)); 380 wait_interval_->pending_configure_job.reset(new SyncSessionJob(new_job));
375 } // drop the rest. 381 } // drop the rest.
382 // TODO(sync): Is it okay to drop the rest? It's weird that
383 // SaveJob() only does what it says sometimes. (See
384 // http://crbug.com/90868.)
376 } 385 }
377 386
378 // Functor for std::find_if to search by ModelSafeGroup. 387 // Functor for std::find_if to search by ModelSafeGroup.
379 struct ModelSafeWorkerGroupIs { 388 struct ModelSafeWorkerGroupIs {
380 explicit ModelSafeWorkerGroupIs(ModelSafeGroup group) : group(group) {} 389 explicit ModelSafeWorkerGroupIs(ModelSafeGroup group) : group(group) {}
381 bool operator()(ModelSafeWorker* w) { 390 bool operator()(ModelSafeWorker* w) {
382 return group == w->GetModelSafeGroup(); 391 return group == w->GetModelSafeGroup();
383 } 392 }
384 ModelSafeGroup group; 393 ModelSafeGroup group;
385 }; 394 };
386 395
387 void SyncScheduler::ScheduleClearUserData() { 396 void SyncScheduler::ScheduleClearUserData() {
388 DCHECK_EQ(MessageLoop::current(), sync_loop_); 397 DCHECK_EQ(MessageLoop::current(), sync_loop_);
389 PostTask(FROM_HERE, "ScheduleClearUserDataImpl", 398 PostTask(FROM_HERE, "ScheduleClearUserDataImpl",
390 method_factory_.NewRunnableMethod( 399 method_factory_.NewRunnableMethod(
391 &SyncScheduler::ScheduleClearUserDataImpl)); 400 &SyncScheduler::ScheduleClearUserDataImpl));
392 } 401 }
393 402
403 void SyncScheduler::ScheduleCleanupDisabledTypes() {
404 DCHECK_EQ(MessageLoop::current(), sync_loop_);
405 PostTask(FROM_HERE, "ScheduleCleanupDisabledTypes",
406 method_factory_.NewRunnableMethod(
407 &SyncScheduler::ScheduleCleanupDisabledTypesImpl));
408 }
409
394 void SyncScheduler::ScheduleNudge( 410 void SyncScheduler::ScheduleNudge(
395 const TimeDelta& delay, 411 const TimeDelta& delay,
396 NudgeSource source, const ModelTypeBitSet& types, 412 NudgeSource source, const ModelTypeBitSet& types,
397 const tracked_objects::Location& nudge_location) { 413 const tracked_objects::Location& nudge_location) {
398 DCHECK_EQ(MessageLoop::current(), sync_loop_); 414 DCHECK_EQ(MessageLoop::current(), sync_loop_);
399 SVLOG_LOC(nudge_location, 2) 415 SVLOG_LOC(nudge_location, 2)
400 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " 416 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, "
401 << "source " << GetNudgeSourceString(source) << ", " 417 << "source " << GetNudgeSourceString(source) << ", "
402 << "types " << syncable::ModelTypeBitSetToString(types); 418 << "types " << syncable::ModelTypeBitSetToString(types);
403 419
(...skipping 19 matching lines...) Expand all
423 439
424 PostTask(nudge_location, "ScheduleNudgeImpl", 440 PostTask(nudge_location, "ScheduleNudgeImpl",
425 method_factory_.NewRunnableMethod( 441 method_factory_.NewRunnableMethod(
426 &SyncScheduler::ScheduleNudgeImpl, delay, 442 &SyncScheduler::ScheduleNudgeImpl, delay,
427 GetUpdatesFromNudgeSource(source), types_with_payloads, false, 443 GetUpdatesFromNudgeSource(source), types_with_payloads, false,
428 nudge_location)); 444 nudge_location));
429 } 445 }
430 446
431 void SyncScheduler::ScheduleClearUserDataImpl() { 447 void SyncScheduler::ScheduleClearUserDataImpl() {
432 DCHECK_EQ(MessageLoop::current(), sync_loop_); 448 DCHECK_EQ(MessageLoop::current(), sync_loop_);
433 SyncSession* session = new SyncSession(session_context_.get(), this, 449 ScheduleSyncSessionJob(
434 SyncSourceInfo(), ModelSafeRoutingInfo(), 450 TimeDelta::FromSeconds(0), SyncSessionJob::CLEAR_USER_DATA,
435 std::vector<ModelSafeWorker*>()); 451 CreateSyncSession(SyncSourceInfo()), FROM_HERE);
436 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), 452 }
437 SyncSessionJob::CLEAR_USER_DATA, session, FROM_HERE); 453
454 void SyncScheduler::ScheduleCleanupDisabledTypesImpl() {
455 DCHECK_EQ(MessageLoop::current(), sync_loop_);
456 ScheduleSyncSessionJob(
457 TimeDelta::FromSeconds(0), SyncSessionJob::CLEANUP_DISABLED_TYPES,
458 CreateSyncSession(SyncSourceInfo()), FROM_HERE);
438 } 459 }
439 460
440 void SyncScheduler::ScheduleNudgeImpl( 461 void SyncScheduler::ScheduleNudgeImpl(
441 const TimeDelta& delay, 462 const TimeDelta& delay,
442 GetUpdatesCallerInfo::GetUpdatesSource source, 463 GetUpdatesCallerInfo::GetUpdatesSource source,
443 const ModelTypePayloadMap& types_with_payloads, 464 const ModelTypePayloadMap& types_with_payloads,
444 bool is_canary_job, const tracked_objects::Location& nudge_location) { 465 bool is_canary_job, const tracked_objects::Location& nudge_location) {
445 DCHECK_EQ(MessageLoop::current(), sync_loop_); 466 DCHECK_EQ(MessageLoop::current(), sync_loop_);
446 467
447 SVLOG_LOC(nudge_location, 2) 468 SVLOG_LOC(nudge_location, 2)
448 << "In ScheduleNudgeImpl with delay " 469 << "In ScheduleNudgeImpl with delay "
449 << delay.InMilliseconds() << " ms, " 470 << delay.InMilliseconds() << " ms, "
450 << "source " << GetUpdatesSourceString(source) << ", " 471 << "source " << GetUpdatesSourceString(source) << ", "
451 << "payloads " 472 << "payloads "
452 << syncable::ModelTypePayloadMapToString(types_with_payloads) 473 << syncable::ModelTypePayloadMapToString(types_with_payloads)
453 << (is_canary_job ? " (canary)" : ""); 474 << (is_canary_job ? " (canary)" : "");
454 475
455 // Note we currently nudge for all types regardless of the ones incurring
456 // the nudge. Doing different would throw off some syncer commands like
457 // CleanupDisabledTypes. We may want to change this in the future.
458 SyncSourceInfo info(source, types_with_payloads); 476 SyncSourceInfo info(source, types_with_payloads);
459 477
460 SyncSession* session(CreateSyncSession(info)); 478 SyncSession* session(CreateSyncSession(info));
461 SyncSessionJob job(SyncSessionJob::NUDGE, TimeTicks::Now() + delay, 479 SyncSessionJob job(SyncSessionJob::NUDGE, TimeTicks::Now() + delay,
462 make_linked_ptr(session), is_canary_job, 480 make_linked_ptr(session), is_canary_job,
463 nudge_location); 481 nudge_location);
464 482
465 session = NULL; 483 session = NULL;
466 if (!ShouldRunJob(job)) 484 if (!ShouldRunJob(job))
467 return; 485 return;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 PostDelayedTask(from_here, "DoSyncSessionJob", 642 PostDelayedTask(from_here, "DoSyncSessionJob",
625 method_factory_.NewRunnableMethod( 643 method_factory_.NewRunnableMethod(
626 &SyncScheduler::DoSyncSessionJob, job), 644 &SyncScheduler::DoSyncSessionJob, job),
627 delay.InMilliseconds()); 645 delay.InMilliseconds());
628 } 646 }
629 647
630 void SyncScheduler::SetSyncerStepsForPurpose( 648 void SyncScheduler::SetSyncerStepsForPurpose(
631 SyncSessionJob::SyncSessionJobPurpose purpose, 649 SyncSessionJob::SyncSessionJobPurpose purpose,
632 SyncerStep* start, SyncerStep* end) { 650 SyncerStep* start, SyncerStep* end) {
633 DCHECK_EQ(MessageLoop::current(), sync_loop_); 651 DCHECK_EQ(MessageLoop::current(), sync_loop_);
634 *end = SYNCER_END;
635 switch (purpose) { 652 switch (purpose) {
636 case SyncSessionJob::CONFIGURATION: 653 case SyncSessionJob::CONFIGURATION:
637 *start = DOWNLOAD_UPDATES; 654 *start = DOWNLOAD_UPDATES;
638 *end = APPLY_UPDATES; 655 *end = APPLY_UPDATES;
639 return; 656 return;
640 case SyncSessionJob::CLEAR_USER_DATA: 657 case SyncSessionJob::CLEAR_USER_DATA:
641 *start = CLEAR_PRIVATE_DATA; 658 *start = CLEAR_PRIVATE_DATA;
659 *end = CLEAR_PRIVATE_DATA;
642 return; 660 return;
643 case SyncSessionJob::NUDGE: 661 case SyncSessionJob::NUDGE:
644 case SyncSessionJob::POLL: 662 case SyncSessionJob::POLL:
645 *start = SYNCER_BEGIN; 663 *start = SYNCER_BEGIN;
664 *end = SYNCER_END;
665 return;
666 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
667 *start = CLEANUP_DISABLED_TYPES;
668 *end = CLEANUP_DISABLED_TYPES;
646 return; 669 return;
647 default: 670 default:
648 NOTREACHED(); 671 NOTREACHED();
672 *start = SYNCER_END;
673 *end = SYNCER_END;
674 return;
649 } 675 }
650 } 676 }
651 677
652 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) { 678 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) {
653 DCHECK_EQ(MessageLoop::current(), sync_loop_); 679 DCHECK_EQ(MessageLoop::current(), sync_loop_);
654 if (!ShouldRunJob(job)) { 680 if (!ShouldRunJob(job)) {
655 SLOG(WARNING) 681 SLOG(WARNING)
656 << "Not executing " 682 << "Not executing "
657 << SyncSessionJob::GetPurposeString(job.purpose) << " job from " 683 << SyncSessionJob::GetPurposeString(job.purpose) << " job from "
658 << GetUpdatesSourceString(job.session->source().updates_source); 684 << GetUpdatesSourceString(job.session->source().updates_source);
(...skipping 11 matching lines...) Expand all
670 696
671 // Create the session with the latest model safe table and use it to purge 697 // Create the session with the latest model safe table and use it to purge
672 // and update any disabled or modified entries in the job. 698 // and update any disabled or modified entries in the job.
673 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); 699 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source()));
674 700
675 job.session->RebaseRoutingInfoWithLatest(session.get()); 701 job.session->RebaseRoutingInfoWithLatest(session.get());
676 } 702 }
677 SVLOG(2) << "DoSyncSessionJob with " 703 SVLOG(2) << "DoSyncSessionJob with "
678 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; 704 << SyncSessionJob::GetPurposeString(job.purpose) << " job";
679 705
680 SyncerStep begin(SYNCER_BEGIN); 706 SyncerStep begin(SYNCER_END);
681 SyncerStep end(SYNCER_END); 707 SyncerStep end(SYNCER_END);
682 SetSyncerStepsForPurpose(job.purpose, &begin, &end); 708 SetSyncerStepsForPurpose(job.purpose, &begin, &end);
683 709
684 bool has_more_to_sync = true; 710 bool has_more_to_sync = true;
685 while (ShouldRunJob(job) && has_more_to_sync) { 711 while (ShouldRunJob(job) && has_more_to_sync) {
686 SVLOG(2) << "Calling SyncShare."; 712 SVLOG(2) << "Calling SyncShare.";
687 // Synchronously perform the sync session from this thread. 713 // Synchronously perform the sync session from this thread.
688 syncer_->SyncShare(job.session.get(), begin, end); 714 syncer_->SyncShare(job.session.get(), begin, end);
689 has_more_to_sync = job.session->HasMoreToSync(); 715 has_more_to_sync = job.session->HasMoreToSync();
690 if (has_more_to_sync) 716 if (has_more_to_sync)
691 job.session->ResetTransientState(); 717 job.session->ResetTransientState();
692 } 718 }
693 SVLOG(2) << "Done SyncShare looping."; 719 SVLOG(2) << "Done SyncShare looping.";
720
694 FinishSyncSessionJob(job); 721 FinishSyncSessionJob(job);
695 } 722 }
696 723
697 void SyncScheduler::UpdateCarryoverSessionState( 724 void SyncScheduler::UpdateCarryoverSessionState(
698 const SyncSessionJob& old_job) { 725 const SyncSessionJob& old_job) {
699 DCHECK_EQ(MessageLoop::current(), sync_loop_); 726 DCHECK_EQ(MessageLoop::current(), sync_loop_);
700 if (old_job.purpose == SyncSessionJob::CONFIGURATION) { 727 if (old_job.purpose == SyncSessionJob::CONFIGURATION) {
701 // Whatever types were part of a configuration task will have had updates 728 // Whatever types were part of a configuration task will have had updates
702 // downloaded. For that reason, we make sure they get recorded in the 729 // downloaded. For that reason, we make sure they get recorded in the
703 // event that they get disabled at a later time. 730 // event that they get disabled at a later time.
(...skipping 21 matching lines...) Expand all
725 iter != job.session->source().types.end(); 752 iter != job.session->source().types.end();
726 ++iter) { 753 ++iter) {
727 syncable::PostTimeToTypeHistogram(iter->first, 754 syncable::PostTimeToTypeHistogram(iter->first,
728 now - last_sync_session_end_time_); 755 now - last_sync_session_end_time_);
729 } 756 }
730 } 757 }
731 last_sync_session_end_time_ = now; 758 last_sync_session_end_time_ = now;
732 UpdateCarryoverSessionState(job); 759 UpdateCarryoverSessionState(job);
733 if (IsSyncingCurrentlySilenced()) { 760 if (IsSyncingCurrentlySilenced()) {
734 SVLOG(2) << "We are currently throttled; not scheduling the next sync."; 761 SVLOG(2) << "We are currently throttled; not scheduling the next sync.";
762 // TODO(sync): Investigate whether we need to check job.purpose
763 // here; see DCHECKs in SaveJob(). (See http://crbug.com/90868.)
735 SaveJob(job); 764 SaveJob(job);
736 return; // Nothing to do. 765 return; // Nothing to do.
737 } 766 }
738 767
739 SVLOG(2) << "Updating the next polling time after SyncMain"; 768 SVLOG(2) << "Updating the next polling time after SyncMain";
740 ScheduleNextSync(job); 769 ScheduleNextSync(job);
741 } 770 }
742 771
743 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) { 772 void SyncScheduler::ScheduleNextSync(const SyncSessionJob& old_job) {
744 DCHECK_EQ(MessageLoop::current(), sync_loop_); 773 DCHECK_EQ(MessageLoop::current(), sync_loop_);
(...skipping 11 matching lines...) Expand all
756 const bool work_to_do = 785 const bool work_to_do =
757 num_server_changes_remaining > 0 || num_unsynced_handles > 0; 786 num_server_changes_remaining > 0 || num_unsynced_handles > 0;
758 SVLOG(2) << "num server changes remaining: " << num_server_changes_remaining 787 SVLOG(2) << "num server changes remaining: " << num_server_changes_remaining
759 << ", num unsynced handles: " << num_unsynced_handles 788 << ", num unsynced handles: " << num_unsynced_handles
760 << ", syncer has work to do: " << work_to_do; 789 << ", syncer has work to do: " << work_to_do;
761 790
762 AdjustPolling(&old_job); 791 AdjustPolling(&old_job);
763 792
764 // TODO(tim): Old impl had special code if notifications disabled. Needed? 793 // TODO(tim): Old impl had special code if notifications disabled. Needed?
765 if (!work_to_do) { 794 if (!work_to_do) {
766 // Success implies backoff relief. Note that if this was a "one-off" job 795 // Success implies backoff relief. Note that if this was a
767 // (i.e. purpose == SyncSessionJob::CLEAR_USER_DATA), if there was 796 // "one-off" job (i.e. purpose ==
768 // work_to_do before it ran this wont have changed, as jobs like this don't 797 // SyncSessionJob::{CLEAR_USER_DATA,CLEANUP_DISABLED_TYPES}), if
769 // run a full sync cycle. So we don't need special code here. 798 // there was work_to_do before it ran this wont have changed, as
799 // jobs like this don't run a full sync cycle. So we don't need
800 // special code here.
770 wait_interval_.reset(); 801 wait_interval_.reset();
771 SVLOG(2) << "Job succeeded so not scheduling more jobs"; 802 SVLOG(2) << "Job succeeded so not scheduling more jobs";
772 return; 803 return;
773 } 804 }
774 805
775 if (old_job.session->source().updates_source == 806 if (old_job.session->source().updates_source ==
776 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) { 807 GetUpdatesCallerInfo::SYNC_CYCLE_CONTINUATION) {
777 SVLOG(2) << "Job failed with source continuation"; 808 SVLOG(2) << "Job failed with source continuation";
778 // We don't seem to have made forward progress. Start or extend backoff. 809 // We don't seem to have made forward progress. Start or extend backoff.
779 HandleConsecutiveContinuationError(old_job); 810 HandleConsecutiveContinuationError(old_job);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1073
1043 #undef SLOG 1074 #undef SLOG
1044 1075
1045 #undef VLOG_LOC 1076 #undef VLOG_LOC
1046 1077
1047 #undef VLOG_LOC_STREAM 1078 #undef VLOG_LOC_STREAM
1048 1079
1049 #undef ENUM_CASE 1080 #undef ENUM_CASE
1050 1081
1051 } // browser_sync 1082 } // browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/sync_scheduler.h ('k') | chrome/browser/sync/engine/sync_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698