| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/linux/mtp_device_task_helper.h" | 5 #include "chrome/browser/media_galleries/linux/mtp_device_task_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "chrome/browser/media_galleries/linux/mtp_device_object_enumerator.h" | 12 #include "chrome/browser/media_galleries/linux/mtp_device_object_enumerator.h" |
| 13 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" | 13 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" |
| 14 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" | 14 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" |
| 15 #include "components/storage_monitor/storage_monitor.h" | 15 #include "components/storage_monitor/storage_monitor.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | 17 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" |
| 18 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 #include "webkit/browser/fileapi/async_file_util.h" | 20 #include "storage/browser/fileapi/async_file_util.h" |
| 21 #include "webkit/common/fileapi/file_system_util.h" | 21 #include "storage/common/fileapi/file_system_util.h" |
| 22 | 22 |
| 23 using storage_monitor::StorageMonitor; | 23 using storage_monitor::StorageMonitor; |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Does nothing. | 27 // Does nothing. |
| 28 // This method is used to handle the results of | 28 // This method is used to handle the results of |
| 29 // MediaTransferProtocolManager::CloseStorage method call. | 29 // MediaTransferProtocolManager::CloseStorage method call. |
| 30 void DoNothing(bool error) { | 30 void DoNothing(bool error) { |
| 31 } | 31 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 void MTPDeviceTaskHelper::OnDidReadDirectory( | 175 void MTPDeviceTaskHelper::OnDidReadDirectory( |
| 176 const ReadDirectorySuccessCallback& success_callback, | 176 const ReadDirectorySuccessCallback& success_callback, |
| 177 const ErrorCallback& error_callback, | 177 const ErrorCallback& error_callback, |
| 178 const std::vector<MtpFileEntry>& file_entries, | 178 const std::vector<MtpFileEntry>& file_entries, |
| 179 bool has_more, | 179 bool has_more, |
| 180 bool error) const { | 180 bool error) const { |
| 181 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 181 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 182 if (error) | 182 if (error) |
| 183 return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED); | 183 return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED); |
| 184 | 184 |
| 185 fileapi::AsyncFileUtil::EntryList entries; | 185 storage::AsyncFileUtil::EntryList entries; |
| 186 base::FilePath current; | 186 base::FilePath current; |
| 187 MTPDeviceObjectEnumerator file_enum(file_entries); | 187 MTPDeviceObjectEnumerator file_enum(file_entries); |
| 188 while (!(current = file_enum.Next()).empty()) { | 188 while (!(current = file_enum.Next()).empty()) { |
| 189 fileapi::DirectoryEntry entry; | 189 storage::DirectoryEntry entry; |
| 190 entry.name = fileapi::VirtualPath::BaseName(current).value(); | 190 entry.name = storage::VirtualPath::BaseName(current).value(); |
| 191 uint32 file_id = 0; | 191 uint32 file_id = 0; |
| 192 bool ret = file_enum.GetEntryId(&file_id); | 192 bool ret = file_enum.GetEntryId(&file_id); |
| 193 DCHECK(ret); | 193 DCHECK(ret); |
| 194 entry.name.push_back(','); | 194 entry.name.push_back(','); |
| 195 entry.name += base::UintToString(file_id); | 195 entry.name += base::UintToString(file_id); |
| 196 entry.is_directory = file_enum.IsDirectory(); | 196 entry.is_directory = file_enum.IsDirectory(); |
| 197 entry.size = file_enum.Size(); | 197 entry.size = file_enum.Size(); |
| 198 entry.last_modified_time = file_enum.LastModifiedTime(); | 198 entry.last_modified_time = file_enum.LastModifiedTime(); |
| 199 entries.push_back(entry); | 199 entries.push_back(entry); |
| 200 } | 200 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 | 268 |
| 269 void MTPDeviceTaskHelper::HandleDeviceError( | 269 void MTPDeviceTaskHelper::HandleDeviceError( |
| 270 const ErrorCallback& error_callback, | 270 const ErrorCallback& error_callback, |
| 271 base::File::Error error) const { | 271 base::File::Error error) const { |
| 272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 272 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 273 content::BrowserThread::PostTask(content::BrowserThread::IO, | 273 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 274 FROM_HERE, | 274 FROM_HERE, |
| 275 base::Bind(error_callback, error)); | 275 base::Bind(error_callback, error)); |
| 276 } | 276 } |
| OLD | NEW |