| 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 18 matching lines...) Expand all Loading... |
| 29 using base::PlatformFileError; | 29 using base::PlatformFileError; |
| 30 using base::PlatformFileInfo; | 30 using base::PlatformFileInfo; |
| 31 | 31 |
| 32 // This class provides asynchronous access to common file routines for the | 32 // This class provides asynchronous access to common file routines for the |
| 33 // FileSystem API. | 33 // FileSystem API. |
| 34 class FileSystemFileUtilProxy { | 34 class FileSystemFileUtilProxy { |
| 35 public: | 35 public: |
| 36 typedef base::FileUtilProxy::Entry Entry; | 36 typedef base::FileUtilProxy::Entry Entry; |
| 37 | 37 |
| 38 typedef base::FileUtilProxy::StatusCallback StatusCallback; | 38 typedef base::FileUtilProxy::StatusCallback StatusCallback; |
| 39 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; | |
| 40 typedef base::Callback<void(PlatformFileError, | 39 typedef base::Callback<void(PlatformFileError, |
| 41 bool /* created */ | 40 bool /* created */ |
| 42 )> EnsureFileExistsCallback; | 41 )> EnsureFileExistsCallback; |
| 43 typedef base::Callback<void(PlatformFileError, | 42 typedef base::Callback<void(PlatformFileError, |
| 44 const PlatformFileInfo&, | 43 const PlatformFileInfo&, |
| 45 const FilePath& /* platform_path */ | 44 const FilePath& /* platform_path */ |
| 46 )> GetFileInfoCallback; | 45 )> GetFileInfoCallback; |
| 47 typedef base::Callback<void(PlatformFileError, | 46 typedef base::Callback<void(PlatformFileError, |
| 48 const std::vector<Entry>& | 47 const std::vector<Entry>& |
| 49 )> ReadDirectoryCallback; | 48 )> ReadDirectoryCallback; |
| 50 | 49 |
| 51 typedef Callback2<PlatformFileError /* error code */, | 50 typedef Callback2<PlatformFileError /* error code */, |
| 52 const FilePath& /* local_path, where possible */ | 51 const FilePath& /* local_path, where possible */ |
| 53 >::Type GetLocalPathCallback; | 52 >::Type GetLocalPathCallback; |
| 54 | 53 |
| 55 // Creates or opens a file with the given flags. It is invalid to pass NULL | |
| 56 // for the callback. | |
| 57 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create | |
| 58 // a new file at the given |file_path| and calls back with | |
| 59 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. | |
| 60 static bool CreateOrOpen(const FileSystemOperationContext& context, | |
| 61 scoped_refptr<MessageLoopProxy> message_loop_proxy, | |
| 62 const FilePath& file_path, | |
| 63 int file_flags, | |
| 64 const CreateOrOpenCallback& callback); | |
| 65 | |
| 66 // Close the given file handle. | |
| 67 static bool Close(const FileSystemOperationContext& context, | |
| 68 scoped_refptr<MessageLoopProxy> message_loop_proxy, | |
| 69 PlatformFile, | |
| 70 const StatusCallback& callback); | |
| 71 | |
| 72 // Ensures that the given |file_path| exist. This creates a empty new file | 54 // Ensures that the given |file_path| exist. This creates a empty new file |
| 73 // at |file_path| if the |file_path| does not exist. | 55 // at |file_path| if the |file_path| does not exist. |
| 74 // If a new file han not existed and is created at the |file_path|, | 56 // If a new file han not existed and is created at the |file_path|, |
| 75 // |created| of the callback argument is set true and |error code| | 57 // |created| of the callback argument is set true and |error code| |
| 76 // is set PLATFORM_FILE_OK. | 58 // is set PLATFORM_FILE_OK. |
| 77 // If the file already exists, |created| is set false and |error code| | 59 // If the file already exists, |created| is set false and |error code| |
| 78 // is set PLATFORM_FILE_OK. | 60 // is set PLATFORM_FILE_OK. |
| 79 // If the file hasn't existed but it couldn't be created for some other | 61 // If the file hasn't existed but it couldn't be created for some other |
| 80 // reasons, |created| is set false and |error code| indicates the error. | 62 // reasons, |created| is set false and |error code| indicates the error. |
| 81 static bool EnsureFileExists( | 63 static bool EnsureFileExists( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 int64 length, | 146 int64 length, |
| 165 const StatusCallback& callback); | 147 const StatusCallback& callback); |
| 166 | 148 |
| 167 private: | 149 private: |
| 168 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 150 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
| 169 }; | 151 }; |
| 170 | 152 |
| 171 } // namespace fileapi | 153 } // namespace fileapi |
| 172 | 154 |
| 173 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 155 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
| OLD | NEW |