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

Side by Side Diff: src/WebRequestJsObject.cpp

Issue 10310030: Convert references to FileSystem & Co. into shared pointers (avoid use after free) (Closed)
Patch Set: Created April 18, 2013, 11:59 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
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 21 matching lines...) Expand all
32 } 32 }
33 } 33 }
34 34
35 callback = arguments[2]; 35 callback = arguments[2];
36 if (!callback->IsFunction()) 36 if (!callback->IsFunction())
37 throw std::runtime_error("Third argument to GET must be a function"); 37 throw std::runtime_error("Third argument to GET must be a function");
38 } 38 }
39 39
40 void Run() 40 void Run()
41 { 41 {
42 AdblockPlus::ServerResponse result = jsEngine.GetWebRequest().GET(url, hea ders); 42 AdblockPlus::ServerResponse result = jsEngine.GetWebRequest()->GET(url, he aders);
43 43
44 AdblockPlus::JsEngine::Context context(jsEngine); 44 AdblockPlus::JsEngine::Context context(jsEngine);
45 45
46 AdblockPlus::JsValuePtr resultObject = jsEngine.NewObject(); 46 AdblockPlus::JsValuePtr resultObject = jsEngine.NewObject();
47 resultObject->SetProperty("status", result.status); 47 resultObject->SetProperty("status", result.status);
48 resultObject->SetProperty("responseStatus", result.responseStatus); 48 resultObject->SetProperty("responseStatus", result.responseStatus);
49 resultObject->SetProperty("responseText", result.responseText); 49 resultObject->SetProperty("responseText", result.responseText);
50 50
51 AdblockPlus::JsValuePtr headersObject = jsEngine.NewObject(); 51 AdblockPlus::JsValuePtr headersObject = jsEngine.NewObject();
52 for (AdblockPlus::HeaderList::iterator it = result.responseHeaders.begin() ; 52 for (AdblockPlus::HeaderList::iterator it = result.responseHeaders.begin() ;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return v8::Undefined(); 88 return v8::Undefined();
89 } 89 }
90 } 90 }
91 91
92 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup( 92 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup(
93 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj) 93 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValuePtr obj)
94 { 94 {
95 obj->SetProperty("GET", jsEngine.NewCallback(::GETCallback)); 95 obj->SetProperty("GET", jsEngine.NewCallback(::GETCallback));
96 return obj; 96 return obj;
97 } 97 }
OLDNEW
« src/JsEngine.cpp ('K') | « src/JsEngine.cpp ('k') | test/AppInfoJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld