Commit 4baa0eb8 authored by John Rummell's avatar John Rummell Committed by Commit Bot

Don't attempt to provision if no system_network_context_manager

When running unit_tests there is no system_network_context_manager
available, so provisioning can't take place. If that is the case then
don't attempt to provision an origin ID.

Tested this with an Android emulator. Without this change 9 of the
OptimizationGuideHintsManagerTest unit_tests failed, and all pass after
this change applied.

Bug: 1018052
Test: see above
Change-Id: Ic3733014c00fc48d1b6860142f08daffcf3d8391
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881950Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710052}
parent b5a95dae
...@@ -208,18 +208,26 @@ class MediaDrmProvisionHelper { ...@@ -208,18 +208,26 @@ class MediaDrmProvisionHelper {
MediaDrmProvisionHelper() { MediaDrmProvisionHelper() {
DVLOG(1) << __func__; DVLOG(1) << __func__;
DCHECK(media::MediaDrmBridge::IsPerOriginProvisioningSupported()); DCHECK(media::MediaDrmBridge::IsPerOriginProvisioningSupported());
create_fetcher_cb_ =
base::BindRepeating(&content::CreateProvisionFetcher,
g_browser_process->system_network_context_manager()
->GetSharedURLLoaderFactory());
} }
void Provision(ProvisionedOriginIdCB callback) { void Provision(ProvisionedOriginIdCB callback) {
DVLOG(1) << __func__; DVLOG(1) << __func__;
auto* network_context_manager =
g_browser_process->system_network_context_manager();
if (!network_context_manager) {
// system_network_context_manager() returns nullptr in unit tests.
DLOG(WARNING) << "Failed to provision origin ID as no "
"system_network_context_manager";
std::move(callback).Run(false, base::nullopt);
return;
}
complete_callback_ = std::move(callback); complete_callback_ = std::move(callback);
origin_id_ = base::UnguessableToken::Create(); origin_id_ = base::UnguessableToken::Create();
create_fetcher_cb_ = base::BindRepeating(
&content::CreateProvisionFetcher,
network_context_manager->GetSharedURLLoaderFactory());
// Try provisioning for L3 first. // Try provisioning for L3 first.
media_drm_bridge_ = media::MediaDrmBridge::CreateWithoutSessionSupport( media_drm_bridge_ = media::MediaDrmBridge::CreateWithoutSessionSupport(
......
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