Commit 77b3d096 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Clean up old Mojo types in CdmFoo classes

This CL converts old Mojo types to new Mojo types
in CdmFoo classes except for CdmService::LoadCdm.

  - Convert FooRequest to mojo::PendingReceiver.
  - Convert FooPtr to mojo::PendingRemote or mojo::Remote.
  - Convert the second parameter to mojo::PendingRemote in
    service_manager::GetInterface

Bug: 955171
Change-Id: I9ff169c17829f5ce69ede8c6b3ab991350491047
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1883347
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710241}
parent 49c67d9d
......@@ -93,21 +93,22 @@ void CastRenderer::Initialize(::media::MediaResource* media_resource,
::media::PipelineStatusCallback init_cb) {
LOG(INFO) << __FUNCTION__ << ": " << this;
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!application_media_info_manager_ptr_);
DCHECK(!application_media_info_manager_remote_);
init_cb_ = std::move(init_cb);
// Retrieve application_media_info_manager_ptr_ if it is available via
// Retrieve application_media_info_manager_remote_ if it is available via
// CastApplicationMediaInfoManager.
if (host_interfaces_) {
service_manager::GetInterface<
::media::mojom::CastApplicationMediaInfoManager>(
host_interfaces_, &application_media_info_manager_ptr_);
host_interfaces_,
application_media_info_manager_remote_.BindNewPipeAndPassReceiver());
}
if (application_media_info_manager_ptr_) {
application_media_info_manager_ptr_->GetCastApplicationMediaInfo(
if (application_media_info_manager_remote_) {
application_media_info_manager_remote_->GetCastApplicationMediaInfo(
base::BindOnce(&CastRenderer::OnApplicationMediaInfoReceived,
weak_factory_.GetWeakPtr(), media_resource, client));
} else {
......
......@@ -104,8 +104,8 @@ class CastRenderer : public ::media::Renderer,
bool eos_[2];
gfx::Size video_res_;
::media::mojom::CastApplicationMediaInfoManagerPtr
application_media_info_manager_ptr_;
mojo::Remote<::media::mojom::CastApplicationMediaInfoManager>
application_media_info_manager_remote_;
mojo::Remote<chromecast::mojom::MultiroomManager> multiroom_manager_;
::media::PipelineStatusCallback init_cb_;
......
......@@ -93,16 +93,16 @@ class MediaDrmStorageImplTest : public content::RenderViewHostTestHarness {
MediaDrmStorageImpl::GetOriginIdCB get_origin_id_cb,
MediaDrmStorageImpl::AllowEmptyOriginIdCB allow_empty_cb =
base::BindRepeating(&AllowEmptyOriginId)) {
media::mojom::MediaDrmStoragePtr media_drm_storage_ptr;
auto request = mojo::MakeRequest(&media_drm_storage_ptr);
mojo::PendingRemote<media::mojom::MediaDrmStorage> media_drm_storage_remote;
auto receiver = media_drm_storage_remote.InitWithNewPipeAndPassReceiver();
auto media_drm_storage = std::make_unique<media::MojoMediaDrmStorage>(
std::move(media_drm_storage_ptr));
std::move(media_drm_storage_remote));
// The created object will be destroyed on connection error.
new MediaDrmStorageImpl(rfh, pref_service_.get(),
std::move(get_origin_id_cb),
std::move(allow_empty_cb), std::move(request));
std::move(allow_empty_cb), std::move(receiver));
return std::move(media_drm_storage);
}
......
......@@ -5,6 +5,7 @@
#include "media/mojo/services/android_mojo_util.h"
#include "media/mojo/services/mojo_media_drm_storage.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/service_manager/public/cpp/connect.h"
namespace media {
......@@ -13,19 +14,23 @@ namespace android_mojo_util {
std::unique_ptr<ProvisionFetcher> CreateProvisionFetcher(
service_manager::mojom::InterfaceProvider* host_interfaces) {
DCHECK(host_interfaces);
mojom::ProvisionFetcherPtr provision_fetcher_ptr;
service_manager::GetInterface(host_interfaces, &provision_fetcher_ptr);
mojo::PendingRemote<mojom::ProvisionFetcher> provision_fetcher_remote;
service_manager::GetInterface(
host_interfaces,
provision_fetcher_remote.InitWithNewPipeAndPassReceiver());
return std::make_unique<MojoProvisionFetcher>(
std::move(provision_fetcher_ptr));
std::move(provision_fetcher_remote));
}
std::unique_ptr<MediaDrmStorage> CreateMediaDrmStorage(
service_manager::mojom::InterfaceProvider* host_interfaces) {
DCHECK(host_interfaces);
mojom::MediaDrmStoragePtr media_drm_storage_ptr;
service_manager::GetInterface(host_interfaces, &media_drm_storage_ptr);
mojo::PendingRemote<mojom::MediaDrmStorage> media_drm_storage_remote;
service_manager::GetInterface(
host_interfaces,
media_drm_storage_remote.InitWithNewPipeAndPassReceiver());
return std::make_unique<MojoMediaDrmStorage>(
std::move(media_drm_storage_ptr));
std::move(media_drm_storage_remote));
}
} // namespace android_mojo_util
......
......@@ -122,9 +122,10 @@ class CdmFactoryImpl : public DeferredDestroy<mojom::CdmFactory> {
} // namespace
CdmService::CdmService(std::unique_ptr<Client> client,
service_manager::mojom::ServiceRequest request)
: service_binding_(this, std::move(request)),
CdmService::CdmService(
std::unique_ptr<Client> client,
mojo::PendingReceiver<service_manager::mojom::Service> receiver)
: service_binding_(this, std::move(receiver)),
keepalive_(std::make_unique<service_manager::ServiceKeepalive>(
&service_binding_,
kKeepaliveIdleTimeout)),
......@@ -164,8 +165,8 @@ void CdmService::OnDisconnected() {
Terminate();
}
void CdmService::Create(mojom::CdmServiceRequest request) {
bindings_.AddBinding(this, std::move(request));
void CdmService::Create(mojo::PendingReceiver<mojom::CdmService> receiver) {
receivers_.Add(this, std::move(receiver));
}
#if defined(OS_MACOSX)
......
......@@ -14,8 +14,9 @@
#include "media/mojo/mojom/content_decryption_module.mojom.h"
#include "media/mojo/services/deferred_destroy_strong_binding_set.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_binding.h"
......@@ -55,7 +56,7 @@ class MEDIA_MOJO_EXPORT CdmService : public service_manager::Service,
};
CdmService(std::unique_ptr<Client> client,
service_manager::mojom::ServiceRequest request);
mojo::PendingReceiver<service_manager::mojom::Service> receiver);
~CdmService() final;
// By default CdmService release is delayed. Overrides the delay with |delay|.
......@@ -78,7 +79,7 @@ class MEDIA_MOJO_EXPORT CdmService : public service_manager::Service,
mojo::ScopedMessagePipeHandle interface_pipe) override;
void OnDisconnected() final;
void Create(mojom::CdmServiceRequest request);
void Create(mojo::PendingReceiver<mojom::CdmService> receiver);
// mojom::CdmService implementation.
#if defined(OS_MACOSX)
......@@ -98,7 +99,7 @@ class MEDIA_MOJO_EXPORT CdmService : public service_manager::Service,
std::unique_ptr<CdmFactory> cdm_factory_;
DeferredDestroyStrongBindingSet<mojom::CdmFactory> cdm_factory_bindings_;
service_manager::BinderRegistry registry_;
mojo::BindingSet<mojom::CdmService> bindings_;
mojo::ReceiverSet<mojom::CdmService> receivers_;
DISALLOW_COPY_AND_ASSIGN(CdmService);
};
......
......@@ -7,8 +7,11 @@
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "media/cdm/api/content_decryption_module.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -41,24 +44,25 @@ class MockCdmFile : public mojom::CdmFile {
class MockCdmStorage : public mojom::CdmStorage {
public:
MockCdmStorage(mojom::CdmStorageRequest request, MockCdmFile* cdm_file)
: binding_(this, std::move(request)), client_binding_(cdm_file) {}
MockCdmStorage(mojo::PendingReceiver<mojom::CdmStorage> receiver,
MockCdmFile* cdm_file)
: receiver_(this, std::move(receiver)), client_receiver_(cdm_file) {}
~MockCdmStorage() override = default;
// MojoCdmFileIO calls CdmStorage::Open() to open the file. Requests always
// MojoCdmFileIO calls CdmStorage::Open() to open the file. Receivers always
// succeed.
void Open(const std::string& file_name, OpenCallback callback) override {
mojom::CdmFileAssociatedPtrInfo client_ptr_info;
client_binding_.Bind(mojo::MakeRequest(&client_ptr_info));
mojo::PendingAssociatedRemote<mojom::CdmFile> client_remote;
client_receiver_.Bind(client_remote.InitWithNewEndpointAndPassReceiver());
std::move(callback).Run(mojom::CdmStorage::Status::kSuccess,
std::move(client_ptr_info));
std::move(client_remote));
base::RunLoop().RunUntilIdle();
}
private:
mojo::Binding<mojom::CdmStorage> binding_;
mojo::AssociatedBinding<mojom::CdmFile> client_binding_;
mojo::Receiver<mojom::CdmStorage> receiver_;
mojo::AssociatedReceiver<mojom::CdmFile> client_receiver_;
};
} // namespace
......@@ -75,12 +79,11 @@ class MojoCdmFileIOTest : public testing::Test, public MojoCdmFileIO::Delegate {
void SetUp() override {
client_ = std::make_unique<MockFileIOClient>();
auto request = mojo::MakeRequest(&cdm_storage_ptr_);
cdm_storage_ =
std::make_unique<MockCdmStorage>(std::move(request), &cdm_file_);
cdm_storage_ = std::make_unique<MockCdmStorage>(
cdm_storage_remote_.BindNewPipeAndPassReceiver(), &cdm_file_);
file_io_ = std::make_unique<MojoCdmFileIO>(this, client_.get(),
cdm_storage_ptr_.get());
cdm_storage_remote_.get());
}
// MojoCdmFileIO::Delegate implementation.
......@@ -94,7 +97,7 @@ class MojoCdmFileIOTest : public testing::Test, public MojoCdmFileIO::Delegate {
base::test::TaskEnvironment task_environment_;
std::unique_ptr<MojoCdmFileIO> file_io_;
std::unique_ptr<MockFileIOClient> client_;
mojom::CdmStoragePtr cdm_storage_ptr_;
mojo::Remote<mojom::CdmStorage> cdm_storage_remote_;
std::unique_ptr<MockCdmStorage> cdm_storage_;
MockCdmFile cdm_file_;
};
......
......@@ -10,6 +10,7 @@
#include "media/mojo/services/mojo_cdm_allocator.h"
#include "media/mojo/services/mojo_cdm_file_io.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/service_manager/public/cpp/connect.h"
namespace media {
......@@ -29,7 +30,7 @@ cdm::FileIO* MojoCdmHelper::CreateCdmFileIO(cdm::FileIOClient* client) {
// Pass a reference to CdmStorage so that MojoCdmFileIO can open a file.
auto mojo_cdm_file_io =
std::make_unique<MojoCdmFileIO>(this, client, cdm_storage_ptr_.get());
std::make_unique<MojoCdmFileIO>(this, client, cdm_storage_remote_.get());
cdm::FileIO* cdm_file_io = mojo_cdm_file_io.get();
DVLOG(3) << __func__ << ": cdm_file_io = " << cdm_file_io;
......@@ -46,10 +47,11 @@ cdm::CdmProxy* MojoCdmHelper::CreateCdmProxy(cdm::CdmProxyClient* client) {
return nullptr;
}
mojom::CdmProxyPtr cdm_proxy_ptr;
service_manager::GetInterface<mojom::CdmProxy>(interface_provider_,
&cdm_proxy_ptr);
cdm_proxy_ = std::make_unique<MojoCdmProxy>(std::move(cdm_proxy_ptr), client);
mojo::PendingRemote<mojom::CdmProxy> cdm_proxy_remote;
service_manager::GetInterface<mojom::CdmProxy>(
interface_provider_, cdm_proxy_remote.InitWithNewPipeAndPassReceiver());
cdm_proxy_ =
std::make_unique<MojoCdmProxy>(std::move(cdm_proxy_remote), client);
return cdm_proxy_.get();
}
......@@ -114,9 +116,9 @@ void MojoCdmHelper::ReportFileReadSize(int file_size_bytes) {
}
void MojoCdmHelper::ConnectToCdmStorage() {
if (!cdm_storage_ptr_) {
service_manager::GetInterface<mojom::CdmStorage>(interface_provider_,
&cdm_storage_ptr_);
if (!cdm_storage_remote_) {
service_manager::GetInterface<mojom::CdmStorage>(
interface_provider_, cdm_storage_remote_.BindNewPipeAndPassReceiver());
}
}
......@@ -128,9 +130,8 @@ CdmAllocator* MojoCdmHelper::GetAllocator() {
void MojoCdmHelper::ConnectToOutputProtection() {
if (!output_protection_) {
interface_provider_->GetInterface(
mojom::OutputProtection::Name_,
output_protection_.BindNewPipeAndPassReceiver().PassPipe());
service_manager::GetInterface<mojom::OutputProtection>(
interface_provider_, output_protection_.BindNewPipeAndPassReceiver());
}
}
......
......@@ -72,7 +72,7 @@ class MEDIA_MOJO_EXPORT MojoCdmHelper final : public CdmAuxiliaryHelper,
// connection error occurs, we will not be able to reconnect to the
// service as the document has been destroyed (see FrameServiceBase) or
// the browser crashed, so there's no point in trying to reconnect.
mojom::CdmStoragePtr cdm_storage_ptr_;
mojo::Remote<mojom::CdmStorage> cdm_storage_remote_;
std::unique_ptr<CdmAllocator> allocator_;
mojo::Remote<mojom::OutputProtection> output_protection_;
mojo::Remote<mojom::PlatformVerification> platform_verification_;
......
......@@ -76,9 +76,10 @@ CdmProxy::KeyType ToMediaKeyType(cdm::CdmProxy::KeyType key_type) {
} // namespace
MojoCdmProxy::MojoCdmProxy(mojom::CdmProxyPtr cdm_proxy_ptr,
MojoCdmProxy::MojoCdmProxy(
mojo::PendingRemote<mojom::CdmProxy> cdm_proxy_remote,
cdm::CdmProxyClient* client)
: cdm_proxy_ptr_(std::move(cdm_proxy_ptr)),
: cdm_proxy_remote_(std::move(cdm_proxy_remote)),
client_(client),
client_binding_(this) {
DVLOG(1) << __func__;
......@@ -99,7 +100,8 @@ void MojoCdmProxy::Initialize() {
base::BindOnce(&MojoCdmProxy::OnInitialized, weak_factory_.GetWeakPtr()),
media::CdmProxy::Status::kFail, media::CdmProxy::Protocol::kNone, 0,
CdmContext::kInvalidCdmId);
cdm_proxy_ptr_->Initialize(std::move(client_ptr_info), std::move(callback));
cdm_proxy_remote_->Initialize(std::move(client_ptr_info),
std::move(callback));
}
void MojoCdmProxy::Process(Function function,
......@@ -114,7 +116,7 @@ void MojoCdmProxy::Process(Function function,
base::BindOnce(&MojoCdmProxy::OnProcessed, weak_factory_.GetWeakPtr()),
media::CdmProxy::Status::kFail, std::vector<uint8_t>());
cdm_proxy_ptr_->Process(
cdm_proxy_remote_->Process(
ToMediaFunction(function), crypto_session_id,
std::vector<uint8_t>(input_data, input_data + input_data_size),
expected_output_data_size, std::move(callback));
......@@ -130,7 +132,7 @@ void MojoCdmProxy::CreateMediaCryptoSession(const uint8_t* input_data,
weak_factory_.GetWeakPtr()),
media::CdmProxy::Status::kFail, 0, 0);
cdm_proxy_ptr_->CreateMediaCryptoSession(
cdm_proxy_remote_->CreateMediaCryptoSession(
std::vector<uint8_t>(input_data, input_data + input_data_size),
std::move(callback));
}
......@@ -148,7 +150,7 @@ void MojoCdmProxy::SetKey(uint32_t crypto_session_id,
base::BindOnce(&MojoCdmProxy::OnKeySet, weak_factory_.GetWeakPtr()),
media::CdmProxy::Status::kFail);
cdm_proxy_ptr_->SetKey(
cdm_proxy_remote_->SetKey(
crypto_session_id, std::vector<uint8_t>(key_id, key_id + key_id_size),
ToMediaKeyType(key_type),
std::vector<uint8_t>(key_blob, key_blob + key_blob_size),
......@@ -165,8 +167,8 @@ void MojoCdmProxy::RemoveKey(uint32_t crypto_session_id,
base::BindOnce(&MojoCdmProxy::OnKeyRemoved, weak_factory_.GetWeakPtr()),
media::CdmProxy::Status::kFail);
cdm_proxy_ptr_->RemoveKey(crypto_session_id,
std::vector<uint8_t>(key_id, key_id + key_id_size),
cdm_proxy_remote_->RemoveKey(
crypto_session_id, std::vector<uint8_t>(key_id, key_id + key_id_size),
std::move(callback));
}
......
......@@ -16,6 +16,8 @@
#include "media/mojo/mojom/cdm_proxy.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/bindings/associated_binding.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media {
......@@ -23,7 +25,8 @@ namespace media {
class MEDIA_MOJO_EXPORT MojoCdmProxy : public cdm::CdmProxy,
mojom::CdmProxyClient {
public:
MojoCdmProxy(mojom::CdmProxyPtr cdm_proxy_ptr, cdm::CdmProxyClient* client);
MojoCdmProxy(mojo::PendingRemote<mojom::CdmProxy> cdm_proxy_remote,
cdm::CdmProxyClient* client);
~MojoCdmProxy() override;
// cdm::CdmProxy implementation.
......@@ -64,7 +67,7 @@ class MEDIA_MOJO_EXPORT MojoCdmProxy : public cdm::CdmProxy,
void OnKeySet(media::CdmProxy::Status status);
void OnKeyRemoved(media::CdmProxy::Status status);
mojom::CdmProxyPtr cdm_proxy_ptr_;
mojo::Remote<mojom::CdmProxy> cdm_proxy_remote_;
cdm::CdmProxyClient* client_;
mojo::AssociatedBinding<mojom::CdmProxyClient> client_binding_;
......
......@@ -21,6 +21,7 @@
#include "media/mojo/services/mojo_cdm_service_context.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
......@@ -118,9 +119,10 @@ class MojoCdmProxyTest : public ::testing::Test {
MojoCdmProxyTest() {
// Client side setup.
mojom::CdmProxyPtr cdm_proxy_ptr;
auto request = mojo::MakeRequest(&cdm_proxy_ptr);
mojo_cdm_proxy_.reset(new MojoCdmProxy(std::move(cdm_proxy_ptr), &client_));
mojo::PendingRemote<mojom::CdmProxy> cdm_proxy_remote;
auto receiver = cdm_proxy_remote.InitWithNewPipeAndPassReceiver();
mojo_cdm_proxy_.reset(
new MojoCdmProxy(std::move(cdm_proxy_remote), &client_));
cdm_proxy_ = mojo_cdm_proxy_.get();
// Service side setup.
......@@ -128,9 +130,9 @@ class MojoCdmProxyTest : public ::testing::Test {
mock_cdm_proxy_ = mock_cdm_proxy.get();
mojo_cdm_proxy_service_.reset(new MojoCdmProxyService(
std::move(mock_cdm_proxy), &mojo_cdm_service_context_));
binding_.reset(new mojo::Binding<mojom::CdmProxy>(
mojo_cdm_proxy_service_.get(), std::move(request)));
binding_->set_connection_error_handler(base::BindOnce(
receiver_.reset(new mojo::Receiver<mojom::CdmProxy>(
mojo_cdm_proxy_service_.get(), std::move(receiver)));
receiver_->set_disconnect_handler(base::BindOnce(
&MojoCdmProxyTest::OnConnectionError, base::Unretained(this)));
base::RunLoop().RunUntilIdle();
......@@ -261,7 +263,7 @@ class MojoCdmProxyTest : public ::testing::Test {
void OnConnectionError() { mojo_cdm_proxy_service_.reset(); }
void ForceConnectionError() {
binding_->CloseWithReason(2, "Test closed connection.");
receiver_->ResetWithReason(2, "Test closed connection.");
mojo_cdm_proxy_service_.reset();
base::RunLoop().RunUntilIdle();
}
......@@ -277,7 +279,7 @@ class MojoCdmProxyTest : public ::testing::Test {
// Service side members.
MojoCdmServiceContext mojo_cdm_service_context_;
std::unique_ptr<MojoCdmProxyService> mojo_cdm_proxy_service_;
std::unique_ptr<mojo::Binding<mojom::CdmProxy>> binding_;
std::unique_ptr<mojo::Receiver<mojom::CdmProxy>> receiver_;
MockCdmProxy* mock_cdm_proxy_ = nullptr;
// Media component side members.
......
......@@ -19,8 +19,8 @@ namespace media {
// never run. Handle connection error to make sure callbacks will always run.
MojoMediaDrmStorage::MojoMediaDrmStorage(
mojom::MediaDrmStoragePtr media_drm_storage_ptr)
: media_drm_storage_ptr_(std::move(media_drm_storage_ptr)) {
mojo::PendingRemote<mojom::MediaDrmStorage> media_drm_storage_remote)
: media_drm_storage_remote_(std::move(media_drm_storage_remote)) {
DVLOG(1) << __func__;
}
......@@ -28,14 +28,14 @@ MojoMediaDrmStorage::~MojoMediaDrmStorage() {}
void MojoMediaDrmStorage::Initialize(InitCB init_cb) {
DVLOG(1) << __func__;
media_drm_storage_ptr_->Initialize(
media_drm_storage_remote_->Initialize(
mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(init_cb), false,
base::nullopt));
}
void MojoMediaDrmStorage::OnProvisioned(ResultCB result_cb) {
DVLOG(1) << __func__;
media_drm_storage_ptr_->OnProvisioned(
media_drm_storage_remote_->OnProvisioned(
mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(result_cb), false));
}
......@@ -43,7 +43,7 @@ void MojoMediaDrmStorage::SavePersistentSession(const std::string& session_id,
const SessionData& session_data,
ResultCB result_cb) {
DVLOG(1) << __func__;
media_drm_storage_ptr_->SavePersistentSession(
media_drm_storage_remote_->SavePersistentSession(
session_id,
mojom::SessionData::New(session_data.key_set_id, session_data.mime_type,
session_data.key_type),
......@@ -54,7 +54,7 @@ void MojoMediaDrmStorage::LoadPersistentSession(
const std::string& session_id,
LoadPersistentSessionCB load_persistent_session_cb) {
DVLOG(1) << __func__;
media_drm_storage_ptr_->LoadPersistentSession(
media_drm_storage_remote_->LoadPersistentSession(
session_id,
mojo::WrapCallbackWithDefaultInvokeIfNotRun(
base::BindOnce(&MojoMediaDrmStorage::OnPersistentSessionLoaded,
......@@ -66,7 +66,7 @@ void MojoMediaDrmStorage::LoadPersistentSession(
void MojoMediaDrmStorage::RemovePersistentSession(const std::string& session_id,
ResultCB result_cb) {
DVLOG(1) << __func__;
media_drm_storage_ptr_->RemovePersistentSession(
media_drm_storage_remote_->RemovePersistentSession(
session_id,
mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(result_cb), false));
}
......
......@@ -13,13 +13,17 @@
#include "media/base/android/media_drm_storage.h"
#include "media/mojo/mojom/media_drm_storage.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media {
// A MediaDrmStorage that proxies to a mojom::MediaDrmStoragePtr.
// A MediaDrmStorage that proxies to a
// mojo::PendingRemote<mojom::MediaDrmStorage>.
class MEDIA_MOJO_EXPORT MojoMediaDrmStorage : public MediaDrmStorage {
public:
explicit MojoMediaDrmStorage(mojom::MediaDrmStoragePtr media_drm_storage_ptr);
explicit MojoMediaDrmStorage(
mojo::PendingRemote<mojom::MediaDrmStorage> media_drm_storage_remote);
~MojoMediaDrmStorage() final;
// MediaDrmStorage implementation:
......@@ -39,7 +43,7 @@ class MEDIA_MOJO_EXPORT MojoMediaDrmStorage : public MediaDrmStorage {
LoadPersistentSessionCB load_persistent_session_cb,
mojom::SessionDataPtr session_data);
mojom::MediaDrmStoragePtr media_drm_storage_ptr_;
mojo::Remote<mojom::MediaDrmStorage> media_drm_storage_remote_;
base::WeakPtrFactory<MojoMediaDrmStorage> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(MojoMediaDrmStorage);
......
......@@ -9,8 +9,8 @@
namespace media {
MojoProvisionFetcher::MojoProvisionFetcher(
mojom::ProvisionFetcherPtr provision_fetcher_ptr)
: provision_fetcher_ptr_(std::move(provision_fetcher_ptr)) {
mojo::PendingRemote<mojom::ProvisionFetcher> provision_fetcher_remote)
: provision_fetcher_remote_(std::move(provision_fetcher_remote)) {
DVLOG(1) << __func__;
}
......@@ -21,7 +21,7 @@ void MojoProvisionFetcher::Retrieve(const std::string& default_url,
const std::string& request_data,
const ResponseCB& response_cb) {
DVLOG(1) << __func__;
provision_fetcher_ptr_->Retrieve(
provision_fetcher_remote_->Retrieve(
default_url, request_data,
base::Bind(&MojoProvisionFetcher::OnResponse, weak_factory_.GetWeakPtr(),
response_cb));
......
......@@ -11,14 +11,17 @@
#include "media/base/provision_fetcher.h"
#include "media/mojo/mojom/provision_fetcher.mojom.h"
#include "media/mojo/services/media_mojo_export.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace media {
// A ProvisionFetcher that proxies to a mojom::ProvisionFetcherPtr.
// A ProvisionFetcher that proxies to a
// mojo::PendingRemote<mojom::ProvisionFetcher>.
class MEDIA_MOJO_EXPORT MojoProvisionFetcher : public ProvisionFetcher {
public:
explicit MojoProvisionFetcher(
mojom::ProvisionFetcherPtr provision_fetcher_ptr);
mojo::PendingRemote<mojom::ProvisionFetcher> provision_fetcher_remote);
~MojoProvisionFetcher() final;
// ProvisionFetcher implementation:
......@@ -32,7 +35,7 @@ class MEDIA_MOJO_EXPORT MojoProvisionFetcher : public ProvisionFetcher {
bool success,
const std::string& response);
mojom::ProvisionFetcherPtr provision_fetcher_ptr_;
mojo::Remote<mojom::ProvisionFetcher> provision_fetcher_remote_;
base::WeakPtrFactory<MojoProvisionFetcher> weak_factory_{this};
......
......@@ -11,13 +11,11 @@
namespace service_manager {
// Binds |ptr| to a remote implementation of Interface from |interfaces|.
// Binds |receiver| to a remote implementation of Interface from |interfaces|.
template <typename Interface>
inline void GetInterface(mojom::InterfaceProvider* interfaces,
mojo::InterfacePtr<Interface>* ptr) {
mojo::MessagePipe pipe;
ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u));
interfaces->GetInterface(Interface::Name_, std::move(pipe.handle1));
mojo::PendingReceiver<Interface> receiver) {
interfaces->GetInterface(Interface::Name_, receiver.PassPipe());
}
} // namespace service_manager
......
......@@ -73,15 +73,15 @@ BinderOverrides& GetBinderOverrides() {
} // namespace
ServiceBinding::ServiceBinding(service_manager::Service* service)
: service_(service), binding_(this) {
: service_(service) {
DCHECK(service_);
}
ServiceBinding::ServiceBinding(service_manager::Service* service,
mojom::ServiceRequest request)
mojo::PendingReceiver<mojom::Service> receiver)
: ServiceBinding(service) {
if (request.is_pending())
Bind(std::move(request));
if (receiver.is_valid())
Bind(std::move(receiver));
}
ServiceBinding::~ServiceBinding() = default;
......@@ -92,10 +92,10 @@ Connector* ServiceBinding::GetConnector() {
return connector_.get();
}
void ServiceBinding::Bind(mojom::ServiceRequest request) {
void ServiceBinding::Bind(mojo::PendingReceiver<mojom::Service> receiver) {
DCHECK(!is_bound());
binding_.Bind(std::move(request));
binding_.set_connection_error_handler(base::BindOnce(
receiver_.Bind(std::move(receiver));
receiver_.set_disconnect_handler(base::BindOnce(
&ServiceBinding::OnConnectionError, base::Unretained(this)));
}
......@@ -114,7 +114,7 @@ void ServiceBinding::RequestClose() {
void ServiceBinding::Close() {
DCHECK(is_bound());
binding_.Close();
receiver_.reset();
service_control_.reset();
connector_.reset();
}
......
......@@ -12,10 +12,10 @@
#include "base/component_export.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/binding_set.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/receiver_set.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/mojom/connector.mojom.h"
#include "services/service_manager/public/mojom/service.mojom.h"
......@@ -31,7 +31,7 @@ class Service;
// can use to make outgoing interface requests.
//
// A ServiceBinding is considered to be "bound" after |Bind()| is invoked with a
// valid ServiceRequest (or the equivalent constructor is used -- see below).
// valid Service receiver (or the equivalent constructor is used -- see below).
// Upon connection error or an explicit call to |Close()|, the ServiceBinding
// will be considered "unbound" until another call to |Bind()| is made.
//
......@@ -54,14 +54,14 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_CPP) ServiceBinding
// |service| is not owned and must outlive this ServiceBinding.
explicit ServiceBinding(service_manager::Service* service);
// Same as above, but behaves as if |Bind(request)| is also called immediately
// after construction. See below.
// Same as above, but behaves as if |Bind(receiver)| is also called
// immediately after construction. See below.
ServiceBinding(service_manager::Service* service,
mojom::ServiceRequest request);
mojo::PendingReceiver<mojom::Service> receiver);
~ServiceBinding() override;
bool is_bound() const { return binding_.is_bound(); }
bool is_bound() const { return receiver_.is_bound(); }
const Identity& identity() const { return identity_; }
......@@ -69,7 +69,7 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_CPP) ServiceBinding
// identifying as the service to which this ServiceBinding is bound.
Connector* GetConnector();
// Binds this ServiceBinding to a new ServiceRequest. Once a ServiceBinding
// Binds this ServiceBinding to a new Service receiver. Once a ServiceBinding
// is bound, its target Service will begin receiving Service events. The
// order of events received is:
//
......@@ -80,10 +80,10 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_CPP) ServiceBinding
// The target Service will be able to receive these events until this
// ServiceBinding is either unbound or destroyed.
//
// If |request| is invalid, this call does nothing.
// If |receiver| is invalid, this call does nothing.
//
// Must only be called on an unbound ServiceBinding.
void Bind(mojom::ServiceRequest request);
void Bind(mojo::PendingReceiver<mojom::Service> receiver);
// Asks the Service Manager nicely if it's OK for this service instance to
// disappear now. If the Service Manager thinks it's OK, it will sever the
......@@ -179,10 +179,10 @@ class COMPONENT_EXPORT(SERVICE_MANAGER_CPP) ServiceBinding
// A pending Connector request which will eventually be passed to the Service
// Manager. Created preemptively by every unbound ServiceBinding so that
// |connector()| may begin pipelining outgoing requests even before the
// ServiceBinding is bound to a ServiceRequest.
// ServiceBinding is bound to a Service receiver.
mojom::ConnectorRequest pending_connector_request_;
mojo::Binding<mojom::Service> binding_;
mojo::Receiver<mojom::Service> receiver_{this};
Identity identity_;
std::unique_ptr<Connector> connector_;
......
......@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/test/test_connector_factory.h"
#include "services/tracing/public/cpp/perfetto/perfetto_config.h"
......
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