Commit b7b305f3 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

Add more checks in MojoCdmService

This is to prevent abnormal cases from happening.

Bug: 999311
Test: Tested w/ shaka player demo and existing unit tests pass
Change-Id: Icef06d979351f16386cf3cbb177971a57a1e264c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1777139
Auto-Submit: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691911}
parent ef83a628
......@@ -60,7 +60,9 @@ void MojoCdmService::Initialize(const std::string& key_system,
const CdmConfig& cdm_config,
InitializeCallback callback) {
DVLOG(1) << __func__ << ": " << key_system;
DCHECK(!cdm_);
CHECK(!has_initialize_been_called_) << "Initialize should only happen once";
has_initialize_been_called_ = true;
auto weak_this = weak_factory_.GetWeakPtr();
cdm_factory_->Create(
......@@ -154,6 +156,7 @@ void MojoCdmService::OnCdmCreated(
return;
}
CHECK(!cdm_) << "CDM should only be created once.";
cdm_ = cdm;
if (context_) {
......
......@@ -101,6 +101,8 @@ class MEDIA_MOJO_EXPORT MojoCdmService : public mojom::ContentDecryptionModule {
// Callback for when |decryptor_| loses connectivity.
void OnDecryptorConnectionError();
bool has_initialize_been_called_ = false;
CdmFactory* cdm_factory_;
MojoCdmServiceContext* const context_ = nullptr;
scoped_refptr<::media::ContentDecryptionModule> cdm_;
......
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