Revert of Re-enabled contenteditable and text-changed tests after content editable...
[chromium-blink-merge.git] / base / system_monitor / system_monitor.h
blob5dd849f5e3e3da2daf38e16c6040a020c5211000
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.
5 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
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"
14 namespace base {
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.
28 // Create SystemMonitor. Only one SystemMonitor instance per application
29 // is allowed.
30 SystemMonitor();
31 ~SystemMonitor();
33 // Get the application-wide SystemMonitor (if not present, returns NULL).
34 static SystemMonitor* Get();
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) {}
42 protected:
43 virtual ~DevicesChangedObserver() {}
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);
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);
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
60 // Cross-platform handling of a device change event.
61 void ProcessDevicesChanged(DeviceType device_type);
63 private:
64 // Functions to trigger notifications.
65 void NotifyDevicesChanged(DeviceType device_type);
67 scoped_refptr<ObserverListThreadSafe<DevicesChangedObserver> >
68 devices_changed_observer_list_;
70 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
73 } // namespace base
75 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_