Commit 0fdaa08c authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Convert mojom::ContentDecryptionModulePtr to new Mojo type

This CL converts |remote_cdm_| member variable to mojo::Remote
in MojoCdm class. As the change, this CL also converts related
things as well.

  - Convert mojo::StrongBindingSet to mojo::UniqueReceiverSet

TBR=xhwang@chromium.org

Bug: 955171
Change-Id: Id8f8e13fab7658ec6a94187febf9fcdad342340c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1841596Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#705902}
parent d44d57b6
...@@ -41,7 +41,7 @@ void MojoCdm::Create( ...@@ -41,7 +41,7 @@ void MojoCdm::Create(
const std::string& key_system, const std::string& key_system,
const url::Origin& security_origin, const url::Origin& security_origin,
const CdmConfig& cdm_config, const CdmConfig& cdm_config,
mojom::ContentDecryptionModulePtr remote_cdm, mojo::PendingRemote<mojom::ContentDecryptionModule> remote_cdm,
mojom::InterfaceFactory* interface_factory, mojom::InterfaceFactory* interface_factory,
const SessionMessageCB& session_message_cb, const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb, const SessionClosedCB& session_closed_cb,
...@@ -60,7 +60,7 @@ void MojoCdm::Create( ...@@ -60,7 +60,7 @@ void MojoCdm::Create(
std::move(promise)); std::move(promise));
} }
MojoCdm::MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm, MojoCdm::MojoCdm(mojo::PendingRemote<mojom::ContentDecryptionModule> remote_cdm,
mojom::InterfaceFactory* interface_factory, mojom::InterfaceFactory* interface_factory,
const SessionMessageCB& session_message_cb, const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb, const SessionClosedCB& session_closed_cb,
...@@ -116,7 +116,7 @@ void MojoCdm::InitializeCdm(const std::string& key_system, ...@@ -116,7 +116,7 @@ void MojoCdm::InitializeCdm(const std::string& key_system,
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// If connection error has happened, fail immediately. // If connection error has happened, fail immediately.
if (remote_cdm_.encountered_error()) { if (!remote_cdm_.is_connected()) {
LOG(ERROR) << "Remote CDM encountered error."; LOG(ERROR) << "Remote CDM encountered error.";
promise->reject(CdmPromise::Exception::INVALID_STATE_ERROR, 0, promise->reject(CdmPromise::Exception::INVALID_STATE_ERROR, 0,
"Mojo CDM creation failed."); "Mojo CDM creation failed.");
...@@ -127,7 +127,7 @@ void MojoCdm::InitializeCdm(const std::string& key_system, ...@@ -127,7 +127,7 @@ void MojoCdm::InitializeCdm(const std::string& key_system,
RecordConnectionError(false); RecordConnectionError(false);
// Otherwise, set an error handler to catch the connection error. // Otherwise, set an error handler to catch the connection error.
remote_cdm_.set_connection_error_with_reason_handler( remote_cdm_.set_disconnect_with_reason_handler(
base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this))); base::Bind(&MojoCdm::OnConnectionError, base::Unretained(this)));
pending_init_promise_ = std::move(promise); pending_init_promise_ = std::move(promise);
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "media/mojo/mojom/content_decryption_module.mojom.h" #include "media/mojo/mojom/content_decryption_module.mojom.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.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/remote.h"
namespace base { namespace base {
class SingleThreadTaskRunner; class SingleThreadTaskRunner;
...@@ -53,7 +55,7 @@ class MojoCdm : public ContentDecryptionModule, ...@@ -53,7 +55,7 @@ class MojoCdm : public ContentDecryptionModule,
const std::string& key_system, const std::string& key_system,
const url::Origin& security_origin, const url::Origin& security_origin,
const CdmConfig& cdm_config, const CdmConfig& cdm_config,
mojom::ContentDecryptionModulePtr remote_cdm, mojo::PendingRemote<mojom::ContentDecryptionModule> remote_cdm,
mojom::InterfaceFactory* interface_factory, mojom::InterfaceFactory* interface_factory,
const SessionMessageCB& session_message_cb, const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb, const SessionClosedCB& session_closed_cb,
...@@ -89,7 +91,7 @@ class MojoCdm : public ContentDecryptionModule, ...@@ -89,7 +91,7 @@ class MojoCdm : public ContentDecryptionModule,
int GetCdmId() const final; int GetCdmId() const final;
private: private:
MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm, MojoCdm(mojo::PendingRemote<mojom::ContentDecryptionModule> remote_cdm,
mojom::InterfaceFactory* interface_factory, mojom::InterfaceFactory* interface_factory,
const SessionMessageCB& session_message_cb, const SessionMessageCB& session_message_cb,
const SessionClosedCB& session_closed_cb, const SessionClosedCB& session_closed_cb,
...@@ -138,7 +140,7 @@ class MojoCdm : public ContentDecryptionModule, ...@@ -138,7 +140,7 @@ class MojoCdm : public ContentDecryptionModule,
THREAD_CHECKER(thread_checker_); THREAD_CHECKER(thread_checker_);
mojom::ContentDecryptionModulePtr remote_cdm_; mojo::Remote<mojom::ContentDecryptionModule> remote_cdm_;
mojom::InterfaceFactory* interface_factory_; mojom::InterfaceFactory* interface_factory_;
mojo::AssociatedBinding<ContentDecryptionModuleClient> client_binding_; mojo::AssociatedBinding<ContentDecryptionModuleClient> client_binding_;
......
...@@ -58,13 +58,14 @@ void MojoCdmFactory::Create( ...@@ -58,13 +58,14 @@ void MojoCdmFactory::Create(
return; return;
} }
mojom::ContentDecryptionModulePtr cdm_ptr; mojo::PendingRemote<mojom::ContentDecryptionModule> cdm_pending_remote;
interface_factory_->CreateCdm(key_system, mojo::MakeRequest(&cdm_ptr)); interface_factory_->CreateCdm(
key_system, cdm_pending_remote.InitWithNewPipeAndPassReceiver());
MojoCdm::Create(key_system, security_origin, cdm_config, std::move(cdm_ptr), MojoCdm::Create(key_system, security_origin, cdm_config,
interface_factory_, session_message_cb, session_closed_cb, std::move(cdm_pending_remote), interface_factory_,
session_keys_change_cb, session_expiration_update_cb, session_message_cb, session_closed_cb, session_keys_change_cb,
cdm_created_cb); session_expiration_update_cb, cdm_created_cb);
} }
} // namespace media } // namespace media
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "media/mojo/services/mojo_cdm_service.h" #include "media/mojo/services/mojo_cdm_service.h"
#include "media/mojo/services/mojo_cdm_service_context.h" #include "media/mojo/services/mojo_cdm_service_context.h"
#include "mojo/public/cpp/bindings/interface_request.h" #include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
#include "url/origin.h" #include "url/origin.h"
...@@ -80,10 +81,9 @@ class MojoCdmTest : public ::testing::Test { ...@@ -80,10 +81,9 @@ class MojoCdmTest : public ::testing::Test {
// TODO(xhwang): Add pending init support. // TODO(xhwang): Add pending init support.
DCHECK_NE(PENDING, expected_result); DCHECK_NE(PENDING, expected_result);
mojom::ContentDecryptionModulePtr remote_cdm; mojo::PendingRemote<mojom::ContentDecryptionModule> remote_cdm;
auto cdm_request = mojo::MakeRequest(&remote_cdm);
cdm_binding_.Bind(std::move(cdm_request)); cdm_binding_.Bind(remote_cdm.InitWithNewPipeAndPassReceiver());
std::string key_system; std::string key_system;
if (expected_result == CONNECTION_ERROR_BEFORE) { if (expected_result == CONNECTION_ERROR_BEFORE) {
......
...@@ -103,7 +103,7 @@ class CdmFactoryImpl : public DeferredDestroy<mojom::CdmFactory> { ...@@ -103,7 +103,7 @@ class CdmFactoryImpl : public DeferredDestroy<mojom::CdmFactory> {
std::move(destroy_cb_).Run(); std::move(destroy_cb_).Run();
} }
// Must be declared before the bindings below because the bound objects might // Must be declared before the receivers below because the bound objects might
// take a raw pointer of |cdm_service_context_| and assume it's always // take a raw pointer of |cdm_service_context_| and assume it's always
// available. // available.
MojoCdmServiceContext cdm_service_context_; MojoCdmServiceContext cdm_service_context_;
......
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