OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_FILE_SYSTEM_PROXY_H_ | 5 #ifndef BASE_FILE_SYSTEM_PROXY_H_ |
6 #define CHROME_BROWSER_FILE_SYSTEM_PROXY_H_ | 6 #define BASE_FILE_SYSTEM_PROXY_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/tracked_objects.h" |
| 12 |
| 13 namespace base { |
| 14 |
| 15 class MessageLoopProxy; |
11 | 16 |
12 // This class provides asynchronous access to common file routines. | 17 // This class provides asynchronous access to common file routines. |
13 class FileSystemProxy { | 18 class FileUtilProxy { |
14 public: | 19 public: |
15 // This callback is used by methods that report success with a bool. It is | 20 // This callback is used by methods that report success with a bool. It is |
16 // valid to pass NULL as the callback parameter to any function that takes a | 21 // valid to pass NULL as the callback parameter to any function that takes a |
17 // StatusCallback, in which case the operation will complete silently. | 22 // StatusCallback, in which case the operation will complete silently. |
18 typedef Callback1<bool /* succeeded */>::Type StatusCallback; | 23 typedef Callback1<bool /* succeeded */>::Type StatusCallback; |
19 | 24 |
20 // Creates or opens a file with the given flags. It is invalid to pass NULL | 25 // Creates or opens a file with the given flags. It is invalid to pass NULL |
21 // for the callback. | 26 // for the callback. |
22 typedef Callback2<base::PassPlatformFile, bool /* created */>::Type | 27 typedef Callback2<base::PassPlatformFile, bool /* created */>::Type |
23 CreateOrOpenCallback; | 28 CreateOrOpenCallback; |
24 static void CreateOrOpen(const FilePath& file_path, | 29 static void CreateOrOpen(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 30 const FilePath& file_path, |
25 int file_flags, | 31 int file_flags, |
26 CreateOrOpenCallback* callback); | 32 CreateOrOpenCallback* callback); |
27 | 33 |
28 // Creates a temporary file for writing. The path and an open file handle | 34 // Creates a temporary file for writing. The path and an open file handle |
29 // are returned. It is invalid to pass NULL for the callback. | 35 // are returned. It is invalid to pass NULL for the callback. |
30 typedef Callback2<base::PassPlatformFile, FilePath>::Type | 36 typedef Callback2<base::PassPlatformFile, FilePath>::Type |
31 CreateTemporaryCallback; | 37 CreateTemporaryCallback; |
32 static void CreateTemporary(CreateTemporaryCallback* callback); | 38 static void CreateTemporary( |
| 39 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 40 CreateTemporaryCallback* callback); |
33 | 41 |
34 // Close the given file handle. | 42 // Close the given file handle. |
35 static void Close(base::PlatformFile, StatusCallback* callback); | 43 static void Close(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 44 base::PlatformFile, |
| 45 StatusCallback* callback); |
36 | 46 |
37 // Deletes a file or empty directory. | 47 // Deletes a file or empty directory. |
38 static void Delete(const FilePath& file_path, | 48 static void Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 49 const FilePath& file_path, |
39 StatusCallback* callback); | 50 StatusCallback* callback); |
40 | 51 |
41 // Deletes a directory and all of its contents. | 52 // Deletes a directory and all of its contents. |
42 static void RecursiveDelete(const FilePath& file_path, | 53 static void RecursiveDelete( |
43 StatusCallback* callback); | 54 scoped_refptr<MessageLoopProxy> message_loop_proxy, |
| 55 const FilePath& file_path, |
| 56 StatusCallback* callback); |
44 | 57 |
45 private: | 58 private: |
46 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemProxy); | 59 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); |
47 }; | 60 }; |
48 | 61 |
49 #endif // CHROME_BROWSER_FILE_SYSTEM_PROXY_H_ | 62 } // namespace base |
| 63 |
| 64 #endif // BASE_FILE_SYSTEM_PROXY_H_ |
OLD | NEW |