| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; | 54 typedef Callback<PlatformFileError(PlatformFile*, bool*)> CreateOrOpenTask; |
| 55 typedef Callback<PlatformFileError(PlatformFile)> CloseTask; | 55 typedef Callback<PlatformFileError(PlatformFile)> CloseTask; |
| 56 typedef Callback<PlatformFileError(void)> FileTask; |
| 56 | 57 |
| 57 // Creates or opens a file with the given flags. It is invalid to pass a null | 58 // 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 | 59 // 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 | 60 // 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. | 61 // PLATFORM_FILE_ERROR_FILE_EXISTS if the |file_path| already exists. |
| 61 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, | 62 static bool CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 62 const FilePath& file_path, | 63 const FilePath& file_path, |
| 63 int file_flags, | 64 int file_flags, |
| 64 const CreateOrOpenCallback& callback); | 65 const CreateOrOpenCallback& callback); |
| 65 | 66 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 int64 length, | 162 int64 length, |
| 162 const StatusCallback& callback); | 163 const StatusCallback& callback); |
| 163 | 164 |
| 164 // Flushes a file. The callback can be null. | 165 // Flushes a file. The callback can be null. |
| 165 static bool Flush( | 166 static bool Flush( |
| 166 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 167 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 167 PlatformFile file, | 168 PlatformFile file, |
| 168 const StatusCallback& callback); | 169 const StatusCallback& callback); |
| 169 | 170 |
| 170 // Relay helpers. | 171 // Relay helpers. |
| 172 static bool RelayFileTask( |
| 173 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 174 const tracked_objects::Location& from_here, |
| 175 const FileTask& task, |
| 176 const StatusCallback& callback); |
| 177 |
| 171 static bool RelayCreateOrOpen( | 178 static bool RelayCreateOrOpen( |
| 172 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 179 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 173 const CreateOrOpenTask& open_task, | 180 const CreateOrOpenTask& open_task, |
| 174 const CloseTask& close_task, | 181 const CloseTask& close_task, |
| 175 const CreateOrOpenCallback& callback); | 182 const CreateOrOpenCallback& callback); |
| 176 | 183 |
| 177 static bool RelayClose( | 184 static bool RelayClose( |
| 178 scoped_refptr<MessageLoopProxy> message_loop_proxy, | 185 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 179 const CloseTask& close_task, | 186 const CloseTask& close_task, |
| 180 PlatformFile, | 187 PlatformFile, |
| 181 const StatusCallback& callback); | 188 const StatusCallback& callback); |
| 182 | 189 |
| 183 private: | 190 private: |
| 184 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); | 191 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); |
| 185 }; | 192 }; |
| 186 | 193 |
| 187 } // namespace base | 194 } // namespace base |
| 188 | 195 |
| 189 #endif // BASE_FILE_UTIL_PROXY_H_ | 196 #endif // BASE_FILE_UTIL_PROXY_H_ |
| OLD | NEW |