OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 // |SetSourceConnection| sets |source_connection_| to PresentationConnection | |
25 // object owned by one frame. | |
26 // |SetTargetConnection| sets |target_connection_| to mojo handle of | |
27 // PresentationConnection object owned by a different frame. | |
dcheng
2017/01/17 23:31:49
Nit: update these comments? I found them helpful w
zhaobin
2017/01/18 18:25:47
Done.
| |
28 // | |
29 // When both |source_connection_| and |target_connection_| are set, | |
30 // we can send message or notify state changes between controller and receiver. | |
31 // | |
32 // To send message from controlling frame to receiver frame: | |
33 // 1. Controlling frame invokes connection.sendMessage(); | |
34 // 2. This call is delegated to controller presentation connection proxy's | |
35 // SendString(). | |
36 // PresentationConnectionProxy::SendString() { | |
37 // target_connection_->OnConnectionMessageReceived(); | |
38 // } | |
39 // 3. Receiver PresentationConnectionProxy::OnConnectionMessageReceived() is | |
40 // invoked. | |
41 // 4. connection.onmessage event on receiver frame is fired. | |
42 // | |
43 // Sending message from receiver frame to controlling frame and notifying state | |
44 // changes works the same. | |
45 // | |
46 // Instance of this class is only created for offscreen presentations. | |
47 class CONTENT_EXPORT PresentationConnectionProxy | |
48 : public blink::WebPresentationConnectionProxy, | |
49 public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { | |
50 public: | |
51 ~PresentationConnectionProxy() override; | |
52 | |
53 virtual void SendConnectionMessage( | |
54 blink::mojom::ConnectionMessagePtr session_message, | |
55 const OnMessageCallback& callback) const; | |
56 | |
57 // blink::mojom::PresentationConnection implementation | |
58 void OnMessage(blink::mojom::ConnectionMessagePtr message, | |
59 const OnMessageCallback& callback) override; | |
60 void DidChangeState(blink::mojom::PresentationConnectionState state) override; | |
61 | |
62 protected: | |
63 PresentationConnectionProxy(blink::WebPresentationConnection*); | |
dcheng
2017/01/17 23:31:49
Nit: explicit (also, please name the constructor p
zhaobin
2017/01/18 18:25:47
Done.
| |
64 mojo::Binding<blink::mojom::PresentationConnection> binding_; | |
65 mojo::InterfacePtr<blink::mojom::PresentationConnection> target_connection_; | |
66 | |
67 private: | |
68 blink::WebPresentationConnection* source_connection_; | |
69 }; | |
70 | |
71 // Represents PresentationConnectionProxy object on controlling frame. | |
72 class CONTENT_EXPORT ControllerConnectionProxy | |
73 : public PresentationConnectionProxy { | |
74 public: | |
75 ControllerConnectionProxy(blink::WebPresentationConnection*); | |
dcheng
2017/01/17 23:31:49
Ditto with explicit here.
zhaobin
2017/01/18 18:25:47
Done.
| |
76 ~ControllerConnectionProxy() override; | |
77 | |
78 virtual blink::mojom::PresentationConnectionPtr Bind(); | |
79 virtual blink::mojom::PresentationConnectionRequest MakeRemoteRequest(); | |
80 }; | |
81 | |
82 // Represents PresentationConnectionProxy object on receiver frame. | |
83 class CONTENT_EXPORT ReceiverConnectionProxy | |
84 : public PresentationConnectionProxy { | |
85 public: | |
86 ReceiverConnectionProxy(blink::WebPresentationConnection*); | |
87 ~ReceiverConnectionProxy() override; | |
88 | |
89 virtual void Bind(blink::mojom::PresentationConnectionRequest); | |
90 virtual void SetTargetConnection( | |
91 blink::mojom::PresentationConnectionPtr connection); | |
92 }; | |
93 | |
94 } // namespace content | |
95 | |
96 #endif // CONTENT_RENDERER_PRESENTATION_PRESENTATION_CONNECTION_PROXY_H_ | |
OLD | NEW |