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

Unified Diff: content/renderer/presentation/presentation_dispatcher.cc

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: rebase with master and resolve merge conflicts Created 4 years, 2 months 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: content/renderer/presentation/presentation_dispatcher.cc
diff --git a/content/renderer/presentation/presentation_dispatcher.cc b/content/renderer/presentation/presentation_dispatcher.cc
index e0f857e4f63069ad3f09e923b4536617d81888f6..fe4e9b063ca7f51680d7b1d578c050bef52c053e 100644
--- a/content/renderer/presentation/presentation_dispatcher.cc
+++ b/content/renderer/presentation/presentation_dispatcher.cc
@@ -13,6 +13,7 @@
#include "content/public/common/presentation_constants.h"
#include "content/public/renderer/render_frame.h"
#include "content/renderer/presentation/presentation_connection_client.h"
+#include "content/renderer/presentation/presentation_connection_proxy.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
@@ -81,8 +82,8 @@ namespace content {
PresentationDispatcher::PresentationDispatcher(RenderFrame* render_frame)
: RenderFrameObserver(render_frame),
controller_(nullptr),
- binding_(this) {
-}
+ receiver_(nullptr),
+ binding_(this) {}
PresentationDispatcher::~PresentationDispatcher() {
// Controller should be destroyed before the dispatcher when frame is
@@ -375,11 +376,23 @@ void PresentationDispatcher::OnDefaultSessionStarted(
if (!controller_)
return;
- if (!session_info.is_null()) {
- presentation_service_->ListenForSessionMessages(session_info.Clone());
- controller_->didStartDefaultSession(
- new PresentationConnectionClient(std::move(session_info)));
+ if (session_info.is_null())
+ return;
+
+ presentation_service_->ListenForSessionMessages(session_info.Clone());
+
+ std::unique_ptr<PresentationConnectionProxy> controller_connection_proxy =
+ nullptr;
+ if (session_info->is_offscreen_presentation) {
mark a. foltz 2016/10/21 00:53:03 Can you factor out the common code to create and s
zhaobin 2016/10/22 02:44:13 Done.
+ controller_connection_proxy =
+ base::MakeUnique<PresentationConnectionProxy>();
+ // Pass controller_connection_proxy to PSImpl and register
+ // it with OffscreenPresentationManager.
+ presentation_service_->SetPresentationConnection(
+ session_info.Clone(), controller_connection_proxy->Bind());
}
+ controller_->didStartDefaultSession(new PresentationConnectionClient(
+ std::move(session_info), std::move(controller_connection_proxy)));
mark a. foltz 2016/10/21 00:53:03 Is it legal to std::move(nullptr)?
zhaobin 2016/10/22 02:44:13 It works fine...
}
void PresentationDispatcher::OnSessionCreated(
@@ -397,16 +410,38 @@ void PresentationDispatcher::OnSessionCreated(
DCHECK(!session_info.is_null());
presentation_service_->ListenForSessionMessages(session_info.Clone());
- callback->onSuccess(
- base::MakeUnique<PresentationConnectionClient>(std::move(session_info)));
+
+ std::unique_ptr<PresentationConnectionProxy> controller_connection_proxy =
+ nullptr;
+ if (session_info->is_offscreen_presentation) {
+ controller_connection_proxy =
+ base::MakeUnique<PresentationConnectionProxy>();
+ // Pass controller_connection_proxy to PSImpl and register
+ // it with OffscreenPresentationManager.
+ presentation_service_->SetPresentationConnection(
+ session_info.Clone(), controller_connection_proxy->Bind());
+ }
+ // Bind controller_connection_proxy with PresentationConnection
+ // on controller page.
+ callback->onSuccess(base::MakeUnique<PresentationConnectionClient>(
+ session_info.Clone(), std::move(controller_connection_proxy)));
}
void PresentationDispatcher::OnReceiverConnectionAvailable(
- blink::mojom::PresentationSessionInfoPtr session_info) {
- if (receiver_) {
- receiver_->onReceiverConnectionAvailable(
- new PresentationConnectionClient(std::move(session_info)));
- }
+ blink::mojom::PresentationSessionInfoPtr session_info,
+ blink::mojom::PresentationConnectionPtr controller) {
+ if (!receiver_)
+ return;
mark a. foltz 2016/10/21 00:53:03 This seems like a bug, so DCHECK(). IIUC this must
zhaobin 2016/10/22 02:44:13 Done.
+
+ std::unique_ptr<PresentationConnectionProxy> receiver_connection_proxy =
+ base::MakeUnique<PresentationConnectionProxy>();
+
+ controller->SetTargetConnection(receiver_connection_proxy->Bind());
+ receiver_connection_proxy->SetTargetConnection(std::move(controller));
+ // Bind receiver_connection_proxy with PresentationConnection
+ // in receiver page.
+ receiver_->onReceiverConnectionAvailable(new PresentationConnectionClient(
+ std::move(session_info), std::move(receiver_connection_proxy)));
}
void PresentationDispatcher::OnConnectionStateChanged(

Powered by Google App Engine
This is Rietveld 408576698