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

Side by Side Diff: gin/runner.h

Issue 1112923003: Replace Handle<> with Local in remaining gin/* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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 | « gin/public/wrapper_info.h ('k') | gin/shell_runner.h » ('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 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "gin/gin_export.h" 11 #include "gin/gin_export.h"
12 #include "gin/public/context_holder.h" 12 #include "gin/public/context_holder.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 namespace gin { 15 namespace gin {
16 16
17 // Runner is responsible for running code in a v8::Context. 17 // Runner is responsible for running code in a v8::Context.
18 class GIN_EXPORT Runner { 18 class GIN_EXPORT Runner {
19 public: 19 public:
20 Runner(); 20 Runner();
21 virtual ~Runner(); 21 virtual ~Runner();
22 22
23 // Before running script in this context, you'll need to enter the runner's 23 // Before running script in this context, you'll need to enter the runner's
24 // context by creating an instance of Runner::Scope on the stack. 24 // context by creating an instance of Runner::Scope on the stack.
25 virtual void Run(const std::string& source, 25 virtual void Run(const std::string& source,
26 const std::string& resource_name) = 0; 26 const std::string& resource_name) = 0;
27 virtual v8::Handle<v8::Value> Call(v8::Handle<v8::Function> function, 27 virtual v8::Local<v8::Value> Call(v8::Local<v8::Function> function,
28 v8::Handle<v8::Value> receiver, 28 v8::Local<v8::Value> receiver,
29 int argc, 29 int argc,
30 v8::Handle<v8::Value> argv[]) = 0; 30 v8::Local<v8::Value> argv[]) = 0;
31 virtual ContextHolder* GetContextHolder() = 0; 31 virtual ContextHolder* GetContextHolder() = 0;
32 32
33 v8::Handle<v8::Object> global() { 33 v8::Local<v8::Object> global() {
34 return GetContextHolder()->context()->Global(); 34 return GetContextHolder()->context()->Global();
35 } 35 }
36 36
37 // Useful for running script in this context asynchronously. Rather than 37 // Useful for running script in this context asynchronously. Rather than
38 // holding a raw pointer to the runner, consider holding a WeakPtr. 38 // holding a raw pointer to the runner, consider holding a WeakPtr.
39 base::WeakPtr<Runner> GetWeakPtr() { 39 base::WeakPtr<Runner> GetWeakPtr() {
40 return weak_factory_.GetWeakPtr(); 40 return weak_factory_.GetWeakPtr();
41 } 41 }
42 42
43 class GIN_EXPORT Scope { 43 class GIN_EXPORT Scope {
(...skipping 13 matching lines...) Expand all
57 friend class Scope; 57 friend class Scope;
58 58
59 base::WeakPtrFactory<Runner> weak_factory_; 59 base::WeakPtrFactory<Runner> weak_factory_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(Runner); 61 DISALLOW_COPY_AND_ASSIGN(Runner);
62 }; 62 };
63 63
64 } // namespace gin 64 } // namespace gin
65 65
66 #endif // GIN_RUNNER_H_ 66 #endif // GIN_RUNNER_H_
OLDNEW
« no previous file with comments | « gin/public/wrapper_info.h ('k') | gin/shell_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698