Skip to content

Commit

Permalink
Add testing feature to disable MediaDrm provisioning
Browse files Browse the repository at this point in the history
If the feature "FailUrlProvisionFetcherForTesting" is enabled,
all MediaDrm provisioning requests will not be sent to the provisioning
server and will respond as if the request failed.

BUG=954541
TEST=tested manually

Change-Id: I9606e05671d1ffaede8743a150ebe67cfbfb2836
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1576121
Commit-Queue: John Rummell <jrummell@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653329}
  • Loading branch information
jrummell-chromium authored and Commit Bot committed Apr 23, 2019
1 parent 6bce395 commit 1d58343
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ TEST_F(MediaDrmOriginIdManagerTest, DisablePreProvisioningAtStartup) {

EXPECT_FALSE(
base::FeatureList::IsEnabled(media::kMediaDrmPreprovisioningAtStartup));
EXPECT_FALSE(
base::FeatureList::IsEnabled(media::kFailUrlProvisionFetcherForTesting));

test_browser_thread_bundle_.RunUntilIdle();

Expand Down
8 changes: 8 additions & 0 deletions content/browser/media/url_provision_fetcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/bind.h"
#include "content/public/browser/provision_fetcher_factory.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/media_switches.h"
#include "net/base/load_flags.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
Expand All @@ -29,6 +30,13 @@ void URLProvisionFetcher::Retrieve(
const std::string& default_url,
const std::string& request_data,
const media::ProvisionFetcher::ResponseCB& response_cb) {
// For testing, don't actually do provisioning if the feature is enabled,
// just indicate that the request failed.
if (base::FeatureList::IsEnabled(media::kFailUrlProvisionFetcherForTesting)) {
response_cb.Run(false, std::string());
return;
}

response_cb_ = response_cb;

const std::string request_string =
Expand Down
7 changes: 7 additions & 0 deletions media/base/media_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ const base::Feature kVideoBlitColorAccuracy{"video-blit-color-accuracy",
const base::Feature kExternalClearKeyForTesting{
"ExternalClearKeyForTesting", base::FEATURE_DISABLED_BY_DEFAULT};

// Prevents UrlProvisionFetcher from making a provisioning request. If
// specified, any provisioning request made will not be sent to the provisioning
// server, and the response will indicate a failure to communicate with the
// provisioning server.
const base::Feature kFailUrlProvisionFetcherForTesting{
"FailUrlProvisionFetcherForTesting", base::FEATURE_DISABLED_BY_DEFAULT};

// Enables hardware secure decryption if supported by hardware and CDM.
// TODO(xhwang): Currently this is only used for development of new features.
// Apply this to Android and ChromeOS as well where hardware secure decryption
Expand Down
1 change: 1 addition & 0 deletions media/base/media_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ MEDIA_EXPORT extern const base::Feature kBackgroundVideoPauseOptimization;
MEDIA_EXPORT extern const base::Feature kD3D11VideoDecoder;
MEDIA_EXPORT extern const base::Feature kD3D11VideoDecoderIgnoreWorkarounds;
MEDIA_EXPORT extern const base::Feature kExternalClearKeyForTesting;
MEDIA_EXPORT extern const base::Feature kFailUrlProvisionFetcherForTesting;
MEDIA_EXPORT extern const base::Feature kFallbackAfterDecodeError;
MEDIA_EXPORT extern const base::Feature kHardwareMediaKeyHandling;
MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryption;
Expand Down

0 comments on commit 1d58343

Please sign in to comment.