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

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

Issue 2383473002: [scheduler] Teach scheduler about audio state (Closed)
Patch Set: Switched approach to use WebContentsImpl::WasRecentlyAudible 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // If the next task is after the stopping time and auto-advancing now, then 250 // If the next task is after the stopping time and auto-advancing now, then
251 // force time to be the stopping time. 251 // force time to be the stopping time.
252 if (!result && advance_now_ && now_src_->NowTicks() < time) { 252 if (advance_now_ && now_src_->NowTicks() < time) {
Sami 2016/10/03 14:37:30 Not sure why this change is needed?
altimin 2016/10/03 15:53:38 tl;dr: Without this change new test does not work
Sami 2016/10/03 16:25:29 Yeah okay, I think it seems a little weird to not
altimin 2016/10/03 16:28:22 It kinda makes sense: please take a look at RunUnt
253 now_src_->Advance(time - now_src_->NowTicks()); 253 now_src_->Advance(time - now_src_->NowTicks());
254 } 254 }
255 255
256 return result; 256 return result;
257 } 257 }
258 258
259 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { 259 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) {
260 return RunUntilTime(now_src_->NowTicks() + period); 260 return RunUntilTime(now_src_->NowTicks() + period);
261 } 261 }
262 262
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 336
337 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { 337 bool OrderedSimpleTaskRunner::AdvanceNowCallback() {
338 base::TimeTicks next_task_time = NextTaskTime(); 338 base::TimeTicks next_task_time = NextTaskTime();
339 if (now_src_->NowTicks() < next_task_time) { 339 if (now_src_->NowTicks() < next_task_time) {
340 now_src_->Advance(next_task_time - now_src_->NowTicks()); 340 now_src_->Advance(next_task_time - now_src_->NowTicks());
341 } 341 }
342 return true; 342 return true;
343 } 343 }
344 344
345 } // namespace cc 345 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698