| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 virtual ~TimeDomain(); | 43 virtual ~TimeDomain(); |
| 44 | 44 |
| 45 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from | 45 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from |
| 46 // any thread. | 46 // any thread. |
| 47 // TODO(alexclarke): Make this main thread only. | 47 // TODO(alexclarke): Make this main thread only. |
| 48 virtual LazyNow CreateLazyNow() const = 0; | 48 virtual LazyNow CreateLazyNow() const = 0; |
| 49 | 49 |
| 50 // Evaluate this TimeDomain's Now. Can be called from any thread. | 50 // Evaluate this TimeDomain's Now. Can be called from any thread. |
| 51 virtual base::TimeTicks Now() const = 0; | 51 virtual base::TimeTicks Now() const = 0; |
| 52 | 52 |
| 53 // Computes a runtime which is >= |time_domain_now| + |delay|. This is used to | 53 // The time to report to blink. This should usually be base::TimeTicks::Now() |
| 54 // allow the TimeDomain to decide if the real or virtual time should be used | 54 // because blink expects time to be monotonically increacing and we need to |
| 55 // when computing the task run time. This can be called from any thread. | 55 // guaranted this even if a task queue migrates between TimeDomains. |
| 56 virtual base::TimeTicks ComputeDelayedRunTime( | 56 virtual base::TimeTicks BlinkNow() const = 0; |
| 57 base::TimeTicks time_domain_now, | |
| 58 base::TimeDelta delay) const = 0; | |
| 59 | 57 |
| 60 // Some TimeDomains support virtual time, this method tells us to advance time | 58 // Some TimeDomains support virtual time, this method tells us to advance time |
| 61 // if possible and return true if time was advanced. | 59 // if possible and return true if time was advanced. |
| 62 virtual bool MaybeAdvanceTime() = 0; | 60 virtual bool MaybeAdvanceTime() = 0; |
| 63 | 61 |
| 64 // Returns the name of this time domain for tracing. | 62 // Returns the name of this time domain for tracing. |
| 65 virtual const char* GetName() const = 0; | 63 virtual const char* GetName() const = 0; |
| 66 | 64 |
| 67 // If there is a scheduled delayed task, |out_time| is set to the scheduled | 65 // If there is a scheduled delayed task, |out_time| is set to the scheduled |
| 68 // runtime for the next one and it returns true. Returns false otherwise. | 66 // runtime for the next one and it returns true. Returns false otherwise. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Observer* observer_; // NOT OWNED. | 153 Observer* observer_; // NOT OWNED. |
| 156 | 154 |
| 157 base::ThreadChecker main_thread_checker_; | 155 base::ThreadChecker main_thread_checker_; |
| 158 | 156 |
| 159 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 157 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 160 }; | 158 }; |
| 161 | 159 |
| 162 } // namespace scheduler | 160 } // namespace scheduler |
| 163 | 161 |
| 164 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ | 162 #endif // COMPONENTS_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |