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; |
39 typedef base::Callback<void(PlatformFileError, | 40 typedef base::Callback<void(PlatformFileError, |
40 bool /* created */ | 41 bool /* created */ |
41 )> EnsureFileExistsCallback; | 42 )> EnsureFileExistsCallback; |
42 typedef base::Callback<void(PlatformFileError, | 43 typedef base::Callback<void(PlatformFileError, |
43 const PlatformFileInfo&, | 44 const PlatformFileInfo&, |
44 const FilePath& /* platform_path */ | 45 const FilePath& /* platform_path */ |
45 )> GetFileInfoCallback; | 46 )> GetFileInfoCallback; |
46 typedef base::Callback<void(PlatformFileError, | 47 typedef base::Callback<void(PlatformFileError, |
47 const std::vector<Entry>& | 48 const std::vector<Entry>& |
48 )> ReadDirectoryCallback; | 49 )> ReadDirectoryCallback; |
49 | 50 |
50 typedef Callback2<PlatformFileError /* error code */, | 51 typedef Callback2<PlatformFileError /* error code */, |
51 const FilePath& /* local_path, where possible */ | 52 const FilePath& /* local_path, where possible */ |
52 >::Type GetLocalPathCallback; | 53 >::Type GetLocalPathCallback; |
53 | 54 |
| 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 |
54 // Ensures that the given |file_path| exist. This creates a empty new file | 72 // Ensures that the given |file_path| exist. This creates a empty new file |
55 // at |file_path| if the |file_path| does not exist. | 73 // at |file_path| if the |file_path| does not exist. |
56 // If a new file han not existed and is created at the |file_path|, | 74 // If a new file han not existed and is created at the |file_path|, |
57 // |created| of the callback argument is set true and |error code| | 75 // |created| of the callback argument is set true and |error code| |
58 // is set PLATFORM_FILE_OK. | 76 // is set PLATFORM_FILE_OK. |
59 // If the file already exists, |created| is set false and |error code| | 77 // If the file already exists, |created| is set false and |error code| |
60 // is set PLATFORM_FILE_OK. | 78 // is set PLATFORM_FILE_OK. |
61 // If the file hasn't existed but it couldn't be created for some other | 79 // If the file hasn't existed but it couldn't be created for some other |
62 // reasons, |created| is set false and |error code| indicates the error. | 80 // reasons, |created| is set false and |error code| indicates the error. |
63 static bool EnsureFileExists( | 81 static bool EnsureFileExists( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 int64 length, | 164 int64 length, |
147 const StatusCallback& callback); | 165 const StatusCallback& callback); |
148 | 166 |
149 private: | 167 private: |
150 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); | 168 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemFileUtilProxy); |
151 }; | 169 }; |
152 | 170 |
153 } // namespace fileapi | 171 } // namespace fileapi |
154 | 172 |
155 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ | 173 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_FILE_UTIL_PROXY_H_ |
OLD | NEW |