ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / chromeos / camera_detector.h
blob8194e2ec445966e10c8f9b23081a40d6fff9c68f
1 // Copyright (c) 2011 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_DETECTOR_H_
6 #define CHROME_BROWSER_CHROMEOS_CAMERA_DETECTOR_H_
8 #include "base/callback.h"
10 namespace chromeos {
12 // Class used to check for camera presence.
13 class CameraDetector {
14 public:
15 enum CameraPresence {
16 kCameraPresenceUnknown = 0,
17 kCameraAbsent,
18 kCameraPresent
21 // Returns result of the last presence check. If no check has been performed
22 // yet, returns |kCameraPresenceUnknown|.
23 static CameraPresence camera_presence() {
24 return camera_presence_;
27 // Checks asynchronously for camera device presence. Only one
28 // presence check can be running at a time. Calls |check_done|
29 // on current thread when the check has been completed.
30 static void StartPresenceCheck(const base::Closure& check_done);
32 private:
33 // Called back on UI thread after check has been performed.
34 static void OnPresenceCheckDone(const base::Closure& callback, bool present);
36 // Checks for camera presence. Runs on a thread that allows I/O.
37 static bool CheckPresence();
39 // Result of the last presence check.
40 static CameraPresence camera_presence_;
42 static bool presence_check_in_progress_;
44 DISALLOW_COPY_AND_ASSIGN(CameraDetector);
47 } // namespace chromeos
49 #endif // CHROME_BROWSER_CHROMEOS_CAMERA_DETECTOR_H_