| Index: test/FileSystemJsObject.cpp | 
| =================================================================== | 
| --- a/test/FileSystemJsObject.cpp | 
| +++ b/test/FileSystemJsObject.cpp | 
| @@ -16,17 +16,17 @@ | 
| */ | 
|  | 
| #include <sstream> | 
| #include "BaseJsTest.h" | 
| #include "../src/Thread.h" | 
|  | 
| namespace | 
| { | 
| -  class MockFileSystem : public AdblockPlus::FileSystem | 
| +  class MockFileSystem : public AdblockPlus::IFileSystem | 
| { | 
| public: | 
| bool success; | 
| std::string contentToRead; | 
| std::string lastWrittenPath; | 
| std::string lastWrittenContent; | 
| std::string movedFrom; | 
| std::string movedTo; | 
| @@ -36,63 +36,80 @@ | 
| bool statIsDirectory; | 
| bool statIsFile; | 
| int statLastModified; | 
|  | 
| MockFileSystem() : success(true) | 
| { | 
| } | 
|  | 
| -    std::shared_ptr<std::istream> Read(const std::string& path) const | 
| +    void Read(const std::string& path, const ReadCallback& callback) const | 
| { | 
| if (!success) | 
| -        throw std::runtime_error("Unable to read " + path); | 
| -      std::stringstream* const stream = new std::stringstream; | 
| -      *stream << contentToRead; | 
| -      return std::shared_ptr<std::istream>(stream); | 
| +      { | 
| +        callback("", "Unable to read " + path); | 
| +        return; | 
| +      } | 
| +      callback(std::string(contentToRead), ""); | 
| } | 
|  | 
| -    void Write(const std::string& path, std::istream& data) | 
| +    void Write(const std::string& path, const std::string& data, | 
| +               const Callback& callback) | 
| { | 
| if (!success) | 
| -        throw std::runtime_error("Unable to write to " + path); | 
| +      { | 
| +        callback("Unable to write to " + path); | 
| +        return; | 
| +      } | 
| lastWrittenPath = path; | 
|  | 
| -      std::stringstream content; | 
| -      content << data.rdbuf(); | 
| -      lastWrittenContent = content.str(); | 
| +      lastWrittenContent = data; | 
| +      callback(""); | 
| } | 
|  | 
| -    void Move(const std::string& fromPath, const std::string& toPath) | 
| +    void Move(const std::string& fromPath, const std::string& toPath, | 
| +              const Callback& callback) | 
| { | 
| if (!success) | 
| -        throw std::runtime_error("Unable to move " + fromPath + " to " | 
| -                                 + toPath); | 
| +      { | 
| +        callback("Unable to move " + fromPath + " to " + toPath); | 
| +        return; | 
| +      } | 
| movedFrom = fromPath; | 
| movedTo = toPath; | 
| +      callback(""); | 
| } | 
|  | 
| -    void Remove(const std::string& path) | 
| +    void Remove(const std::string& path, const Callback& callback) | 
| { | 
| if (!success) | 
| -        throw std::runtime_error("Unable to remove " + path); | 
| +      { | 
| +        callback("Unable to remove " + path); | 
| +        return; | 
| +      } | 
| removedPath = path; | 
| +      callback(""); | 
| } | 
|  | 
| -    StatResult Stat(const std::string& path) const | 
| +    void Stat(const std::string& path, | 
| +              const StatCallback& callback) const | 
| { | 
| -      if (!success) | 
| -        throw std::runtime_error("Unable to stat " + path); | 
| -      statPath = path; | 
| StatResult result; | 
| -      result.exists = statExists; | 
| -      result.isDirectory = statIsDirectory; | 
| -      result.isFile = statIsFile; | 
| -      result.lastModified = statLastModified; | 
| -      return result; | 
| +      std::string error; | 
| +      if (!success) | 
| +        error = "Unable to stat " + path; | 
| +      else | 
| +      { | 
| +        statPath = path; | 
| +        result.exists = statExists; | 
| +        result.isDirectory = statIsDirectory; | 
| +        result.isFile = statIsFile; | 
| +        result.lastModified = statLastModified; | 
| +      } | 
| +      callback(result, error); | 
| } | 
|  | 
| std::string Resolve(const std::string& path) const | 
| { | 
| if (!success) | 
| throw std::runtime_error("Unable to stat " + path); | 
| return path; | 
| } | 
| @@ -111,19 +128,20 @@ | 
|  | 
| class FileSystemJsObjectTest : public BaseJsTest | 
| { | 
| protected: | 
| MockFileSystemPtr mockFileSystem; | 
|  | 
| void SetUp() | 
| { | 
| -      BaseJsTest::SetUp(); | 
| mockFileSystem = MockFileSystemPtr(new MockFileSystem); | 
| -      jsEngine->SetFileSystem(mockFileSystem); | 
| +      JsEngineCreationParameters params; | 
| +      params.fileSystem = mockFileSystem; | 
| +      jsEngine = CreateJsEngine(std::move(params)); | 
| } | 
| }; | 
| } | 
|  | 
| TEST_F(FileSystemJsObjectTest, Read) | 
| { | 
| mockFileSystem->contentToRead = "foo"; | 
| std::string content; | 
|  |