OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
10 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
11 #include "webkit/browser/fileapi/async_file_util.h" | 12 #include "webkit/browser/fileapi/async_file_util.h" |
12 #include "webkit/common/blob/shareable_file_reference.h" | 13 #include "webkit/common/blob/shareable_file_reference.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
16 class Time; | 17 class Time; |
17 } | 18 } |
18 | 19 |
19 namespace fileapi { | 20 namespace fileapi { |
20 class FileSystemOperationContext; | 21 class FileSystemOperationContext; |
21 class FileSystemURL; | 22 class FileSystemURL; |
22 } | 23 } |
23 | 24 |
24 namespace chrome { | 25 namespace chrome { |
25 | 26 |
26 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil { | 27 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil { |
27 public: | 28 public: |
28 virtual ~DeviceMediaAsyncFileUtil(); | 29 virtual ~DeviceMediaAsyncFileUtil(); |
29 | 30 |
30 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if | 31 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if |
31 // asynchronous operation is not supported. Callers own the returned | 32 // asynchronous operation is not supported. Callers own the returned |
32 // object. | 33 // object. |
33 static DeviceMediaAsyncFileUtil* Create(const base::FilePath& profile_path); | 34 static DeviceMediaAsyncFileUtil* Create(const base::FilePath& profile_path); |
34 | 35 |
35 // AsyncFileUtil overrides. | 36 // AsyncFileUtil overrides. |
36 virtual bool CreateOrOpen( | 37 virtual bool CreateOrOpen( |
37 fileapi::FileSystemOperationContext* context, | 38 scoped_ptr<fileapi::FileSystemOperationContext> context, |
38 const fileapi::FileSystemURL& url, | 39 const fileapi::FileSystemURL& url, |
39 int file_flags, | 40 int file_flags, |
40 const CreateOrOpenCallback& callback) OVERRIDE; | 41 const CreateOrOpenCallback& callback) OVERRIDE; |
41 virtual bool EnsureFileExists( | 42 virtual bool EnsureFileExists( |
42 fileapi::FileSystemOperationContext* context, | 43 scoped_ptr<fileapi::FileSystemOperationContext> context, |
43 const fileapi::FileSystemURL& url, | 44 const fileapi::FileSystemURL& url, |
44 const EnsureFileExistsCallback& callback) OVERRIDE; | 45 const EnsureFileExistsCallback& callback) OVERRIDE; |
45 virtual bool CreateDirectory( | 46 virtual bool CreateDirectory( |
46 fileapi::FileSystemOperationContext* context, | 47 scoped_ptr<fileapi::FileSystemOperationContext> context, |
47 const fileapi::FileSystemURL& url, | 48 const fileapi::FileSystemURL& url, |
48 bool exclusive, | 49 bool exclusive, |
49 bool recursive, | 50 bool recursive, |
50 const StatusCallback& callback) OVERRIDE; | 51 const StatusCallback& callback) OVERRIDE; |
51 virtual bool GetFileInfo( | 52 virtual bool GetFileInfo( |
52 fileapi::FileSystemOperationContext* context, | 53 scoped_ptr<fileapi::FileSystemOperationContext> context, |
53 const fileapi::FileSystemURL& url, | 54 const fileapi::FileSystemURL& url, |
54 const GetFileInfoCallback& callback) OVERRIDE; | 55 const GetFileInfoCallback& callback) OVERRIDE; |
55 virtual bool ReadDirectory( | 56 virtual bool ReadDirectory( |
56 fileapi::FileSystemOperationContext* context, | 57 scoped_ptr<fileapi::FileSystemOperationContext> context, |
57 const fileapi::FileSystemURL& url, | 58 const fileapi::FileSystemURL& url, |
58 const ReadDirectoryCallback& callback) OVERRIDE; | 59 const ReadDirectoryCallback& callback) OVERRIDE; |
59 virtual bool Touch( | 60 virtual bool Touch( |
60 fileapi::FileSystemOperationContext* context, | 61 scoped_ptr<fileapi::FileSystemOperationContext> context, |
61 const fileapi::FileSystemURL& url, | 62 const fileapi::FileSystemURL& url, |
62 const base::Time& last_access_time, | 63 const base::Time& last_access_time, |
63 const base::Time& last_modified_time, | 64 const base::Time& last_modified_time, |
64 const StatusCallback& callback) OVERRIDE; | 65 const StatusCallback& callback) OVERRIDE; |
65 virtual bool Truncate( | 66 virtual bool Truncate( |
66 fileapi::FileSystemOperationContext* context, | 67 scoped_ptr<fileapi::FileSystemOperationContext> context, |
67 const fileapi::FileSystemURL& url, | 68 const fileapi::FileSystemURL& url, |
68 int64 length, | 69 int64 length, |
69 const StatusCallback& callback) OVERRIDE; | 70 const StatusCallback& callback) OVERRIDE; |
70 virtual bool CopyFileLocal( | 71 virtual bool CopyFileLocal( |
71 fileapi::FileSystemOperationContext* context, | 72 scoped_ptr<fileapi::FileSystemOperationContext> context, |
72 const fileapi::FileSystemURL& src_url, | 73 const fileapi::FileSystemURL& src_url, |
73 const fileapi::FileSystemURL& dest_url, | 74 const fileapi::FileSystemURL& dest_url, |
74 const StatusCallback& callback) OVERRIDE; | 75 const StatusCallback& callback) OVERRIDE; |
75 virtual bool MoveFileLocal( | 76 virtual bool MoveFileLocal( |
76 fileapi::FileSystemOperationContext* context, | 77 scoped_ptr<fileapi::FileSystemOperationContext> context, |
77 const fileapi::FileSystemURL& src_url, | 78 const fileapi::FileSystemURL& src_url, |
78 const fileapi::FileSystemURL& dest_url, | 79 const fileapi::FileSystemURL& dest_url, |
79 const StatusCallback& callback) OVERRIDE; | 80 const StatusCallback& callback) OVERRIDE; |
80 virtual bool CopyInForeignFile( | 81 virtual bool CopyInForeignFile( |
81 fileapi::FileSystemOperationContext* context, | 82 scoped_ptr<fileapi::FileSystemOperationContext> context, |
82 const base::FilePath& src_file_path, | 83 const base::FilePath& src_file_path, |
83 const fileapi::FileSystemURL& dest_url, | 84 const fileapi::FileSystemURL& dest_url, |
84 const StatusCallback& callback) OVERRIDE; | 85 const StatusCallback& callback) OVERRIDE; |
85 virtual bool DeleteFile( | 86 virtual bool DeleteFile( |
86 fileapi::FileSystemOperationContext* context, | 87 scoped_ptr<fileapi::FileSystemOperationContext> context, |
87 const fileapi::FileSystemURL& url, | 88 const fileapi::FileSystemURL& url, |
88 const StatusCallback& callback) OVERRIDE; | 89 const StatusCallback& callback) OVERRIDE; |
89 virtual bool DeleteDirectory( | 90 virtual bool DeleteDirectory( |
90 fileapi::FileSystemOperationContext* context, | 91 scoped_ptr<fileapi::FileSystemOperationContext> context, |
91 const fileapi::FileSystemURL& url, | 92 const fileapi::FileSystemURL& url, |
92 const StatusCallback& callback) OVERRIDE; | 93 const StatusCallback& callback) OVERRIDE; |
93 virtual bool CreateSnapshotFile( | 94 virtual bool CreateSnapshotFile( |
94 fileapi::FileSystemOperationContext* context, | 95 scoped_ptr<fileapi::FileSystemOperationContext> context, |
95 const fileapi::FileSystemURL& url, | 96 const fileapi::FileSystemURL& url, |
96 const CreateSnapshotFileCallback& callback) OVERRIDE; | 97 const CreateSnapshotFileCallback& callback) OVERRIDE; |
97 | 98 |
98 private: | 99 private: |
99 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. | 100 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. |
100 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path); | 101 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path); |
101 | 102 |
102 // Called when GetFileInfo method call succeeds. |file_info| | 103 // Called when GetFileInfo method call succeeds. |file_info| |
103 // contains the |platform_path| file details. |callback| is invoked | 104 // contains the |platform_path| file details. |callback| is invoked |
104 // to complete the GetFileInfo request. | 105 // to complete the GetFileInfo request. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const AsyncFileUtil::CreateSnapshotFileCallback& callback, | 162 const AsyncFileUtil::CreateSnapshotFileCallback& callback, |
162 base::PlatformFileError error); | 163 base::PlatformFileError error); |
163 | 164 |
164 // Called when the snapshot file specified by the |snapshot_file_path| is | 165 // Called when the snapshot file specified by the |snapshot_file_path| is |
165 // created to hold the contents of the |device_file_path|. If the snapshot | 166 // created to hold the contents of the |device_file_path|. If the snapshot |
166 // file is successfully created, |snapshot_file_path| will be an non-empty | 167 // file is successfully created, |snapshot_file_path| will be an non-empty |
167 // file path. In case of failure, |snapshot_file_path| will be an empty file | 168 // file path. In case of failure, |snapshot_file_path| will be an empty file |
168 // path. Forwards the CreateSnapshot request to the delegate to copy the | 169 // path. Forwards the CreateSnapshot request to the delegate to copy the |
169 // contents of |device_file_path| to |snapshot_file_path|. | 170 // contents of |device_file_path| to |snapshot_file_path|. |
170 void OnSnapshotFileCreatedRunTask( | 171 void OnSnapshotFileCreatedRunTask( |
171 fileapi::FileSystemOperationContext* context, | 172 scoped_ptr<fileapi::FileSystemOperationContext> context, |
172 const AsyncFileUtil::CreateSnapshotFileCallback& callback, | 173 const AsyncFileUtil::CreateSnapshotFileCallback& callback, |
173 const base::FilePath& device_file_path, | 174 const base::FilePath& device_file_path, |
174 base::FilePath* snapshot_file_path); | 175 base::FilePath* snapshot_file_path); |
175 | 176 |
176 // Profile path. | 177 // Profile path. |
177 const base::FilePath profile_path_; | 178 const base::FilePath profile_path_; |
178 | 179 |
179 // For callbacks that may run after destruction. | 180 // For callbacks that may run after destruction. |
180 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; | 181 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; |
181 | 182 |
182 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); | 183 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); |
183 }; | 184 }; |
184 | 185 |
185 } // namespace chrome | 186 } // namespace chrome |
186 | 187 |
187 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H
_ | 188 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H
_ |
OLD | NEW |