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

Side by Side 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: use event router forwarder instead Created 8 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
7
8 #include "base/file_path.h"
9 #include "base/memory/singleton.h"
10 #include "base/values.h"
11
12 namespace extensions {
13
14 // Event router for systemInfo API. It is a singleton instance shared by
15 // multiple profiles.
16 // TODO(hongbo): It should derive from SystemMonitor::DevicesChangedObserver.
17 // Since the system_monitor will be refactored along with media_gallery, once
18 // http://crbug.com/145400 is fixed, we need to update SystemInfoEventRouter
19 // accordingly.
20 class SystemInfoEventRouter {
21 public:
22 static SystemInfoEventRouter* GetInstance();
23
24 // Add/remove event listener for the |event_name| event from |profile|.
25 void AddEventListener(const std::string& event_name);
26 void RemoveEventListener(const std::string& event_name);
27
28 // Return true if the |event_name| is an event from systemInfo namespace.
29 static bool IsSystemInfoEvent(const std::string& event_name);
30
31 // TODO(hongbo): The following methods should be likely overriden from
32 // SystemMonitor::DevicesChangedObserver once the http://crbug.com/145400
33 // is fixed.
34 void OnStorageAvailableCapacityChanged(const std::string& id,
35 int64 available_capacity);
36 void OnRemovableStorageAttached(const std::string& id,
37 const string16& name,
38 const FilePath::StringType& location);
39 void OnRemovableStorageDetached(const std::string& id);
40
41 private:
42 friend struct DefaultSingletonTraits<SystemInfoEventRouter>;
43 // The map of event name which has been watching already to the count it has
44 // been watched.
45 typedef std::map<std::string, int> EventWatchingMap;
Mihai Parparita -not on Chrome 2012/09/01 00:20:53 Nit: I think this can just be a std::multiset<std:
Hongbo Min 2012/09/02 02:47:12 Done.
46
47 SystemInfoEventRouter();
48 virtual ~SystemInfoEventRouter();
49
50 // Called on the UI thread to dispatch the systemInfo event to all extension
51 // processes cross multiple profiles.
52 void DispatchEvent(const std::string& event_name,
53 scoped_ptr<base::ListValue> args);
54
55 // Used to record the number of being watched for the event.
56 EventWatchingMap event_watching_map_;
57
58 DISALLOW_COPY_AND_ASSIGN(SystemInfoEventRouter);
59 };
60
61 } // namespace extensions
62
63 #endif // CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698