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

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

Issue 11358243: Redesigned and refactored ScopedMTPDeviceMapEntry, MTPDeviceMapService & MTPDeviceDelegate classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' 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..ee8056c654f0a5f6ab0b5868e03b808e3b6c7b2e 100644
--- a/chrome/browser/media_gallery/media_file_system_registry.h
+++ b/chrome/browser/media_gallery/media_file_system_registry.h
@@ -9,6 +9,7 @@
#define CHROME_BROWSER_MEDIA_GALLERY_MEDIA_FILE_SYSTEM_REGISTRY_H_
#include <map>
+#include <set>
#include <string>
#include <utility>
#include <vector>
@@ -17,7 +18,6 @@
#include "base/lazy_instance.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "base/prefs/public/pref_change_registrar.h"
#include "base/prefs/public/pref_observer.h"
#include "base/system_monitor/system_monitor.h"
@@ -64,12 +64,16 @@ class MediaFileSystemContext {
const std::string& device_id, const FilePath& path) = 0;
#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
- // Registers and returns the file system id for the MTP or PTP device
- // specified by |device_id| and |path|. Updates |entry| with the corresponding
- // ScopedMTPDeviceMapEntry object.
+ // For the given |galleries_host|, this function returns the file system id
+ // of the registered MTP or PTP device specified by |device_id| and |path|.
virtual std::string RegisterFileSystemForMTPDevice(
const std::string& device_id, const FilePath& path,
- scoped_refptr<ScopedMTPDeviceMapEntry>* entry) = 0;
+ const ExtensionGalleriesHost* galleries_host) = 0;
+
+ // Removes the MTP or PTP device reference for the given |galleries_host|.
+ virtual void RemoveMTPDeviceReferenceForHost(
+ const FilePath::StringType& device_location,
+ const ExtensionGalleriesHost* galleries_host) = 0;
#endif
// Revoke the passed |fsid|.
@@ -120,11 +124,19 @@ class MediaFileSystemRegistry
typedef std::map<Profile*, PrefChangeRegistrar*> PrefChangeRegistrarMap;
#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
- // Map a MTP or PTP device location to the weak pointer of
- // ScopedMTPDeviceMapEntry.
- typedef std::map<const FilePath::StringType,
- base::WeakPtr<ScopedMTPDeviceMapEntry> >
+ // Map a MTP or PTP device location to the ScopedMTPDeviceMapEntry.
+ // This map owns ScopedMTPDeviceMapEntry.
+ typedef std::map<const FilePath::StringType, ScopedMTPDeviceMapEntry*>
MTPDeviceDelegateMap;
+
+ // Set of extension galleries host.
+ typedef std::set<const ExtensionGalleriesHost*> ExtensionGalleriesHostSet;
+
+ // Map a device location to a set of extension galleries host.
+ // This map keeps track of extension galleries that currently registered
+ // the MTP device gallery as a file system.
+ typedef std::map<const FilePath::StringType, ExtensionGalleriesHostSet>
+ MTPDeviceReferencesMap;
#endif
// Obtain an instance of this class via GetInstance().
@@ -136,14 +148,17 @@ class MediaFileSystemRegistry
const std::string& pref_name) OVERRIDE;
#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
- // Returns ScopedMTPDeviceMapEntry object for the given |device_location|.
- ScopedMTPDeviceMapEntry* GetOrCreateScopedMTPDeviceMapEntry(
- const FilePath::StringType& device_location);
+ // Adds the |galleries_host| reference for the MTP device specified by the
+ // |device_location|.
+ void AddGalleriesHostReferenceForMTPDevice(
+ const FilePath::StringType& device_location,
+ const ExtensionGalleriesHost* galleries_host);
- // Removes the ScopedMTPDeviceMapEntry associated with the given
+ // Removes the |galleries_host| reference for the MTP device specified by the
// |device_location|.
- void RemoveScopedMTPDeviceMapEntry(
- const FilePath::StringType& device_location);
+ void RemoveGalleriesHostReferenceForMTPDevice(
+ const FilePath::StringType& device_location,
+ const ExtensionGalleriesHost* galleries_host);
#endif
void OnExtensionGalleriesHostEmpty(Profile* profile,
@@ -157,7 +172,8 @@ class MediaFileSystemRegistry
#if defined(SUPPORT_MTP_DEVICE_FILESYSTEM)
// Only accessed on the UI thread.
- MTPDeviceDelegateMap mtp_delegate_map_;
+ MTPDeviceDelegateMap mtp_device_delegate_map_;
+ MTPDeviceReferencesMap mtp_device_references_map_;
#endif
scoped_ptr<MediaFileSystemContext> file_system_context_;

Powered by Google App Engine
This is Rietveld 408576698