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

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

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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
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_path.h" 9 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "base/platform_file.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 { 15 namespace base {
16 class SequencedTaskRunner; 16 class SequencedTaskRunner;
17 class Time; 17 class Time;
18 } 18 }
19 19
20 namespace fileapi { 20 namespace fileapi {
21 class FileSystemOperationContext; 21 class FileSystemOperationContext;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 private: 123 private:
124 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. 124 // Use Create() to get an instance of DeviceMediaAsyncFileUtil.
125 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path); 125 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path);
126 126
127 // Called when GetFileInfo method call succeeds. |file_info| contains the 127 // Called when GetFileInfo method call succeeds. |file_info| contains the
128 // file details of the requested url. |callback| is invoked to complete the 128 // file details of the requested url. |callback| is invoked to complete the
129 // GetFileInfo request. 129 // GetFileInfo request.
130 void OnDidGetFileInfo( 130 void OnDidGetFileInfo(
131 const AsyncFileUtil::GetFileInfoCallback& callback, 131 const AsyncFileUtil::GetFileInfoCallback& callback,
132 const base::PlatformFileInfo& file_info); 132 const base::File::Info& file_info);
133 133
134 // Called when GetFileInfo method call failed to get the details of file 134 // Called when GetFileInfo method call failed to get the details of file
135 // specified by the requested url. |callback| is invoked to notify the 135 // specified by the requested url. |callback| is invoked to notify the
136 // caller about the platform file |error|. 136 // caller about the platform file |error|.
137 void OnGetFileInfoError( 137 void OnGetFileInfoError(
138 const AsyncFileUtil::GetFileInfoCallback& callback, 138 const AsyncFileUtil::GetFileInfoCallback& callback,
139 base::PlatformFileError error); 139 base::File::Error error);
140 140
141 // Called when ReadDirectory method call succeeds. |callback| is invoked to 141 // Called when ReadDirectory method call succeeds. |callback| is invoked to
142 // complete the ReadDirectory request. 142 // complete the ReadDirectory request.
143 // 143 //
144 // If the contents of the given directory are reported in one batch, then 144 // If the contents of the given directory are reported in one batch, then
145 // |file_list| will have the list of all files/directories in the given 145 // |file_list| will have the list of all files/directories in the given
146 // directory and |has_more| will be false. 146 // directory and |has_more| will be false.
147 // 147 //
148 // If the contents of the given directory are reported in multiple chunks, 148 // If the contents of the given directory are reported in multiple chunks,
149 // |file_list| will have only a subset of all contents (the subsets reported 149 // |file_list| will have only a subset of all contents (the subsets reported
150 // in any two calls are disjoint), and |has_more| will be true, except for 150 // in any two calls are disjoint), and |has_more| will be true, except for
151 // the last chunk. 151 // the last chunk.
152 void OnDidReadDirectory( 152 void OnDidReadDirectory(
153 const AsyncFileUtil::ReadDirectoryCallback& callback, 153 const AsyncFileUtil::ReadDirectoryCallback& callback,
154 const AsyncFileUtil::EntryList& file_list, 154 const AsyncFileUtil::EntryList& file_list,
155 bool has_more); 155 bool has_more);
156 156
157 // Called when ReadDirectory method call failed to enumerate the directory 157 // Called when ReadDirectory method call failed to enumerate the directory
158 // objects. |callback| is invoked to notify the caller about the |error| 158 // objects. |callback| is invoked to notify the caller about the |error|
159 // that occured while reading the directory objects. 159 // that occured while reading the directory objects.
160 void OnReadDirectoryError( 160 void OnReadDirectoryError(
161 const AsyncFileUtil::ReadDirectoryCallback& callback, 161 const AsyncFileUtil::ReadDirectoryCallback& callback,
162 base::PlatformFileError error); 162 base::File::Error error);
163 163
164 // Called when the snapshot file specified by the |platform_path| is 164 // Called when the snapshot file specified by the |platform_path| is
165 // successfully created. |file_info| contains the device media file details 165 // successfully created. |file_info| contains the device media file details
166 // for which the snapshot file is created. 166 // for which the snapshot file is created.
167 void OnDidCreateSnapshotFile( 167 void OnDidCreateSnapshotFile(
168 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 168 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
169 base::SequencedTaskRunner* media_task_runner, 169 base::SequencedTaskRunner* media_task_runner,
170 const base::PlatformFileInfo& file_info, 170 const base::File::Info& file_info,
171 const base::FilePath& platform_path); 171 const base::FilePath& platform_path);
172 172
173 // Called after OnDidCreateSnapshotFile finishes media check. 173 // Called after OnDidCreateSnapshotFile finishes media check.
174 // |callback| is invoked to complete the CreateSnapshotFile request. 174 // |callback| is invoked to complete the CreateSnapshotFile request.
175 void OnDidCheckMedia( 175 void OnDidCheckMedia(
176 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 176 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
177 const base::PlatformFileInfo& file_info, 177 const base::File::Info& file_info,
178 scoped_refptr<webkit_blob::ShareableFileReference> platform_file, 178 scoped_refptr<webkit_blob::ShareableFileReference> platform_file,
179 base::PlatformFileError error); 179 base::File::Error error);
180 180
181 // The following three functions are called in sequence when we have a 181 // The following three functions are called in sequence when we have a
182 // streaming MTP implementation and don't need a local snapshot file to be 182 // streaming MTP implementation and don't need a local snapshot file to be
183 // created. 183 // created.
184 void GetHeaderBytesForMIMESniffing( 184 void GetHeaderBytesForMIMESniffing(
185 const fileapi::FileSystemURL& url, 185 const fileapi::FileSystemURL& url,
186 base::SequencedTaskRunner* media_task_runner, 186 base::SequencedTaskRunner* media_task_runner,
187 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 187 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
188 base::PlatformFileError error, 188 base::File::Error error,
189 const base::PlatformFileInfo& file_info); 189 const base::File::Info& file_info);
190 void FinishStreamingSnapshotFile( 190 void FinishStreamingSnapshotFile(
191 const fileapi::FileSystemURL& url, 191 const fileapi::FileSystemURL& url,
192 base::SequencedTaskRunner* media_task_runner, 192 base::SequencedTaskRunner* media_task_runner,
193 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 193 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
194 const base::PlatformFileInfo& file_info, 194 const base::File::Info& file_info,
195 net::IOBuffer* buffer, 195 net::IOBuffer* buffer,
196 int buffer_size); 196 int buffer_size);
197 197
198 // Called when CreateSnapshotFile method call fails. |callback| is invoked to 198 // Called when CreateSnapshotFile method call fails. |callback| is invoked to
199 // notify the caller about the |error|. 199 // notify the caller about the |error|.
200 void OnCreateSnapshotFileError( 200 void OnCreateSnapshotFileError(
201 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 201 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
202 base::PlatformFileError error); 202 base::File::Error error);
203 203
204 // Called when the snapshot file specified by the |snapshot_file_path| is 204 // Called when the snapshot file specified by the |snapshot_file_path| is
205 // created to hold the contents of the url.path(). If the snapshot 205 // created to hold the contents of the url.path(). If the snapshot
206 // file is successfully created, |snapshot_file_path| will be an non-empty 206 // file is successfully created, |snapshot_file_path| will be an non-empty
207 // file path. In case of failure, |snapshot_file_path| will be an empty file 207 // file path. In case of failure, |snapshot_file_path| will be an empty file
208 // path. Forwards the CreateSnapshot request to the delegate to copy the 208 // path. Forwards the CreateSnapshot request to the delegate to copy the
209 // contents of url.path() to |snapshot_file_path|. 209 // contents of url.path() to |snapshot_file_path|.
210 void OnSnapshotFileCreatedRunTask( 210 void OnSnapshotFileCreatedRunTask(
211 scoped_ptr<fileapi::FileSystemOperationContext> context, 211 scoped_ptr<fileapi::FileSystemOperationContext> context,
212 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 212 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
213 const fileapi::FileSystemURL& url, 213 const fileapi::FileSystemURL& url,
214 base::FilePath* snapshot_file_path); 214 base::FilePath* snapshot_file_path);
215 215
216 // Profile path. 216 // Profile path.
217 const base::FilePath profile_path_; 217 const base::FilePath profile_path_;
218 218
219 // For callbacks that may run after destruction. 219 // For callbacks that may run after destruction.
220 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; 220 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_;
221 221
222 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); 222 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil);
223 }; 223 };
224 224
225 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _ 225 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698