OLD | NEW |
| (Empty) |
1 // Copyright 2013 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_CHROMEOS_DRIVE_ASYNC_FILE_UTIL_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_ASYNC_FILE_UTIL_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/callback.h" | |
10 #include "webkit/browser/fileapi/async_file_util.h" | |
11 | |
12 namespace drive { | |
13 | |
14 class FileSystemInterface; | |
15 | |
16 namespace internal { | |
17 | |
18 // The implementation of fileapi::AsyncFileUtil for Drive File System. | |
19 class AsyncFileUtil : public fileapi::AsyncFileUtil { | |
20 public: | |
21 // Callback to return the FileSystemInterface instance. This is an | |
22 // injecting point for testing. | |
23 // Note that the callback will be copied between threads (IO and UI), and | |
24 // will be called on UI thread. | |
25 typedef base::Callback<FileSystemInterface*()> FileSystemGetter; | |
26 | |
27 explicit AsyncFileUtil(const FileSystemGetter& file_system_getter); | |
28 virtual ~AsyncFileUtil(); | |
29 | |
30 // fileapi::AsyncFileUtil overrides. | |
31 virtual void CreateOrOpen( | |
32 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
33 const fileapi::FileSystemURL& url, | |
34 int file_flags, | |
35 const CreateOrOpenCallback& callback) OVERRIDE; | |
36 virtual void EnsureFileExists( | |
37 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
38 const fileapi::FileSystemURL& url, | |
39 const EnsureFileExistsCallback& callback) OVERRIDE; | |
40 virtual void CreateDirectory( | |
41 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
42 const fileapi::FileSystemURL& url, | |
43 bool exclusive, | |
44 bool recursive, | |
45 const StatusCallback& callback) OVERRIDE; | |
46 virtual void GetFileInfo( | |
47 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
48 const fileapi::FileSystemURL& url, | |
49 const GetFileInfoCallback& callback) OVERRIDE; | |
50 virtual void ReadDirectory( | |
51 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
52 const fileapi::FileSystemURL& url, | |
53 const ReadDirectoryCallback& callback) OVERRIDE; | |
54 virtual void Touch( | |
55 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
56 const fileapi::FileSystemURL& url, | |
57 const base::Time& last_access_time, | |
58 const base::Time& last_modified_time, | |
59 const StatusCallback& callback) OVERRIDE; | |
60 virtual void Truncate( | |
61 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
62 const fileapi::FileSystemURL& url, | |
63 int64 length, | |
64 const StatusCallback& callback) OVERRIDE; | |
65 virtual void CopyFileLocal( | |
66 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
67 const fileapi::FileSystemURL& src_url, | |
68 const fileapi::FileSystemURL& dest_url, | |
69 CopyOrMoveOption option, | |
70 const CopyFileProgressCallback& progress_callback, | |
71 const StatusCallback& callback) OVERRIDE; | |
72 virtual void MoveFileLocal( | |
73 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
74 const fileapi::FileSystemURL& src_url, | |
75 const fileapi::FileSystemURL& dest_url, | |
76 CopyOrMoveOption option, | |
77 const StatusCallback& callback) OVERRIDE; | |
78 virtual void CopyInForeignFile( | |
79 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
80 const base::FilePath& src_file_path, | |
81 const fileapi::FileSystemURL& dest_url, | |
82 const StatusCallback& callback) OVERRIDE; | |
83 virtual void DeleteFile( | |
84 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
85 const fileapi::FileSystemURL& url, | |
86 const StatusCallback& callback) OVERRIDE; | |
87 virtual void DeleteDirectory( | |
88 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
89 const fileapi::FileSystemURL& url, | |
90 const StatusCallback& callback) OVERRIDE; | |
91 virtual void DeleteRecursively( | |
92 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
93 const fileapi::FileSystemURL& url, | |
94 const StatusCallback& callback) OVERRIDE; | |
95 virtual void CreateSnapshotFile( | |
96 scoped_ptr<fileapi::FileSystemOperationContext> context, | |
97 const fileapi::FileSystemURL& url, | |
98 const CreateSnapshotFileCallback& callback) OVERRIDE; | |
99 | |
100 private: | |
101 FileSystemGetter file_system_getter_; | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(AsyncFileUtil); | |
104 }; | |
105 | |
106 } // namespace internal | |
107 } // namespace drive | |
108 | |
109 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_ASYNC_FILE_UTIL_H_ | |
OLD | NEW |