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

Side by Side Diff: components/scheduler/child/scheduler_helper.cc

Issue 1058873010: Move blink scheduler implementation into a component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 5 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/child/scheduler/scheduler_helper.h" 5 #include "components/scheduler/child/scheduler_helper.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "base/trace_event/trace_event_argument.h" 8 #include "base/trace_event/trace_event_argument.h"
9 #include "content/child/scheduler/nestable_single_thread_task_runner.h" 9 #include "components/scheduler/child/nestable_single_thread_task_runner.h"
10 #include "content/child/scheduler/prioritizing_task_queue_selector.h" 10 #include "components/scheduler/child/prioritizing_task_queue_selector.h"
11 #include "content/child/scheduler/time_source.h" 11 #include "components/scheduler/child/time_source.h"
12 12
13 namespace content { 13 namespace scheduler {
14 14
15 SchedulerHelper::SchedulerHelper( 15 SchedulerHelper::SchedulerHelper(
16 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner, 16 scoped_refptr<NestableSingleThreadTaskRunner> main_task_runner,
17 SchedulerHelperDelegate* scheduler_helper_delegate, 17 SchedulerHelperDelegate* scheduler_helper_delegate,
18 const char* tracing_category, 18 const char* tracing_category,
19 const char* disabled_by_default_tracing_category, 19 const char* disabled_by_default_tracing_category,
20 const char* idle_period_tracing_name, 20 const char* idle_period_tracing_name,
21 size_t total_task_queue_count, 21 size_t total_task_queue_count,
22 base::TimeDelta required_quiescence_duration_before_long_idle_period) 22 base::TimeDelta required_quiescence_duration_before_long_idle_period)
23 : task_queue_selector_(new PrioritizingTaskQueueSelector()), 23 : task_queue_selector_(new PrioritizingTaskQueueSelector()),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 scheduler_helper_delegate_->IsNotQuiescent(); 197 scheduler_helper_delegate_->IsNotQuiescent();
198 return; 198 return;
199 } 199 }
200 200
201 base::TimeTicks now(Now()); 201 base::TimeTicks now(Now());
202 base::TimeDelta next_long_idle_period_delay; 202 base::TimeDelta next_long_idle_period_delay;
203 IdlePeriodState new_idle_period_state = 203 IdlePeriodState new_idle_period_state =
204 ComputeNewLongIdlePeriodState(now, &next_long_idle_period_delay); 204 ComputeNewLongIdlePeriodState(now, &next_long_idle_period_delay);
205 if (IsInIdlePeriod(new_idle_period_state)) { 205 if (IsInIdlePeriod(new_idle_period_state)) {
206 StartIdlePeriod(new_idle_period_state, now, 206 StartIdlePeriod(new_idle_period_state, now,
207 now + next_long_idle_period_delay, 207 now + next_long_idle_period_delay, false);
208 false);
209 } 208 }
210 209
211 if (task_queue_manager_->IsQueueEmpty(QueueId::IDLE_TASK_QUEUE)) { 210 if (task_queue_manager_->IsQueueEmpty(QueueId::IDLE_TASK_QUEUE)) {
212 // If there are no current idle tasks then post the call to initiate the 211 // If there are no current idle tasks then post the call to initiate the
213 // next idle for execution after wakeup (at which point after-wakeup idle 212 // next idle for execution after wakeup (at which point after-wakeup idle
214 // tasks might be eligible to run or more idle tasks posted). 213 // tasks might be eligible to run or more idle tasks posted).
215 control_task_after_wakeup_runner_->PostDelayedTask( 214 control_task_after_wakeup_runner_->PostDelayedTask(
216 FROM_HERE, 215 FROM_HERE,
217 enable_next_long_idle_period_after_wakeup_closure_.callback(), 216 enable_next_long_idle_period_after_wakeup_closure_.callback(),
218 next_long_idle_period_delay); 217 next_long_idle_period_delay);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 DCHECK(IsInIdlePeriod(new_state)); 256 DCHECK(IsInIdlePeriod(new_state));
258 257
259 task_queue_selector_->EnableQueue( 258 task_queue_selector_->EnableQueue(
260 QueueId::IDLE_TASK_QUEUE, 259 QueueId::IDLE_TASK_QUEUE,
261 PrioritizingTaskQueueSelector::BEST_EFFORT_PRIORITY); 260 PrioritizingTaskQueueSelector::BEST_EFFORT_PRIORITY);
262 task_queue_manager_->PumpQueue(QueueId::IDLE_TASK_QUEUE); 261 task_queue_manager_->PumpQueue(QueueId::IDLE_TASK_QUEUE);
263 idle_period_state_ = new_state; 262 idle_period_state_ = new_state;
264 263
265 idle_period_deadline_ = idle_period_deadline; 264 idle_period_deadline_ = idle_period_deadline;
266 if (post_end_idle_period) { 265 if (post_end_idle_period) {
267 control_task_runner_->PostDelayedTask( 266 control_task_runner_->PostDelayedTask(FROM_HERE,
268 FROM_HERE, 267 end_idle_period_closure_.callback(),
269 end_idle_period_closure_.callback(), 268 idle_period_deadline_ - now);
270 idle_period_deadline_ - now);
271 } 269 }
272 } 270 }
273 271
274 void SchedulerHelper::EndIdlePeriod() { 272 void SchedulerHelper::EndIdlePeriod() {
275 CheckOnValidThread(); 273 CheckOnValidThread();
276 274
277 end_idle_period_closure_.Cancel(); 275 end_idle_period_closure_.Cancel();
278 enable_next_long_idle_period_closure_.Cancel(); 276 enable_next_long_idle_period_closure_.Cancel();
279 enable_next_long_idle_period_after_wakeup_closure_.Cancel(); 277 enable_next_long_idle_period_after_wakeup_closure_.Cancel();
280 278
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 324
327 TaskQueueManager* SchedulerHelper::GetTaskQueueManagerForTesting() { 325 TaskQueueManager* SchedulerHelper::GetTaskQueueManagerForTesting() {
328 CheckOnValidThread(); 326 CheckOnValidThread();
329 return task_queue_manager_.get(); 327 return task_queue_manager_.get();
330 } 328 }
331 329
332 base::TimeTicks SchedulerHelper::Now() const { 330 base::TimeTicks SchedulerHelper::Now() const {
333 return time_source_->Now(); 331 return time_source_->Now();
334 } 332 }
335 333
336 SchedulerHelper::IdlePeriodState 334 SchedulerHelper::IdlePeriodState SchedulerHelper::SchedulerIdlePeriodState()
337 SchedulerHelper::SchedulerIdlePeriodState() const { 335 const {
338 return idle_period_state_; 336 return idle_period_state_;
339 } 337 }
340 338
341 PrioritizingTaskQueueSelector* 339 PrioritizingTaskQueueSelector* SchedulerHelper::SchedulerTaskQueueSelector()
342 SchedulerHelper::SchedulerTaskQueueSelector() const { 340 const {
343 return task_queue_selector_.get(); 341 return task_queue_selector_.get();
344 } 342 }
345 343
346 scoped_refptr<base::SingleThreadTaskRunner> SchedulerHelper::TaskRunnerForQueue( 344 scoped_refptr<base::SingleThreadTaskRunner> SchedulerHelper::TaskRunnerForQueue(
347 size_t queue_index) const { 345 size_t queue_index) const {
348 CheckOnValidThread(); 346 CheckOnValidThread();
349 return task_queue_manager_->TaskRunnerForQueue(queue_index); 347 return task_queue_manager_->TaskRunnerForQueue(queue_index);
350 } 348 }
351 349
352 void SchedulerHelper::SetQueueName(size_t queue_index, const char* name) { 350 void SchedulerHelper::SetQueueName(size_t queue_index, const char* name) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 task_queue_manager_->AddTaskObserver(task_observer); 401 task_queue_manager_->AddTaskObserver(task_observer);
404 } 402 }
405 403
406 void SchedulerHelper::RemoveTaskObserver( 404 void SchedulerHelper::RemoveTaskObserver(
407 base::MessageLoop::TaskObserver* task_observer) { 405 base::MessageLoop::TaskObserver* task_observer) {
408 CheckOnValidThread(); 406 CheckOnValidThread();
409 if (task_queue_manager_) 407 if (task_queue_manager_)
410 task_queue_manager_->RemoveTaskObserver(task_observer); 408 task_queue_manager_->RemoveTaskObserver(task_observer);
411 } 409 }
412 410
413 } // namespace content 411 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/scheduler_helper.h ('k') | components/scheduler/child/scheduler_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698