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

Side by Side Diff: cc/test/ordered_simple_task_runner.cc

Issue 2383473002: [scheduler] Teach scheduler about audio state (Closed)
Patch Set: Rebased Created 4 years, 2 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 #include "cc/test/ordered_simple_task_runner.h" 5 #include "cc/test/ordered_simple_task_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 bool OrderedSimpleTaskRunner::RunUntilTime(base::TimeTicks time) { 242 bool OrderedSimpleTaskRunner::RunUntilTime(base::TimeTicks time) {
243 // If we are not auto advancing, force now forward to the time. 243 // If we are not auto advancing, force now forward to the time.
244 if (!advance_now_ && now_src_->NowTicks() < time) 244 if (!advance_now_ && now_src_->NowTicks() < time)
245 now_src_->Advance(time - now_src_->NowTicks()); 245 now_src_->Advance(time - now_src_->NowTicks());
246 246
247 // Run tasks 247 // Run tasks
248 bool result = RunTasksWhile(NowBefore(time)); 248 bool result = RunTasksWhile(NowBefore(time));
249 249
250 bool has_reached_task_limit = HasPendingTasks() && NextTaskTime() <= time;
251
250 // If the next task is after the stopping time and auto-advancing now, then 252 // If the next task is after the stopping time and auto-advancing now, then
251 // force time to be the stopping time. 253 // force time to be the stopping time.
252 if (!result && advance_now_ && now_src_->NowTicks() < time) { 254 if (!has_reached_task_limit && advance_now_ && now_src_->NowTicks() < time) {
253 now_src_->Advance(time - now_src_->NowTicks()); 255 now_src_->Advance(time - now_src_->NowTicks());
254 } 256 }
255 257
256 return result; 258 return result;
257 } 259 }
258 260
259 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { 261 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) {
260 return RunUntilTime(now_src_->NowTicks() + period); 262 return RunUntilTime(now_src_->NowTicks() + period);
261 } 263 }
262 264
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 338
337 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { 339 bool OrderedSimpleTaskRunner::AdvanceNowCallback() {
338 base::TimeTicks next_task_time = NextTaskTime(); 340 base::TimeTicks next_task_time = NextTaskTime();
339 if (now_src_->NowTicks() < next_task_time) { 341 if (now_src_->NowTicks() < next_task_time) {
340 now_src_->Advance(next_task_time - now_src_->NowTicks()); 342 now_src_->Advance(next_task_time - now_src_->NowTicks());
341 } 343 }
342 return true; 344 return true;
343 } 345 }
344 346
345 } // namespace cc 347 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/audio_stream_monitor.cc » ('j') | content/browser/web_contents/web_contents_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698