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

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

Issue 18580012: Cleanup: return value and null-callback fixups on AsyncFileUtil interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 7 years, 5 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 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h" 5 #include "chrome/browser/media_galleries/fileapi/device_media_async_file_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 DeviceMediaAsyncFileUtil::~DeviceMediaAsyncFileUtil() { 74 DeviceMediaAsyncFileUtil::~DeviceMediaAsyncFileUtil() {
75 } 75 }
76 76
77 // static 77 // static
78 DeviceMediaAsyncFileUtil* DeviceMediaAsyncFileUtil::Create( 78 DeviceMediaAsyncFileUtil* DeviceMediaAsyncFileUtil::Create(
79 const base::FilePath& profile_path) { 79 const base::FilePath& profile_path) {
80 DCHECK(!profile_path.empty()); 80 DCHECK(!profile_path.empty());
81 return new DeviceMediaAsyncFileUtil(profile_path); 81 return new DeviceMediaAsyncFileUtil(profile_path);
82 } 82 }
83 83
84 bool DeviceMediaAsyncFileUtil::CreateOrOpen( 84 void DeviceMediaAsyncFileUtil::CreateOrOpen(
85 scoped_ptr<FileSystemOperationContext> context, 85 scoped_ptr<FileSystemOperationContext> context,
86 const FileSystemURL& url, 86 const FileSystemURL& url,
87 int file_flags, 87 int file_flags,
88 const CreateOrOpenCallback& callback) { 88 const CreateOrOpenCallback& callback) {
89 DCHECK(IsOnIOThread(context.get())); 89 DCHECK(IsOnIOThread(context.get()));
90 NOTIMPLEMENTED(); 90 NOTIMPLEMENTED();
91 if (!callback.is_null()) { 91 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue;
92 base::PlatformFile invalid_file = base::kInvalidPlatformFileValue; 92 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
93 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, 93 base::PassPlatformFile(&invalid_file));
94 base::PassPlatformFile(&invalid_file));
95 }
96 return true;
97 } 94 }
98 95
99 bool DeviceMediaAsyncFileUtil::EnsureFileExists( 96 void DeviceMediaAsyncFileUtil::EnsureFileExists(
100 scoped_ptr<FileSystemOperationContext> context, 97 scoped_ptr<FileSystemOperationContext> context,
101 const FileSystemURL& url, 98 const FileSystemURL& url,
102 const EnsureFileExistsCallback& callback) { 99 const EnsureFileExistsCallback& callback) {
103 DCHECK(IsOnIOThread(context.get())); 100 DCHECK(IsOnIOThread(context.get()));
104 NOTIMPLEMENTED(); 101 NOTIMPLEMENTED();
105 if (!callback.is_null()) 102 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, false);
106 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, false);
107 return true;
108 } 103 }
109 104
110 bool DeviceMediaAsyncFileUtil::CreateDirectory( 105 void DeviceMediaAsyncFileUtil::CreateDirectory(
111 scoped_ptr<FileSystemOperationContext> context, 106 scoped_ptr<FileSystemOperationContext> context,
112 const FileSystemURL& url, 107 const FileSystemURL& url,
113 bool exclusive, 108 bool exclusive,
114 bool recursive, 109 bool recursive,
115 const StatusCallback& callback) { 110 const StatusCallback& callback) {
116 DCHECK(IsOnIOThread(context.get())); 111 DCHECK(IsOnIOThread(context.get()));
117 NOTIMPLEMENTED(); 112 NOTIMPLEMENTED();
118 if (!callback.is_null()) 113 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
119 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
120 return true;
121 } 114 }
122 115
123 bool DeviceMediaAsyncFileUtil::GetFileInfo( 116 void DeviceMediaAsyncFileUtil::GetFileInfo(
124 scoped_ptr<FileSystemOperationContext> context, 117 scoped_ptr<FileSystemOperationContext> context,
125 const FileSystemURL& url, 118 const FileSystemURL& url,
126 const GetFileInfoCallback& callback) { 119 const GetFileInfoCallback& callback) {
127 DCHECK(IsOnIOThread(context.get())); 120 DCHECK(IsOnIOThread(context.get()));
128 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get()); 121 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get());
129 if (!delegate) { 122 if (!delegate) {
130 OnGetFileInfoError(callback, url.path(), 123 OnGetFileInfoError(callback, url.path(),
131 base::PLATFORM_FILE_ERROR_NOT_FOUND); 124 base::PLATFORM_FILE_ERROR_NOT_FOUND);
132 return true; 125 return;
133 } 126 }
134 delegate->GetFileInfo( 127 delegate->GetFileInfo(
135 url.path(), 128 url.path(),
136 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo, 129 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo,
137 weak_ptr_factory_.GetWeakPtr(), 130 weak_ptr_factory_.GetWeakPtr(),
138 callback, 131 callback,
139 url.path()), 132 url.path()),
140 base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError, 133 base::Bind(&DeviceMediaAsyncFileUtil::OnGetFileInfoError,
141 weak_ptr_factory_.GetWeakPtr(), 134 weak_ptr_factory_.GetWeakPtr(),
142 callback, 135 callback,
143 url.path())); 136 url.path()));
144 return true;
145 } 137 }
146 138
147 bool DeviceMediaAsyncFileUtil::ReadDirectory( 139 void DeviceMediaAsyncFileUtil::ReadDirectory(
148 scoped_ptr<FileSystemOperationContext> context, 140 scoped_ptr<FileSystemOperationContext> context,
149 const FileSystemURL& url, 141 const FileSystemURL& url,
150 const ReadDirectoryCallback& callback) { 142 const ReadDirectoryCallback& callback) {
151 DCHECK(IsOnIOThread(context.get())); 143 DCHECK(IsOnIOThread(context.get()));
152 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get()); 144 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get());
153 if (!delegate) { 145 if (!delegate) {
154 OnReadDirectoryError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 146 OnReadDirectoryError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND);
155 return true; 147 return;
156 } 148 }
157 delegate->ReadDirectory( 149 delegate->ReadDirectory(
158 url.path(), 150 url.path(),
159 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory, 151 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory,
160 weak_ptr_factory_.GetWeakPtr(), 152 weak_ptr_factory_.GetWeakPtr(),
161 callback), 153 callback),
162 base::Bind(&DeviceMediaAsyncFileUtil::OnReadDirectoryError, 154 base::Bind(&DeviceMediaAsyncFileUtil::OnReadDirectoryError,
163 weak_ptr_factory_.GetWeakPtr(), 155 weak_ptr_factory_.GetWeakPtr(),
164 callback)); 156 callback));
165 return true;
166 } 157 }
167 158
168 bool DeviceMediaAsyncFileUtil::Touch( 159 void DeviceMediaAsyncFileUtil::Touch(
169 scoped_ptr<FileSystemOperationContext> context, 160 scoped_ptr<FileSystemOperationContext> context,
170 const FileSystemURL& url, 161 const FileSystemURL& url,
171 const base::Time& last_access_time, 162 const base::Time& last_access_time,
172 const base::Time& last_modified_time, 163 const base::Time& last_modified_time,
173 const StatusCallback& callback) { 164 const StatusCallback& callback) {
174 DCHECK(IsOnIOThread(context.get())); 165 DCHECK(IsOnIOThread(context.get()));
175 NOTIMPLEMENTED(); 166 NOTIMPLEMENTED();
176 if (!callback.is_null()) 167 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
177 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
178 return true;
179 } 168 }
180 169
181 bool DeviceMediaAsyncFileUtil::Truncate( 170 void DeviceMediaAsyncFileUtil::Truncate(
182 scoped_ptr<FileSystemOperationContext> context, 171 scoped_ptr<FileSystemOperationContext> context,
183 const FileSystemURL& url, 172 const FileSystemURL& url,
184 int64 length, 173 int64 length,
185 const StatusCallback& callback) { 174 const StatusCallback& callback) {
186 DCHECK(IsOnIOThread(context.get())); 175 DCHECK(IsOnIOThread(context.get()));
187 NOTIMPLEMENTED(); 176 NOTIMPLEMENTED();
188 if (!callback.is_null()) 177 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
189 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
190 return true;
191 } 178 }
192 179
193 bool DeviceMediaAsyncFileUtil::CopyFileLocal( 180 void DeviceMediaAsyncFileUtil::CopyFileLocal(
194 scoped_ptr<FileSystemOperationContext> context, 181 scoped_ptr<FileSystemOperationContext> context,
195 const FileSystemURL& src_url, 182 const FileSystemURL& src_url,
196 const FileSystemURL& dest_url, 183 const FileSystemURL& dest_url,
197 const StatusCallback& callback) { 184 const StatusCallback& callback) {
198 DCHECK(IsOnIOThread(context.get())); 185 DCHECK(IsOnIOThread(context.get()));
199 NOTIMPLEMENTED(); 186 NOTIMPLEMENTED();
200 if (!callback.is_null()) 187 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
201 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
202 return true;
203 } 188 }
204 189
205 bool DeviceMediaAsyncFileUtil::MoveFileLocal( 190 void DeviceMediaAsyncFileUtil::MoveFileLocal(
206 scoped_ptr<FileSystemOperationContext> context, 191 scoped_ptr<FileSystemOperationContext> context,
207 const FileSystemURL& src_url, 192 const FileSystemURL& src_url,
208 const FileSystemURL& dest_url, 193 const FileSystemURL& dest_url,
209 const StatusCallback& callback) { 194 const StatusCallback& callback) {
210 DCHECK(IsOnIOThread(context.get())); 195 DCHECK(IsOnIOThread(context.get()));
211 NOTIMPLEMENTED(); 196 NOTIMPLEMENTED();
212 if (!callback.is_null()) 197 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
213 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
214 return true;
215 } 198 }
216 199
217 bool DeviceMediaAsyncFileUtil::CopyInForeignFile( 200 void DeviceMediaAsyncFileUtil::CopyInForeignFile(
218 scoped_ptr<FileSystemOperationContext> context, 201 scoped_ptr<FileSystemOperationContext> context,
219 const base::FilePath& src_file_path, 202 const base::FilePath& src_file_path,
220 const FileSystemURL& dest_url, 203 const FileSystemURL& dest_url,
221 const StatusCallback& callback) { 204 const StatusCallback& callback) {
222 DCHECK(IsOnIOThread(context.get())); 205 DCHECK(IsOnIOThread(context.get()));
223 NOTIMPLEMENTED(); 206 NOTIMPLEMENTED();
224 if (!callback.is_null()) 207 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
225 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
226 return true;
227 } 208 }
228 209
229 bool DeviceMediaAsyncFileUtil::DeleteFile( 210 void DeviceMediaAsyncFileUtil::DeleteFile(
230 scoped_ptr<FileSystemOperationContext> context, 211 scoped_ptr<FileSystemOperationContext> context,
231 const FileSystemURL& url, 212 const FileSystemURL& url,
232 const StatusCallback& callback) { 213 const StatusCallback& callback) {
233 DCHECK(IsOnIOThread(context.get())); 214 DCHECK(IsOnIOThread(context.get()));
234 NOTIMPLEMENTED(); 215 NOTIMPLEMENTED();
235 if (!callback.is_null()) 216 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
236 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
237 return true;
238 } 217 }
239 218
240 bool DeviceMediaAsyncFileUtil::DeleteDirectory( 219 void DeviceMediaAsyncFileUtil::DeleteDirectory(
241 scoped_ptr<FileSystemOperationContext> context, 220 scoped_ptr<FileSystemOperationContext> context,
242 const FileSystemURL& url, 221 const FileSystemURL& url,
243 const StatusCallback& callback) { 222 const StatusCallback& callback) {
244 DCHECK(IsOnIOThread(context.get())); 223 DCHECK(IsOnIOThread(context.get()));
245 NOTIMPLEMENTED(); 224 NOTIMPLEMENTED();
246 if (!callback.is_null()) 225 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
247 callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
248 return true;
249 } 226 }
250 227
251 bool DeviceMediaAsyncFileUtil::DeleteRecursively( 228 void DeviceMediaAsyncFileUtil::DeleteRecursively(
252 scoped_ptr<FileSystemOperationContext> context, 229 scoped_ptr<FileSystemOperationContext> context,
253 const FileSystemURL& url, 230 const FileSystemURL& url,
254 const StatusCallback& callback) { 231 const StatusCallback& callback) {
255 DCHECK(IsOnIOThread(context.get())); 232 DCHECK(IsOnIOThread(context.get()));
256 if (!callback.is_null()) 233 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
257 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION);
258 return true;
259 } 234 }
260 235
261 bool DeviceMediaAsyncFileUtil::CreateSnapshotFile( 236 void DeviceMediaAsyncFileUtil::CreateSnapshotFile(
262 scoped_ptr<FileSystemOperationContext> context, 237 scoped_ptr<FileSystemOperationContext> context,
263 const FileSystemURL& url, 238 const FileSystemURL& url,
264 const CreateSnapshotFileCallback& callback) { 239 const CreateSnapshotFileCallback& callback) {
265 DCHECK(IsOnIOThread(context.get())); 240 DCHECK(IsOnIOThread(context.get()));
266 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get()); 241 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(context.get());
267 if (!delegate) { 242 if (!delegate) {
268 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND); 243 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_NOT_FOUND);
269 return true; 244 return;
270 } 245 }
271 base::FilePath* snapshot_file_path = new base::FilePath; 246 base::FilePath* snapshot_file_path = new base::FilePath;
272 base::SequencedTaskRunner* task_runner = context->task_runner(); 247 base::SequencedTaskRunner* task_runner = context->task_runner();
273 return task_runner->PostTaskAndReply( 248 const bool success = task_runner->PostTaskAndReply(
274 FROM_HERE, 249 FROM_HERE,
275 base::Bind(&CreateSnapshotFileOnBlockingPool, 250 base::Bind(&CreateSnapshotFileOnBlockingPool,
276 url.path(), 251 url.path(),
277 profile_path_, 252 profile_path_,
278 base::Unretained(snapshot_file_path)), 253 base::Unretained(snapshot_file_path)),
279 base::Bind(&DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask, 254 base::Bind(&DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask,
280 weak_ptr_factory_.GetWeakPtr(), 255 weak_ptr_factory_.GetWeakPtr(),
281 base::Passed(&context), 256 base::Passed(&context),
282 callback, 257 callback,
283 url.path(), 258 url.path(),
284 base::Owned(snapshot_file_path))); 259 base::Owned(snapshot_file_path)));
260 DCHECK(success);
285 } 261 }
286 262
287 DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil( 263 DeviceMediaAsyncFileUtil::DeviceMediaAsyncFileUtil(
288 const base::FilePath& profile_path) 264 const base::FilePath& profile_path)
289 : profile_path_(profile_path), 265 : profile_path_(profile_path),
290 weak_ptr_factory_(this) { 266 weak_ptr_factory_(this) {
291 } 267 }
292 268
293 void DeviceMediaAsyncFileUtil::OnDidGetFileInfo( 269 void DeviceMediaAsyncFileUtil::OnDidGetFileInfo(
294 const AsyncFileUtil::GetFileInfoCallback& callback, 270 const AsyncFileUtil::GetFileInfoCallback& callback,
295 // TODO(thestig): remove this. 271 // TODO(thestig): remove this.
296 const base::FilePath& platform_path, 272 const base::FilePath& platform_path,
297 const base::PlatformFileInfo& file_info) { 273 const base::PlatformFileInfo& file_info) {
298 if (!callback.is_null()) 274 callback.Run(base::PLATFORM_FILE_OK, file_info);
299 callback.Run(base::PLATFORM_FILE_OK, file_info);
300 } 275 }
301 276
302 void DeviceMediaAsyncFileUtil::OnGetFileInfoError( 277 void DeviceMediaAsyncFileUtil::OnGetFileInfoError(
303 const AsyncFileUtil::GetFileInfoCallback& callback, 278 const AsyncFileUtil::GetFileInfoCallback& callback,
304 // TODO(thestig): remove this. 279 // TODO(thestig): remove this.
305 const base::FilePath& platform_path, 280 const base::FilePath& platform_path,
306 base::PlatformFileError error) { 281 base::PlatformFileError error) {
307 if (!callback.is_null()) 282 callback.Run(error, base::PlatformFileInfo());
308 callback.Run(error, base::PlatformFileInfo());
309 } 283 }
310 284
311 void DeviceMediaAsyncFileUtil::OnDidReadDirectory( 285 void DeviceMediaAsyncFileUtil::OnDidReadDirectory(
312 const AsyncFileUtil::ReadDirectoryCallback& callback, 286 const AsyncFileUtil::ReadDirectoryCallback& callback,
313 const AsyncFileUtil::EntryList& file_list, 287 const AsyncFileUtil::EntryList& file_list,
314 bool has_more) { 288 bool has_more) {
315 if (!callback.is_null()) 289 callback.Run(base::PLATFORM_FILE_OK, file_list, has_more);
316 callback.Run(base::PLATFORM_FILE_OK, file_list, has_more);
317 } 290 }
318 291
319 void DeviceMediaAsyncFileUtil::OnReadDirectoryError( 292 void DeviceMediaAsyncFileUtil::OnReadDirectoryError(
320 const AsyncFileUtil::ReadDirectoryCallback& callback, 293 const AsyncFileUtil::ReadDirectoryCallback& callback,
321 base::PlatformFileError error) { 294 base::PlatformFileError error) {
322 if (!callback.is_null()) 295 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/);
323 callback.Run(error, AsyncFileUtil::EntryList(), false /*no more*/);
324 } 296 }
325 297
326 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile( 298 void DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile(
327 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 299 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
328 base::SequencedTaskRunner* media_task_runner, 300 base::SequencedTaskRunner* media_task_runner,
329 const base::PlatformFileInfo& file_info, 301 const base::PlatformFileInfo& file_info,
330 const base::FilePath& platform_path) { 302 const base::FilePath& platform_path) {
331 if (callback.is_null())
332 return;
333 base::PostTaskAndReplyWithResult( 303 base::PostTaskAndReplyWithResult(
334 media_task_runner, 304 media_task_runner,
335 FROM_HERE, 305 FROM_HERE,
336 base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path), 306 base::Bind(&NativeMediaFileUtil::IsMediaFile, platform_path),
337 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia, 307 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCheckMedia,
338 weak_ptr_factory_.GetWeakPtr(), 308 weak_ptr_factory_.GetWeakPtr(),
339 callback, 309 callback,
340 file_info, 310 file_info,
341 ShareableFileReference::GetOrCreate( 311 ShareableFileReference::GetOrCreate(
342 platform_path, 312 platform_path,
343 ShareableFileReference::DELETE_ON_FINAL_RELEASE, 313 ShareableFileReference::DELETE_ON_FINAL_RELEASE,
344 media_task_runner))); 314 media_task_runner)));
345 } 315 }
346 316
347 void DeviceMediaAsyncFileUtil::OnDidCheckMedia( 317 void DeviceMediaAsyncFileUtil::OnDidCheckMedia(
348 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 318 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
349 const base::PlatformFileInfo& file_info, 319 const base::PlatformFileInfo& file_info,
350 scoped_refptr<webkit_blob::ShareableFileReference> platform_file, 320 scoped_refptr<webkit_blob::ShareableFileReference> platform_file,
351 base::PlatformFileError error) { 321 base::PlatformFileError error) {
352 if (callback.is_null())
353 return;
354 base::FilePath platform_path(platform_file.get()->path()); 322 base::FilePath platform_path(platform_file.get()->path());
355 if (error != base::PLATFORM_FILE_OK) 323 if (error != base::PLATFORM_FILE_OK)
356 platform_file = NULL; 324 platform_file = NULL;
357 callback.Run(error, file_info, platform_path, platform_file); 325 callback.Run(error, file_info, platform_path, platform_file);
358 } 326 }
359 327
360 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError( 328 void DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError(
361 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 329 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
362 base::PlatformFileError error) { 330 base::PlatformFileError error) {
363 if (!callback.is_null()) 331 callback.Run(error, base::PlatformFileInfo(), base::FilePath(),
364 callback.Run(error, base::PlatformFileInfo(), base::FilePath(), 332 scoped_refptr<ShareableFileReference>());
365 scoped_refptr<ShareableFileReference>());
366 } 333 }
367 334
368 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask( 335 void DeviceMediaAsyncFileUtil::OnSnapshotFileCreatedRunTask(
369 scoped_ptr<FileSystemOperationContext> context, 336 scoped_ptr<FileSystemOperationContext> context,
370 const AsyncFileUtil::CreateSnapshotFileCallback& callback, 337 const AsyncFileUtil::CreateSnapshotFileCallback& callback,
371 const base::FilePath& device_file_path, 338 const base::FilePath& device_file_path,
372 base::FilePath* snapshot_file_path) { 339 base::FilePath* snapshot_file_path) {
373 DCHECK(IsOnIOThread(context.get())); 340 DCHECK(IsOnIOThread(context.get()));
374 if (!snapshot_file_path || snapshot_file_path->empty()) { 341 if (!snapshot_file_path || snapshot_file_path->empty()) {
375 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED); 342 OnCreateSnapshotFileError(callback, base::PLATFORM_FILE_ERROR_FAILED);
(...skipping 10 matching lines...) Expand all
386 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, 353 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile,
387 weak_ptr_factory_.GetWeakPtr(), 354 weak_ptr_factory_.GetWeakPtr(),
388 callback, 355 callback,
389 make_scoped_refptr(context->task_runner())), 356 make_scoped_refptr(context->task_runner())),
390 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, 357 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError,
391 weak_ptr_factory_.GetWeakPtr(), 358 weak_ptr_factory_.GetWeakPtr(),
392 callback)); 359 callback));
393 } 360 }
394 361
395 } // namespace chrome 362 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698