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

Side by Side Diff: src/WebRequestJsObject.cpp

Issue 6112412478472192: Issue 1547 - Pass isolate to v8::API (Closed)
Patch Set: rebase and move 'isolate' into the proper scopes Created Feb. 5, 2015, 3:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/GlobalJsObject.cpp ('K') | « src/Utils.cpp ('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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <map> 18 #include <map>
19 #include <AdblockPlus/JsValue.h> 19 #include <AdblockPlus/JsValue.h>
20 #include <AdblockPlus/WebRequest.h> 20 #include <AdblockPlus/WebRequest.h>
21 21
22 #include "JsContext.h" 22 #include "JsContext.h"
23 #include "Thread.h" 23 #include "Thread.h"
24 #include "Utils.h"
24 #include "WebRequestJsObject.h" 25 #include "WebRequestJsObject.h"
25 26
26 namespace 27 namespace
27 { 28 {
28 class WebRequestThread : public AdblockPlus::Thread 29 class WebRequestThread : public AdblockPlus::Thread
29 { 30 {
30 public: 31 public:
31 WebRequestThread(AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValueList & arguments) 32 WebRequestThread(AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValueList & arguments)
32 : jsEngine(jsEngine), url(arguments[0]->AsString()) 33 : jsEngine(jsEngine), url(arguments[0]->AsString())
33 { 34 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 private: 84 private:
84 AdblockPlus::JsEnginePtr jsEngine; 85 AdblockPlus::JsEnginePtr jsEngine;
85 std::string url; 86 std::string url;
86 AdblockPlus::HeaderList headers; 87 AdblockPlus::HeaderList headers;
87 AdblockPlus::JsValuePtr callback; 88 AdblockPlus::JsValuePtr callback;
88 }; 89 };
89 90
90 v8::Handle<v8::Value> GETCallback(const v8::Arguments& arguments) 91 v8::Handle<v8::Value> GETCallback(const v8::Arguments& arguments)
91 { 92 {
92 WebRequestThread* thread; 93 WebRequestThread* thread;
94
Felix Dahlke 2015/02/06 04:17:27 Unrelated as well.
93 try 95 try
94 { 96 {
95 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(a rguments); 97 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(a rguments);
96 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments) ; 98 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments) ;
97 if (converted.size() != 3u) 99 if (converted.size() != 3u)
98 throw std::runtime_error("GET requires exactly 3 arguments"); 100 throw std::runtime_error("GET requires exactly 3 arguments");
99 thread = new WebRequestThread(jsEngine, converted); 101 thread = new WebRequestThread(jsEngine, converted);
100 } 102 }
101 catch (const std::exception& e) 103 catch (const std::exception& e)
102 { 104 {
103 return v8::ThrowException(v8::String::New(e.what())); 105 using AdblockPlus::Utils::ToV8String;
106 v8::Isolate* isolate = arguments.GetIsolate();
107 return v8::ThrowException(ToV8String(isolate, e.what()));
104 } 108 }
105 thread->Start(); 109 thread->Start();
106 return v8::Undefined(); 110 return v8::Undefined();
107 } 111 }
108 } 112 }
109 113
110 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup( 114 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup(
111 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj) 115 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj)
112 { 116 {
113 obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback)); 117 obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback));
114 return obj; 118 return obj;
115 } 119 }
OLDNEW
« src/GlobalJsObject.cpp ('K') | « src/Utils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld