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

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: Polish testing code 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 <set>
9
10 #include "base/file_path.h"
11 #include "base/memory/singleton.h"
12 #include "base/values.h"
13
14 namespace extensions {
15
16 // Event router for systemInfo API. It is a singleton instance shared by
17 // multiple profiles.
18 // TODO(hongbo): It should derive from SystemMonitor::DevicesChangedObserver.
19 // Since the system_monitor will be refactored along with media_gallery, once
20 // http://crbug.com/145400 is fixed, we need to update SystemInfoEventRouter
21 // accordingly.
22 class SystemInfoEventRouter {
23 public:
24 static SystemInfoEventRouter* GetInstance();
25
26 // Add/remove event listener for the |event_name| event from |profile|.
27 void AddEventListener(const std::string& event_name);
28 void RemoveEventListener(const std::string& event_name);
29
30 // Return true if the |event_name| is an event from systemInfo namespace.
31 static bool IsSystemInfoEvent(const std::string& event_name);
32
33 // TODO(hongbo): The following methods should be likely overriden from
34 // SystemMonitor::DevicesChangedObserver once the http://crbug.com/145400
35 // is fixed.
36 void OnStorageAvailableCapacityChanged(const std::string& id,
37 int64 available_capacity);
38 void OnRemovableStorageAttached(const std::string& id,
39 const string16& name,
40 const FilePath::StringType& location);
41 void OnRemovableStorageDetached(const std::string& id);
42
43 private:
44 friend struct DefaultSingletonTraits<SystemInfoEventRouter>;
45
46 SystemInfoEventRouter();
47 virtual ~SystemInfoEventRouter();
48
49 // Called on the UI thread to dispatch the systemInfo event to all extension
50 // processes cross multiple profiles.
51 void DispatchEvent(const std::string& event_name,
52 scoped_ptr<base::ListValue> args);
53
54 // Used to record the event names being watched.
55 std::multiset<std::string> watching_event_set_;
56
57 DISALLOW_COPY_AND_ASSIGN(SystemInfoEventRouter);
58 };
59
60 } // namespace extensions
61
62 #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