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

Side by Side Diff: base/system_monitor/system_monitor.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « base/sys_info_win.cc ('k') | base/system_monitor/system_monitor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
7
8 #include "base/base_export.h"
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list_threadsafe.h"
12 #include "build/build_config.h"
13
14 namespace base {
15
16 // Class for monitoring various system-related subsystems
17 // such as power management, network status, etc.
18 // TODO(mbelshe): Add support beyond just power management.
19 class BASE_EXPORT SystemMonitor {
20 public:
21 // Type of devices whose change need to be monitored, such as add/remove.
22 enum DeviceType {
23 DEVTYPE_AUDIO_CAPTURE, // Audio capture device, e.g., microphone.
24 DEVTYPE_VIDEO_CAPTURE, // Video capture device, e.g., webcam.
25 DEVTYPE_UNKNOWN, // Other devices.
26 };
27
28 // Create SystemMonitor. Only one SystemMonitor instance per application
29 // is allowed.
30 SystemMonitor();
31 ~SystemMonitor();
32
33 // Get the application-wide SystemMonitor (if not present, returns NULL).
34 static SystemMonitor* Get();
35
36 class BASE_EXPORT DevicesChangedObserver {
37 public:
38 // Notification that the devices connected to the system have changed.
39 // This is only implemented on Windows currently.
40 virtual void OnDevicesChanged(DeviceType device_type) {}
41
42 protected:
43 virtual ~DevicesChangedObserver() {}
44 };
45
46 // Add a new observer.
47 // Can be called from any thread.
48 // Must not be called from within a notification callback.
49 void AddDevicesChangedObserver(DevicesChangedObserver* obs);
50
51 // Remove an existing observer.
52 // Can be called from any thread.
53 // Must not be called from within a notification callback.
54 void RemoveDevicesChangedObserver(DevicesChangedObserver* obs);
55
56 // The ProcessFoo() style methods are a broken pattern and should not
57 // be copied. Any significant addition to this class is blocked on
58 // refactoring to improve the state of affairs. See http://crbug.com/149059
59
60 // Cross-platform handling of a device change event.
61 void ProcessDevicesChanged(DeviceType device_type);
62
63 private:
64 // Functions to trigger notifications.
65 void NotifyDevicesChanged(DeviceType device_type);
66
67 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> >
68 devices_changed_observer_list_;
69
70 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
71 };
72
73 } // namespace base
74
75 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
OLDNEW
« no previous file with comments | « base/sys_info_win.cc ('k') | base/system_monitor/system_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698