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

Delta Between Two Patch Sets: src/GlobalJsObject.cpp

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 | « src/GlobalJsObject.h ('k') | src/JsEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include <vector> 1 #include <vector>
2 #include <stdexcept> 2 #include <stdexcept>
3 3
4 #include <AdblockPlus/JsEngine.h> 4 #include <AdblockPlus/JsEngine.h>
5 #include <AdblockPlus/JsValue.h> 5 #include <AdblockPlus/JsValue.h>
6
7 #include "AppInfoJsObject.h"
6 #include "ConsoleJsObject.h" 8 #include "ConsoleJsObject.h"
7 #include "FileSystemJsObject.h" 9 #include "FileSystemJsObject.h"
8 #include "GlobalJsObject.h" 10 #include "GlobalJsObject.h"
9 #include "ConsoleJsObject.h" 11 #include "ConsoleJsObject.h"
10 #include "WebRequestJsObject.h" 12 #include "WebRequestJsObject.h"
11 #include "Thread.h" 13 #include "Thread.h"
12 14
13 using namespace AdblockPlus; 15 using namespace AdblockPlus;
14 16
15 namespace 17 namespace
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 63 }
62 timeoutThread->Start(); 64 timeoutThread->Start();
63 65
64 // We should actually return the timer ID here, which could be 66 // We should actually return the timer ID here, which could be
65 // used via clearTimeout(). But since we don't seem to need 67 // used via clearTimeout(). But since we don't seem to need
66 // clearTimeout(), we can save that for later. 68 // clearTimeout(), we can save that for later.
67 return v8::Undefined(); 69 return v8::Undefined();
68 } 70 }
69 } 71 }
70 72
71 JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, JsValuePtr obj) 73 JsValuePtr GlobalJsObject::Setup(JsEngine& jsEngine, const AppInfo& appInfo,
74 JsValuePtr obj)
72 { 75 {
73 obj->SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback)); 76 obj->SetProperty("setTimeout", jsEngine.NewCallback(::SetTimeoutCallback));
74 obj->SetProperty("_fileSystem", 77 obj->SetProperty("_fileSystem",
75 FileSystemJsObject::Setup(jsEngine, jsEngine.NewObject())); 78 FileSystemJsObject::Setup(jsEngine, jsEngine.NewObject()));
Felix Dahlke 2013/04/18 12:46:50 Why pass a new object in? Seems to make more sense
Wladimir Palant 2013/04/18 13:29:33 Merely for consistency. GlobaJsObject::Setup() can
76 obj->SetProperty("_webRequest", 79 obj->SetProperty("_webRequest",
77 WebRequestJsObject::Setup(jsEngine, jsEngine.NewObject())); 80 WebRequestJsObject::Setup(jsEngine, jsEngine.NewObject()));
78 obj->SetProperty("console", 81 obj->SetProperty("console",
79 ConsoleJsObject::Setup(jsEngine, jsEngine.NewObject())); 82 ConsoleJsObject::Setup(jsEngine, jsEngine.NewObject()));
83 obj->SetProperty("_appInfo",
84 AppInfoJsObject::Setup(jsEngine, appInfo, jsEngine.NewObject()));
80 return obj; 85 return obj;
81 } 86 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld