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

Unified Diff: chrome/browser/extensions/api/system_info_storage/storage_info_provider.h

Issue 10836341: Add the basic code skeleton for system info event router (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refine the implementations for storage event. Created 8 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698