| Index: chrome/browser/extensions/api/system_info_storage/storage_info_provider.h
|
| diff --git a/chrome/browser/extensions/api/system_info_storage/storage_info_provider.h b/chrome/browser/extensions/api/system_info_storage/storage_info_provider.h
|
| index 0265ddd0d04031b56caa45818272d3301c66fe62..d74a39ee47ef8e701255abafba7c149cedb0593b 100644
|
| --- a/chrome/browser/extensions/api/system_info_storage/storage_info_provider.h
|
| +++ b/chrome/browser/extensions/api/system_info_storage/storage_info_provider.h
|
| @@ -4,6 +4,8 @@
|
| #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEM_INFO_STORAGE_STORAGE_INFO_PROVIDER_H_
|
| #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_INFO_STORAGE_STORAGE_INFO_PROVIDER_H_
|
|
|
| +#include "base/file_path.h"
|
| +#include "base/system_monitor/system_monitor.h"
|
| #include "chrome/browser/extensions/system_info_provider.h"
|
| #include "chrome/common/extensions/api/experimental_system_info_storage.h"
|
|
|
| @@ -24,18 +26,70 @@ extern const char kStorageTypeRemovable[];
|
| } // namespace systeminfo
|
|
|
| class StorageInfoProvider
|
| - : public SystemInfoProvider<
|
| + : public base::SystemMonitor::DevicesChangedObserver,
|
| + public SystemInfoProvider<
|
| api::experimental_system_info_storage::StorageInfo> {
|
| public:
|
| - virtual ~StorageInfoProvider() {}
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| + // Called when the available capacity is changed.
|
| + // |id|: identifies the storage unit on which the change happened.
|
| + // |available_capacity|: the available capacity on the storage unit.
|
| + virtual void OnStorageDeviceAvailableCapacityChanged(const std::string& id,
|
| + double available_capacity) = 0;
|
| +
|
| + // Called when a new storage device is attached to the system, e.g.
|
| + // a USB disk is plugged in.
|
| + // |id|: The unique identifier for the storage device attached already.
|
| + // |type|: The string of storage type. See storage_info_provider.h comment.
|
| + // |capacity|: The total capacity of the storage device can hold.
|
| + // |available_capacity|: The available capacity left on the storage device.
|
| + virtual void OnStorageDeviceAdded(const std::string& id,
|
| + const std::string& type,
|
| + double capacity,
|
| + double available_capacity) = 0;
|
| +
|
| + // Called when a storage device is removed from the system, e.g.
|
| + // a USB disk is unplugged.
|
| + // |id|: the identifier of the storage device that has been removed.
|
| + virtual void OnStorageDeviceRemoved(const std::string& id) = 0;
|
| + };
|
| +
|
| + virtual ~StorageInfoProvider();
|
|
|
| // Get the single shared instance of StorageInfoProvider.
|
| static StorageInfoProvider* Get();
|
|
|
| - // Get the information for the storage unit specified by the |id| parameter,
|
| - // and output the result to the |info|.
|
| - virtual bool QueryUnitInfo(const std::string& id,
|
| + // Start watching the storage device change events. Return true if it
|
| + // succeeds to start, otherwise false is returned.
|
| + virtual bool StartWatching(Delegate* delegate);
|
| +
|
| + // Stop watching the storage device change events. Return true if it
|
| + // succeeds to stop, otherwise false is returned.
|
| + virtual bool StopWatching();
|
| +
|
| + // Get the information of the storage unit containing |path|, and output the
|
| + // result to the |info|.
|
| + virtual bool QueryUnitInfo(const FilePath::StringType& path,
|
| api::experimental_system_info_storage::StorageUnitInfo* info) = 0;
|
| +
|
| + // Overriden from base::SystemMonitor::DevicesChangedObserver.
|
| + virtual void OnMediaDeviceAttached(const std::string& id,
|
| + const string16& name, const FilePath::StringType& location) OVERRIDE;
|
| + virtual void OnMediaDeviceDetached(const std::string& id) OVERRIDE;
|
| +
|
| + protected:
|
| + StorageInfoProvider();
|
| +
|
| + // Platform specific implementation for start and stop watching.
|
| + virtual bool PlatformStartWatching(Delegate* delegate) = 0;
|
| + virtual bool PlatformStopWatching() = 0;
|
| +
|
| + Delegate* delegate_;
|
| +
|
| + // True if it already started watching the storage change events.
|
| + bool is_watching_;
|
| };
|
|
|
| } // namespace extensions
|
|
|