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

Side by Side Diff: third_party/WebKit/public/platform/scheduler/base/task_queue.h

Issue 2540663002: Add the concept of QueueEnabledVoters to blink scheduler TaskQueue (Closed)
Patch Set: Added a couple of extra tests Created 4 years 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 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 5 #ifndef THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 6 #define THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return *this; 110 return *this;
111 } 111 }
112 112
113 QueueType type; 113 QueueType type;
114 bool should_monitor_quiescence; 114 bool should_monitor_quiescence;
115 TimeDomain* time_domain; 115 TimeDomain* time_domain;
116 bool should_notify_observers; 116 bool should_notify_observers;
117 bool should_report_when_execution_blocked; 117 bool should_report_when_execution_blocked;
118 }; 118 };
119 119
120 // Enable or disable task execution for this queue. NOTE this must be called 120 // An interface that lets the owner vote on whether or not the associated
121 // on the thread this TaskQueue was created by. 121 // TaskQueue should be enabled.
122 virtual void SetQueueEnabled(bool enabled) = 0; 122 class QueueEnabledVoter {
Sami 2016/11/29 14:45:17 I think "voter" works but just to throw another (s
alex clarke (OOO till 29th) 2016/11/29 16:49:11 Acknowledged.
123 public:
124 QueueEnabledVoter() {}
125 virtual ~QueueEnabledVoter() {}
126
127 // Votes to enable or disable the associated TaskQueue. The TaskQueue will
128 // only be enabled if all the voters agree it should be enabled, or if there
129 // are no voters.
130 // NOTE this must be called on the thread the associated TaskQueue was
131 // created on.
132 virtual void SetQueueEnabled(bool enabled) = 0;
133
134 // Returns the TaskQueue this voter votes on.
135 virtual TaskQueue* GetTaskQueue() const = 0;
Sami 2016/11/29 14:45:17 GetTaskQueueForTest? Doesn't seem like we need thi
alex clarke (OOO till 29th) 2016/11/29 16:49:11 Done.
136
137 private:
138 DISALLOW_COPY_AND_ASSIGN(QueueEnabledVoter);
139 };
140
141 // Returns an interface that allows the caller to vote on whether or not this
142 // TaskQueue is enabled. The TaskQueue will be enabled if there are no voters
143 // or of all agree it should be enabled.
Sami 2016/11/29 14:45:17 s/of/if/
alex clarke (OOO till 29th) 2016/11/29 16:49:11 Done.
144 // NOTE this must be called on the thread this TaskQueue was created by.
145 virtual std::unique_ptr<QueueEnabledVoter> GetQueueEnabledVoter() = 0;
123 146
124 // NOTE this must be called on the thread this TaskQueue was created by. 147 // NOTE this must be called on the thread this TaskQueue was created by.
125 virtual bool IsQueueEnabled() const = 0; 148 virtual bool IsQueueEnabled() const = 0;
126 149
127 // Returns true if the queue is completely empty. 150 // Returns true if the queue is completely empty.
128 virtual bool IsEmpty() const = 0; 151 virtual bool IsEmpty() const = 0;
129 152
130 // Returns the number of pending tasks in the queue. 153 // Returns the number of pending tasks in the queue.
131 virtual size_t GetNumberOfPendingTasks() const = 0; 154 virtual size_t GetNumberOfPendingTasks() const = 0;
132 155
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 protected: 217 protected:
195 ~TaskQueue() override {} 218 ~TaskQueue() override {}
196 219
197 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 220 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
198 }; 221 };
199 222
200 } // namespace scheduler 223 } // namespace scheduler
201 } // namespace blink 224 } // namespace blink
202 225
203 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_ 226 #endif // THIRD_PARTY_WEBKIT_PUBLIC_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698