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

Issue 3717001: Make sure we close the file_handle when we create (but not open) a new file (Closed)

Created:
10 years, 2 months ago by kinuko
Modified:
9 years, 7 months ago
CC:
chromium-reviews, darin-cc_chromium.org, brettw-cc_chromium.org, michaeln
Visibility:
Public.

Description

Make sure we close the file_handle when we create (but not open) a new file 1. Add FileUtilProxy::Create that does not leave a file_handle opened. 2. Update the file_util_operation to use FileUtilProxy::Create instead of FileUtilProxy::CreateOrOpen so that no other tasks get queued in before we close the handle. BUG=58424, 58473 TEST=fast/filesystem/ Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=62192

Patch Set 1 #

Patch Set 2 : fixed initialization order #

Total comments: 1

Patch Set 3 : changed the flag name #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+31 lines, -3 lines) Patch
M base/file_util_proxy.h View 1 chunk +7 lines, -0 lines 2 comments Download
M base/file_util_proxy.cc View 1 2 4 chunks +22 lines, -1 line 0 comments Download
M webkit/fileapi/file_system_operation.cc View 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
kinuko
10 years, 2 months ago (2010-10-11 19:09:10 UTC) #1
Kavita Kanetkar
LGTM On 2010/10/11 19:09:10, Kinuko Yasuda wrote: >
10 years, 2 months ago (2010-10-11 19:15:55 UTC) #2
Kavita Kanetkar
LGTM
10 years, 2 months ago (2010-10-11 19:16:28 UTC) #3
dumi
LGTM http://codereview.chromium.org/3717001/diff/2002/5001 File base/file_util_proxy.cc (right): http://codereview.chromium.org/3717001/diff/2002/5001#newcode122 base/file_util_proxy.cc:122: bool create_only, maybe change the name to no_file_handle, ...
10 years, 2 months ago (2010-10-11 20:27:18 UTC) #4
kinuko
On 2010/10/11 20:27:18, dumi wrote: > LGTM > > http://codereview.chromium.org/3717001/diff/2002/5001 > File base/file_util_proxy.cc (right): > ...
10 years, 2 months ago (2010-10-11 20:50:22 UTC) #5
brettw
http://codereview.chromium.org/3717001/diff/8001/9002 File base/file_util_proxy.h (right): http://codereview.chromium.org/3717001/diff/8001/9002#newcode52 base/file_util_proxy.h:52: // CreateOrOpen but it doesn't return a file handle. ...
10 years, 2 months ago (2010-10-13 22:48:32 UTC) #6
kinuko
http://codereview.chromium.org/3717001/diff/8001/9002 File base/file_util_proxy.h (right): http://codereview.chromium.org/3717001/diff/8001/9002#newcode52 base/file_util_proxy.h:52: // CreateOrOpen but it doesn't return a file handle. ...
10 years, 2 months ago (2010-10-13 23:01:28 UTC) #7
kinuko
On Wed, Oct 13, 2010 at 4:11 PM, <brettw@chromium.org> wrote: > > http://codereview.chromium.org/3717001/diff/8001/9002 > File ...
10 years, 2 months ago (2010-10-13 23:21:22 UTC) #8
brettw
10 years, 2 months ago (2010-10-13 23:24:54 UTC) #9
On Wed, Oct 13, 2010 at 4:20 PM, Kinuko Yasuda <kinuko@chromium.org> wrote:
> On Wed, Oct 13, 2010 at 4:11 PM, <brettw@chromium.org> wrote:
>>
>> http://codereview.chromium.org/3717001/diff/8001/9002
>> File base/file_util_proxy.h (right):
>>
>> http://codereview.chromium.org/3717001/diff/8001/9002#newcode52
>> base/file_util_proxy.h:52: // CreateOrOpen but it doesn't return a file
>> handle.
>> On 2010/10/13 23:01:28, Kinuko Yasuda wrote:
>>>
>>> On 2010/10/13 22:48:32, brettw wrote:
>>> > Sorry I didn't look at this before it was checked in.
>>> >
>>> > From looking at the function name, Create is a bit confusing. I
>>
>> would normally
>>>
>>> > expect from an API with functions Create and CreateOrOpen that
>>
>> Create forces
>>>
>>> the
>>> > file to be created, giving me an empty file no matter what, while
>>
>> CreateOrOpen
>>>
>>> > would create me an empty one or open an existing one. I would expect
>>
>> both to
>>>
>>> > give me the handle.
>>> > I wonder if there's some name like EnsureFileExists that might make
>>
>> the
>>>
>>> behavior
>>> > more clear?
>>
>>> I see the point, sorry for bringing the confusing change.
>>
>>> EnsureFileExists sounds clearer, but we want it to return an error
>>> (ERROR_FILE_EXIST, sort of EEXIST) if the file already exists and the
>>
>> method
>>>
>>> name may not make sense in the case?
>>
>> Hmm, I see. I think EnsureFileExists would still be okay as long as the
>> error values are documented clearly (maybe comment "The error code in
>> the callback will be XXX if the file was created, or ERROR_FILE_EXIST if
>> it already exists."
>
> Sounds like it makes sense.  I buy this.
>
>>
>> "CreateFileIfNonexistent" is the alternative I can come up with if you
>> prefer that, but it seems kind of long.
>>
>> No matter what it's called, we should be sure to document the
>> ERROR_FILE_EXIST behavior? It sounds like almost all callers will want
>> to know about this.
>
> My comment wasn't accurate enough, CreateOrOpen returns FILE_EXIST error if
> PLATFORM_FILE_CREATE file_flag is given as CreatePlatformFile does.  To make
> it clear I will add a comment to CreateOrOpen too though.
> I'll make a separate changeset to address these issues (will cc you).
> Thanks!

Thanks for helping improve this!

Brett

Powered by Google App Engine
This is Rietveld 408576698