| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/media_galleries/linux/mtp_device_object_enumerator.h" | 8 #include "chrome/browser/media_galleries/linux/mtp_device_object_enumerator.h" |
| 9 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" | 9 #include "chrome/browser/media_galleries/linux/mtp_read_file_worker.h" |
| 10 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" | 10 #include "chrome/browser/media_galleries/linux/snapshot_file_details.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 const std::vector<MtpFileEntry>& file_entries, | 155 const std::vector<MtpFileEntry>& file_entries, |
| 156 bool error) const { | 156 bool error) const { |
| 157 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 157 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 158 if (error) | 158 if (error) |
| 159 return HandleDeviceError(error_callback, base::PLATFORM_FILE_ERROR_FAILED); | 159 return HandleDeviceError(error_callback, base::PLATFORM_FILE_ERROR_FAILED); |
| 160 | 160 |
| 161 fileapi::AsyncFileUtil::EntryList entries; | 161 fileapi::AsyncFileUtil::EntryList entries; |
| 162 base::FilePath current; | 162 base::FilePath current; |
| 163 MTPDeviceObjectEnumerator file_enum(file_entries); | 163 MTPDeviceObjectEnumerator file_enum(file_entries); |
| 164 while (!(current = file_enum.Next()).empty()) { | 164 while (!(current = file_enum.Next()).empty()) { |
| 165 fileapi::AsyncFileUtil::Entry entry; | 165 fileapi::DirectoryEntry entry; |
| 166 entry.name = fileapi::VirtualPath::BaseName(current).value(); | 166 entry.name = fileapi::VirtualPath::BaseName(current).value(); |
| 167 entry.is_directory = file_enum.IsDirectory(); | 167 entry.is_directory = file_enum.IsDirectory(); |
| 168 entry.size = file_enum.Size(); | 168 entry.size = file_enum.Size(); |
| 169 entry.last_modified_time = file_enum.LastModifiedTime(); | 169 entry.last_modified_time = file_enum.LastModifiedTime(); |
| 170 entries.push_back(entry); | 170 entries.push_back(entry); |
| 171 } | 171 } |
| 172 content::BrowserThread::PostTask(content::BrowserThread::IO, | 172 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 173 FROM_HERE, | 173 FROM_HERE, |
| 174 base::Bind(success_callback, entries)); | 174 base::Bind(success_callback, entries)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void MTPDeviceTaskHelper::HandleDeviceError( | 177 void MTPDeviceTaskHelper::HandleDeviceError( |
| 178 const ErrorCallback& error_callback, | 178 const ErrorCallback& error_callback, |
| 179 base::PlatformFileError error) const { | 179 base::PlatformFileError error) const { |
| 180 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 180 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 181 content::BrowserThread::PostTask(content::BrowserThread::IO, | 181 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 182 FROM_HERE, | 182 FROM_HERE, |
| 183 base::Bind(error_callback, error)); | 183 base::Bind(error_callback, error)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace chrome | 186 } // namespace chrome |
| OLD | NEW |