Chromium Code Reviews| 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 using OnMessageCallback = base::Callback<void(bool)>; | |
| 18 | |
| 19 // This class represents a browser side PresentationConnection. It connects with | |
| 20 // PresentationConnection owned by a render frame to enable message exchange. | |
| 21 // Message received on this class is further routed to media router. State of | |
|
mark a. foltz
2017/01/27 00:44:21
nit: Media Router
zhaobin
2017/01/27 05:05:46
Done.
| |
| 22 // browser side PresentationConnection is always 'connected'. | |
| 23 // | |
| 24 // |SetTargetConnection| sets |target_connection_| to mojo handle of | |
| 25 // PresentationConnection object owned a render frame, and transits state of | |
| 26 // |target_connection_| to 'connected'. | |
| 27 // | |
| 28 // Send message from page to media router: | |
|
mark a. foltz
2017/01/27 00:44:21
s/page/render frame/
zhaobin
2017/01/27 05:05:46
Done.
| |
| 29 // PresentationConnection::sendString(); | |
| 30 // -> PresentationDispatcher::DoSendMessage(); | |
| 31 // -> PresentationConnectionProxy::SendSessionMessage(); | |
| 32 // --> (mojo call to browser side PresentationConnection) | |
| 33 // -> BrowserPresentationConnectionProxy::OnMessage(); | |
| 34 // -> MediaRouter::SendRouteMessage(); | |
| 35 // | |
| 36 // Instance of this class is only created for remotely rendered presentations. | |
| 37 // It is owned by PresentationFrame. When PresentationFrame gets destroyed or | |
| 38 // |route_| is closed or terminated, instance of this class will be destroyed. | |
|
mark a. foltz
2017/01/27 00:44:21
What if the PresentationConnection is closed?
zhaobin
2017/01/27 05:05:46
If controller connection.close(), PSDImpl will det
| |
| 39 | |
| 40 class BrowserPresentationConnectionProxy | |
| 41 : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { | |
| 42 public: | |
| 43 BrowserPresentationConnectionProxy(const content::PresentationSessionInfo&, | |
| 44 MediaRouter* router, | |
| 45 MediaRoute* route); | |
| 46 ~BrowserPresentationConnectionProxy() override; | |
| 47 | |
| 48 void Bind(blink::mojom::PresentationConnectionRequest); | |
| 49 void SetTargetConnection(blink::mojom::PresentationConnectionPtr connection); | |
| 50 | |
| 51 // blink::mojom::PresentationConnection implementation | |
| 52 void OnMessage(blink::mojom::ConnectionMessagePtr message, | |
| 53 const OnMessageCallback& callback) override; | |
| 54 void DidChangeState( | |
| 55 blink::mojom::PresentationConnectionState state) override {} | |
| 56 | |
| 57 private: | |
| 58 content::PresentationSessionInfo session_info_; | |
| 59 | |
| 60 // |router_| not owned by this class. | |
| 61 MediaRouter* router_; | |
| 62 // |route_| not owned by this class. | |
| 63 MediaRoute* route_; | |
|
mark a. foltz
2017/01/27 00:44:21
Can this be const?
zhaobin
2017/01/27 05:05:46
Done.
| |
| 64 | |
| 65 mojo::Binding<blink::mojom::PresentationConnection> binding_; | |
| 66 blink::mojom::PresentationConnectionPtr target_connection_; | |
| 67 }; | |
| 68 | |
| 69 } // namespace media_router | |
| 70 | |
| 71 #endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | |
| OLD | NEW |