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( ...@@ -26,13 +26,13 @@ MojoAndroidOverlay::MojoAndroidOverlay(
mojo::Remote<mojom::AndroidOverlayProvider> provider( mojo::Remote<mojom::AndroidOverlayProvider> provider(
std::move(pending_provider)); std::move(pending_provider));
provider->CreateOverlay(mojo::MakeRequest(&overlay_ptr_), provider->CreateOverlay(overlay_.BindNewPipeAndPassReceiver(),
receiver_.BindNewPipeAndPassRemote(), receiver_.BindNewPipeAndPassRemote(),
std::move(mojo_config)); std::move(mojo_config));
} }
MojoAndroidOverlay::~MojoAndroidOverlay() { 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 // with the surface. If a synchronous destroy is pending, then it can be
// allowed to continue. // allowed to continue.
} }
...@@ -42,7 +42,7 @@ void MojoAndroidOverlay::ScheduleLayout(const gfx::Rect& rect) { ...@@ -42,7 +42,7 @@ void MojoAndroidOverlay::ScheduleLayout(const gfx::Rect& rect) {
if (!received_surface_) if (!received_surface_)
return; return;
overlay_ptr_->ScheduleLayout(rect); overlay_->ScheduleLayout(rect);
} }
const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface() const base::android::JavaRef<jobject>& MojoAndroidOverlay::GetJavaSurface()
...@@ -70,7 +70,7 @@ void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) { ...@@ -70,7 +70,7 @@ void MojoAndroidOverlay::OnSurfaceReady(uint64_t surface_key) {
} }
void MojoAndroidOverlay::OnDestroyed() { 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. // gotten a surface. Regardless, the overlay cannot be used.
if (!received_surface_) if (!received_surface_)
...@@ -78,7 +78,7 @@ void MojoAndroidOverlay::OnDestroyed() { ...@@ -78,7 +78,7 @@ void MojoAndroidOverlay::OnDestroyed() {
else else
RunSurfaceDestroyedCallbacks(); 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. // signal that we should do that, since it still might be in use.
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "media/mojo/mojom/android_overlay.mojom.h" #include "media/mojo/mojom/android_overlay.mojom.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"
#include "mojo/public/cpp/bindings/remote.h"
namespace media { namespace media {
...@@ -36,7 +37,7 @@ class MojoAndroidOverlay : public AndroidOverlay, ...@@ -36,7 +37,7 @@ class MojoAndroidOverlay : public AndroidOverlay,
private: private:
AndroidOverlayConfig config_; AndroidOverlayConfig config_;
mojom::AndroidOverlayPtr overlay_ptr_; mojo::Remote<mojom::AndroidOverlay> overlay_;
mojo::Receiver<mojom::AndroidOverlayClient> receiver_{this}; mojo::Receiver<mojom::AndroidOverlayClient> receiver_{this};
gl::ScopedJavaSurface surface_; gl::ScopedJavaSurface surface_;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "gpu/ipc/common/gpu_surface_tracker.h" #include "gpu/ipc/common/gpu_surface_tracker.h"
#include "media/base/mock_filters.h" #include "media/base/mock_filters.h"
#include "media/mojo/clients/mojo_android_overlay.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/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
...@@ -54,10 +54,11 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -54,10 +54,11 @@ class MojoAndroidOverlayTest : public ::testing::Test {
: public StrictMock<mojom::AndroidOverlayProvider> { : public StrictMock<mojom::AndroidOverlayProvider> {
public: public:
// These argument types lack default constructors, so gmock can't mock them. // These argument types lack default constructors, so gmock can't mock them.
void CreateOverlay(mojom::AndroidOverlayRequest overlay_request, void CreateOverlay(
mojo::PendingRemote<mojom::AndroidOverlayClient> client, mojo::PendingReceiver<mojom::AndroidOverlay> overlay_receiver,
mojom::AndroidOverlayConfigPtr config) override { mojo::PendingRemote<mojom::AndroidOverlayClient> client,
overlay_request_ = std::move(overlay_request); mojom::AndroidOverlayConfigPtr config) override {
overlay_receiver_ = std::move(overlay_receiver);
client_.Bind(std::move(client)); client_.Bind(std::move(client));
config_ = std::move(config); config_ = std::move(config);
OverlayCreated(); OverlayCreated();
...@@ -65,14 +66,15 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -65,14 +66,15 @@ class MojoAndroidOverlayTest : public ::testing::Test {
MOCK_METHOD0(OverlayCreated, void(void)); MOCK_METHOD0(OverlayCreated, void(void));
mojom::AndroidOverlayRequest overlay_request_; mojo::PendingReceiver<mojom::AndroidOverlay> overlay_receiver_;
mojo::Remote<mojom::AndroidOverlayClient> client_; mojo::Remote<mojom::AndroidOverlayClient> client_;
mojom::AndroidOverlayConfigPtr config_; mojom::AndroidOverlayConfigPtr config_;
}; };
public: public:
MojoAndroidOverlayTest() MojoAndroidOverlayTest()
: provider_receiver_(&mock_provider_), overlay_binding_(&mock_overlay_) {} : provider_receiver_(&mock_provider_),
overlay_receiver_(&mock_overlay_) {}
~MojoAndroidOverlayTest() override {} ~MojoAndroidOverlayTest() override {}
...@@ -104,7 +106,7 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -104,7 +106,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
} }
// Create an overlay in |overlay_client_| using the current config, but do // 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() { void CreateOverlay() {
EXPECT_CALL(mock_provider_, OverlayCreated()); EXPECT_CALL(mock_provider_, OverlayCreated());
...@@ -123,7 +125,7 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -123,7 +125,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
CreateOverlay(); CreateOverlay();
// Bind an overlay to the request. // 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(); base::RunLoop().RunUntilIdle();
} }
...@@ -167,7 +169,7 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -167,7 +169,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
// The mock overlay impl that |mock_provider_| will provide. // The mock overlay impl that |mock_provider_| will provide.
MockAndroidOverlay mock_overlay_; MockAndroidOverlay mock_overlay_;
mojo::Binding<mojom::AndroidOverlay> overlay_binding_; mojo::Receiver<mojom::AndroidOverlay> overlay_receiver_;
// The client under test. // The client under test.
std::unique_ptr<AndroidOverlay> overlay_client_; std::unique_ptr<AndroidOverlay> overlay_client_;
......
...@@ -16,7 +16,7 @@ import "ui/gfx/geometry/mojom/geometry.mojom"; ...@@ -16,7 +16,7 @@ import "ui/gfx/geometry/mojom/geometry.mojom";
interface AndroidOverlayProvider { interface AndroidOverlayProvider {
// Create an overlay and send it to |client|, using |config| as the initial // Create an overlay and send it to |client|, using |config| as the initial
// configuration. |overlay| will hold the overlay object. // configuration. |overlay| will hold the overlay object.
CreateOverlay(AndroidOverlay& overlay, CreateOverlay(pending_receiver<AndroidOverlay> overlay,
pending_remote<AndroidOverlayClient> client, pending_remote<AndroidOverlayClient> client,
AndroidOverlayConfig config); 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