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

Side by Side Diff: webkit/fileapi/file_system_operation.cc

Issue 3717001: Make sure we close the file_handle when we create (but not open) a new file (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: changed the flag name Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« base/file_util_proxy.h ('K') | « base/file_util_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_operation.h" 5 #include "webkit/fileapi/file_system_operation.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "net/url_request/url_request_context.h" 8 #include "net/url_request/url_request_context.h"
9 #include "webkit/fileapi/file_system_callback_dispatcher.h" 9 #include "webkit/fileapi/file_system_callback_dispatcher.h"
10 #include "webkit/fileapi/file_writer_delegate.h" 10 #include "webkit/fileapi/file_writer_delegate.h"
(...skipping 18 matching lines...) Expand all
29 base::FileUtilProxy::Close(proxy_, file_writer_delegate_->file(), NULL); 29 base::FileUtilProxy::Close(proxy_, file_writer_delegate_->file(), NULL);
30 } 30 }
31 31
32 void FileSystemOperation::CreateFile(const FilePath& path, 32 void FileSystemOperation::CreateFile(const FilePath& path,
33 bool exclusive) { 33 bool exclusive) {
34 #ifndef NDEBUG 34 #ifndef NDEBUG
35 DCHECK(kOperationNone == pending_operation_); 35 DCHECK(kOperationNone == pending_operation_);
36 pending_operation_ = kOperationCreateFile; 36 pending_operation_ = kOperationCreateFile;
37 #endif 37 #endif
38 38
39 base::FileUtilProxy::CreateOrOpen( 39 base::FileUtilProxy::Create(
40 proxy_, path, base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ, 40 proxy_, path, base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_READ,
41 callback_factory_.NewCallback( 41 callback_factory_.NewCallback(
42 exclusive ? &FileSystemOperation::DidCreateFileExclusive 42 exclusive ? &FileSystemOperation::DidCreateFileExclusive
43 : &FileSystemOperation::DidCreateFileNonExclusive)); 43 : &FileSystemOperation::DidCreateFileNonExclusive));
44 } 44 }
45 45
46 void FileSystemOperation::CreateDirectory(const FilePath& path, 46 void FileSystemOperation::CreateDirectory(const FilePath& path,
47 bool exclusive, 47 bool exclusive,
48 bool recursive) { 48 bool recursive) {
49 #ifndef NDEBUG 49 #ifndef NDEBUG
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 const GURL& blob_url, 138 const GURL& blob_url,
139 int64 offset) { 139 int64 offset) {
140 #ifndef NDEBUG 140 #ifndef NDEBUG
141 DCHECK(kOperationNone == pending_operation_); 141 DCHECK(kOperationNone == pending_operation_);
142 pending_operation_ = kOperationWrite; 142 pending_operation_ = kOperationWrite;
143 #endif 143 #endif
144 DCHECK(blob_url.is_valid()); 144 DCHECK(blob_url.is_valid());
145 file_writer_delegate_.reset(new FileWriterDelegate(this, offset)); 145 file_writer_delegate_.reset(new FileWriterDelegate(this, offset));
146 blob_request_.reset(new URLRequest(blob_url, file_writer_delegate_.get())); 146 blob_request_.reset(new URLRequest(blob_url, file_writer_delegate_.get()));
147 blob_request_->set_context(url_request_context); 147 blob_request_->set_context(url_request_context);
148 base::FileUtilProxy::CreateOrOpen( 148 base::FileUtilProxy::Create(
149 proxy_, 149 proxy_,
150 path, 150 path,
151 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE | 151 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE |
152 base::PLATFORM_FILE_ASYNC, 152 base::PLATFORM_FILE_ASYNC,
153 callback_factory_.NewCallback( 153 callback_factory_.NewCallback(
154 &FileSystemOperation::OnFileOpenedForWrite)); 154 &FileSystemOperation::OnFileOpenedForWrite));
155 } 155 }
156 156
157 void FileSystemOperation::OnFileOpenedForWrite( 157 void FileSystemOperation::OnFileOpenedForWrite(
158 base::PlatformFileError rv, 158 base::PlatformFileError rv,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 void FileSystemOperation::DidTouchFile(base::PlatformFileError rv) { 310 void FileSystemOperation::DidTouchFile(base::PlatformFileError rv) {
311 if (rv == base::PLATFORM_FILE_OK) 311 if (rv == base::PLATFORM_FILE_OK)
312 dispatcher_->DidSucceed(); 312 dispatcher_->DidSucceed();
313 else 313 else
314 dispatcher_->DidFail(rv); 314 dispatcher_->DidFail(rv);
315 } 315 }
316 316
317 } // namespace fileapi 317 } // namespace fileapi
OLDNEW
« base/file_util_proxy.h ('K') | « base/file_util_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698