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

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

Issue 7281017: [Sync] Add RequestCleanupDisabledTypes() method to SyncManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 const char* SyncScheduler::SyncSessionJob::GetPurposeString( 70 const char* SyncScheduler::SyncSessionJob::GetPurposeString(
71 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { 71 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) {
72 switch (purpose) { 72 switch (purpose) {
73 ENUM_CASE(UNKNOWN); 73 ENUM_CASE(UNKNOWN);
74 ENUM_CASE(POLL); 74 ENUM_CASE(POLL);
75 ENUM_CASE(NUDGE); 75 ENUM_CASE(NUDGE);
76 ENUM_CASE(CLEAR_USER_DATA); 76 ENUM_CASE(CLEAR_USER_DATA);
77 ENUM_CASE(CONFIGURATION); 77 ENUM_CASE(CONFIGURATION);
78 ENUM_CASE(CLEANUP_DISABLED_TYPES);
78 } 79 }
79 NOTREACHED(); 80 NOTREACHED();
80 return ""; 81 return "";
81 } 82 }
82 83
83 TimeDelta SyncScheduler::DelayProvider::GetDelay( 84 TimeDelta SyncScheduler::DelayProvider::GetDelay(
84 const base::TimeDelta& last_delay) { 85 const base::TimeDelta& last_delay) {
85 return SyncScheduler::GetRecommendedDelay(last_delay); 86 return SyncScheduler::GetRecommendedDelay(last_delay);
86 } 87 }
87 88
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 ModelSafeGroup group; 385 ModelSafeGroup group;
385 }; 386 };
386 387
387 void SyncScheduler::ScheduleClearUserData() { 388 void SyncScheduler::ScheduleClearUserData() {
388 DCHECK_EQ(MessageLoop::current(), sync_loop_); 389 DCHECK_EQ(MessageLoop::current(), sync_loop_);
389 PostTask(FROM_HERE, "ScheduleClearUserDataImpl", 390 PostTask(FROM_HERE, "ScheduleClearUserDataImpl",
390 method_factory_.NewRunnableMethod( 391 method_factory_.NewRunnableMethod(
391 &SyncScheduler::ScheduleClearUserDataImpl)); 392 &SyncScheduler::ScheduleClearUserDataImpl));
392 } 393 }
393 394
395 void SyncScheduler::ScheduleDisabledTypesCleanup() {
396 DCHECK_EQ(MessageLoop::current(), sync_loop_);
397 PostTask(FROM_HERE, "ScheduleDisabledTypesCleanup",
398 method_factory_.NewRunnableMethod(
399 &SyncScheduler::ScheduleDisabledTypesCleanupImpl));
400 }
401
394 void SyncScheduler::ScheduleNudge( 402 void SyncScheduler::ScheduleNudge(
395 const TimeDelta& delay, 403 const TimeDelta& delay,
396 NudgeSource source, const ModelTypeBitSet& types, 404 NudgeSource source, const ModelTypeBitSet& types,
397 const tracked_objects::Location& nudge_location) { 405 const tracked_objects::Location& nudge_location) {
398 DCHECK_EQ(MessageLoop::current(), sync_loop_); 406 DCHECK_EQ(MessageLoop::current(), sync_loop_);
399 SVLOG_LOC(nudge_location, 2) 407 SVLOG_LOC(nudge_location, 2)
400 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " 408 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, "
401 << "source " << GetNudgeSourceString(source) << ", " 409 << "source " << GetNudgeSourceString(source) << ", "
402 << "types " << syncable::ModelTypeBitSetToString(types); 410 << "types " << syncable::ModelTypeBitSetToString(types);
403 411
(...skipping 19 matching lines...) Expand all
423 431
424 PostTask(nudge_location, "ScheduleNudgeImpl", 432 PostTask(nudge_location, "ScheduleNudgeImpl",
425 method_factory_.NewRunnableMethod( 433 method_factory_.NewRunnableMethod(
426 &SyncScheduler::ScheduleNudgeImpl, delay, 434 &SyncScheduler::ScheduleNudgeImpl, delay,
427 GetUpdatesFromNudgeSource(source), types_with_payloads, false, 435 GetUpdatesFromNudgeSource(source), types_with_payloads, false,
428 nudge_location)); 436 nudge_location));
429 } 437 }
430 438
431 void SyncScheduler::ScheduleClearUserDataImpl() { 439 void SyncScheduler::ScheduleClearUserDataImpl() {
432 DCHECK_EQ(MessageLoop::current(), sync_loop_); 440 DCHECK_EQ(MessageLoop::current(), sync_loop_);
433 SyncSession* session = new SyncSession(session_context_.get(), this, 441 SyncSession* session =
434 SyncSourceInfo(), ModelSafeRoutingInfo(), 442 new SyncSession(session_context_.get(), this,
435 std::vector<ModelSafeWorker*>()); 443 SyncSourceInfo(), ModelSafeRoutingInfo(),
444 std::vector<ModelSafeWorker*>());
436 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0), 445 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0),
437 SyncSessionJob::CLEAR_USER_DATA, session, FROM_HERE); 446 SyncSessionJob::CLEAR_USER_DATA, session, FROM_HERE);
438 } 447 }
439 448
449 void SyncScheduler::ScheduleDisabledTypesCleanupImpl() {
450 DCHECK_EQ(MessageLoop::current(), sync_loop_);
451 SyncSession* session =
452 new SyncSession(session_context_.get(), this,
453 SyncSourceInfo(), ModelSafeRoutingInfo(),
454 std::vector<ModelSafeWorker*>());
455 ScheduleSyncSessionJob(TimeDelta::FromSeconds(0),
456 SyncSessionJob::CLEANUP_DISABLED_TYPES, session, FROM_HERE);
457 }
458
440 void SyncScheduler::ScheduleNudgeImpl( 459 void SyncScheduler::ScheduleNudgeImpl(
441 const TimeDelta& delay, 460 const TimeDelta& delay,
442 GetUpdatesCallerInfo::GetUpdatesSource source, 461 GetUpdatesCallerInfo::GetUpdatesSource source,
443 const ModelTypePayloadMap& types_with_payloads, 462 const ModelTypePayloadMap& types_with_payloads,
444 bool is_canary_job, const tracked_objects::Location& nudge_location) { 463 bool is_canary_job, const tracked_objects::Location& nudge_location) {
445 DCHECK_EQ(MessageLoop::current(), sync_loop_); 464 DCHECK_EQ(MessageLoop::current(), sync_loop_);
446 465
447 SVLOG_LOC(nudge_location, 2) 466 SVLOG_LOC(nudge_location, 2)
448 << "In ScheduleNudgeImpl with delay " 467 << "In ScheduleNudgeImpl with delay "
449 << delay.InMilliseconds() << " ms, " 468 << delay.InMilliseconds() << " ms, "
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 PostDelayedTask(from_here, "DoSyncSessionJob", 643 PostDelayedTask(from_here, "DoSyncSessionJob",
625 method_factory_.NewRunnableMethod( 644 method_factory_.NewRunnableMethod(
626 &SyncScheduler::DoSyncSessionJob, job), 645 &SyncScheduler::DoSyncSessionJob, job),
627 delay.InMilliseconds()); 646 delay.InMilliseconds());
628 } 647 }
629 648
630 void SyncScheduler::SetSyncerStepsForPurpose( 649 void SyncScheduler::SetSyncerStepsForPurpose(
631 SyncSessionJob::SyncSessionJobPurpose purpose, 650 SyncSessionJob::SyncSessionJobPurpose purpose,
632 SyncerStep* start, SyncerStep* end) { 651 SyncerStep* start, SyncerStep* end) {
633 DCHECK_EQ(MessageLoop::current(), sync_loop_); 652 DCHECK_EQ(MessageLoop::current(), sync_loop_);
634 *end = SYNCER_END;
635 switch (purpose) { 653 switch (purpose) {
636 case SyncSessionJob::CONFIGURATION: 654 case SyncSessionJob::CONFIGURATION:
637 *start = DOWNLOAD_UPDATES; 655 *start = DOWNLOAD_UPDATES;
638 *end = APPLY_UPDATES; 656 *end = APPLY_UPDATES;
639 return; 657 return;
640 case SyncSessionJob::CLEAR_USER_DATA: 658 case SyncSessionJob::CLEAR_USER_DATA:
641 *start = CLEAR_PRIVATE_DATA; 659 *start = CLEAR_PRIVATE_DATA;
660 *end = CLEAR_PRIVATE_DATA;
661 return;
662 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
663 *start = CLEANUP_DISABLED_TYPES;
664 *end = CLEANUP_DISABLED_TYPES;
642 return; 665 return;
643 case SyncSessionJob::NUDGE: 666 case SyncSessionJob::NUDGE:
644 case SyncSessionJob::POLL: 667 case SyncSessionJob::POLL:
645 *start = SYNCER_BEGIN; 668 *start = SYNCER_BEGIN;
669 *end = SYNCER_END;
646 return; 670 return;
647 default: 671 default:
648 NOTREACHED(); 672 NOTREACHED();
673 *start = SYNCER_END;
674 *end = SYNCER_END;
675 return;
649 } 676 }
650 } 677 }
651 678
652 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) { 679 void SyncScheduler::DoSyncSessionJob(const SyncSessionJob& job) {
653 DCHECK_EQ(MessageLoop::current(), sync_loop_); 680 DCHECK_EQ(MessageLoop::current(), sync_loop_);
654 if (!ShouldRunJob(job)) { 681 if (!ShouldRunJob(job)) {
655 SLOG(WARNING) 682 SLOG(WARNING)
656 << "Not executing " 683 << "Not executing "
657 << SyncSessionJob::GetPurposeString(job.purpose) << " job from " 684 << SyncSessionJob::GetPurposeString(job.purpose) << " job from "
658 << GetUpdatesSourceString(job.session->source().updates_source); 685 << GetUpdatesSourceString(job.session->source().updates_source);
(...skipping 11 matching lines...) Expand all
670 697
671 // Create the session with the latest model safe table and use it to purge 698 // 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. 699 // and update any disabled or modified entries in the job.
673 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source())); 700 scoped_ptr<SyncSession> session(CreateSyncSession(job.session->source()));
674 701
675 job.session->RebaseRoutingInfoWithLatest(session.get()); 702 job.session->RebaseRoutingInfoWithLatest(session.get());
676 } 703 }
677 SVLOG(2) << "DoSyncSessionJob with " 704 SVLOG(2) << "DoSyncSessionJob with "
678 << SyncSessionJob::GetPurposeString(job.purpose) << " job"; 705 << SyncSessionJob::GetPurposeString(job.purpose) << " job";
679 706
680 SyncerStep begin(SYNCER_BEGIN); 707 SyncerStep begin(SYNCER_END);
681 SyncerStep end(SYNCER_END); 708 SyncerStep end(SYNCER_END);
682 SetSyncerStepsForPurpose(job.purpose, &begin, &end); 709 SetSyncerStepsForPurpose(job.purpose, &begin, &end);
683 710
684 bool has_more_to_sync = true; 711 bool has_more_to_sync = true;
685 while (ShouldRunJob(job) && has_more_to_sync) { 712 while (ShouldRunJob(job) && has_more_to_sync) {
686 SVLOG(2) << "Calling SyncShare."; 713 SVLOG(2) << "Calling SyncShare.";
687 // Synchronously perform the sync session from this thread. 714 // Synchronously perform the sync session from this thread.
688 syncer_->SyncShare(job.session.get(), begin, end); 715 syncer_->SyncShare(job.session.get(), begin, end);
689 has_more_to_sync = job.session->HasMoreToSync(); 716 has_more_to_sync = job.session->HasMoreToSync();
690 if (has_more_to_sync) 717 if (has_more_to_sync)
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 1069
1043 #undef SLOG 1070 #undef SLOG
1044 1071
1045 #undef VLOG_LOC 1072 #undef VLOG_LOC
1046 1073
1047 #undef VLOG_LOC_STREAM 1074 #undef VLOG_LOC_STREAM
1048 1075
1049 #undef ENUM_CASE 1076 #undef ENUM_CASE
1050 1077
1051 } // browser_sync 1078 } // browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698