summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorskyostil <skyostil@chromium.org>2015-04-24 10:59:30 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-24 17:59:25 +0000
commita08639cd15b52dfb784cc94295e9fc13823b1d71 (patch)
tree06651c80ca3a1203dcec4bb1ddc286af8641f2d6 /components
parentf2a0b4ecb28f0012325152de861485d536385cc3 (diff)
downloadchromium_src-a08639cd15b52dfb784cc94295e9fc13823b1d71.zip
chromium_src-a08639cd15b52dfb784cc94295e9fc13823b1d71.tar.gz
chromium_src-a08639cd15b52dfb784cc94295e9fc13823b1d71.tar.bz2
scheduler: Encapsulate task queue selector inside the scheduler helper
Encapsulate task queue selector inside the scheduler helper to avoid clients changing task queue states in an uncontrolled way. This will be needed by the upcoming shutdown task queue. No functional changes. BUG=463143 Review URL: https://codereview.chromium.org/1103853004 Cr-Commit-Position: refs/heads/master@{#326833}
Diffstat (limited to 'components')
-rw-r--r--components/scheduler/child/scheduler_helper.cc30
-rw-r--r--components/scheduler/child/scheduler_helper.h9
-rw-r--r--components/scheduler/renderer/renderer_scheduler_impl.cc36
3 files changed, 47 insertions, 28 deletions
diff --git a/components/scheduler/child/scheduler_helper.cc b/components/scheduler/child/scheduler_helper.cc
index 19e8d2b..cb2d191 100644
--- a/components/scheduler/child/scheduler_helper.cc
+++ b/components/scheduler/child/scheduler_helper.cc
@@ -7,7 +7,6 @@
#include "base/trace_event/trace_event.h"
#include "base/trace_event/trace_event_argument.h"
#include "components/scheduler/child/nestable_single_thread_task_runner.h"
-#include "components/scheduler/child/prioritizing_task_queue_selector.h"
#include "components/scheduler/child/time_source.h"
namespace scheduler {
@@ -336,11 +335,6 @@ SchedulerHelper::IdlePeriodState SchedulerHelper::SchedulerIdlePeriodState()
return idle_period_state_;
}
-PrioritizingTaskQueueSelector* SchedulerHelper::SchedulerTaskQueueSelector()
- const {
- return task_queue_selector_.get();
-}
-
scoped_refptr<base::SingleThreadTaskRunner> SchedulerHelper::TaskRunnerForQueue(
size_t queue_index) const {
CheckOnValidThread();
@@ -357,6 +351,30 @@ bool SchedulerHelper::IsQueueEmpty(size_t queue_index) const {
return task_queue_manager_->IsQueueEmpty(queue_index);
}
+void SchedulerHelper::SetQueuePriority(
+ size_t queue_index,
+ PrioritizingTaskQueueSelector::QueuePriority priority) {
+ CheckOnValidThread();
+ return task_queue_selector_->SetQueuePriority(queue_index, priority);
+}
+
+void SchedulerHelper::EnableQueue(
+ size_t queue_index,
+ PrioritizingTaskQueueSelector::QueuePriority priority) {
+ CheckOnValidThread();
+ task_queue_selector_->EnableQueue(queue_index, priority);
+}
+
+void SchedulerHelper::DisableQueue(size_t queue_index) {
+ CheckOnValidThread();
+ task_queue_selector_->DisableQueue(queue_index);
+}
+
+bool SchedulerHelper::IsQueueEnabled(size_t queue_index) const {
+ CheckOnValidThread();
+ return task_queue_selector_->IsQueueEnabled(queue_index);
+}
+
// static
const char* SchedulerHelper::TaskQueueIdToString(QueueId queue_id) {
switch (queue_id) {
diff --git a/components/scheduler/child/scheduler_helper.h b/components/scheduler/child/scheduler_helper.h
index 7ace694..3cb6997 100644
--- a/components/scheduler/child/scheduler_helper.h
+++ b/components/scheduler/child/scheduler_helper.h
@@ -6,6 +6,7 @@
#define COMPONENTS_SCHEDULER_CHILD_SCHEDULER_HELPER_H_
#include "components/scheduler/child/cancelable_closure_holder.h"
+#include "components/scheduler/child/prioritizing_task_queue_selector.h"
#include "components/scheduler/child/single_thread_idle_task_runner.h"
#include "components/scheduler/child/task_queue_manager.h"
#include "components/scheduler/child/time_source.h"
@@ -13,7 +14,6 @@
namespace scheduler {
-class PrioritizingTaskQueueSelector;
class NestableSingleThreadTaskRunner;
// Common scheduler functionality for Default and Idle tasks.
@@ -159,11 +159,16 @@ class SCHEDULER_EXPORT SchedulerHelper {
// Accessor methods.
base::TimeTicks Now() const;
IdlePeriodState SchedulerIdlePeriodState() const;
- PrioritizingTaskQueueSelector* SchedulerTaskQueueSelector() const;
scoped_refptr<base::SingleThreadTaskRunner> TaskRunnerForQueue(
size_t queue_index) const;
void SetQueueName(size_t queue_index, const char* name);
bool IsQueueEmpty(size_t queue_index) const;
+ void SetQueuePriority(size_t queue_index,
+ PrioritizingTaskQueueSelector::QueuePriority priority);
+ void EnableQueue(size_t queue_index,
+ PrioritizingTaskQueueSelector::QueuePriority priority);
+ void DisableQueue(size_t queue_index);
+ bool IsQueueEnabled(size_t queue_index) const;
// Test helpers.
void SetTimeSourceForTesting(scoped_ptr<TimeSource> time_source);
diff --git a/components/scheduler/renderer/renderer_scheduler_impl.cc b/components/scheduler/renderer/renderer_scheduler_impl.cc
index 5ed3d6d..4ca86ec 100644
--- a/components/scheduler/renderer/renderer_scheduler_impl.cc
+++ b/components/scheduler/renderer/renderer_scheduler_impl.cc
@@ -362,44 +362,41 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) {
new_policy == current_policy_)
return;
- PrioritizingTaskQueueSelector* task_queue_selector =
- helper_.SchedulerTaskQueueSelector();
bool policy_disables_timers = false;
switch (new_policy) {
case Policy::COMPOSITOR_PRIORITY:
- task_queue_selector->SetQueuePriority(
- COMPOSITOR_TASK_QUEUE, PrioritizingTaskQueueSelector::HIGH_PRIORITY);
+ helper_.SetQueuePriority(COMPOSITOR_TASK_QUEUE,
+ PrioritizingTaskQueueSelector::HIGH_PRIORITY);
// TODO(scheduler-dev): Add a task priority between HIGH and BEST_EFFORT
// that still has some guarantee of running.
- task_queue_selector->SetQueuePriority(
+ helper_.SetQueuePriority(
LOADING_TASK_QUEUE,
PrioritizingTaskQueueSelector::BEST_EFFORT_PRIORITY);
break;
case Policy::TOUCHSTART_PRIORITY:
- task_queue_selector->SetQueuePriority(
- COMPOSITOR_TASK_QUEUE, PrioritizingTaskQueueSelector::HIGH_PRIORITY);
- task_queue_selector->DisableQueue(LOADING_TASK_QUEUE);
+ helper_.SetQueuePriority(COMPOSITOR_TASK_QUEUE,
+ PrioritizingTaskQueueSelector::HIGH_PRIORITY);
+ helper_.DisableQueue(LOADING_TASK_QUEUE);
// TODO(alexclarke): Set policy_disables_timers once the blink TimerBase
// refactor is safely landed.
break;
case Policy::NORMAL:
- task_queue_selector->SetQueuePriority(
- COMPOSITOR_TASK_QUEUE,
- PrioritizingTaskQueueSelector::NORMAL_PRIORITY);
- task_queue_selector->SetQueuePriority(
- LOADING_TASK_QUEUE, PrioritizingTaskQueueSelector::NORMAL_PRIORITY);
+ helper_.SetQueuePriority(COMPOSITOR_TASK_QUEUE,
+ PrioritizingTaskQueueSelector::NORMAL_PRIORITY);
+ helper_.SetQueuePriority(LOADING_TASK_QUEUE,
+ PrioritizingTaskQueueSelector::NORMAL_PRIORITY);
break;
}
if (timer_queue_suspend_count_ != 0 || policy_disables_timers) {
- task_queue_selector->DisableQueue(TIMER_TASK_QUEUE);
+ helper_.DisableQueue(TIMER_TASK_QUEUE);
} else {
- helper_.SchedulerTaskQueueSelector()->SetQueuePriority(
- TIMER_TASK_QUEUE, PrioritizingTaskQueueSelector::NORMAL_PRIORITY);
+ helper_.SetQueuePriority(TIMER_TASK_QUEUE,
+ PrioritizingTaskQueueSelector::NORMAL_PRIORITY);
}
- DCHECK(task_queue_selector->IsQueueEnabled(COMPOSITOR_TASK_QUEUE));
+ DCHECK(helper_.IsQueueEnabled(COMPOSITOR_TASK_QUEUE));
if (new_policy != Policy::TOUCHSTART_PRIORITY)
- DCHECK(task_queue_selector->IsQueueEnabled(LOADING_TASK_QUEUE));
+ DCHECK(helper_.IsQueueEnabled(LOADING_TASK_QUEUE));
current_policy_ = new_policy;
@@ -507,8 +504,7 @@ void RendererSchedulerImpl::SuspendTimerQueue() {
helper_.CheckOnValidThread();
timer_queue_suspend_count_++;
ForceUpdatePolicy();
- DCHECK(
- !helper_.SchedulerTaskQueueSelector()->IsQueueEnabled(TIMER_TASK_QUEUE));
+ DCHECK(!helper_.IsQueueEnabled(TIMER_TASK_QUEUE));
}
void RendererSchedulerImpl::ResumeTimerQueue() {