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

Unified Diff: chrome/browser/system_monitor/removable_storage_notifications.h

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to head Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/system_monitor/removable_storage_notifications.h
diff --git a/chrome/browser/system_monitor/removable_storage_notifications.h b/chrome/browser/system_monitor/removable_storage_notifications.h
index 43924db968eb31b9388164e5d363cb228e4c1f00..c43246c8b2bd9a67b4c58f8db58221de23b06032 100644
--- a/chrome/browser/system_monitor/removable_storage_notifications.h
+++ b/chrome/browser/system_monitor/removable_storage_notifications.h
@@ -6,7 +6,9 @@
#define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_
#include "base/file_path.h"
-#include "base/system_monitor/system_monitor.h"
+#include "base/observer_list_threadsafe.h"
+#include "base/string16.h"
+#include "base/synchronization/lock.h"
namespace chrome {
@@ -14,22 +16,80 @@ namespace chrome {
// attachments/detachments.
class RemovableStorageNotifications {
public:
+ RemovableStorageNotifications();
virtual ~RemovableStorageNotifications() {}
// Returns a pointer to an object owned by the BrowserMainParts, with lifetime
// somewhat shorter than a process Singleton.
static RemovableStorageNotifications* GetInstance();
+ struct BASE_EXPORT RemovableStorageInfo {
+ RemovableStorageInfo();
+ RemovableStorageInfo(const std::string& id,
+ const string16& device_name,
+ const FilePath::StringType& device_location);
+
+ // Unique device id - persists between device attachments.
+ std::string device_id;
+
+ // Human readable removable storage device name.
+ string16 name;
+
+ // Current attached removable storage device location.
+ FilePath::StringType location;
+ };
+
// Finds the device that contains |path| and populates |device_info|.
// Should be able to handle any path on the local system, not just removable
// storage. Returns false if unable to find the device.
virtual bool GetDeviceInfoForPath(
const FilePath& path,
- base::SystemMonitor::RemovableStorageInfo* device_info) const = 0;
+ RemovableStorageInfo* device_info) const = 0;
// Returns the storage size of the device present at |location|. If the
// device information is unavailable, returns zero.
virtual uint64 GetStorageSize(const std::string& location) const = 0;
+
+ // Returns information for attached removable storage.
+ std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const;
+
+ class BASE_EXPORT RemovableStorageObserver {
vandebo (ex-Chrome) 2013/01/04 19:58:38 The Observer should not be an inner class and shou
Greg Billock 2013/01/07 21:55:18 Sounds good. I was mimicking the existing layout p
+ public:
+ // When a removable storage device is attached or detached, one of these
+ // two events is triggered.
+ virtual void OnRemovableStorageAttached(
+ const std::string& id,
+ const string16& name,
+ const FilePath::StringType& location) {}
+ virtual void OnRemovableStorageDetached(const std::string& id) {}
+
+ protected:
+ virtual ~RemovableStorageObserver() {}
+ };
+
+ void AddRemovableStorageObserver(RemovableStorageObserver* obs);
vandebo (ex-Chrome) 2013/01/04 19:58:38 Since there's only one observer in this class, the
Greg Billock 2013/01/07 21:55:18 Done. This was a mouthful! On 2013/01/04 19:58:38
+ void RemoveRemovableStorageObserver(RemovableStorageObserver* obs);
+
+ void ProcessRemovableStorageAttached(const std::string& id,
vandebo (ex-Chrome) 2013/01/04 19:58:38 The process methods should not be public. I was p
Greg Billock 2013/01/07 21:55:18 Done.
+ const string16& name,
+ const FilePath::StringType& location);
+ void ProcessRemovableStorageDetached(const std::string& id);
+
+ private:
+ typedef std::map<std::string, RemovableStorageInfo> RemovableStorageMap;
+
+ void NotifyRemovableStorageAttached(const std::string& id,
+ const string16& name,
+ const FilePath::StringType& location);
+ void NotifyRemovableStorageDetached(const std::string& id);
+
+ scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> >
+ observer_list_;
+
+ // For manipulating removable_storage_map_ structure.
+ mutable base::Lock removable_storage_lock_;
+ // Map of all the attached removable storage devices.
+ RemovableStorageMap removable_storage_map_;
};
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698