OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_FILE_SYSTEM_PROXY_H_ | |
6 #define CHROME_BROWSER_FILE_SYSTEM_PROXY_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/platform_file.h" | |
10 #include "base/ref_counted.h" | |
11 | |
12 // This class provides asynchronous access to common file routines. | |
13 class FileSystemProxy { | |
14 public: | |
15 // 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 | |
17 // StatusCallback, in which case the operation will complete silently. | |
18 typedef Callback1<bool /* succeeded */>::Type StatusCallback; | |
19 | |
20 // Creates or opens a file with the given flags. It is invalid to pass NULL | |
21 // for the callback. | |
22 typedef Callback2<base::PassPlatformFile, bool /* created */>::Type | |
23 CreateOrOpenCallback; | |
24 static void CreateOrOpen(const FilePath& file_path, | |
25 int file_flags, | |
26 CreateOrOpenCallback* callback); | |
27 | |
28 // 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. | |
30 typedef Callback2<base::PassPlatformFile, FilePath>::Type | |
31 CreateTemporaryCallback; | |
32 static void CreateTemporary(CreateTemporaryCallback* callback); | |
33 | |
34 // Close the given file handle. | |
35 static void Close(base::PlatformFile, StatusCallback* callback); | |
36 | |
37 // Deletes a file or empty directory. | |
38 static void Delete(const FilePath& file_path, | |
39 StatusCallback* callback); | |
40 | |
41 // Deletes a directory and all of its contents. | |
42 static void RecursiveDelete(const FilePath& file_path, | |
43 StatusCallback* callback); | |
44 | |
45 private: | |
46 DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemProxy); | |
47 }; | |
48 | |
49 #endif // CHROME_BROWSER_FILE_SYSTEM_PROXY_H_ | |
OLD | NEW |