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

Side by Side Diff: src/JsEngine.cpp

Issue 29499630: Issue 4938 - fix race conditions and get rid of hacks related to DefaultFileSystem (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 27, 2017, 11:15 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/DefaultFileSystem.cpp ('k') | test/DefaultFileSystem.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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 } 79 }
80 80
81 using namespace AdblockPlus; 81 using namespace AdblockPlus;
82 82
83 TimerPtr AdblockPlus::CreateDefaultTimer() 83 TimerPtr AdblockPlus::CreateDefaultTimer()
84 { 84 {
85 return TimerPtr(new DefaultTimer()); 85 return TimerPtr(new DefaultTimer());
86 } 86 }
87 87
88 FileSystemPtr AdblockPlus::CreateDefaultFileSystem() 88 FileSystemPtr AdblockPlus::CreateDefaultFileSystem(const Scheduler& scheduler)
89 { 89 {
90 return FileSystemPtr(new DefaultFileSystem(std::unique_ptr<DefaultFileSystemSy nc>(new DefaultFileSystemSync()))); 90 return FileSystemPtr(new DefaultFileSystem(scheduler, std::unique_ptr<DefaultF ileSystemSync>(new DefaultFileSystemSync())));
91 } 91 }
92 92
93 WebRequestPtr AdblockPlus::CreateDefaultWebRequest(const Scheduler& scheduler) 93 WebRequestPtr AdblockPlus::CreateDefaultWebRequest(const Scheduler& scheduler)
94 { 94 {
95 return WebRequestPtr(new DefaultWebRequest(scheduler, std::unique_ptr<DefaultW ebRequestSync>(new DefaultWebRequestSync()))); 95 return WebRequestPtr(new DefaultWebRequest(scheduler, std::unique_ptr<DefaultW ebRequestSync>(new DefaultWebRequestSync())));
96 } 96 }
97 97
98 LogSystemPtr AdblockPlus::CreateDefaultLogSystem() 98 LogSystemPtr AdblockPlus::CreateDefaultLogSystem()
99 { 99 {
100 return LogSystemPtr(new DefaultLogSystem()); 100 return LogSystemPtr(new DefaultLogSystem());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 , timer(std::move(timer)) 160 , timer(std::move(timer))
161 , webRequest(std::move(webRequest)) 161 , webRequest(std::move(webRequest))
162 , logSystem(std::move(logSystem)) 162 , logSystem(std::move(logSystem))
163 { 163 {
164 } 164 }
165 165
166 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo, 166 AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo,
167 TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr webRequest, LogSystemP tr logSystem) 167 TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr webRequest, LogSystemP tr logSystem)
168 { 168 {
169 JsEnginePtr result(new JsEngine(timer ? std::move(timer) : CreateDefaultTimer( ), 169 JsEnginePtr result(new JsEngine(timer ? std::move(timer) : CreateDefaultTimer( ),
170 fileSystem ? std::move(fileSystem) : CreateDefaultFileSystem(), 170 fileSystem ? std::move(fileSystem) : CreateDefaultFileSystem(::DummySchedule r),
171 webRequest ? std::move(webRequest) : CreateDefaultWebRequest(::DummySchedule r), 171 webRequest ? std::move(webRequest) : CreateDefaultWebRequest(::DummySchedule r),
172 logSystem ? std::move(logSystem) : CreateDefaultLogSystem())); 172 logSystem ? std::move(logSystem) : CreateDefaultLogSystem()));
173 173
174 const v8::Locker locker(result->GetIsolate()); 174 const v8::Locker locker(result->GetIsolate());
175 const v8::Isolate::Scope isolateScope(result->GetIsolate()); 175 const v8::Isolate::Scope isolateScope(result->GetIsolate());
176 const v8::HandleScope handleScope(result->GetIsolate()); 176 const v8::HandleScope handleScope(result->GetIsolate());
177 177
178 result->context.reset(new v8::Global<v8::Context>(result->GetIsolate(), 178 result->context.reset(new v8::Global<v8::Context>(result->GetIsolate(),
179 v8::Context::New(result->GetIsolate()))); 179 v8::Context::New(result->GetIsolate())));
180 auto global = result->GetGlobalObject(); 180 auto global = result->GetGlobalObject();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 { 341 {
342 return *logSystem; 342 return *logSystem;
343 } 343 }
344 344
345 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name, 345 void AdblockPlus::JsEngine::SetGlobalProperty(const std::string& name,
346 const AdblockPlus::JsValue& value) 346 const AdblockPlus::JsValue& value)
347 { 347 {
348 auto global = GetGlobalObject(); 348 auto global = GetGlobalObject();
349 global.SetProperty(name, value); 349 global.SetProperty(name, value);
350 } 350 }
OLDNEW
« no previous file with comments | « src/DefaultFileSystem.cpp ('k') | test/DefaultFileSystem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld