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 registers pictures directories and media devices as | 5 // MediaFileSystemRegistry registers pictures directories and media devices as |
6 // File API filesystems and keeps track of the path to filesystem ID mappings. | 6 // File API filesystems and keeps track of the path to filesystem ID mappings. |
7 | 7 |
8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 8 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 9 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // The instance is lazily created per browser process. | 45 // The instance is lazily created per browser process. |
46 static MediaFileSystemRegistry* GetInstance(); | 46 static MediaFileSystemRegistry* GetInstance(); |
47 | 47 |
48 // Returns the list of media filesystem IDs and paths for a given RPH. | 48 // Returns the list of media filesystem IDs and paths for a given RPH. |
49 // Called on the UI thread. | 49 // Called on the UI thread. |
50 std::vector<MediaFSIDAndPath> GetMediaFileSystems( | 50 std::vector<MediaFSIDAndPath> GetMediaFileSystems( |
51 const content::RenderProcessHost* rph, | 51 const content::RenderProcessHost* rph, |
52 const extensions::Extension& extension); | 52 const extensions::Extension& extension); |
53 | 53 |
54 // base::SystemMonitor::DevicesChangedObserver implementation. | 54 // base::SystemMonitor::DevicesChangedObserver implementation. |
55 virtual void OnMediaDeviceDetached(const std::string& id) OVERRIDE; | 55 virtual void OnMediaDeviceDetached( |
| 56 const std::string& id, |
| 57 const FilePath::StringType& location) OVERRIDE; |
56 | 58 |
57 // content::NotificationObserver implementation. | 59 // content::NotificationObserver implementation. |
58 virtual void Observe(int type, | 60 virtual void Observe(int type, |
59 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
60 const content::NotificationDetails& details) OVERRIDE; | 62 const content::NotificationDetails& details) OVERRIDE; |
61 | 63 |
62 private: | 64 private: |
63 friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>; | 65 friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>; |
64 | 66 |
65 // Mapping of media directories to filesystem IDs. | 67 // Mapping of media directories to filesystem IDs. |
66 typedef std::map<FilePath, std::string> MediaPathToFSIDMap; | 68 typedef std::map<FilePath, std::string> MediaPathToFSIDMap; |
67 | 69 |
68 // Mapping of RPH to MediaPathToFSIDMaps. | 70 // Mapping of RPH to MediaPathToFSIDMaps. |
69 typedef std::map<const content::RenderProcessHost*, | 71 typedef std::map<const content::RenderProcessHost*, |
70 MediaPathToFSIDMap> ChildIdToMediaFSMap; | 72 MediaPathToFSIDMap> ChildIdToMediaFSMap; |
71 | 73 |
72 // Mapping of device id to mount path. | 74 // Mapping of device id to mount path. |
73 typedef std::map<std::string, FilePath> DeviceIdToMediaPathMap; | 75 typedef std::map<std::string, FilePath> DeviceIdToMediaPathMap; |
74 | 76 |
75 // Obtain an instance of this class via GetInstance(). | 77 // Obtain an instance of this class via GetInstance(). |
76 MediaFileSystemRegistry(); | 78 MediaFileSystemRegistry(); |
77 virtual ~MediaFileSystemRegistry(); | 79 virtual ~MediaFileSystemRegistry(); |
78 | 80 |
79 // Helper functions to register / unregister listening for renderer process | 81 // Helper functions to register / unregister listening for renderer process |
80 // closed / terminiated notifications. | 82 // closed / terminiated notifications. |
81 void RegisterForRPHGoneNotifications(const content::RenderProcessHost* rph); | 83 void RegisterForRPHGoneNotifications(const content::RenderProcessHost* rph); |
82 void UnregisterForRPHGoneNotifications(const content::RenderProcessHost* rph); | 84 void UnregisterForRPHGoneNotifications(const content::RenderProcessHost* rph); |
83 | 85 |
84 // Registers a path as a media file system and return the filesystem id. | 86 // Registers a path as a media file system and return the filesystem id. |
85 std::string RegisterPathAsFileSystem(const FilePath& path); | 87 std::string RegisterPathAsFileSystem( |
| 88 const FilePath& path, |
| 89 const base::SystemMonitor::MediaDeviceType& type); |
86 | 90 |
87 // Revoke a media file system with a given |path|. | 91 // Revoke a media file system with a given |path|. |
88 void RevokeMediaFileSystem(const FilePath& path); | 92 void RevokeMediaFileSystem(const FilePath& path); |
89 | 93 |
90 // Only accessed on the UI thread. | 94 // Only accessed on the UI thread. |
91 ChildIdToMediaFSMap media_fs_map_; | 95 ChildIdToMediaFSMap media_fs_map_; |
92 | 96 |
93 // Only accessed on the UI thread. | 97 // Only accessed on the UI thread. |
94 DeviceIdToMediaPathMap device_id_map_; | 98 DeviceIdToMediaPathMap device_id_map_; |
95 | 99 |
96 // Is only used on the UI thread. | 100 // Is only used on the UI thread. |
97 content::NotificationRegistrar registrar_; | 101 content::NotificationRegistrar registrar_; |
98 | 102 |
99 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); | 103 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); |
100 }; | 104 }; |
101 | 105 |
102 } // namespace chrome | 106 } // namespace chrome |
103 | 107 |
104 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ | 108 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ |
OLD | NEW |