ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / chromeos / camera_presence_notifier.h
blob5bf089c54a81f378c7d60a8e0e1a85f20383bd15
1 // Copyright 2014 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 CHROME_BROWSER_CHROMEOS_CAMERA_PRESENCE_NOTIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_CAMERA_PRESENCE_NOTIFIER_H_
8 #include "base/memory/singleton.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/observer_list.h"
11 #include "base/timer/timer.h"
13 namespace chromeos {
15 // Camera presence status dispatcher.
16 class CameraPresenceNotifier {
17 public:
18 class Observer {
19 public:
20 virtual void OnCameraPresenceCheckDone(bool is_camera_present) = 0;
21 protected:
22 virtual ~Observer() {}
25 static CameraPresenceNotifier* GetInstance();
27 void AddObserver(CameraPresenceNotifier::Observer* observer);
28 void RemoveObserver(CameraPresenceNotifier::Observer* observer);
30 private:
31 friend struct DefaultSingletonTraits<CameraPresenceNotifier>;
32 CameraPresenceNotifier();
33 ~CameraPresenceNotifier();
35 void CheckCameraPresence();
37 // Sends out a camera presence status notification.
38 void OnCameraPresenceCheckDone();
40 bool camera_present_on_last_check_;
42 // Timer for camera check cycle.
43 base::RepeatingTimer<CameraPresenceNotifier> camera_check_timer_;
45 base::ObserverList<Observer> observers_;
47 base::WeakPtrFactory<CameraPresenceNotifier> weak_factory_;
49 DISALLOW_COPY_AND_ASSIGN(CameraPresenceNotifier);
52 } // namespace chromeos
54 #endif // CHROME_BROWSER_CHROMEOS_CAMERA_PRESENCE_NOTIFIER_H_