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

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

Issue 10537092: Media Gallery: Register isolated file systems on a per RenderProcessHost basis. Otherwise when one… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 registers pictures directories as File API 5 // MediaFileSystemRegistry registers pictures directories as File API
6 // filesystems and keeps track of the path to filesystem ID mappings. 6 // filesystems and keeps track of the path to filesystem ID mappings.
7 // In the near future, MediaFileSystemRegistry will also support media devices. 7 // In the near future, MediaFileSystemRegistry will also support media devices.
8 8
9 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ 9 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_
10 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ 10 #define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_
11 #pragma once 11 #pragma once
12 12
13 #include <map> 13 #include <map>
14 #include <string> 14 #include <string>
15 #include <utility> 15 #include <utility>
16 #include <vector> 16 #include <vector>
17 17
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "base/lazy_instance.h" 19 #include "base/lazy_instance.h"
20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h"
20 22
21 class FilePath; 23 class FilePath;
22 24
25 namespace content {
26 class RenderProcessHost;
27 }
28
23 namespace fileapi { 29 namespace fileapi {
24 class IsolatedContext; 30 class IsolatedContext;
25 } 31 }
26 32
27 namespace chrome { 33 namespace chrome {
28 34
29 class MediaFileSystemRegistry { 35 class MediaFileSystemRegistry : public content::NotificationObserver {
30 public: 36 public:
31 // (Filesystem ID, path) 37 // (Filesystem ID, path)
32 typedef std::pair<std::string, FilePath> MediaFSIDAndPath; 38 typedef std::pair<std::string, FilePath> MediaFSIDAndPath;
33 39
34 // The instance is lazily created per browser process. 40 // The instance is lazily created per browser process.
35 static MediaFileSystemRegistry* GetInstance(); 41 static MediaFileSystemRegistry* GetInstance();
36 42
37 // Returns the list of media filesystem IDs and paths. 43 // Returns the list of media filesystem IDs and paths for a given RPH.
38 // Called on the UI thread. 44 // Called on the UI thread.
39 std::vector<MediaFSIDAndPath> GetMediaFileSystems() const; 45 std::vector<MediaFSIDAndPath> GetMediaFileSystems(
46 const content::RenderProcessHost* rph);
47
48 // content::NotificationObserver implementation.
49 virtual void Observe(int type,
50 const content::NotificationSource& source,
51 const content::NotificationDetails& details) OVERRIDE;
40 52
41 private: 53 private:
42 friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>; 54 friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>;
43 55
44 // Mapping of media directories to filesystem IDs. 56 // Mapping of media directories to filesystem IDs.
45 typedef std::map<FilePath, std::string> MediaPathToFSIDMap; 57 typedef std::map<FilePath, std::string> MediaPathToFSIDMap;
46 58
59 // Mapping of RPH to MediaPathToFSIDMaps.
60 typedef std::map<const content::RenderProcessHost*,
61 MediaPathToFSIDMap> ChildIdToMediaFSMap;
62
47 // Obtain an instance of this class via GetInstance(). 63 // Obtain an instance of this class via GetInstance().
48 MediaFileSystemRegistry(); 64 MediaFileSystemRegistry();
49 virtual ~MediaFileSystemRegistry(); 65 virtual ~MediaFileSystemRegistry();
50 66
51 // Registers a path as a media file system. 67 // Helper functions to register / unregister listening for renderer process
52 void RegisterPathAsFileSystem(const FilePath& path); 68 // closed / terminiated notifications.
69 void RegisterForRPHGoneNotifications(const content::RenderProcessHost* rph);
70 void UnregisterForRPHGoneNotifications(const content::RenderProcessHost* rph);
71
72 // Registers a path as a media file system and return the filesystem id.
73 std::string RegisterPathAsFileSystem(const FilePath& path);
53 74
54 // Only accessed on the UI thread. 75 // Only accessed on the UI thread.
55 MediaPathToFSIDMap media_fs_map_; 76 ChildIdToMediaFSMap media_fs_map_;
77
78 // Is only used on the UI Thread.
79 content::NotificationRegistrar registrar_;
56 80
57 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); 81 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry);
58 }; 82 };
59 83
60 } // namespace chrome 84 } // namespace chrome
61 85
62 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_ 86 #endif // CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698