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

Side by Side Diff: chrome/browser/media_gallery/media_file_system_registry.cc

Issue 10873072: Rename SystemMonitor's MediaDevice calls to RemovableStorage. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 // MediaFileSystemRegistry implementation. 5 // MediaFileSystemRegistry implementation.
6 6
7 #include "chrome/browser/media_gallery/media_file_system_registry.h" 7 #include "chrome/browser/media_gallery/media_file_system_registry.h"
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // TODO(vandebo) file system galleries need a unique id as well. 82 // TODO(vandebo) file system galleries need a unique id as well.
83 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path) && 83 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path) &&
84 IsGalleryPermittedForExtension(extension, pictures_path.value())) { 84 IsGalleryPermittedForExtension(extension, pictures_path.value())) {
85 std::string fsid = RegisterPathAsFileSystem(pictures_path); 85 std::string fsid = RegisterPathAsFileSystem(pictures_path);
86 child_it->second.insert(std::make_pair(pictures_path, fsid)); 86 child_it->second.insert(std::make_pair(pictures_path, fsid));
87 } 87 }
88 } 88 }
89 89
90 // TODO(thestig) Handle overlap between devices and media directories. 90 // TODO(thestig) Handle overlap between devices and media directories.
91 SystemMonitor* monitor = SystemMonitor::Get(); 91 SystemMonitor* monitor = SystemMonitor::Get();
92 const std::vector<SystemMonitor::MediaDeviceInfo> media_devices = 92 const std::vector<SystemMonitor::RemovableStorageInfo> media_devices =
93 monitor->GetAttachedMediaDevices(); 93 monitor->GetAttachedRemovableStorage();
94 for (size_t i = 0; i < media_devices.size(); ++i) { 94 for (size_t i = 0; i < media_devices.size(); ++i) {
95 MediaStorageUtil::Type type; 95 MediaStorageUtil::Type type;
96 MediaStorageUtil::CrackDeviceId(media_devices[i].unique_id, &type, NULL); 96 MediaStorageUtil::CrackDeviceId(media_devices[i].device_id, &type, NULL);
97 // TODO(vandebo) Handle MTP devices. 97 // TODO(vandebo) Handle MTP devices.
98 if (type != MediaStorageUtil::USB_MTP && 98 if (type != MediaStorageUtil::USB_MTP &&
99 IsGalleryPermittedForExtension(extension, media_devices[i].location)) { 99 IsGalleryPermittedForExtension(extension, media_devices[i].location)) {
100 device_id_map_.insert(std::make_pair(media_devices[i].unique_id, 100 device_id_map_.insert(std::make_pair(media_devices[i].device_id,
101 media_devices[i])); 101 media_devices[i]));
102 FilePath path(media_devices[i].location); 102 FilePath path(media_devices[i].location);
103 const std::string fsid = RegisterPathAsFileSystem(path); 103 const std::string fsid = RegisterPathAsFileSystem(path);
104 child_it->second.insert(std::make_pair(path, fsid)); 104 child_it->second.insert(std::make_pair(path, fsid));
105 } 105 }
106 } 106 }
107 107
108 MediaPathToFSIDMap& child_map = child_it->second; 108 MediaPathToFSIDMap& child_map = child_it->second;
109 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); 109 for (MediaPathToFSIDMap::const_iterator it = child_map.begin();
110 it != child_map.end(); 110 it != child_map.end();
111 ++it) { 111 ++it) {
112 MediaFSInfo entry; 112 MediaFSInfo entry;
113 // TODO(vandebo) use a better name, fsid for now. 113 // TODO(vandebo) use a better name, fsid for now.
114 entry.name = it->second; 114 entry.name = it->second;
115 entry.fsid = it->second; 115 entry.fsid = it->second;
116 entry.path = it->first; 116 entry.path = it->first;
117 results.push_back(entry); 117 results.push_back(entry);
118 } 118 }
119 return results; 119 return results;
120 } 120 }
121 121
122 void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) { 122 void MediaFileSystemRegistry::OnRemovableStorageDetached(
123 const std::string& id) {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 124 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
124 125
125 DeviceIdToInfoMap::iterator it = device_id_map_.find(id); 126 DeviceIdToInfoMap::iterator it = device_id_map_.find(id);
126 if (it == device_id_map_.end()) 127 if (it == device_id_map_.end())
127 return; 128 return;
128 129
129 FilePath path(it->second.location); 130 FilePath path(it->second.location);
130 RevokeMediaFileSystem(path); 131 RevokeMediaFileSystem(path);
131 device_id_map_.erase(it); 132 device_id_map_.erase(it);
132 } 133 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 MediaPathToFSIDMap& child_map = child_it->second; 219 MediaPathToFSIDMap& child_map = child_it->second;
219 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); 220 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path);
220 if (media_path_it == child_map.end()) 221 if (media_path_it == child_map.end())
221 continue; 222 continue;
222 223
223 child_map.erase(media_path_it); 224 child_map.erase(media_path_it);
224 } 225 }
225 } 226 }
226 227
227 } // namespace chrome 228 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_file_system_registry.h ('k') | chrome/browser/media_gallery/media_storage_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698