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 |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
16 #include "content/public/browser/notification_types.h" | 16 #include "content/public/browser/notification_types.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "webkit/fileapi/isolated_context.h" | 18 #include "webkit/fileapi/isolated_context.h" |
| 19 #include "webkit/fileapi/media_device_map_service.h" |
| 20 |
| 21 using fileapi::MediaDeviceMapService; |
19 | 22 |
20 namespace chrome { | 23 namespace chrome { |
21 | 24 |
22 static base::LazyInstance<MediaFileSystemRegistry>::Leaky | 25 static base::LazyInstance<MediaFileSystemRegistry>::Leaky |
23 g_media_file_system_registry = LAZY_INSTANCE_INITIALIZER; | 26 g_media_file_system_registry = LAZY_INSTANCE_INITIALIZER; |
24 | 27 |
25 using base::SystemMonitor; | 28 using base::SystemMonitor; |
26 using content::BrowserThread; | 29 using content::BrowserThread; |
27 using content::RenderProcessHost; | 30 using content::RenderProcessHost; |
28 using fileapi::IsolatedContext; | 31 using fileapi::IsolatedContext; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); | 76 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); |
74 it != child_map.end(); | 77 it != child_map.end(); |
75 ++it) { | 78 ++it) { |
76 const FilePath path = it->first; | 79 const FilePath path = it->first; |
77 const std::string fsid = it->second; | 80 const std::string fsid = it->second; |
78 results.push_back(std::make_pair(fsid, path)); | 81 results.push_back(std::make_pair(fsid, path)); |
79 } | 82 } |
80 return results; | 83 return results; |
81 } | 84 } |
82 | 85 |
83 void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) { | 86 void MediaFileSystemRegistry::OnMediaDeviceDetached( |
| 87 const std::string& id, |
| 88 const FilePath::StringType& location) { |
84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
85 | 90 |
86 DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id); | 91 DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id); |
87 if (it == device_id_map_.end()) | 92 if (it == device_id_map_.end()) |
88 return; | 93 return; |
| 94 MediaDeviceMapService::GetInstance()->RemoveMediaDevice(location); |
89 RevokeMediaFileSystem(it->second); | 95 RevokeMediaFileSystem(it->second); |
90 device_id_map_.erase(it); | 96 device_id_map_.erase(it); |
91 } | 97 } |
92 | 98 |
93 void MediaFileSystemRegistry::Observe( | 99 void MediaFileSystemRegistry::Observe( |
94 int type, | 100 int type, |
95 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
96 const content::NotificationDetails& details) { | 102 const content::NotificationDetails& details) { |
97 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED || | 103 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED || |
98 type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); | 104 type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 MediaPathToFSIDMap& child_map = child_it->second; | 168 MediaPathToFSIDMap& child_map = child_it->second; |
163 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); | 169 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); |
164 if (media_path_it == child_map.end()) | 170 if (media_path_it == child_map.end()) |
165 continue; | 171 continue; |
166 isolated_context->RevokeFileSystem(media_path_it->second); | 172 isolated_context->RevokeFileSystem(media_path_it->second); |
167 child_map.erase(media_path_it); | 173 child_map.erase(media_path_it); |
168 } | 174 } |
169 } | 175 } |
170 | 176 |
171 } // namespace chrome | 177 } // namespace chrome |
OLD | NEW |