File: cec_private_delegate.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (67 lines) | stat: -rw-r--r-- 2,865 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef EXTENSIONS_BROWSER_API_CEC_PRIVATE_CEC_PRIVATE_DELEGATE_H_
#define EXTENSIONS_BROWSER_API_CEC_PRIVATE_CEC_PRIVATE_DELEGATE_H_

#include <memory>
#include <vector>

#include "base/functional/callback.h"
#include "extensions/common/api/cec_private.h"

namespace extensions::api {

// The cec_private API ultimately forwards requests to another api which will
// differ depending on platform.
// CecPrivateDelegate provides an abstraction interface to absorb the
// underlying api differences depending on platform.
// CecPrivateDelegate implementations can have a different lifetime from their
// underlying api provider and are responsible for handling its appearance and
// disappearance.
// When the underlying api provider absent, CecPrivateDelegates will shield
// callers from related errors with NOOPs.
class CecPrivateDelegate {
 public:
  using QueryDisplayPowerStateCallback = base::OnceCallback<void(
      const std::vector<cec_private::DisplayCecPowerState>& power_states)>;

  CecPrivateDelegate(const CecPrivateDelegate&) = delete;
  CecPrivateDelegate& operator=(const CecPrivateDelegate&) = delete;
  virtual ~CecPrivateDelegate() = default;

  // Creates a platform-specific CecPrivateDelegate instance.
  static std::unique_ptr<CecPrivateDelegate> CreateInstance();

  // Sends a HDMI-CEC power control message to all attached displays requesting
  // that they go into standby mode (a.k.a. sleep).
  // The effect of calling this method is on a best-effort basis. No guarantees
  // are made about whether the montitors will actually go into standby mode.
  // Does nothing if the underlying provider isn't available. In this case the
  // callback is still invoked.
  virtual void SendStandBy(base::OnceClosure callback) = 0;

  // Announces this device as the active input source to all displays and sends
  // a HDMI-CEC power control message to all attached displays requesting that
  // they wake up.
  // The effect of calling this method is on a best-effort basis. No guarantees
  // are made about whether the montitors will actually wake up.
  // Does nothing if the underlying provider isn't available. In this case the
  // callback is still invoked.
  virtual void SendWakeUp(base::OnceClosure callback) = 0;

  // Gets the current power state of all attached displays. Displays that do not
  // support HDMI-CEC may not appear in the results.
  // Passes an empty list to the callback if the underlying provider isn't
  // available.
  virtual void QueryDisplayCecPowerState(
      QueryDisplayPowerStateCallback callback) = 0;

 protected:
  CecPrivateDelegate() = default;
};

}  // namespace extensions::api

#endif  // EXTENSIONS_BROWSER_API_CEC_PRIVATE_CEC_PRIVATE_DELEGATE_H_