OLD | NEW |
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 #ifndef COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ | 5 #ifndef COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ |
6 #define COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ | 6 #define COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 }; | 39 }; |
40 | 40 |
41 explicit TimeDomain(Observer* observer); | 41 explicit TimeDomain(Observer* observer); |
42 virtual ~TimeDomain(); | 42 virtual ~TimeDomain(); |
43 | 43 |
44 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from | 44 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from |
45 // any thread. | 45 // any thread. |
46 // TODO(alexclarke): Make this main thread only. | 46 // TODO(alexclarke): Make this main thread only. |
47 virtual LazyNow CreateLazyNow() = 0; | 47 virtual LazyNow CreateLazyNow() = 0; |
48 | 48 |
49 // Computes a runtime which is >= |time_domain_now| + |delay|. This is used to | |
50 // allow the TimeDomain to decide if the real or virtual time should be used | |
51 // when computing the task run time. This can be called from any thread. | |
52 virtual base::TimeTicks ComputeDelayedRunTime( | |
53 base::TimeTicks time_domain_now, | |
54 base::TimeDelta delay) const = 0; | |
55 | |
56 // Some TimeDomains support virtual time, this method tells us to advance time | 49 // Some TimeDomains support virtual time, this method tells us to advance time |
57 // if possible and return true if time was advanced. | 50 // if possible and return true if time was advanced. |
58 virtual bool MaybeAdvanceTime() = 0; | 51 virtual bool MaybeAdvanceTime() = 0; |
59 | 52 |
60 // Returns the name of this time domain for tracing. | 53 // Returns the name of this time domain for tracing. |
61 virtual const char* GetName() const = 0; | 54 virtual const char* GetName() const = 0; |
62 | 55 |
63 // If there is a scheduled delayed task, |out_time| is set to the scheduled | 56 // If there is a scheduled delayed task, |out_time| is set to the scheduled |
64 // runtime for the next one and it returns true. Returns false otherwise. | 57 // runtime for the next one and it returns true. Returns false otherwise. |
65 bool NextScheduledRunTime(base::TimeTicks* out_time) const; | 58 bool NextScheduledRunTime(base::TimeTicks* out_time) const; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 Observer* observer_; | 145 Observer* observer_; |
153 | 146 |
154 base::ThreadChecker main_thread_checker_; | 147 base::ThreadChecker main_thread_checker_; |
155 | 148 |
156 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 149 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
157 }; | 150 }; |
158 | 151 |
159 } // namespace scheduler | 152 } // namespace scheduler |
160 | 153 |
161 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ | 154 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ |
OLD | NEW |