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

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

Issue 1815363002: Add RetainedRef uses where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 #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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_FAILED); 216 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_FAILED);
217 return; 217 return;
218 } 218 }
219 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 219 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
220 if (!delegate) { 220 if (!delegate) {
221 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND); 221 OnCreateSnapshotFileError(callback, base::File::FILE_ERROR_NOT_FOUND);
222 return; 222 return;
223 } 223 }
224 delegate->CreateSnapshotFile( 224 delegate->CreateSnapshotFile(
225 url.path(), // device file path 225 url.path(), // device file path
226 snapshot_file_path, 226 snapshot_file_path, base::Bind(&OnDidCreateSnapshotFile, callback,
227 base::Bind(&OnDidCreateSnapshotFile, 227 base::RetainedRef(context->task_runner()),
228 callback, 228 validate_media_files),
229 make_scoped_refptr(context->task_runner()),
230 validate_media_files),
231 base::Bind(&OnCreateSnapshotFileError, callback)); 229 base::Bind(&OnCreateSnapshotFileError, callback));
232 } 230 }
233 231
234 } // namespace 232 } // namespace
235 233
236 class DeviceMediaAsyncFileUtil::MediaPathFilterWrapper 234 class DeviceMediaAsyncFileUtil::MediaPathFilterWrapper
237 : public base::RefCountedThreadSafe<MediaPathFilterWrapper> { 235 : public base::RefCountedThreadSafe<MediaPathFilterWrapper> {
238 public: 236 public:
239 MediaPathFilterWrapper(); 237 MediaPathFilterWrapper();
240 238
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Returns an error if any unsupported flag is found. 310 // Returns an error if any unsupported flag is found.
313 if (file_flags & ~(base::File::FLAG_OPEN | 311 if (file_flags & ~(base::File::FLAG_OPEN |
314 base::File::FLAG_READ | 312 base::File::FLAG_READ |
315 base::File::FLAG_WRITE_ATTRIBUTES)) { 313 base::File::FLAG_WRITE_ATTRIBUTES)) {
316 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure()); 314 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure());
317 return; 315 return;
318 } 316 }
319 CreateSnapshotFile( 317 CreateSnapshotFile(
320 std::move(context), url, 318 std::move(context), url,
321 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, 319 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen,
322 make_scoped_refptr(context->task_runner()), file_flags, 320 base::RetainedRef(context->task_runner()), file_flags,
323 callback)); 321 callback));
324 } 322 }
325 323
326 void DeviceMediaAsyncFileUtil::EnsureFileExists( 324 void DeviceMediaAsyncFileUtil::EnsureFileExists(
327 scoped_ptr<FileSystemOperationContext> context, 325 scoped_ptr<FileSystemOperationContext> context,
328 const FileSystemURL& url, 326 const FileSystemURL& url,
329 const EnsureFileExistsCallback& callback) { 327 const EnsureFileExistsCallback& callback) {
330 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 328 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
331 NOTIMPLEMENTED(); 329 NOTIMPLEMENTED();
332 callback.Run(base::File::FILE_ERROR_SECURITY, false); 330 callback.Run(base::File::FILE_ERROR_SECURITY, false);
(...skipping 26 matching lines...) Expand all
359 scoped_ptr<FileSystemOperationContext> context, 357 scoped_ptr<FileSystemOperationContext> context,
360 const FileSystemURL& url, 358 const FileSystemURL& url,
361 int /* flags */, 359 int /* flags */,
362 const GetFileInfoCallback& callback) { 360 const GetFileInfoCallback& callback) {
363 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 361 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
364 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 362 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
365 if (!delegate) { 363 if (!delegate) {
366 OnGetFileInfoError(callback, base::File::FILE_ERROR_NOT_FOUND); 364 OnGetFileInfoError(callback, base::File::FILE_ERROR_NOT_FOUND);
367 return; 365 return;
368 } 366 }
369 delegate->GetFileInfo( 367 delegate->GetFileInfo(url.path(),
370 url.path(), 368 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo,
371 base::Bind(&DeviceMediaAsyncFileUtil::OnDidGetFileInfo, 369 weak_ptr_factory_.GetWeakPtr(),
372 weak_ptr_factory_.GetWeakPtr(), 370 base::RetainedRef(context->task_runner()),
373 make_scoped_refptr(context->task_runner()), 371 url.path(), callback),
374 url.path(), 372 base::Bind(&OnGetFileInfoError, callback));
375 callback),
376 base::Bind(&OnGetFileInfoError, callback));
377 } 373 }
378 374
379 void DeviceMediaAsyncFileUtil::ReadDirectory( 375 void DeviceMediaAsyncFileUtil::ReadDirectory(
380 scoped_ptr<FileSystemOperationContext> context, 376 scoped_ptr<FileSystemOperationContext> context,
381 const FileSystemURL& url, 377 const FileSystemURL& url,
382 const ReadDirectoryCallback& callback) { 378 const ReadDirectoryCallback& callback) {
383 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 379 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
384 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url); 380 MTPDeviceAsyncDelegate* delegate = GetMTPDeviceDelegate(url);
385 if (!delegate) { 381 if (!delegate) {
386 OnReadDirectoryError(callback, base::File::FILE_ERROR_NOT_FOUND); 382 OnReadDirectoryError(callback, base::File::FILE_ERROR_NOT_FOUND);
387 return; 383 return;
388 } 384 }
389 385
390 delegate->ReadDirectory( 386 delegate->ReadDirectory(
391 url.path(), 387 url.path(),
392 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory, 388 base::Bind(&DeviceMediaAsyncFileUtil::OnDidReadDirectory,
393 weak_ptr_factory_.GetWeakPtr(), 389 weak_ptr_factory_.GetWeakPtr(),
394 make_scoped_refptr(context->task_runner()), 390 base::RetainedRef(context->task_runner()), callback),
395 callback),
396 base::Bind(&OnReadDirectoryError, callback)); 391 base::Bind(&OnReadDirectoryError, callback));
397 } 392 }
398 393
399 void DeviceMediaAsyncFileUtil::Touch( 394 void DeviceMediaAsyncFileUtil::Touch(
400 scoped_ptr<FileSystemOperationContext> context, 395 scoped_ptr<FileSystemOperationContext> context,
401 const FileSystemURL& url, 396 const FileSystemURL& url,
402 const base::Time& last_access_time, 397 const base::Time& last_access_time,
403 const base::Time& last_modified_time, 398 const base::Time& last_modified_time,
404 const StatusCallback& callback) { 399 const StatusCallback& callback) {
405 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 400 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void DeviceMediaAsyncFileUtil::OnDidDeleteDirectory( 696 void DeviceMediaAsyncFileUtil::OnDidDeleteDirectory(
702 const StatusCallback& callback) { 697 const StatusCallback& callback) {
703 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 698 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
704 699
705 callback.Run(base::File::FILE_OK); 700 callback.Run(base::File::FILE_OK);
706 } 701 }
707 702
708 bool DeviceMediaAsyncFileUtil::validate_media_files() const { 703 bool DeviceMediaAsyncFileUtil::validate_media_files() const {
709 return media_path_filter_wrapper_.get() != NULL; 704 return media_path_filter_wrapper_.get() != NULL;
710 } 705 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_system_impl.cc ('k') | chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698