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