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

Side by Side Diff: content/renderer/scheduler/renderer_scheduler_impl.h

Issue 994833003: Prevent multiple pending UpdatePolicy tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak Created 5 years, 9 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_RENDERER_SCHEDULER_IMPL_H_ 5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
7 7
8 #include "base/atomicops.h" 8 #include "base/atomicops.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override; 46 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer) override;
47 void RemoveTaskObserver( 47 void RemoveTaskObserver(
48 base::MessageLoop::TaskObserver* task_observer) override; 48 base::MessageLoop::TaskObserver* task_observer) override;
49 void Shutdown() override; 49 void Shutdown() override;
50 50
51 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source); 51 void SetTimeSourceForTesting(scoped_refptr<cc::TestNowSource> time_source);
52 void SetWorkBatchSizeForTesting(size_t work_batch_size); 52 void SetWorkBatchSizeForTesting(size_t work_batch_size);
53 53
54 private: 54 private:
55 friend class RendererSchedulerImplTest; 55 friend class RendererSchedulerImplTest;
56 friend class MockRendererSchedulerImpl;
56 57
57 // Keep RendererSchedulerImpl::TaskQueueIdToString in sync with this enum. 58 // Keep RendererSchedulerImpl::TaskQueueIdToString in sync with this enum.
58 enum QueueId { 59 enum QueueId {
59 DEFAULT_TASK_QUEUE, 60 DEFAULT_TASK_QUEUE,
60 COMPOSITOR_TASK_QUEUE, 61 COMPOSITOR_TASK_QUEUE,
61 LOADING_TASK_QUEUE, 62 LOADING_TASK_QUEUE,
62 IDLE_TASK_QUEUE, 63 IDLE_TASK_QUEUE,
63 CONTROL_TASK_QUEUE, 64 CONTROL_TASK_QUEUE,
64 CONTROL_TASK_AFTER_WAKEUP_QUEUE, 65 CONTROL_TASK_AFTER_WAKEUP_QUEUE,
65 // Must be the last entry. 66 // Must be the last entry.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // The time we should stay in a priority-escalated mode after an input event. 112 // The time we should stay in a priority-escalated mode after an input event.
112 static const int kPriorityEscalationAfterInputMillis = 100; 113 static const int kPriorityEscalationAfterInputMillis = 100;
113 114
114 // IdleTaskDeadlineSupplier Implementation: 115 // IdleTaskDeadlineSupplier Implementation:
115 void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const; 116 void CurrentIdleTaskDeadlineCallback(base::TimeTicks* deadline_out) const;
116 117
117 // Returns the current scheduler policy. Must be called from the main thread. 118 // Returns the current scheduler policy. Must be called from the main thread.
118 Policy SchedulerPolicy() const; 119 Policy SchedulerPolicy() const;
119 120
120 // Posts a call to UpdatePolicy on the control runner to be run after |delay| 121 // Posts a call to UpdatePolicy on the control runner to be run after |delay|
121 void PostUpdatePolicyOnControlRunner(base::TimeDelta delay); 122 // Ensures that there can only be one pending delayed and one non-delayed
123 // UpdatePolicy task.
124 void PostUpdatePolicyOnControlRunnerLocked(base::TimeDelta delay);
Sami 2015/03/10 16:19:38 Should we call this MaybePost... to match the othe
122 125
123 // Update the policy if a new signal has arrived. Must be called from the main 126 // Update the policy if a new signal has arrived. Must be called from the main
124 // thread. 127 // thread.
125 void MaybeUpdatePolicy(); 128 void MaybeUpdatePolicy();
126 129
127 // Updates the scheduler policy. Must be called from the main thread. 130 // Updates the scheduler policy. Must be called from the main thread. If
128 void UpdatePolicy(); 131 // |clear_pending_non_delayed_update_policy| is true then
132 // pending_non_delayed_update_policy_ will be set to false.
133 virtual void UpdatePolicy(bool clear_pending_non_delayed_update_policy);
129 134
130 // Helper for computing the new policy. |new_policy_duration| will be filled 135 // Helper for computing the new policy. |new_policy_duration| will be filled
131 // with the amount of time after which the policy should be updated again. If 136 // with the amount of time after which the policy should be updated again. If
132 // the duration is zero, a new policy update will not be scheduled. Must be 137 // the duration is zero, a new policy update will not be scheduled. Must be
133 // called with |incoming_signals_lock_| held. 138 // called with |incoming_signals_lock_| held.
134 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration); 139 Policy ComputeNewPolicy(base::TimeDelta* new_policy_duration);
135 140
136 // An input event of some sort happened, the policy may need updating. 141 // An input event of some sort happened, the policy may need updating.
137 void UpdateForInputEvent(blink::WebInputEvent::Type type); 142 void UpdateForInputEvent(blink::WebInputEvent::Type type);
138 143
(...skipping 13 matching lines...) Expand all
152 scoped_ptr<TaskQueueManager> task_queue_manager_; 157 scoped_ptr<TaskQueueManager> task_queue_manager_;
153 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_; 158 scoped_refptr<base::SingleThreadTaskRunner> control_task_runner_;
154 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_; 159 scoped_refptr<base::SingleThreadTaskRunner> control_task_after_wakeup_runner_;
155 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_; 160 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
156 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 161 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
157 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_; 162 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner_;
158 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_; 163 scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_;
159 164
160 base::Closure update_policy_closure_; 165 base::Closure update_policy_closure_;
161 CancelableClosureHolder end_idle_period_closure_; 166 CancelableClosureHolder end_idle_period_closure_;
167 CancelableClosureHolder delayed_update_policy_closure_;
168 bool pending_non_delayed_update_policy_;
162 169
163 // Don't access current_policy_ directly, instead use SchedulerPolicy(). 170 // Don't access current_policy_ directly, instead use SchedulerPolicy().
164 Policy current_policy_; 171 Policy current_policy_;
165 172
166 base::TimeTicks estimated_next_frame_begin_; 173 base::TimeTicks estimated_next_frame_begin_;
167 174
168 // The incoming_signals_lock_ mutex protects access to all variables in the 175 // The incoming_signals_lock_ mutex protects access to all variables in the
169 // (contiguous) block below. 176 // (contiguous) block below.
170 base::Lock incoming_signals_lock_; 177 base::Lock incoming_signals_lock_;
171 base::TimeTicks last_input_receipt_time_on_compositor_; 178 base::TimeTicks last_input_receipt_time_on_compositor_;
172 base::TimeTicks last_input_process_time_on_main_; 179 base::TimeTicks last_input_process_time_on_main_;
173 blink::WebInputEvent::Type last_input_type_; 180 blink::WebInputEvent::Type last_input_type_;
174 InputStreamState input_stream_state_; 181 InputStreamState input_stream_state_;
175 PollableNeedsUpdateFlag policy_may_need_update_; 182 PollableNeedsUpdateFlag policy_may_need_update_;
176 183
177 scoped_refptr<cc::TestNowSource> time_source_; 184 scoped_refptr<cc::TestNowSource> time_source_;
178 185
179 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_; 186 base::WeakPtr<RendererSchedulerImpl> weak_renderer_scheduler_ptr_;
180 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_; 187 base::WeakPtrFactory<RendererSchedulerImpl> weak_factory_;
181 188
182 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl); 189 DISALLOW_COPY_AND_ASSIGN(RendererSchedulerImpl);
183 }; 190 };
184 191
185 } // namespace content 192 } // namespace content
186 193
187 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_ 194 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698