| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_gallery/linux/mtp_device_delegate_impl_linux.h" | 5 #include "chrome/browser/media_gallery/linux/mtp_device_delegate_impl_linux.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 PlatformFileError MTPDeviceDelegateImplLinux::CreateSnapshotFile( | 126 PlatformFileError MTPDeviceDelegateImplLinux::CreateSnapshotFile( |
| 127 const FilePath& device_file_path, | 127 const FilePath& device_file_path, |
| 128 const FilePath& local_path, | 128 const FilePath& local_path, |
| 129 PlatformFileInfo* file_info) { | 129 PlatformFileInfo* file_info) { |
| 130 if (!LazyInit()) | 130 if (!LazyInit()) |
| 131 return base::PLATFORM_FILE_ERROR_FAILED; | 131 return base::PLATFORM_FILE_ERROR_FAILED; |
| 132 | 132 |
| 133 PlatformFileError error = GetFileInfo(device_file_path, file_info); | 133 PlatformFileError error = GetFileInfo(device_file_path, file_info); |
| 134 if (error != base::PLATFORM_FILE_OK) | 134 if (error != base::PLATFORM_FILE_OK) |
| 135 return error; | 135 return error; |
| 136 if (file_info->is_directory) |
| 137 return base::PLATFORM_FILE_ERROR_NOT_A_FILE; |
| 136 | 138 |
| 137 if (file_info->size <= 0 || file_info->size > kuint32max) | 139 if (file_info->size <= 0 || file_info->size > kuint32max) |
| 138 return base::PLATFORM_FILE_ERROR_FAILED; | 140 return base::PLATFORM_FILE_ERROR_FAILED; |
| 139 | 141 |
| 140 scoped_refptr<MTPReadFileWorker> worker(new MTPReadFileWorker( | 142 scoped_refptr<MTPReadFileWorker> worker(new MTPReadFileWorker( |
| 141 device_handle_, | 143 device_handle_, |
| 142 GetDeviceRelativePath(device_path_, device_file_path.value()), | 144 GetDeviceRelativePath(device_path_, device_file_path.value()), |
| 143 file_info->size, local_path, media_task_runner_, | 145 file_info->size, local_path, media_task_runner_, |
| 144 &on_task_completed_event_, &on_shutdown_event_)); | 146 &on_task_completed_event_, &on_shutdown_event_)); |
| 145 worker->Run(); | 147 worker->Run(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return !device_handle_.empty(); | 189 return !device_handle_.empty(); |
| 188 } | 190 } |
| 189 | 191 |
| 190 void CreateMTPDeviceDelegate(const std::string& device_location, | 192 void CreateMTPDeviceDelegate(const std::string& device_location, |
| 191 base::SequencedTaskRunner* media_task_runner, | 193 base::SequencedTaskRunner* media_task_runner, |
| 192 const CreateMTPDeviceDelegateCallback& cb) { | 194 const CreateMTPDeviceDelegateCallback& cb) { |
| 193 cb.Run(new MTPDeviceDelegateImplLinux(device_location, media_task_runner)); | 195 cb.Run(new MTPDeviceDelegateImplLinux(device_location, media_task_runner)); |
| 194 } | 196 } |
| 195 | 197 |
| 196 } // namespace chrome | 198 } // namespace chrome |
| OLD | NEW |