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 // 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 | 48 |
49 /****************** | 49 /****************** |
50 * Public methods | 50 * Public methods |
51 ******************/ | 51 ******************/ |
52 | 52 |
53 // static | 53 // static |
54 MediaFileSystemRegistry* MediaFileSystemRegistry::GetInstance() { | 54 MediaFileSystemRegistry* MediaFileSystemRegistry::GetInstance() { |
55 return g_media_file_system_registry.Pointer(); | 55 return g_media_file_system_registry.Pointer(); |
56 } | 56 } |
57 | 57 |
58 std::vector<MediaFileSystemRegistry::MediaFSIDAndPath> | 58 std::vector<MediaFileSystemRegistry::MediaFSInfo> |
59 MediaFileSystemRegistry::GetMediaFileSystems( | 59 MediaFileSystemRegistry::GetMediaFileSystemsForExtension( |
60 const content::RenderProcessHost* rph, | 60 const content::RenderProcessHost* rph, |
61 const extensions::Extension& extension) { | 61 const extensions::Extension& extension) { |
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
63 | 63 |
64 std::vector<MediaFSIDAndPath> results; | 64 std::vector<MediaFSInfo> results; |
65 std::pair<ChildIdToMediaFSMap::iterator, bool> ret = | 65 std::pair<ChildIdToMediaFSMap::iterator, bool> ret = |
66 media_fs_map_.insert(std::make_pair(rph, MediaPathToFSIDMap())); | 66 media_fs_map_.insert(std::make_pair(rph, MediaPathToFSIDMap())); |
67 ChildIdToMediaFSMap::iterator& child_it = ret.first; | 67 ChildIdToMediaFSMap::iterator& child_it = ret.first; |
68 if (ret.second) { | 68 if (ret.second) { |
69 // Never seen a GetMediaFileSystems call from this RPH. Initialize its | 69 // Never seen a GetMediaFileSystems call from this RPH. Initialize its |
70 // file system mappings. | 70 // file system mappings. |
71 RegisterForRPHGoneNotifications(rph); | 71 RegisterForRPHGoneNotifications(rph); |
72 FilePath pictures_path; | 72 FilePath pictures_path; |
73 // TODO(vandebo) file system galleries need a unique id as well. | 73 // TODO(vandebo) file system galleries need a unique id as well. |
74 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path) && | 74 if (PathService::Get(chrome::DIR_USER_PICTURES, &pictures_path) && |
(...skipping 16 matching lines...) Expand all Loading... | |
91 device_id_map_.insert(std::make_pair(media_devices[i].unique_id, path)); | 91 device_id_map_.insert(std::make_pair(media_devices[i].unique_id, path)); |
92 const std::string fsid = RegisterPathAsFileSystem(path); | 92 const std::string fsid = RegisterPathAsFileSystem(path); |
93 child_it->second.insert(std::make_pair(path, fsid)); | 93 child_it->second.insert(std::make_pair(path, fsid)); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 MediaPathToFSIDMap& child_map = child_it->second; | 97 MediaPathToFSIDMap& child_map = child_it->second; |
98 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); | 98 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); |
99 it != child_map.end(); | 99 it != child_map.end(); |
100 ++it) { | 100 ++it) { |
101 const FilePath path = it->first; | 101 MediaFSInfo entry; |
102 const std::string fsid = it->second; | 102 entry.name = it->first.value(); |
Lei Zhang
2012/07/30 20:56:32
FilePath.value() is a wstring on Windows.
vandebo (ex-Chrome)
2012/07/31 18:27:17
Right. Changed to fsid for now.
| |
103 results.push_back(std::make_pair(fsid, path)); | 103 entry.fsid = it->second; |
104 entry.path = it->first; | |
105 results.push_back(entry); | |
104 } | 106 } |
105 return results; | 107 return results; |
106 } | 108 } |
107 | 109 |
108 void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) { | 110 void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) { |
109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
110 | 112 |
111 DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id); | 113 DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id); |
112 if (it == device_id_map_.end()) | 114 if (it == device_id_map_.end()) |
113 return; | 115 return; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
187 MediaPathToFSIDMap& child_map = child_it->second; | 189 MediaPathToFSIDMap& child_map = child_it->second; |
188 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); | 190 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); |
189 if (media_path_it == child_map.end()) | 191 if (media_path_it == child_map.end()) |
190 continue; | 192 continue; |
191 isolated_context->RevokeFileSystem(media_path_it->second); | 193 isolated_context->RevokeFileSystem(media_path_it->second); |
192 child_map.erase(media_path_it); | 194 child_map.erase(media_path_it); |
193 } | 195 } |
194 } | 196 } |
195 | 197 |
196 } // namespace chrome | 198 } // namespace chrome |
OLD | NEW |