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

Side by Side Diff: base/files/file_util_proxy.cc

Issue 227433006: Remove CreatePlatformFile from file_util_proxy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | base/files/file_util_proxy_unittest.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/files/file_util_proxy.h" 5 #include "base/files/file_util_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 error_ = File::FILE_ERROR_FAILED; 83 error_ = File::FILE_ERROR_FAILED;
84 return; 84 return;
85 } 85 }
86 86
87 int file_flags = 87 int file_flags =
88 PLATFORM_FILE_WRITE | 88 PLATFORM_FILE_WRITE |
89 PLATFORM_FILE_TEMPORARY | 89 PLATFORM_FILE_TEMPORARY |
90 PLATFORM_FILE_CREATE_ALWAYS | 90 PLATFORM_FILE_CREATE_ALWAYS |
91 additional_file_flags; 91 additional_file_flags;
92 92
93 error_ = File::FILE_OK; 93 File file(file_path_, file_flags);
94 // TODO(rvargas): Convert this code to use File. 94 if (!file.IsValid()) {
95 file_handle_ =
96 CreatePlatformFile(file_path_, file_flags, NULL,
97 reinterpret_cast<PlatformFileError*>(&error_));
98 if (error_ != File::FILE_OK) {
99 base::DeleteFile(file_path_, false); 95 base::DeleteFile(file_path_, false);
100 file_path_.clear(); 96 file_path_.clear();
97 error_ = file.error_details();
98 return;
101 } 99 }
100 error_ = File::FILE_OK;
101 file_handle_ = file.TakePlatformFile();
102 } 102 }
103 103
104 void Reply(const FileUtilProxy::CreateTemporaryCallback& callback) { 104 void Reply(const FileUtilProxy::CreateTemporaryCallback& callback) {
105 DCHECK(!callback.is_null()); 105 DCHECK(!callback.is_null());
106 callback.Run(error_, PassPlatformFile(&file_handle_), file_path_); 106 callback.Run(error_, PassPlatformFile(&file_handle_), file_path_);
107 } 107 }
108 108
109 private: 109 private:
110 scoped_refptr<TaskRunner> task_runner_; 110 scoped_refptr<TaskRunner> task_runner_;
111 PlatformFile file_handle_; 111 PlatformFile file_handle_;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 File::Error CreateOrOpenAdapter( 206 File::Error CreateOrOpenAdapter(
207 const FilePath& file_path, int file_flags, 207 const FilePath& file_path, int file_flags,
208 PlatformFile* file_handle, bool* created) { 208 PlatformFile* file_handle, bool* created) {
209 DCHECK(file_handle); 209 DCHECK(file_handle);
210 DCHECK(created); 210 DCHECK(created);
211 if (!DirectoryExists(file_path.DirName())) { 211 if (!DirectoryExists(file_path.DirName())) {
212 // If its parent does not exist, should return NOT_FOUND error. 212 // If its parent does not exist, should return NOT_FOUND error.
213 return File::FILE_ERROR_NOT_FOUND; 213 return File::FILE_ERROR_NOT_FOUND;
214 } 214 }
215 File::Error error = File::FILE_OK; 215
216 *file_handle = 216 File file(file_path, file_flags);
217 CreatePlatformFile(file_path, file_flags, created, 217 if (!file.IsValid())
218 reinterpret_cast<PlatformFileError*>(&error)); 218 return file.error_details();
219 return error; 219
220 *file_handle = file.TakePlatformFile();
221 *created = file.created();
222 return File::FILE_OK;
220 } 223 }
221 224
222 File::Error CloseAdapter(PlatformFile file_handle) { 225 File::Error CloseAdapter(PlatformFile file_handle) {
223 if (!ClosePlatformFile(file_handle)) { 226 if (!ClosePlatformFile(file_handle)) {
224 return File::FILE_ERROR_FAILED; 227 return File::FILE_ERROR_FAILED;
225 } 228 }
226 return File::FILE_OK; 229 return File::FILE_OK;
227 } 230 }
228 231
229 File::Error DeleteAdapter(const FilePath& file_path, bool recursive) { 232 File::Error DeleteAdapter(const FilePath& file_path, bool recursive) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 bool FileUtilProxy::RelayClose( 425 bool FileUtilProxy::RelayClose(
423 TaskRunner* task_runner, 426 TaskRunner* task_runner,
424 const CloseTask& close_task, 427 const CloseTask& close_task,
425 PlatformFile file_handle, 428 PlatformFile file_handle,
426 const StatusCallback& callback) { 429 const StatusCallback& callback) {
427 return base::PostTaskAndReplyWithResult( 430 return base::PostTaskAndReplyWithResult(
428 task_runner, FROM_HERE, Bind(close_task, file_handle), callback); 431 task_runner, FROM_HERE, Bind(close_task, file_handle), callback);
429 } 432 }
430 433
431 } // namespace base 434 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/files/file_util_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698