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

Side by Side Diff: src/JsEngine.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/DefaultWebRequestWinInet.cpp ('k') | src/WebRequestJsObject.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
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 <AdblockPlus.h> 18 #include <AdblockPlus.h>
19 #include "GlobalJsObject.h" 19 #include "GlobalJsObject.h"
20 #include "JsContext.h" 20 #include "JsContext.h"
21 #include "JsError.h" 21 #include "JsError.h"
22 #include "Utils.h" 22 #include "Utils.h"
23 #include "DefaultTimer.h" 23 #include "DefaultTimer.h"
24 #include "DefaultWebRequest.h"
24 #include <libplatform/libplatform.h> 25 #include <libplatform/libplatform.h>
25 26
26 namespace 27 namespace
27 { 28 {
28 v8::Handle<v8::Script> CompileScript(v8::Isolate* isolate, 29 v8::Handle<v8::Script> CompileScript(v8::Isolate* isolate,
29 const std::string& source, const std::string& filename) 30 const std::string& source, const std::string& filename)
30 { 31 {
31 using AdblockPlus::Utils::ToV8String; 32 using AdblockPlus::Utils::ToV8String;
32 const v8::Handle<v8::String> v8Source = ToV8String(isolate, source); 33 const v8::Handle<v8::String> v8Source = ToV8String(isolate, source);
33 if (filename.length()) 34 if (filename.length())
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return TimerPtr(new DefaultTimer()); 79 return TimerPtr(new DefaultTimer());
79 } 80 }
80 81
81 FileSystemPtr AdblockPlus::CreateDefaultFileSystem() 82 FileSystemPtr AdblockPlus::CreateDefaultFileSystem()
82 { 83 {
83 return FileSystemPtr(new DefaultFileSystem(std::make_shared<DefaultFileSystemS ync>())); 84 return FileSystemPtr(new DefaultFileSystem(std::make_shared<DefaultFileSystemS ync>()));
84 } 85 }
85 86
86 WebRequestPtr AdblockPlus::CreateDefaultWebRequest() 87 WebRequestPtr AdblockPlus::CreateDefaultWebRequest()
87 { 88 {
88 return WebRequestPtr(new DefaultWebRequest(std::make_shared<DefaultWebRequestS ync>())); 89 return WebRequestPtr(new DefaultWebRequest(std::unique_ptr<DefaultWebRequestSy nc>(new DefaultWebRequestSync())));
89 } 90 }
90 91
91 AdblockPlus::ScopedV8Isolate::ScopedV8Isolate() 92 AdblockPlus::ScopedV8Isolate::ScopedV8Isolate()
92 { 93 {
93 V8Initializer::Init(); 94 V8Initializer::Init();
94 v8::Isolate::CreateParams isolateParams; 95 v8::Isolate::CreateParams isolateParams;
95 isolateParams.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultA llocator(); 96 isolateParams.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultA llocator();
96 isolate = v8::Isolate::New(isolateParams); 97 isolate = v8::Isolate::New(isolateParams);
97 } 98 }
98 99
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 326 }
326 327
327 void AdblockPlus::JsEngine::SetFileSystem(const AdblockPlus::FileSystemSyncPtr& val) 328 void AdblockPlus::JsEngine::SetFileSystem(const AdblockPlus::FileSystemSyncPtr& val)
328 { 329 {
329 if (!val) 330 if (!val)
330 throw std::runtime_error("FileSystem cannot be null"); 331 throw std::runtime_error("FileSystem cannot be null");
331 332
332 fileSystem.reset(new DefaultFileSystem(val)); 333 fileSystem.reset(new DefaultFileSystem(val));
333 } 334 }
334 335
335 void AdblockPlus::JsEngine::SetWebRequest(const AdblockPlus::WebRequestSharedPtr & val)
336 {
337 if (!val)
338 throw std::runtime_error("WebRequest cannot be null");
339
340 webRequestLegacy = val;
341 }
342
343 AdblockPlus::LogSystemPtr AdblockPlus::JsEngine::GetLogSystem() const 336 AdblockPlus::LogSystemPtr AdblockPlus::JsEngine::GetLogSystem() const
344 { 337 {
345 return logSystem; 338 return logSystem;
346 } 339 }
347 340
348 void AdblockPlus::JsEngine::SetLogSystem(const AdblockPlus::LogSystemPtr& val) 341 void AdblockPlus::JsEngine::SetLogSystem(const AdblockPlus::LogSystemPtr& val)
349 { 342 {
350 if (!val) 343 if (!val)
351 throw std::runtime_error("LogSystem cannot be null"); 344 throw std::runtime_error("LogSystem cannot be null");
352 345
353 logSystem = val; 346 logSystem = val;
354 } 347 }
355 348
356 349
357 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, 350 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
358 const AdblockPlus::JsValue& value) 351 const AdblockPlus::JsValue& value)
359 { 352 {
360 auto global = GetGlobalObject(); 353 auto global = GetGlobalObject();
361 global.SetProperty(name, value); 354 global.SetProperty(name, value);
362 } 355 }
OLDNEW
« no previous file with comments | « src/DefaultWebRequestWinInet.cpp ('k') | src/WebRequestJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld