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_old.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/file_util_proxy.h" | 12 #include "base/file_util_proxy.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
15 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class MessageLoopProxy; | 18 class MessageLoopProxy; |
19 class Time; | 19 class Time; |
20 } | 20 } |
21 | 21 |
22 namespace fileapi { | 22 namespace fileapi { |
23 | 23 |
24 class FileSystemOperationContext; | 24 class FileSystemOperationContext; |
25 | 25 |
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::Entry Entry; |
36 typedef base::FileUtilProxy::CreateOrOpenCallback CreateOrOpenCallback; | 36 |
37 typedef base::FileUtilProxy::EnsureFileExistsCallback | 37 // TODO(kinuko): replace them with new callback code. |
38 EnsureFileExistsCallback; | 38 typedef Callback1<PlatformFileError>::Type StatusCallback; |
| 39 typedef Callback3<PlatformFileError /* error code */, |
| 40 base::PassPlatformFile, |
| 41 bool /* created */>::Type CreateOrOpenCallback; |
| 42 typedef Callback2<PlatformFileError /* error code */, |
| 43 bool /* created */>::Type EnsureFileExistsCallback; |
39 typedef Callback3<PlatformFileError /* error code */, | 44 typedef Callback3<PlatformFileError /* error code */, |
40 const PlatformFileInfo& /* file_info */, | 45 const PlatformFileInfo& /* file_info */, |
41 const FilePath& /* platform_path, where possible */ | 46 const FilePath& /* platform_path, where possible */ |
42 >::Type GetFileInfoCallback; | 47 >::Type GetFileInfoCallback; |
43 typedef Callback2<PlatformFileError /* error code */, | 48 typedef Callback2<PlatformFileError /* error code */, |
44 const FilePath& /* local_path, where possible */ | 49 const FilePath& /* local_path, where possible */ |
45 >::Type GetLocalPathCallback; | 50 >::Type GetLocalPathCallback; |
46 typedef base::FileUtilProxy::ReadDirectoryCallback ReadDirectoryCallback; | 51 typedef Callback2<PlatformFileError /* error code */, |
| 52 const std::vector<Entry>&>::Type ReadDirectoryCallback; |
47 | 53 |
48 // Creates or opens a file with the given flags. It is invalid to pass NULL | 54 // Creates or opens a file with the given flags. It is invalid to pass NULL |
49 // for the callback. | 55 // for the callback. |
50 // If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to create | 56 // 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 | 57 // a new file at the given |file_path| and calls back with |
52 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. | 58 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. |
53 static bool CreateOrOpen(const FileSystemOperationContext& context, | 59 static bool CreateOrOpen(const FileSystemOperationContext& context, |
54 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 60 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
55 const FilePath& file_path, | 61 const FilePath& file_path, |
56 int file_flags, | 62 int file_flags, |
(...skipping 100 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 |