File: renderer_controller_proxy.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,122,156 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 (73 lines) | stat: -rw-r--r-- 3,172 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
68
69
70
71
72
73
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_CAST_STREAMING_RENDERER_CONTROL_RENDERER_CONTROLLER_PROXY_H_
#define COMPONENTS_CAST_STREAMING_RENDERER_CONTROL_RENDERER_CONTROLLER_PROXY_H_

#include "base/functional/callback.h"
#include "base/threading/thread_checker.h"
#include "components/cast_streaming/common/public/mojom/renderer_controller.mojom.h"
#include "media/mojo/mojom/renderer.mojom.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"

namespace cast_streaming {

// This class serves the purpose of allowing both the browser and renderer
// processes to connect media::mojom::Renderer receiver and remote endpoints
// without concerns of creation order or race conditions becoming concerns.
class RendererControllerProxy : public mojom::RendererController {
 public:
  using MojoDisconnectCB = base::OnceCallback<void()>;

  explicit RendererControllerProxy(MojoDisconnectCB disconnection_handler);
  ~RendererControllerProxy() override;

  // Binds the frame-specific receiver from the browser process.
  void BindRendererController(
      mojo::PendingAssociatedReceiver<mojom::RendererController>
          pending_receiver);

  // Gets the receiver associated with the RenderFrame associated with this
  // instance.
  mojo::PendingReceiver<media::mojom::Renderer> GetReceiver();

 private:
  // mojom::RendererController overrides.
  //
  // Fuses |browser_process_renderer_controls| received from the browser
  // process with  |renderer_process_remote_|, so that commands sent by the
  // browser process are passed immediately to
  // |renderer_process_pending_receiver_|.
  void SetPlaybackController(mojo::PendingReceiver<media::mojom::Renderer>
                                 browser_process_renderer_controls,
                             SetPlaybackControllerCallback callback) override;

  // Callback from the SetPlaybackController() method. Returned when the
  // receiver is taken by the Renderer which uses it.
  SetPlaybackControllerCallback set_playback_controller_cb_;

  // This handle is bound to the |renderer_process_pending_receiver_| upon
  // class construction. When SetPlaybackController() is called, ownership of
  // this instance will be transferred away from this class.
  mojo::PendingRemote<media::mojom::Renderer> renderer_process_remote_;

  // Owned by this class from time of creation until the first call to
  // GetReceiver(), at which time its ownership is passed to the caller.
  mojo::PendingReceiver<media::mojom::Renderer>
      renderer_process_pending_receiver_;

  // Receiver passed from the browser process to the renderer process.
  mojo::AssociatedReceiver<mojom::RendererController> browser_process_receiver_;

  MojoDisconnectCB on_mojo_disconnection_;

  THREAD_CHECKER(thread_checker_);
};

}  // namespace cast_streaming

#endif  // COMPONENTS_CAST_STREAMING_RENDERER_CONTROL_RENDERER_CONTROLLER_PROXY_H_