OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SKY_ENGINE_TONIC_DART_TIMER_HEAP_H_ |
| 6 #define SKY_ENGINE_TONIC_DART_TIMER_HEAP_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/time/time.h" |
| 10 #include "dart/runtime/include/dart_api.h" |
| 11 #include "sky/engine/tonic/dart_persistent_value.h" |
| 12 #include "sky/engine/wtf/HashMap.h" |
| 13 #include "sky/engine/wtf/OwnPtr.h" |
| 14 #include "sky/engine/wtf/PassOwnPtr.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 class DartTimerHeap { |
| 19 public: |
| 20 DartTimerHeap(); |
| 21 ~DartTimerHeap(); |
| 22 |
| 23 struct Task { |
| 24 DartPersistentValue closure; |
| 25 base::TimeDelta delay; |
| 26 bool repeating = false; |
| 27 }; |
| 28 |
| 29 int Add(PassOwnPtr<Task> task); |
| 30 void Remove(int id); |
| 31 |
| 32 private: |
| 33 void Schedule(int id, PassOwnPtr<Task> task); |
| 34 void Run(int id); |
| 35 |
| 36 int next_timer_id_; |
| 37 HashMap<int, OwnPtr<Task>> heap_; |
| 38 |
| 39 base::WeakPtrFactory<DartTimerHeap> weak_factory_; |
| 40 }; |
| 41 |
| 42 } |
| 43 |
| 44 #endif // SKY_ENGINE_TONIC_DART_TIMER_HEAP_H_ |
OLD | NEW |