Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: gin/modules/timer.h

Issue 120043008: Add a simple one shot and repeating timer API for Mojo.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef GIN_MODULES_TIMER_H_
6 #define GIN_MODULES_TIMER_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "base/timer/timer.h"
10 #include "gin/gin_export.h"
11 #include "gin/handle.h"
12 #include "gin/runner.h"
13 #include "gin/wrappable.h"
14 #include "v8/include/v8.h"
15
16 namespace gin {
17
18 class ObjectTemplateBuilder;
19
20 class GIN_EXPORT Timer : public Wrappable<Timer> {
21 public:
22 enum TimerType {
23 TYPE_ONE_SHOT,
24 TYPE_REPEATING
25 };
26
27 static WrapperInfo kWrapperInfo;
28 static Handle<Timer> Create(TimerType type, v8::Isolate* isolate,
29 int delay_ms, v8::Handle<v8::Function> function);
30
31 virtual ObjectTemplateBuilder GetObjectTemplateBuilder(
32 v8::Isolate* isolate) OVERRIDE;
33
34 void Cancel();
35 void Reset();
36
37 private:
38 Timer(v8::Isolate* isolate, bool repeating, int delay_ms,
39 v8::Handle<v8::Function> function);
40 virtual ~Timer();
41 void OnTimerFired();
42
43 base::WeakPtrFactory<Timer> weak_factory_;
44 base::Timer timer_;
45 base::WeakPtr<gin::Runner> runner_;
46 };
47
48
49 class GIN_EXPORT TimerModule : public Wrappable<TimerModule> {
50 public:
51 static WrapperInfo kWrapperInfo;
52 static Handle<TimerModule> Create(v8::Isolate* isolate);
53 static v8::Local<v8::Value> GetModule(v8::Isolate* isolate);
54
55 private:
56 TimerModule();
57 virtual ~TimerModule();
58
59 virtual ObjectTemplateBuilder GetObjectTemplateBuilder(
60 v8::Isolate* isolate) OVERRIDE;
61 };
62
63 } // namespace gin
64
65 #endif // GIN_MODULES_TIMER_H_
OLDNEW
« no previous file with comments | « gin/modules/module_runner_delegate.cc ('k') | gin/modules/timer.cc » ('j') | gin/runner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698