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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another GYP fix Created 4 years, 5 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 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 #include "components/scheduler/renderer/throttling_helper.h" 5 #include "platform/scheduler/renderer/throttling_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/scheduler/base/real_time_domain.h" 8 #include "platform/scheduler/base/real_time_domain.h"
9 #include "components/scheduler/child/scheduler_tqm_delegate.h" 9 #include "platform/scheduler/child/scheduler_tqm_delegate.h"
10 #include "components/scheduler/renderer/renderer_scheduler_impl.h" 10 #include "platform/scheduler/renderer/renderer_scheduler_impl.h"
11 #include "components/scheduler/renderer/throttled_time_domain.h" 11 #include "platform/scheduler/renderer/throttled_time_domain.h"
12 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" 12 #include "platform/scheduler/renderer/web_frame_scheduler_impl.h"
13 #include "third_party/WebKit/public/platform/WebFrameScheduler.h" 13 #include "public/platform/WebFrameScheduler.h"
14 14
15 namespace blink {
15 namespace scheduler { 16 namespace scheduler {
16 17
17 ThrottlingHelper::ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler, 18 ThrottlingHelper::ThrottlingHelper(RendererSchedulerImpl* renderer_scheduler,
18 const char* tracing_category) 19 const char* tracing_category)
19 : task_runner_(renderer_scheduler->ControlTaskRunner()), 20 : task_runner_(renderer_scheduler->ControlTaskRunner()),
20 renderer_scheduler_(renderer_scheduler), 21 renderer_scheduler_(renderer_scheduler),
21 tick_clock_(renderer_scheduler->tick_clock()), 22 tick_clock_(renderer_scheduler->tick_clock()),
22 tracing_category_(tracing_category), 23 tracing_category_(tracing_category),
23 time_domain_(new ThrottledTimeDomain(this, tick_clock_)), 24 time_domain_(new ThrottledTimeDomain(this, tick_clock_)),
24 weak_factory_(this) { 25 weak_factory_(this) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, now, 155 MaybeSchedulePumpThrottledTasksLocked(FROM_HERE, now,
155 next_scheduled_delayed_task); 156 next_scheduled_delayed_task);
156 } 157 }
157 } 158 }
158 159
159 /* static */ 160 /* static */
160 base::TimeTicks ThrottlingHelper::ThrottledRunTime( 161 base::TimeTicks ThrottlingHelper::ThrottledRunTime(
161 base::TimeTicks unthrottled_runtime) { 162 base::TimeTicks unthrottled_runtime) {
162 const base::TimeDelta one_second = base::TimeDelta::FromSeconds(1); 163 const base::TimeDelta one_second = base::TimeDelta::FromSeconds(1);
163 return unthrottled_runtime + one_second - 164 return unthrottled_runtime + one_second -
164 ((unthrottled_runtime - base::TimeTicks()) % one_second); 165 ((unthrottled_runtime - base::TimeTicks()) % one_second);
165 } 166 }
166 167
167 void ThrottlingHelper::MaybeSchedulePumpThrottledTasksLocked( 168 void ThrottlingHelper::MaybeSchedulePumpThrottledTasksLocked(
168 const tracked_objects::Location& from_here, 169 const tracked_objects::Location& from_here,
169 base::TimeTicks now, 170 base::TimeTicks now,
170 base::TimeTicks unthrottled_runtime) { 171 base::TimeTicks unthrottled_runtime) {
171 base::TimeTicks throttled_runtime = 172 base::TimeTicks throttled_runtime =
172 ThrottledRunTime(std::max(now, unthrottled_runtime)); 173 ThrottledRunTime(std::max(now, unthrottled_runtime));
173 // If there is a pending call to PumpThrottledTasks and it's sooner than 174 // If there is a pending call to PumpThrottledTasks and it's sooner than
174 // |unthrottled_runtime| then return. 175 // |unthrottled_runtime| then return.
175 if (!pending_pump_throttled_tasks_runtime_.is_null() && 176 if (!pending_pump_throttled_tasks_runtime_.is_null() &&
176 throttled_runtime >= pending_pump_throttled_tasks_runtime_) { 177 throttled_runtime >= pending_pump_throttled_tasks_runtime_) {
177 return; 178 return;
178 } 179 }
179 180
180 pending_pump_throttled_tasks_runtime_ = throttled_runtime; 181 pending_pump_throttled_tasks_runtime_ = throttled_runtime;
181 182
182 suspend_timers_when_backgrounded_closure_.Cancel(); 183 suspend_timers_when_backgrounded_closure_.Cancel();
183 184
184 base::TimeDelta delay = pending_pump_throttled_tasks_runtime_ - now; 185 base::TimeDelta delay = pending_pump_throttled_tasks_runtime_ - now;
185 TRACE_EVENT1(tracing_category_, 186 TRACE_EVENT1(tracing_category_,
186 "ThrottlingHelper::MaybeSchedulePumpThrottledTasksLocked", 187 "ThrottlingHelper::MaybeSchedulePumpThrottledTasksLocked",
187 "delay_till_next_pump_ms", delay.InMilliseconds()); 188 "delay_till_next_pump_ms", delay.InMilliseconds());
188 task_runner_->PostDelayedTask( 189 task_runner_->PostDelayedTask(
189 from_here, suspend_timers_when_backgrounded_closure_.callback(), delay); 190 from_here, suspend_timers_when_backgrounded_closure_.callback(), delay);
190 } 191 }
191 192
192 } // namespace scheduler 193 } // namespace scheduler
194 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698