Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 const ErrorCallback& error_callback) { 335 const ErrorCallback& error_callback) {
336 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 336 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
337 DCHECK(!file_path.empty()); 337 DCHECK(!file_path.empty());
338 338
339 // If a ReadDirectory operation is in progress, the file info may already be 339 // If a ReadDirectory operation is in progress, the file info may already be
340 // cached. 340 // cached.
341 FileInfoCache::const_iterator it = file_info_cache_.find(file_path); 341 FileInfoCache::const_iterator it = file_info_cache_.find(file_path);
342 if (it != file_info_cache_.end()) { 342 if (it != file_info_cache_.end()) {
343 // TODO(thestig): This code is repeated in several places. Combine them. 343 // TODO(thestig): This code is repeated in several places. Combine them.
344 // e.g. c/b/media_galleries/win/mtp_device_operations_util.cc 344 // e.g. c/b/media_galleries/win/mtp_device_operations_util.cc
345 const fileapi::DirectoryEntry& cached_file_entry = it->second; 345 const storage::DirectoryEntry& cached_file_entry = it->second;
346 base::File::Info info; 346 base::File::Info info;
347 info.size = cached_file_entry.size; 347 info.size = cached_file_entry.size;
348 info.is_directory = cached_file_entry.is_directory; 348 info.is_directory = cached_file_entry.is_directory;
349 info.is_symbolic_link = false; 349 info.is_symbolic_link = false;
350 info.last_modified = cached_file_entry.last_modified_time; 350 info.last_modified = cached_file_entry.last_modified_time;
351 info.creation_time = base::Time(); 351 info.creation_time = base::Time();
352 352
353 success_callback.Run(info); 353 success_callback.Run(info);
354 return; 354 return;
355 } 355 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 // Empty snapshot file. 743 // Empty snapshot file.
744 return OnDidWriteDataIntoSnapshotFile( 744 return OnDidWriteDataIntoSnapshotFile(
745 snapshot_file_info, current_snapshot_request_info_->snapshot_file_path); 745 snapshot_file_info, current_snapshot_request_info_->snapshot_file_path);
746 } 746 }
747 WriteDataIntoSnapshotFile(snapshot_file_info); 747 WriteDataIntoSnapshotFile(snapshot_file_info);
748 } 748 }
749 749
750 void MTPDeviceDelegateImplLinux::OnDidReadDirectory( 750 void MTPDeviceDelegateImplLinux::OnDidReadDirectory(
751 uint32 dir_id, 751 uint32 dir_id,
752 const ReadDirectorySuccessCallback& success_callback, 752 const ReadDirectorySuccessCallback& success_callback,
753 const fileapi::AsyncFileUtil::EntryList& file_list, 753 const storage::AsyncFileUtil::EntryList& file_list,
754 bool has_more) { 754 bool has_more) {
755 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 755 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
756 756
757 FileIdToMTPFileNodeMap::iterator it = file_id_to_node_map_.find(dir_id); 757 FileIdToMTPFileNodeMap::iterator it = file_id_to_node_map_.find(dir_id);
758 DCHECK(it != file_id_to_node_map_.end()); 758 DCHECK(it != file_id_to_node_map_.end());
759 MTPFileNode* dir_node = it->second; 759 MTPFileNode* dir_node = it->second;
760 760
761 // Traverse the MTPFileNode tree to reconstuct the full path for |dir_id|. 761 // Traverse the MTPFileNode tree to reconstuct the full path for |dir_id|.
762 std::deque<std::string> dir_path_parts; 762 std::deque<std::string> dir_path_parts;
763 MTPFileNode* parent_node = dir_node; 763 MTPFileNode* parent_node = dir_node;
764 while (parent_node->parent()) { 764 while (parent_node->parent()) {
765 dir_path_parts.push_front(parent_node->file_name()); 765 dir_path_parts.push_front(parent_node->file_name());
766 parent_node = parent_node->parent(); 766 parent_node = parent_node->parent();
767 } 767 }
768 base::FilePath dir_path = device_path_; 768 base::FilePath dir_path = device_path_;
769 for (size_t i = 0; i < dir_path_parts.size(); ++i) 769 for (size_t i = 0; i < dir_path_parts.size(); ++i)
770 dir_path = dir_path.Append(dir_path_parts[i]); 770 dir_path = dir_path.Append(dir_path_parts[i]);
771 771
772 fileapi::AsyncFileUtil::EntryList normalized_file_list; 772 storage::AsyncFileUtil::EntryList normalized_file_list;
773 for (size_t i = 0; i < file_list.size(); ++i) { 773 for (size_t i = 0; i < file_list.size(); ++i) {
774 normalized_file_list.push_back(file_list[i]); 774 normalized_file_list.push_back(file_list[i]);
775 fileapi::DirectoryEntry& entry = normalized_file_list.back(); 775 storage::DirectoryEntry& entry = normalized_file_list.back();
776 776
777 // |entry.name| has the file id encoded in it. Decode here. 777 // |entry.name| has the file id encoded in it. Decode here.
778 size_t separator_idx = entry.name.find_last_of(','); 778 size_t separator_idx = entry.name.find_last_of(',');
779 DCHECK_NE(std::string::npos, separator_idx); 779 DCHECK_NE(std::string::npos, separator_idx);
780 std::string file_id_str = entry.name.substr(separator_idx); 780 std::string file_id_str = entry.name.substr(separator_idx);
781 file_id_str = file_id_str.substr(1); // Get rid of the comma. 781 file_id_str = file_id_str.substr(1); // Get rid of the comma.
782 uint32 file_id = 0; 782 uint32 file_id = 0;
783 bool ret = base::StringToUint(file_id_str, &file_id); 783 bool ret = base::StringToUint(file_id_str, &file_id);
784 DCHECK(ret); 784 DCHECK(ret);
785 entry.name = entry.name.substr(0, separator_idx); 785 entry.name = entry.name.substr(0, separator_idx);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 void MTPDeviceDelegateImplLinux::OnDidReadBytes( 827 void MTPDeviceDelegateImplLinux::OnDidReadBytes(
828 const ReadBytesSuccessCallback& success_callback, 828 const ReadBytesSuccessCallback& success_callback,
829 const base::File::Info& file_info, int bytes_read) { 829 const base::File::Info& file_info, int bytes_read) {
830 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 830 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
831 success_callback.Run(file_info, bytes_read); 831 success_callback.Run(file_info, bytes_read);
832 PendingRequestDone(); 832 PendingRequestDone();
833 } 833 }
834 834
835 void MTPDeviceDelegateImplLinux::OnDidFillFileCache( 835 void MTPDeviceDelegateImplLinux::OnDidFillFileCache(
836 const base::FilePath& path, 836 const base::FilePath& path,
837 const fileapi::AsyncFileUtil::EntryList& /* file_list */, 837 const storage::AsyncFileUtil::EntryList& /* file_list */,
838 bool has_more) { 838 bool has_more) {
839 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 839 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
840 DCHECK(path.IsParent(pending_tasks_.front().path)); 840 DCHECK(path.IsParent(pending_tasks_.front().path));
841 if (has_more) 841 if (has_more)
842 return; // Wait until all entries have been read. 842 return; // Wait until all entries have been read.
843 pending_tasks_.front().cached_path = path; 843 pending_tasks_.front().cached_path = path;
844 } 844 }
845 845
846 void MTPDeviceDelegateImplLinux::OnFillFileCacheFailed( 846 void MTPDeviceDelegateImplLinux::OnFillFileCacheFailed(
847 base::File::Error /* error */) { 847 base::File::Error /* error */) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 *id = current_node->file_id(); 938 *id = current_node->file_id();
939 return true; 939 return true;
940 } 940 }
941 941
942 void CreateMTPDeviceAsyncDelegate( 942 void CreateMTPDeviceAsyncDelegate(
943 const std::string& device_location, 943 const std::string& device_location,
944 const CreateMTPDeviceAsyncDelegateCallback& callback) { 944 const CreateMTPDeviceAsyncDelegateCallback& callback) {
945 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 945 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
946 callback.Run(new MTPDeviceDelegateImplLinux(device_location)); 946 callback.Run(new MTPDeviceDelegateImplLinux(device_location));
947 } 947 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698