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

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: resolving code review comments from Derek 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 using OnMessageCallback = base::Callback<void(bool)>;
20
21 // This class connects PresentationConnection owned by one frame with
22 // PresentationConnection owned by a different frame.
23 //
24 // PresentationConnectionProxy's ctor sets |source_connection_| to
25 // PresentationConnection object owned by one frame.
26 //
27 // To connect |controller_connection_proxy| on controlling frame with
28 // |receiver_connection_proxy| on receiver frame:
29 // 1. On controlling frame, create PresentationConnection object and
30 // ControllerConnectionProxy object |controller_connection_proxy|;
31 // 2. Create |target_connection_request|, an interface request of
32 // controller proxy's |target_connection_| by invoking:
33 // ControllerConnectionProxy::MakeRemoteRequest() {
34 // return mojo::MakeRequest(&target_connection_);
35 // }
36 // 3. Pass |controller_connection_proxy|'s interface pointer and
37 // |target_connection_request| to browser;
38 // 4. Browser passes |controller_connection_proxy|'s interface pointer and
39 // |target_connection_request| to receiver frame;
40 // 5. On receiver frame, create PresentationConnection object and
41 // ReceiverConnectionProxy object |receiver_connection_proxy|;
42 // 6. Bind |target_connection_request| with |receiver_connection_proxy| by
43 // invoking:
44 // ReceiverConnectionProxy::Bind(target_connection_request);
45 // 7. Set receiver proxy's |target_connection_| to
46 // |controller_connection_proxy|'s interface pointer:
47 // ReceiverConnectionProxy::BindTargetConnection(
48 // blink::mojom::PresentationConnectionPtr connection) {
49 // target_connection_ = std::move(connection);
50 // ...
51 // }
52 //
53 // When both |source_connection_| and |target_connection_| are set,
54 // we can send message or notify state changes between controller and receiver.
55 //
56 // To send message from controlling frame to receiver frame:
57 // 1. Controlling frame invokes connection.sendMessage();
58 // 2. This call is delegated to controller presentation connection proxy's
59 // SendString().
mark a. foltz 2017/01/23 20:18:42 I don't see SendString() defined below. Did you m
zhaobin 2017/01/24 01:23:24 Done.
60 // ControllerConnectionProxy::SendConnectionMessage() {
61 // target_connection_->OnMessage();
62 // }
63 // 3. ReceiverConnectionProxy::OnMessage() is invoked.
64 // 4. connection.onmessage event on receiver frame is fired.
65 //
66 // Sending message from receiver frame to controlling frame and notifying state
67 // changes works the same.
68 //
69 // Instance of this class is created for both offscreen and non offscreen
70 // presentations.
71 class CONTENT_EXPORT PresentationConnectionProxy
72 : public blink::WebPresentationConnectionProxy,
73 public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) {
74 public:
75 ~PresentationConnectionProxy() override;
76
77 virtual void SendConnectionMessage(
78 blink::mojom::ConnectionMessagePtr session_message,
mark a. foltz 2017/01/23 20:18:41 s/session_message/connection_message/ here and els
zhaobin 2017/01/24 01:23:24 Done.
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* connection);
mark a. foltz 2017/01/23 20:18:42 source_connection
zhaobin 2017/01/24 01:23:24 Done.
89 mojo::Binding<blink::mojom::PresentationConnection> binding_;
90 mojo::InterfacePtr<blink::mojom::PresentationConnection> target_connection_;
mark a. foltz 2017/01/23 20:18:42 Slight preference for naming this target_connectio
zhaobin 2017/01/24 01:23:24 Done.
91
92 private:
93 // Raw pointer to blink connection object owning this proxy object. Does not
mark a. foltz 2017/01/23 20:18:42 s/blink/Blink/
zhaobin 2017/01/24 01:23:24 Done.
94 // take ownership.
95 blink::WebPresentationConnection* const source_connection_;
96 };
97
98 // Represents PresentationConnectionProxy object on controlling frame.
99 class CONTENT_EXPORT ControllerConnectionProxy
100 : public PresentationConnectionProxy {
101 public:
102 explicit ControllerConnectionProxy(
103 blink::WebPresentationConnection* connection);
mark a. foltz 2017/01/23 20:18:42 s/connection/controller_connection/
zhaobin 2017/01/24 01:23:24 Done.
104 ~ControllerConnectionProxy() override;
105
106 blink::mojom::PresentationConnectionPtr Bind();
107 blink::mojom::PresentationConnectionRequest MakeRemoteRequest();
108 };
109
110 // Represents PresentationConnectionProxy object on receiver frame.
111 class CONTENT_EXPORT ReceiverConnectionProxy
112 : public PresentationConnectionProxy {
113 public:
114 explicit ReceiverConnectionProxy(
115 blink::WebPresentationConnection* connection);
mark a. foltz 2017/01/23 20:18:42 s/connection/receiver_connection/
zhaobin 2017/01/24 01:23:24 Done.
116 ~ReceiverConnectionProxy() override;
117
118 void Bind(
119 blink::mojom::PresentationConnectionRequest target_connection_request);
mark a. foltz 2017/01/23 20:18:41 Could this be receiver_connection_request? The req
zhaobin 2017/01/24 01:23:24 Done.
120 void BindTargetConnection(blink::mojom::PresentationConnectionPtr connection);
mark a. foltz 2017/01/23 20:18:42 Can this be BindControllerConnection() with contro
zhaobin 2017/01/24 01:23:24 Done.
121 };
122
123 } // namespace content
124
125 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698