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

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: Add mock implementation for onAdded and onRemoved events 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 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/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h"
10 #include "base/values.h"
11 #include "chrome/browser/extensions/system_info_watcher.h"
12 #include "chrome/browser/profiles/profile.h"
13
14 namespace extensions {
15
16 class SystemInfoWatcher;
17
18 // Event router for systemInfo API. It is a singleton instance shared by
19 // multiple profiles.
20 class SystemInfoEventRouter : public SystemInfoWatcher::Observer {
21 public:
22 // The single instance of the event router.
23 static SystemInfoEventRouter* GetInstance();
24
25 // Add/remove event listener for the |event_name| event from |profile|.
26 void AddEventListener(Profile* profile, const std::string& event_name);
27 void RemoveEventListener(Profile* profile, const std::string& event_name);
28
29 // Return true if the |event_name| event is already being listened.
30 bool HasEventListener(const std::string& event_name);
31
32 private:
33 friend struct DefaultSingletonTraits<SystemInfoEventRouter>;
34
35 // Map of the profile and its events that are being listened.
36 typedef std::map<Profile*, std::set<std::string> > EventListenerMap;
37
38 SystemInfoEventRouter();
39 virtual ~SystemInfoEventRouter();
40
41 // SystemInfoWatcher::Observer overridens.
42 void OnStorageDeviceAvailableCapacityChanged(const std::string& id,
43 double available_capacity);
44 void OnStorageDeviceAdded(const std::string& id,
45 const std::string& type,
46 double capacity,
47 double available_capacity);
48 void OnStorageDeviceRemoved(const std::string& id);
49
50
51 // Dispatch systemInfo event to all profiles it observes.
52 void DispatchEvent(const std::string& event_name,
53 scoped_ptr<base::ListValue> args);
54
55 // The watcher for system information changes.
56 SystemInfoWatcher* system_info_watcher_;
57
58 EventListenerMap event_listener_map_;
59
60 DISALLOW_COPY_AND_ASSIGN(SystemInfoEventRouter);
61 };
62
63 } // namespace extensions
64 #endif // CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698