Commit b8713aa8 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate references to mirroring.mojom.ResourceProvider to new mojo types

Convert the remaining bits that still use the old mojo types for
mirroring::mojom::ResourceProvider to the new mojo types, and adapt
unit tests.

Bug: 955171
Change-Id: If014a142d4f903244a80a5e59fdd38aabf37ad93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807220
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697995}
parent 8b35731c
...@@ -169,7 +169,6 @@ void CastMirroringServiceHost::GetForOffscreenTab( ...@@ -169,7 +169,6 @@ void CastMirroringServiceHost::GetForOffscreenTab(
CastMirroringServiceHost::CastMirroringServiceHost( CastMirroringServiceHost::CastMirroringServiceHost(
content::DesktopMediaID source_media_id) content::DesktopMediaID source_media_id)
: source_media_id_(source_media_id), : source_media_id_(source_media_id),
resource_provider_binding_(this),
gpu_client_(nullptr, base::OnTaskRunnerDeleter(nullptr)) { gpu_client_(nullptr, base::OnTaskRunnerDeleter(nullptr)) {
// Observe the target WebContents for Tab mirroring. // Observe the target WebContents for Tab mirroring.
if (source_media_id_.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) if (source_media_id_.type == content::DesktopMediaID::TYPE_WEB_CONTENTS)
...@@ -198,8 +197,8 @@ void CastMirroringServiceHost::Start( ...@@ -198,8 +197,8 @@ void CastMirroringServiceHost::Start(
.WithDisplayName("Mirroring Service") .WithDisplayName("Mirroring Service")
.WithSandboxType(service_manager::SANDBOX_TYPE_UTILITY) .WithSandboxType(service_manager::SANDBOX_TYPE_UTILITY)
.Pass()); .Pass());
mojom::ResourceProviderPtr provider; mojo::PendingRemote<mojom::ResourceProvider> provider;
resource_provider_binding_.Bind(mojo::MakeRequest(&provider)); resource_provider_receiver.Bind(provider.InitWithNewPipeAndPassReceiver());
mirroring_service_->Start( mirroring_service_->Start(
std::move(session_params), GetCaptureResolutionConstraint(), std::move(session_params), GetCaptureResolutionConstraint(),
std::move(observer), std::move(provider), std::move(outbound_channel), std::move(observer), std::move(provider), std::move(outbound_channel),
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
...@@ -124,8 +125,8 @@ class CastMirroringServiceHost final : public mojom::MirroringServiceHost, ...@@ -124,8 +125,8 @@ class CastMirroringServiceHost final : public mojom::MirroringServiceHost,
// Describes the media source for this mirroring session. // Describes the media source for this mirroring session.
content::DesktopMediaID source_media_id_; content::DesktopMediaID source_media_id_;
// The binding to this mojom::ResourceProvider implementation. // The receiver to this mojom::ResourceProvider implementation.
mojo::Binding<mojom::ResourceProvider> resource_provider_binding_; mojo::Receiver<mojom::ResourceProvider> resource_provider_receiver{this};
// Connection to the remote mojom::MirroringService implementation. // Connection to the remote mojom::MirroringService implementation.
mojo::Remote<mojom::MirroringService> mirroring_service_; mojo::Remote<mojom::MirroringService> mirroring_service_;
......
...@@ -21,7 +21,7 @@ interface MirroringService { ...@@ -21,7 +21,7 @@ interface MirroringService {
Start(SessionParameters params, Start(SessionParameters params,
gfx.mojom.Size max_resolution, gfx.mojom.Size max_resolution,
pending_remote<SessionObserver> observer, pending_remote<SessionObserver> observer,
ResourceProvider resource_provider, pending_remote<ResourceProvider> resource_provider,
pending_remote<CastMessageChannel> outbound_channel, pending_remote<CastMessageChannel> outbound_channel,
pending_receiver<CastMessageChannel> inbound_channel); pending_receiver<CastMessageChannel> inbound_channel);
}; };
...@@ -23,7 +23,7 @@ void MirroringService::Start( ...@@ -23,7 +23,7 @@ void MirroringService::Start(
mojom::SessionParametersPtr params, mojom::SessionParametersPtr params,
const gfx::Size& max_resolution, const gfx::Size& max_resolution,
mojo::PendingRemote<mojom::SessionObserver> observer, mojo::PendingRemote<mojom::SessionObserver> observer,
mojom::ResourceProviderPtr resource_provider, mojo::PendingRemote<mojom::ResourceProvider> resource_provider,
mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel, mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel,
mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel) { mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel) {
session_.reset(); // Stops the current session if active. session_.reset(); // Stops the current session if active.
......
...@@ -28,7 +28,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) MirroringService final ...@@ -28,7 +28,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) MirroringService final
void Start(mojom::SessionParametersPtr params, void Start(mojom::SessionParametersPtr params,
const gfx::Size& max_resolution, const gfx::Size& max_resolution,
mojo::PendingRemote<mojom::SessionObserver> observer, mojo::PendingRemote<mojom::SessionObserver> observer,
mojom::ResourceProviderPtr resource_provider, mojo::PendingRemote<mojom::ResourceProvider> resource_provider,
mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel, mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel,
mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel) mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel)
override; override;
......
...@@ -377,7 +377,7 @@ Session::Session( ...@@ -377,7 +377,7 @@ Session::Session(
mojom::SessionParametersPtr session_params, mojom::SessionParametersPtr session_params,
const gfx::Size& max_resolution, const gfx::Size& max_resolution,
mojo::PendingRemote<mojom::SessionObserver> observer, mojo::PendingRemote<mojom::SessionObserver> observer,
mojom::ResourceProviderPtr resource_provider, mojo::PendingRemote<mojom::ResourceProvider> resource_provider,
mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel, mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel,
mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel, mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
......
...@@ -63,7 +63,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) Session final ...@@ -63,7 +63,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) Session final
Session(mojom::SessionParametersPtr session_params, Session(mojom::SessionParametersPtr session_params,
const gfx::Size& max_resolution, const gfx::Size& max_resolution,
mojo::PendingRemote<mojom::SessionObserver> observer, mojo::PendingRemote<mojom::SessionObserver> observer,
mojom::ResourceProviderPtr resource_provider, mojo::PendingRemote<mojom::ResourceProvider> resource_provider,
mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel, mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel,
mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel, mojo::PendingReceiver<mojom::CastMessageChannel> inbound_channel,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
...@@ -158,7 +158,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) Session final ...@@ -158,7 +158,7 @@ class COMPONENT_EXPORT(MIRRORING_SERVICE) Session final
} state_; } state_;
mojo::Remote<mojom::SessionObserver> observer_; mojo::Remote<mojom::SessionObserver> observer_;
mojom::ResourceProviderPtr resource_provider_; mojo::Remote<mojom::ResourceProvider> resource_provider_;
MirrorSettings mirror_settings_; MirrorSettings mirror_settings_;
MessageDispatcher message_dispatcher_; MessageDispatcher message_dispatcher_;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "components/mirroring/service/value_util.h" #include "components/mirroring/service/value_util.h"
#include "media/cast/test/utility/default_config.h" #include "media/cast/test/utility/default_config.h"
#include "media/cast/test/utility/net_utility.h" #include "media/cast/test/utility/net_utility.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
...@@ -76,9 +75,7 @@ class SessionTest : public mojom::ResourceProvider, ...@@ -76,9 +75,7 @@ class SessionTest : public mojom::ResourceProvider,
public mojom::CastMessageChannel, public mojom::CastMessageChannel,
public ::testing::Test { public ::testing::Test {
public: public:
SessionTest() SessionTest() : receiver_endpoint_(media::cast::test::GetFreeLocalPort()) {}
: receiver_endpoint_(media::cast::test::GetFreeLocalPort()),
resource_provider_binding_(this) {}
~SessionTest() override { task_environment_.RunUntilIdle(); } ~SessionTest() override { task_environment_.RunUntilIdle(); }
...@@ -201,10 +198,11 @@ class SessionTest : public mojom::ResourceProvider, ...@@ -201,10 +198,11 @@ class SessionTest : public mojom::ResourceProvider,
session_params->type = session_type_; session_params->type = session_type_;
session_params->receiver_model_name = "Chromecast"; session_params->receiver_model_name = "Chromecast";
cast_mode_ = "mirroring"; cast_mode_ = "mirroring";
mojom::ResourceProviderPtr resource_provider_ptr; mojo::PendingRemote<mojom::ResourceProvider> resource_provider_remote;
mojo::PendingRemote<mojom::SessionObserver> session_observer_remote; mojo::PendingRemote<mojom::SessionObserver> session_observer_remote;
mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel_remote; mojo::PendingRemote<mojom::CastMessageChannel> outbound_channel_remote;
resource_provider_binding_.Bind(mojo::MakeRequest(&resource_provider_ptr)); resource_provider_receiver_.Bind(
resource_provider_remote.InitWithNewPipeAndPassReceiver());
session_observer_receiver_.Bind( session_observer_receiver_.Bind(
session_observer_remote.InitWithNewPipeAndPassReceiver()); session_observer_remote.InitWithNewPipeAndPassReceiver());
outbound_channel_receiver_.Bind( outbound_channel_receiver_.Bind(
...@@ -215,7 +213,7 @@ class SessionTest : public mojom::ResourceProvider, ...@@ -215,7 +213,7 @@ class SessionTest : public mojom::ResourceProvider,
EXPECT_CALL(*this, OnOutboundMessage("OFFER")).Times(1); EXPECT_CALL(*this, OnOutboundMessage("OFFER")).Times(1);
session_ = std::make_unique<Session>( session_ = std::make_unique<Session>(
std::move(session_params), gfx::Size(1920, 1080), std::move(session_params), gfx::Size(1920, 1080),
std::move(session_observer_remote), std::move(resource_provider_ptr), std::move(session_observer_remote), std::move(resource_provider_remote),
std::move(outbound_channel_remote), std::move(outbound_channel_remote),
inbound_channel_.BindNewPipeAndPassReceiver(), nullptr); inbound_channel_.BindNewPipeAndPassReceiver(), nullptr);
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
...@@ -341,7 +339,7 @@ class SessionTest : public mojom::ResourceProvider, ...@@ -341,7 +339,7 @@ class SessionTest : public mojom::ResourceProvider,
private: private:
base::test::TaskEnvironment task_environment_; base::test::TaskEnvironment task_environment_;
const net::IPEndPoint receiver_endpoint_; const net::IPEndPoint receiver_endpoint_;
mojo::Binding<mojom::ResourceProvider> resource_provider_binding_; mojo::Receiver<mojom::ResourceProvider> resource_provider_receiver_{this};
mojo::Receiver<mojom::SessionObserver> session_observer_receiver_{this}; mojo::Receiver<mojom::SessionObserver> session_observer_receiver_{this};
mojo::Receiver<mojom::CastMessageChannel> outbound_channel_receiver_{this}; mojo::Receiver<mojom::CastMessageChannel> outbound_channel_receiver_{this};
mojo::Remote<mojom::CastMessageChannel> inbound_channel_; mojo::Remote<mojom::CastMessageChannel> inbound_channel_;
......
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