Chromium Code Reviews| 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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "platform/scheduler/base/lazy_now.h" | 16 #include "platform/scheduler/base/lazy_now.h" |
| 17 #include "platform/scheduler/base/task_queue_impl.h" | 17 #include "platform/scheduler/base/task_queue_impl.h" |
| 18 | 18 |
| 19 namespace blink { | 19 namespace blink { |
| 20 namespace scheduler { | 20 namespace scheduler { |
| 21 namespace internal { | 21 namespace internal { |
| 22 class TaskQueueImpl; | 22 class TaskQueueImpl; |
| 23 } // internal | 23 } // internal |
| 24 class TaskQueueManager; | 24 class TaskQueueManager; |
| 25 class TaskQueueManagerDelegate; | 25 class TaskQueueManagerDelegate; |
| 26 | 26 |
| 27 // The TimeDomain's job is to keep track of moments when delayed tasks have been | 27 // The TimeDomain's job is to wake task queues up when their next delayed tasks |
| 28 // scheduled to fire and to notify their TaskQueues via UpdateDelayedWorkQueue. | 28 // are due to fire. TaskQueues request a wake up via ScheduleDelayedWork, when |
| 29 // the WakeUp is due the TimeDomain calls | |
| 30 // TaskQueue::MoveReadyDelayedTasksToDelayedWorkQueue which schedules the next | |
| 31 // non-canceled wakeup. | |
| 29 // | 32 // |
| 30 // The time domain keeps track of the next wakeup required to pump delayed tasks | 33 // To prevent spurious wake-ups for canceled tasks the TaskQueue should only |
| 31 // and issues |RequestWakeup| calls to the subclass as needed. Where possible | 34 // have |
|
Sami
2016/09/13 17:42:53
nit: reformat
alex clarke (OOO till 29th)
2016/09/14 09:04:24
Done.
| |
| 32 // it tried to de-dupe these wakeups. Ideally it would be possible to cancel | 35 // a single wake up registered with its TimeDomain. If should call |
| 33 // them, but that's not currently supported by the base message loop. | 36 // CancelDelayedWork as needed to ensure this. The TimeDomain communicates with |
| 37 // the TaskQueueManager to actually schedule the wake-ups on the underlying | |
| 38 // base::MessageLoop. Various levels of de-duping are employed to prevent | |
| 39 // unnecessary posting of TaskQueueManager::DoWork. | |
| 34 // | 40 // |
| 35 // The clock itself is provided by subclasses of the TimeDomain and it may be | 41 // The clock itself is provided by subclasses of the TimeDomain and it may be |
| 36 // the real wall clock or a synthetic (virtual) time base. | 42 // the real wall clock or a synthetic (virtual) time base. |
| 37 class BLINK_PLATFORM_EXPORT TimeDomain { | 43 class BLINK_PLATFORM_EXPORT TimeDomain { |
| 38 public: | 44 public: |
| 39 class BLINK_PLATFORM_EXPORT Observer { | 45 class BLINK_PLATFORM_EXPORT Observer { |
| 40 public: | 46 public: |
| 41 virtual ~Observer() {} | 47 virtual ~Observer() {} |
| 42 | 48 |
| 43 // Called when an empty TaskQueue registered with this TimeDomain has a task | 49 // Called when an empty TaskQueue registered with this TimeDomain has a task |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 | 166 |
| 161 base::ThreadChecker main_thread_checker_; | 167 base::ThreadChecker main_thread_checker_; |
| 162 | 168 |
| 163 DISALLOW_COPY_AND_ASSIGN(TimeDomain); | 169 DISALLOW_COPY_AND_ASSIGN(TimeDomain); |
| 164 }; | 170 }; |
| 165 | 171 |
| 166 } // namespace scheduler | 172 } // namespace scheduler |
| 167 } // namespace blink | 173 } // namespace blink |
| 168 | 174 |
| 169 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ | 175 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TIME_DOMAIN_H_ |
| OLD | NEW |