Commit e2084383 authored by mark a. foltz's avatar mark a. foltz Committed by Commit Bot

[Presentation API] Remove content::PresentationInfo.

Replaces usages of content::PresentationInfo with blink::mojom::PresentationInfo.
There should be no change in behavior.

The presentation ID length check in the typemap is moved to PresentationServiceImpl.
Presentation IDs are always generated by the browser and a too-long ID is a bug.

Bug: 817903
Change-Id: I6518abbab6d8b6f24925f1fb649a150b08221622
Reviewed-on: https://chromium-review.googlesource.com/1026987Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarDerek Cheng <imcheng@chromium.org>
Commit-Queue: mark a. foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557973}
parent e09fad69
......@@ -9,7 +9,6 @@
#include "chrome/browser/media/android/router/media_router_android_bridge.h"
#include "chrome/browser/media/router/test/test_helper.h"
#include "content/public/browser/presentation_service_delegate.h"
#include "content/public/common/presentation_info.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -6,7 +6,6 @@
#include "base/test/mock_callback.h"
#include "chrome/browser/media/router/test/mock_media_router.h"
#include "chrome/browser/media/router/test/test_helper.h"
#include "content/public/common/presentation_info.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......
......@@ -12,7 +12,6 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/presentation_info.h"
#include "third_party/blink/public/platform/modules/presentation/presentation.mojom.h"
#if defined(OS_ANDROID)
......@@ -91,7 +90,7 @@ void StartPresentationContext::InvokeSuccessCallback(
const MediaRoute& route) {
if (!cb_invoked_) {
std::move(success_cb_)
.Run(content::PresentationInfo(presentation_url, presentation_id),
.Run(blink::mojom::PresentationInfo(presentation_url, presentation_id),
route);
cb_invoked_ = true;
}
......
......@@ -12,10 +12,10 @@
#include "content/public/browser/presentation_request.h"
#include "content/public/browser/presentation_service_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "third_party/blink/public/platform/modules/presentation/presentation.mojom.h"
namespace content {
class WebContents;
struct PresentationInfo;
} // namespace content
namespace media_router {
......@@ -30,7 +30,7 @@ class RouteRequestResult;
class StartPresentationContext {
public:
using PresentationConnectionCallback =
base::OnceCallback<void(const content::PresentationInfo&,
base::OnceCallback<void(const blink::mojom::PresentationInfo&,
const MediaRoute&)>;
using PresentationConnectionErrorCallback =
content::PresentationConnectionErrorCallback;
......
......@@ -47,7 +47,7 @@ class MockWebContentsDelegate : public content::WebContentsDelegate {
class MediaRouterDialogControllerTest : public ChromeRenderViewHostTestHarness {
public:
MOCK_METHOD2(RequestSuccess,
void(const content::PresentationInfo&, const MediaRoute&));
void(const blink::mojom::PresentationInfo&, const MediaRoute&));
MOCK_METHOD1(RequestError,
void(const blink::mojom::PresentationError& error));
......
......@@ -931,7 +931,7 @@ TEST_F(MediaRouterMojoImplTest, PresentationConnectionStateChangedCallback) {
MediaRoute::Id route_id("route-id");
const GURL presentation_url("http://www.example.com/presentation.html");
const std::string kPresentationId("pid");
content::PresentationInfo connection(presentation_url, kPresentationId);
blink::mojom::PresentationInfo connection(presentation_url, kPresentationId);
base::MockCallback<content::PresentationConnectionStateChangedCallback>
callback;
std::unique_ptr<PresentationConnectionStateSubscription> subscription =
......
......@@ -11,7 +11,6 @@
#include "chrome/common/media_router/media_route.h"
#include "content/public/browser/presentation_service_delegate.h"
#include "content/public/common/presentation_connection_message.h"
#include "content/public/common/presentation_info.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace media_router {
......
......@@ -11,6 +11,8 @@
#include "content/public/browser/web_contents.h"
#include "url/gurl.h"
using blink::mojom::PresentationInfo;
namespace media_router {
// LocalPresentationManager implementation.
......@@ -20,12 +22,12 @@ LocalPresentationManager::~LocalPresentationManager() {}
LocalPresentationManager::LocalPresentation*
LocalPresentationManager::GetOrCreateLocalPresentation(
const content::PresentationInfo& presentation_info) {
auto it = local_presentations_.find(presentation_info.presentation_id);
const PresentationInfo& presentation_info) {
auto it = local_presentations_.find(presentation_info.id);
if (it == local_presentations_.end()) {
it = local_presentations_
.insert(std::make_pair(
presentation_info.presentation_id,
presentation_info.id,
std::make_unique<LocalPresentation>(presentation_info)))
.first;
}
......@@ -33,13 +35,12 @@ LocalPresentationManager::GetOrCreateLocalPresentation(
}
void LocalPresentationManager::RegisterLocalPresentationController(
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
const RenderFrameHostId& render_frame_host_id,
content::PresentationConnectionPtr controller_connection_ptr,
content::PresentationConnectionRequest receiver_connection_request,
const MediaRoute& route) {
DVLOG(2) << __func__
<< " [presentation_id]: " << presentation_info.presentation_id
DVLOG(2) << __func__ << " [presentation_id]: " << presentation_info.id
<< ", [render_frame_host_id]: " << render_frame_host_id.second;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......@@ -70,10 +71,9 @@ void LocalPresentationManager::UnregisterLocalPresentationController(
}
void LocalPresentationManager::OnLocalPresentationReceiverCreated(
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
const content::ReceiverConnectionAvailableCallback& receiver_callback) {
DVLOG(2) << __func__
<< " [presentation_id]: " << presentation_info.presentation_id;
DVLOG(2) << __func__ << " [presentation_id]: " << presentation_info.id;
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
auto* presentation = GetOrCreateLocalPresentation(presentation_info);
presentation->RegisterReceiver(receiver_callback);
......@@ -102,7 +102,7 @@ const MediaRoute* LocalPresentationManager::GetRoute(
// LocalPresentation implementation.
LocalPresentationManager::LocalPresentation::LocalPresentation(
const content::PresentationInfo& presentation_info)
const PresentationInfo& presentation_info)
: presentation_info_(presentation_info) {}
LocalPresentationManager::LocalPresentation::~LocalPresentation() {}
......@@ -113,7 +113,7 @@ void LocalPresentationManager::LocalPresentation::RegisterController(
content::PresentationConnectionRequest receiver_connection_request,
const MediaRoute& route) {
if (!receiver_callback_.is_null()) {
receiver_callback_.Run(presentation_info_,
receiver_callback_.Run(PresentationInfo::New(presentation_info_),
std::move(controller_connection_ptr),
std::move(receiver_connection_request));
} else {
......@@ -137,7 +137,7 @@ void LocalPresentationManager::LocalPresentation::RegisterReceiver(
for (auto& controller : pending_controllers_) {
receiver_callback.Run(
presentation_info_,
PresentationInfo::New(presentation_info_),
std::move(controller.second->controller_connection_ptr),
std::move(controller.second->receiver_connection_request));
}
......
......@@ -17,10 +17,7 @@
#include "chrome/common/media_router/media_route.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/presentation_service_delegate.h"
namespace content {
struct PresentationInfo;
}
#include "third_party/blink/public/platform/modules/presentation/presentation.mojom.h"
namespace media_router {
// Manages all local presentations started in the associated Profile and
......@@ -64,7 +61,7 @@ namespace media_router {
// |receiver_connection_request|: Mojo InterfaceRequest to be bind to
// blink::PresentationConnection object in receiver frame's render process.
// void PresentationServiceImpl::OnReceiverConnectionAvailable(
// const content::PresentationInfo& presentation_info,
// const blink::mojom::PresentationInfo& presentation_info,
// PresentationConnectionPtr controller_connection_ptr,
// PresentationConnectionRequest receiver_connection_request) {
// presentation_receiver_client_->OnReceiverConnectionAvailable(
......@@ -115,7 +112,7 @@ class LocalPresentationManager : public KeyedService {
// this class. Ownership is transferred to presentation receiver via
// |receiver_callback| passed below.
virtual void RegisterLocalPresentationController(
const content::PresentationInfo& presentation_info,
const blink::mojom::PresentationInfo& presentation_info,
const RenderFrameHostId& render_frame_id,
content::PresentationConnectionPtr controller_connection_ptr,
content::PresentationConnectionRequest receiver_connection_request,
......@@ -132,7 +129,7 @@ class LocalPresentationManager : public KeyedService {
// Registers |receiver_callback| to presentation with |presentation_info|.
virtual void OnLocalPresentationReceiverCreated(
const content::PresentationInfo& presentation_info,
const blink::mojom::PresentationInfo& presentation_info,
const content::ReceiverConnectionAvailableCallback& receiver_callback);
// Unregisters ReceiverConnectionAvailableCallback associated with
......@@ -157,7 +154,7 @@ class LocalPresentationManager : public KeyedService {
class LocalPresentation {
public:
explicit LocalPresentation(
const content::PresentationInfo& presentation_info);
const blink::mojom::PresentationInfo& presentation_info);
~LocalPresentation();
// Register controller with |render_frame_id|. If |receiver_callback_| has
......@@ -191,7 +188,7 @@ class LocalPresentationManager : public KeyedService {
// controllers.
bool IsValid() const;
const content::PresentationInfo presentation_info_;
const blink::mojom::PresentationInfo presentation_info_;
base::Optional<MediaRoute> route_;
// Callback to invoke whenever a receiver connection is available.
......@@ -238,7 +235,7 @@ class LocalPresentationManager : public KeyedService {
// Creates a local presentation with |presentation_info|.
LocalPresentation* GetOrCreateLocalPresentation(
const content::PresentationInfo& presentation_info);
const blink::mojom::PresentationInfo& presentation_info);
// Maps from presentation ID to LocalPresentation.
LocalPresentationMap local_presentations_;
......
......@@ -12,6 +12,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
using blink::mojom::PresentationInfo;
using blink::mojom::PresentationInfoPtr;
using testing::_;
namespace media_router {
......@@ -25,14 +27,14 @@ const char kPresentationUrl[] = "http://www.example.com/presentation.html";
class MockReceiverConnectionAvailableCallback {
public:
void OnReceiverConnectionAvailable(
const content::PresentationInfo& presentation_info,
PresentationInfoPtr presentation_info,
content::PresentationConnectionPtr controller_conn,
content::PresentationConnectionRequest receiver_conn_request) {
OnReceiverConnectionAvailableRaw(presentation_info, controller_conn.get());
OnReceiverConnectionAvailableRaw(*presentation_info, controller_conn.get());
}
MOCK_METHOD2(OnReceiverConnectionAvailableRaw,
void(const content::PresentationInfo&,
void(const PresentationInfo&,
blink::mojom::PresentationConnection*));
};
......@@ -61,7 +63,7 @@ class LocalPresentationManagerTest : public ::testing::Test {
void RegisterController(const std::string& presentation_id,
content::PresentationConnectionPtr controller) {
RegisterController(
content::PresentationInfo(GURL(kPresentationUrl), presentation_id),
PresentationInfo(GURL(kPresentationUrl), presentation_id),
render_frame_host_id_, std::move(controller));
}
......@@ -76,7 +78,7 @@ class LocalPresentationManagerTest : public ::testing::Test {
std::move(controller));
}
void RegisterController(const content::PresentationInfo& presentation_info,
void RegisterController(const PresentationInfo& presentation_info,
const RenderFrameHostId& render_frame_id,
content::PresentationConnectionPtr controller) {
content::PresentationConnectionRequest receiver_conn_request;
......@@ -94,7 +96,7 @@ class LocalPresentationManagerTest : public ::testing::Test {
const std::string& presentation_id,
MockReceiverConnectionAvailableCallback& receiver_callback) {
manager()->OnLocalPresentationReceiverCreated(
content::PresentationInfo(GURL(kPresentationUrl), presentation_id),
PresentationInfo(GURL(kPresentationUrl), presentation_id),
base::BindRepeating(&MockReceiverConnectionAvailableCallback::
OnReceiverConnectionAvailable,
base::Unretained(&receiver_callback)));
......@@ -116,7 +118,7 @@ class LocalPresentationManagerTest : public ::testing::Test {
private:
const RenderFrameHostId render_frame_host_id_;
const content::PresentationInfo presentation_info_;
const PresentationInfo presentation_info_;
LocalPresentationManager manager_;
MediaRoute route_;
};
......
......@@ -30,7 +30,6 @@
#include "content/public/browser/presentation_screen_availability_listener.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/presentation_info.h"
#include "url/gurl.h"
#if !defined(OS_ANDROID)
......@@ -45,6 +44,7 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(
using content::RenderFrameHost;
using blink::mojom::PresentationError;
using blink::mojom::PresentationErrorType;
using blink::mojom::PresentationInfo;
using blink::mojom::ScreenAvailability;
namespace media_router {
......@@ -96,7 +96,7 @@ class PresentationFrame {
bool HasScreenAvailabilityListenerForTest(
const MediaSource::Id& source_id) const;
void ListenForConnectionStateChange(
const content::PresentationInfo& connection,
const PresentationInfo& connection,
const content::PresentationConnectionStateChangedCallback&
state_changed_cb);
......@@ -104,10 +104,10 @@ class PresentationFrame {
MediaRoute::Id GetRouteId(const std::string& presentation_id) const;
void AddPresentation(const content::PresentationInfo& presentation_info,
void AddPresentation(const PresentationInfo& presentation_info,
const MediaRoute& route);
void ConnectToPresentation(
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
content::PresentationConnectionPtr controller_connection_ptr,
content::PresentationConnectionRequest receiver_connection_request);
void RemovePresentation(const std::string& presentation_id);
......@@ -216,21 +216,20 @@ void PresentationFrame::Reset() {
}
void PresentationFrame::AddPresentation(
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
const MediaRoute& route) {
presentation_id_to_route_.emplace(presentation_info.presentation_id, route);
presentation_id_to_route_.emplace(presentation_info.id, route);
}
void PresentationFrame::ConnectToPresentation(
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
content::PresentationConnectionPtr controller_connection_ptr,
content::PresentationConnectionRequest receiver_connection_request) {
const auto pid_route_it =
presentation_id_to_route_.find(presentation_info.presentation_id);
presentation_id_to_route_.find(presentation_info.id);
if (pid_route_it == presentation_id_to_route_.end()) {
DLOG(WARNING) << "No route for [presentation_id]: "
<< presentation_info.presentation_id;
DLOG(WARNING) << "No route for [presentation_id]: " << presentation_info.id;
return;
}
......@@ -245,7 +244,7 @@ void PresentationFrame::ConnectToPresentation(
} else {
DVLOG(2)
<< "Creating BrowserPresentationConnectionProxy for [presentation_id]: "
<< presentation_info.presentation_id;
<< presentation_info.id;
MediaRoute::Id route_id = pid_route_it->second.media_route_id();
if (base::ContainsKey(browser_connection_proxies_, route_id)) {
DLOG(ERROR) << __func__
......@@ -275,13 +274,13 @@ void PresentationFrame::RemovePresentation(const std::string& presentation_id) {
}
void PresentationFrame::ListenForConnectionStateChange(
const content::PresentationInfo& connection,
const PresentationInfo& connection,
const content::PresentationConnectionStateChangedCallback&
state_changed_cb) {
auto it = presentation_id_to_route_.find(connection.presentation_id);
auto it = presentation_id_to_route_.find(connection.id);
if (it == presentation_id_to_route_.end()) {
DLOG(ERROR) << __func__ << "route id not found for presentation: "
<< connection.presentation_id;
DLOG(ERROR) << __func__
<< "route id not found for presentation: " << connection.id;
return;
}
......@@ -410,8 +409,8 @@ void PresentationServiceDelegateImpl::OnJoinRouteResponse(
<< ", presentation URL: " << presentation_url
<< ", presentation ID: " << presentation_id;
DCHECK_EQ(presentation_id, result.presentation_id());
content::PresentationInfo presentation_info(presentation_url,
result.presentation_id());
PresentationInfo presentation_info(presentation_url,
result.presentation_id());
AddPresentation(render_frame_host_id, presentation_info, *result.route());
std::move(success_cb).Run(presentation_info);
}
......@@ -420,19 +419,19 @@ void PresentationServiceDelegateImpl::OnJoinRouteResponse(
void PresentationServiceDelegateImpl::OnStartPresentationSucceeded(
const RenderFrameHostId& render_frame_host_id,
content::PresentationConnectionCallback success_cb,
const content::PresentationInfo& new_presentation_info,
const PresentationInfo& new_presentation_info,
const MediaRoute& route) {
DVLOG(1) << "OnStartPresentationSucceeded: "
<< "route_id: " << route.media_route_id()
<< ", presentation URL: " << new_presentation_info.presentation_url
<< ", presentation ID: " << new_presentation_info.presentation_id;
<< ", presentation URL: " << new_presentation_info.url
<< ", presentation ID: " << new_presentation_info.id;
AddPresentation(render_frame_host_id, new_presentation_info, route);
std::move(success_cb).Run(new_presentation_info);
}
void PresentationServiceDelegateImpl::AddPresentation(
const RenderFrameHostId& render_frame_host_id,
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
const MediaRoute& route) {
auto* presentation_frame = GetOrAddPresentationFrame(render_frame_host_id);
presentation_frame->AddPresentation(presentation_info, route);
......@@ -587,7 +586,7 @@ void PresentationServiceDelegateImpl::Terminate(
void PresentationServiceDelegateImpl::ListenForConnectionStateChange(
int render_process_id,
int render_frame_id,
const content::PresentationInfo& connection,
const PresentationInfo& connection,
const content::PresentationConnectionStateChangedCallback&
state_changed_cb) {
RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
......@@ -599,7 +598,7 @@ void PresentationServiceDelegateImpl::ListenForConnectionStateChange(
void PresentationServiceDelegateImpl::ConnectToPresentation(
int render_process_id,
int render_frame_id,
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
content::PresentationConnectionPtr controller_connection_ptr,
content::PresentationConnectionRequest receiver_connection_request) {
RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
......@@ -618,8 +617,8 @@ void PresentationServiceDelegateImpl::OnRouteResponse(
return;
}
content::PresentationInfo presentation_info(result.presentation_url(),
result.presentation_id());
PresentationInfo presentation_info(result.presentation_url(),
result.presentation_id());
AddPresentation(presentation_request.render_frame_host_id, presentation_info,
*result.route());
if (default_presentation_request_ &&
......
......@@ -30,7 +30,6 @@
namespace content {
class PresentationScreenAvailabilityListener;
class WebContents;
struct PresentationInfo;
} // namespace content
namespace url {
......@@ -118,13 +117,13 @@ class PresentationServiceDelegateImpl
void ListenForConnectionStateChange(
int render_process_id,
int render_frame_id,
const content::PresentationInfo& connection,
const blink::mojom::PresentationInfo& connection,
const content::PresentationConnectionStateChangedCallback&
state_changed_cb) override;
void ConnectToPresentation(
int render_process_id,
int render_frame_id,
const content::PresentationInfo& presentation_info,
const blink::mojom::PresentationInfo& presentation_info,
content::PresentationConnectionPtr controller_connection_ptr,
content::PresentationConnectionRequest receiver_connection_request)
override;
......@@ -194,7 +193,7 @@ class PresentationServiceDelegateImpl
void OnStartPresentationSucceeded(
const RenderFrameHostId& render_frame_host_id,
content::PresentationConnectionCallback success_cb,
const content::PresentationInfo& new_presentation_info,
const blink::mojom::PresentationInfo& new_presentation_info,
const MediaRoute& route);
// Notifies the PresentationFrame of |render_frame_host_id| that a
......@@ -202,7 +201,7 @@ class PresentationServiceDelegateImpl
// The PresentationFrame will be created if it does not already exist.
// This must be called before |ConnectToPresentation()|.
void AddPresentation(const RenderFrameHostId& render_frame_host_id,
const content::PresentationInfo& presentation_info,
const blink::mojom::PresentationInfo& presentation_info,
const MediaRoute& route);
// Notifies the PresentationFrame of |render_frame_host_id| that a
......
......@@ -24,7 +24,6 @@
#include "content/public/browser/presentation_screen_availability_listener.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/presentation_info.h"
#include "content/public/test/web_contents_tester.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -36,6 +35,7 @@ using ::testing::Mock;
using ::testing::Return;
using ::testing::StrictMock;
using ::testing::WithArgs;
using blink::mojom::PresentationInfo;
namespace {
......@@ -45,10 +45,9 @@ constexpr char kPresentationUrl3[] = "cast:233637DE";
constexpr char kFrameUrl[] = "http://anotherframeurl.fakeurl.com/";
constexpr char kPresentationId[] = "presentation_id";
// Matches content::PresentationInfo.
// Matches blink::mojom::PresentationInfo.
MATCHER_P(InfoEquals, expected, "") {
return expected.presentation_url == arg.presentation_url &&
expected.presentation_id == arg.presentation_id;
return expected.url == arg.url && expected.id == arg.id;
}
} // namespace
......@@ -59,8 +58,7 @@ class MockDelegateObserver
: public content::PresentationServiceDelegate::Observer {
public:
MOCK_METHOD0(OnDelegateDestroyed, void());
MOCK_METHOD1(OnDefaultPresentationStarted,
void(const content::PresentationInfo&));
MOCK_METHOD1(OnDefaultPresentationStarted, void(const PresentationInfo&));
};
class MockDefaultPresentationRequestObserver
......@@ -75,7 +73,7 @@ class MockDefaultPresentationRequestObserver
class MockCreatePresentationConnnectionCallbacks {
public:
MOCK_METHOD1(OnCreateConnectionSuccess,
void(const content::PresentationInfo& connection));
void(const PresentationInfo& connection));
MOCK_METHOD1(OnCreateConnectionError,
void(const blink::mojom::PresentationError& error));
};
......@@ -83,7 +81,7 @@ class MockCreatePresentationConnnectionCallbacks {
class MockLocalPresentationManager : public LocalPresentationManager {
public:
void RegisterLocalPresentationController(
const content::PresentationInfo& presentation_info,
const PresentationInfo& presentation_info,
const RenderFrameHostId& render_frame_id,
content::PresentationConnectionPtr controller,
content::PresentationConnectionRequest,
......@@ -93,14 +91,14 @@ class MockLocalPresentationManager : public LocalPresentationManager {
}
MOCK_METHOD3(RegisterLocalPresentationController,
void(const content::PresentationInfo& presentation_info,
void(const PresentationInfo& presentation_info,
const RenderFrameHostId& render_frame_id,
const MediaRoute& route));
MOCK_METHOD2(UnregisterLocalPresentationController,
void(const std::string& presentation_id,
const RenderFrameHostId& render_frame_id));
MOCK_METHOD2(OnLocalPresentationReceiverCreated,
void(const content::PresentationInfo& presentation_info,
void(const PresentationInfo& presentation_info,
const content::ReceiverConnectionAvailableCallback&
receiver_callback));
MOCK_METHOD1(OnLocalPresentationReceiverTerminated,
......@@ -147,7 +145,7 @@ class PresentationServiceDelegateImplTest
}
MOCK_METHOD1(OnDefaultPresentationStarted,
void(const content::PresentationInfo& presentation_info));
void(const PresentationInfo& presentation_info));
protected:
virtual content::WebContents* GetWebContents() { return web_contents(); }
......@@ -461,7 +459,7 @@ TEST_F(PresentationServiceDelegateImplTest, ListenForConnnectionStateChange) {
base::MockCallback<content::PresentationConnectionStateChangedCallback>
mock_callback;
auto callback = mock_callback.Get();
content::PresentationInfo connection(presentation_url1_, kPresentationId);
PresentationInfo connection(presentation_url1_, kPresentationId);
EXPECT_CALL(*router_, OnAddPresentationConnectionStateChangedCallbackInvoked(
Equals(callback)));
delegate_impl_->ListenForConnectionStateChange(
......@@ -510,8 +508,7 @@ TEST_F(PresentationServiceDelegateImplTest, SinksObserverCantRegister) {
TEST_F(PresentationServiceDelegateImplTest,
TestCloseConnectionForLocalPresentation) {
GURL presentation_url = GURL("http://www.example.com/presentation.html");
content::PresentationInfo presentation_info(presentation_url,
kPresentationId);
PresentationInfo presentation_info(presentation_url, kPresentationId);
RenderFrameHostId rfh_id(main_frame_process_id_, main_frame_routing_id_);
MediaRoute media_route("route_id",
MediaSourceForPresentationUrl(presentation_url),
......@@ -565,13 +562,11 @@ TEST_F(PresentationServiceDelegateImplTest,
TEST_F(PresentationServiceDelegateImplTest, ConnectToLocalPresentation) {
RenderFrameHostId rfh_id(main_frame_process_id_, main_frame_routing_id_);
content::PresentationInfo presentation_info(presentation_url1_,
kPresentationId);
PresentationInfo presentation_info(presentation_url1_, kPresentationId);
MediaRoute media_route(
"route_id",
MediaSourceForPresentationUrl(presentation_info.presentation_url),
"mediaSinkId", "", true, true);
MediaRoute media_route("route_id",
MediaSourceForPresentationUrl(presentation_info.url),
"mediaSinkId", "", true, true);
media_route.set_local_presentation(true);
base::MockCallback<content::PresentationConnectionCallback> success_cb;
......@@ -599,13 +594,11 @@ TEST_F(PresentationServiceDelegateImplTest, ConnectToLocalPresentation) {
TEST_F(PresentationServiceDelegateImplTest, ConnectToPresentation) {
RenderFrameHostId rfh_id(main_frame_process_id_, main_frame_routing_id_);
content::PresentationInfo presentation_info(presentation_url1_,
kPresentationId);
PresentationInfo presentation_info(presentation_url1_, kPresentationId);
MediaRoute media_route(
"route_id",
MediaSourceForPresentationUrl(presentation_info.presentation_url),
"mediaSinkId", "", true, true);
MediaRoute media_route("route_id",
MediaSourceForPresentationUrl(presentation_info.url),
"mediaSinkId", "", true, true);
base::MockCallback<content::PresentationConnectionCallback> success_cb;
EXPECT_CALL(success_cb, Run(_));
......
......@@ -77,8 +77,8 @@ void ReceiverPresentationServiceDelegateImpl::
const content::ReceiverConnectionAvailableCallback&
receiver_available_callback) {
local_presentation_manager_->OnLocalPresentationReceiverCreated(
content::PresentationInfo(web_contents_->GetLastCommittedURL(),
presentation_id_),
blink::mojom::PresentationInfo(web_contents_->GetLastCommittedURL(),
presentation_id_),
receiver_available_callback);
}
......
......@@ -25,7 +25,6 @@
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/presentation_connection_message.h"
#include "content/public/common/presentation_info.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/script_executor.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -295,7 +294,7 @@ IN_PROC_BROWSER_TEST_F(PresentationReceiverWindowControllerBrowserTest,
media_router::LocalPresentationManagerFactory::GetOrCreateForBrowserContext(
browser()->profile())
->RegisterLocalPresentationController(
content::PresentationInfo(presentation_url, kPresentationId),
blink::mojom::PresentationInfo(presentation_url, kPresentationId),
RenderFrameHostId(0, 0), std::move(controller_ptr),
controller_connection.MakeConnectionRequest(),
media_router::MediaRoute("route",
......
......@@ -17,6 +17,7 @@
#include "content/public/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
using blink::mojom::PresentationInfo;
using content::WebContents;
namespace media_router {
......@@ -29,7 +30,7 @@ class MediaRouterDialogControllerWebUIImplTest : public MediaRouterWebUITest {
void OpenMediaRouterDialog();
MOCK_METHOD2(PresentationSuccessCallback,
void(const content::PresentationInfo&, const MediaRoute&));
void(const blink::mojom::PresentationInfo&, const MediaRoute&));
MOCK_METHOD1(PresentationErrorCallback,
void(const blink::mojom::PresentationError& error));
......
......@@ -107,7 +107,7 @@ class PresentationRequestCallbacks {
const blink::mojom::PresentationError& expected_error)
: expected_error_(expected_error) {}
void Success(const content::PresentationInfo&, const MediaRoute&) {}
void Success(const blink::mojom::PresentationInfo&, const MediaRoute&) {}
void Error(const blink::mojom::PresentationError& error) {
EXPECT_EQ(expected_error_.error_type, error.error_type);
......
......@@ -12,7 +12,6 @@ public_headers = [
"//chrome/common/media_router/media_source.h",
"//chrome/common/media_router/route_request_result.h",
"//content/public/common/presentation_connection_message.h",
"//content/public/common/presentation_info.h",
]
public_deps = [
"//chrome/common/media_router:router",
......
......@@ -27,13 +27,16 @@ using blink::mojom::PresentationConnectionState;
using blink::mojom::PresentationError;
using blink::mojom::PresentationErrorPtr;
using blink::mojom::PresentationErrorType;
using blink::mojom::PresentationInfo;
using blink::mojom::PresentationInfoPtr;
using blink::mojom::ScreenAvailability;
namespace content {
namespace {
const int kInvalidRequestId = -1;
static constexpr int kInvalidRequestId = -1;
static constexpr size_t kMaxPresentationIdLength = 256;
int GetNextRequestId() {
static int next_request_id = 0;
......@@ -43,7 +46,7 @@ int GetNextRequestId() {
void InvokeNewPresentationCallbackWithError(
PresentationServiceImpl::NewPresentationCallback callback) {
std::move(callback).Run(
base::nullopt,
PresentationInfoPtr(),
PresentationError::New(
PresentationErrorType::PREVIOUS_START_IN_PROGRESS,
"There is already an unsettled Promise from a previous call "
......@@ -208,7 +211,7 @@ void PresentationServiceImpl::StartPresentation(
DVLOG(2) << "StartPresentation";
if (!controller_delegate_) {
std::move(callback).Run(
base::nullopt,
PresentationInfoPtr(),
PresentationError::New(PresentationErrorType::NO_AVAILABLE_SCREENS,
"No screens found."));
return;
......@@ -244,7 +247,7 @@ void PresentationServiceImpl::ReconnectPresentation(
DVLOG(2) << "ReconnectPresentation";
if (!controller_delegate_) {
std::move(callback).Run(
base::nullopt,
PresentationInfoPtr(),
PresentationError::New(PresentationErrorType::NO_PRESENTATION_FOUND,
"Error joining route: No matching route"));
return;
......@@ -298,7 +301,8 @@ void PresentationServiceImpl::OnStartPresentationSucceeded(
return;
CHECK(pending_start_presentation_cb_.get());
pending_start_presentation_cb_->Run(presentation_info,
DCHECK(presentation_info.id.length() <= kMaxPresentationIdLength);
pending_start_presentation_cb_->Run(PresentationInfo::New(presentation_info),
PresentationErrorPtr());
ListenForConnectionStateChange(presentation_info);
pending_start_presentation_cb_.reset();
......@@ -312,7 +316,7 @@ void PresentationServiceImpl::OnStartPresentationError(
return;
CHECK(pending_start_presentation_cb_.get());
pending_start_presentation_cb_->Run(base::nullopt,
pending_start_presentation_cb_->Run(PresentationInfoPtr(),
PresentationError::New(error));
pending_start_presentation_cb_.reset();
start_presentation_request_id_ = kInvalidRequestId;
......@@ -321,8 +325,10 @@ void PresentationServiceImpl::OnStartPresentationError(
void PresentationServiceImpl::OnReconnectPresentationSucceeded(
int request_id,
const PresentationInfo& presentation_info) {
DCHECK(presentation_info.id.length() <= kMaxPresentationIdLength);
if (RunAndEraseReconnectPresentationMojoCallback(
request_id, presentation_info, PresentationErrorPtr())) {
request_id, PresentationInfo::New(presentation_info),
PresentationErrorPtr())) {
ListenForConnectionStateChange(presentation_info);
}
}
......@@ -330,20 +336,20 @@ void PresentationServiceImpl::OnReconnectPresentationSucceeded(
void PresentationServiceImpl::OnReconnectPresentationError(
int request_id,
const blink::mojom::PresentationError& error) {
RunAndEraseReconnectPresentationMojoCallback(request_id, base::nullopt,
PresentationError::New(error));
RunAndEraseReconnectPresentationMojoCallback(
request_id, PresentationInfoPtr(), PresentationError::New(error));
}
bool PresentationServiceImpl::RunAndEraseReconnectPresentationMojoCallback(
int request_id,
const base::Optional<PresentationInfo>& presentation_info,
blink::mojom::PresentationErrorPtr error) {
PresentationInfoPtr presentation_info,
PresentationErrorPtr error) {
auto it = pending_reconnect_presentation_cbs_.find(request_id);
if (it == pending_reconnect_presentation_cbs_.end())
return false;
DCHECK(it->second.get());
it->second->Run(presentation_info, std::move(error));
it->second->Run(std::move(presentation_info), std::move(error));
pending_reconnect_presentation_cbs_.erase(it);
return true;
}
......@@ -388,16 +394,17 @@ void PresentationServiceImpl::OnConnectionStateChanged(
const PresentationInfo& connection,
const PresentationConnectionStateChangeInfo& info) {
DVLOG(2) << "PresentationServiceImpl::OnConnectionStateChanged "
<< "[presentation_id]: " << connection.presentation_id
<< "[presentation_id]: " << connection.id
<< " [state]: " << info.state;
if (!controller_)
return;
if (info.state == PresentationConnectionState::CLOSED) {
controller_->OnConnectionClosed(connection, info.close_reason,
info.message);
controller_->OnConnectionClosed(PresentationInfo::New(connection),
info.close_reason, info.message);
} else {
controller_->OnConnectionStateChanged(connection, info.state);
controller_->OnConnectionStateChanged(PresentationInfo::New(connection),
info.state);
}
}
......@@ -422,7 +429,7 @@ PresentationServiceImpl::GetPresentationServiceDelegate() {
}
void PresentationServiceImpl::SetPresentationConnection(
const PresentationInfo& presentation_info,
PresentationInfoPtr presentation_info,
blink::mojom::PresentationConnectionPtr controller_connection_ptr,
blink::mojom::PresentationConnectionRequest receiver_connection_request) {
DVLOG(2) << "SetPresentationConnection";
......@@ -431,19 +438,19 @@ void PresentationServiceImpl::SetPresentationConnection(
return;
controller_delegate_->ConnectToPresentation(
render_process_id_, render_frame_id_, presentation_info,
render_process_id_, render_frame_id_, *presentation_info,
std::move(controller_connection_ptr),
std::move(receiver_connection_request));
}
void PresentationServiceImpl::OnReceiverConnectionAvailable(
const content::PresentationInfo& presentation_info,
PresentationInfoPtr presentation_info,
PresentationConnectionPtr controller_connection_ptr,
PresentationConnectionRequest receiver_connection_request) {
DVLOG(2) << "PresentationServiceImpl::OnReceiverConnectionAvailable";
receiver_->OnReceiverConnectionAvailable(
presentation_info, std::move(controller_connection_ptr),
std::move(presentation_info), std::move(controller_connection_ptr),
std::move(receiver_connection_request));
}
......@@ -498,7 +505,8 @@ void PresentationServiceImpl::OnDelegateDestroyed() {
void PresentationServiceImpl::OnDefaultPresentationStarted(
const PresentationInfo& connection) {
if (controller_)
controller_->OnDefaultPresentationStarted(connection);
controller_->OnDefaultPresentationStarted(
PresentationInfo::New(connection));
ListenForConnectionStateChange(connection);
}
......@@ -535,7 +543,7 @@ PresentationServiceImpl::NewPresentationCallbackWrapper::
~NewPresentationCallbackWrapper() {
if (!callback_.is_null()) {
std::move(callback_).Run(
base::nullopt,
PresentationInfoPtr(),
PresentationError::New(
PresentationErrorType::PRESENTATION_REQUEST_CANCELLED,
"The frame is navigating or being destroyed."));
......@@ -543,10 +551,10 @@ PresentationServiceImpl::NewPresentationCallbackWrapper::
}
void PresentationServiceImpl::NewPresentationCallbackWrapper::Run(
const base::Optional<PresentationInfo>& presentation_info,
blink::mojom::PresentationErrorPtr error) {
PresentationInfoPtr presentation_info,
PresentationErrorPtr error) {
DCHECK(!callback_.is_null());
std::move(callback_).Run(presentation_info, std::move(error));
std::move(callback_).Run(std::move(presentation_info), std::move(error));
}
} // namespace content
......@@ -17,7 +17,6 @@
#include "base/macros.h"
#include "base/memory/linked_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "content/common/content_export.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/presentation_screen_availability_listener.h"
......@@ -56,7 +55,7 @@ class CONTENT_EXPORT PresentationServiceImpl
public PresentationServiceDelegate::Observer {
public:
using NewPresentationCallback =
base::OnceCallback<void(const base::Optional<PresentationInfo>&,
base::OnceCallback<void(blink::mojom::PresentationInfoPtr,
blink::mojom::PresentationErrorPtr)>;
// Creates a PresentationServiceImpl using the given RenderFrameHost.
......@@ -87,7 +86,7 @@ class CONTENT_EXPORT PresentationServiceImpl
void Terminate(const GURL& presentation_url,
const std::string& presentation_id) override;
void SetPresentationConnection(
const PresentationInfo& presentation_info,
blink::mojom::PresentationInfoPtr presentation_info,
blink::mojom::PresentationConnectionPtr controller_connection_ptr,
blink::mojom::PresentationConnectionRequest receiver_connection_request)
override;
......@@ -145,7 +144,7 @@ class CONTENT_EXPORT PresentationServiceImpl
explicit NewPresentationCallbackWrapper(NewPresentationCallback callback);
~NewPresentationCallbackWrapper();
void Run(const base::Optional<PresentationInfo>& presentation_info,
void Run(blink::mojom::PresentationInfoPtr presentation_info,
blink::mojom::PresentationErrorPtr error);
private:
......@@ -178,7 +177,8 @@ class CONTENT_EXPORT PresentationServiceImpl
// Passed to embedder's implementation of PresentationServiceDelegate for
// later invocation when default presentation has started.
void OnDefaultPresentationStarted(const PresentationInfo& presentation_info);
void OnDefaultPresentationStarted(
const blink::mojom::PresentationInfo& presentation_info);
// Finds the callback from |pending_reconnect_presentation_cbs_| using
// |request_id|.
......@@ -187,7 +187,7 @@ class CONTENT_EXPORT PresentationServiceImpl
// was found.
bool RunAndEraseReconnectPresentationMojoCallback(
int request_id,
const base::Optional<PresentationInfo>& presentation_info,
blink::mojom::PresentationInfoPtr presentation_info,
blink::mojom::PresentationErrorPtr error);
// Removes all listeners and resets default presentation URL on this instance
......@@ -197,32 +197,34 @@ class CONTENT_EXPORT PresentationServiceImpl
// These functions are bound as base::Callbacks and passed to
// embedder's implementation of PresentationServiceDelegate for later
// invocation.
void OnStartPresentationSucceeded(int request_id,
const PresentationInfo& presentation_info);
void OnStartPresentationSucceeded(
int request_id,
const blink::mojom::PresentationInfo& presentation_info);
void OnStartPresentationError(int request_id,
const blink::mojom::PresentationError& error);
void OnReconnectPresentationSucceeded(
int request_id,
const PresentationInfo& presentation_info);
const blink::mojom::PresentationInfo& presentation_info);
void OnReconnectPresentationError(
int request_id,
const blink::mojom::PresentationError& error);
// Calls to |delegate_| to start listening for state changes for |connection|.
// State changes will be returned via |OnConnectionStateChanged|.
void ListenForConnectionStateChange(const PresentationInfo& connection);
void ListenForConnectionStateChange(
const blink::mojom::PresentationInfo& connection);
// Passed to embedder's implementation of PresentationServiceDelegate for
// later invocation when connection messages arrive.
void OnConnectionMessages(
const content::PresentationInfo& presentation_info,
const blink::mojom::PresentationInfo& presentation_info,
std::vector<content::PresentationConnectionMessage> messages);
// A callback registered to LocalPresentationManager when
// the PresentationServiceImpl for the presentation receiver is initialized.
// Calls |receiver_| to create a new PresentationConnection on receiver page.
void OnReceiverConnectionAvailable(
const content::PresentationInfo& presentation_info,
blink::mojom::PresentationInfoPtr presentation_info,
PresentationConnectionPtr controller_connection_ptr,
PresentationConnectionRequest receiver_connection_request);
......@@ -235,7 +237,7 @@ class CONTENT_EXPORT PresentationServiceImpl
// Invoked by the embedder's PresentationServiceDelegate when a
// PresentationConnection's state has changed.
void OnConnectionStateChanged(
const PresentationInfo& connection,
const blink::mojom::PresentationInfo& connection,
const PresentationConnectionStateChangeInfo& info);
// Returns true if this object is associated with |render_frame_host|.
......
......@@ -18,7 +18,6 @@
#include "content/public/browser/presentation_request.h"
#include "content/public/browser/presentation_service_delegate.h"
#include "content/public/common/presentation_connection_message.h"
#include "content/public/common/presentation_info.h"
#include "content/test/test_render_frame_host.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
......@@ -29,6 +28,8 @@ using blink::mojom::PresentationConnectionCloseReason;
using blink::mojom::PresentationConnectionState;
using blink::mojom::PresentationError;
using blink::mojom::PresentationErrorType;
using blink::mojom::PresentationInfo;
using blink::mojom::PresentationInfoPtr;
using blink::mojom::ScreenAvailability;
using ::testing::_;
using ::testing::Eq;
......@@ -46,10 +47,9 @@ MATCHER_P(PresentationUrlsAre, expected_urls, "") {
return arg.presentation_urls == expected_urls;
}
// Matches content::PresentationInfo.
// Matches blink::mojom::PresentationInfo.
MATCHER_P(InfoEquals, expected, "") {
return expected.presentation_url == arg.presentation_url &&
expected.presentation_id == arg.presentation_id;
return expected.url == arg.url && expected.id == arg.id;
}
ACTION_TEMPLATE(SaveArgByMove,
......@@ -190,15 +190,15 @@ class MockPresentationServiceDelegate
class MockPresentationReceiver : public blink::mojom::PresentationReceiver {
public:
void OnReceiverConnectionAvailable(
const content::PresentationInfo& info,
PresentationInfoPtr info,
blink::mojom::PresentationConnectionPtr controller_connection,
blink::mojom::PresentationConnectionRequest receiver_connection_request)
override {
OnReceiverConnectionAvailable(info);
OnReceiverConnectionAvailable(*info);
}
MOCK_METHOD1(OnReceiverConnectionAvailable,
void(const content::PresentationInfo& info));
void(const PresentationInfo& info));
};
class MockReceiverPresentationServiceDelegate
......@@ -233,24 +233,37 @@ class MockPresentationController : public blink::mojom::PresentationController {
public:
MOCK_METHOD2(OnScreenAvailabilityUpdated,
void(const GURL& url, ScreenAvailability availability));
MOCK_METHOD2(OnConnectionStateChanged,
void OnConnectionStateChanged(PresentationInfoPtr connection,
PresentationConnectionState new_state) {
OnConnectionStateChangedInternal(*connection, new_state);
}
MOCK_METHOD2(OnConnectionStateChangedInternal,
void(const PresentationInfo& connection,
PresentationConnectionState new_state));
MOCK_METHOD3(OnConnectionClosed,
void OnConnectionClosed(
PresentationInfoPtr connection,
blink::mojom::PresentationConnectionCloseReason reason,
const std::string& message) {
OnConnectionClosedInternal(*connection, reason, message);
}
MOCK_METHOD3(OnConnectionClosedInternal,
void(const PresentationInfo& connection,
blink::mojom::PresentationConnectionCloseReason reason,
const std::string& message));
// PresentationConnectionMessage is move-only.
void OnConnectionMessagesReceived(
const PresentationInfo& presentation_info,
PresentationInfoPtr presentation_info,
std::vector<PresentationConnectionMessage> messages) {
OnConnectionMessagesReceivedInternal(presentation_info, messages);
OnConnectionMessagesReceivedInternal(*presentation_info, messages);
}
MOCK_METHOD2(
OnConnectionMessagesReceivedInternal,
void(const PresentationInfo& presentation_info,
const std::vector<PresentationConnectionMessage>& messages));
MOCK_METHOD1(OnDefaultPresentationStarted,
void OnDefaultPresentationStarted(PresentationInfoPtr presentation_info) {
OnDefaultPresentationStartedInternal(*presentation_info);
}
MOCK_METHOD1(OnDefaultPresentationStartedInternal,
void(const PresentationInfo& presentation_info));
};
......@@ -342,16 +355,16 @@ class PresentationServiceImplTest : public RenderViewHostImplTestHarness {
service_impl_->screen_availability_listeners_.end());
}
void ExpectPresentationSuccess(const base::Optional<PresentationInfo>& info,
void ExpectPresentationSuccess(PresentationInfoPtr info,
blink::mojom::PresentationErrorPtr error) {
EXPECT_TRUE(info.has_value());
EXPECT_FALSE(info.is_null());
EXPECT_TRUE(error.is_null());
presentation_cb_was_run_ = true;
}
void ExpectPresentationError(const base::Optional<PresentationInfo>& info,
void ExpectPresentationError(PresentationInfoPtr info,
blink::mojom::PresentationErrorPtr error) {
EXPECT_FALSE(info.has_value());
EXPECT_TRUE(info.is_null());
EXPECT_FALSE(error.is_null());
presentation_cb_was_run_ = true;
}
......@@ -456,8 +469,8 @@ TEST_F(PresentationServiceImplTest, SetDefaultPresentationUrls) {
PresentationInfo presentation_info(presentation_url2_, kPresentationId);
EXPECT_CALL(mock_controller_,
OnDefaultPresentationStarted(InfoEquals(presentation_info)));
EXPECT_CALL(mock_controller_, OnDefaultPresentationStartedInternal(
InfoEquals(presentation_info)));
EXPECT_CALL(mock_delegate_, ListenForConnectionStateChange(_, _, _, _));
std::move(callback).Run(
PresentationInfo(presentation_url2_, kPresentationId));
......@@ -490,7 +503,7 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionStateChange) {
.WillOnce(SaveArg<3>(&state_changed_cb));
service_impl_->ListenForConnectionStateChange(connection);
EXPECT_CALL(mock_controller_, OnConnectionStateChanged(
EXPECT_CALL(mock_controller_, OnConnectionStateChangedInternal(
InfoEquals(presentation_connection),
PresentationConnectionState::TERMINATED));
state_changed_cb.Run(PresentationConnectionStateChangeInfo(
......@@ -513,10 +526,10 @@ TEST_F(PresentationServiceImplTest, ListenForConnectionClose) {
closed_info.close_reason = PresentationConnectionCloseReason::WENT_AWAY;
closed_info.message = "Foo";
EXPECT_CALL(
mock_controller_,
OnConnectionClosed(InfoEquals(presentation_connection),
PresentationConnectionCloseReason::WENT_AWAY, "Foo"));
EXPECT_CALL(mock_controller_,
OnConnectionClosedInternal(
InfoEquals(presentation_connection),
PresentationConnectionCloseReason::WENT_AWAY, "Foo"));
state_changed_cb.Run(closed_info);
base::RunLoop().RunUntilIdle();
}
......@@ -634,7 +647,8 @@ TEST_F(PresentationServiceImplTest, Terminate) {
}
TEST_F(PresentationServiceImplTest, SetPresentationConnection) {
PresentationInfo presentation_info(presentation_url1_, kPresentationId);
PresentationInfoPtr presentation_info =
PresentationInfo::New(presentation_url1_, kPresentationId);
blink::mojom::PresentationConnectionPtr connection;
MockPresentationConnection mock_presentation_connection;
......@@ -648,7 +662,7 @@ TEST_F(PresentationServiceImplTest, SetPresentationConnection) {
_, _, InfoEquals(expected), _));
service_impl_->SetPresentationConnection(
presentation_info, std::move(connection), std::move(request));
std::move(presentation_info), std::move(connection), std::move(request));
}
TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
......@@ -670,7 +684,7 @@ TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
service_impl.SetReceiver(std::move(receiver_ptr));
EXPECT_FALSE(callback.is_null());
PresentationInfo presentation_info(presentation_url1_, kPresentationId);
PresentationInfo expected(presentation_url1_, kPresentationId);
// Client gets notified of receiver connections.
blink::mojom::PresentationConnectionPtr controller_connection;
......@@ -680,9 +694,10 @@ TEST_F(PresentationServiceImplTest, ReceiverPresentationServiceDelegate) {
blink::mojom::PresentationConnectionPtr receiver_connection;
EXPECT_CALL(mock_receiver,
OnReceiverConnectionAvailable(InfoEquals(presentation_info)))
OnReceiverConnectionAvailable(InfoEquals(expected)))
.Times(1);
callback.Run(presentation_info, std::move(controller_connection),
callback.Run(PresentationInfo::New(expected),
std::move(controller_connection),
mojo::MakeRequest(&receiver_connection));
base::RunLoop().RunUntilIdle();
......
......@@ -3,16 +3,10 @@
# found in the LICENSE file.
mojom = "//third_party/blink/public/platform/modules/presentation/presentation.mojom"
public_headers = [
"//content/public/common/presentation_connection_message.h",
"//content/public/common/presentation_info.h",
]
public_headers = [ "//content/public/common/presentation_connection_message.h" ]
traits_headers =
[ "//content/common/presentation/presentation_struct_traits.h" ]
deps = [
"//url",
]
type_mappings = [
"blink.mojom.PresentationConnectionMessage=content::PresentationConnectionMessage[move_only]",
"blink.mojom.PresentationInfo=content::PresentationInfo",
]
type_mappings = [ "blink.mojom.PresentationConnectionMessage=content::PresentationConnectionMessage[move_only]" ]
......@@ -8,23 +8,6 @@
namespace mojo {
bool StructTraits<blink::mojom::PresentationInfoDataView,
content::PresentationInfo>::
Read(blink::mojom::PresentationInfoDataView data,
content::PresentationInfo* out) {
if (!data.ReadUrl(&(out->presentation_url)) ||
!data.ReadId(&(out->presentation_id))) {
return false;
}
if (out->presentation_id.empty() ||
!base::IsStringASCII(out->presentation_id) ||
out->presentation_id.length() > content::PresentationInfo::kMaxIdLength) {
return false;
}
return true;
}
bool UnionTraits<blink::mojom::PresentationConnectionMessageDataView,
content::PresentationConnectionMessage>::
Read(blink::mojom::PresentationConnectionMessageDataView data,
......
......@@ -12,28 +12,11 @@
#include "base/optional.h"
#include "base/strings/string_util.h"
#include "content/public/common/presentation_connection_message.h"
#include "content/public/common/presentation_info.h"
#include "third_party/blink/public/platform/modules/presentation/presentation.mojom.h"
#include "url/mojom/url.mojom.h"
namespace mojo {
template <>
struct StructTraits<blink::mojom::PresentationInfoDataView,
content::PresentationInfo> {
static const GURL& url(const content::PresentationInfo& presentation_info) {
return presentation_info.presentation_url;
}
static const std::string& id(
const content::PresentationInfo& presentation_info) {
return presentation_info.presentation_id;
}
static bool Read(blink::mojom::PresentationInfoDataView data,
content::PresentationInfo* out);
};
template <>
struct UnionTraits<blink::mojom::PresentationConnectionMessageDataView,
content::PresentationConnectionMessage> {
......
......@@ -14,7 +14,6 @@
#include "content/common/content_export.h"
#include "content/public/browser/media_controller.h"
#include "content/public/common/presentation_connection_message.h"
#include "content/public/common/presentation_info.h"
#include "third_party/blink/public/platform/modules/presentation/presentation.mojom.h"
namespace content {
......@@ -23,11 +22,11 @@ struct PresentationRequest;
class PresentationScreenAvailabilityListener;
using PresentationConnectionCallback =
base::OnceCallback<void(const PresentationInfo&)>;
base::OnceCallback<void(const blink::mojom::PresentationInfo&)>;
using PresentationConnectionErrorCallback =
base::OnceCallback<void(const blink::mojom::PresentationError&)>;
using DefaultPresentationConnectionCallback =
base::RepeatingCallback<void(const PresentationInfo&)>;
base::RepeatingCallback<void(const blink::mojom::PresentationInfo&)>;
struct PresentationConnectionStateChangeInfo {
explicit PresentationConnectionStateChangeInfo(
......@@ -53,7 +52,7 @@ using PresentationConnectionRequest =
blink::mojom::PresentationConnectionRequest;
using ReceiverConnectionAvailableCallback =
base::RepeatingCallback<void(const content::PresentationInfo&,
base::RepeatingCallback<void(blink::mojom::PresentationInfoPtr,
PresentationConnectionPtr,
PresentationConnectionRequest)>;
......@@ -123,7 +122,7 @@ class CONTENT_EXPORT ControllerPresentationServiceDelegate
// Sets the default presentation URLs represented by |request|. When the
// default presentation is started on this frame, |callback| will be invoked
// with the corresponding PresentationInfo object.
// with the corresponding blink::mojom::PresentationInfo object.
// If |request.presentation_urls| is empty, the default presentation URLs will
// be cleared and the previously registered callback (if any) will be removed.
virtual void SetDefaultPresentationUrls(
......@@ -189,7 +188,7 @@ class CONTENT_EXPORT ControllerPresentationServiceDelegate
virtual void ListenForConnectionStateChange(
int render_process_id,
int render_frame_id,
const PresentationInfo& connection,
const blink::mojom::PresentationInfo& connection,
const PresentationConnectionStateChangedCallback& state_changed_cb) = 0;
// Connect |controller_connection| owned by the controlling frame to the
......@@ -202,7 +201,7 @@ class CONTENT_EXPORT ControllerPresentationServiceDelegate
virtual void ConnectToPresentation(
int render_process_id,
int render_frame_id,
const PresentationInfo& presentation_info,
const blink::mojom::PresentationInfo& presentation_info,
PresentationConnectionPtr controller_connection_ptr,
PresentationConnectionRequest receiver_connection_request) = 0;
};
......
......@@ -188,8 +188,6 @@ jumbo_source_set("common_sources") {
"platform_notification_data.h",
"presentation_connection_message.cc",
"presentation_connection_message.h",
"presentation_info.cc",
"presentation_info.h",
"previews_state.h",
"process_type.h",
"push_event_payload.h",
......
// Copyright 2015 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 "content/public/common/presentation_info.h"
namespace content {
PresentationInfo::PresentationInfo(const GURL& presentation_url,
const std::string& presentation_id)
: presentation_url(presentation_url), presentation_id(presentation_id) {}
PresentationInfo::~PresentationInfo() {}
} // namespace content
// Copyright 2015 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 CONTENT_PUBLIC_COMMON_PRESENTATION_INFO_H_
#define CONTENT_PUBLIC_COMMON_PRESENTATION_INFO_H_
#include <string>
#include "content/common/content_export.h"
#include "url/gurl.h"
namespace content {
// Represents a presentation that has been established via either
// browser actions or Presentation API.
struct CONTENT_EXPORT PresentationInfo {
PresentationInfo() = default;
PresentationInfo(const GURL& presentation_url,
const std::string& presentation_id);
~PresentationInfo();
static constexpr size_t kMaxIdLength = 256;
GURL presentation_url;
std::string presentation_id;
};
} // namespace content
#endif // CONTENT_PUBLIC_COMMON_PRESENTATION_INFO_H_
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