Commit 0f91d968 authored by John Rummell's avatar John Rummell Committed by Commit Bot

Enable MediaDrmOriginIdManager to start when profile is loaded

Update MediaDrmOriginIdManager so that when a profile is loaded it will
check if any more origin IDs need to be pre-provisioned, and if so
attempt to pre-provision them. This is enabled by a new base::Feature
"MediaDrmPreprovisioningAtStartup".

BUG=917527
TEST=new unit_tests pass

Change-Id: If0e51516bd0f4d348792230c5309e89bd2b3388d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1481111Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637950}
parent d7c9a582
......@@ -8,6 +8,7 @@
#include <utility>
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
......@@ -22,6 +23,7 @@
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/provision_fetcher_factory.h"
#include "media/base/android/media_drm_bridge.h"
#include "media/base/media_switches.h"
#include "media/base/provision_fetcher.h"
#include "services/network/public/cpp/network_connection_tracker.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
......@@ -313,6 +315,16 @@ MediaDrmOriginIdManager::MediaDrmOriginIdManager(PrefService* pref_service)
: pref_service_(pref_service), weak_factory_(this) {
DVLOG(1) << __func__;
DCHECK(pref_service_);
// This manager can be started when the user's profile is loaded, if
// |kMediaDrmPreprovisioningAtStartup| is enabled. In that case attempt to
// pre-provisioning origin IDs if needed. If this manager is only loaded when
// needed (|kMediaDrmPreprovisioningAtStartup| not enabled), then the caller
// is most likely going to call GetOriginId(), so let it pre-provision origin
// IDs if necessary. This flag is also used by testing so that it can check
// pre-provisioning directly.
if (base::FeatureList::IsEnabled(media::kMediaDrmPreprovisioningAtStartup))
PreProvisionIfNecessary();
}
MediaDrmOriginIdManager::~MediaDrmOriginIdManager() {
......
......@@ -6,11 +6,13 @@
#include <utility>
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/media/android/cdm/media_drm_origin_id_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "media/base/media_switches.h"
// static
MediaDrmOriginIdManager* MediaDrmOriginIdManagerFactory::GetForProfile(
......@@ -45,3 +47,12 @@ content::BrowserContext* MediaDrmOriginIdManagerFactory::GetBrowserContextToUse(
return context;
}
bool MediaDrmOriginIdManagerFactory::ServiceIsCreatedWithBrowserContext()
const {
// Create this service when the context is created if it should perform
// pre-provisioning at startup. Creation will end up calling
// GetBrowserContextToUse() above which returns NULL for incognito contexts,
// and thus no instance will be created for them.
return base::FeatureList::IsEnabled(media::kMediaDrmPreprovisioningAtStartup);
}
......@@ -36,6 +36,8 @@ class MediaDrmOriginIdManagerFactory
content::BrowserContext* GetBrowserContextToUse(
content::BrowserContext* context) const override;
bool ServiceIsCreatedWithBrowserContext() const override;
};
#endif // CHROME_BROWSER_MEDIA_ANDROID_CDM_MEDIA_DRM_ORIGIN_ID_MANAGER_FACTORY_H_
......@@ -382,10 +382,17 @@ const base::Feature kVideoRotateToFullscreen{"VideoRotateToFullscreen",
const base::Feature kMediaDrmPersistentLicense{
"MediaDrmPersistentLicense", base::FEATURE_ENABLED_BY_DEFAULT};
// Determines if MediaDrmOriginIdManager should attempt to pre-provision origin
// IDs at startup (whenever a profile is loaded). Also used by tests that
// disable it so that the tests can setup before pre-provisioning is done.
const base::Feature kMediaDrmPreprovisioningAtStartup{
"MediaDrmPreprovisioningAtStartup", base::FEATURE_DISABLED_BY_DEFAULT};
// Enables the Android Image Reader path for Video decoding(for AVDA and MCVD)
const base::Feature kAImageReaderVideoOutput{"AImageReaderVideoOutput",
base::FEATURE_DISABLED_BY_DEFAULT};
#endif
#endif // defined(OS_ANDROID)
#if defined(OS_WIN)
// Does NV12->NV12 video copy on the main thread right before the texture's
......
......@@ -143,6 +143,7 @@ MEDIA_EXPORT extern const base::Feature kMediaControlsExpandGesture;
MEDIA_EXPORT extern const base::Feature kVideoFullscreenOrientationLock;
MEDIA_EXPORT extern const base::Feature kVideoRotateToFullscreen;
MEDIA_EXPORT extern const base::Feature kMediaDrmPersistentLicense;
MEDIA_EXPORT extern const base::Feature kMediaDrmPreprovisioningAtStartup;
MEDIA_EXPORT extern const base::Feature kAImageReaderVideoOutput;
#endif // defined(OS_ANDROID)
......
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