| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 5 #ifndef CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 6 #define CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| 7 | 7 |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/observer_list_threadsafe.h" | 9 #include "base/observer_list_threadsafe.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/system_monitor/system_monitor.h" | |
| 13 | 12 |
| 14 namespace chrome { | 13 namespace chrome { |
| 15 | 14 |
| 16 class RemovableStorageObserver; | 15 class RemovableStorageObserver; |
| 17 | 16 |
| 18 // Base class for platform-specific instances watching for removable storage | 17 // Base class for platform-specific instances watching for removable storage |
| 19 // attachments/detachments. | 18 // attachments/detachments. |
| 20 class RemovableStorageNotifications { | 19 class RemovableStorageNotifications { |
| 21 public: | 20 public: |
| 22 struct StorageInfo { | 21 struct StorageInfo { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime | 39 // Returns a pointer to an object owned by the BrowserMainParts, with lifetime |
| 41 // somewhat shorter than a process Singleton. | 40 // somewhat shorter than a process Singleton. |
| 42 static RemovableStorageNotifications* GetInstance(); | 41 static RemovableStorageNotifications* GetInstance(); |
| 43 | 42 |
| 44 // Finds the device that contains |path| and populates |device_info|. | 43 // Finds the device that contains |path| and populates |device_info|. |
| 45 // Should be able to handle any path on the local system, not just removable | 44 // Should be able to handle any path on the local system, not just removable |
| 46 // storage. Returns false if unable to find the device. | 45 // storage. Returns false if unable to find the device. |
| 47 // TODO(gbillock): Change this method signature to use StorageInfo. | 46 // TODO(gbillock): Change this method signature to use StorageInfo. |
| 48 virtual bool GetDeviceInfoForPath( | 47 virtual bool GetDeviceInfoForPath( |
| 49 const FilePath& path, | 48 const FilePath& path, |
| 50 base::SystemMonitor::RemovableStorageInfo* device_info) const = 0; | 49 StorageInfo* device_info) const = 0; |
| 51 | 50 |
| 52 // Returns the storage size of the device present at |location|. If the | 51 // Returns the storage size of the device present at |location|. If the |
| 53 // device information is unavailable, returns zero. | 52 // device information is unavailable, returns zero. |
| 54 virtual uint64 GetStorageSize(const std::string& location) const = 0; | 53 virtual uint64 GetStorageSize(const std::string& location) const = 0; |
| 55 | 54 |
| 56 // Returns information for attached removable storage. | 55 // Returns information for attached removable storage. |
| 57 std::vector<StorageInfo> GetAttachedStorage() const; | 56 std::vector<StorageInfo> GetAttachedStorage() const; |
| 58 | 57 |
| 59 void AddObserver(RemovableStorageObserver* obs); | 58 void AddObserver(RemovableStorageObserver* obs); |
| 60 void RemoveObserver(RemovableStorageObserver* obs); | 59 void RemoveObserver(RemovableStorageObserver* obs); |
| 61 | 60 |
| 62 protected: | 61 protected: |
| 63 RemovableStorageNotifications(); | 62 RemovableStorageNotifications(); |
| 64 | 63 |
| 64 // TODO(gbillock): remove these friends by making the classes owned by the |
| 65 // platform-specific implementation. |
| 66 friend class MediaFileSystemRegistryTest; |
| 67 friend class MediaGalleriesPrivateApiTest; |
| 68 friend class MediaStorageUtilTest; |
| 69 friend class MediaTransferProtocolDeviceObserverLinux; |
| 70 friend class PortableDeviceWatcherWin; |
| 71 friend class VolumeMountWatcherWin; |
| 72 |
| 65 void ProcessAttach(const std::string& id, | 73 void ProcessAttach(const std::string& id, |
| 66 const string16& name, | 74 const string16& name, |
| 67 const FilePath::StringType& location); | 75 const FilePath::StringType& location); |
| 68 void ProcessDetach(const std::string& id); | 76 void ProcessDetach(const std::string& id); |
| 69 | 77 |
| 70 private: | 78 private: |
| 71 typedef std::map<std::string, StorageInfo> RemovableStorageMap; | 79 typedef std::map<std::string, StorageInfo> RemovableStorageMap; |
| 72 | 80 |
| 73 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > | 81 scoped_refptr<ObserverListThreadSafe<RemovableStorageObserver> > |
| 74 observer_list_; | 82 observer_list_; |
| 75 | 83 |
| 76 // For manipulating removable_storage_map_ structure. | 84 // For manipulating removable_storage_map_ structure. |
| 77 mutable base::Lock storage_lock_; | 85 mutable base::Lock storage_lock_; |
| 78 | 86 |
| 79 // Map of all the attached removable storage devices. | 87 // Map of all the attached removable storage devices. |
| 80 RemovableStorageMap storage_map_; | 88 RemovableStorageMap storage_map_; |
| 81 }; | 89 }; |
| 82 | 90 |
| 83 } // namespace chrome | 91 } // namespace chrome |
| 84 | 92 |
| 85 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ | 93 #endif // CHROME_BROWSER_SYSTEM_MONITOR_REMOVABLE_STORAGE_NOTIFICATIONS_H_ |
| OLD | NEW |