OLD | NEW |
---|---|
(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 CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | |
6 #define CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | |
7 | |
8 #include "content/public/browser/presentation_service_delegate.h" | |
9 #include "content/public/common/presentation_session.h" | |
10 #include "mojo/public/cpp/bindings/binding.h" | |
11 | |
12 namespace media_router { | |
13 | |
14 class MediaRouter; | |
15 class MediaRoute; | |
16 | |
17 // This class represents a browser side PresentationConnection. It connects with | |
18 // PresentationConnection owned by a render frame to enable message exchange. | |
19 // Message received on this class is further routed to Media Router. State of | |
20 // browser side PresentationConnection is always 'connected'. | |
21 // | |
22 // |SetTargetConnection| sets |target_connection_| to mojo handle of | |
23 // PresentationConnection object owned a render frame, and transits state of | |
24 // |target_connection_| to 'connected'. | |
25 // | |
26 // Send message from render frame to media router: | |
27 // PresentationConnection::sendString(); | |
28 // -> PresentationDispatcher::DoSendMessage(); | |
29 // -> PresentationConnectionProxy::SendSessionMessage(); | |
30 // --> (mojo call to browser side PresentationConnection) | |
31 // -> BrowserPresentationConnectionProxy::OnMessage(); | |
32 // -> MediaRouter::SendRouteMessage(); | |
33 // | |
34 // Instance of this class is only created for remotely rendered presentations. | |
35 // It is owned by PresentationFrame. When PresentationFrame gets destroyed or | |
36 // |route_| is closed or terminated, instance of this class will be destroyed. | |
37 | |
38 class BrowserPresentationConnectionProxy | |
39 : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { | |
40 public: | |
41 using OnMessageCallback = base::Callback<void(bool)>; | |
42 | |
43 BrowserPresentationConnectionProxy(MediaRouter* router, | |
44 const MediaRoute* route); | |
45 ~BrowserPresentationConnectionProxy() override; | |
46 | |
47 // Binds instance of this class with |receiver_connection_request|. | |
48 void Bind( | |
imcheng
2017/01/31 01:53:24
Maybe name this BindToRequest or something similar
zhaobin
2017/01/31 18:44:15
Done.
| |
49 blink::mojom::PresentationConnectionRequest receiver_connection_request); | |
50 | |
51 // Sets |target_connection_ptr_| to |controller_connection_ptr|. Should be | |
52 // called only once. | |
53 void BindControllerConnection( | |
54 blink::mojom::PresentationConnectionPtr controller_connection_ptr); | |
55 | |
56 // blink::mojom::PresentationConnection implementation | |
57 void OnMessage(blink::mojom::ConnectionMessagePtr message, | |
58 const OnMessageCallback& on_message_callback) override; | |
59 void DidChangeState( | |
60 blink::mojom::PresentationConnectionState state) override {} | |
imcheng
2017/01/31 01:53:24
Add a TODO to implement this, or a comment why thi
zhaobin
2017/01/31 18:44:15
Done.
| |
61 | |
62 private: | |
63 // |router_| not owned by this class. | |
64 MediaRouter* router_; | |
imcheng
2017/01/31 01:53:25
MediaRouter* const
zhaobin
2017/01/31 18:44:15
Done.
| |
65 // |route_| not owned by this class. | |
66 const MediaRoute* route_; | |
imcheng
2017/01/31 01:53:25
Who owns the MediaRoute? Since it is just a data o
zhaobin
2017/01/31 18:44:15
Done.
| |
67 | |
68 mojo::Binding<blink::mojom::PresentationConnection> binding_; | |
69 blink::mojom::PresentationConnectionPtr target_connection_ptr_; | |
70 }; | |
71 | |
72 } // namespace media_router | |
73 | |
74 #endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | |
OLD | NEW |