Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_FILE_UTIL_PROXY_H_ | 5 #ifndef BASE_FILE_UTIL_PROXY_H_ |
| 6 #define BASE_FILE_UTIL_PROXY_H_ | 6 #define BASE_FILE_UTIL_PROXY_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base_api.h" | 10 #include "base/base_api.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 // for the callback. | 57 // for the callback. |
| 58 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create | 58 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create |
| 59 // a new file at the given |file_path| and calls back with | 59 // a new file at the given |file_path| and calls back with |
| 60 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. | 60 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. |
| 61 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 61 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 62 const FilePath& file_path, | 62 const FilePath& file_path, |
| 63 int file_flags, | 63 int file_flags, |
| 64 CreateOrOpenCallback* callback); | 64 CreateOrOpenCallback* callback); |
| 65 | 65 |
| 66 // Creates a temporary file for writing. The path and an open file handle | 66 // Creates a temporary file for writing. The path and an open file handle |
| 67 // are returned. It is invalid to pass NULL for the callback. | 67 // are returned. It is invalid to pass NULL for the callback. The file |
| 68 // flags should at least set base::PLATFORM_FILE_TEMPORARY and | |
| 69 // base::PLATFORM_FILE_WRITE and some flag related to the temporary file | |
| 70 // creation. A typical example would be: | |
| 71 // base::PLATFORM_FILE_CREATE_ALWAYS | | |
|
darin (slow to review)
2011/06/04 21:06:01
i think having to specify PLATFORM_FILE_TEMPORARY
Sam Kerner (Chrome)
2011/06/06 22:19:27
I looked in to doing this a while ago, and I think
| |
| 72 // base::PLATFORM_FILE_WRITE | | |
| 73 // base::PLATFORM_FILE_TEMPORARY | |
| 74 // for synchronous writes. Add base::PLATFORM_FILE_ASYNC to support | |
| 75 // asynchronous file operations for net::FileStream. | |
| 68 static bool CreateTemporary( | 76 static bool CreateTemporary( |
| 69 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 77 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 78 int file_flags, | |
| 70 CreateTemporaryCallback* callback); | 79 CreateTemporaryCallback* callback); |
| 71 | 80 |
| 72 // Close the given file handle. | 81 // Close the given file handle. |
| 73 static bool Close(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 82 static bool Close(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 74 PlatformFile, | 83 PlatformFile, |
| 75 StatusCallback* callback); | 84 StatusCallback* callback); |
| 76 | 85 |
| 77 // Ensures that the given |file_path| exist. This creates a empty new file | 86 // Ensures that the given |file_path| exist. This creates a empty new file |
| 78 // at |file_path| if the |file_path| does not exist. | 87 // at |file_path| if the |file_path| does not exist. |
| 79 // If a new file han not existed and is created at the |file_path|, | 88 // If a new file han not existed and is created at the |file_path|, |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 PlatformFile file, | 216 PlatformFile file, |
| 208 StatusCallback* callback); | 217 StatusCallback* callback); |
| 209 | 218 |
| 210 private: | 219 private: |
| 211 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); | 220 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); |
| 212 }; | 221 }; |
| 213 | 222 |
| 214 } // namespace base | 223 } // namespace base |
| 215 | 224 |
| 216 #endif // BASE_FILE_UTIL_PROXY_H_ | 225 #endif // BASE_FILE_UTIL_PROXY_H_ |
| OLD | NEW |