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

Convert LocalMuter and StreamFactory to new Mojo types

This CL converts LocalMuterAssociatedRequest and StreamFactoryPtr
in content to the new Mojo types.

Bug: 955171
Change-Id: I08356dd12197b7db14730f7045da0b1742e69804
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786891Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#695418}
parent 9702e695
......@@ -12,6 +12,7 @@
#include "content/public/test/browser_task_environment.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "services/audio/public/cpp/fake_stream_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -159,7 +160,8 @@ struct TestEnvironment {
StrictMock<MockRendererAudioInputStreamFactoryClient> renderer_factory_client;
std::unique_ptr<AudioInputStreamBroker> broker;
MockStreamFactory stream_factory;
audio::mojom::StreamFactoryPtr factory_ptr{stream_factory.MakeRemote()};
mojo::Remote<audio::mojom::StreamFactory> factory_ptr{
stream_factory.MakeRemote()};
};
} // namespace
......
......@@ -11,6 +11,8 @@
#include "base/test/mock_callback.h"
#include "content/public/test/browser_task_environment.h"
#include "media/mojo/mojom/audio_input_stream.mojom.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "services/audio/public/cpp/fake_stream_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -110,7 +112,7 @@ class MockStreamFactory : public audio::FakeStreamFactory {
base::UnguessableToken group_id;
mojo::ScopedSharedBufferHandle key_press_count_buffer;
CreateLoopbackStreamCallback created_callback;
audio::mojom::LocalMuterAssociatedRequest muter_request;
mojo::PendingAssociatedReceiver<audio::mojom::LocalMuter> muter_receiver;
};
void ExpectStreamCreation(StreamRequestData* ex) {
......@@ -143,7 +145,7 @@ class MockStreamFactory : public audio::FakeStreamFactory {
void BindMuter(
mojo::PendingAssociatedReceiver<audio::mojom::LocalMuter> receiver,
const base::UnguessableToken& group_id) final {
stream_request_data_->muter_request = std::move(receiver);
stream_request_data_->muter_receiver = std::move(receiver);
IsMuting(group_id);
}
......@@ -172,7 +174,8 @@ struct TestEnvironment {
StrictMock<MockRendererAudioInputStreamFactoryClient> renderer_factory_client;
std::unique_ptr<AudioLoopbackStreamBroker> broker;
MockStreamFactory stream_factory;
audio::mojom::StreamFactoryPtr factory_ptr{stream_factory.MakeRemote()};
mojo::Remote<audio::mojom::StreamFactory> factory_ptr{
stream_factory.MakeRemote()};
};
} // namespace
......
......@@ -19,6 +19,7 @@
#include "media/mojo/mojom/audio_output_stream.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/buffer.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "services/audio/public/cpp/fake_stream_factory.h"
......@@ -158,7 +159,8 @@ struct TestEnvironment {
StrictMock<MockAudioOutputStreamProviderClient> provider_client;
std::unique_ptr<AudioOutputStreamBroker> broker;
MockStreamFactory stream_factory;
audio::mojom::StreamFactoryPtr factory_ptr{stream_factory.MakeRemote()};
mojo::Remote<audio::mojom::StreamFactory> factory_ptr{
stream_factory.MakeRemote()};
};
} // namespace
......
......@@ -315,10 +315,10 @@ audio::mojom::StreamFactory* ForwardingAudioStreamFactory::Core::GetFactory() {
TRACE_EVENT_INSTANT1(
"audio", "ForwardingAudioStreamFactory: Binding new factory",
TRACE_EVENT_SCOPE_THREAD, "group", group_id_.GetLowForSerialization());
connector_->BindInterface(audio::mojom::kServiceName,
mojo::MakeRequest(&remote_factory_));
connector_->Connect(audio::mojom::kServiceName,
remote_factory_.BindNewPipeAndPassReceiver());
// Unretained is safe because |this| owns |remote_factory_|.
remote_factory_.set_connection_error_handler(base::BindOnce(
remote_factory_.set_disconnect_handler(base::BindOnce(
&ForwardingAudioStreamFactory::Core::ResetRemoteFactoryPtr,
base::Unretained(this)));
......
......@@ -21,6 +21,7 @@
#include "content/common/media/renderer_audio_input_stream_factory.mojom.h"
#include "content/public/browser/web_contents_observer.h"
#include "media/mojo/mojom/audio_output_stream.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/audio/public/mojom/audio_processing.mojom.h"
#include "services/audio/public/mojom/stream_factory.mojom.h"
......@@ -153,7 +154,7 @@ class CONTENT_EXPORT ForwardingAudioStreamFactory final
// since we want to clean up the service when not in use. If we have active
// muting but nothing else, we should stop it and start it again when we
// need to reacquire the factory for some other reason.
audio::mojom::StreamFactoryPtr remote_factory_;
mojo::Remote<audio::mojom::StreamFactory> remote_factory_;
// Running id used for tracking audible streams. We keep count here to avoid
// collisions.
......
......@@ -33,8 +33,10 @@
#include "media/audio/test_audio_thread.h"
#include "media/base/audio_parameters.h"
#include "media/mojo/mojom/audio_data_pipe.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/interface_request.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 "services/audio/public/cpp/fake_stream_factory.h"
#include "services/audio/public/mojom/constants.mojom.h"
#include "services/audio/public/mojom/stream_factory.mojom.h"
......@@ -94,15 +96,16 @@ class MAYBE_RenderFrameAudioInputStreamFactoryTest
RenderViewHostTestHarness::TearDown();
}
void BindFactory(mojo::ScopedMessagePipeHandle factory_request) {
audio_service_stream_factory_.binding_.Bind(
audio::mojom::StreamFactoryRequest(std::move(factory_request)));
void BindFactory(mojo::ScopedMessagePipeHandle factory_receiver) {
audio_service_stream_factory_.receiver_.Bind(
mojo::PendingReceiver<audio::mojom::StreamFactory>(
std::move(factory_receiver)));
}
class MockStreamFactory : public audio::FakeStreamFactory {
public:
MockStreamFactory() : binding_(this) {}
~MockStreamFactory() override {}
MockStreamFactory() = default;
~MockStreamFactory() override = default;
void CreateInputStream(
mojo::PendingReceiver<media::mojom::AudioInputStream> stream_receiver,
......@@ -133,7 +136,7 @@ class MAYBE_RenderFrameAudioInputStreamFactoryTest
CreateInputStreamCallback last_created_callback;
CreateLoopbackStreamCallback last_created_loopback_callback;
mojo::Binding<audio::mojom::StreamFactory> binding_;
mojo::Receiver<audio::mojom::StreamFactory> receiver_{this};
};
class FakeRendererAudioInputStreamFactoryClient
......
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