| 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 "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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void DeviceMediaAsyncFileUtil::CreateOrOpen( | 82 void DeviceMediaAsyncFileUtil::CreateOrOpen( |
| 83 scoped_ptr<FileSystemOperationContext> context, | 83 scoped_ptr<FileSystemOperationContext> context, |
| 84 const FileSystemURL& url, | 84 const FileSystemURL& url, |
| 85 int file_flags, | 85 int file_flags, |
| 86 const CreateOrOpenCallback& callback) { | 86 const CreateOrOpenCallback& callback) { |
| 87 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 87 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 88 // Returns an error if any unsupported flag is found. | 88 // Returns an error if any unsupported flag is found. |
| 89 if (file_flags & ~(base::File::FLAG_OPEN | | 89 if (file_flags & ~(base::File::FLAG_OPEN | |
| 90 base::File::FLAG_READ | | 90 base::File::FLAG_READ | |
| 91 base::File::FLAG_WRITE_ATTRIBUTES)) { | 91 base::File::FLAG_WRITE_ATTRIBUTES)) { |
| 92 base::PlatformFile invalid_file(base::kInvalidPlatformFileValue); | 92 callback.Run(base::File(base::File::FILE_ERROR_SECURITY), base::Closure()); |
| 93 callback.Run(base::File::FILE_ERROR_SECURITY, | |
| 94 base::PassPlatformFile(&invalid_file), | |
| 95 base::Closure()); | |
| 96 return; | 93 return; |
| 97 } | 94 } |
| 98 CreateSnapshotFile( | 95 CreateSnapshotFile( |
| 99 context.Pass(), | 96 context.Pass(), |
| 100 url, | 97 url, |
| 101 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, | 98 base::Bind(&NativeMediaFileUtil::CreatedSnapshotFileForCreateOrOpen, |
| 102 make_scoped_refptr(context->task_runner()), | 99 make_scoped_refptr(context->task_runner()), |
| 103 file_flags, | 100 file_flags, |
| 104 callback)); | 101 callback)); |
| 105 } | 102 } |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 url.path(), // device file path | 381 url.path(), // device file path |
| 385 snapshot_file_path, | 382 snapshot_file_path, |
| 386 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, | 383 base::Bind(&DeviceMediaAsyncFileUtil::OnDidCreateSnapshotFile, |
| 387 weak_ptr_factory_.GetWeakPtr(), | 384 weak_ptr_factory_.GetWeakPtr(), |
| 388 callback, | 385 callback, |
| 389 make_scoped_refptr(context->task_runner())), | 386 make_scoped_refptr(context->task_runner())), |
| 390 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, | 387 base::Bind(&DeviceMediaAsyncFileUtil::OnCreateSnapshotFileError, |
| 391 weak_ptr_factory_.GetWeakPtr(), | 388 weak_ptr_factory_.GetWeakPtr(), |
| 392 callback)); | 389 callback)); |
| 393 } | 390 } |
| OLD | NEW |