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

Side by Side Diff: gin/runner.h

Issue 74753002: Introduce gin_shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix more header nits 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_context_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
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_RUNNER_H_ 5 #ifndef GIN_RUNNER_H_
6 #define GIN_RUNNER_H_ 6 #define GIN_RUNNER_H_
7 7
8 #include <string> 8 #include <string>
9
10 #include "base/memory/weak_ptr.h"
9 #include "gin/context_holder.h" 11 #include "gin/context_holder.h"
10 12
11 namespace gin { 13 namespace gin {
12 14
13 class Runner; 15 class Runner;
16 class TryCatch;
14 17
15 class RunnerDelegate { 18 class RunnerDelegate {
16 public: 19 public:
17 RunnerDelegate(); 20 RunnerDelegate();
18 virtual ~RunnerDelegate(); 21 virtual ~RunnerDelegate();
19 22
20 // Returns the template for the global object. 23 // Returns the template for the global object.
21 virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate(Runner* runner); 24 virtual v8::Handle<v8::ObjectTemplate> GetGlobalTemplate(Runner* runner);
22
23 virtual void DidCreateContext(Runner* runner); 25 virtual void DidCreateContext(Runner* runner);
26 virtual void WillRunScript(Runner* runner, v8::Handle<v8::Script> script);
27 virtual void DidRunScript(Runner* runner, v8::Handle<v8::Script> script);
28 virtual void UnhandledException(Runner* runner, TryCatch& try_catch);
24 }; 29 };
25 30
26 class Runner : public ContextHolder { 31 class Runner : public ContextHolder {
27 public: 32 public:
28 Runner(RunnerDelegate* delegate, v8::Isolate* isolate); 33 Runner(RunnerDelegate* delegate, v8::Isolate* isolate);
29 ~Runner(); 34 ~Runner();
30 35
31 void Run(const std::string& script); 36 void Run(const std::string& script);
32 void Run(v8::Handle<v8::Script> script); 37 void Run(v8::Handle<v8::Script> script);
33 38
34 v8::Handle<v8::Object> global() const { 39 v8::Handle<v8::Object> global() const {
35 return context()->Global(); 40 return context()->Global();
36 } 41 }
37 42
43 base::WeakPtr<Runner> GetWeakPtr() {
44 return weak_factory_.GetWeakPtr();
45 }
46
38 class Scope { 47 class Scope {
39 public: 48 public:
40 explicit Scope(Runner* runner); 49 explicit Scope(Runner* runner);
41 ~Scope(); 50 ~Scope();
42 51
43 private: 52 private:
44 v8::HandleScope handle_scope_; 53 v8::HandleScope handle_scope_;
45 v8::Context::Scope scope_; 54 v8::Context::Scope scope_;
46 55
47 DISALLOW_COPY_AND_ASSIGN(Scope); 56 DISALLOW_COPY_AND_ASSIGN(Scope);
48 }; 57 };
49 58
50 private: 59 private:
51 friend class Scope; 60 friend class Scope;
52 61
53 RunnerDelegate* delegate_; 62 RunnerDelegate* delegate_;
54 63
64 base::WeakPtrFactory<Runner> weak_factory_;
65
55 DISALLOW_COPY_AND_ASSIGN(Runner); 66 DISALLOW_COPY_AND_ASSIGN(Runner);
56 }; 67 };
57 68
58 } // namespace gin 69 } // namespace gin
59 70
60 #endif // GIN_RUNNER_H_ 71 #endif // GIN_RUNNER_H_
OLDNEW
« no previous file with comments | « gin/per_context_data.cc ('k') | gin/runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698