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 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/browser/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 | |
22 // browser | |
23 // side PresentationConnection is always 'connected'. | |
mark a. foltz
2016/12/02 23:06:48
Wrap comments @ 80 cols
zhaobin
2017/01/13 00:05:49
Done.
| |
24 // | |
25 // |SetTargetConnection| sets |target_connection_| to mojo handle of | |
26 // PresentationConnection object owned a render frame, and transits state of | |
27 // |target_connection_| to 'connected'. | |
28 // | |
29 // Send message from page to media router: | |
30 // PresentationConnection::sendString(); | |
31 // -> PresentationDispatcher::DoSendMessage(); | |
32 // -> PresentationConnectionProxy::SendSessionMessage(); | |
33 // --> (mojo call to browser sid PresentationConnection) | |
mark a. foltz
2016/12/02 23:06:48
typo in 'sid'
zhaobin
2017/01/13 00:05:49
Done.
| |
34 // -> BrowserPresentationConnectionProxy::OnMessage(); | |
35 // -> MediaRouter::SendRouteMessage(); | |
36 // | |
37 // Instance of this class is only created for non-offscreen presentations. | |
mark a. foltz
2016/12/02 23:06:48
We should probably decide on consistent terminolog
zhaobin
2017/01/13 00:05:49
Done.
| |
38 | |
39 class BrowserPresentationConnectionProxy | |
40 : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { | |
41 public: | |
42 BrowserPresentationConnectionProxy(const content::PresentationSessionInfo&, | |
43 MediaRouter* router, | |
44 MediaRoute* route); | |
45 ~BrowserPresentationConnectionProxy() override; | |
46 | |
47 blink::mojom::PresentationConnectionPtr Bind(); | |
48 | |
49 // blink::mojom::PresentationConnection implementation | |
50 void SetTargetConnection( | |
51 blink::mojom::PresentationConnectionPtr connection) override; | |
52 void OnMessage(blink::mojom::SessionMessagePtr message, | |
53 const OnMessageCallback& callback) override; | |
54 void DidChangeState(blink::mojom::PresentationConnectionState state) override; | |
55 | |
56 void OnConnectionMessageCallback(bool sent); | |
57 | |
58 private: | |
59 content::PresentationSessionInfo session_info_; | |
60 MediaRouter* router_; | |
mark a. foltz
2016/12/02 23:06:48
I'm assuming both of these pointers are unowned.
zhaobin
2017/01/13 00:05:49
Done.
PresentationFrame owns BrowserPresentationC
| |
61 MediaRoute* route_; | |
62 | |
63 mojo::Binding<blink::mojom::PresentationConnection> binding_; | |
64 blink::mojom::PresentationConnectionPtr target_connection_; | |
65 std::unique_ptr<OnMessageCallback> on_message_callback_; | |
mark a. foltz
2016/12/02 23:06:48
By default, callbacks are copyable, and I'm not aw
zhaobin
2017/01/13 00:05:49
Done.
| |
66 }; | |
67 | |
68 } // namespace media_router | |
69 | |
70 #endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ | |
OLD | NEW |