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

Side by Side Diff: src/WebRequestJsObject.cpp

Issue 10305024: Simplify context setup, set properties on the global object directly instead of using templates (Closed)
Patch Set: Created April 18, 2013, 6:26 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/WebRequestJsObject.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <map> 1 #include <map>
2 #include <AdblockPlus/JsEngine.h> 2 #include <AdblockPlus/JsEngine.h>
3 #include <AdblockPlus/JsValue.h> 3 #include <AdblockPlus/JsValue.h>
4 #include <AdblockPlus/WebRequest.h> 4 #include <AdblockPlus/WebRequest.h>
5 #include "WebRequestJsObject.h" 5 #include "WebRequestJsObject.h"
6 #include "Thread.h" 6 #include "Thread.h"
7 7
8 namespace 8 namespace
9 { 9 {
10 class WebRequestThread : public AdblockPlus::Thread 10 class WebRequestThread : public AdblockPlus::Thread
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 catch (const std::exception& e) 83 catch (const std::exception& e)
84 { 84 {
85 return v8::ThrowException(v8::String::New(e.what())); 85 return v8::ThrowException(v8::String::New(e.what()));
86 } 86 }
87 thread->Start(); 87 thread->Start();
88 return v8::Undefined(); 88 return v8::Undefined();
89 } 89 }
90 } 90 }
91 91
92 v8::Handle<v8::ObjectTemplate> AdblockPlus::WebRequestJsObject::Create( 92 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup(
93 AdblockPlus::JsEngine& jsEngine) 93 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj)
94 { 94 {
95 v8::HandleScope handleScope; 95 obj->SetProperty("GET", jsEngine.NewCallback(::GETCallback));
96 const v8::Handle<v8::ObjectTemplate> request = v8::ObjectTemplate::New(); 96 return obj;
97 const v8::Handle<v8::FunctionTemplate> getFunction =
98 v8::FunctionTemplate::New(::GETCallback,
99 v8::External::New(&jsEngine));
100 request->Set(v8::String::New("GET"), getFunction);
101 return handleScope.Close(request);
102 } 97 }
OLDNEW
« no previous file with comments | « src/WebRequestJsObject.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld