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

Unified Diff: src/JsEngine.cpp

Issue 29369557: Issue #4692 - Rewrite I/O tasks to avoid engine self-reference
Patch Set: Created Dec. 28, 2016, 5:34 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
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | src/JsEngineInternal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/JsEngine.cpp
===================================================================
--- a/src/JsEngine.cpp
+++ b/src/JsEngine.cpp
@@ -16,6 +16,7 @@
*/
#include <AdblockPlus.h>
+#include "FileSystemJsObject.h"
#include "GlobalJsObject.h"
#include "JsContext.h"
#include "JsEngineInternal.h"
@@ -111,14 +112,21 @@
const v8::Context::Scope contextScope(GetContextAsLocal());
auto globalObject = GetGlobalObject();
// Timeout
- auto propertyName = AdblockPlus::Utils::ToV8String(GetIsolate(), "setTimeout");
- globalObject->Set(propertyName, MakeCallback(::CallbackForSetTimeout));
+ globalObject->Set(ToV8String("setTimeout"), MakeCallback(::CallbackForSetTimeout));
// Web request
auto auxiliaryObject = v8::Object::New();
- propertyName = AdblockPlus::Utils::ToV8String(GetIsolate(), "GET");
- auxiliaryObject->Set(propertyName, MakeCallback(::GETCallback));
- propertyName = AdblockPlus::Utils::ToV8String(GetIsolate(), "_webRequest");
- globalObject->Set(propertyName, auxiliaryObject);
+ auxiliaryObject->Set(ToV8String("GET"), MakeCallback(::GETCallback));
+ globalObject->Set(ToV8String("_webRequest"), auxiliaryObject);
+ // File system I/O
+ auxiliaryObject = v8::Object::New();
+ auxiliaryObject->Set(ToV8String("read"), MakeCallback(::ReadCallback));
+ auxiliaryObject->Set(ToV8String("write"), MakeCallback(::WriteCallback));
+ auxiliaryObject->Set(ToV8String("move"), MakeCallback(::MoveCallback));
+ auxiliaryObject->Set(ToV8String("remove"), MakeCallback(::RemoveCallback));
+ auxiliaryObject->Set(ToV8String("stat"), MakeCallback(::StatCallback));
+ auxiliaryObject->Set(ToV8String("resolve"), MakeCallback(::ResolveCallback));
+ globalObject->Set(ToV8String("_fileSystem"), auxiliaryObject);
+
// TODO: Move the rest of the global object initializations here
}
@@ -305,6 +313,11 @@
return static_cast<JsEngineInternal*>(v8::Local<v8::External>::Cast(arguments.Data())->Value());
}
+v8::Local<v8::String> JsEngineInternal::ToV8String(const std::string& s)
+{
+ return AdblockPlus::Utils::ToV8String(GetIsolate(), s);
+}
+
AdblockPlus::JsValueList AdblockPlus::JsEngine::ConvertArguments(const v8::Arguments& arguments)
{
const JsContext context(shared_from_this());
« no previous file with comments | « src/GlobalJsObject.cpp ('k') | src/JsEngineInternal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld