Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Issue 1634293002: mojo filesystem: Simplify full file reading/writing. (Closed)

Created:
4 years, 11 months ago by Elliot Glaysher
Modified:
4 years, 11 months ago
Reviewers:
sky
CC:
chromium-reviews, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, darin (slow to review), ben+mojo_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

mojo filesystem: Simplify full file reading/writing. One common pattern that's coming up multiple times is that we want to read or write the full contents of a file. The first attempt at an interface to that had was put on the File object. However, file seeking behaviour differs between platforms. Performing a seek on an empty file is safe on posix and errors on Windows. And when dealing with arbitrary File objects, we want to seek to the beginning just in case there was any previous usage on the File object. It was also cumbersome. The user was still responsible for opening the file and closing it once they were done with it. Putting these operations on Directory not only removes a bug, but also simplifies the interface. BUG=557405 Committed: https://crrev.com/fd918ae590f61f145d75c800abb8eb050ca32b06 Cr-Commit-Position: refs/heads/master@{#371845}

Patch Set 1 #

Patch Set 2 : Unit tests are nice to haves. #

Patch Set 3 : Further cleanup of pref store. #

Total comments: 4

Patch Set 4 : These sort of type things should be caught by the compiler... #

Patch Set 5 : Remove check #

Unified diffs Side-by-side diffs Delta from patch set Stats (+178 lines, -80 lines) Patch
M components/filesystem/directory_impl.h View 1 chunk +5 lines, -0 lines 0 comments Download
M components/filesystem/directory_impl.cc View 1 2 3 3 chunks +66 lines, -1 line 0 comments Download
M components/filesystem/directory_impl_unittest.cc View 1 2 chunks +88 lines, -0 lines 0 comments Download
M components/filesystem/file_impl.h View 1 chunk +0 lines, -1 line 0 comments Download
M components/filesystem/file_impl.cc View 1 chunk +0 lines, -22 lines 0 comments Download
M components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h View 1 2 2 chunks +1 line, -7 lines 0 comments Download
M components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc View 1 2 3 4 4 chunks +12 lines, -45 lines 0 comments Download
M components/filesystem/public/interfaces/directory.mojom View 1 chunk +6 lines, -0 lines 0 comments Download
M components/filesystem/public/interfaces/file.mojom View 1 chunk +0 lines, -4 lines 0 comments Download

Messages

Total messages: 13 (3 generated)
Elliot Glaysher
4 years, 11 months ago (2016-01-26 22:46:55 UTC) #2
sky
https://codereview.chromium.org/1634293002/diff/40001/components/filesystem/directory_impl.cc File components/filesystem/directory_impl.cc (right): https://codereview.chromium.org/1634293002/diff/40001/components/filesystem/directory_impl.cc#newcode243 components/filesystem/directory_impl.cc:243: while ((len = base_file.ReadAtCurrentPos(buf.get(), kBufferSize)) > 0) ReadAtCurrentPos returns ...
4 years, 11 months ago (2016-01-27 01:08:40 UTC) #3
Elliot Glaysher
https://codereview.chromium.org/1634293002/diff/40001/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc File components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc (right): https://codereview.chromium.org/1634293002/diff/40001/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc#newcode376 components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc:376: CHECK_EQ(FileError::OK, err); On 2016/01/27 01:08:40, sky wrote: > Seems ...
4 years, 11 months ago (2016-01-27 01:13:42 UTC) #4
sky
https://codereview.chromium.org/1634293002/diff/40001/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc File components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc (right): https://codereview.chromium.org/1634293002/diff/40001/components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc#newcode376 components/filesystem/public/cpp/prefs/filesystem_json_pref_store.cc:376: CHECK_EQ(FileError::OK, err); On 2016/01/27 01:13:42, Elliot Glaysher wrote: > ...
4 years, 11 months ago (2016-01-27 02:48:13 UTC) #5
Elliot Glaysher
ptal
4 years, 11 months ago (2016-01-27 18:10:20 UTC) #6
sky
LGTM
4 years, 11 months ago (2016-01-27 19:21:09 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1634293002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1634293002/80001
4 years, 11 months ago (2016-01-27 19:26:39 UTC) #9
commit-bot: I haz the power
Committed patchset #5 (id:80001)
4 years, 11 months ago (2016-01-27 19:42:08 UTC) #10
commit-bot: I haz the power
Patchset 5 (id:??) landed as https://crrev.com/fd918ae590f61f145d75c800abb8eb050ca32b06 Cr-Commit-Position: refs/heads/master@{#371845}
4 years, 11 months ago (2016-01-27 19:43:01 UTC) #12
Garrett Casto
4 years, 11 months ago (2016-01-27 20:38:28 UTC) #13
Message was sent while issue was closed.
A revert of this CL (patchset #5 id:80001) has been created in
https://codereview.chromium.org/1643733002/ by gcasto@chromium.org.

The reason for reverting is: Broke the Windows build. 

https://build.chromium.org/p/chromium.win/builders/Win%20x64%20GN/builds/1043...

FAILED: ninja -t msvc -e environment.x64 -- E:\b\build\goma/gomacc.exe
"E:\b\depot_tools\win_toolchain\vs2013_files\VC\bin\amd64/cl.exe" /nologo
/showIncludes /FC @obj/components/filesystem/lib/directory_impl.obj.rsp /c
../../components/filesystem/directory_impl.cc
/Foobj/components/filesystem/lib/directory_impl.obj
/Fdobj/components/filesystem/lib_cc.pdb
e:\b\build\slave\win_x64_gn\build\src\components\filesystem\directory_impl.cc(274)
: error C2220: warning treated as error - no 'object' file generated
e:\b\build\slave\win_x64_gn\build\src\components\filesystem\directory_impl.cc(274)
: warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss
of data
ninja: build stopped: subcommand failed..

Powered by Google App Engine
This is Rietveld 408576698