Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_BASE_DELAYED_UNIQUE_NOTIFIER_H_ | |
| 6 #define CC_BASE_DELAYED_UNIQUE_NOTIFIER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "cc/base/cc_export.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class SequencedTaskRunner; | |
| 14 } // namespace base | |
| 15 | |
| 16 namespace cc { | |
| 17 | |
| 18 class CC_EXPORT DelayedUniqueNotifier { | |
| 19 public: | |
| 20 // Configure this notifier to issue the |closure| notification in |delay| time | |
| 21 // from Schedule() call. | |
| 22 DelayedUniqueNotifier(base::SequencedTaskRunner* task_runner, | |
| 23 const base::Closure& closure, | |
| 24 const base::TimeDelta& delay); | |
| 25 | |
| 26 // Destroying the notifier will ensure that no further notifications will | |
| 27 // happen from this class. | |
| 28 ~DelayedUniqueNotifier(); | |
| 29 | |
| 30 // Schedule a notification to be run. If another notification is already | |
| 31 // pending, then it will happen in given delay from now. That is, if delay is | |
|
reveman
2014/05/22 23:24:28
happen in (at least) given delay from now.
vmpstr
2014/05/27 18:14:59
Done.
| |
| 32 // 16ms and a notification has been scheduled 10ms ago (ie, it should trigger | |
| 33 // in 6ms), then calling schedule will ensure that the only notification that | |
|
reveman
2014/05/22 23:24:28
s/in 6ms/in no less than 6ms/
vmpstr
2014/05/27 18:14:59
Done.
| |
| 34 // arrives will happen in 16ms from now. | |
|
reveman
2014/05/22 23:24:28
in (at least) 16ms from now.
vmpstr
2014/05/27 18:14:59
Done.
| |
| 35 void Schedule(); | |
| 36 | |
| 37 // Cancel any previously scheduled runs. | |
| 38 void Cancel(); | |
| 39 | |
| 40 private: | |
| 41 void NotifyIfTime(); | |
| 42 | |
| 43 base::SequencedTaskRunner* task_runner_; | |
| 44 base::Closure closure_; | |
| 45 base::TimeDelta delay_; | |
| 46 base::TimeTicks next_notification_time_; | |
| 47 bool notification_pending_; | |
| 48 | |
| 49 base::WeakPtrFactory<DelayedUniqueNotifier> weak_ptr_factory_; | |
| 50 }; | |
| 51 | |
| 52 } // namespace cc | |
| 53 | |
| 54 #endif // CC_BASE_DELAYED_UNIQUE_NOTIFIER_H_ | |
| OLD | NEW |