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

Side by Side Diff: gin/runner.h

Issue 67763002: Add gin, a lightweight bindings system for V8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Aaron's comments Created 7 years, 1 month 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
« no previous file with comments | « gin/per_isolate_data.cc ('k') | gin/runner.cc » ('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 // 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_RUNNER_H_
6 #define GIN_RUNNER_H_
7
8 #include "base/basictypes.h"
9 #include "v8/include/v8.h"
10
11 namespace gin {
12
13 class Runner;
14
15 class RunnerDelegate {
16 public:
17 // Returns the object that is passed to the script's |main| function.
18 virtual v8::Handle<v8::Object> CreateRootObject(Runner* runner) = 0;
19
20 protected:
21 virtual ~RunnerDelegate();
22 };
23
24 class Runner {
25 public:
26 Runner(RunnerDelegate* delegate, v8::Isolate* isolate);
27 ~Runner();
28
29 void Run(v8::Handle<v8::Script> script);
30
31 v8::Isolate* isolate() const { return isolate_; }
32
33 v8::Handle<v8::Context> context() const {
34 return v8::Local<v8::Context>::New(isolate_, context_);
35 }
36
37 v8::Handle<v8::Object> global() const {
38 return context()->Global();
39 }
40
41 class Scope {
42 public:
43 explicit Scope(Runner* runner);
44 ~Scope();
45
46 private:
47 v8::HandleScope handle_scope_;
48 v8::Context::Scope scope_;
49
50 DISALLOW_COPY_AND_ASSIGN(Scope);
51 };
52
53 private:
54 friend class Scope;
55
56 v8::Handle<v8::Function> GetMain();
57
58 RunnerDelegate* delegate_;
59 v8::Isolate* isolate_;
60 v8::Persistent<v8::Context> context_;
61
62 DISALLOW_COPY_AND_ASSIGN(Runner);
63 };
64
65 } // namespace gin
66
67 #endif // GIN_RUNNER_H_
OLDNEW
« no previous file with comments | « gin/per_isolate_data.cc ('k') | gin/runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698