Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1306)

Side by Side Diff: content/renderer/presentation/presentation_connection_proxy.h

Issue 2471263003: [Presentation API] (4th)(1-UA blink side) Add WebPresentationConnection and WebPresentationConnecti… (Closed)
Patch Set: resolve code review comments from mlamouri Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 #ifndef CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
6 #define CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
7
8 #include "base/callback.h"
9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "third_party/WebKit/public/platform/modules/presentation/WebPresentatio nConnectionProxy.h"
11 #include "third_party/WebKit/public/platform/modules/presentation/presentation.m ojom.h"
12
13 namespace blink {
14 class WebPresentationConnection;
15 } // namespace blink
16
17 namespace content {
18
19 // This class connects PresentationConnection owned by one frame with
20 // PresentationConnection owned by a different frame.
21 //
22 // PresentationConnectionProxy's ctor sets |source_connection_| to
23 // PresentationConnection object owned by one frame.
24 //
25 // To connect |controller_connection_proxy| on controlling frame with
26 // |receiver_connection_proxy| on receiver frame:
27 // 1. On controlling frame, create PresentationConnection object and
28 // ControllerConnectionProxy object |controller_connection_proxy|;
29 // 2. Create |target_connection_request|, an interface request of
30 // controller proxy's |target_connection_| by invoking:
31 // ControllerConnectionProxy::MakeRemoteRequest() {
32 // return mojo::MakeRequest(&target_connection_);
33 // }
34 // 3. Pass |controller_connection_proxy|'s interface pointer and
35 // |target_connection_request| to browser;
36 // 4. Browser passes |controller_connection_proxy|'s interface pointer and
37 // |target_connection_request| to receiver frame;
38 // 5. On receiver frame, create PresentationConnection object and
39 // ReceiverConnectionProxy object |receiver_connection_proxy|;
40 // 6. Bind |target_connection_request| with |receiver_connection_proxy| by
41 // invoking:
42 // ReceiverConnectionProxy::Bind(target_connection_request);
43 // 7. Set receiver proxy's |target_connection_| to
44 // |controller_connection_proxy|'s interface pointer:
45 // ReceiverConnectionProxy::BindTargetConnection(
46 // blink::mojom::PresentationConnectionPtr connection) {
47 // target_connection_ = std::move(connection);
48 // ...
49 // }
50 //
51 // When both |source_connection_| and |target_connection_| are set,
52 // we can send message or notify state changes between controller and receiver.
53 //
54 // To send message from controlling frame to receiver frame:
55 // 1. Controlling frame invokes connection.sendMessage();
56 // 2. This call is delegated to controller presentation connection proxy's
57 // SendConnectionMessage().
58 // ControllerConnectionProxy::SendConnectionMessage() {
59 // target_connection_->OnMessage();
60 // }
61 // 3. ReceiverConnectionProxy::OnMessage() is invoked.
62 // 4. connection.onmessage event on receiver frame is fired.
63 //
64 // Sending message from receiver frame to controlling frame and notifying state
65 // changes works the same.
66 //
67 // Instance of this class is created for both offscreen and non offscreen
68 // presentations.
69 class CONTENT_EXPORT PresentationConnectionProxy
70 : public NON_EXPORTED_BASE(blink::WebPresentationConnectionProxy),
71 public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) {
72 public:
73 using OnMessageCallback = base::Callback<void(bool)>;
74
75 ~PresentationConnectionProxy() override;
76
77 virtual void SendConnectionMessage(
78 blink::mojom::ConnectionMessagePtr connection_message,
79 const OnMessageCallback& callback) const;
80
81 // blink::mojom::PresentationConnection implementation
82 void OnMessage(blink::mojom::ConnectionMessagePtr message,
83 const OnMessageCallback& callback) override;
84 void DidChangeState(blink::mojom::PresentationConnectionState state) override;
85
86 protected:
87 explicit PresentationConnectionProxy(
88 blink::WebPresentationConnection* source_connection);
89 mojo::Binding<blink::mojom::PresentationConnection> binding_;
90 mojo::InterfacePtr<blink::mojom::PresentationConnection>
91 target_connection_ptr_;
92
93 private:
94 // Raw pointer to Blink connection object owning this proxy object. Does not
95 // take ownership.
96 blink::WebPresentationConnection* const source_connection_;
97 };
98
99 // Represents PresentationConnectionProxy object on controlling frame.
100 class CONTENT_EXPORT ControllerConnectionProxy
101 : public PresentationConnectionProxy {
102 public:
103 explicit ControllerConnectionProxy(
104 blink::WebPresentationConnection* controller_connection);
105 ~ControllerConnectionProxy() override;
106
107 blink::mojom::PresentationConnectionPtr Bind();
108 blink::mojom::PresentationConnectionRequest MakeRemoteRequest();
109 };
110
111 // Represents PresentationConnectionProxy object on receiver frame.
112 class CONTENT_EXPORT ReceiverConnectionProxy
113 : public PresentationConnectionProxy {
114 public:
115 explicit ReceiverConnectionProxy(
116 blink::WebPresentationConnection* receiver_connection);
117 ~ReceiverConnectionProxy() override;
118
119 void Bind(
120 blink::mojom::PresentationConnectionRequest receiver_connection_request);
121
122 // Sets |target_connection_ptr_| to |controller_connection_ptr|. Should be
123 // called only once.
124 void BindControllerConnection(
125 blink::mojom::PresentationConnectionPtr controller_connection_ptr);
126 };
127
128 } // namespace content
129
130 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
OLDNEW
« no previous file with comments | « content/renderer/BUILD.gn ('k') | content/renderer/presentation/presentation_connection_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698