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

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

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests 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
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/media_file_system_config.h"
21
22 #if defined(SUPPORT_MEDIA_FILESYSTEM)
23 #include "webkit/fileapi/media/media_device_map_service.h"
kinuko 2012/07/28 02:29:59 nit: maybe you could add the ifdef inside the head
kmadhusu 2012/07/28 23:15:30 As we discussed, this is a temporary code. Therefo
24
25 using fileapi::MediaDeviceMapService;
26 #endif
20 27
21 namespace chrome { 28 namespace chrome {
22 29
23 static base::LazyInstance<MediaFileSystemRegistry>::Leaky 30 static base::LazyInstance<MediaFileSystemRegistry>::Leaky
24 g_media_file_system_registry = LAZY_INSTANCE_INITIALIZER; 31 g_media_file_system_registry = LAZY_INSTANCE_INITIALIZER;
25 32
26 using base::SystemMonitor; 33 using base::SystemMonitor;
27 using content::BrowserThread; 34 using content::BrowserThread;
28 using content::RenderProcessHost; 35 using content::RenderProcessHost;
29 using fileapi::IsolatedContext; 36 using fileapi::IsolatedContext;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 for (MediaPathToFSIDMap::const_iterator it = child_map.begin(); 81 for (MediaPathToFSIDMap::const_iterator it = child_map.begin();
75 it != child_map.end(); 82 it != child_map.end();
76 ++it) { 83 ++it) {
77 const FilePath path = it->first; 84 const FilePath path = it->first;
78 const std::string fsid = it->second; 85 const std::string fsid = it->second;
79 results.push_back(std::make_pair(fsid, path)); 86 results.push_back(std::make_pair(fsid, path));
80 } 87 }
81 return results; 88 return results;
82 } 89 }
83 90
84 void MediaFileSystemRegistry::OnMediaDeviceDetached(const std::string& id) { 91 void MediaFileSystemRegistry::OnMediaDeviceDetached(
92 const std::string& id,
93 const FilePath::StringType& location) {
85 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
86 95
87 DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id); 96 DeviceIdToMediaPathMap::iterator it = device_id_map_.find(id);
88 if (it == device_id_map_.end()) 97 if (it == device_id_map_.end())
89 return; 98 return;
99
100 #if defined(SUPPORT_MEDIA_FILESYSTEM)
101 MediaDeviceMapService::GetInstance()->RemoveMediaDevice(location);
102 #endif
103
90 RevokeMediaFileSystem(it->second); 104 RevokeMediaFileSystem(it->second);
91 device_id_map_.erase(it); 105 device_id_map_.erase(it);
92 } 106 }
93 107
94 void MediaFileSystemRegistry::Observe( 108 void MediaFileSystemRegistry::Observe(
95 int type, 109 int type,
96 const content::NotificationSource& source, 110 const content::NotificationSource& source,
97 const content::NotificationDetails& details) { 111 const content::NotificationDetails& details) {
98 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED || 112 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED ||
99 type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); 113 type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 MediaPathToFSIDMap& child_map = child_it->second; 177 MediaPathToFSIDMap& child_map = child_it->second;
164 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path); 178 MediaPathToFSIDMap::iterator media_path_it = child_map.find(path);
165 if (media_path_it == child_map.end()) 179 if (media_path_it == child_map.end())
166 continue; 180 continue;
167 isolated_context->RevokeFileSystem(media_path_it->second); 181 isolated_context->RevokeFileSystem(media_path_it->second);
168 child_map.erase(media_path_it); 182 child_map.erase(media_path_it);
169 } 183 }
170 } 184 }
171 185
172 } // namespace chrome 186 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698