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

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

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
Index: chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
diff --git a/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc b/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
index 56a7b290d9b9a04261b3a748245e622ca52a6aa9..9e72bea2efd27c56f0531590608a7b8cb2b2e771 100644
--- a/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
+++ b/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/api/system_info_storage/storage_info_provider.h"
namespace extensions {
+
namespace systeminfo {
const char kStorageTypeUnknown[] = "unknown";
@@ -12,4 +13,47 @@ const char kStorageTypeHardDisk[] = "harddisk";
const char kStorageTypeRemovable[] = "removable";
} // namespace systeminfo
+
+using api::experimental_system_info_storage::StorageInfo;
+using api::experimental_system_info_storage::StorageUnitInfo;
+using content::BrowserThread;
+
+StorageInfoProvider::StorageInfoProvider()
+ : delegate_(NULL),
+ is_watching_(false) {
+}
+
+StorageInfoProvider::~StorageInfoProvider() {
+ DCHECK(is_watching_) << "Need to call StopWatching before destroying!";
+}
+
+bool StorageInfoProvider::StartWatching(Delegate* delegate) {
+ // Since it always needs a message loop for device notification, we post
+ // the watching task to File thread instead of the worker pool.
+ bool success =
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
+ base::IgnoreResult(&StorageInfoProvider::PlatformStartWatching),
+ base::Unretained(this), delegate));
+
+ return success;
+}
+
+bool StorageInfoProvider::StopWatching() {
+ bool success =
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(
+ base::IgnoreResult(&StorageInfoProvider::PlatformStopWatching),
+ base::Unretained(this)));
+
+ return success;
+}
+
+void StorageInfoProvider::OnMediaDeviceAttached(const std::string& id,
+ const string16& name, const FilePath::StringType& location) {
+ // TODO(hongbo): Handle the event of a new storage device attached.
+}
+
+void StorageInfoProvider::OnMediaDeviceDetached(const std::string& id) {
+ // TODO(hongbo): Handle the event of a storage device detached.
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698