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

Issue 10296001: Implement File API (Closed)

Created:
April 12, 2013, 10:10 a.m. by Felix Dahlke
Modified:
April 29, 2013, 9:58 a.m.
Visibility:
Public.

Description

I've implemented the File I/O API we seem to need, that is: - read - write - move - remove - stat I began to fight duplication, but there's still some in the code base. I'm planning to create a common base class for all the JS objects with some base callback thread class like IoThread at some point.

Patch Set 1 #

Patch Set 2 : Don't pass a blog to _fileSystem.write #

Total comments: 26

Patch Set 3 : Address issues #

Total comments: 3

Patch Set 4 : Addressed all remaining issues #

Total comments: 16

Patch Set 5 : Addressed the new issues #

Unified diffs Side-by-side diffs Delta from patch set Stats (+952 lines, -201 lines) Patch
M include/AdblockPlus.h View 1 2 3 1 chunk +2 lines, -1 line 0 comments Download
A include/AdblockPlus/DefaultFileSystem.h View 1 2 3 1 chunk +21 lines, -0 lines 0 comments Download
R include/AdblockPlus/FileReader.h View 1 2 3 1 chunk +0 lines, -18 lines 0 comments Download
A include/AdblockPlus/FileSystem.h View 1 2 3 1 chunk +34 lines, -0 lines 0 comments Download
M include/AdblockPlus/FilterEngine.h View 1 2 3 1 chunk +3 lines, -5 lines 0 comments Download
M include/AdblockPlus/JsEngine.h View 3 chunks +4 lines, -4 lines 0 comments Download
A include/AdblockPlus/tr1_memory.h View 1 2 3 1 chunk +5 lines, -0 lines 0 comments Download
M lib/compat.js View 1 chunk +0 lines, -3 lines 0 comments Download
M lib/io.js View 1 3 chunks +16 lines, -103 lines 0 comments Download
M libadblockplus.gyp View 1 2 3 2 chunks +5 lines, -1 line 0 comments Download
M shell/src/Main.cpp View 1 2 3 3 chunks +2 lines, -14 lines 0 comments Download
A src/DefaultFileSystem.cpp View 1 2 3 4 1 chunk +73 lines, -0 lines 0 comments Download
R src/FileReader.cpp View 1 chunk +0 lines, -5 lines 0 comments Download
A src/FileSystemJsObject.h View 1 chunk +16 lines, -0 lines 0 comments Download
A src/FileSystemJsObject.cpp View 1 2 3 4 1 chunk +370 lines, -0 lines 0 comments Download
M src/GlobalJsObject.h View 1 chunk +5 lines, -3 lines 0 comments Download
M src/GlobalJsObject.cpp View 1 2 2 chunks +12 lines, -7 lines 0 comments Download
M src/JsEngine.cpp View 1 2 3 4 chunks +12 lines, -15 lines 0 comments Download
A src/Utils.h View 1 2 3 1 chunk +16 lines, -0 lines 0 comments Download
A src/Utils.cpp View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A test/DefaultFileSystem.cpp View 1 2 3 1 chunk +56 lines, -0 lines 0 comments Download
A test/FileSystemJsObject.cpp View 1 2 3 1 chunk +233 lines, -0 lines 0 comments Download
M test/JsEngine.cpp View 1 2 3 4 chunks +40 lines, -22 lines 0 comments Download

Messages

Total messages: 10
Felix Dahlke
April 12, 2013, 10:14 a.m. (2013-04-12 10:14:23 UTC) #1
Wladimir Palant
http://codereview.adblockplus.org/10296001/diff/5001/include/AdblockPlus/FileSystem.h File include/AdblockPlus/FileSystem.h (right): http://codereview.adblockplus.org/10296001/diff/5001/include/AdblockPlus/FileSystem.h#newcode22 include/AdblockPlus/FileSystem.h:22: virtual std::auto_ptr<std::istream> Read(const std::string& path) const = 0; I ...
April 12, 2013, 4:10 p.m. (2013-04-12 16:10:35 UTC) #2
Felix Dahlke
I'll prepare a new change set in a bit, comments below. http://codereview.adblockplus.org/10296001/diff/5001/include/AdblockPlus/FileSystem.h File include/AdblockPlus/FileSystem.h (right): ...
April 15, 2013, 3:43 a.m. (2013-04-15 03:43:34 UTC) #3
Felix Dahlke
I've addressed all the issues, except: - Use std::ostream for Write (discussed that with Wladimir) ...
April 15, 2013, 1:42 p.m. (2013-04-15 13:42:15 UTC) #4
Wladimir Palant
I assume that you want to remove JsEngine::Load() in a separate change. What about implementing ...
April 16, 2013, 6:50 a.m. (2013-04-16 06:50:13 UTC) #5
Wladimir Palant
http://codereview.adblockplus.org/10296001/diff/13001/src/WebRequestJsObject.cpp File src/WebRequestJsObject.cpp (left): http://codereview.adblockplus.org/10296001/diff/13001/src/WebRequestJsObject.cpp#oldcode20 src/WebRequestJsObject.cpp:20: } You might want to revert that change. My ...
April 16, 2013, 6:52 a.m. (2013-04-16 06:52:44 UTC) #6
Felix Dahlke
Uploaded a new change set fixing all remaining issues, adding some tests, using and std::ostream ...
April 16, 2013, 11:57 a.m. (2013-04-16 11:57:49 UTC) #7
Wladimir Palant
http://codereview.adblockplus.org/10296001/diff/29001/src/DefaultFileSystem.cpp File src/DefaultFileSystem.cpp (right): http://codereview.adblockplus.org/10296001/diff/29001/src/DefaultFileSystem.cpp#newcode1 src/DefaultFileSystem.cpp:1: #include <AdblockPlus/DefaultFileSystem.h> A general concern with this API: what ...
April 16, 2013, 1:03 p.m. (2013-04-16 13:03:41 UTC) #8
Felix Dahlke
http://codereview.adblockplus.org/10296001/diff/29001/src/DefaultFileSystem.cpp File src/DefaultFileSystem.cpp (right): http://codereview.adblockplus.org/10296001/diff/29001/src/DefaultFileSystem.cpp#newcode1 src/DefaultFileSystem.cpp:1: #include <AdblockPlus/DefaultFileSystem.h> On 2013/04/16 13:03:41, Wladimir Palant wrote: > ...
April 16, 2013, 2 p.m. (2013-04-16 14:00:09 UTC) #9
Wladimir Palant
April 16, 2013, 2:10 p.m. (2013-04-16 14:10:12 UTC) #10
LGTM

Feel free to push, I'll update my patches.

http://codereview.adblockplus.org/10296001/diff/29001/src/DefaultFileSystem.cpp
File src/DefaultFileSystem.cpp (right):

http://codereview.adblockplus.org/10296001/diff/29001/src/DefaultFileSystem.c...
src/DefaultFileSystem.cpp:1: #include <AdblockPlus/DefaultFileSystem.h>
I suspect that all of cstdio and fstream maps to ASCII variants of Windows
functions - or does OEM conversion if we are lucky. I doubt that any of these
functions recognize UTF-8.

Looking into this after commit is fine with me.

http://codereview.adblockplus.org/10296001/diff/29001/src/FileSystemJsObject.cpp
File src/FileSystemJsObject.cpp (right):

http://codereview.adblockplus.org/10296001/diff/29001/src/FileSystemJsObject....
src/FileSystemJsObject.cpp:250: if (!arguments.Length() == 2)
Weird operator precedence rules then...

Powered by Google App Engine
This is Rietveld