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: remove new empty lines Created Feb. 9, 2015, 11:02 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/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 try 94 try
94 { 95 {
95 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(a rguments); 96 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(a rguments);
96 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments) ; 97 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments) ;
97 if (converted.size() != 3u) 98 if (converted.size() != 3u)
98 throw std::runtime_error("GET requires exactly 3 arguments"); 99 throw std::runtime_error("GET requires exactly 3 arguments");
99 thread = new WebRequestThread(jsEngine, converted); 100 thread = new WebRequestThread(jsEngine, converted);
100 } 101 }
101 catch (const std::exception& e) 102 catch (const std::exception& e)
102 { 103 {
103 return v8::ThrowException(v8::String::New(e.what())); 104 using AdblockPlus::Utils::ToV8String;
105 v8::Isolate* isolate = arguments.GetIsolate();
106 return v8::ThrowException(ToV8String(isolate, e.what()));
104 } 107 }
105 thread->Start(); 108 thread->Start();
106 return v8::Undefined(); 109 return v8::Undefined();
107 } 110 }
108 } 111 }
109 112
110 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup( 113 AdblockPlus::JsValuePtr AdblockPlus::WebRequestJsObject::Setup(
111 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj) 114 AdblockPlus::JsEnginePtr jsEngine, AdblockPlus::JsValuePtr obj)
112 { 115 {
113 obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback)); 116 obj->SetProperty("GET", jsEngine->NewCallback(::GETCallback));
114 return obj; 117 return obj;
115 } 118 }
OLDNEW
« no previous file with comments | « src/Utils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld