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

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

Issue 298843002: Media Galleries: Refactor DeviceMediaAsyncFileUtil. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "webkit/browser/fileapi/async_file_util.h" 12 #include "webkit/browser/fileapi/async_file_util.h"
13 #include "webkit/common/blob/shareable_file_reference.h" 13 #include "webkit/common/blob/shareable_file_reference.h"
14 14
15 namespace base {
16 class SequencedTaskRunner;
17 class Time;
18 }
19
20 namespace fileapi { 15 namespace fileapi {
21 class FileSystemOperationContext; 16 class FileSystemOperationContext;
22 class FileSystemURL; 17 class FileSystemURL;
23 } 18 }
24 19
25 namespace net {
26 class IOBuffer;
27 }
28
29 namespace webkit_blob { 20 namespace webkit_blob {
30 class FileStreamReader; 21 class FileStreamReader;
31 } 22 }
32 23
33 enum MediaFileValidationType { 24 enum MediaFileValidationType {
34 NO_MEDIA_FILE_VALIDATION, 25 NO_MEDIA_FILE_VALIDATION,
35 APPLY_MEDIA_FILE_VALIDATION, 26 APPLY_MEDIA_FILE_VALIDATION,
36 }; 27 };
37 28
38 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil { 29 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil {
39 public: 30 public:
40 virtual ~DeviceMediaAsyncFileUtil(); 31 virtual ~DeviceMediaAsyncFileUtil();
41 32
42 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if 33 // Returns an instance of DeviceMediaAsyncFileUtil.
43 // asynchronous operation is not supported. Callers own the returned 34 static scoped_ptr<DeviceMediaAsyncFileUtil> Create(
44 // object.
45 static DeviceMediaAsyncFileUtil* Create(
46 const base::FilePath& profile_path, 35 const base::FilePath& profile_path,
47 MediaFileValidationType validation_type); 36 MediaFileValidationType validation_type);
48 37
49 bool SupportsStreaming(const fileapi::FileSystemURL& url); 38 bool SupportsStreaming(const fileapi::FileSystemURL& url);
50 39
51 // AsyncFileUtil overrides. 40 // AsyncFileUtil overrides.
52 virtual void CreateOrOpen( 41 virtual void CreateOrOpen(
53 scoped_ptr<fileapi::FileSystemOperationContext> context, 42 scoped_ptr<fileapi::FileSystemOperationContext> context,
54 const fileapi::FileSystemURL& url, 43 const fileapi::FileSystemURL& url,
55 int file_flags, 44 int file_flags,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 fileapi::FileSystemContext* context); 119 fileapi::FileSystemContext* context);
131 120
132 private: 121 private:
133 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. 122 // Use Create() to get an instance of DeviceMediaAsyncFileUtil.
134 DeviceMediaAsyncFileUtil(const base::FilePath& profile_path, 123 DeviceMediaAsyncFileUtil(const base::FilePath& profile_path,
135 MediaFileValidationType validation_type); 124 MediaFileValidationType validation_type);
136 125
137 // Called when GetFileInfo method call succeeds. |file_info| contains the 126 // Called when GetFileInfo method call succeeds. |file_info| contains the
138 // file details of the requested url. |callback| is invoked to complete the 127 // file details of the requested url. |callback| is invoked to complete the
139 // GetFileInfo request. 128 // GetFileInfo request.
140 void OnDidGetFileInfo( 129 void OnDidGetFileInfo(const GetFileInfoCallback& callback,
141 const AsyncFileUtil::GetFileInfoCallback& callback, 130 const base::File::Info& file_info);
142 const base::File::Info& file_info);
143
144 // Called when GetFileInfo method call failed to get the details of file
145 // specified by the requested url. |callback| is invoked to notify the
146 // caller about the file |error|.
147 void OnGetFileInfoError(
148 const AsyncFileUtil::GetFileInfoCallback& callback,
149 base::File::Error error);
150 131
151 // Called when ReadDirectory method call succeeds. |callback| is invoked to 132 // Called when ReadDirectory method call succeeds. |callback| is invoked to
152 // complete the ReadDirectory request. 133 // complete the ReadDirectory request.
153 // 134 //
154 // If the contents of the given directory are reported in one batch, then 135 // If the contents of the given directory are reported in one batch, then
155 // |file_list| will have the list of all files/directories in the given 136 // |file_list| will have the list of all files/directories in the given
156 // directory and |has_more| will be false. 137 // directory and |has_more| will be false.
157 // 138 //
158 // If the contents of the given directory are reported in multiple chunks, 139 // If the contents of the given directory are reported in multiple chunks,
159 // |file_list| will have only a subset of all contents (the subsets reported 140 // |file_list| will have only a subset of all contents (the subsets reported
160 // in any two calls are disjoint), and |has_more| will be true, except for 141 // in any two calls are disjoint), and |has_more| will be true, except for
161 // the last chunk. 142 // the last chunk.
162 void OnDidReadDirectory( 143 void OnDidReadDirectory(
163 const AsyncFileUtil::ReadDirectoryCallback& callback, 144 const ReadDirectoryCallback& callback,
164 const AsyncFileUtil::EntryList& file_list, 145 const EntryList& file_list,
165 bool has_more); 146 bool has_more);
166 147
167 // Called when ReadDirectory method call failed to enumerate the directory 148 bool validate_media_files() const;
168 // objects. |callback| is invoked to notify the caller about the |error|
169 // that occured while reading the directory objects.
170 void OnReadDirectoryError(
171 const AsyncFileUtil::ReadDirectoryCallback& callback,
172 base::File::Error error);
173
174 // Called when the snapshot file specified by the |platform_path| is
175 // successfully created. |file_info| contains the device media file details
176 // for which the snapshot file is created.
177 void OnDidCreateSnapshotFile(
178 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
179 base::SequencedTaskRunner* media_task_runner,
180 const base::File::Info& file_info,
181 const base::FilePath& platform_path);
182
183 // Called after OnDidCreateSnapshotFile finishes media check.
184 // |callback| is invoked to complete the CreateSnapshotFile request.
185 void OnDidCheckMedia(
186 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
187 const base::File::Info& file_info,
188 scoped_refptr<webkit_blob::ShareableFileReference> platform_file,
189 base::File::Error error);
190
191 // Called when CreateSnapshotFile method call fails. |callback| is invoked to
192 // notify the caller about the |error|.
193 void OnCreateSnapshotFileError(
194 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
195 base::File::Error error);
196
197 // Called when the snapshot file specified by the |snapshot_file_path| is
198 // created to hold the contents of the url.path(). If the snapshot
199 // file is successfully created, |snapshot_file_path| will be an non-empty
200 // file path. In case of failure, |snapshot_file_path| will be an empty file
201 // path. Forwards the CreateSnapshot request to the delegate to copy the
202 // contents of url.path() to |snapshot_file_path|.
203 void OnSnapshotFileCreatedRunTask(
204 scoped_ptr<fileapi::FileSystemOperationContext> context,
205 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
206 const fileapi::FileSystemURL& url,
207 const base::FilePath& snapshot_file_path);
208 149
209 // Profile path. 150 // Profile path.
210 const base::FilePath profile_path_; 151 const base::FilePath profile_path_;
211 152
212 const MediaFileValidationType validation_type_; 153 const MediaFileValidationType validation_type_;
213 154
214 // For callbacks that may run after destruction. 155 // For callbacks that may run after destruction.
215 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; 156 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_;
216 157
217 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); 158 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil);
218 }; 159 };
219 160
220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _ 161 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media_galleries/fileapi/device_media_async_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698