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

Side by Side Diff: components/scheduler/base/real_time_domain.cc

Issue 1718233002: Fix computation of runtime for throttled tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 10 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/base/real_time_domain.h" 5 #include "components/scheduler/base/real_time_domain.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/scheduler/base/task_queue_impl.h" 8 #include "components/scheduler/base/task_queue_impl.h"
9 #include "components/scheduler/base/task_queue_manager.h" 9 #include "components/scheduler/base/task_queue_manager.h"
10 #include "components/scheduler/base/task_queue_manager_delegate.h" 10 #include "components/scheduler/base/task_queue_manager_delegate.h"
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 LazyNow RealTimeDomain::CreateLazyNow() const { 25 LazyNow RealTimeDomain::CreateLazyNow() const {
26 return task_queue_manager_->CreateLazyNow(); 26 return task_queue_manager_->CreateLazyNow();
27 } 27 }
28 28
29 base::TimeTicks RealTimeDomain::Now() const { 29 base::TimeTicks RealTimeDomain::Now() const {
30 return task_queue_manager_->delegate()->NowTicks(); 30 return task_queue_manager_->delegate()->NowTicks();
31 } 31 }
32 32
33 base::TimeTicks RealTimeDomain::ComputeDelayedRunTime(
34 base::TimeTicks time_domain_now,
35 base::TimeDelta delay) const {
36 return time_domain_now + delay;
37 }
38
33 void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) { 39 void RealTimeDomain::RequestWakeup(base::TimeTicks now, base::TimeDelta delay) {
34 // NOTE this is only called if the scheduled runtime is sooner than any 40 // NOTE this is only called if the scheduled runtime is sooner than any
35 // previously scheduled runtime, or there is no (outstanding) previously 41 // previously scheduled runtime, or there is no (outstanding) previously
36 // scheduled runtime. 42 // scheduled runtime.
37 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay); 43 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, delay);
38 } 44 }
39 45
40 bool RealTimeDomain::MaybeAdvanceTime() { 46 bool RealTimeDomain::MaybeAdvanceTime() {
41 base::TimeTicks next_run_time; 47 base::TimeTicks next_run_time;
42 if (!NextScheduledRunTime(&next_run_time)) 48 if (!NextScheduledRunTime(&next_run_time))
43 return false; 49 return false;
44 50
45 base::TimeTicks now = Now(); 51 base::TimeTicks now = Now();
46 if (now >= next_run_time) 52 if (now >= next_run_time)
47 return true; // Causes DoWork to post a continuation. 53 return true; // Causes DoWork to post a continuation.
48 54
49 // The next task is sometime in the future, make sure we schedule a DoWork to 55 // The next task is sometime in the future, make sure we schedule a DoWork to
50 // run it. 56 // run it.
51 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now, 57 task_queue_manager_->MaybeScheduleDelayedWork(FROM_HERE, now,
52 next_run_time - now); 58 next_run_time - now);
53 return false; 59 return false;
54 } 60 }
55 61
56 void RealTimeDomain::AsValueIntoInternal( 62 void RealTimeDomain::AsValueIntoInternal(
57 base::trace_event::TracedValue* state) const {} 63 base::trace_event::TracedValue* state) const {}
58 64
59 const char* RealTimeDomain::GetName() const { 65 const char* RealTimeDomain::GetName() const {
60 return "RealTimeDomain"; 66 return "RealTimeDomain";
61 } 67 }
62
63 } // namespace scheduler 68 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/base/real_time_domain.h ('k') | components/scheduler/base/task_queue_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698