| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 GIN_MODULES_TIMER_H_ | 5 #ifndef GIN_MODULES_TIMER_H_ |
| 6 #define GIN_MODULES_TIMER_H_ | 6 #define GIN_MODULES_TIMER_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "gin/gin_export.h" | 10 #include "gin/gin_export.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 enum TimerType { | 23 enum TimerType { |
| 24 TYPE_ONE_SHOT, | 24 TYPE_ONE_SHOT, |
| 25 TYPE_REPEATING | 25 TYPE_REPEATING |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 static WrapperInfo kWrapperInfo; | 28 static WrapperInfo kWrapperInfo; |
| 29 static Handle<Timer> Create(TimerType type, v8::Isolate* isolate, | 29 static Handle<Timer> Create(TimerType type, v8::Isolate* isolate, |
| 30 int delay_ms, v8::Handle<v8::Function> function); | 30 int delay_ms, v8::Handle<v8::Function> function); |
| 31 | 31 |
| 32 virtual ObjectTemplateBuilder GetObjectTemplateBuilder( | 32 virtual ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 33 v8::Isolate* isolate) OVERRIDE; | 33 v8::Isolate* isolate) override; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 Timer(v8::Isolate* isolate, bool repeating, int delay_ms, | 36 Timer(v8::Isolate* isolate, bool repeating, int delay_ms, |
| 37 v8::Handle<v8::Function> function); | 37 v8::Handle<v8::Function> function); |
| 38 virtual ~Timer(); | 38 virtual ~Timer(); |
| 39 void OnTimerFired(); | 39 void OnTimerFired(); |
| 40 | 40 |
| 41 base::Timer timer_; | 41 base::Timer timer_; |
| 42 base::WeakPtr<gin::Runner> runner_; | 42 base::WeakPtr<gin::Runner> runner_; |
| 43 base::WeakPtrFactory<Timer> weak_factory_; | 43 base::WeakPtrFactory<Timer> weak_factory_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(Timer); | 45 DISALLOW_COPY_AND_ASSIGN(Timer); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 | 48 |
| 49 class GIN_EXPORT TimerModule : public Wrappable<TimerModule> { | 49 class GIN_EXPORT TimerModule : public Wrappable<TimerModule> { |
| 50 public: | 50 public: |
| 51 static const char kName[]; | 51 static const char kName[]; |
| 52 static WrapperInfo kWrapperInfo; | 52 static WrapperInfo kWrapperInfo; |
| 53 static Handle<TimerModule> Create(v8::Isolate* isolate); | 53 static Handle<TimerModule> Create(v8::Isolate* isolate); |
| 54 static v8::Local<v8::Value> GetModule(v8::Isolate* isolate); | 54 static v8::Local<v8::Value> GetModule(v8::Isolate* isolate); |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 TimerModule(); | 57 TimerModule(); |
| 58 virtual ~TimerModule(); | 58 virtual ~TimerModule(); |
| 59 | 59 |
| 60 virtual ObjectTemplateBuilder GetObjectTemplateBuilder( | 60 virtual ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 61 v8::Isolate* isolate) OVERRIDE; | 61 v8::Isolate* isolate) override; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 } // namespace gin | 64 } // namespace gin |
| 65 | 65 |
| 66 #endif // GIN_MODULES_TIMER_H_ | 66 #endif // GIN_MODULES_TIMER_H_ |
| OLD | NEW |