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_galleries/linux/mtp_device_delegate_impl_linux.h" | 5 #include "chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // Empty snapshot file. | 718 // Empty snapshot file. |
719 return OnDidWriteDataIntoSnapshotFile( | 719 return OnDidWriteDataIntoSnapshotFile( |
720 snapshot_file_info, current_snapshot_request_info_->snapshot_file_path); | 720 snapshot_file_info, current_snapshot_request_info_->snapshot_file_path); |
721 } | 721 } |
722 WriteDataIntoSnapshotFile(snapshot_file_info); | 722 WriteDataIntoSnapshotFile(snapshot_file_info); |
723 } | 723 } |
724 | 724 |
725 void MTPDeviceDelegateImplLinux::OnDidReadDirectory( | 725 void MTPDeviceDelegateImplLinux::OnDidReadDirectory( |
726 uint32 dir_id, | 726 uint32 dir_id, |
727 const ReadDirectorySuccessCallback& success_callback, | 727 const ReadDirectorySuccessCallback& success_callback, |
728 const fileapi::AsyncFileUtil::EntryList& file_list, | 728 const storage::AsyncFileUtil::EntryList& file_list, |
729 bool has_more) { | 729 bool has_more) { |
730 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 730 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
731 | 731 |
732 FileIdToMTPFileNodeMap::iterator it = file_id_to_node_map_.find(dir_id); | 732 FileIdToMTPFileNodeMap::iterator it = file_id_to_node_map_.find(dir_id); |
733 DCHECK(it != file_id_to_node_map_.end()); | 733 DCHECK(it != file_id_to_node_map_.end()); |
734 MTPFileNode* dir_node = it->second; | 734 MTPFileNode* dir_node = it->second; |
735 | 735 |
736 fileapi::AsyncFileUtil::EntryList normalized_file_list; | 736 storage::AsyncFileUtil::EntryList normalized_file_list; |
737 for (size_t i = 0; i < file_list.size(); ++i) { | 737 for (size_t i = 0; i < file_list.size(); ++i) { |
738 normalized_file_list.push_back(file_list[i]); | 738 normalized_file_list.push_back(file_list[i]); |
739 fileapi::DirectoryEntry& entry = normalized_file_list.back(); | 739 storage::DirectoryEntry& entry = normalized_file_list.back(); |
740 | 740 |
741 // |entry.name| has the file id encoded in it. Decode here. | 741 // |entry.name| has the file id encoded in it. Decode here. |
742 size_t separator_idx = entry.name.find_last_of(','); | 742 size_t separator_idx = entry.name.find_last_of(','); |
743 DCHECK_NE(std::string::npos, separator_idx); | 743 DCHECK_NE(std::string::npos, separator_idx); |
744 std::string file_id_str = entry.name.substr(separator_idx); | 744 std::string file_id_str = entry.name.substr(separator_idx); |
745 file_id_str = file_id_str.substr(1); // Get rid of the comma. | 745 file_id_str = file_id_str.substr(1); // Get rid of the comma. |
746 uint32 file_id = 0; | 746 uint32 file_id = 0; |
747 bool ret = base::StringToUint(file_id_str, &file_id); | 747 bool ret = base::StringToUint(file_id_str, &file_id); |
748 DCHECK(ret); | 748 DCHECK(ret); |
749 entry.name = entry.name.substr(0, separator_idx); | 749 entry.name = entry.name.substr(0, separator_idx); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 void MTPDeviceDelegateImplLinux::OnDidReadBytes( | 787 void MTPDeviceDelegateImplLinux::OnDidReadBytes( |
788 const ReadBytesSuccessCallback& success_callback, | 788 const ReadBytesSuccessCallback& success_callback, |
789 const base::File::Info& file_info, int bytes_read) { | 789 const base::File::Info& file_info, int bytes_read) { |
790 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 790 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
791 success_callback.Run(file_info, bytes_read); | 791 success_callback.Run(file_info, bytes_read); |
792 PendingRequestDone(); | 792 PendingRequestDone(); |
793 } | 793 } |
794 | 794 |
795 void MTPDeviceDelegateImplLinux::OnDidFillFileCache( | 795 void MTPDeviceDelegateImplLinux::OnDidFillFileCache( |
796 const base::FilePath& path, | 796 const base::FilePath& path, |
797 const fileapi::AsyncFileUtil::EntryList& /* file_list */, | 797 const storage::AsyncFileUtil::EntryList& /* file_list */, |
798 bool has_more) { | 798 bool has_more) { |
799 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 799 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
800 DCHECK(path.IsParent(pending_tasks_.front().path)); | 800 DCHECK(path.IsParent(pending_tasks_.front().path)); |
801 if (has_more) | 801 if (has_more) |
802 return; // Wait until all entries have been read. | 802 return; // Wait until all entries have been read. |
803 pending_tasks_.front().cached_path = path; | 803 pending_tasks_.front().cached_path = path; |
804 } | 804 } |
805 | 805 |
806 void MTPDeviceDelegateImplLinux::OnFillFileCacheFailed( | 806 void MTPDeviceDelegateImplLinux::OnFillFileCacheFailed( |
807 base::File::Error /* error */) { | 807 base::File::Error /* error */) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 *id = current_node->file_id(); | 898 *id = current_node->file_id(); |
899 return true; | 899 return true; |
900 } | 900 } |
901 | 901 |
902 void CreateMTPDeviceAsyncDelegate( | 902 void CreateMTPDeviceAsyncDelegate( |
903 const std::string& device_location, | 903 const std::string& device_location, |
904 const CreateMTPDeviceAsyncDelegateCallback& callback) { | 904 const CreateMTPDeviceAsyncDelegateCallback& callback) { |
905 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 905 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
906 callback.Run(new MTPDeviceDelegateImplLinux(device_location)); | 906 callback.Run(new MTPDeviceDelegateImplLinux(device_location)); |
907 } | 907 } |
OLD | NEW |