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

Convert AndroidOverlayClient to new Mojo types

This CL converts AndroidOverlayClient and Binding<T> in media to
the new Mojo type, and uses pending_remote<AndroidOverlayClient>
in android_overlay.mojom.

Bug: 955171
Change-Id: I1c224864438978fb4445c4c57cb7ec4099534ac4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1865152
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@{#706810}
parent 18de6bf3
...@@ -14,7 +14,7 @@ MojoAndroidOverlay::MojoAndroidOverlay( ...@@ -14,7 +14,7 @@ MojoAndroidOverlay::MojoAndroidOverlay(
mojo::PendingRemote<mojom::AndroidOverlayProvider> pending_provider, mojo::PendingRemote<mojom::AndroidOverlayProvider> pending_provider,
AndroidOverlayConfig config, AndroidOverlayConfig config,
const base::UnguessableToken& routing_token) const base::UnguessableToken& routing_token)
: config_(std::move(config)), binding_(this) { : config_(std::move(config)) {
// Fill in details of |config| into |mojo_config|. Our caller could do this // Fill in details of |config| into |mojo_config|. Our caller could do this
// too, but since we want to retain |config_| anyway, we do it here. // too, but since we want to retain |config_| anyway, we do it here.
mojom::AndroidOverlayConfigPtr mojo_config = mojom::AndroidOverlayConfigPtr mojo_config =
...@@ -24,12 +24,10 @@ MojoAndroidOverlay::MojoAndroidOverlay( ...@@ -24,12 +24,10 @@ MojoAndroidOverlay::MojoAndroidOverlay(
mojo_config->secure = config_.secure; mojo_config->secure = config_.secure;
mojo_config->power_efficient = config_.power_efficient; mojo_config->power_efficient = config_.power_efficient;
mojom::AndroidOverlayClientPtr ptr;
binding_.Bind(mojo::MakeRequest(&ptr));
mojo::Remote<mojom::AndroidOverlayProvider> provider( mojo::Remote<mojom::AndroidOverlayProvider> provider(
std::move(pending_provider)); std::move(pending_provider));
provider->CreateOverlay(mojo::MakeRequest(&overlay_ptr_), std::move(ptr), provider->CreateOverlay(mojo::MakeRequest(&overlay_ptr_),
receiver_.BindNewPipeAndPassRemote(),
std::move(mojo_config)); std::move(mojo_config));
} }
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
#include "media/base/android/android_overlay.h" #include "media/base/android/android_overlay.h"
#include "media/mojo/mojom/android_overlay.mojom.h" #include "media/mojo/mojom/android_overlay.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace media { namespace media {
...@@ -37,7 +37,7 @@ class MojoAndroidOverlay : public AndroidOverlay, ...@@ -37,7 +37,7 @@ class MojoAndroidOverlay : public AndroidOverlay,
private: private:
AndroidOverlayConfig config_; AndroidOverlayConfig config_;
mojom::AndroidOverlayPtr overlay_ptr_; mojom::AndroidOverlayPtr overlay_ptr_;
mojo::Binding<mojom::AndroidOverlayClient> binding_; mojo::Receiver<mojom::AndroidOverlayClient> receiver_{this};
gl::ScopedJavaSurface surface_; gl::ScopedJavaSurface surface_;
// Have we received OnSurfaceReady yet? // Have we received OnSurfaceReady yet?
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
#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/binding.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 "services/service_manager/public/mojom/interface_provider.mojom.h" #include "services/service_manager/public/mojom/interface_provider.mojom.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/android/scoped_java_surface.h" #include "ui/gl/android/scoped_java_surface.h"
...@@ -53,10 +55,10 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -53,10 +55,10 @@ class MojoAndroidOverlayTest : public ::testing::Test {
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(mojom::AndroidOverlayRequest overlay_request,
mojom::AndroidOverlayClientPtr client, mojo::PendingRemote<mojom::AndroidOverlayClient> client,
mojom::AndroidOverlayConfigPtr config) override { mojom::AndroidOverlayConfigPtr config) override {
overlay_request_ = std::move(overlay_request); overlay_request_ = std::move(overlay_request);
client_ = std::move(client); client_.Bind(std::move(client));
config_ = std::move(config); config_ = std::move(config);
OverlayCreated(); OverlayCreated();
} }
...@@ -64,7 +66,7 @@ class MojoAndroidOverlayTest : public ::testing::Test { ...@@ -64,7 +66,7 @@ class MojoAndroidOverlayTest : public ::testing::Test {
MOCK_METHOD0(OverlayCreated, void(void)); MOCK_METHOD0(OverlayCreated, void(void));
mojom::AndroidOverlayRequest overlay_request_; mojom::AndroidOverlayRequest overlay_request_;
mojom::AndroidOverlayClientPtr client_; mojo::Remote<mojom::AndroidOverlayClient> client_;
mojom::AndroidOverlayConfigPtr config_; mojom::AndroidOverlayConfigPtr config_;
}; };
......
...@@ -16,8 +16,9 @@ import "ui/gfx/geometry/mojom/geometry.mojom"; ...@@ -16,8 +16,9 @@ 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, AndroidOverlayClient client, CreateOverlay(AndroidOverlay& overlay,
AndroidOverlayConfig config); pending_remote<AndroidOverlayClient> client,
AndroidOverlayConfig config);
}; };
// One overlay instance. This will be provided by the provider to clients // One overlay instance. This will be provided by the provider to clients
......
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