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

media: Check CdmConfig in CdmAdapter

We used to have these checks in PpapiCdmAdapter, but they were lost when
we added media::CdmAdapter.

In summary:
- Only allow storage ID when |allow_persistent_state| is true.
- Only allow File IO when |allow_persistent_state| is true.
- Only allow platform challenge when |allow_distinctive_identifier| is
  true.

Also post tasks in CdmAdapter in failure cases to avoid reentrance into
the CDM instance.

this change. Filed crbug.com/836046 to refactor CdmAdapter and tests.

Test: The current CdmAdapterTest makes it harder to add unittest for
Bug: 510088,836046
Change-Id: I5a88c253a75a3af00f553681b65792198f31dba7
Reviewed-on: https://chromium-review.googlesource.com/1025220Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553373}
parent c06d6ca5
......@@ -50,6 +50,13 @@ constexpr int kSizeKBMin = 1;
constexpr int kSizeKBMax = 512 * 1024; // 512MB
constexpr int kSizeKBBuckets = 100;
// Only support version 1 of Storage Id. However, the "latest" version can also
// be requested.
constexpr uint32_t kRequestLatestStorageIdVersion = 0;
constexpr uint32_t kCurrentStorageIdVersion = 1;
static_assert(kCurrentStorageIdVersion < 0x80000000,
"Versions 0x80000000 and above are reserved.");
cdm::HdcpVersion ToCdmHdcpVersion(HdcpVersion hdcp_version) {
switch (hdcp_version) {
case media::HdcpVersion::kHdcpVersionNone:
......@@ -1024,6 +1031,14 @@ void CdmAdapter::SendPlatformChallenge(const char* service_id,
uint32_t challenge_size) {
DCHECK(task_runner_->BelongsToCurrentThread());
if (!cdm_config_.allow_distinctive_identifier) {
task_runner_->PostTask(
FROM_HERE,
base::BindRepeating(&CdmAdapter::OnChallengePlatformDone,
weak_factory_.GetWeakPtr(), false, "", "", ""));
return;
}
helper_->ChallengePlatform(std::string(service_id, service_id_size),
std::string(challenge, challenge_size),
base::Bind(&CdmAdapter::OnChallengePlatformDone,
......@@ -1166,13 +1181,25 @@ cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) {
DVLOG(3) << __func__;
DCHECK(task_runner_->BelongsToCurrentThread());
if (!cdm_config_.allow_persistent_state) {
DVLOG(1) << __func__ << ": Persistent state not allowed.";
return nullptr;
}
return helper_->CreateCdmFileIO(client);
}
void CdmAdapter::RequestStorageId(uint32_t version) {
if (version >= 0x80000000) {
// Versions 0x80000000 and above are reserved.
cdm_->OnStorageId(version, nullptr, 0);
if (!cdm_config_.allow_persistent_state ||
!(version == kCurrentStorageIdVersion ||
version == kRequestLatestStorageIdVersion)) {
DVLOG(1) << __func__ << ": Persistent state not allowed ("
<< cdm_config_.allow_persistent_state
<< ") or invalid storage ID version (" << version << ").";
task_runner_->PostTask(
FROM_HERE, base::BindRepeating(&CdmAdapter::OnStorageIdObtained,
weak_factory_.GetWeakPtr(), version,
std::vector<uint8_t>()));
return;
}
......
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