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_export.h" | 10 #include "base/base_export.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 // Holds metadata for file or directory entry. | 26 // Holds metadata for file or directory entry. |
27 struct Entry { | 27 struct Entry { |
28 FilePath::StringType name; | 28 FilePath::StringType name; |
29 bool is_directory; | 29 bool is_directory; |
30 int64 size; | 30 int64 size; |
31 base::Time last_modified_time; | 31 base::Time last_modified_time; |
32 }; | 32 }; |
33 | 33 |
34 // This callback is used by methods that report only an error code. It is | 34 // This callback is used by methods that report only an error code. It is |
35 // valid to pass a null callback to any function that takes a StatusCallback, | 35 // valid to pass StatusCallback() to any function that takes a StatusCallback, |
36 // in which case the operation will complete silently. | 36 // in which case the operation will complete silently. |
37 typedef Callback<void(PlatformFileError)> StatusCallback; | 37 typedef Callback<void(PlatformFileError)> StatusCallback; |
38 | 38 |
39 typedef Callback<void(PlatformFileError, | 39 typedef Callback<void(PlatformFileError, |
40 PassPlatformFile, | 40 PassPlatformFile, |
41 bool /* created */)> CreateOrOpenCallback; | 41 bool /* created */)> CreateOrOpenCallback; |
42 typedef Callback<void(PlatformFileError, | 42 typedef Callback<void(PlatformFileError, |
43 PassPlatformFile, | 43 PassPlatformFile, |
44 FilePath)> CreateTemporaryCallback; | 44 FilePath)> CreateTemporaryCallback; |
45 typedef Callback<void(PlatformFileError, | 45 typedef Callback<void(PlatformFileError, |
46 const PlatformFileInfo& | 46 const PlatformFileInfo& |
47 )> GetFileInfoCallback; | 47 )> GetFileInfoCallback; |
48 typedef Callback<void(PlatformFileError, | 48 typedef Callback<void(PlatformFileError, |
49 const char* /* data */, | 49 const char* /* data */, |
50 int /* bytes read */)> ReadCallback; | 50 int /* bytes read */)> ReadCallback; |
51 typedef Callback<void(PlatformFileError, | 51 typedef Callback<void(PlatformFileError, |
52 int /* bytes written */)> WriteCallback; | 52 int /* bytes written */)> WriteCallback; |
53 | 53 |
54 typedef Callback<PlatformFileError(PlatformFile*, bool*)> CreateOrOpenTask; | |
55 typedef Callback<PlatformFileError(PlatformFile)> CloseTask; | |
56 | |
57 // Creates or opens a file with the given flags. It is invalid to pass a null | 54 // Creates or opens a file with the given flags. It is invalid to pass a null |
58 // callback. If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to | 55 // callback. If PLATFORM_FILE_CREATE is set in |file_flags| it always tries to |
59 // create a new file at the given |file_path| and calls back with | 56 // create a new file at the given |file_path| and calls back with |
60 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. | 57 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. |
61 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 58 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
62 const FilePath& file_path, | 59 const FilePath& file_path, |
63 int file_flags, | 60 int file_flags, |
64 const CreateOrOpenCallback& callback); | 61 const CreateOrOpenCallback& callback); |
65 | 62 |
66 // Creates a temporary file for writing. The path and an open file handle are | 63 // Creates a temporary file for writing. The path and an open file handle are |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 const FilePath& path, | 157 const FilePath& path, |
161 int64 length, | 158 int64 length, |
162 const StatusCallback& callback); | 159 const StatusCallback& callback); |
163 | 160 |
164 // Flushes a file. The callback can be null. | 161 // Flushes a file. The callback can be null. |
165 static bool Flush( | 162 static bool Flush( |
166 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 163 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
167 PlatformFile file, | 164 PlatformFile file, |
168 const StatusCallback& callback); | 165 const StatusCallback& callback); |
169 | 166 |
170 // Relay helpers. | |
171 static bool RelayCreateOrOpen( | |
172 scoped_refptr<MessageLoopProxy> message_loop_proxy, | |
173 const CreateOrOpenTask& open_task, | |
174 const CloseTask& close_task, | |
175 const CreateOrOpenCallback& callback); | |
176 | |
177 static bool RelayClose( | |
178 scoped_refptr<MessageLoopProxy> message_loop_proxy, | |
179 const CloseTask& close_task, | |
180 PlatformFile, | |
181 const StatusCallback& callback); | |
182 | |
183 private: | 167 private: |
184 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); | 168 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); |
185 }; | 169 }; |
186 | 170 |
187 } // namespace base | 171 } // namespace base |
188 | 172 |
189 #endif // BASE_FILE_UTIL_PROXY_H_ | 173 #endif // BASE_FILE_UTIL_PROXY_H_ |
OLD | NEW |