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