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 1fc2ac1c5b285ec1aa3dbfb2bb19411bf4809836..be34cccb58a9ff03400d09a0e5fa0f5b8dd6db6b 100644 |
| --- a/chrome/browser/media_gallery/media_file_system_registry.h |
| +++ b/chrome/browser/media_gallery/media_file_system_registry.h |
| @@ -21,6 +21,7 @@ |
| #include "base/prefs/public/pref_change_registrar.h" |
| #include "base/prefs/public/pref_observer.h" |
| #include "base/system_monitor/system_monitor.h" |
| +#include "chrome/browser/media_gallery/mtp_device_delegate_impl.h" |
| #include "webkit/fileapi/media/mtp_device_file_system_config.h" |
| class Profile; |
| @@ -41,7 +42,6 @@ namespace chrome { |
| class ExtensionGalleriesHost; |
| class MediaGalleriesPreferences; |
| -class ScopedMTPDeviceMapEntry; |
| struct MediaFileSystemInfo { |
| MediaFileSystemInfo(const std::string& fs_name, |
| @@ -54,6 +54,43 @@ struct MediaFileSystemInfo { |
| std::string fsid; |
| }; |
| +#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) |
| +// Class to manage MTPDeviceDelegateImpl object for the attached MTP device. |
| +// Refcounted to reuse the same MTP device delegate entry across extensions. |
| +// This class supports WeakPtr (extends SupportsWeakPtr) to expose itself as |
| +// a weak pointer to MediaFileSystemRegistry. |
| +class ScopedMTPDeviceMapEntry |
| + : public base::RefCounted<ScopedMTPDeviceMapEntry>, |
| + public base::SupportsWeakPtr<ScopedMTPDeviceMapEntry> { |
| + public: |
| + // |no_references_callback| is called when the last ScopedMTPDeviceMapEntry |
| + // reference goes away. |
| + ScopedMTPDeviceMapEntry(const FilePath::StringType& device_location, |
| + const base::Closure& no_references_callback); |
| + |
| + private: |
| + // Friend declaration for ref counted implementation. |
| + friend class base::RefCounted<ScopedMTPDeviceMapEntry>; |
| + |
| + // Private because this class is ref-counted. |
| + ~ScopedMTPDeviceMapEntry(); |
| + |
| + // Store the MTP or PTP device location. |
| + const FilePath::StringType device_location_; |
| + |
| + // Store a raw pointer of MTPDeviceDelegateImpl object. |
| + // MTPDeviceDelegateImpl is ref-counted and owned by MTPDeviceMapService. |
| + // This class tells MTPDeviceMapService to dispose of it when the last |
| + // reference to |this| goes away. |
| + MTPDeviceDelegateImpl* delegate_; |
| + |
| + // A callback to call when the last reference of this object goes away. |
| + base::Closure no_references_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedMTPDeviceMapEntry); |
| +}; |
| +#endif |
| + |
| class MediaFileSystemContext { |
| public: |
| virtual ~MediaFileSystemContext() {} |
| @@ -107,7 +144,10 @@ class MediaFileSystemRegistry |
| const FilePath::StringType& location) OVERRIDE; |
| virtual void OnRemovableStorageDetached(const std::string& id) OVERRIDE; |
| + size_t GetExtensionHostCountForTests(); |
|
Lei Zhang
2012/11/09 09:14:53
const
vandebo (ex-Chrome)
2012/11/13 06:50:18
Done.
|
| + |
| private: |
| + friend class TestMediaFileSystemContext; |
| friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>; |
| class MediaFileSystemContextImpl; |