Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2044)

Unified Diff: chrome/browser/media/router/browser_presentation_connection_proxy.h

Issue 2471573005: [Presentation API] (5th) (1-UA) integrate controller and receiver side for 1-UA messaging (Closed)
Patch Set: split renderer related changes into 4th patch Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8448c003d35db8b86c2d1a627ecd38e41d57289c
--- /dev/null
+++ b/chrome/browser/media/router/browser_presentation_connection_proxy.h
@@ -0,0 +1,70 @@
+// Copyright 2016 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/browser/presentation_session.h"
+#include "mojo/public/cpp/bindings/binding.h"
+
+namespace media_router {
+
+class MediaRouter;
+class MediaRoute;
+
+using OnMessageCallback = base::Callback<void(bool)>;
+
+// 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'.
mark a. foltz 2016/12/02 23:06:48 Wrap comments @ 80 cols
zhaobin 2017/01/13 00:05:49 Done.
+//
+// |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 page to media router:
+// PresentationConnection::sendString();
+// -> PresentationDispatcher::DoSendMessage();
+// -> PresentationConnectionProxy::SendSessionMessage();
+// --> (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.
+// -> BrowserPresentationConnectionProxy::OnMessage();
+// -> MediaRouter::SendRouteMessage();
+//
+// 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.
+
+class BrowserPresentationConnectionProxy
+ : public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) {
+ public:
+ BrowserPresentationConnectionProxy(const content::PresentationSessionInfo&,
+ MediaRouter* router,
+ MediaRoute* route);
+ ~BrowserPresentationConnectionProxy() override;
+
+ blink::mojom::PresentationConnectionPtr Bind();
+
+ // blink::mojom::PresentationConnection implementation
+ void SetTargetConnection(
+ blink::mojom::PresentationConnectionPtr connection) override;
+ void OnMessage(blink::mojom::SessionMessagePtr message,
+ const OnMessageCallback& callback) override;
+ void DidChangeState(blink::mojom::PresentationConnectionState state) override;
+
+ void OnConnectionMessageCallback(bool sent);
+
+ private:
+ content::PresentationSessionInfo session_info_;
+ 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
+ MediaRoute* route_;
+
+ mojo::Binding<blink::mojom::PresentationConnection> binding_;
+ blink::mojom::PresentationConnectionPtr target_connection_;
+ 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.
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_BROWSER_PRESENTATION_CONNECTION_PROXY_H_

Powered by Google App Engine
This is Rietveld 408576698