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

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: Refine the implementations for storage event. 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/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h"
10 #include "base/values.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/extensions/api/system_info_storage/storage_info_provide r.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 StorageInfoProvider::Delegate {
21 public:
22 static SystemInfoEventRouter* GetInstance();
23
24 // Add/remove event listener for the |event_name| event from |profile|.
25 void AddEventListener(Profile* profile, const std::string& event_name);
26 void RemoveEventListener(Profile* profile, const std::string& event_name);
27
28 // Return true if the |event_name| event is already being listened.
29 bool HasEventListener(const std::string& event_name);
30
31 // Return true if the |event_name| is an event from systemInfo namespace.
32 static bool IsSystemInfoEvent(const std::string& event_name);
33
34 private:
35 friend struct DefaultSingletonTraits<SystemInfoEventRouter>;
36
37 // Map of the profile and its events that are being listened.
38 typedef std::map<Profile*, std::set<std::string> > EventListenerMap;
39
40 SystemInfoEventRouter();
41 virtual ~SystemInfoEventRouter();
42
43 // Overriden from StorageInfoProvider::Delegate. These methods can be
44 // called from any thread.
45 void OnStorageDeviceAvailableCapacityChanged(const std::string& id,
46 double available_capacity);
47 void OnStorageDeviceAdded(const std::string& id,
48 const std::string& type,
49 double capacity,
50 double available_capacity);
51 void OnStorageDeviceRemoved(const std::string& id);
52
53
54 // Called on the UI thread to dispatch the systemInfo event to all extension
55 // processes cross multiple profiles.
56 void DispatchEvent(const std::string& event_name,
57 const base::ListValue& args);
58 // Called on the UI thread.
59 void DispatchAvailableCapacityChangedEvent(const std::string& id,
60 double available_capacity);
61
62 EventListenerMap event_listener_map_;
63
64 DISALLOW_COPY_AND_ASSIGN(SystemInfoEventRouter);
65 };
66
67 } // namespace extensions
68 #endif // CHROME_BROWSER_EXTENSIONS_SYSTEM_INFO_EVENT_ROUTER_H_
OLDNEW
« 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