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

Issue 7821013: Base: Change ReadPlatformFile to perform a best (Closed)

Created:
9 years, 3 months ago by rvargas (doing something else)
Modified:
9 years, 3 months ago
CC:
chromium-reviews, brettw-cc_chromium.org, Paweł Hajdan Jr.
Visibility:
Public.

Description

Base: Change ReadPlatformFile to perform a best effort read of the requested data, and add another function (ReadPlatformFileNoBestEffort) that just forwards the call to the OS. Now ReadPlatformFile and WritePlatformFile behave the same way. BUG=none TEST=base_unittests Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=99264

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -19 lines) Patch
M base/platform_file.h View 1 chunk +10 lines, -1 line 0 comments Download
M base/platform_file_posix.cc View 1 chunk +19 lines, -0 lines 0 comments Download
M base/platform_file_unittest.cc View 2 chunks +8 lines, -18 lines 0 comments Download
M base/platform_file_win.cc View 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
rvargas (doing something else)
9 years, 3 months ago (2011-09-01 02:39:06 UTC) #1
darin (slow to review)
Why is it valuable to make ReadPlatformFile loop? Are you worried about cases where someone ...
9 years, 3 months ago (2011-09-01 05:46:30 UTC) #2
rvargas (doing something else)
On 2011/09/01 05:46:30, darin wrote: > Why is it valuable to make ReadPlatformFile loop? Are ...
9 years, 3 months ago (2011-09-01 17:35:58 UTC) #3
darin (slow to review)
9 years, 3 months ago (2011-09-01 19:36:53 UTC) #4
On Thu, Sep 1, 2011 at 10:35 AM, <rvargas@chromium.org> wrote:

> On 2011/09/01 05:46:30, darin wrote:
>
>> Why is it valuable to make ReadPlatformFile loop?  Are you worried about
>> cases where someone allocates a buffer the size of the file, and then
>> calls
>> read once, expecting everything to be read?
>>
>
> I think it is a matter of consistency between Read and Write methods.
>
> I guess if someone is reading a whole file of arbitrary length, then a loop
> in
> the caller is the expected pattern, but I don't see why a base function
> like
> this one should require that pattern for everyone.
>
> If the purpose of the call is to read a fixed portion of a file, or even to
> read
> a whole file of a known small size, looping at the caller side is not what
> I
> would expect.
>
> I consider more natural for this interface (especially given that it has an
> explicit offset argument) to actually return what it was asked for instead
> of
> just a few bytes.
>
> I would also fix the current callers, but none of them (except a unit test)
> is
> performing a loop directly... that's why I decided to change the current
> behavior instead of having the new method implement the new behavior.
>
>
OK, LGTM



>
>
>  Ordinarily, I would expect that that is not such a common case since the
>> buffer could be large, but maybe we have code like that?  I would instead
>> expect that people would use a temp buffer of fixed size and read into
>> that
>> until they hit EOF.  This means that they would not likely be bothered by
>> a
>> call to ReadPlatformFile returning a partial result.
>>
>
>  -Darin
>>
>
>
>
>
http://codereview.chromium.**org/7821013/<http://codereview.chromium.org/7821...
>

Powered by Google App Engine
This is Rietveld 408576698