Chromium Code Reviews| Index: chrome/browser/media/router/browser_presentation_connection_proxy.h |
| diff --git a/chrome/browser/media/router/browser_presentation_connection_proxy.h b/chrome/browser/media/router/browser_presentation_connection_proxy.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7fb739074180fbe91fbd9da8df80a0df07963f24 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/browser_presentation_connection_proxy.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ |
| +#define CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ |
| + |
| +#include "content/public/browser/presentation_service_delegate.h" |
| +#include "content/public/common/presentation_session.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| + |
| +namespace media_router { |
| + |
| +class MediaRouter; |
| +class MediaRoute; |
| + |
| +// This class represents a browser side PresentationConnection. It connects with |
| +// PresentationConnection owned by a render frame to enable message exchange. |
| +// Message received on this class is further routed to Media Router. State of |
| +// browser side PresentationConnection is always 'connected'. |
| +// |
| +// |SetTargetConnection| sets |target_connection_| to mojo handle of |
| +// PresentationConnection object owned a render frame, and transits state of |
| +// |target_connection_| to 'connected'. |
| +// |
| +// Send message from render frame to media router: |
| +// PresentationConnection::sendString(); |
| +// -> PresentationDispatcher::DoSendMessage(); |
| +// -> PresentationConnectionProxy::SendSessionMessage(); |
| +// --> (mojo call to browser side PresentationConnection) |
| +// -> BrowserPresentationConnectionProxy::OnMessage(); |
| +// -> MediaRouter::SendRouteMessage(); |
| +// |
| +// Instance of this class is only created for remotely rendered presentations. |
| +// It is owned by PresentationFrame. When PresentationFrame gets destroyed or |
| +// |route_| is closed or terminated, instance of this class will be destroyed. |
| + |
| +class BrowserPresentationConnectionProxy |
| + : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) { |
| + public: |
| + using OnMessageCallback = base::Callback<void(bool)>; |
| + |
| + BrowserPresentationConnectionProxy(MediaRouter* router, |
| + const MediaRoute* route); |
| + ~BrowserPresentationConnectionProxy() override; |
| + |
| + // Binds instance of this class with |receiver_connection_request|. |
| + void Bind( |
|
imcheng
2017/01/31 01:53:24
Maybe name this BindToRequest or something similar
zhaobin
2017/01/31 18:44:15
Done.
|
| + blink::mojom::PresentationConnectionRequest receiver_connection_request); |
| + |
| + // Sets |target_connection_ptr_| to |controller_connection_ptr|. Should be |
| + // called only once. |
| + void BindControllerConnection( |
| + blink::mojom::PresentationConnectionPtr controller_connection_ptr); |
| + |
| + // blink::mojom::PresentationConnection implementation |
| + void OnMessage(blink::mojom::ConnectionMessagePtr message, |
| + const OnMessageCallback& on_message_callback) override; |
| + void DidChangeState( |
| + 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.
|
| + |
| + private: |
| + // |router_| not owned by this class. |
| + MediaRouter* router_; |
|
imcheng
2017/01/31 01:53:25
MediaRouter* const
zhaobin
2017/01/31 18:44:15
Done.
|
| + // |route_| not owned by this class. |
| + 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.
|
| + |
| + mojo::Binding<blink::mojom::PresentationConnection> binding_; |
| + blink::mojom::PresentationConnectionPtr target_connection_ptr_; |
| +}; |
| + |
| +} // namespace media_router |
| + |
| +#endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_ |