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

Side by Side Diff: src/WebRequestJsObject.cpp

Issue 29543810: Issue 5118 - Lock the platform interfaces before use (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Last details Created Sept. 13, 2017, 8:17 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/Platform.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
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 jsEngine->GetPlatform().WithWebRequest(
83 jsEngine->GetPlatform().GetWebRequest().GET(url, headers, getCallback); 83 [url, headers, getCallback](IWebRequest& webRequest)
84 {
85 webRequest.GET(url, headers, getCallback);
86 });
84 } 87 }
85 88
86 namespace 89 namespace
87 { 90 {
88 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) 91 void GETCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments)
89 { 92 {
90 try 93 try
91 { 94 {
92 AdblockPlus::JsEngine::ScheduleWebRequest(arguments); 95 AdblockPlus::JsEngine::ScheduleWebRequest(arguments);
93 } catch (const std::exception& e) 96 } catch (const std::exception& e)
94 { 97 {
95 return AdblockPlus::Utils::ThrowExceptionInJS(arguments.GetIsolate(), e.wh at()); 98 return AdblockPlus::Utils::ThrowExceptionInJS(arguments.GetIsolate(), e.wh at());
96 } 99 }
97 } 100 }
98 } 101 }
99 102
100 AdblockPlus::JsValue& AdblockPlus::WebRequestJsObject::Setup( 103 AdblockPlus::JsValue& AdblockPlus::WebRequestJsObject::Setup(
101 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj) 104 AdblockPlus::JsEngine& jsEngine, AdblockPlus::JsValue& obj)
102 { 105 {
103 obj.SetProperty("GET", jsEngine.NewCallback(::GETCallback)); 106 obj.SetProperty("GET", jsEngine.NewCallback(::GETCallback));
104 return obj; 107 return obj;
105 } 108 }
OLDNEW
« no previous file with comments | « src/Platform.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld