Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include/AdblockPlus/JsEngine.h

Issue 10305024: Simplify context setup, set properties on the global object directly instead of using templates (Closed)
Left Patch Set: Created April 18, 2013, 6:26 a.m.
Right Patch Set: Unbitrotted patch Created April 18, 2013, 11:44 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/AppInfoJsObject.h » ('j') | src/GlobalJsObject.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #ifndef ADBLOCKPLUS_JS_ENGINE_H 1 #ifndef ADBLOCKPLUS_JS_ENGINE_H
2 #define ADBLOCKPLUS_JS_ENGINE_H 2 #define ADBLOCKPLUS_JS_ENGINE_H
3 3
4 #include <stdexcept> 4 #include <stdexcept>
5 #include <string> 5 #include <string>
6 #include <v8.h> 6 #include <v8.h>
7 #include <AdblockPlus/JsValue.h> 7 #include <AdblockPlus/JsValue.h>
8 8
9 namespace AdblockPlus 9 namespace AdblockPlus
10 { 10 {
11 struct AppInfo;
11 class FileSystem; 12 class FileSystem;
12 class WebRequest; 13 class WebRequest;
13 class ErrorCallback; 14 class ErrorCallback;
14 15
15 class JsError : public std::runtime_error 16 class JsError : public std::runtime_error
16 { 17 {
17 public: 18 public:
18 explicit JsError(const v8::Handle<v8::Value> exception, 19 explicit JsError(const v8::Handle<v8::Value> exception,
19 const v8::Handle<v8::Message> message); 20 const v8::Handle<v8::Message> message);
20 }; 21 };
21 22
22 class JsEngine 23 class JsEngine
23 { 24 {
24 friend class JsValue; 25 friend class JsValue;
25 26
26 public: 27 public:
27 JsEngine(FileSystem* const fileReader, 28 JsEngine(const AppInfo& appInfo,
29 FileSystem* const fileReader,
28 WebRequest* const webRequest, 30 WebRequest* const webRequest,
29 ErrorCallback* const errorCallback); 31 ErrorCallback* const errorCallback);
30 JsValuePtr Evaluate(const std::string& source, 32 JsValuePtr Evaluate(const std::string& source,
31 const std::string& filename = ""); 33 const std::string& filename = "");
32 void Load(const std::string& scriptPath); 34 void Load(const std::string& scriptPath);
33 void Gc(); 35 void Gc();
34 JsValuePtr NewValue(const std::string& val); 36 JsValuePtr NewValue(const std::string& val);
35 JsValuePtr NewValue(int64_t val); 37 JsValuePtr NewValue(int64_t val);
36 JsValuePtr NewValue(bool val); 38 JsValuePtr NewValue(bool val);
37 inline JsValuePtr NewValue(const char* val) 39 inline JsValuePtr NewValue(const char* val)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 private: 77 private:
76 FileSystem& fileSystem; 78 FileSystem& fileSystem;
77 WebRequest& webRequest; 79 WebRequest& webRequest;
78 ErrorCallback& errorCallback; 80 ErrorCallback& errorCallback;
79 v8::Isolate* isolate; 81 v8::Isolate* isolate;
80 v8::Persistent<v8::Context> context; 82 v8::Persistent<v8::Context> context;
81 }; 83 };
82 } 84 }
83 85
84 #endif 86 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld