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

Side by Side Diff: third_party/WebKit/public/platform/scheduler/child/single_thread_idle_task_runner.h

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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 THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_CHILD_SINGLE_THREAD_IDLE_TA SK_RUNNER_H_ 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_CHILD_SINGLE_THREAD_IDLE_TA SK_RUNNER_H_
6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_CHILD_SINGLE_THREAD_IDLE_TA SK_RUNNER_H_ 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_CHILD_SINGLE_THREAD_IDLE_TA SK_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/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 namespace blink { 23 namespace blink {
24 namespace scheduler { 24 namespace scheduler {
25 25
26 // A SingleThreadIdleTaskRunner is a task runner for running idle tasks. Idle 26 // A SingleThreadIdleTaskRunner is a task runner for running idle tasks. Idle
27 // tasks have an unbound argument which is bound to a deadline 27 // tasks have an unbound argument which is bound to a deadline
28 // (in base::TimeTicks) when they are run. The idle task is expected to 28 // (in base::TimeTicks) when they are run. The idle task is expected to
29 // complete by this deadline. 29 // complete by this deadline.
30 class SingleThreadIdleTaskRunner 30 class SingleThreadIdleTaskRunner
31 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> { 31 : public base::RefCountedThreadSafe<SingleThreadIdleTaskRunner> {
32 public: 32 public:
33 typedef base::Callback<void(base::TimeTicks)> IdleTask; 33 typedef base::OnceCallback<void(base::TimeTicks)> IdleTask;
34 34
35 // Used to request idle task deadlines and signal posting of idle tasks. 35 // Used to request idle task deadlines and signal posting of idle tasks.
36 class BLINK_PLATFORM_EXPORT Delegate { 36 class BLINK_PLATFORM_EXPORT Delegate {
37 public: 37 public:
38 Delegate(); 38 Delegate();
39 virtual ~Delegate(); 39 virtual ~Delegate();
40 40
41 // Signals that an idle task has been posted. This will be called on the 41 // Signals that an idle task has been posted. This will be called on the
42 // posting thread, which may not be the same thread as the 42 // posting thread, which may not be the same thread as the
43 // SingleThreadIdleTaskRunner runs on. 43 // SingleThreadIdleTaskRunner runs on.
(...skipping 11 matching lines...) Expand all
55 }; 55 };
56 56
57 // NOTE Category strings must have application lifetime (statics or 57 // NOTE Category strings must have application lifetime (statics or
58 // literals). They may not include " chars. 58 // literals). They may not include " chars.
59 SingleThreadIdleTaskRunner( 59 SingleThreadIdleTaskRunner(
60 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner, 60 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner,
61 Delegate* Delegate, 61 Delegate* Delegate,
62 const char* tracing_category); 62 const char* tracing_category);
63 63
64 virtual void PostIdleTask(const tracked_objects::Location& from_here, 64 virtual void PostIdleTask(const tracked_objects::Location& from_here,
65 const IdleTask& idle_task); 65 IdleTask idle_task);
66 66
67 virtual void PostNonNestableIdleTask( 67 virtual void PostNonNestableIdleTask(
68 const tracked_objects::Location& from_here, 68 const tracked_objects::Location& from_here,
69 const IdleTask& idle_task); 69 IdleTask idle_task);
70 70
71 bool RunsTasksOnCurrentThread() const; 71 bool RunsTasksOnCurrentThread() const;
72 72
73 void SetBlameContext(base::trace_event::BlameContext* blame_context); 73 void SetBlameContext(base::trace_event::BlameContext* blame_context);
74 74
75 protected: 75 protected:
76 virtual ~SingleThreadIdleTaskRunner(); 76 virtual ~SingleThreadIdleTaskRunner();
77 77
78 private: 78 private:
79 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>; 79 friend class base::RefCountedThreadSafe<SingleThreadIdleTaskRunner>;
80 80
81 void RunTask(IdleTask idle_task); 81 void RunTask(IdleTask idle_task);
82 82
83 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner_; 83 scoped_refptr<base::SingleThreadTaskRunner> idle_priority_task_runner_;
84 Delegate* delegate_; // NOT OWNED 84 Delegate* delegate_; // NOT OWNED
85 const char* tracing_category_; 85 const char* tracing_category_;
86 base::trace_event::BlameContext* blame_context_; // Not owned. 86 base::trace_event::BlameContext* blame_context_; // Not owned.
87 base::WeakPtr<SingleThreadIdleTaskRunner> weak_scheduler_ptr_; 87 base::WeakPtr<SingleThreadIdleTaskRunner> weak_scheduler_ptr_;
88 base::WeakPtrFactory<SingleThreadIdleTaskRunner> weak_factory_; 88 base::WeakPtrFactory<SingleThreadIdleTaskRunner> weak_factory_;
89 DISALLOW_COPY_AND_ASSIGN(SingleThreadIdleTaskRunner); 89 DISALLOW_COPY_AND_ASSIGN(SingleThreadIdleTaskRunner);
90 }; 90 };
91 91
92 } // namespace scheduler 92 } // namespace scheduler
93 } // namespace blink 93 } // namespace blink
94 94
95 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_CHILD_SINGLE_THREAD_IDLE _TASK_RUNNER_H_ 95 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_CHILD_SINGLE_THREAD_IDLE _TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698