| 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 virtual ~TimeDomain(); | 55 virtual ~TimeDomain(); |
| 56 | 56 |
| 57 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from | 57 // Returns a LazyNow that evaluate this TimeDomain's Now. Can be called from |
| 58 // any thread. | 58 // any thread. |
| 59 // TODO(alexclarke): Make this main thread only. | 59 // TODO(alexclarke): Make this main thread only. |
| 60 virtual LazyNow CreateLazyNow() const = 0; | 60 virtual LazyNow CreateLazyNow() const = 0; |
| 61 | 61 |
| 62 // Evaluate this TimeDomain's Now. Can be called from any thread. | 62 // Evaluate this TimeDomain's Now. Can be called from any thread. |
| 63 virtual base::TimeTicks Now() const = 0; | 63 virtual base::TimeTicks Now() const = 0; |
| 64 | 64 |
| 65 // Some TimeDomains support virtual time, this method tells us to advance time | 65 // Computes the delay until the next task the TimeDomain is aware of, if any. |
| 66 // if possible and return true if time was advanced. | 66 // Note virtual time domains may return base::TimeDelta() if they have any |
| 67 virtual bool MaybeAdvanceTime() = 0; | 67 // delayed tasks they deem eligible to run. Virtual time domains are allowed |
| 68 // to advance their internal clock when this method is called. |
| 69 virtual base::Optional<base::TimeDelta> DelayTillNextTask( |
| 70 LazyNow* lazy_now) = 0; |
| 68 | 71 |
| 69 // Returns the name of this time domain for tracing. | 72 // Returns the name of this time domain for tracing. |
| 70 virtual const char* GetName() const = 0; | 73 virtual const char* GetName() const = 0; |
| 71 | 74 |
| 72 // If there is a scheduled delayed task, |out_time| is set to the scheduled | 75 // If there is a scheduled delayed task, |out_time| is set to the scheduled |
| 73 // runtime for the next one and it returns true. Returns false otherwise. | 76 // runtime for the next one and it returns true. Returns false otherwise. |
| 74 bool NextScheduledRunTime(base::TimeTicks* out_time) const; | 77 bool NextScheduledRunTime(base::TimeTicks* out_time) const; |
| 75 | 78 |
| 76 protected: | 79 protected: |
| 77 friend class internal::TaskQueueImpl; | 80 friend class internal::TaskQueueImpl; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 void RegisterQueue(internal::TaskQueueImpl* queue); | 106 void RegisterQueue(internal::TaskQueueImpl* queue); |
| 104 | 107 |
| 105 // Removes |queue| from the set of task queues that UpdateWorkQueues calls | 108 // Removes |queue| from the set of task queues that UpdateWorkQueues calls |
| 106 // UpdateWorkQueue on. Returns true if |queue| was updatable. | 109 // UpdateWorkQueue on. Returns true if |queue| was updatable. |
| 107 bool UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); | 110 bool UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); |
| 108 | 111 |
| 109 // Removes |queue| from all internal data structures. | 112 // Removes |queue| from all internal data structures. |
| 110 void UnregisterQueue(internal::TaskQueueImpl* queue); | 113 void UnregisterQueue(internal::TaskQueueImpl* queue); |
| 111 | 114 |
| 112 // Updates active queues associated with this TimeDomain. | 115 // Updates active queues associated with this TimeDomain. |
| 113 void UpdateWorkQueues(LazyNow lazy_now); | 116 void UpdateWorkQueues(LazyNow* lazy_now); |
| 114 | 117 |
| 115 // Called by the TaskQueueManager when the TimeDomain is registered. | 118 // Called by the TaskQueueManager when the TimeDomain is registered. |
| 116 virtual void OnRegisterWithTaskQueueManager( | 119 virtual void OnRegisterWithTaskQueueManager( |
| 117 TaskQueueManager* task_queue_manager) = 0; | 120 TaskQueueManager* task_queue_manager) = 0; |
| 118 | 121 |
| 119 // The implementaion will secedule task processing to run with |delay| with | 122 // The implementaion will secedule task processing to run with |delay| with |
| 120 // respect to the TimeDomain's time source. Always called on the main thread. | 123 // respect to the TimeDomain's time source. Always called on the main thread. |
| 121 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime | 124 // NOTE this is only called by ScheduleDelayedWork if the scheduled runtime |
| 122 // is sooner than any previously sheduled work or if there is no other | 125 // is sooner than any previously sheduled work or if there is no other |
| 123 // scheduled work. | 126 // scheduled work. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 180 |
| 178 base::ThreadChecker main_thread_checker_; | 181 base::ThreadChecker main_thread_checker_; |
| 179 | 182 |
| 180 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 183 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 181 }; | 184 }; |
| 182 | 185 |
| 183 } // namespace scheduler | 186 } // namespace scheduler |
| 184 } // namespace blink | 187 } // namespace blink |
| 185 | 188 |
| 186 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 189 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |