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

Side by Side Diff: experimental/SkV8Example/Global.h

Issue 103143009: Add a setTimer() function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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
« no previous file with comments | « no previous file | experimental/SkV8Example/Global.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 *
8 */
9
10 #ifndef SkV8Example_Global_DEFINED
11 #define SkV8Example_Global_DEFINED
12
13 #include <v8.h>
14
15 using namespace v8;
16
17 #include "SkTypes.h"
18 #include "SkEvent.h"
19
20 class SkOSWindow;
21
22 // Provides the global isolate and context for our V8 instance.
23 // Also implements all the global level functions.
24 class Global : SkNoncopyable {
25 public:
26 Global(Isolate* isolate)
27 : fIsolate(isolate)
28 , fWindow(NULL)
29 {
30 gGlobal = this;
31 }
32 virtual ~Global() {}
33
34 // The script will be parsed into the context this Global contains.
35 bool parseScript(const char script[]);
36
37 Local<Context> getContext() {
38 return Local<Context>::New(fIsolate, fContext);
39 }
40
41 Isolate* getIsolate() {
42 return fIsolate;
43 }
44
45 void setWindow(SkOSWindow* win) {
46 fWindow = win;
47 }
48 SkOSWindow* getWindow() {
49 return fWindow;
50 }
51
52 void reportException(TryCatch* tryCatch);
53
54 private:
55 Handle<Context> createRootContext();
56
57 static bool TimeOutProc(const SkEvent& evt);
58
59 // Static functions that implement the global JS functions we add to
60 // the context.
61 static void SetTimeout(const v8::FunctionCallbackInfo<v8::Value>& args);
62 static void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
63 static void Inval(const v8::FunctionCallbackInfo<Value>& args);
64
65 Persistent<Context> fContext;
66 Isolate* fIsolate;
67 SkOSWindow* fWindow;
68 static Global* gGlobal;
69
70 // Handle to the function to call when the timeout triggers.
71 Persistent<Function> fTimeout;
72 };
73
74 #endif
OLDNEW
« no previous file with comments | « no previous file | experimental/SkV8Example/Global.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698