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

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

Issue 10584019: sync: Remove ClearUserData command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test 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/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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 is_canary_job(is_canary_job), 106 is_canary_job(is_canary_job),
107 from_here(from_here) { 107 from_here(from_here) {
108 } 108 }
109 109
110 const char* SyncScheduler::SyncSessionJob::GetPurposeString( 110 const char* SyncScheduler::SyncSessionJob::GetPurposeString(
111 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) { 111 SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) {
112 switch (purpose) { 112 switch (purpose) {
113 ENUM_CASE(UNKNOWN); 113 ENUM_CASE(UNKNOWN);
114 ENUM_CASE(POLL); 114 ENUM_CASE(POLL);
115 ENUM_CASE(NUDGE); 115 ENUM_CASE(NUDGE);
116 ENUM_CASE(CLEAR_USER_DATA);
117 ENUM_CASE(CONFIGURATION); 116 ENUM_CASE(CONFIGURATION);
118 ENUM_CASE(CLEANUP_DISABLED_TYPES); 117 ENUM_CASE(CLEANUP_DISABLED_TYPES);
119 } 118 }
120 NOTREACHED(); 119 NOTREACHED();
121 return ""; 120 return "";
122 } 121 }
123 122
124 TimeDelta SyncScheduler::DelayProvider::GetDelay( 123 TimeDelta SyncScheduler::DelayProvider::GetDelay(
125 const base::TimeDelta& last_delay) { 124 const base::TimeDelta& last_delay) {
126 return SyncScheduler::GetRecommendedDelay(last_delay); 125 return SyncScheduler::GetRecommendedDelay(last_delay);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 std::vector<ModelSafeWorker*>())); 280 std::vector<ModelSafeWorker*>()));
282 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED); 281 SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED);
283 event.snapshot = dummy->TakeSnapshot(); 282 event.snapshot = dummy->TakeSnapshot();
284 session_context_->NotifyListeners(event); 283 session_context_->NotifyListeners(event);
285 } 284 }
286 285
287 SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval( 286 SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval(
288 const SyncSessionJob& job) { 287 const SyncSessionJob& job) {
289 DCHECK_EQ(MessageLoop::current(), sync_loop_); 288 DCHECK_EQ(MessageLoop::current(), sync_loop_);
290 DCHECK(wait_interval_.get()); 289 DCHECK(wait_interval_.get());
291 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA);
292 DCHECK_NE(job.purpose, SyncSessionJob::CLEANUP_DISABLED_TYPES); 290 DCHECK_NE(job.purpose, SyncSessionJob::CLEANUP_DISABLED_TYPES);
293 291
294 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode " 292 SDVLOG(2) << "DecideWhileInWaitInterval with WaitInterval mode "
295 << WaitInterval::GetModeString(wait_interval_->mode) 293 << WaitInterval::GetModeString(wait_interval_->mode)
296 << (wait_interval_->had_nudge ? " (had nudge)" : "") 294 << (wait_interval_->had_nudge ? " (had nudge)" : "")
297 << (job.is_canary_job ? " (canary)" : ""); 295 << (job.is_canary_job ? " (canary)" : "");
298 296
299 if (job.purpose == SyncSessionJob::POLL) 297 if (job.purpose == SyncSessionJob::POLL)
300 return DROP; 298 return DROP;
301 299
(...skipping 13 matching lines...) Expand all
315 return wait_interval_->had_nudge ? DROP : CONTINUE; 313 return wait_interval_->had_nudge ? DROP : CONTINUE;
316 else // We are here because timer ran out. So retry. 314 else // We are here because timer ran out. So retry.
317 return CONTINUE; 315 return CONTINUE;
318 } 316 }
319 return job.is_canary_job ? CONTINUE : SAVE; 317 return job.is_canary_job ? CONTINUE : SAVE;
320 } 318 }
321 319
322 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob( 320 SyncScheduler::JobProcessDecision SyncScheduler::DecideOnJob(
323 const SyncSessionJob& job) { 321 const SyncSessionJob& job) {
324 DCHECK_EQ(MessageLoop::current(), sync_loop_); 322 DCHECK_EQ(MessageLoop::current(), sync_loop_);
325 if (job.purpose == SyncSessionJob::CLEAR_USER_DATA || 323 if (job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES)
326 job.purpose == SyncSessionJob::CLEANUP_DISABLED_TYPES)
327 return CONTINUE; 324 return CONTINUE;
328 325
329 // See if our type is throttled. 326 // See if our type is throttled.
330 syncable::ModelTypeSet throttled_types = 327 syncable::ModelTypeSet throttled_types =
331 session_context_->throttled_data_type_tracker()->GetThrottledTypes(); 328 session_context_->throttled_data_type_tracker()->GetThrottledTypes();
332 if (job.purpose == SyncSessionJob::NUDGE && 329 if (job.purpose == SyncSessionJob::NUDGE &&
333 job.session->source().updates_source == GetUpdatesCallerInfo::LOCAL) { 330 job.session->source().updates_source == GetUpdatesCallerInfo::LOCAL) {
334 syncable::ModelTypeSet requested_types; 331 syncable::ModelTypeSet requested_types;
335 for (ModelTypePayloadMap::const_iterator i = 332 for (ModelTypePayloadMap::const_iterator i =
336 job.session->source().types.begin(); 333 job.session->source().types.begin();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 407
411 DCHECK(job.purpose == SyncSessionJob::NUDGE || job.purpose == 408 DCHECK(job.purpose == SyncSessionJob::NUDGE || job.purpose ==
412 SyncSessionJob::CONFIGURATION); 409 SyncSessionJob::CONFIGURATION);
413 410
414 SaveJob(job); 411 SaveJob(job);
415 return false; 412 return false;
416 } 413 }
417 414
418 void SyncScheduler::SaveJob(const SyncSessionJob& job) { 415 void SyncScheduler::SaveJob(const SyncSessionJob& job) {
419 DCHECK_EQ(MessageLoop::current(), sync_loop_); 416 DCHECK_EQ(MessageLoop::current(), sync_loop_);
420 DCHECK_NE(job.purpose, SyncSessionJob::CLEAR_USER_DATA);
421 // TODO(sync): Should we also check that job.purpose != 417 // TODO(sync): Should we also check that job.purpose !=
422 // CLEANUP_DISABLED_TYPES? (See http://crbug.com/90868.) 418 // CLEANUP_DISABLED_TYPES? (See http://crbug.com/90868.)
423 if (job.purpose == SyncSessionJob::NUDGE) { 419 if (job.purpose == SyncSessionJob::NUDGE) {
424 SDVLOG(2) << "Saving a nudge job"; 420 SDVLOG(2) << "Saving a nudge job";
425 InitOrCoalescePendingJob(job); 421 InitOrCoalescePendingJob(job);
426 } else if (job.purpose == SyncSessionJob::CONFIGURATION){ 422 } else if (job.purpose == SyncSessionJob::CONFIGURATION){
427 SDVLOG(2) << "Saving a configuration job"; 423 SDVLOG(2) << "Saving a configuration job";
428 DCHECK(wait_interval_.get()); 424 DCHECK(wait_interval_.get());
429 DCHECK(mode_ == CONFIGURATION_MODE); 425 DCHECK(mode_ == CONFIGURATION_MODE);
430 426
(...skipping 11 matching lines...) Expand all
442 438
443 // Functor for std::find_if to search by ModelSafeGroup. 439 // Functor for std::find_if to search by ModelSafeGroup.
444 struct ModelSafeWorkerGroupIs { 440 struct ModelSafeWorkerGroupIs {
445 explicit ModelSafeWorkerGroupIs(ModelSafeGroup group) : group(group) {} 441 explicit ModelSafeWorkerGroupIs(ModelSafeGroup group) : group(group) {}
446 bool operator()(ModelSafeWorker* w) { 442 bool operator()(ModelSafeWorker* w) {
447 return group == w->GetModelSafeGroup(); 443 return group == w->GetModelSafeGroup();
448 } 444 }
449 ModelSafeGroup group; 445 ModelSafeGroup group;
450 }; 446 };
451 447
452 void SyncScheduler::ClearUserData() {
453 DCHECK_EQ(MessageLoop::current(), sync_loop_);
454 SyncSessionJob job(SyncSessionJob::CLEAR_USER_DATA, TimeTicks::Now(),
455 make_linked_ptr(CreateSyncSession(SyncSourceInfo())),
456 false,
457 FROM_HERE);
458
459 DoSyncSessionJob(job);
460 }
461
462 void SyncScheduler::CleanupDisabledTypes() { 448 void SyncScheduler::CleanupDisabledTypes() {
463 DCHECK_EQ(MessageLoop::current(), sync_loop_); 449 DCHECK_EQ(MessageLoop::current(), sync_loop_);
464 SyncSessionJob job(SyncSessionJob::CLEANUP_DISABLED_TYPES, TimeTicks::Now(), 450 SyncSessionJob job(SyncSessionJob::CLEANUP_DISABLED_TYPES, TimeTicks::Now(),
465 make_linked_ptr(CreateSyncSession(SyncSourceInfo())), 451 make_linked_ptr(CreateSyncSession(SyncSourceInfo())),
466 false, 452 false,
467 FROM_HERE); 453 FROM_HERE);
468 DoSyncSessionJob(job); 454 DoSyncSessionJob(job);
469 } 455 }
470 456
471 void SyncScheduler::ScheduleNudgeAsync( 457 void SyncScheduler::ScheduleNudgeAsync(
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 // static 634 // static
649 void SyncScheduler::SetSyncerStepsForPurpose( 635 void SyncScheduler::SetSyncerStepsForPurpose(
650 SyncSessionJob::SyncSessionJobPurpose purpose, 636 SyncSessionJob::SyncSessionJobPurpose purpose,
651 SyncerStep* start, 637 SyncerStep* start,
652 SyncerStep* end) { 638 SyncerStep* end) {
653 switch (purpose) { 639 switch (purpose) {
654 case SyncSessionJob::CONFIGURATION: 640 case SyncSessionJob::CONFIGURATION:
655 *start = DOWNLOAD_UPDATES; 641 *start = DOWNLOAD_UPDATES;
656 *end = APPLY_UPDATES; 642 *end = APPLY_UPDATES;
657 return; 643 return;
658 case SyncSessionJob::CLEAR_USER_DATA:
659 *start = CLEAR_PRIVATE_DATA;
660 *end = CLEAR_PRIVATE_DATA;
661 return;
662 case SyncSessionJob::NUDGE: 644 case SyncSessionJob::NUDGE:
663 case SyncSessionJob::POLL: 645 case SyncSessionJob::POLL:
664 *start = SYNCER_BEGIN; 646 *start = SYNCER_BEGIN;
665 *end = SYNCER_END; 647 *end = SYNCER_END;
666 return; 648 return;
667 case SyncSessionJob::CLEANUP_DISABLED_TYPES: 649 case SyncSessionJob::CLEANUP_DISABLED_TYPES:
668 *start = CLEANUP_DISABLED_TYPES; 650 *start = CLEANUP_DISABLED_TYPES;
669 *end = CLEANUP_DISABLED_TYPES; 651 *end = CLEANUP_DISABLED_TYPES;
670 return; 652 return;
671 default: 653 default:
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 1134
1153 #undef SDVLOG_LOC 1135 #undef SDVLOG_LOC
1154 1136
1155 #undef SDVLOG 1137 #undef SDVLOG
1156 1138
1157 #undef SLOG 1139 #undef SLOG
1158 1140
1159 #undef ENUM_CASE 1141 #undef ENUM_CASE
1160 1142
1161 } // browser_sync 1143 } // browser_sync
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