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

Unified Diff: chrome/browser/media_gallery/media_file_system_registry.h

Issue 11027051: MediaFileSystemRegistry unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win compile Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..063fcf433bee3608be018499c71a97708348bc00 100644
--- a/chrome/browser/media_gallery/media_file_system_registry.h
+++ b/chrome/browser/media_gallery/media_file_system_registry.h
@@ -23,6 +23,10 @@
#include "base/system_monitor/system_monitor.h"
#include "webkit/fileapi/media/mtp_device_file_system_config.h"
+#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
+#include "chrome/browser/media_gallery/mtp_device_delegate_impl.h"
+#endif
+
class Profile;
namespace content {
@@ -41,7 +45,6 @@ namespace chrome {
class ExtensionGalleriesHost;
class MediaGalleriesPreferences;
-class ScopedMTPDeviceMapEntry;
struct MediaFileSystemInfo {
MediaFileSystemInfo(const std::string& fs_name,
@@ -54,6 +57,43 @@ struct MediaFileSystemInfo {
std::string fsid;
};
+#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
Lei Zhang 2012/11/15 05:40:10 This is going to conflict with https://codereview.
kmadhusu 2012/11/15 17:31:09 Looks like this CL is close to commit stage. So, y
+// 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 +147,10 @@ class MediaFileSystemRegistry
const FilePath::StringType& location) OVERRIDE;
virtual void OnRemovableStorageDetached(const std::string& id) OVERRIDE;
+ size_t GetExtensionHostCountForTests() const;
+
private:
+ friend class TestMediaFileSystemContext;
friend struct base::DefaultLazyInstanceTraits<MediaFileSystemRegistry>;
class MediaFileSystemContextImpl;

Powered by Google App Engine
This is Rietveld 408576698