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

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

Issue 14556015: [Media Galleries] Lazily initialize the storage monitor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase on prefs Created 7 years, 7 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
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 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_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ 8 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_
9 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ 9 #define CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h"
19 #include "base/prefs/pref_change_registrar.h" 20 #include "base/prefs/pref_change_registrar.h"
20 #include "chrome/browser/media_galleries/media_galleries_preferences.h" 21 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
21 #include "chrome/browser/media_galleries/mtp_device_delegate_impl.h" 22 #include "chrome/browser/media_galleries/mtp_device_delegate_impl.h"
22 #include "chrome/browser/storage_monitor/removable_storage_observer.h" 23 #include "chrome/browser/storage_monitor/removable_storage_observer.h"
23 24
24 class Profile; 25 class Profile;
25 26
26 namespace content { 27 namespace content {
27 class RenderViewHost; 28 class RenderViewHost;
28 } 29 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 MediaFileSystemsCallback; 67 MediaFileSystemsCallback;
67 68
68 class MediaFileSystemRegistry : public RemovableStorageObserver { 69 class MediaFileSystemRegistry : public RemovableStorageObserver {
69 public: 70 public:
70 MediaFileSystemRegistry(); 71 MediaFileSystemRegistry();
71 virtual ~MediaFileSystemRegistry(); 72 virtual ~MediaFileSystemRegistry();
72 73
73 // Passes to |callback| the list of media filesystem IDs and paths for a 74 // Passes to |callback| the list of media filesystem IDs and paths for a
74 // given RVH. Called on the UI thread. 75 // given RVH. Called on the UI thread.
75 void GetMediaFileSystemsForExtension( 76 void GetMediaFileSystemsForExtension(
76 const content::RenderViewHost* rvh, 77 content::RenderViewHost* rvh,
77 const extensions::Extension* extension, 78 const extensions::Extension* extension,
78 const MediaFileSystemsCallback& callback); 79 const MediaFileSystemsCallback& callback);
79 80
80 // Returns the initialized media galleries preferences for the specified 81 // This method should be used instead of calling MediaGalleriesPreferences
81 // |profile|. This method should be used instead of calling 82 // directly because this method also ensures that currently attached
82 // MediaGalleriesPreferences directly because this method also ensures that 83 // removable devices are added to the preferences.
83 // currently attached removable devices are added to the preferences.
84 // Called on the UI thread. 84 // Called on the UI thread.
85 MediaGalleriesPreferences* GetPreferences(Profile* profile); 85 // Note: Caller must ensure that the storage monitor is initialized before
86 // calling this method.
87 virtual MediaGalleriesPreferences* GetPreferences(Profile* profile) OVERRIDE;
vandebo (ex-Chrome) 2013/05/23 15:04:17 Not an override. Does it need to be virtual?
Greg Billock 2013/05/30 22:17:47 Reverted this. (Was from the ::Vendor class I had
86 88
87 // RemovableStorageObserver implementation. 89 // RemovableStorageObserver implementation.
88 virtual void OnRemovableStorageDetached(const StorageInfo& info) OVERRIDE; 90 virtual void OnRemovableStorageDetached(const StorageInfo& info) OVERRIDE;
89 91
90 size_t GetExtensionGalleriesHostCountForTests() const; 92 size_t GetExtensionGalleriesHostCountForTests() const;
91 93
92 // See TransientDeviceIds::GetTransientIdForDeviceId(). 94 // See TransientDeviceIds::GetTransientIdForDeviceId().
93 uint64 GetTransientIdForDeviceId(const std::string& device_id); 95 uint64 GetTransientIdForDeviceId(const std::string& device_id);
94 96
95 private: 97 private:
96 friend class TestMediaFileSystemContext; 98 friend class TestMediaFileSystemContext;
97 class MediaFileSystemContextImpl; 99 class MediaFileSystemContextImpl;
98 100
101 // Bottom half of |GetMediaFileSystemsForExtension|. Called when the
102 // storage monitor is fully initialized.
103 void GetMediaFileSystemsPostInit(const content::RenderViewHost* rvh,
104 const extensions::Extension* extension,
105 const MediaFileSystemsCallback& callback);
106
99 // Map an extension to the ExtensionGalleriesHost. 107 // Map an extension to the ExtensionGalleriesHost.
100 typedef std::map<std::string /*extension_id*/, 108 typedef std::map<std::string /*extension_id*/,
101 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap; 109 scoped_refptr<ExtensionGalleriesHost> > ExtensionHostMap;
102 // Map a profile and extension to the ExtensionGalleriesHost. 110 // Map a profile and extension to the ExtensionGalleriesHost.
103 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap; 111 typedef std::map<Profile*, ExtensionHostMap> ExtensionGalleriesHostMap;
104 // Map a profile to a PrefChangeRegistrar. 112 // Map a profile to a PrefChangeRegistrar.
105 typedef std::map<Profile*, PrefChangeRegistrar*> PrefChangeRegistrarMap; 113 typedef std::map<Profile*, PrefChangeRegistrar*> PrefChangeRegistrarMap;
106 114
107 // Map a MTP or PTP device location to the raw pointer of 115 // Map a MTP or PTP device location to the raw pointer of
108 // ScopedMTPDeviceMapEntry. It is safe to store a raw pointer in this 116 // ScopedMTPDeviceMapEntry. It is safe to store a raw pointer in this
(...skipping 19 matching lines...) Expand all
128 // ExtensionGalleriesHost objects created. 136 // ExtensionGalleriesHost objects created.
129 ExtensionGalleriesHostMap extension_hosts_map_; 137 ExtensionGalleriesHostMap extension_hosts_map_;
130 138
131 PrefChangeRegistrarMap pref_change_registrar_map_; 139 PrefChangeRegistrarMap pref_change_registrar_map_;
132 140
133 // Only accessed on the UI thread. 141 // Only accessed on the UI thread.
134 MTPDeviceDelegateMap mtp_device_delegate_map_; 142 MTPDeviceDelegateMap mtp_device_delegate_map_;
135 143
136 scoped_ptr<MediaFileSystemContext> file_system_context_; 144 scoped_ptr<MediaFileSystemContext> file_system_context_;
137 145
146 base::WeakPtrFactory<MediaFileSystemRegistry> weak_ptr_factory_;
147
138 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry); 148 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistry);
139 }; 149 };
140 150
141 } // namespace chrome 151 } // namespace chrome
142 152
143 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_ 153 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MEDIA_FILE_SYSTEM_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698