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

Unified Diff: src/JsEngine.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Remove a #include Utils.h from test. Created June 2, 2017, 7:38 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -67,16 +67,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();
@@ -126,28 +131,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::Persistent<v8::Context>(result->GetIsolate(),
v8::Context::New(result->GetIsolate())));
auto global = result->GetGlobalObject();
@@ -305,24 +313,16 @@
return list;
}
AdblockPlus::FileSystemPtr AdblockPlus::JsEngine::GetFileSystem() const
{
return fileSystem;
}
-void AdblockPlus::JsEngine::SetFileSystem(const AdblockPlus::FileSystemPtr& val)
-{
- if (!val)
- throw std::runtime_error("FileSystem cannot be null");
-
- fileSystem = val;
-}
-
void AdblockPlus::JsEngine::SetWebRequest(const AdblockPlus::WebRequestSharedPtr& val)
{
if (!val)
throw std::runtime_error("WebRequest cannot be null");
webRequestLegacy = val;
}

Powered by Google App Engine
This is Rietveld