Chromium Code Reviews| Index: base/system_monitor/system_monitor.h |
| diff --git a/base/system_monitor/system_monitor.h b/base/system_monitor/system_monitor.h |
| index 48d512b708c11aa44368c05300dd9a38f29e00ed..26d64419ab5b249996e30537431eb06d00ef2742 100644 |
| --- a/base/system_monitor/system_monitor.h |
| +++ b/base/system_monitor/system_monitor.h |
| @@ -6,6 +6,7 @@ |
| #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ |
| #include <map> |
| +#include <set> |
| #include <string> |
| #include <vector> |
| @@ -58,6 +59,22 @@ class BASE_EXPORT SystemMonitor { |
| DEVTYPE_UNKNOWN, // Other devices. |
| }; |
| + // The delegate for watching the storage free space changes. If it starts |
|
vandebo (ex-Chrome)
2012/09/10 21:52:49
This isn't for watching storage free space changes
|
| + // watching a storage device, all DevicesChangedObserver added to the |
| + // SystemMonitor will be received OnStorageFreeChanged notification in case |
| + // of the free space of the storage being watched is changed. |
| + class BASE_EXPORT StorageFreeSpaceDelegate { |
| + public: |
| + virtual ~StorageFreeSpaceDelegate() {} |
| + |
| + // Start watching the storage device identified by the |path| parameter. |
| + // Return true if it succeeds to start, otherwise, false is returned. |
| + virtual bool StartWatchingStorage(const FilePath::StringType& path) = 0; |
| + |
| + // Stop watching the storage device identified by the |path| paramter. |
| + virtual bool StopWatchingStorage(const FilePath::StringType& path) = 0; |
| + }; |
| + |
| struct BASE_EXPORT RemovableStorageInfo { |
| RemovableStorageInfo(); |
| RemovableStorageInfo(const std::string& id, |
| @@ -135,6 +152,9 @@ class BASE_EXPORT SystemMonitor { |
| // This is only implemented on Windows currently. |
| virtual void OnDevicesChanged(DeviceType device_type) {} |
| + // Get triggered when the free space of the storage |path| is changed. |
| + virtual void OnStorageFreeSpaceChanged(const FilePath::StringType& path) {} |
| + |
| // When a removable storage device is attached or detached, one of these |
| // two events is triggered. |
| virtual void OnRemovableStorageAttached( |
| @@ -176,6 +196,15 @@ class BASE_EXPORT SystemMonitor { |
| const FilePath::StringType& location); |
| void ProcessRemovableStorageDetached(const std::string& id); |
| + void ProcessStorageFreeSpaceChanged(const FilePath::StringType& path); |
| + |
| + void set_storage_free_space_delegate(StorageFreeSpaceDelegate* delegate) { |
| + free_space_delegate_ = delegate; |
| + } |
| + |
|
Hongbo Min
2012/09/10 14:37:50
vandebo, here I add these two methods for the clie
vandebo (ex-Chrome)
2012/09/10 21:52:49
I guess that's a fair point, but there's a lot of
|
| + bool StartWatchingStorage(const FilePath::StringType& path); |
| + bool StopWatchingStorage(const FilePath::StringType& path); |
| + |
| private: |
| // Mapping of unique device id to device info tuple. |
| typedef std::map<std::string, RemovableStorageInfo> RemovableStorageMap; |
| @@ -222,6 +251,12 @@ class BASE_EXPORT SystemMonitor { |
| // Map of all the attached removable storage devices. |
| RemovableStorageMap removable_storage_map_; |
| + // The delegate instance for watching storage free space changes. |
| + StorageFreeSpaceDelegate* free_space_delegate_; |
| + |
| + // The set of the storage devices being watched. |
| + std::multiset<FilePath::StringType> watched_storages_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(SystemMonitor); |
| }; |