| OLD | NEW |
| 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 | 9 |
| 9 #include "base/callback.h" | 10 #include "base/callback.h" |
| 10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 14 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" | 15 #include "chrome/browser/media_galleries/fileapi/media_path_filter.h" |
| 15 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" | 16 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" | 17 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" |
| 17 #include "chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.h" | 18 #include "chrome/browser/media_galleries/fileapi/mtp_file_stream_reader.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 const CreateOrOpenCallback& callback) { | 310 const CreateOrOpenCallback& callback) { |
| 310 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 311 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 311 // Returns an error if any unsupported flag is found. | 312 // Returns an error if any unsupported flag is found. |
| 312 if (file_flags & ~(base::File::FLAG_OPEN | | 313 if (file_flags & ~(base::File::FLAG_OPEN | |
| 313 base::File::FLAG_READ | | 314 base::File::FLAG_READ | |
| 314 base::File::FLAG_WRITE_ATTRIBUTES)) { | 315 base::File::FLAG_WRITE_ATTRIBUTES)) { |
| 315 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure()); | 316 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure()); |
| 316 return; | 317 return; |
| 317 } | 318 } |
| 318 CreateSnapshotFile( | 319 CreateSnapshotFile( |
| 319 context.Pass(), | 320 std::move(context), url, |
| 320 url, | |
| 321 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, | 321 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, |
| 322 make_scoped_refptr(context->task_runner()), | 322 make_scoped_refptr(context->task_runner()), file_flags, |
| 323 file_flags, | |
| 324 callback)); | 323 callback)); |
| 325 } | 324 } |
| 326 | 325 |
| 327 void DeviceMediaAsyncFileUtil::EnsureFileExists( | 326 void DeviceMediaAsyncFileUtil::EnsureFileExists( |
| 328 scoped_ptr<FileSystemOperationContext> context, | 327 scoped_ptr<FileSystemOperationContext> context, |
| 329 const FileSystemURL& url, | 328 const FileSystemURL& url, |
| 330 const EnsureFileExistsCallback& callback) { | 329 const EnsureFileExistsCallback& callback) { |
| 331 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 330 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 332 NOTIMPLEMENTED(); | 331 NOTIMPLEMENTED(); |
| 333 callback.Run(base::File::FILE_ERROR_SECURITY, false); | 332 callback.Run(base::File::FILE_ERROR_SECURITY, false); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 void DeviceMediaAsyncFileUtil::OnDidDeleteDirectory( | 701 void DeviceMediaAsyncFileUtil::OnDidDeleteDirectory( |
| 703 const StatusCallback& callback) { | 702 const StatusCallback& callback) { |
| 704 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 703 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 705 | 704 |
| 706 callback.Run(base::File::FILE_OK); | 705 callback.Run(base::File::FILE_OK); |
| 707 } | 706 } |
| 708 | 707 |
| 709 bool DeviceMediaAsyncFileUtil::validate_media_files() const { | 708 bool DeviceMediaAsyncFileUtil::validate_media_files() const { |
| 710 return media_path_filter_wrapper_.get() != NULL; | 709 return media_path_filter_wrapper_.get() != NULL; |
| 711 } | 710 } |
| OLD | NEW |