| 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 24 matching lines...) Expand all Loading... |
| 35 // responsibility of TaskQueueImpl to keep the time domain up to date if this | 35 // responsibility of TaskQueueImpl to keep the time domain up to date if this |
| 36 // changes. | 36 // changes. |
| 37 class BLINK_PLATFORM_EXPORT TimeDomain { | 37 class BLINK_PLATFORM_EXPORT TimeDomain { |
| 38 public: | 38 public: |
| 39 class BLINK_PLATFORM_EXPORT Observer { | 39 class BLINK_PLATFORM_EXPORT Observer { |
| 40 public: | 40 public: |
| 41 virtual ~Observer() {} | 41 virtual ~Observer() {} |
| 42 | 42 |
| 43 // Called when an empty TaskQueue registered with this TimeDomain has a task | 43 // Called when an empty TaskQueue registered with this TimeDomain has a task |
| 44 // enqueued. | 44 // enqueued. |
| 45 virtual void OnTimeDomainHasImmediateWork() = 0; | 45 // |task_queue| - task queue which has immediate work scheduled. |
| 46 virtual void OnTimeDomainHasImmediateWork(TaskQueue* task_queue) = 0; |
| 46 | 47 |
| 47 // Called when a TaskQueue registered with this TimeDomain has a delayed | 48 // Called when a TaskQueue registered with this TimeDomain has a delayed |
| 48 // task enqueued. | 49 // task enqueued. |
| 49 virtual void OnTimeDomainHasDelayedWork() = 0; | 50 // |task_queue| - task queue which has delayed work scheduled. |
| 51 virtual void OnTimeDomainHasDelayedWork(TaskQueue* task_queue) = 0; |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 explicit TimeDomain(Observer* observer); | 54 explicit TimeDomain(Observer* observer); |
| 53 virtual ~TimeDomain(); | 55 virtual ~TimeDomain(); |
| 54 | 56 |
| 55 // 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 |
| 56 // any thread. | 58 // any thread. |
| 57 // TODO(alexclarke): Make this main thread only. | 59 // TODO(alexclarke): Make this main thread only. |
| 58 virtual LazyNow CreateLazyNow() const = 0; | 60 virtual LazyNow CreateLazyNow() const = 0; |
| 59 | 61 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 // runtime for the next one and it returns true. Returns false otherwise. | 73 // runtime for the next one and it returns true. Returns false otherwise. |
| 72 bool NextScheduledRunTime(base::TimeTicks* out_time) const; | 74 bool NextScheduledRunTime(base::TimeTicks* out_time) const; |
| 73 | 75 |
| 74 protected: | 76 protected: |
| 75 friend class internal::TaskQueueImpl; | 77 friend class internal::TaskQueueImpl; |
| 76 friend class TaskQueueManager; | 78 friend class TaskQueueManager; |
| 77 | 79 |
| 78 void AsValueInto(base::trace_event::TracedValue* state) const; | 80 void AsValueInto(base::trace_event::TracedValue* state) const; |
| 79 | 81 |
| 80 // Migrates |queue| from this time domain to |destination_time_domain|. | 82 // Migrates |queue| from this time domain to |destination_time_domain|. |
| 83 // Main-thread only. |
| 81 void MigrateQueue(internal::TaskQueueImpl* queue, | 84 void MigrateQueue(internal::TaskQueueImpl* queue, |
| 82 TimeDomain* destination_time_domain); | 85 TimeDomain* destination_time_domain); |
| 83 | 86 |
| 84 // If there is a scheduled delayed task, |out_task_queue| is set to the queue | 87 // If there is a scheduled delayed task, |out_task_queue| is set to the queue |
| 85 // the next task was posted to and it returns true. Returns false otherwise. | 88 // the next task was posted to and it returns true. Returns false otherwise. |
| 86 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; | 89 bool NextScheduledTaskQueue(TaskQueue** out_task_queue) const; |
| 87 | 90 |
| 88 // Adds |queue| to the set of task queues that UpdateWorkQueues calls | 91 // Adds |queue| to the set of task queues that UpdateWorkQueues calls |
| 89 // UpdateWorkQueue on. | 92 // UpdateWorkQueue on. |
| 90 void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); | 93 void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 162 |
| 160 base::ThreadChecker main_thread_checker_; | 163 base::ThreadChecker main_thread_checker_; |
| 161 | 164 |
| 162 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 165 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 163 }; | 166 }; |
| 164 | 167 |
| 165 } // namespace scheduler | 168 } // namespace scheduler |
| 166 } // namespace blink | 169 } // namespace blink |
| 167 | 170 |
| 168 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 171 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |