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

Side by Side Diff: components/scheduler/base/task_queue.h

Issue 1441073006: Move throttling of background timers into the renderer scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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 COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 5 #ifndef COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 6 #define COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "components/scheduler/scheduler_export.h" 10 #include "components/scheduler/scheduler_export.h"
11 11
12 namespace scheduler { 12 namespace scheduler {
13 class TimeDomain; 13 class TimeDomain;
14 14
15 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner { 15 class SCHEDULER_EXPORT TaskQueue : public base::SingleThreadTaskRunner {
16 public: 16 public:
17 TaskQueue() {} 17 TaskQueue() {}
18 18
19 // Unregisters the task queue after which no tasks posted to it will run and 19 // Unregisters the task queue after which no tasks posted to it will run and
20 // the TaskQueueManager's reference to it will be released soon. 20 // the TaskQueueManager's reference to it will be released soon.
21 virtual void UnregisterTaskQueue() = 0; 21 virtual void UnregisterTaskQueue() = 0;
22 22
23 // Post a delayed task at an absolute desired run time instead of a time
24 // delta from the current time.
25 virtual bool PostDelayedTaskAt(const tracked_objects::Location& from_here,
26 const base::Closure& task,
27 base::TimeTicks desired_run_time) = 0;
28
29 enum QueuePriority { 23 enum QueuePriority {
30 // Queues with control priority will run before any other queue, and will 24 // Queues with control priority will run before any other queue, and will
31 // explicitly starve other queues. Typically this should only be used for 25 // explicitly starve other queues. Typically this should only be used for
32 // private queues which perform control operations. 26 // private queues which perform control operations.
33 CONTROL_PRIORITY, 27 CONTROL_PRIORITY,
34 // Queues with high priority will be selected preferentially over normal or 28 // Queues with high priority will be selected preferentially over normal or
35 // best effort queues. The selector will ensure that high priority queues 29 // best effort queues. The selector will ensure that high priority queues
36 // cannot completely starve normal priority queues. 30 // cannot completely starve normal priority queues.
37 HIGH_PRIORITY, 31 HIGH_PRIORITY,
38 // Queues with normal priority are the default. 32 // Queues with normal priority are the default.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 TimeDomain* time_domain; 132 TimeDomain* time_domain;
139 bool should_notify_observers; 133 bool should_notify_observers;
140 }; 134 };
141 135
142 // Returns true if the queue priority is not 136 // Returns true if the queue priority is not
143 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the 137 // TaskQueueSelector::DISABLED_PRIORITY. NOTE this must be called on the
144 // thread this TaskQueue was created by. 138 // thread this TaskQueue was created by.
145 virtual bool IsQueueEnabled() const = 0; 139 virtual bool IsQueueEnabled() const = 0;
146 140
147 // Returns true if there no tasks in either the work or incoming task queue. 141 // Returns true if there no tasks in either the work or incoming task queue.
142 // This method ignores delayed tasks that are scheduled to run in the future.
148 // Note that this function involves taking a lock, so calling it has some 143 // Note that this function involves taking a lock, so calling it has some
149 // overhead. NOTE this must be called on the thread this TaskQueue was created 144 // overhead. NOTE this must be called on the thread this TaskQueue was created
150 // by. 145 // by.
151 virtual bool IsQueueEmpty() const; 146 virtual bool HasPendingImmediateTask() const;
Sami 2015/11/25 17:12:25 Just remembered that we also have GetQueueState().
alex clarke (OOO till 29th) 2015/11/26 18:43:27 I mostly did that :) I suppose I could get rid of
147
148 // Returns true if there is one or more delayed tasks scheduled to run in the
149 // future. Can be called on any thread.
150 virtual bool HasPendingDelayedTask() const = 0;
152 151
153 // Returns the QueueState. Note that this function involves taking a lock, so 152 // Returns the QueueState. Note that this function involves taking a lock, so
154 // calling it has some overhead. 153 // calling it has some overhead.
155 virtual QueueState GetQueueState() const = 0; 154 virtual QueueState GetQueueState() const = 0;
156 155
157 // Can be called on any thread. 156 // Can be called on any thread.
158 virtual const char* GetName() const = 0; 157 virtual const char* GetName() const = 0;
159 158
160 // Set the priority of the queue to |priority|. NOTE this must be called on 159 // Set the priority of the queue to |priority|. NOTE this must be called on
161 // the thread this TaskQueue was created by. 160 // the thread this TaskQueue was created by.
(...skipping 25 matching lines...) Expand all
187 186
188 protected: 187 protected:
189 ~TaskQueue() override {} 188 ~TaskQueue() override {}
190 189
191 DISALLOW_COPY_AND_ASSIGN(TaskQueue); 190 DISALLOW_COPY_AND_ASSIGN(TaskQueue);
192 }; 191 };
193 192
194 } // namespace scheduler 193 } // namespace scheduler
195 194
196 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_ 195 #endif // COMPONENTS_SCHEDULER_BASE_TASK_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698