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

Unified Diff: chrome/browser/extensions/system_info_event_router.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: Polish testing code 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 | « chrome/browser/extensions/event_router.cc ('k') | chrome/browser/extensions/system_info_event_router.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/system_info_event_router.h
diff --git a/chrome/browser/extensions/system_info_event_router.h b/chrome/browser/extensions/system_info_event_router.h
new file mode 100644
index 0000000000000000000000000000000000000000..a6e22a930f9bf03f91c77a55c10d241b41496f85
--- /dev/null
+++ b/chrome/browser/extensions/system_info_event_router.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
+#define CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
+
+#include <set>
+
+#include "base/file_path.h"
+#include "base/memory/singleton.h"
+#include "base/values.h"
+
+namespace extensions {
+
+// Event router for systemInfo API. It is a singleton instance shared by
+// multiple profiles.
+// TODO(hongbo): It should derive from SystemMonitor::DevicesChangedObserver.
+// Since the system_monitor will be refactored along with media_gallery, once
+// http://crbug.com/145400 is fixed, we need to update SystemInfoEventRouter
+// accordingly.
+class SystemInfoEventRouter {
+ public:
+ static SystemInfoEventRouter* GetInstance();
+
+ // Add/remove event listener for the |event_name| event from |profile|.
+ void AddEventListener(const std::string& event_name);
+ void RemoveEventListener(const std::string& event_name);
+
+ // Return true if the |event_name| is an event from systemInfo namespace.
+ static bool IsSystemInfoEvent(const std::string& event_name);
+
+ // TODO(hongbo): The following methods should be likely overriden from
+ // SystemMonitor::DevicesChangedObserver once the http://crbug.com/145400
+ // is fixed.
+ void OnStorageAvailableCapacityChanged(const std::string& id,
+ int64 available_capacity);
+ void OnRemovableStorageAttached(const std::string& id,
+ const string16& name,
+ const FilePath::StringType& location);
+ void OnRemovableStorageDetached(const std::string& id);
+
+ private:
+ friend struct DefaultSingletonTraits<SystemInfoEventRouter>;
+
+ SystemInfoEventRouter();
+ virtual ~SystemInfoEventRouter();
+
+ // Called on the UI thread to dispatch the systemInfo event to all extension
+ // processes cross multiple profiles.
+ void DispatchEvent(const std::string& event_name,
+ scoped_ptr<base::ListValue> args);
+
+ // Used to record the event names being watched.
+ std::multiset<std::string> watching_event_set_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemInfoEventRouter);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
« no previous file with comments | « chrome/browser/extensions/event_router.cc ('k') | chrome/browser/extensions/system_info_event_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698