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

Side by Side Diff: content/child/scheduler/single_thread_idle_task_runner.h

Issue 1025323003: Introduce a SchedulerHelper in content/child/scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sami's suggestions 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ 5 #ifndef CONTENT_CHILD_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_
6 #define CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ 6 #define CONTENT_CHILD_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 // A SingleThreadIdleTaskRunner is a task runner for running idle tasks. Idle 16 // A SingleThreadIdleTaskRunner is a task runner for running idle tasks. Idle
17 // tasks have an unbound argument which is bound to a deadline 17 // tasks have an unbound argument which is bound to a deadline
18 // (in base::TimeTicks) when they are run. The idle task is expected to 18 // (in base::TimeTicks) when they are run. The idle task is expected to
19 // complete by this deadline. 19 // complete by this deadline.
20 class SingleThreadIdleTaskRunner 20 class SingleThreadIdleTaskRunner
21 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> { 21 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> {
22 public: 22 public:
23 typedef base::Callback<void(base::TimeTicks)> IdleTask; 23 typedef base::Callback<void(base::TimeTicks)> IdleTask;
24 24
25 SingleThreadIdleTaskRunner( 25 SingleThreadIdleTaskRunner(
26 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner, 26 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner,
27 scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner, 27 scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner,
28 base::Callback<void(base::TimeTicks*)> deadline_supplier); 28 base::Callback<void(base::TimeTicks*)> deadline_supplier,
29 const char* tracing_category);
rmcilroy 2015/03/27 14:34:40 same comment about trace_category
alex clarke (OOO till 29th) 2015/03/27 16:09:17 Done.
29 30
30 virtual void PostIdleTask(const tracked_objects::Location& from_here, 31 virtual void PostIdleTask(const tracked_objects::Location& from_here,
31 const IdleTask& idle_task); 32 const IdleTask& idle_task);
32 33
33 virtual void PostNonNestableIdleTask( 34 virtual void PostNonNestableIdleTask(
34 const tracked_objects::Location& from_here, 35 const tracked_objects::Location& from_here,
35 const IdleTask& idle_task); 36 const IdleTask& idle_task);
36 37
37 virtual void PostIdleTaskAfterWakeup( 38 virtual void PostIdleTaskAfterWakeup(
38 const tracked_objects::Location& from_here, 39 const tracked_objects::Location& from_here,
39 const IdleTask& idle_task); 40 const IdleTask& idle_task);
40 41
41 bool RunsTasksOnCurrentThread() const; 42 bool RunsTasksOnCurrentThread() const;
42 43
43 protected: 44 protected:
44 virtual ~SingleThreadIdleTaskRunner(); 45 virtual ~SingleThreadIdleTaskRunner();
45 46
46 private: 47 private:
47 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>; 48 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>;
48 49
49 void RunTask(IdleTask idle_task); 50 void RunTask(IdleTask idle_task);
50 51
51 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner_; 52 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner_;
52 scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner_; 53 scoped_refptr<base::SingleThreadTaskRunner> after_wakeup_task_runner_;
53 base::Callback<void(base::TimeTicks*)> deadline_supplier_; 54 base::Callback<void(base::TimeTicks*)> deadline_supplier_;
55 const char* tracing_category_;
54 DISALLOW_COPY_AND_ASSIGN(SingleThreadIdleTaskRunner); 56 DISALLOW_COPY_AND_ASSIGN(SingleThreadIdleTaskRunner);
55 }; 57 };
56 58
57 } // namespace content 59 } // namespace content
58 60
59 #endif // CONTENT_RENDERER_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_ 61 #endif // CONTENT_CHILD_SCHEDULER_SINGLE_THREAD_IDLE_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698