| LEFT | RIGHT |
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 jsEngine->GetAsyncFileSystem()->Read(converted[0].AsString(), | 48 jsEngine->GetAsyncFileSystem()->Read(converted[0].AsString(), |
| 49 [weakJsEngine, weakCallback] | 49 [weakJsEngine, weakCallback] |
| 50 (IFileSystem::IOBuffer&& content, const std::string& error) | 50 (IFileSystem::IOBuffer&& content, const std::string& error) |
| 51 { | 51 { |
| 52 auto jsEngine = weakJsEngine.lock(); | 52 auto jsEngine = weakJsEngine.lock(); |
| 53 if (!jsEngine) | 53 if (!jsEngine) |
| 54 return; | 54 return; |
| 55 | 55 |
| 56 const JsContext context(*jsEngine); | 56 const JsContext context(*jsEngine); |
| 57 auto result = jsEngine->NewObject(); | 57 auto result = jsEngine->NewObject(); |
| 58 result.SetProperty("content", std::move(content)); | 58 result.SetStringBufferProperty("content", std::move(content)); |
| 59 if (!error.empty()) | 59 if (!error.empty()) |
| 60 result.SetProperty("error", error); | 60 result.SetProperty("error", error); |
| 61 jsEngine->TakeJsValues(weakCallback)[0].Call(result); | 61 jsEngine->TakeJsValues(weakCallback)[0].Call(result); |
| 62 }); | 62 }); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void WriteCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) | 65 void WriteCallback(const v8::FunctionCallbackInfo<v8::Value>& arguments) |
| 66 { | 66 { |
| 67 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); | 67 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arg
uments); |
| 68 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); | 68 AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) | 212 JsValue& FileSystemJsObject::Setup(JsEngine& jsEngine, JsValue& obj) |
| 213 { | 213 { |
| 214 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback)); | 214 obj.SetProperty("read", jsEngine.NewCallback(::ReadCallback)); |
| 215 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); | 215 obj.SetProperty("write", jsEngine.NewCallback(::WriteCallback)); |
| 216 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); | 216 obj.SetProperty("move", jsEngine.NewCallback(::MoveCallback)); |
| 217 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); | 217 obj.SetProperty("remove", jsEngine.NewCallback(::RemoveCallback)); |
| 218 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); | 218 obj.SetProperty("stat", jsEngine.NewCallback(::StatCallback)); |
| 219 obj.SetProperty("resolve", jsEngine.NewCallback(::ResolveCallback)); | 219 obj.SetProperty("resolve", jsEngine.NewCallback(::ResolveCallback)); |
| 220 return obj; | 220 return obj; |
| 221 } | 221 } |
| LEFT | RIGHT |