| OLD | NEW |
| 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 ModelSafeGroup group; | 438 ModelSafeGroup group; |
| 439 }; | 439 }; |
| 440 | 440 |
| 441 void SyncScheduler::ScheduleClearUserData() { | 441 void SyncScheduler::ScheduleClearUserData() { |
| 442 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 442 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 443 PostTask(FROM_HERE, "ScheduleClearUserDataImpl", | 443 PostTask(FROM_HERE, "ScheduleClearUserDataImpl", |
| 444 method_factory_.NewRunnableMethod( | 444 method_factory_.NewRunnableMethod( |
| 445 &SyncScheduler::ScheduleClearUserDataImpl)); | 445 &SyncScheduler::ScheduleClearUserDataImpl)); |
| 446 } | 446 } |
| 447 | 447 |
| 448 // TODO(sync): Remove the *Impl methods for the other Schedule* |
| 449 // functions, too. |
| 448 void SyncScheduler::ScheduleCleanupDisabledTypes() { | 450 void SyncScheduler::ScheduleCleanupDisabledTypes() { |
| 449 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 451 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 450 PostTask(FROM_HERE, "ScheduleCleanupDisabledTypes", | 452 ScheduleSyncSessionJob( |
| 451 method_factory_.NewRunnableMethod( | 453 TimeDelta::FromSeconds(0), SyncSessionJob::CLEANUP_DISABLED_TYPES, |
| 452 &SyncScheduler::ScheduleCleanupDisabledTypesImpl)); | 454 CreateSyncSession(SyncSourceInfo()), FROM_HERE); |
| 453 } | 455 } |
| 454 | 456 |
| 455 void SyncScheduler::ScheduleNudge( | 457 void SyncScheduler::ScheduleNudge( |
| 456 const TimeDelta& delay, | 458 const TimeDelta& delay, |
| 457 NudgeSource source, const ModelTypeBitSet& types, | 459 NudgeSource source, const ModelTypeBitSet& types, |
| 458 const tracked_objects::Location& nudge_location) { | 460 const tracked_objects::Location& nudge_location) { |
| 459 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 461 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 460 SVLOG_LOC(nudge_location, 2) | 462 SVLOG_LOC(nudge_location, 2) |
| 461 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " | 463 << "Nudge scheduled with delay " << delay.InMilliseconds() << " ms, " |
| 462 << "source " << GetNudgeSourceString(source) << ", " | 464 << "source " << GetNudgeSourceString(source) << ", " |
| (...skipping 26 matching lines...) Expand all Loading... |
| 489 nudge_location)); | 491 nudge_location)); |
| 490 } | 492 } |
| 491 | 493 |
| 492 void SyncScheduler::ScheduleClearUserDataImpl() { | 494 void SyncScheduler::ScheduleClearUserDataImpl() { |
| 493 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 495 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 494 ScheduleSyncSessionJob( | 496 ScheduleSyncSessionJob( |
| 495 TimeDelta::FromSeconds(0), SyncSessionJob::CLEAR_USER_DATA, | 497 TimeDelta::FromSeconds(0), SyncSessionJob::CLEAR_USER_DATA, |
| 496 CreateSyncSession(SyncSourceInfo()), FROM_HERE); | 498 CreateSyncSession(SyncSourceInfo()), FROM_HERE); |
| 497 } | 499 } |
| 498 | 500 |
| 499 void SyncScheduler::ScheduleCleanupDisabledTypesImpl() { | |
| 500 DCHECK_EQ(MessageLoop::current(), sync_loop_); | |
| 501 ScheduleSyncSessionJob( | |
| 502 TimeDelta::FromSeconds(0), SyncSessionJob::CLEANUP_DISABLED_TYPES, | |
| 503 CreateSyncSession(SyncSourceInfo()), FROM_HERE); | |
| 504 } | |
| 505 | |
| 506 void SyncScheduler::ScheduleNudgeImpl( | 501 void SyncScheduler::ScheduleNudgeImpl( |
| 507 const TimeDelta& delay, | 502 const TimeDelta& delay, |
| 508 GetUpdatesCallerInfo::GetUpdatesSource source, | 503 GetUpdatesCallerInfo::GetUpdatesSource source, |
| 509 const ModelTypePayloadMap& types_with_payloads, | 504 const ModelTypePayloadMap& types_with_payloads, |
| 510 bool is_canary_job, const tracked_objects::Location& nudge_location) { | 505 bool is_canary_job, const tracked_objects::Location& nudge_location) { |
| 511 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 506 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 512 | 507 |
| 513 SVLOG_LOC(nudge_location, 2) | 508 SVLOG_LOC(nudge_location, 2) |
| 514 << "In ScheduleNudgeImpl with delay " | 509 << "In ScheduleNudgeImpl with delay " |
| 515 << delay.InMilliseconds() << " ms, " | 510 << delay.InMilliseconds() << " ms, " |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 copy.is_canary_job = is_canary_job; | 1025 copy.is_canary_job = is_canary_job; |
| 1031 DoSyncSessionJob(copy); | 1026 DoSyncSessionJob(copy); |
| 1032 } | 1027 } |
| 1033 } | 1028 } |
| 1034 | 1029 |
| 1035 SyncSession* SyncScheduler::CreateSyncSession(const SyncSourceInfo& source) { | 1030 SyncSession* SyncScheduler::CreateSyncSession(const SyncSourceInfo& source) { |
| 1036 DCHECK_EQ(MessageLoop::current(), sync_loop_); | 1031 DCHECK_EQ(MessageLoop::current(), sync_loop_); |
| 1037 ModelSafeRoutingInfo routes; | 1032 ModelSafeRoutingInfo routes; |
| 1038 std::vector<ModelSafeWorker*> workers; | 1033 std::vector<ModelSafeWorker*> workers; |
| 1039 session_context_->registrar()->GetModelSafeRoutingInfo(&routes); | 1034 session_context_->registrar()->GetModelSafeRoutingInfo(&routes); |
| 1035 VLOG(2) << "Creating sync session with routes " |
| 1036 << ModelSafeRoutingInfoToString(routes); |
| 1040 session_context_->registrar()->GetWorkers(&workers); | 1037 session_context_->registrar()->GetWorkers(&workers); |
| 1041 SyncSourceInfo info(source); | 1038 SyncSourceInfo info(source); |
| 1042 | 1039 |
| 1043 SyncSession* session(new SyncSession(session_context_.get(), this, info, | 1040 SyncSession* session(new SyncSession(session_context_.get(), this, info, |
| 1044 routes, workers)); | 1041 routes, workers)); |
| 1045 | 1042 |
| 1046 return session; | 1043 return session; |
| 1047 } | 1044 } |
| 1048 | 1045 |
| 1049 void SyncScheduler::PollTimerCallback() { | 1046 void SyncScheduler::PollTimerCallback() { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 | 1155 |
| 1159 #undef SVLOG_LOC | 1156 #undef SVLOG_LOC |
| 1160 | 1157 |
| 1161 #undef SVLOG | 1158 #undef SVLOG |
| 1162 | 1159 |
| 1163 #undef SLOG | 1160 #undef SLOG |
| 1164 | 1161 |
| 1165 #undef ENUM_CASE | 1162 #undef ENUM_CASE |
| 1166 | 1163 |
| 1167 } // browser_sync | 1164 } // browser_sync |
| OLD | NEW |