Chromium Code Reviews| Index: chrome/browser/media_gallery/media_file_system_registry.h |
| diff --git a/chrome/browser/media_gallery/media_file_system_registry.h b/chrome/browser/media_gallery/media_file_system_registry.h |
| index f5267976a6efffdc41eb815e7b802a2810c40f78..a0f7abab2507799a56986de0878bfafd363f5d43 100644 |
| --- a/chrome/browser/media_gallery/media_file_system_registry.h |
| +++ b/chrome/browser/media_gallery/media_file_system_registry.h |
| @@ -15,14 +15,15 @@ |
| #include "base/basictypes.h" |
| #include "base/lazy_instance.h" |
| +#include "base/file_path.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/system_monitor/system_monitor.h" |
| -#include "content/public/browser/notification_observer.h" |
| -#include "content/public/browser/notification_registrar.h" |
| class FilePath; |
|
Lei Zhang
2012/09/04 23:38:51
nit: you don't need this since you're adding file_
vandebo (ex-Chrome)
2012/09/05 00:58:12
Done.
|
| +class Profile; |
| namespace content { |
| -class RenderProcessHost; |
| +class RenderViewHost; |
| } |
| namespace extensions { |
| @@ -35,12 +36,13 @@ class IsolatedContext; |
| namespace chrome { |
| +class ExtensionGalleriesHost; |
| + |
| class MediaFileSystemRegistry |
| - : public base::SystemMonitor::DevicesChangedObserver, |
| - public content::NotificationObserver { |
| + : public base::SystemMonitor::DevicesChangedObserver { |
| public: |
| struct MediaFSInfo { |
| - std::string name; |
| + string16 name; |
| std::string fsid; |
| FilePath path; |
| }; |
| @@ -48,57 +50,35 @@ class MediaFileSystemRegistry |
| // The instance is lazily created per browser process. |
| static MediaFileSystemRegistry* GetInstance(); |
| - // Returns the list of media filesystem IDs and paths for a given RPH. |
| + // Returns the list of media filesystem IDs and paths for a given RVH. |
| // Called on the UI thread. |
| std::vector<MediaFSInfo> GetMediaFileSystemsForExtension( |
| - const content::RenderProcessHost* rph, |
| - const extensions::Extension& extension); |
| + const content::RenderViewHost* rvh, |
| + const extensions::Extension* extension); |
| // base::SystemMonitor::DevicesChangedObserver implementation. |
| virtual void OnRemovableStorageDetached(const std::string& id) OVERRIDE; |
| - // content::NotificationObserver implementation. |
| - virtual void Observe(int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) OVERRIDE; |
| - |
| private: |
| friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>; |
| - // Mapping of media directories to filesystem IDs. |
| - typedef std::map<FilePath, std::string> MediaPathToFSIDMap; |
| - |
| - // Mapping of RPH to MediaPathToFSIDMaps. |
| - typedef std::map<const content::RenderProcessHost*, |
| - MediaPathToFSIDMap> ChildIdToMediaFSMap; |
| - |
| - // Mapping of device id to media device info. |
| - typedef std::map<std::string, base::SystemMonitor::RemovableStorageInfo> |
| - DeviceIdToInfoMap; |
| + // Map an extension to the ExtensionGalleriesHost. |
| + typedef std::map<std::string /*extension_id*/, |
| + scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; |
| + // Map a profile and extension to the ExtensionGallerisHost. |
|
Lei Zhang
2012/09/04 23:38:51
nit: typo
vandebo (ex-Chrome)
2012/09/05 00:58:12
Done.
|
| + typedef std::map<Profile*, ExtensionHostMap> |
|
Lei Zhang
2012/09/04 23:38:51
You can probably use const Profile* here and on li
vandebo (ex-Chrome)
2012/09/05 00:58:12
I had that originally, but removed it because Medi
|
| + ExtensionGalleriesHostMap; |
|
Lei Zhang
2012/09/04 23:38:51
nit: fits on previous line.
vandebo (ex-Chrome)
2012/09/05 00:58:12
Done.
|
| // Obtain an instance of this class via GetInstance(). |
| MediaFileSystemRegistry(); |
| virtual ~MediaFileSystemRegistry(); |
| - // Helper functions to register / unregister listening for renderer process |
| - // closed / terminiated notifications. |
| - void RegisterForRPHGoneNotifications(const content::RenderProcessHost* rph); |
| - void UnregisterForRPHGoneNotifications(const content::RenderProcessHost* rph); |
| - |
| - // Registers a path as a media file system and return the filesystem id. |
| - std::string RegisterPathAsFileSystem(const FilePath& path); |
| - |
| - // Revoke a media file system with a given |path|. |
| - void RevokeMediaFileSystem(const FilePath& path); |
| - |
| - // Only accessed on the UI thread. |
| - ChildIdToMediaFSMap media_fs_map_; |
| - |
| - // Only accessed on the UI thread. |
| - DeviceIdToInfoMap device_id_map_; |
| + void OnExtensionGalleriesHostEmpty(Profile* profile, |
| + const std::string& extension_id); |
| - // Is only used on the UI thread. |
| - content::NotificationRegistrar registrar_; |
| + // Only accessed on the UI thread. This map owns all the |
| + // ExtensionGalleriesHost objects created. |
| + ExtensionGalleriesHostMap extension_hosts_map_; |
| DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
| }; |