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 WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 using base::MessageLoopProxy; | 26 using base::MessageLoopProxy; |
| 27 using base::PlatformFile; | 27 using base::PlatformFile; |
| 28 using base::PlatformFileError; | 28 using base::PlatformFileError; |
| 29 using base::PlatformFileInfo; | 29 using base::PlatformFileInfo; |
| 30 | 30 |
| 31 // This class provides asynchronous access to common file routines for the | 31 // This class provides asynchronous access to common file routines for the |
| 32 // FileSystem API. | 32 // FileSystem API. |
| 33 class FileSystemFileUtilProxy { | 33 class FileSystemFileUtilProxy { |
| 34 public: | 34 public: |
| 35 typedef base::FileUtilProxy::StatusCallback StatusCallback; | 35 typedef base::FileUtilProxy::StatusCallback StatusCallback; |
| 36 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; | 36 typedef Callback4<PlatformFileError /* error code */, |
| 37 base::PassPlatformFile, | |
| 38 bool /* created */, | |
| 39 int64 /* file_size */ | |
|
brettw
2011/07/19 20:29:31
Can you document what will happen on failure? Like
kinuko
2011/07/20 13:39:35
Done.
| |
| 40 >::Type CreateOrOpenCallback; | |
| 37 typedef base::FileUtilProxy::EnsureFileExistsCallback | 41 typedef base::FileUtilProxy::EnsureFileExistsCallback |
| 38 EnsureFileExistsCallback; | 42 EnsureFileExistsCallback; |
| 39 typedef Callback3<PlatformFileError /* error code */, | 43 typedef Callback3<PlatformFileError /* error code */, |
| 40 const PlatformFileInfo& /* file_info */, | 44 const PlatformFileInfo& /* file_info */, |
| 41 const FilePath& /* platform_path, where possible */ | 45 const FilePath& /* platform_path, where possible */ |
| 42 >::Type GetFileInfoCallback; | 46 >::Type GetFileInfoCallback; |
| 43 typedef Callback2<PlatformFileError /* error code */, | 47 typedef Callback2<PlatformFileError /* error code */, |
| 44 const FilePath& /* local_path, where possible */ | 48 const FilePath& /* local_path, where possible */ |
| 45 >::Type GetLocalPathCallback; | 49 >::Type GetLocalPathCallback; |
| 46 typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback; | 50 typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback; |
| 47 | 51 |
| 48 // Creates or opens a file with the given flags. It is invalid to pass NULL | 52 // Creates or opens a file with the given flags. This also returns the |
|
brettw
2011/07/19 20:29:31
This comment initially confused me since this func
kinuko
2011/07/20 13:39:35
Removed.
| |
| 49 // for the callback. | 53 // file size for the opened file. |
| 54 // It is invalid to pass NULL for the callback. | |
| 50 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create | 55 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create |
| 51 // a new file at the given |file_path| and calls back with | 56 // a new file at the given |file_path| and calls back with |
| 52 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. | 57 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. |
| 53 static bool CreateOrOpen(const FileSystemOperationContext& context, | 58 static bool CreateOrOpenAndQuerySize( |
| 54 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 59 const FileSystemOperationContext& context, |
| 55 const FilePath& file_path, | 60 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 56 int file_flags, | 61 const FilePath& file_path, |
| 57 CreateOrOpenCallback* callback); | 62 int file_flags, |
| 63 CreateOrOpenCallback* callback); | |
| 58 | 64 |
| 59 // Close the given file handle. | 65 // Close the given file handle. |
| 60 static bool Close(const FileSystemOperationContext& context, | 66 static bool Close(const FileSystemOperationContext& context, |
| 61 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 67 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 62 PlatformFile, | 68 PlatformFile, |
| 63 StatusCallback* callback); | 69 StatusCallback* callback); |
| 64 | 70 |
| 65 // Ensures that the given |file_path| exist. This creates a empty new file | 71 // Ensures that the given |file_path| exist. This creates a empty new file |
| 66 // at |file_path| if the |file_path| does not exist. | 72 // at |file_path| if the |file_path| does not exist. |
| 67 // If a new file han not existed and is created at the |file_path|, | 73 // If a new file han not existed and is created at the |file_path|, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 int64 length, | 163 int64 length, |
| 158 StatusCallback* callback); | 164 StatusCallback* callback); |
| 159 | 165 |
| 160 private: | 166 private: |
| 161 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 167 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
| 162 }; | 168 }; |
| 163 | 169 |
| 164 } // namespace fileapi | 170 } // namespace fileapi |
| 165 | 171 |
| 166 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 172 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| OLD | NEW |