OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ |
7 | 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "chrome/browser/media/router/route_message_observer.h" |
8 #include "chrome/common/media_router/media_route.h" | 11 #include "chrome/common/media_router/media_route.h" |
9 #include "content/public/browser/presentation_service_delegate.h" | 12 #include "content/public/browser/presentation_service_delegate.h" |
10 #include "content/public/common/presentation_connection_message.h" | 13 #include "content/public/common/presentation_connection_message.h" |
11 #include "content/public/common/presentation_info.h" | 14 #include "content/public/common/presentation_info.h" |
12 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
13 | 16 |
14 namespace media_router { | 17 namespace media_router { |
15 | 18 |
16 class MediaRouter; | 19 class MediaRouter; |
17 | 20 |
(...skipping 12 matching lines...) Expand all Loading... |
30 // -> PresentationConnectionProxy::SendConnectionMessage(); | 33 // -> PresentationConnectionProxy::SendConnectionMessage(); |
31 // --> (mojo call to browser side PresentationConnection) | 34 // --> (mojo call to browser side PresentationConnection) |
32 // -> BrowserPresentationConnectionProxy::OnMessage(); | 35 // -> BrowserPresentationConnectionProxy::OnMessage(); |
33 // -> MediaRouter::SendRouteMessage(); | 36 // -> MediaRouter::SendRouteMessage(); |
34 // | 37 // |
35 // Instance of this class is only created for remotely rendered presentations. | 38 // Instance of this class is only created for remotely rendered presentations. |
36 // It is owned by PresentationFrame. When PresentationFrame gets destroyed or | 39 // It is owned by PresentationFrame. When PresentationFrame gets destroyed or |
37 // |route_| is closed or terminated, instance of this class will be destroyed. | 40 // |route_| is closed or terminated, instance of this class will be destroyed. |
38 | 41 |
39 class BrowserPresentationConnectionProxy | 42 class BrowserPresentationConnectionProxy |
40 : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { | 43 : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection), |
| 44 public RouteMessageObserver { |
41 public: | 45 public: |
42 using OnMessageCallback = base::OnceCallback<void(bool)>; | 46 using OnMessageCallback = base::OnceCallback<void(bool)>; |
43 | 47 |
44 // |router|: media router instance not owned by this class; | 48 // |router|: media router instance not owned by this class; |
45 // |route_id|: underlying media route. |target_connection_ptr_| sends message | 49 // |route_id|: underlying media route. |target_connection_ptr_| sends message |
46 // to media route with |route_id|; | 50 // to media route with |route_id|; |
47 // |receiver_connection_request|: mojo interface request to be bind with this | 51 // |receiver_connection_request|: mojo interface request to be bind with this |
48 // object; | 52 // object; |
49 // |controller_connection_ptr|: mojo interface ptr of controlling frame's | 53 // |controller_connection_ptr|: mojo interface ptr of controlling frame's |
50 // connection proxy object. | 54 // connection proxy object. |
51 BrowserPresentationConnectionProxy( | 55 BrowserPresentationConnectionProxy( |
52 MediaRouter* router, | 56 MediaRouter* router, |
53 const MediaRoute::Id& route_id, | 57 const MediaRoute::Id& route_id, |
54 blink::mojom::PresentationConnectionRequest receiver_connection_request, | 58 blink::mojom::PresentationConnectionRequest receiver_connection_request, |
55 blink::mojom::PresentationConnectionPtr controller_connection_ptr); | 59 blink::mojom::PresentationConnectionPtr controller_connection_ptr); |
56 ~BrowserPresentationConnectionProxy() override; | 60 ~BrowserPresentationConnectionProxy() override; |
57 | 61 |
58 // blink::mojom::PresentationConnection implementation | 62 // blink::mojom::PresentationConnection implementation |
59 void OnMessage(content::PresentationConnectionMessage message, | 63 void OnMessage(content::PresentationConnectionMessage message, |
60 OnMessageCallback on_message_callback) override; | 64 OnMessageCallback on_message_callback) override; |
61 | 65 |
62 // Underlying media route is always connected. Media route class does not | 66 // Underlying media route is always connected. Media route class does not |
63 // support state change. | 67 // support state change. |
64 void DidChangeState(content::PresentationConnectionState state) override {} | 68 void DidChangeState(content::PresentationConnectionState state) override {} |
65 | 69 |
66 // Underlying media route is always connected. Media route class does not | 70 // Underlying media route is always connected. Media route class does not |
67 // support state change. | 71 // support state change. |
68 void OnClose() override {} | 72 void OnClose() override {} |
69 | 73 |
| 74 // RouteMessageObserver implementation. |
| 75 void OnMessagesReceived(const std::vector<RouteMessage>& messages) override; |
| 76 |
70 private: | 77 private: |
71 // |router_| not owned by this class. | 78 // |router_| not owned by this class. |
72 MediaRouter* const router_; | 79 MediaRouter* const router_; |
73 const MediaRoute::Id route_id_; | 80 const MediaRoute::Id route_id_; |
74 | 81 |
75 mojo::Binding<blink::mojom::PresentationConnection> binding_; | 82 mojo::Binding<blink::mojom::PresentationConnection> binding_; |
76 blink::mojom::PresentationConnectionPtr target_connection_ptr_; | 83 blink::mojom::PresentationConnectionPtr target_connection_ptr_; |
77 }; | 84 }; |
78 | 85 |
79 } // namespace media_router | 86 } // namespace media_router |
80 | 87 |
81 #endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | 88 #endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ |
OLD | NEW |