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

Side by Side Diff: src/WebRequestJsObject.cpp

Issue 29497591: Issue 5180 - remove synchronous WebRequest interface and stop exposing of DefaultWebRequest (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 25, 2017, 2:31 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
« no previous file with comments | « src/JsEngine.cpp ('k') | test/Notification.cpp » ('j') | 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 auto headersObject = jsEngine->NewObject(); 73 auto headersObject = jsEngine->NewObject();
74 for (const auto& header : response.responseHeaders) 74 for (const auto& header : response.responseHeaders)
75 { 75 {
76 headersObject.SetProperty(header.first, header.second); 76 headersObject.SetProperty(header.first, header.second);
77 } 77 }
78 resultObject.SetProperty("responseHeaders", headersObject); 78 resultObject.SetProperty("responseHeaders", headersObject);
79 79
80 webRequestParams[2].Call(resultObject); 80 webRequestParams[2].Call(resultObject);
81 }; 81 };
82 82
83 if (jsEngine->webRequestLegacy)
84 {
85 std::thread([jsEngine, url, headers, getCallback]
86 {
87 getCallback(jsEngine->webRequestLegacy->GET(url, headers));
88 }).detach();
89 return;
90 }
91
92 jsEngine->webRequest->GET(url, headers, getCallback); 83 jsEngine->webRequest->GET(url, headers, getCallback);
93 } 84 }
94 85
95 namespace 86 namespace
96 { 87 {
97 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) 88 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
98 { 89 {
99 try 90 try
100 { 91 {
101 AdblockPlus::JsEngine::ScheduleWebRequest(arguments); 92 AdblockPlus::JsEngine::ScheduleWebRequest(arguments);
102 } catch (const std::exception& e) 93 } catch (const std::exception& e)
103 { 94 {
104 return AdblockPlus::Utils::ThrowExceptionInJS(arguments.GetIsolate(), e.wh at()); 95 return AdblockPlus::Utils::ThrowExceptionInJS(arguments.GetIsolate(), e.wh at());
105 } 96 }
106 } 97 }
107 } 98 }
108 99
109 AdblockPlus::JsValue& AdblockPlus::WebRequestJsObject::Setup( 100 AdblockPlus::JsValue& AdblockPlus::WebRequestJsObject::Setup(
110 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) 101 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj)
111 { 102 {
112 obj.SetProperty("GET", jsEngine.NewCallback(::GETCallback)); 103 obj.SetProperty("GET", jsEngine.NewCallback(::GETCallback));
113 return obj; 104 return obj;
114 } 105 }
OLDNEW
« no previous file with comments | « src/JsEngine.cpp ('k') | test/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld