| OLD | NEW |
| 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 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 delete this; | 81 delete this; |
| 82 } | 82 } |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 AdblockPlus::JsEnginePtr jsEngine; | 85 AdblockPlus::JsEnginePtr jsEngine; |
| 86 std::string url; | 86 std::string url; |
| 87 AdblockPlus::HeaderList headers; | 87 AdblockPlus::HeaderList headers; |
| 88 AdblockPlus::JsValuePtr callback; | 88 AdblockPlus::JsValuePtr callback; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 v8::Handle<v8::Value> GETCallback(const v8::Arguments& arguments) | 91 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
| 92 { | 92 { |
| 93 WebRequestThread* thread; | 93 WebRequestThread* thread; |
| 94 try | 94 try |
| 95 { | 95 { |
| 96 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(a
rguments); | 96 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(a
rguments); |
| 97 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments)
; | 97 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments)
; |
| 98 if (converted.size() != 3u) | 98 if (converted.size() != 3u) |
| 99 throw std::runtime_error("GET requires exactly 3 arguments"); | 99 throw std::runtime_error("GET requires exactly 3 arguments"); |
| 100 thread = new WebRequestThread(jsEngine, converted); | 100 thread = new WebRequestThread(jsEngine, converted); |
| 101 } | 101 } |
| 102 catch (const std::exception& e) | 102 catch (const std::exception& e) |
| 103 { | 103 { |
| 104 using AdblockPlus::Utils::ToV8String; | 104 return AdblockPlus::Utils::ThrowException(arguments.GetIsolate(), e.what()
); |
| 105 v8::Isolate* isolate = arguments.GetIsolate(); | |
| 106 return v8::ThrowException(ToV8String(isolate, e.what())); | |
| 107 } | 105 } |
| 108 thread->Start(); | 106 thread->Start(); |
| 109 return v8::Undefined(); | |
| 110 } | 107 } |
| 111 } | 108 } |
| 112 | 109 |
| 113 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup( | 110 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup( |
| 114 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj) | 111 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj) |
| 115 { | 112 { |
| 116 obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback)); | 113 obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback)); |
| 117 return obj; | 114 return obj; |
| 118 } | 115 } |
| OLD | NEW |