Commit d9e39eeb authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Convert AndroidOverlay to new Mojo types

This CL converts AndroidOverlay{Ptr, Request} in media to the new
Mojo type, and uses pending_receiver<AndroidOverlay> in
android_overlay.mojom.

Bug: 955171
Change-Id: I2b9e348196879baf63003f7c94dbaf5c79bfc2ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865154
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#706812}
parent 93695c8a
......@@ -26,13 +26,13 @@ MojoAndroidOverlay::MojoAndroidOverlay(
mojo::Remote<mojom::AndroidOverlayProvider> provider(
std::move(pending_provider));
provider->CreateOverlay(mojo::MakeRequest(&overlay_ptr_),
provider->CreateOverlay(overlay_.BindNewPipeAndPassReceiver(),
receiver_.BindNewPipeAndPassRemote(),
std::move(mojo_config));
}
MojoAndroidOverlay::~MojoAndroidOverlay() {
// Dropping |overlay_ptr_| will signal to the implementation that we're done
// Dropping |overlay_| will signal to the implementation that we're done
// with the surface. If a synchronous destroy is pending, then it can be
// allowed to continue.
}
......@@ -42,7 +42,7 @@ void MojoAndroidOverlay::ScheduleLayout(const gfx::Rect& rect) {
if (!received_surface_)
return;
overlay_ptr_->ScheduleLayout(rect);
overlay_->ScheduleLayout(rect);
}
const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface()
......@@ -70,7 +70,7 @@ void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) {
}
void MojoAndroidOverlay::OnDestroyed() {
// Note that |overlay_ptr_| might not be bound yet, or we might not have ever
// Note that |overlay_| might not be bound yet, or we might not have ever
// gotten a surface. Regardless, the overlay cannot be used.
if (!received_surface_)
......@@ -78,7 +78,7 @@ void MojoAndroidOverlay::OnDestroyed() {
else
RunSurfaceDestroyedCallbacks();
// Note: we do not delete |overlay_ptr_| here. Our client must delete us to
// Note: we do not delete |overlay_| here. Our client must delete us to
// signal that we should do that, since it still might be in use.
}
......
......@@ -11,6 +11,7 @@
#include "media/mojo/mojom/android_overlay.mojom.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media {
......@@ -36,7 +37,7 @@ class MojoAndroidOverlay : public AndroidOverlay,
private:
AndroidOverlayConfig config_;
mojom::AndroidOverlayPtr overlay_ptr_;
mojo::Remote<mojom::AndroidOverlay> overlay_;
mojo::Receiver<mojom::AndroidOverlayClient> receiver_{this};
gl::ScopedJavaSurface surface_;
......
......@@ -13,7 +13,7 @@
#include "gpu/ipc/common/gpu_surface_tracker.h"
#include "media/base/mock_filters.h"
#include "media/mojo/clients/mojo_android_overlay.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
......@@ -54,10 +54,11 @@ class MojoAndroidOverlayTest : public ::testing::Test {
: public StrictMock<mojom::AndroidOverlayProvider> {
public:
// These argument types lack default constructors, so gmock can't mock them.
void CreateOverlay(mojom::AndroidOverlayRequest overlay_request,
mojo::PendingRemote<mojom::AndroidOverlayClient> client,
mojom::AndroidOverlayConfigPtr config) override {
overlay_request_ = std::move(overlay_request);
void CreateOverlay(
mojo::PendingReceiver<mojom::AndroidOverlay> overlay_receiver,
mojo::PendingRemote<mojom::AndroidOverlayClient> client,
mojom::AndroidOverlayConfigPtr config) override {
overlay_receiver_ = std::move(overlay_receiver);
client_.Bind(std::move(client));
config_ = std::move(config);
OverlayCreated();
......@@ -65,14 +66,15 @@ class MojoAndroidOverlayTest : public ::testing::Test {
MOCK_METHOD0(OverlayCreated, void(void));
mojom::AndroidOverlayRequest overlay_request_;
mojo::PendingReceiver<mojom::AndroidOverlay> overlay_receiver_;
mojo::Remote<mojom::AndroidOverlayClient> client_;
mojom::AndroidOverlayConfigPtr config_;
};
public:
MojoAndroidOverlayTest()
: provider_receiver_(&mock_provider_), overlay_binding_(&mock_overlay_) {}
: provider_receiver_(&mock_provider_),
overlay_receiver_(&mock_overlay_) {}
~MojoAndroidOverlayTest() override {}
......@@ -104,7 +106,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
}
// Create an overlay in |overlay_client_| using the current config, but do
// not bind anything to |overlay_request_| yet.
// not bind anything to |overlay_receiver_| yet.
void CreateOverlay() {
EXPECT_CALL(mock_provider_, OverlayCreated());
......@@ -123,7 +125,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
CreateOverlay();
// Bind an overlay to the request.
overlay_binding_.Bind(std::move(mock_provider_.overlay_request_));
overlay_receiver_.Bind(std::move(mock_provider_.overlay_receiver_));
base::RunLoop().RunUntilIdle();
}
......@@ -167,7 +169,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
// The mock overlay impl that |mock_provider_| will provide.
MockAndroidOverlay mock_overlay_;
mojo::Binding<mojom::AndroidOverlay> overlay_binding_;
mojo::Receiver<mojom::AndroidOverlay> overlay_receiver_;
// The client under test.
std::unique_ptr<AndroidOverlay> overlay_client_;
......
......@@ -16,7 +16,7 @@ import "ui/gfx/geometry/mojom/geometry.mojom";
interface AndroidOverlayProvider {
// Create an overlay and send it to |client|, using |config| as the initial
// configuration. |overlay| will hold the overlay object.
CreateOverlay(AndroidOverlay& overlay,
CreateOverlay(pending_receiver<AndroidOverlay> overlay,
pending_remote<AndroidOverlayClient> client,
AndroidOverlayConfig config);
};
......
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