Commit 42407c7f authored by zhaobin's avatar zhaobin Committed by Commit bot

[Presentation API] (5th)(1-UA) integrate controller and receiver side for 1-UA messaging

This CL actually turns on 1-UA messaging:

- When presentation starts, a new route is created and returned to MR. In PresentationDispatcher, we send controller_connection_proxy and receiver_connection_request back to browser via PresentationService::SetPresentationConnection()

For 1-UA:
  - In PresentationServiceDelegateImpl::ConnectToPresentation(), we register proxy and request as a controller connection entry to OPM. If there has been a receiver_call_back, invoke it;
  - When offscreen tab is rendered, we register a receiverPSDImpl, which registers a receiver_call_back to OPM. If there is any pending controller connection entry, invoke receiver_call_back for each controller connection entry;
  - In receiver_call_back (PresentationDispatcher::OnReceiverConnectionAvailable() function), we create a receiver_connection_proxy object, bind it to receiver_connection_request (input parameter) and connect it with controller_connection_proxy (input parameter). Message sending between controller Blink connection and receiver Blink connection may happen afterwards.

For 2-UA:
  - In PresentationServiceDelegateImpl::ConnectToPresentation(), we create a browser_connection_proxy object, bind it to receiver_connection_request (input parameter) and connect it with controller_connection_proxy (input parameter). Message sending from controller Blink connection to media router may happen afterwards.

More details in code comments and design doc (use chromium.org account): https://docs.google.com/document/d/1XM3jhMJTQyhEC5PDAAJFNIaKh6UUEihqZDz_ztEe4Co/edit#heading=h.hadpx5oi0gml

Patch set 4 updates:
- added BrowserPresentationConnectionProxy class
- Added PresentationFrame::IsOffscreen() and PresentationFrame::OnBrowserConnectionAvailable()
- PresentationConnection::OnMessage() takes a callback
- PresentationDispatcher::SendXXX() takes PresentationConnectionProxy as parameter

BUG=525660,513859

Review-Url: https://codereview.chromium.org/2471573005
Cr-Original-Commit-Position: refs/heads/master@{#448299}
Committed: https://chromium.googlesource.com/chromium/src/+/4b94a1fe3f58aacad2c46bbfd84aa780469e15be
Review-Url: https://codereview.chromium.org/2471573005
Cr-Commit-Position: refs/heads/master@{#448509}
parent 35b4a855
......@@ -10,6 +10,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h"
#include "chrome/browser/media/router/receiver_presentation_service_delegate_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/web_contents_sizer.h"
#include "content/public/browser/render_view_host.h"
......@@ -117,11 +118,14 @@ void OffscreenTab::Start(const GURL& start_url,
// automatically unmuted, but will be captured into the MediaStream.
offscreen_tab_web_contents_->SetAudioMuted(true);
// TODO(imcheng): If |optional_presentation_id| is not empty, register it with
// the PresentationRouter. http://crbug.com/513859
if (!optional_presentation_id.empty()) {
NOTIMPLEMENTED()
<< "Register with PresentationRouter, id=" << optional_presentation_id;
DVLOG(1) << " Register with ReceiverPresentationServiceDelegateImpl, "
<< "[presentation_id]: " << optional_presentation_id;
// Create a ReceiverPSDImpl associated with the offscreen tab's WebContents.
// The new instance will set up the necessary infrastructure to allow
// controlling peers the ability to connect to the offscreen tab.
media_router::ReceiverPresentationServiceDelegateImpl::CreateForWebContents(
offscreen_tab_web_contents_.get(), optional_presentation_id);
if (auto* render_view_host =
offscreen_tab_web_contents_->GetRenderViewHost()) {
......
......@@ -18,6 +18,8 @@ static_library("router") {
"//url",
]
sources = [
"browser_presentation_connection_proxy.cc",
"browser_presentation_connection_proxy.h",
"create_presentation_connection_request.cc",
"create_presentation_connection_request.h",
"issue.cc",
......
// 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.
#include "chrome/browser/media/router/browser_presentation_connection_proxy.h"
#include "chrome/browser/media/router/media_router.h"
#include "content/public/common/presentation_constants.h"
namespace {
// TODO(crbug.com/632623): remove this function when we finish typemaps for
// presentation.mojom.
std::unique_ptr<content::PresentationConnectionMessage>
PresentationConnectionMessageFromMojo(
blink::mojom::ConnectionMessagePtr input) {
std::unique_ptr<content::PresentationConnectionMessage> output;
if (input.is_null())
return output;
switch (input->type) {
case blink::mojom::PresentationMessageType::TEXT: {
// Return nullptr content::PresentationSessionMessage if invalid (unset
// |message|, set |data|, or size too large).
if (input->data || !input->message ||
input->message->size() >
content::kMaxPresentationConnectionMessageSize)
return output;
output.reset(new content::PresentationConnectionMessage(
content::PresentationMessageType::TEXT));
output->message = std::move(input->message.value());
return output;
}
case blink::mojom::PresentationMessageType::BINARY: {
// Return nullptr content::PresentationSessionMessage if invalid (unset
// |data|, set |message|, or size too large).
if (!input->data || input->message ||
input->data->size() > content::kMaxPresentationConnectionMessageSize)
return output;
output.reset(new content::PresentationConnectionMessage(
content::PresentationMessageType::BINARY));
output->data.reset(
new std::vector<uint8_t>(std::move(input->data.value())));
return output;
}
}
NOTREACHED() << "Invalid presentation message type " << input->type;
return output;
}
} // namespace
namespace media_router {
BrowserPresentationConnectionProxy::BrowserPresentationConnectionProxy(
MediaRouter* router,
const MediaRoute::Id& route_id,
blink::mojom::PresentationConnectionRequest receiver_connection_request,
blink::mojom::PresentationConnectionPtr controller_connection_ptr)
: router_(router),
route_id_(route_id),
binding_(this),
target_connection_ptr_(std::move(controller_connection_ptr)) {
DCHECK(router);
DCHECK(target_connection_ptr_);
binding_.Bind(std::move(receiver_connection_request));
target_connection_ptr_->DidChangeState(
content::PRESENTATION_CONNECTION_STATE_CONNECTED);
}
BrowserPresentationConnectionProxy::~BrowserPresentationConnectionProxy() {}
void BrowserPresentationConnectionProxy::OnMessage(
blink::mojom::ConnectionMessagePtr connection_message,
const OnMessageCallback& on_message_callback) {
DVLOG(2) << "BrowserPresentationConnectionProxy::OnMessage";
DCHECK(!connection_message.is_null());
auto message =
PresentationConnectionMessageFromMojo(std::move(connection_message));
if (message->is_binary()) {
router_->SendRouteBinaryMessage(route_id_, std::move(message->data),
on_message_callback);
} else {
router_->SendRouteMessage(route_id_, message->message, on_message_callback);
}
}
} // namespace media_router
// 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 "chrome/browser/media/router/media_route.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;
// 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)>;
// |router|: media router instance not owned by this class;
// |route_id|: underlying media route. |target_connection_ptr_| sends message
// to media route with |route_id|;
// |receiver_connection_request|: mojo interface request to be bind with this
// object;
// |controller_connection_ptr|: mojo interface ptr of controlling frame's
// connection proxy object.
BrowserPresentationConnectionProxy(
MediaRouter* router,
const MediaRoute::Id& route_id,
blink::mojom::PresentationConnectionRequest receiver_connection_request,
blink::mojom::PresentationConnectionPtr controller_connection_ptr);
~BrowserPresentationConnectionProxy() override;
// blink::mojom::PresentationConnection implementation
void OnMessage(blink::mojom::ConnectionMessagePtr message,
const OnMessageCallback& on_message_callback) override;
// Underlying media route is always connected. Media route class does not
// support state change.
void DidChangeState(content::PresentationConnectionState state) override {}
private:
// |router_| not owned by this class.
MediaRouter* const router_;
const MediaRoute::Id route_id_;
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_
// 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.
#include "chrome/browser/media/router/browser_presentation_connection_proxy.h"
#include "base/run_loop.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/media/router/media_source.h"
#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/media/router/mock_media_router.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::_;
namespace media_router {
constexpr char kMediaRouteId[] = "MockRouteId";
class MockPresentationConnectionProxy
: public NON_EXPORTED_BASE(blink::mojom::PresentationConnection) {
public:
void OnMessage(blink::mojom::ConnectionMessagePtr message,
const OnMessageCallback& on_message_callback) override {
OnMessageRaw(message.get(), on_message_callback);
}
MOCK_METHOD2(OnMessageRaw,
void(const blink::mojom::ConnectionMessage*,
const OnMessageCallback&));
MOCK_METHOD1(DidChangeState,
void(content::PresentationConnectionState state));
};
class BrowserPresentationConnectionProxyTest : public ::testing::Test {
public:
BrowserPresentationConnectionProxyTest() = default;
void SetUp() override {
mock_controller_connection_proxy_ =
base::MakeUnique<MockPresentationConnectionProxy>();
blink::mojom::PresentationConnectionPtr controller_connection_ptr;
mojo::Binding<blink::mojom::PresentationConnection> binding(
mock_controller_connection_proxy_.get(),
mojo::MakeRequest(&controller_connection_ptr));
EXPECT_CALL(
*mock_controller_connection_proxy_,
DidChangeState(content::PRESENTATION_CONNECTION_STATE_CONNECTED));
blink::mojom::PresentationConnectionPtr receiver_connection_ptr;
base::RunLoop run_loop;
browser_connection_proxy_ =
base::MakeUnique<BrowserPresentationConnectionProxy>(
&mock_router_, "MockRouteId",
mojo::MakeRequest(&receiver_connection_ptr),
std::move(controller_connection_ptr));
run_loop.RunUntilIdle();
}
void TearDown() override {
browser_connection_proxy_.reset();
mock_controller_connection_proxy_.reset();
}
BrowserPresentationConnectionProxy* browser_connection_proxy() {
return browser_connection_proxy_.get();
}
MockMediaRouter* mock_router() { return &mock_router_; }
private:
std::unique_ptr<MockPresentationConnectionProxy>
mock_controller_connection_proxy_;
std::unique_ptr<BrowserPresentationConnectionProxy> browser_connection_proxy_;
MockMediaRouter mock_router_;
content::TestBrowserThreadBundle thread_bundle_;
};
TEST_F(BrowserPresentationConnectionProxyTest, TestOnMessageTextMessage) {
std::string message = "test message";
blink::mojom::ConnectionMessagePtr session_message =
blink::mojom::ConnectionMessage::New();
session_message->type = blink::mojom::PresentationMessageType::TEXT;
session_message->message = message;
base::MockCallback<base::Callback<void(bool)>> mock_on_message_callback;
EXPECT_CALL(*mock_router(), SendRouteMessage(kMediaRouteId, message, _));
browser_connection_proxy()->OnMessage(std::move(session_message),
mock_on_message_callback.Get());
}
TEST_F(BrowserPresentationConnectionProxyTest, TestOnMessageBinaryMessage) {
std::vector<uint8_t> expected_data;
expected_data.push_back(42);
expected_data.push_back(36);
blink::mojom::ConnectionMessagePtr session_message =
blink::mojom::ConnectionMessage::New();
session_message->type = blink::mojom::PresentationMessageType::BINARY;
session_message->data = expected_data;
base::MockCallback<base::Callback<void(bool)>> mock_on_message_callback;
EXPECT_CALL(*mock_router(), SendRouteBinaryMessageInternal(_, _, _))
.WillOnce(::testing::Invoke([this, &expected_data](
const MediaRoute::Id& route_id, std::vector<uint8_t>* data,
const BrowserPresentationConnectionProxy::OnMessageCallback&
callback) { EXPECT_EQ(expected_data, *data); }));
browser_connection_proxy()->OnMessage(std::move(session_message),
mock_on_message_callback.Get());
}
} // namespace media_router
......@@ -133,7 +133,7 @@ class PresentationServiceDelegateImpl
const content::PresentationSessionInfo& connection,
const content::PresentationConnectionStateChangedCallback&
state_changed_cb) override;
void ConnectToOffscreenPresentation(
void ConnectToPresentation(
int render_process_id,
int render_frame_id,
const content::PresentationSessionInfo& session,
......@@ -184,6 +184,8 @@ class PresentationServiceDelegateImpl
DefaultPresentationRequestObserver);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
DefaultPresentationUrlCallback);
FRIEND_TEST_ALL_PREFIXES(PresentationServiceDelegateImplTest,
ConnectToPresentation);
explicit PresentationServiceDelegateImpl(content::WebContents* web_contents);
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/media/router/presentation_service_delegate_impl.h"
#include "base/memory/ptr_util.h"
#include "base/test/mock_callback.h"
#include "chrome/browser/media/router/media_source.h"
#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/media/router/mock_media_router.h"
......@@ -485,7 +486,7 @@ TEST_F(PresentationServiceDelegateImplTest, SinksObserverCantRegister) {
main_frame_process_id_, main_frame_routing_id_, &listener1_));
}
TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) {
TEST_F(PresentationServiceDelegateImplTest, ConnectToPresentation) {
content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame();
ASSERT_TRUE(main_frame);
int render_process_id = main_frame->GetProcess()->GetID();
......@@ -495,6 +496,18 @@ TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) {
content::PresentationSessionInfo session_info(presentation_url,
presentation_id);
base::MockCallback<
base::Callback<void(const content::PresentationSessionInfo&)>>
mock_callback;
EXPECT_CALL(mock_callback, Run(_));
MediaRoute media_route(
"route_id", MediaSourceForPresentationUrl(session_info.presentation_url),
"mediaSinkId", "", true, "", true);
media_route.set_offscreen_presentation(true);
delegate_impl_->OnStartSessionSucceeded(render_process_id, render_frame_id,
mock_callback.Get(), session_info,
media_route);
OffscreenPresentationManagerFactory::GetInstanceForTest()->SetTestingFactory(
profile(), &BuildMockOffscreenPresentationManager);
MockOffscreenPresentationManager* mock_offscreen_manager =
......@@ -508,9 +521,16 @@ TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) {
content::PresentationConnectionPtr connection_ptr;
content::PresentationConnectionRequest connection_request;
delegate_impl_->ConnectToOffscreenPresentation(
render_process_id, render_frame_id, session_info,
std::move(connection_ptr), std::move(connection_request));
delegate_impl_->ConnectToPresentation(render_process_id, render_frame_id,
session_info, std::move(connection_ptr),
std::move(connection_request));
EXPECT_CALL(*mock_offscreen_manager,
UnregisterOffscreenPresentationController(
presentation_id,
RenderFrameHostId(render_process_id, render_frame_id)));
EXPECT_CALL(router_, DetachRoute("route_id"));
delegate_impl_->Reset(render_process_id, render_frame_id);
}
#if !defined(OS_ANDROID)
......
......@@ -4382,6 +4382,7 @@ test("unit_tests") {
if (enable_media_router) {
sources += [
"../browser/media/cast_remoting_connector_unittest.cc",
"../browser/media/router/browser_presentation_connection_proxy_unittest.cc",
"../browser/media/router/create_presentation_connection_request_unittest.cc",
"../browser/media/router/issue_manager_unittest.cc",
"../browser/media/router/issue_unittest.cc",
......
......@@ -472,7 +472,7 @@ void PresentationServiceImpl::SetPresentationConnection(
if (!controller_delegate_)
return;
controller_delegate_->ConnectToOffscreenPresentation(
controller_delegate_->ConnectToPresentation(
render_process_id_, render_frame_id_, session_info,
std::move(controller_connection_ptr),
std::move(receiver_connection_request));
......
......@@ -140,7 +140,7 @@ class MockPresentationServiceDelegate
const content::PresentationConnectionStateChangedCallback&
state_changed_cb));
void ConnectToOffscreenPresentation(
void ConnectToPresentation(
int render_process_id,
int render_frame_id,
const content::PresentationSessionInfo& session,
......@@ -523,8 +523,7 @@ TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrls) {
run_loop.Run();
}
TEST_F(PresentationServiceImplTest,
ListenForConnectionStateChange) {
TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
content::PresentationSessionInfo connection(presentation_url1_,
kPresentationId);
content::PresentationConnectionStateChangedCallback state_changed_cb;
......
......@@ -226,7 +226,7 @@ class CONTENT_EXPORT ControllerPresentationServiceDelegate
// ownership passed from controlling frame to the offscreen presentation.
// |receiver_connection_request|: Mojo InterfaceRequest to be bind to receiver
// page's presentation connection.
virtual void ConnectToOffscreenPresentation(
virtual void ConnectToPresentation(
int render_process_id,
int render_frame_id,
const PresentationSessionInfo& session,
......
......@@ -214,12 +214,14 @@ void PresentationDispatcher::sendBlobData(
}
void PresentationDispatcher::DoSendMessage(SendMessageRequest* request) {
ConnectToPresentationServiceIfNeeded();
presentation_service_->SendConnectionMessage(
std::move(request->session_info), std::move(request->message),
base::Bind(&PresentationDispatcher::HandleSendMessageRequests,
base::Unretained(this)));
DCHECK(request->connection_proxy);
// TODO(crbug.com/684116): Remove static_cast after moving message queue logic
// from PresentationDispatcher to PresentationConnectionProxy.
static_cast<const PresentationConnectionProxy*>(request->connection_proxy)
->SendConnectionMessage(
std::move(request->message),
base::Bind(&PresentationDispatcher::HandleSendMessageRequests,
base::Unretained(this)));
}
void PresentationDispatcher::HandleSendMessageRequests(bool success) {
......@@ -243,6 +245,20 @@ void PresentationDispatcher::HandleSendMessageRequests(bool success) {
}
}
void PresentationDispatcher::SetControllerConnection(
const PresentationSessionInfo& session_info,
blink::WebPresentationConnection* connection) {
DCHECK(connection);
auto* controller_connection_proxy = new ControllerConnectionProxy(connection);
connection->bindProxy(base::WrapUnique(controller_connection_proxy));
ConnectToPresentationServiceIfNeeded();
presentation_service_->SetPresentationConnection(
session_info, controller_connection_proxy->Bind(),
controller_connection_proxy->MakeRemoteRequest());
}
void PresentationDispatcher::closeSession(
const blink::WebURL& presentationUrl,
const blink::WebString& presentationId) {
......@@ -474,13 +490,19 @@ void PresentationDispatcher::OnDefaultSessionStarted(
if (!controller_)
return;
presentation_service_->ListenForConnectionMessages(session_info);
auto* connection =
controller_->didStartDefaultSession(blink::WebPresentationSessionInfo(
session_info.presentation_url,
blink::WebString::fromUTF8(session_info.presentation_id)));
connection->bindProxy(
base::MakeUnique<ControllerConnectionProxy>(connection));
if (connection) {
SetControllerConnection(session_info, connection);
// Change blink connection state to 'connected' before listening to
// connection message. Remove ListenForConnectionMessage() after
// TODO(crbug.com/687011): use BrowserPresentationConnectionProxy to send
// message from route to blink connection.
presentation_service_->ListenForConnectionMessages(session_info);
}
}
void PresentationDispatcher::OnSessionCreated(
......@@ -497,14 +519,15 @@ void PresentationDispatcher::OnSessionCreated(
}
DCHECK(session_info);
presentation_service_->ListenForConnectionMessages(session_info.value());
callback->onSuccess(blink::WebPresentationSessionInfo(
session_info->presentation_url,
blink::WebString::fromUTF8(session_info->presentation_id)));
auto* connection = callback->getConnection();
connection->bindProxy(
base::MakeUnique<ControllerConnectionProxy>(connection));
// Change blink connection state to 'connected' before listening to
// connection message. Remove ListenForConnectionMessage() after
// TODO(crbug.com/687011): use BrowserPresentationConnectionProxy to send
// message from route to blink connection.
SetControllerConnection(session_info.value(), callback->getConnection());
presentation_service_->ListenForConnectionMessages(session_info.value());
}
void PresentationDispatcher::OnReceiverConnectionAvailable(
......@@ -512,6 +535,7 @@ void PresentationDispatcher::OnReceiverConnectionAvailable(
blink::mojom::PresentationConnectionPtr controller_connection_ptr,
blink::mojom::PresentationConnectionRequest receiver_connection_request) {
DCHECK(receiver_);
// Bind receiver_connection_proxy with PresentationConnection in receiver
// page.
auto* connection = receiver_->onReceiverConnectionAvailable(
......
......@@ -28,6 +28,7 @@
namespace blink {
class WebPresentationAvailabilityObserver;
class WebPresentationConnection;
class WebPresentationReceiver;
class WebString;
class WebURL;
......@@ -62,6 +63,8 @@ class CONTENT_EXPORT PresentationDispatcher
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendString);
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendArrayBuffer);
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestSendBlobData);
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
TestOnReceiverConnectionAvailable);
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestCloseSession);
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest, TestTerminateSession);
FRIEND_TEST_ALL_PREFIXES(PresentationDispatcherTest,
......@@ -175,6 +178,17 @@ class CONTENT_EXPORT PresentationDispatcher
void DoSendMessage(SendMessageRequest* request);
void HandleSendMessageRequests(bool success);
// Creates ControllerConnectionProxy object |controller_connection_proxy| with
// |connection|. Sends mojo interface ptr of |controller_connection_proxy|
// and mojo interface request of |controller_connection_proxy|'s
// |target_connection_| to PresentationService.
// |session_info|: |connection|'s id and url;
// |connection|: |controller_connection_proxy|'s |source_connection_|. Raw
// pointer to Blink connection owning proxy object. It does not take object
// ownership.
void SetControllerConnection(const PresentationSessionInfo& session_info,
blink::WebPresentationConnection* connection);
virtual void ConnectToPresentationServiceIfNeeded();
void UpdateListeningState();
......
......@@ -19,4 +19,8 @@ void TestPresentationConnection::bindProxy(
proxy_ = std::move(proxy);
}
blink::WebPresentationConnectionProxy* TestPresentationConnection::proxy() {
return proxy_.get();
}
} // namespace content
......@@ -25,6 +25,8 @@ class TestPresentationConnection : public blink::WebPresentationConnection {
void(const uint8_t* data, size_t length));
MOCK_METHOD1(didChangeState, void(blink::WebPresentationConnectionState));
blink::WebPresentationConnectionProxy* proxy();
private:
std::unique_ptr<blink::WebPresentationConnectionProxy> proxy_;
};
......
......@@ -165,8 +165,7 @@ void PresentationConnection::bindProxy(
DCHECK(proxy);
// TODO(zhaobin): Restore to DCHECK(!m_proxy) when reconnect() is properly
// implemented.
if (!m_proxy)
m_proxy = std::move(proxy);
m_proxy = std::move(proxy);
}
// static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment