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

Side by Side Diff: gin/runner.h

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

Powered by Google App Engine
This is Rietveld 408576698