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

Unified Diff: sync/engine/sync_scheduler.cc

Issue 10542044: [Sync] Remove unnecessary posting of methods in sync scheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and fix dcheck 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 side-by-side diff with in-line comments
Download patch
Index: sync/engine/sync_scheduler.cc
diff --git a/sync/engine/sync_scheduler.cc b/sync/engine/sync_scheduler.cc
index fa8dc522070806932acbf46311bbb913ffab85ee..29215e4e3e040f6debcc5d72e73caf5b106b7dfb 100644
--- a/sync/engine/sync_scheduler.cc
+++ b/sync/engine/sync_scheduler.cc
@@ -255,30 +255,9 @@ void SyncScheduler::Start(Mode mode, const base::Closure& callback) {
<< thread_name << " with mode " << GetModeString(mode);
if (!started_) {
started_ = true;
- PostTask(FROM_HERE, "SendInitialSnapshot",
- base::Bind(&SyncScheduler::SendInitialSnapshot,
- weak_ptr_factory_.GetWeakPtr()));
+ SendInitialSnapshot();
}
- PostTask(FROM_HERE, "StartImpl",
- base::Bind(&SyncScheduler::StartImpl,
- weak_ptr_factory_.GetWeakPtr(), mode, callback));
-}
-
-void SyncScheduler::SendInitialSnapshot() {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
- scoped_ptr<SyncSession> dummy(new SyncSession(session_context_, this,
- SyncSourceInfo(), ModelSafeRoutingInfo(),
- std::vector<ModelSafeWorker*>()));
- SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED);
- event.snapshot = dummy->TakeSnapshot();
- session_context_->NotifyListeners(event);
-}
-
-void SyncScheduler::StartImpl(Mode mode, const base::Closure& callback) {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
- SDVLOG(2) << "In StartImpl with mode " << GetModeString(mode);
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
DCHECK(!session_context_->account_name().empty());
DCHECK(syncer_.get());
Mode old_mode = mode_;
@@ -294,6 +273,16 @@ void SyncScheduler::StartImpl(Mode mode, const base::Closure& callback) {
}
}
+void SyncScheduler::SendInitialSnapshot() {
+ DCHECK_EQ(MessageLoop::current(), sync_loop_);
+ scoped_ptr<SyncSession> dummy(new SyncSession(session_context_, this,
+ SyncSourceInfo(), ModelSafeRoutingInfo(),
+ std::vector<ModelSafeWorker*>()));
+ SyncEngineEvent event(SyncEngineEvent::STATUS_CHANGED);
+ event.snapshot = dummy->TakeSnapshot();
+ session_context_->NotifyListeners(event);
+}
+
SyncScheduler::JobProcessDecision SyncScheduler::DecideWhileInWaitInterval(
const SyncSessionJob& job) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
@@ -459,22 +448,23 @@ struct ModelSafeWorkerGroupIs {
ModelSafeGroup group;
};
-void SyncScheduler::ScheduleClearUserData() {
+void SyncScheduler::ClearUserData() {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
- PostTask(FROM_HERE, "ScheduleClearUserDataImpl",
- base::Bind(&SyncScheduler::ScheduleClearUserDataImpl,
- weak_ptr_factory_.GetWeakPtr()));
+ SyncSessionJob job(SyncSessionJob::CLEAR_USER_DATA, TimeTicks::Now(),
+ make_linked_ptr(CreateSyncSession(SyncSourceInfo())),
+ false,
+ FROM_HERE);
+
+ DoSyncSessionJob(job);
}
-// TODO(sync): Remove the *Impl methods for the other Schedule*
-// functions, too.
-void SyncScheduler::ScheduleCleanupDisabledTypes() {
+void SyncScheduler::CleanupDisabledTypes() {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
SyncSessionJob job(SyncSessionJob::CLEANUP_DISABLED_TYPES, TimeTicks::Now(),
make_linked_ptr(CreateSyncSession(SyncSourceInfo())),
false,
FROM_HERE);
- ScheduleSyncSessionJob(job);
+ DoSyncSessionJob(job);
}
void SyncScheduler::ScheduleNudge(
@@ -489,14 +479,11 @@ void SyncScheduler::ScheduleNudge(
ModelTypePayloadMap types_with_payloads =
syncable::ModelTypePayloadMapFromEnumSet(types, std::string());
- PostTask(nudge_location, "ScheduleNudgeImpl",
- base::Bind(&SyncScheduler::ScheduleNudgeImpl,
- weak_ptr_factory_.GetWeakPtr(),
- delay,
- GetUpdatesFromNudgeSource(source),
- types_with_payloads,
- false,
- nudge_location));
+ SyncScheduler::ScheduleNudgeImpl(delay,
+ GetUpdatesFromNudgeSource(source),
+ types_with_payloads,
+ false,
+ nudge_location);
}
void SyncScheduler::ScheduleNudgeWithPayloads(
@@ -510,24 +497,11 @@ void SyncScheduler::ScheduleNudgeWithPayloads(
<< "payloads "
<< syncable::ModelTypePayloadMapToString(types_with_payloads);
- PostTask(nudge_location, "ScheduleNudgeImpl",
- base::Bind(&SyncScheduler::ScheduleNudgeImpl,
- weak_ptr_factory_.GetWeakPtr(),
- delay,
- GetUpdatesFromNudgeSource(source),
- types_with_payloads,
- false,
- nudge_location));
-}
-
-void SyncScheduler::ScheduleClearUserDataImpl() {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
- SyncSessionJob job(SyncSessionJob::CLEAR_USER_DATA, TimeTicks::Now(),
- make_linked_ptr(CreateSyncSession(SyncSourceInfo())),
- false,
- FROM_HERE);
-
- ScheduleSyncSessionJob(job);
+ SyncScheduler::ScheduleNudgeImpl(delay,
+ GetUpdatesFromNudgeSource(source),
+ types_with_payloads,
+ false,
+ nudge_location);
}
void SyncScheduler::ScheduleNudgeImpl(
@@ -626,12 +600,12 @@ void GetModelSafeParamsForTypes(ModelTypeSet types,
}
}
-void SyncScheduler::ScheduleConfig(
+void SyncScheduler::Configure(
ModelTypeSet types,
GetUpdatesCallerInfo::GetUpdatesSource source) {
DCHECK_EQ(MessageLoop::current(), sync_loop_);
DCHECK(IsConfigRelatedUpdateSourceValue(source));
- SDVLOG(2) << "Scheduling a config";
+ SDVLOG(2) << "Performing a config";
ModelSafeRoutingInfo routes;
std::vector<ModelSafeWorker*> workers;
@@ -640,32 +614,17 @@ void SyncScheduler::ScheduleConfig(
session_context_->workers(),
&routes, &workers);
- PostTask(FROM_HERE, "ScheduleConfigImpl",
- base::Bind(&SyncScheduler::ScheduleConfigImpl,
- weak_ptr_factory_.GetWeakPtr(),
- routes,
- workers,
- source));
-}
-
-void SyncScheduler::ScheduleConfigImpl(
- const ModelSafeRoutingInfo& routing_info,
- const std::vector<ModelSafeWorker*>& workers,
- const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source) {
- DCHECK_EQ(MessageLoop::current(), sync_loop_);
-
- SDVLOG(2) << "In ScheduleConfigImpl";
// TODO(tim): config-specific GetUpdatesCallerInfo value?
tim (not reviewing) 2012/06/11 20:06:13 I think this can be removed.
Nicolas Zea 2012/06/11 20:55:09 Done.
SyncSession* session = new SyncSession(session_context_, this,
SyncSourceInfo(source,
- syncable::ModelTypePayloadMapFromRoutingInfo(
- routing_info, std::string())),
- routing_info, workers);
+ syncable::ModelTypePayloadMapFromRoutingInfo(
+ routes, std::string())),
+ routes, workers);
SyncSessionJob job(SyncSessionJob::CONFIGURATION, TimeTicks::Now(),
make_linked_ptr(session),
false,
FROM_HERE);
- ScheduleSyncSessionJob(job);
+ DoSyncSessionJob(job);
}
const char* SyncScheduler::GetModeString(SyncScheduler::Mode mode) {
@@ -752,12 +711,15 @@ void SyncScheduler::ScheduleSyncSessionJob(const SyncSessionJob& job) {
<< SyncSessionJob::GetPurposeString(job.purpose)
<< " job and " << delay.InMilliseconds() << " ms delay";
+ DCHECK(job.purpose == SyncSessionJob::NUDGE ||
+ job.purpose == SyncSessionJob::POLL);
if (job.purpose == SyncSessionJob::NUDGE) {
SDVLOG_LOC(job.from_here, 2) << "Resetting pending_nudge";
DCHECK(!pending_nudge_.get() || pending_nudge_->session.get() ==
job.session);
pending_nudge_.reset(new SyncSessionJob(job));
}
+
PostDelayedTask(job.from_here, "DoSyncSessionJob",
base::Bind(&SyncScheduler::DoSyncSessionJob,
weak_ptr_factory_.GetWeakPtr(),

Powered by Google App Engine
This is Rietveld 408576698