Index: src/JsEngine.cpp |
=================================================================== |
--- a/src/JsEngine.cpp |
+++ b/src/JsEngine.cpp |
@@ -73,16 +73,21 @@ |
using namespace AdblockPlus; |
TimerPtr AdblockPlus::CreateDefaultTimer() |
{ |
return TimerPtr(new DefaultTimer()); |
} |
+FileSystemPtr AdblockPlus::CreateDefaultFileSystem() |
+{ |
+ return FileSystemPtr(new DefaultFileSystem(std::make_shared<DefaultFileSystemSync>())); |
+} |
+ |
WebRequestPtr AdblockPlus::CreateDefaultWebRequest() |
{ |
return WebRequestPtr(new DefaultWebRequest(std::make_shared<DefaultWebRequestSync>())); |
} |
AdblockPlus::ScopedV8Isolate::ScopedV8Isolate() |
{ |
V8Initializer::Init(); |
@@ -132,28 +137,31 @@ |
auto timerParams = TakeJsValues(timerParamsID); |
JsValue callback = std::move(timerParams[0]); |
timerParams.erase(timerParams.begin()); // remove callback placeholder |
timerParams.erase(timerParams.begin()); // remove timeout param |
callback.Call(timerParams); |
} |
-AdblockPlus::JsEngine::JsEngine(TimerPtr timer, WebRequestPtr webRequest) |
- : fileSystem(new DefaultFileSystem()) |
+AdblockPlus::JsEngine::JsEngine(TimerPtr timer, FileSystemPtr fileSystem, |
+ WebRequestPtr webRequest) |
+ : fileSystem(std::move(fileSystem)) |
, logSystem(new DefaultLogSystem()) |
, timer(std::move(timer)) |
, webRequest(std::move(webRequest)) |
{ |
} |
AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::New(const AppInfo& appInfo, |
- TimerPtr timer, WebRequestPtr webRequest) |
+ TimerPtr timer, FileSystemPtr fileSystem, WebRequestPtr webRequest) |
{ |
- JsEnginePtr result(new JsEngine(std::move(timer), std::move(webRequest))); |
+ JsEnginePtr result(new JsEngine(std::move(timer), |
+ std::move(fileSystem), |
+ std::move(webRequest))); |
const v8::Locker locker(result->GetIsolate()); |
const v8::Isolate::Scope isolateScope(result->GetIsolate()); |
const v8::HandleScope handleScope(result->GetIsolate()); |
result->context.reset(new v8::Global<v8::Context>(result->GetIsolate(), |
v8::Context::New(result->GetIsolate()))); |
auto global = result->GetGlobalObject(); |
@@ -306,27 +314,27 @@ |
{ |
const JsContext context(*this); |
JsValueList list; |
for (int i = 0; i < arguments.Length(); i++) |
list.push_back(JsValue(shared_from_this(), arguments[i])); |
return list; |
} |
-AdblockPlus::FileSystemPtr AdblockPlus::JsEngine::GetFileSystem() const |
+AdblockPlus::FileSystemPtr AdblockPlus::JsEngine::GetAsyncFileSystem() const |
{ |
return fileSystem; |
} |
-void AdblockPlus::JsEngine::SetFileSystem(const AdblockPlus::FileSystemPtr& val) |
+void AdblockPlus::JsEngine::SetFileSystem(const AdblockPlus::FileSystemSyncPtr& val) |
{ |
if (!val) |
throw std::runtime_error("FileSystem cannot be null"); |
- fileSystem = val; |
+ fileSystem.reset(new DefaultFileSystem(val)); |
} |
void AdblockPlus::JsEngine::SetWebRequest(const AdblockPlus::WebRequestSharedPtr& val) |
{ |
if (!val) |
throw std::runtime_error("WebRequest cannot be null"); |
webRequestLegacy = val; |