Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(845)

Side by Side Diff: chrome/browser/media_galleries/fileapi/device_media_async_file_util.h

Issue 14247034: Move Media Galleries FileAPI code out of webkit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cr-14352004
Patch Set: Add android ifdef. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 WEBKIT_FILEAPI_MEDIA_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_
6 #define WEBKIT_FILEAPI_MEDIA_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/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "webkit/fileapi/async_file_util.h" 11 #include "webkit/fileapi/async_file_util.h"
12 #include "webkit/storage/webkit_storage_export.h"
13 12
14 namespace base { 13 namespace base {
15 class Time; 14 class Time;
16 } 15 }
17 16
18 namespace fileapi { 17 namespace fileapi {
19
20 class FileSystemOperationContext; 18 class FileSystemOperationContext;
21 class FileSystemURL; 19 class FileSystemURL;
20 }
22 21
23 class WEBKIT_STORAGE_EXPORT_PRIVATE DeviceMediaAsyncFileUtil 22 namespace chrome {
24 : public AsyncFileUtil { 23
24 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil {
25 public: 25 public:
26 virtual ~DeviceMediaAsyncFileUtil(); 26 virtual ~DeviceMediaAsyncFileUtil();
27 27
28 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if 28 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if
29 // asynchronous operation is not supported. Callers own the returned 29 // asynchronous operation is not supported. Callers own the returned
30 // object. 30 // object.
31 static DeviceMediaAsyncFileUtil* Create(const base::FilePath& profile_path); 31 static DeviceMediaAsyncFileUtil* Create(const base::FilePath& profile_path);
32 32
33 // AsyncFileUtil overrides. 33 // AsyncFileUtil overrides.
34 virtual bool CreateOrOpen( 34 virtual bool CreateOrOpen(
35 FileSystemOperationContext* context, 35 fileapi::FileSystemOperationContext* context,
36 const FileSystemURL& url, 36 const fileapi::FileSystemURL& url,
37 int file_flags, 37 int file_flags,
38 const CreateOrOpenCallback& callback) OVERRIDE; 38 const CreateOrOpenCallback& callback) OVERRIDE;
39 virtual bool EnsureFileExists( 39 virtual bool EnsureFileExists(
40 FileSystemOperationContext* context, 40 fileapi::FileSystemOperationContext* context,
41 const FileSystemURL& url, 41 const fileapi::FileSystemURL& url,
42 const EnsureFileExistsCallback& callback) OVERRIDE; 42 const EnsureFileExistsCallback& callback) OVERRIDE;
43 virtual bool CreateDirectory( 43 virtual bool CreateDirectory(
44 FileSystemOperationContext* context, 44 fileapi::FileSystemOperationContext* context,
45 const FileSystemURL& url, 45 const fileapi::FileSystemURL& url,
46 bool exclusive, 46 bool exclusive,
47 bool recursive, 47 bool recursive,
48 const StatusCallback& callback) OVERRIDE; 48 const StatusCallback& callback) OVERRIDE;
49 virtual bool GetFileInfo( 49 virtual bool GetFileInfo(
50 FileSystemOperationContext* context, 50 fileapi::FileSystemOperationContext* context,
51 const FileSystemURL& url, 51 const fileapi::FileSystemURL& url,
52 const GetFileInfoCallback& callback) OVERRIDE; 52 const GetFileInfoCallback& callback) OVERRIDE;
53 virtual bool ReadDirectory( 53 virtual bool ReadDirectory(
54 FileSystemOperationContext* context, 54 fileapi::FileSystemOperationContext* context,
55 const FileSystemURL& url, 55 const fileapi::FileSystemURL& url,
56 const ReadDirectoryCallback& callback) OVERRIDE; 56 const ReadDirectoryCallback& callback) OVERRIDE;
57 virtual bool Touch( 57 virtual bool Touch(
58 FileSystemOperationContext* context, 58 fileapi::FileSystemOperationContext* context,
59 const FileSystemURL& url, 59 const fileapi::FileSystemURL& url,
60 const base::Time& last_access_time, 60 const base::Time& last_access_time,
61 const base::Time& last_modified_time, 61 const base::Time& last_modified_time,
62 const StatusCallback& callback) OVERRIDE; 62 const StatusCallback& callback) OVERRIDE;
63 virtual bool Truncate( 63 virtual bool Truncate(
64 FileSystemOperationContext* context, 64 fileapi::FileSystemOperationContext* context,
65 const FileSystemURL& url, 65 const fileapi::FileSystemURL& url,
66 int64 length, 66 int64 length,
67 const StatusCallback& callback) OVERRIDE; 67 const StatusCallback& callback) OVERRIDE;
68 virtual bool CopyFileLocal( 68 virtual bool CopyFileLocal(
69 FileSystemOperationContext* context, 69 fileapi::FileSystemOperationContext* context,
70 const FileSystemURL& src_url, 70 const fileapi::FileSystemURL& src_url,
71 const FileSystemURL& dest_url, 71 const fileapi::FileSystemURL& dest_url,
72 const StatusCallback& callback) OVERRIDE; 72 const StatusCallback& callback) OVERRIDE;
73 virtual bool MoveFileLocal( 73 virtual bool MoveFileLocal(
74 FileSystemOperationContext* context, 74 fileapi::FileSystemOperationContext* context,
75 const FileSystemURL& src_url, 75 const fileapi::FileSystemURL& src_url,
76 const FileSystemURL& dest_url, 76 const fileapi::FileSystemURL& dest_url,
77 const StatusCallback& callback) OVERRIDE; 77 const StatusCallback& callback) OVERRIDE;
78 virtual bool CopyInForeignFile( 78 virtual bool CopyInForeignFile(
79 FileSystemOperationContext* context, 79 fileapi::FileSystemOperationContext* context,
80 const base::FilePath& src_file_path, 80 const base::FilePath& src_file_path,
81 const FileSystemURL& dest_url, 81 const fileapi::FileSystemURL& dest_url,
82 const StatusCallback& callback) OVERRIDE; 82 const StatusCallback& callback) OVERRIDE;
83 virtual bool DeleteFile( 83 virtual bool DeleteFile(
84 FileSystemOperationContext* context, 84 fileapi::FileSystemOperationContext* context,
85 const FileSystemURL& url, 85 const fileapi::FileSystemURL& url,
86 const StatusCallback& callback) OVERRIDE; 86 const StatusCallback& callback) OVERRIDE;
87 virtual bool DeleteDirectory( 87 virtual bool DeleteDirectory(
88 FileSystemOperationContext* context, 88 fileapi::FileSystemOperationContext* context,
89 const FileSystemURL& url, 89 const fileapi::FileSystemURL& url,
90 const StatusCallback& callback) OVERRIDE; 90 const StatusCallback& callback) OVERRIDE;
91 virtual bool CreateSnapshotFile( 91 virtual bool CreateSnapshotFile(
92 FileSystemOperationContext* context, 92 fileapi::FileSystemOperationContext* context,
93 const FileSystemURL& url, 93 const fileapi::FileSystemURL& url,
94 const CreateSnapshotFileCallback& callback) OVERRIDE; 94 const CreateSnapshotFileCallback& callback) OVERRIDE;
95 95
96 private: 96 private:
97 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. 97 // Use Create() to get an instance of DeviceMediaAsyncFileUtil.
98 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path); 98 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path);
99 99
100 // Called when GetFileInfo method call succeeds. |file_info| 100 // Called when GetFileInfo method call succeeds. |file_info|
101 // contains the |platform_path| file details. |callback| is invoked 101 // contains the |platform_path| file details. |callback| is invoked
102 // to complete the GetFileInfo request. 102 // to complete the GetFileInfo request.
103 void OnDidGetFileInfo( 103 void OnDidGetFileInfo(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 151 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
152 base::PlatformFileError error); 152 base::PlatformFileError error);
153 153
154 // Called when the snapshot file specified by the |snapshot_file_path| is 154 // Called when the snapshot file specified by the |snapshot_file_path| is
155 // created to hold the contents of the |device_file_path|. If the snapshot 155 // created to hold the contents of the |device_file_path|. If the snapshot
156 // file is successfully created, |snapshot_file_path| will be an non-empty 156 // file is successfully created, |snapshot_file_path| will be an non-empty
157 // file path. In case of failure, |snapshot_file_path| will be an empty file 157 // file path. In case of failure, |snapshot_file_path| will be an empty file
158 // path. Forwards the CreateSnapshot request to the delegate to copy the 158 // path. Forwards the CreateSnapshot request to the delegate to copy the
159 // contents of |device_file_path| to |snapshot_file_path|. 159 // contents of |device_file_path| to |snapshot_file_path|.
160 void OnSnapshotFileCreatedRunTask( 160 void OnSnapshotFileCreatedRunTask(
161 FileSystemOperationContext* context, 161 fileapi::FileSystemOperationContext* context,
162 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 162 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
163 const base::FilePath& device_file_path, 163 const base::FilePath& device_file_path,
164 base::FilePath* snapshot_file_path); 164 base::FilePath* snapshot_file_path);
165 165
166 // Profile path. 166 // Profile path.
167 const base::FilePath profile_path_; 167 const base::FilePath profile_path_;
168 168
169 // For callbacks that may run after destruction. 169 // For callbacks that may run after destruction.
170 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; 170 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_;
171 171
172 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); 172 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil);
173 }; 173 };
174 174
175 } // namespace fileapi 175 } // namespace chrome
176 176
177 #endif // WEBKIT_FILEAPI_MEDIA_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ 177 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698