summaryrefslogtreecommitdiffstats
path: root/sync/engine
diff options
context:
space:
mode:
authorpavely@chromium.org <pavely@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-04 03:45:53 +0000
committerpavely@chromium.org <pavely@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-04 03:45:53 +0000
commitfd405e4810785547fba4ea48d4a186e9e609bd08 (patch)
tree16f7e06245afcd7a2195ed745a9a43b2ee50029e /sync/engine
parent8115f8cc800d39af848dea6228008bb815cd06fa (diff)
downloadchromium_src-fd405e4810785547fba4ea48d4a186e9e609bd08.zip
chromium_src-fd405e4810785547fba4ea48d4a186e9e609bd08.tar.gz
chromium_src-fd405e4810785547fba4ea48d4a186e9e609bd08.tar.bz2
Move JobPriority from parameter to scheduler state
With future introduction of access token request not all calls to TrySyncSessionJob will result in posted tasks. Still fact that TrySyncSessionJob was called with CANARY_PRIORITY needs to be preserved. I'm making next job priority part of scheduler's state. TryCanaryJob sets it to canary, any call to TrySyncSessionJobImpl resets it back to normal. BUG=259913 Review URL: https://codereview.chromium.org/124423002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242997 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r--sync/engine/sync_scheduler_impl.cc24
-rw-r--r--sync/engine/sync_scheduler_impl.h12
2 files changed, 24 insertions, 12 deletions
diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc
index 0aaaba0..6a4f1ef 100644
--- a/sync/engine/sync_scheduler_impl.cc
+++ b/sync/engine/sync_scheduler_impl.cc
@@ -169,6 +169,7 @@ SyncSchedulerImpl::SyncSchedulerImpl(const std::string& name,
session_context_(context),
no_scheduling_allowed_(false),
do_poll_after_credentials_updated_(false),
+ next_sync_session_job_priority_(NORMAL_PRIORITY),
weak_ptr_factory_(this),
weak_ptr_factory_for_weak_handle_(this) {
weak_handle_this_ = MakeWeakHandle(
@@ -237,7 +238,7 @@ void SyncSchedulerImpl::Start(Mode mode) {
CanRunNudgeJobNow(NORMAL_PRIORITY)) {
// We just got back to normal mode. Let's try to run the work that was
// queued up while we were configuring.
- TrySyncSessionJob(NORMAL_PRIORITY);
+ TrySyncSessionJob();
}
}
@@ -297,7 +298,7 @@ void SyncSchedulerImpl::ScheduleConfiguration(
// Only reconfigure if we have types to download.
if (!params.types_to_download.Empty()) {
pending_configure_params_.reset(new ConfigurationParams(params));
- TrySyncSessionJob(NORMAL_PRIORITY);
+ TrySyncSessionJob();
} else {
SDVLOG(2) << "No change in routing info, calling ready task directly.";
params.ready_task.Run();
@@ -660,19 +661,22 @@ void SyncSchedulerImpl::Stop() {
// This is the only place where we invoke DoSyncSessionJob with canary
// privileges. Everyone else should use NORMAL_PRIORITY.
void SyncSchedulerImpl::TryCanaryJob() {
- TrySyncSessionJob(CANARY_PRIORITY);
+ next_sync_session_job_priority_ = CANARY_PRIORITY;
+ TrySyncSessionJob();
}
-void SyncSchedulerImpl::TrySyncSessionJob(JobPriority priority) {
+void SyncSchedulerImpl::TrySyncSessionJob() {
// Post call to TrySyncSessionJobImpl on current thread. Later request for
// access token will be here.
base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
&SyncSchedulerImpl::TrySyncSessionJobImpl,
- weak_ptr_factory_.GetWeakPtr(),
- priority));
+ weak_ptr_factory_.GetWeakPtr()));
}
-void SyncSchedulerImpl::TrySyncSessionJobImpl(JobPriority priority) {
+void SyncSchedulerImpl::TrySyncSessionJobImpl() {
+ JobPriority priority = next_sync_session_job_priority_;
+ next_sync_session_job_priority_ = NORMAL_PRIORITY;
+
DCHECK(CalledOnValidThread());
if (mode_ == CONFIGURATION_MODE) {
if (pending_configure_params_) {
@@ -730,7 +734,7 @@ void SyncSchedulerImpl::PollTimerCallback() {
return;
}
- TrySyncSessionJob(NORMAL_PRIORITY);
+ TrySyncSessionJob();
}
void SyncSchedulerImpl::Unthrottle() {
@@ -767,14 +771,14 @@ void SyncSchedulerImpl::TypeUnthrottle(base::TimeTicks unthrottle_time) {
// Maybe this is a good time to run a nudge job. Let's try it.
if (nudge_tracker_.IsSyncRequired() && CanRunNudgeJobNow(NORMAL_PRIORITY))
- TrySyncSessionJob(NORMAL_PRIORITY);
+ TrySyncSessionJob();
}
void SyncSchedulerImpl::PerformDelayedNudge() {
// Circumstances may have changed since we scheduled this delayed nudge.
// We must check to see if it's OK to run the job before we do so.
if (CanRunNudgeJobNow(NORMAL_PRIORITY))
- TrySyncSessionJob(NORMAL_PRIORITY);
+ TrySyncSessionJob();
// We're not responsible for setting up any retries here. The functions that
// first put us into a state that prevents successful sync cycles (eg. global
diff --git a/sync/engine/sync_scheduler_impl.h b/sync/engine/sync_scheduler_impl.h
index 4c0dd57..81a4fcf 100644
--- a/sync/engine/sync_scheduler_impl.h
+++ b/sync/engine/sync_scheduler_impl.h
@@ -209,8 +209,8 @@ class SYNC_EXPORT_PRIVATE SyncSchedulerImpl
// At the moment TrySyncSessionJob just posts call to TrySyncSessionJobImpl on
// current thread. In the future it will request access token here.
- void TrySyncSessionJob(JobPriority priority);
- void TrySyncSessionJobImpl(JobPriority priority);
+ void TrySyncSessionJob();
+ void TrySyncSessionJobImpl();
// Transitions out of the THROTTLED WaitInterval then calls TryCanaryJob().
void Unthrottle();
@@ -322,6 +322,14 @@ class SYNC_EXPORT_PRIVATE SyncSchedulerImpl
// last_poll_reset_ keeps track of when was last attempt.
base::TimeTicks last_poll_reset_;
+ // next_sync_session_job_priority_ defines which priority will be used next
+ // time TrySyncSessionJobImpl is called. CANARY_PRIORITY allows syncer to run
+ // even if scheduler is in exponential backoff. This is needed for events that
+ // have chance of resolving previous error (e.g. network connection change
+ // after NETWORK_UNAVAILABLE error).
+ // It is reset back to NORMAL_PRIORITY on every call to TrySyncSessionJobImpl.
+ JobPriority next_sync_session_job_priority_;
+
base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_;
// A second factory specially for weak_handle_this_, to allow the handle