0

Migrate t/b/{public,renderer}/platform/media to blink ns [5/6]

This CL is a follow-up to https://crrev.com/c/2847359 and
https://crrev.com/c/2925475.

The code moved from media/blink/ to Blink should use the blink
namespace. This CL removes redundant blink:: prefixes from code in
third_party/blink/renderer/platform/media/.

Bug: 1198341
Change-Id: I45b22f1db5dc4d6bb790e647b95f7acc21057c12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2925376
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: Will Cassella <cassew@google.com>
Cr-Commit-Position: refs/heads/master@{#901030}
This commit is contained in:
Henrique Ferreiro
2021-07-13 15:52:49 +00:00
committed by Chromium LUCI CQ
parent c7071ba573
commit 850efea87a
39 changed files with 544 additions and 590 deletions

@ -31,14 +31,14 @@ enum UncacheableReason {
// Return the logical OR of the reasons "response" cannot be used for a future
// request (using the disk cache), or 0 if it might be useful.
PLATFORM_EXPORT uint32_t
GetReasonsForUncacheability(const blink::WebURLResponse& response);
GetReasonsForUncacheability(const WebURLResponse& response);
// Returns when we should evict data from this response from our
// memory cache. Note that we may still cache data longer if
// a audio/video tag is currently using it. Returns a TimeDelta
// which is should be added to base::Time::Now() or base::TimeTicks::Now().
PLATFORM_EXPORT base::TimeDelta GetCacheValidUntil(
const blink::WebURLResponse& response);
const WebURLResponse& response);
} // namespace blink

@ -29,7 +29,7 @@ template <typename... T>
class PLATFORM_EXPORT CdmResultPromise
: public media::CdmPromiseTemplate<T...> {
public:
CdmResultPromise(const blink::WebContentDecryptionModuleResult& result,
CdmResultPromise(const WebContentDecryptionModuleResult& result,
const std::string& key_system_uma_prefix,
const std::string& uma_name);
CdmResultPromise(const CdmResultPromise&) = delete;
@ -47,7 +47,7 @@ class PLATFORM_EXPORT CdmResultPromise
using media::CdmPromiseTemplate<T...>::MarkPromiseSettled;
using media::CdmPromiseTemplate<T...>::RejectPromiseOnDestruction;
blink::WebContentDecryptionModuleResult web_cdm_result_;
WebContentDecryptionModuleResult web_cdm_result_;
// UMA prefix and name to report result and time to.
std::string key_system_uma_prefix_;
@ -59,7 +59,7 @@ class PLATFORM_EXPORT CdmResultPromise
template <typename... T>
CdmResultPromise<T...>::CdmResultPromise(
const blink::WebContentDecryptionModuleResult& result,
const WebContentDecryptionModuleResult& result,
const std::string& key_system_uma_prefix,
const std::string& uma_name)
: web_cdm_result_(result),
@ -112,7 +112,7 @@ void CdmResultPromise<T...>::reject(media::CdmPromise::Exception exception_code,
ConvertCdmExceptionToResultForUMA(exception_code));
web_cdm_result_.CompleteWithError(ConvertCdmException(exception_code),
system_code,
blink::WebString::FromUTF8(error_message));
WebString::FromUTF8(error_message));
}
} // namespace blink

@ -25,44 +25,42 @@ CdmResultForUMA ConvertCdmExceptionToResultForUMA(
return INVALID_STATE_ERROR;
}
blink::WebContentDecryptionModuleException ConvertCdmException(
WebContentDecryptionModuleException ConvertCdmException(
media::CdmPromise::Exception exception_code) {
switch (exception_code) {
case media::CdmPromise::Exception::NOT_SUPPORTED_ERROR:
return blink::kWebContentDecryptionModuleExceptionNotSupportedError;
return kWebContentDecryptionModuleExceptionNotSupportedError;
case media::CdmPromise::Exception::INVALID_STATE_ERROR:
return blink::kWebContentDecryptionModuleExceptionInvalidStateError;
return kWebContentDecryptionModuleExceptionInvalidStateError;
case media::CdmPromise::Exception::QUOTA_EXCEEDED_ERROR:
return blink::kWebContentDecryptionModuleExceptionQuotaExceededError;
return kWebContentDecryptionModuleExceptionQuotaExceededError;
case media::CdmPromise::Exception::TYPE_ERROR:
return blink::kWebContentDecryptionModuleExceptionTypeError;
return kWebContentDecryptionModuleExceptionTypeError;
}
NOTREACHED();
return blink::kWebContentDecryptionModuleExceptionInvalidStateError;
return kWebContentDecryptionModuleExceptionInvalidStateError;
}
blink::WebEncryptedMediaKeyInformation::KeyStatus ConvertCdmKeyStatus(
WebEncryptedMediaKeyInformation::KeyStatus ConvertCdmKeyStatus(
media::CdmKeyInformation::KeyStatus key_status) {
switch (key_status) {
case media::CdmKeyInformation::USABLE:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::kUsable;
return WebEncryptedMediaKeyInformation::KeyStatus::kUsable;
case media::CdmKeyInformation::INTERNAL_ERROR:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::kInternalError;
return WebEncryptedMediaKeyInformation::KeyStatus::kInternalError;
case media::CdmKeyInformation::EXPIRED:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::kExpired;
return WebEncryptedMediaKeyInformation::KeyStatus::kExpired;
case media::CdmKeyInformation::OUTPUT_RESTRICTED:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::
kOutputRestricted;
return WebEncryptedMediaKeyInformation::KeyStatus::kOutputRestricted;
case media::CdmKeyInformation::OUTPUT_DOWNSCALED:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::
kOutputDownscaled;
return WebEncryptedMediaKeyInformation::KeyStatus::kOutputDownscaled;
case media::CdmKeyInformation::KEY_STATUS_PENDING:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::kStatusPending;
return WebEncryptedMediaKeyInformation::KeyStatus::kStatusPending;
case media::CdmKeyInformation::RELEASED:
return blink::WebEncryptedMediaKeyInformation::KeyStatus::kReleased;
return WebEncryptedMediaKeyInformation::KeyStatus::kReleased;
}
NOTREACHED();
return blink::WebEncryptedMediaKeyInformation::KeyStatus::kInternalError;
return WebEncryptedMediaKeyInformation::KeyStatus::kInternalError;
}
void ReportCdmResultUMA(const std::string& uma_name,

@ -35,11 +35,11 @@ enum CdmResultForUMA {
PLATFORM_EXPORT CdmResultForUMA
ConvertCdmExceptionToResultForUMA(media::CdmPromise::Exception exception_code);
PLATFORM_EXPORT blink::WebContentDecryptionModuleException ConvertCdmException(
media::CdmPromise::Exception exception_code);
PLATFORM_EXPORT WebContentDecryptionModuleException
ConvertCdmException(media::CdmPromise::Exception exception_code);
PLATFORM_EXPORT blink::WebEncryptedMediaKeyInformation::KeyStatus
ConvertCdmKeyStatus(media::CdmKeyInformation::KeyStatus key_status);
PLATFORM_EXPORT WebEncryptedMediaKeyInformation::KeyStatus ConvertCdmKeyStatus(
media::CdmKeyInformation::KeyStatus key_status);
PLATFORM_EXPORT void ReportCdmResultUMA(const std::string& uma_name,
uint32_t system_code,

@ -74,8 +74,7 @@ void CdmSessionAdapter::GetStatusForPolicy(
}
std::unique_ptr<WebContentDecryptionModuleSessionImpl>
CdmSessionAdapter::CreateSession(
blink::WebEncryptedMediaSessionType session_type) {
CdmSessionAdapter::CreateSession(WebEncryptedMediaSessionType session_type) {
return std::make_unique<WebContentDecryptionModuleSessionImpl>(this,
session_type);
}

@ -66,7 +66,7 @@ class PLATFORM_EXPORT CdmSessionAdapter
// Creates a new session and adds it to the internal map. RemoveSession()
// must be called when destroying it, if RegisterSession() was called.
std::unique_ptr<WebContentDecryptionModuleSessionImpl> CreateSession(
blink::WebEncryptedMediaSessionType session_type);
WebEncryptedMediaSessionType session_type);
// Adds a session to the internal map. Called once the session is successfully
// initialized. Returns true if the session was registered, false if there is

@ -138,13 +138,13 @@ EmeConfigRule GetPersistentStateConfigRule(EmeFeatureSupport support,
return EmeConfigRule::PERSISTENCE_REQUIRED;
}
bool IsPersistentSessionType(blink::WebEncryptedMediaSessionType sessionType) {
bool IsPersistentSessionType(WebEncryptedMediaSessionType sessionType) {
switch (sessionType) {
case blink::WebEncryptedMediaSessionType::kTemporary:
case WebEncryptedMediaSessionType::kTemporary:
return false;
case blink::WebEncryptedMediaSessionType::kPersistentLicense:
case WebEncryptedMediaSessionType::kPersistentLicense:
return true;
case blink::WebEncryptedMediaSessionType::kUnknown:
case WebEncryptedMediaSessionType::kUnknown:
break;
}
@ -207,9 +207,9 @@ bool KeySystemConfigSelector::WebLocalFrameDelegate::
}
bool KeySystemConfigSelector::WebLocalFrameDelegate::AllowStorageAccessSync(
blink::WebContentSettingsClient::StorageType storage_type) {
WebContentSettingsClient::StorageType storage_type) {
DCHECK(web_frame_);
blink::WebContentSettingsClient* content_settings_client =
WebContentSettingsClient* content_settings_client =
web_frame_->GetContentSettingsClient();
return !content_settings_client ||
content_settings_client->AllowStorageAccessSync(storage_type);
@ -217,8 +217,7 @@ bool KeySystemConfigSelector::WebLocalFrameDelegate::AllowStorageAccessSync(
struct KeySystemConfigSelector::SelectionRequest {
std::string key_system;
blink::WebVector<blink::WebMediaKeySystemConfiguration>
candidate_configurations;
WebVector<WebMediaKeySystemConfiguration> candidate_configurations;
SelectConfigCB cb;
bool was_permission_requested = false;
bool is_permission_granted = false;
@ -467,11 +466,11 @@ EmeConfigRule KeySystemConfigSelector::GetEncryptionSchemeConfigRule(
bool KeySystemConfigSelector::GetSupportedCapabilities(
const std::string& key_system,
EmeMediaType media_type,
const blink::WebVector<blink::WebMediaKeySystemMediaCapability>&
const WebVector<WebMediaKeySystemMediaCapability>&
requested_media_capabilities,
// Corresponds to the partial configuration, plus restrictions.
KeySystemConfigSelector::ConfigState* config_state,
std::vector<blink::WebMediaKeySystemMediaCapability>*
std::vector<WebMediaKeySystemMediaCapability>*
supported_media_capabilities) {
// From "3.1.1.3 Get Supported Capabilities for Audio/Video Type".
// https://w3c.github.io/encrypted-media/#get-supported-capabilities-for-audio-video-type
@ -486,7 +485,7 @@ bool KeySystemConfigSelector::GetSupportedCapabilities(
for (size_t i = 0; i < requested_media_capabilities.size(); i++) {
// 3.1. Let content type be requested media capability's contentType member.
// 3.2. Let robustness be requested media capability's robustness member.
const blink::WebMediaKeySystemMediaCapability& capability =
const WebMediaKeySystemMediaCapability& capability =
requested_media_capabilities[i];
// 3.3. If contentType is the empty string, return null.
if (capability.mime_type.IsEmpty()) {
@ -588,9 +587,9 @@ bool KeySystemConfigSelector::GetSupportedCapabilities(
KeySystemConfigSelector::ConfigurationSupport
KeySystemConfigSelector::GetSupportedConfiguration(
const std::string& key_system,
const blink::WebMediaKeySystemConfiguration& candidate,
const WebMediaKeySystemConfiguration& candidate,
ConfigState* config_state,
blink::WebMediaKeySystemConfiguration* accumulated_configuration) {
WebMediaKeySystemConfiguration* accumulated_configuration) {
DVLOG(3) << __func__;
// From
@ -711,7 +710,7 @@ KeySystemConfigSelector::GetSupportedConfiguration(
// If preferences disallow local storage, then indicate persistent state is
// not supported.
if (!web_frame_delegate_->AllowStorageAccessSync(
blink::WebContentSettingsClient::StorageType::kLocalStorage)) {
WebContentSettingsClient::StorageType::kLocalStorage)) {
if (persistent_state_support == EmeFeatureSupport::ALWAYS_ENABLED)
return CONFIGURATION_NOT_SUPPORTED;
persistent_state_support = EmeFeatureSupport::NOT_SUPPORTED;
@ -735,14 +734,14 @@ KeySystemConfigSelector::GetSupportedConfiguration(
// let session types be candidate configuration's sessionTypes member.
// - Otherwise, let session types be [ "temporary" ].
// (Done in MediaKeySystemAccessInitializer.)
blink::WebVector<blink::WebEncryptedMediaSessionType> session_types =
WebVector<WebEncryptedMediaSessionType> session_types =
candidate.session_types;
// 13. For each value in session types:
for (size_t i = 0; i < session_types.size(); i++) {
// 13.1. Let session type be the value.
blink::WebEncryptedMediaSessionType session_type = session_types[i];
if (session_type == blink::WebEncryptedMediaSessionType::kUnknown) {
WebEncryptedMediaSessionType session_type = session_types[i];
if (session_type == WebEncryptedMediaSessionType::kUnknown) {
DVLOG(2) << "Rejecting requested configuration because "
<< "session type was not recognized.";
return CONFIGURATION_NOT_SUPPORTED;
@ -764,13 +763,13 @@ KeySystemConfigSelector::GetSupportedConfiguration(
// return NotSupported.
EmeConfigRule session_type_rule = EmeConfigRule::NOT_SUPPORTED;
switch (session_type) {
case blink::WebEncryptedMediaSessionType::kUnknown:
case WebEncryptedMediaSessionType::kUnknown:
NOTREACHED();
return CONFIGURATION_NOT_SUPPORTED;
case blink::WebEncryptedMediaSessionType::kTemporary:
case WebEncryptedMediaSessionType::kTemporary:
session_type_rule = EmeConfigRule::SUPPORTED;
break;
case blink::WebEncryptedMediaSessionType::kPersistentLicense:
case WebEncryptedMediaSessionType::kPersistentLicense:
session_type_rule = GetSessionTypeConfigRule(
key_systems_->GetPersistentLicenseSessionSupport(key_system));
break;
@ -810,7 +809,7 @@ KeySystemConfigSelector::GetSupportedConfiguration(
// 16. If the videoCapabilities member in candidate configuration is
// non-empty:
std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities;
std::vector<WebMediaKeySystemMediaCapability> video_capabilities;
if (!candidate.video_capabilities.empty()) {
// 16.1. Let video capabilities be the result of executing the Get
// Supported Capabilities for Audio/Video Type algorithm on Video,
@ -836,7 +835,7 @@ KeySystemConfigSelector::GetSupportedConfiguration(
// 17. If the audioCapabilities member in candidate configuration is
// non-empty:
std::vector<blink::WebMediaKeySystemMediaCapability> audio_capabilities;
std::vector<WebMediaKeySystemMediaCapability> audio_capabilities;
if (!candidate.audio_capabilities.empty()) {
// 17.1. Let audio capabilities be the result of executing the Get
// Supported Capabilities for Audio/Video Type algorithm on Audio,
@ -980,9 +979,8 @@ KeySystemConfigSelector::GetSupportedConfiguration(
}
void KeySystemConfigSelector::SelectConfig(
const blink::WebString& key_system,
const blink::WebVector<blink::WebMediaKeySystemConfiguration>&
candidate_configurations,
const WebString& key_system,
const WebVector<WebMediaKeySystemConfiguration>& candidate_configurations,
SelectConfigCB cb) {
// Continued from requestMediaKeySystemAccess(), step 6, from
// https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess
@ -1053,7 +1051,7 @@ void KeySystemConfigSelector::SelectConfigInternal(
// and return a new MediaKeySystemAccess object.]
ConfigState config_state(request->was_permission_requested,
request->is_permission_granted);
blink::WebMediaKeySystemConfiguration accumulated_configuration;
WebMediaKeySystemConfiguration accumulated_configuration;
media::CdmConfig cdm_config;
ConfigurationSupport support = GetSupportedConfiguration(
request->key_system, request->candidate_configurations[i],

@ -381,9 +381,8 @@ class FakeWebLocalFrameDelegate
: KeySystemConfigSelector::WebLocalFrameDelegate(nullptr) {}
bool IsCrossOriginToMainFrame() override { return is_cross_origin_; }
bool AllowStorageAccessSync(
blink::WebContentSettingsClient::StorageType storage_type) override {
if (storage_type ==
blink::WebContentSettingsClient::StorageType::kLocalStorage) {
WebContentSettingsClient::StorageType storage_type) override {
if (storage_type == WebContentSettingsClient::StorageType::kLocalStorage) {
return local_storage_allowed_;
}
return true;
@ -1275,13 +1274,13 @@ TEST_F(KeySystemConfigSelectorTest,
TEST_F(KeySystemConfigSelectorTest,
VideoCapabilities_EncryptionScheme_Supported) {
std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities(1);
std::vector<WebMediaKeySystemMediaCapability> video_capabilities(1);
video_capabilities[0].content_type = "a";
video_capabilities[0].mime_type = kSupportedVideoContainer;
video_capabilities[0].codecs = kSupportedVideoCodec;
video_capabilities[0].encryption_scheme = kSupportedEncryptionScheme;
blink::WebMediaKeySystemConfiguration config = EmptyConfiguration();
WebMediaKeySystemConfiguration config = EmptyConfiguration();
config.video_capabilities = video_capabilities;
configs_.push_back(config);
@ -1293,14 +1292,14 @@ TEST_F(KeySystemConfigSelectorTest,
TEST_F(KeySystemConfigSelectorTest,
VideoCapabilities_EncryptionScheme_DisallowHwSecureCodec) {
std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities(1);
std::vector<WebMediaKeySystemMediaCapability> video_capabilities(1);
video_capabilities[0].content_type = "a";
video_capabilities[0].mime_type = kSupportedVideoContainer;
video_capabilities[0].codecs = kSupportedVideoCodec;
video_capabilities[0].encryption_scheme =
kDisallowHwSecureCodecEncryptionScheme;
blink::WebMediaKeySystemConfiguration config = EmptyConfiguration();
WebMediaKeySystemConfiguration config = EmptyConfiguration();
config.video_capabilities = video_capabilities;
configs_.push_back(config);
@ -1488,13 +1487,13 @@ TEST_F(KeySystemConfigSelectorTest,
}
TEST_F(KeySystemConfigSelectorTest, HwSecureCodec_EncryptionScheme_Supported) {
std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities(1);
std::vector<WebMediaKeySystemMediaCapability> video_capabilities(1);
video_capabilities[0].content_type = "a";
video_capabilities[0].mime_type = kSupportedVideoContainer;
video_capabilities[0].codecs = kRequireHwSecureCodec;
video_capabilities[0].encryption_scheme = kSupportedEncryptionScheme;
blink::WebMediaKeySystemConfiguration config = EmptyConfiguration();
WebMediaKeySystemConfiguration config = EmptyConfiguration();
config.video_capabilities = video_capabilities;
configs_.push_back(config);
@ -1507,14 +1506,14 @@ TEST_F(KeySystemConfigSelectorTest, HwSecureCodec_EncryptionScheme_Supported) {
TEST_F(KeySystemConfigSelectorTest,
HwSecureCodec_EncryptionScheme_DisallowHwSecureCodec) {
std::vector<blink::WebMediaKeySystemMediaCapability> video_capabilities(1);
std::vector<WebMediaKeySystemMediaCapability> video_capabilities(1);
video_capabilities[0].content_type = "a";
video_capabilities[0].mime_type = kSupportedVideoContainer;
video_capabilities[0].codecs = kRequireHwSecureCodec;
video_capabilities[0].encryption_scheme =
kDisallowHwSecureCodecEncryptionScheme;
blink::WebMediaKeySystemConfiguration config = EmptyConfiguration();
WebMediaKeySystemConfiguration config = EmptyConfiguration();
config.video_capabilities = video_capabilities;
configs_.push_back(config);

@ -238,7 +238,7 @@ class MultiBufferDataSourceTest : public testing::Test {
public:
MultiBufferDataSourceTest() : preload_(MultiBufferDataSource::AUTO) {
ON_CALL(fetch_context_, CreateUrlLoader(_))
.WillByDefault(Invoke([](const blink::WebAssociatedURLLoaderOptions&) {
.WillByDefault(Invoke([](const WebAssociatedURLLoaderOptions&) {
return std::make_unique<NiceMock<MockWebAssociatedURLLoader>>();
}));
}
@ -438,13 +438,13 @@ class MultiBufferDataSourceTest : public testing::Test {
TestMultiBufferDataProvider* data_provider() {
return multibuffer()->GetProvider();
}
blink::WebAssociatedURLLoader* active_loader() {
WebAssociatedURLLoader* active_loader() {
EXPECT_TRUE(data_provider());
if (!data_provider())
return nullptr;
return data_provider()->active_loader_.get();
}
blink::WebAssociatedURLLoader* active_loader_allownull() {
WebAssociatedURLLoader* active_loader_allownull() {
TestMultiBufferDataProvider* data_provider =
multibuffer()->GetProvider_allownull();
if (!data_provider)
@ -770,7 +770,7 @@ TEST_F(MultiBufferDataSourceTest,
WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetWasFetchedViaServiceWorker(true);
std::vector<blink::WebURL> url_list = {GURL(kHttpUrl)};
std::vector<WebURL> url_list = {GURL(kHttpUrl)};
response1.SetUrlListViaServiceWorker(url_list);
WebURLResponse response2 =
response_generator_->GeneratePartial206(kDataSize, kDataSize * 2 - 1);
@ -785,7 +785,7 @@ TEST_F(MultiBufferDataSourceTest,
WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetWasFetchedViaServiceWorker(true);
std::vector<blink::WebURL> url_list = {GURL(kHttpDifferentPathUrl)};
std::vector<WebURL> url_list = {GURL(kHttpDifferentPathUrl)};
response1.SetUrlListViaServiceWorker(url_list);
WebURLResponse response2 =
response_generator_->GeneratePartial206(kDataSize, kDataSize * 2 - 1);
@ -800,7 +800,7 @@ TEST_F(MultiBufferDataSourceTest,
WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetWasFetchedViaServiceWorker(true);
std::vector<blink::WebURL> url_list = {GURL(kHttpDifferentOriginUrl)};
std::vector<WebURL> url_list = {GURL(kHttpDifferentOriginUrl)};
response1.SetUrlListViaServiceWorker(url_list);
WebURLResponse response2 =
response_generator_->GeneratePartial206(kDataSize, kDataSize * 2 - 1);
@ -815,7 +815,7 @@ TEST_F(MultiBufferDataSourceTest,
WebURLResponse response1 =
response_generator_->GeneratePartial206(0, kDataSize - 1);
response1.SetWasFetchedViaServiceWorker(true);
std::vector<blink::WebURL> url_list = {GURL(kHttpDifferentOriginUrl)};
std::vector<WebURL> url_list = {GURL(kHttpDifferentOriginUrl)};
response1.SetUrlListViaServiceWorker(url_list);
WebURLResponse response2 =
response_generator_->GeneratePartial206(kDataSize, kDataSize * 2 - 1);
@ -1436,8 +1436,8 @@ TEST_F(MultiBufferDataSourceTest, Http_RetryThenRedirect) {
run_loop.Run();
// Server responds with a redirect.
blink::WebURL url{GURL(kHttpDifferentPathUrl)};
blink::WebURLResponse response((GURL(kHttpUrl)));
WebURL url{GURL(kHttpDifferentPathUrl)};
WebURLResponse response((GURL(kHttpUrl)));
response.SetHttpStatusCode(307);
data_provider()->WillFollowRedirect(url, response);
@ -1454,8 +1454,8 @@ TEST_F(MultiBufferDataSourceTest, Http_NotStreamingAfterRedirect) {
Initialize(kHttpUrl, true);
// Server responds with a redirect.
blink::WebURL url{GURL(kHttpDifferentPathUrl)};
blink::WebURLResponse response((GURL(kHttpUrl)));
WebURL url{GURL(kHttpDifferentPathUrl)};
WebURLResponse response((GURL(kHttpUrl)));
response.SetHttpStatusCode(307);
data_provider()->WillFollowRedirect(url, response);
@ -1476,8 +1476,8 @@ TEST_F(MultiBufferDataSourceTest, Http_RangeNotSatisfiableAfterRedirect) {
Initialize(kHttpUrl, true);
// Server responds with a redirect.
blink::WebURL url{GURL(kHttpDifferentPathUrl)};
blink::WebURLResponse response((GURL(kHttpUrl)));
WebURL url{GURL(kHttpDifferentPathUrl)};
WebURLResponse response((GURL(kHttpUrl)));
response.SetHttpStatusCode(307);
data_provider()->WillFollowRedirect(url, response);
@ -1490,8 +1490,8 @@ TEST_F(MultiBufferDataSourceTest, Http_404AfterRedirect) {
Initialize(kHttpUrl, false);
// Server responds with a redirect.
blink::WebURL url{GURL(kHttpDifferentPathUrl)};
blink::WebURLResponse response((GURL(kHttpUrl)));
WebURL url{GURL(kHttpDifferentPathUrl)};
WebURLResponse response((GURL(kHttpUrl)));
response.SetHttpStatusCode(307);
data_provider()->WillFollowRedirect(url, response);
@ -1529,7 +1529,7 @@ TEST_F(MultiBufferDataSourceTest, LengthKnownAtEOF) {
TEST_F(MultiBufferDataSourceTest, FileSizeLessThanBlockSize) {
Initialize(kHttpUrl, true);
GURL gurl(kHttpUrl);
blink::WebURLResponse response(gurl);
WebURLResponse response(gurl);
response.SetHttpStatusCode(200);
response.SetHttpHeaderField(
WebString::FromUTF8("Content-Length"),

@ -32,24 +32,24 @@ CdmResultForUMA ConvertStatusToUMAResult(SessionInitStatus status) {
} // namespace
static blink::WebContentDecryptionModuleResult::SessionStatus ConvertStatus(
static WebContentDecryptionModuleResult::SessionStatus ConvertStatus(
SessionInitStatus status) {
switch (status) {
case SessionInitStatus::UNKNOWN_STATUS:
break;
case SessionInitStatus::NEW_SESSION:
return blink::WebContentDecryptionModuleResult::kNewSession;
return WebContentDecryptionModuleResult::kNewSession;
case SessionInitStatus::SESSION_NOT_FOUND:
return blink::WebContentDecryptionModuleResult::kSessionNotFound;
return WebContentDecryptionModuleResult::kSessionNotFound;
case SessionInitStatus::SESSION_ALREADY_EXISTS:
return blink::WebContentDecryptionModuleResult::kSessionAlreadyExists;
return WebContentDecryptionModuleResult::kSessionAlreadyExists;
}
NOTREACHED();
return blink::WebContentDecryptionModuleResult::kSessionNotFound;
return WebContentDecryptionModuleResult::kSessionNotFound;
}
NewSessionCdmResultPromise::NewSessionCdmResultPromise(
const blink::WebContentDecryptionModuleResult& result,
const WebContentDecryptionModuleResult& result,
const std::string& key_system_uma_prefix,
const std::string& uma_name,
SessionInitializedCB new_session_created_cb,
@ -102,7 +102,7 @@ void NewSessionCdmResultPromise::reject(CdmPromise::Exception exception_code,
ConvertCdmExceptionToResultForUMA(exception_code));
web_cdm_result_.CompleteWithError(ConvertCdmException(exception_code),
system_code,
blink::WebString::FromUTF8(error_message));
WebString::FromUTF8(error_message));
}
} // namespace blink

@ -46,7 +46,7 @@ class PLATFORM_EXPORT NewSessionCdmResultPromise
: public media::CdmPromiseTemplate<std::string> {
public:
NewSessionCdmResultPromise(
const blink::WebContentDecryptionModuleResult& result,
const WebContentDecryptionModuleResult& result,
const std::string& key_system_uma_prefix,
const std::string& uma_name,
SessionInitializedCB new_session_created_cb,
@ -63,7 +63,7 @@ class PLATFORM_EXPORT NewSessionCdmResultPromise
const std::string& error_message) override;
private:
blink::WebContentDecryptionModuleResult web_cdm_result_;
WebContentDecryptionModuleResult web_cdm_result_;
// UMA prefix and name to report result and time to.
std::string key_system_uma_prefix_;

@ -11,7 +11,7 @@
namespace blink {
RemotePlaybackClientWrapperImpl::RemotePlaybackClientWrapperImpl(
blink::WebMediaPlayerClient* client)
WebMediaPlayerClient* client)
: remote_playback_client_(client->RemotePlaybackClient()) {}
RemotePlaybackClientWrapperImpl::~RemotePlaybackClientWrapperImpl() = default;

@ -78,8 +78,8 @@ void ResourceMultiBufferDataProvider::Start() {
// Prepare the request.
WebURLRequest request(url_data_->url());
request.SetRequestContext(is_client_audio_element_
? blink::mojom::RequestContextType::AUDIO
: blink::mojom::RequestContextType::VIDEO);
? mojom::RequestContextType::AUDIO
: mojom::RequestContextType::VIDEO);
request.SetRequestDestination(
is_client_audio_element_ ? network::mojom::RequestDestination::kAudio
: network::mojom::RequestDestination::kVideo);
@ -90,14 +90,14 @@ void ResourceMultiBufferDataProvider::Start() {
if (url_data_->length() == kPositionNotSpecified &&
url_data_->CachedSize() == 0 && url_data_->BytesReadFromCache() == 0 &&
blink::WebNetworkStateNotifier::SaveDataEnabled() &&
WebNetworkStateNotifier::SaveDataEnabled() &&
(url_data_->url().SchemeIs(url::kHttpScheme) ||
url_data_->url().SchemeIs(url::kHttpsScheme))) {
// This lets the data reduction proxy know that we don't have any previously
// cached data for this resource. We can only send it if this is the first
// request for this resource.
request.SetPreviewsState(request.GetPreviewsState() |
blink::PreviewsTypes::kSrcVideoRedirectOn);
PreviewsTypes::kSrcVideoRedirectOn);
}
// We would like to send an if-match header with the request to
@ -112,7 +112,7 @@ void ResourceMultiBufferDataProvider::Start() {
WebString::FromUTF8("identity;q=1, *;q=0"));
// Start resource loading.
blink::WebAssociatedURLLoaderOptions options;
WebAssociatedURLLoaderOptions options;
if (url_data_->cors_mode() != UrlData::CORS_UNSPECIFIED) {
options.expose_all_response_headers = true;
// The author header set is empty, no preflight should go ahead.
@ -173,7 +173,7 @@ void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) {
// WebAssociatedURLLoaderClient implementation.
bool ResourceMultiBufferDataProvider::WillFollowRedirect(
const blink::WebURL& new_url,
const WebURL& new_url,
const WebURLResponse& redirect_response) {
DVLOG(1) << "willFollowRedirect";
redirects_to_ = new_url;

@ -30,7 +30,7 @@ class WebAssociatedURLLoader;
class PLATFORM_EXPORT ResourceMultiBufferDataProvider
: public MultiBuffer::DataProvider,
public blink::WebAssociatedURLLoaderClient {
public WebAssociatedURLLoaderClient {
public:
// NUmber of times we'll retry if the connection fails.
enum { kMaxRetries = 30 };
@ -52,16 +52,15 @@ class PLATFORM_EXPORT ResourceMultiBufferDataProvider
scoped_refptr<media::DataBuffer> Read() override;
void SetDeferred(bool defer) override;
// blink::WebAssociatedURLLoaderClient implementation.
bool WillFollowRedirect(
const blink::WebURL& new_url,
const blink::WebURLResponse& redirect_response) override;
// WebAssociatedURLLoaderClient implementation.
bool WillFollowRedirect(const WebURL& new_url,
const WebURLResponse& redirect_response) override;
void DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent) override;
void DidReceiveResponse(const blink::WebURLResponse& response) override;
void DidReceiveResponse(const WebURLResponse& response) override;
void DidDownloadData(uint64_t data_length) override;
void DidReceiveData(const char* data, int data_length) override;
void DidFinishLoading() override;
void DidFail(const blink::WebURLError&) override;
void DidFail(const WebURLError&) override;
// Use protected instead of private for testing purposes.
protected:
@ -86,7 +85,7 @@ class PLATFORM_EXPORT ResourceMultiBufferDataProvider
int64_t block_size() const;
// If we have made a range request, verify the response from the server.
bool VerifyPartialResponse(const blink::WebURLResponse& response,
bool VerifyPartialResponse(const WebURLResponse& response,
const scoped_refptr<UrlData>& url_data);
// Current Position.
@ -114,7 +113,7 @@ class PLATFORM_EXPORT ResourceMultiBufferDataProvider
// Keeps track of an active WebAssociatedURLLoader.
// Only valid while loading resource.
std::unique_ptr<blink::WebAssociatedURLLoader> active_loader_;
std::unique_ptr<WebAssociatedURLLoader> active_loader_;
// When we encounter a redirect, this is the source of the redirect.
GURL redirects_to_;

@ -55,9 +55,9 @@ static bool want_frfr = false;
// Predicate that checks the Accept-Encoding request header and FRFR previews
// state.
static bool CorrectAcceptEncodingAndPreviewsState(
const blink::WebURLRequest& request) {
const WebURLRequest& request) {
bool has_frfr =
request.GetPreviewsState() & blink::PreviewsTypes::kSrcVideoRedirectOn;
request.GetPreviewsState() & PreviewsTypes::kSrcVideoRedirectOn;
if (has_frfr != want_frfr) {
return false;
}
@ -171,8 +171,8 @@ class ResourceMultiBufferDataProviderTest : public testing::Test {
}
void Redirect(const char* url) {
blink::WebURL new_url{GURL(url)};
blink::WebURLResponse redirect_response(gurl_);
WebURL new_url{GURL(url)};
WebURLResponse redirect_response(gurl_);
EXPECT_CALL(*this, RedirectCallback(_))
.WillOnce(
@ -210,8 +210,8 @@ class ResourceMultiBufferDataProviderTest : public testing::Test {
}
protected:
std::unique_ptr<blink::WebAssociatedURLLoader> CreateUrlLoader(
const blink::WebAssociatedURLLoaderOptions& options) {
std::unique_ptr<WebAssociatedURLLoader> CreateUrlLoader(
const WebAssociatedURLLoaderOptions& options) {
auto url_loader = std::make_unique<NiceMock<MockWebAssociatedURLLoader>>();
EXPECT_CALL(*url_loader.get(),
LoadAsynchronously(Truly(CorrectAcceptEncodingAndPreviewsState),
@ -370,8 +370,7 @@ TEST_F(ResourceMultiBufferDataProviderTest, TestSaveDataFRFRPreviewsState) {
};
for (const TestCase& test_case : kTestCases) {
SCOPED_TRACE(test_case.label);
blink::WebNetworkStateNotifier::SetSaveDataEnabled(
test_case.enable_save_data);
WebNetworkStateNotifier::SetSaveDataEnabled(test_case.enable_save_data);
Initialize(test_case.url.c_str(), 0);
want_frfr = test_case.want_frfr_previews_enabled;

@ -18,8 +18,8 @@ class MockResourceFetchContext : public ResourceFetchContext {
~MockResourceFetchContext() override;
MOCK_METHOD1(CreateUrlLoader,
std::unique_ptr<blink::WebAssociatedURLLoader>(
const blink::WebAssociatedURLLoaderOptions&));
std::unique_ptr<WebAssociatedURLLoader>(
const WebAssociatedURLLoaderOptions&));
};
} // namespace blink

@ -11,7 +11,7 @@
namespace blink {
class MockWebAssociatedURLLoader : public blink::WebAssociatedURLLoader {
class MockWebAssociatedURLLoader : public WebAssociatedURLLoader {
public:
MockWebAssociatedURLLoader();
MockWebAssociatedURLLoader(const MockWebAssociatedURLLoader&) = delete;
@ -20,8 +20,8 @@ class MockWebAssociatedURLLoader : public blink::WebAssociatedURLLoader {
~MockWebAssociatedURLLoader() override;
MOCK_METHOD2(LoadAsynchronously,
void(const blink::WebURLRequest& request,
blink::WebAssociatedURLLoaderClient* client));
void(const WebURLRequest& request,
WebAssociatedURLLoaderClient* client));
MOCK_METHOD0(Cancel, void());
MOCK_METHOD1(SetDefersLoading, void(bool value));
MOCK_METHOD1(SetLoadingTaskRunner,

@ -31,44 +31,44 @@ class TestResponseGenerator {
TestResponseGenerator& operator=(const TestResponseGenerator&) = delete;
// Generates a WebURLError object.
blink::WebURLError GenerateError();
WebURLError GenerateError();
// Generates a regular HTTP 200 response.
blink::WebURLResponse Generate200();
WebURLResponse Generate200();
// Generates a regular HTTP 206 response starting from |first_byte_offset|
// until the end of the resource.
blink::WebURLResponse Generate206(int64_t first_byte_offset);
WebURLResponse Generate206(int64_t first_byte_offset);
// Generates a custom HTTP 206 response starting from |first_byte_offset|
// until the end of the resource. You can tweak what gets included in the
// headers via |flags|.
blink::WebURLResponse Generate206(int64_t first_byte_offset, Flags flags);
WebURLResponse Generate206(int64_t first_byte_offset, Flags flags);
// Generates a regular HTTP 206 response starting from |first_byte_offset|
// until |last_byte_offset|.
blink::WebURLResponse GeneratePartial206(int64_t first_byte_offset,
int64_t last_byte_offset);
WebURLResponse GeneratePartial206(int64_t first_byte_offset,
int64_t last_byte_offset);
// Generates a custom HTTP 206 response starting from |first_byte_offset|
// until |last_byte_offset|. You can tweak what gets included in the
// headers via |flags|.
blink::WebURLResponse GeneratePartial206(int64_t first_byte_offset,
int64_t last_byte_offset,
Flags flags);
WebURLResponse GeneratePartial206(int64_t first_byte_offset,
int64_t last_byte_offset,
Flags flags);
// Generates a regular HTTP 404 response.
blink::WebURLResponse Generate404();
WebURLResponse Generate404();
// Generate a HTTP response with specified code.
blink::WebURLResponse GenerateResponse(int code);
WebURLResponse GenerateResponse(int code);
// Generates a file:// response starting from |first_byte_offset| until the
// end of the resource.
//
// If |first_byte_offset| is negative a response containing no content length
// will be returned.
blink::WebURLResponse GenerateFileResponse(int64_t first_byte_offset);
WebURLResponse GenerateFileResponse(int64_t first_byte_offset);
int64_t content_length() { return content_length_; }

@ -18,7 +18,7 @@ namespace blink {
TextTrackImpl::TextTrackImpl(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
blink::WebMediaPlayerClient* client,
WebMediaPlayerClient* client,
std::unique_ptr<WebInbandTextTrackImpl> text_track)
: task_runner_(task_runner),
client_(client),
@ -48,16 +48,15 @@ void TextTrackImpl::OnAddCue(WebInbandTextTrackImpl* text_track,
const std::string& id,
const std::string& content,
const std::string& settings) {
if (blink::WebInbandTextTrackClient* client = text_track->Client()) {
if (WebInbandTextTrackClient* client = text_track->Client()) {
client->AddWebVTTCue(start.InSecondsF(), end.InSecondsF(),
blink::WebString::FromUTF8(id),
blink::WebString::FromUTF8(content),
blink::WebString::FromUTF8(settings));
WebString::FromUTF8(id), WebString::FromUTF8(content),
WebString::FromUTF8(settings));
}
}
void TextTrackImpl::OnRemoveTrack(
blink::WebMediaPlayerClient* client,
WebMediaPlayerClient* client,
std::unique_ptr<WebInbandTextTrackImpl> text_track) {
if (text_track->Client())
client->RemoveTextTrack(text_track.get());

@ -23,7 +23,7 @@ class PLATFORM_EXPORT TextTrackImpl : public media::TextTrack {
public:
// Constructor assumes ownership of the |text_track| object.
TextTrackImpl(const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
blink::WebMediaPlayerClient* client,
WebMediaPlayerClient* client,
std::unique_ptr<WebInbandTextTrackImpl> text_track);
TextTrackImpl(const TextTrackImpl&) = delete;
@ -44,11 +44,11 @@ class PLATFORM_EXPORT TextTrackImpl : public media::TextTrack {
const std::string& content,
const std::string& settings);
static void OnRemoveTrack(blink::WebMediaPlayerClient* client,
static void OnRemoveTrack(WebMediaPlayerClient* client,
std::unique_ptr<WebInbandTextTrackImpl> text_track);
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
blink::WebMediaPlayerClient* client_;
WebMediaPlayerClient* client_;
std::unique_ptr<WebInbandTextTrackImpl> text_track_;
};

@ -31,7 +31,7 @@ constexpr const char VideoFrameCompositor::kTracingCategory[];
VideoFrameCompositor::VideoFrameCompositor(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
std::unique_ptr<blink::WebVideoFrameSubmitter> submitter)
std::unique_ptr<WebVideoFrameSubmitter> submitter)
: task_runner_(task_runner),
tick_clock_(base::DefaultTickClock::GetInstance()),
background_rendering_timer_(
@ -313,10 +313,10 @@ void VideoFrameCompositor::StopForceBeginFrames() {
submitter_->SetForceBeginFrames(false);
}
std::unique_ptr<blink::WebMediaPlayer::VideoFramePresentationMetadata>
std::unique_ptr<WebMediaPlayer::VideoFramePresentationMetadata>
VideoFrameCompositor::GetLastPresentedFrameMetadata() {
auto frame_metadata =
std::make_unique<blink::WebMediaPlayer::VideoFramePresentationMetadata>();
std::make_unique<WebMediaPlayer::VideoFramePresentationMetadata>();
scoped_refptr<media::VideoFrame> last_frame;
{

@ -31,9 +31,9 @@ using ::testing::StrictMock;
using RenderingMode = ::media::VideoRendererSink::RenderCallback::RenderingMode;
class MockWebVideoFrameSubmitter : public blink::WebVideoFrameSubmitter {
class MockWebVideoFrameSubmitter : public WebVideoFrameSubmitter {
public:
// blink::WebVideoFrameSubmitter implementation.
// WebVideoFrameSubmitter implementation.
void StopUsingProvider() override {}
MOCK_METHOD1(EnableSubmission, void(viz::SurfaceId));
MOCK_METHOD0(StartRendering, void());

@ -310,7 +310,7 @@ class WatchTimeReporterTest
if (wtr_ && IsMonitoring())
EXPECT_WATCH_TIME_FINALIZED();
wtr_ = std::make_unique<blink::WatchTimeReporter>(
wtr_ = std::make_unique<WatchTimeReporter>(
media::mojom::PlaybackProperties::New(
has_audio_, has_video_, false, false, is_mse, is_encrypted, false,
media::mojom::MediaStreamType::kNone),
@ -319,8 +319,7 @@ class WatchTimeReporterTest
base::Unretained(this)),
base::BindRepeating(&WatchTimeReporterTest::GetPipelineStatistics,
base::Unretained(this)),
&fake_metrics_provider_,
blink::scheduler::GetSequencedTaskRunnerForTesting(),
&fake_metrics_provider_, scheduler::GetSequencedTaskRunnerForTesting(),
task_environment_.GetMockTickClock());
reporting_interval_ = wtr_->reporting_interval_;
@ -372,7 +371,7 @@ class WatchTimeReporterTest
: wtr_->OnNativeControlsDisabled();
}
void OnDisplayTypeChanged(blink::DisplayType display_type) {
void OnDisplayTypeChanged(DisplayType display_type) {
wtr_->OnDisplayTypeChanged(display_type);
}
@ -443,7 +442,7 @@ class WatchTimeReporterTest
if (TestFlags & kStartWithNativeControls)
OnNativeControlsEnabled(true);
if (TestFlags & kStartWithDisplayFullscreen)
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kFullscreen);
// Setup all current time expectations first since they need to use the
// InSequence macro for ease of use, but we don't want the watch time
@ -643,7 +642,7 @@ class WatchTimeReporterTest
const bool has_audio_;
FakeMediaMetricsProvider fake_metrics_provider_;
std::unique_ptr<blink::WatchTimeReporter> wtr_;
std::unique_ptr<WatchTimeReporter> wtr_;
base::TimeDelta reporting_interval_;
};
@ -1444,7 +1443,7 @@ TEST_P(DisplayTypeWatchTimeReporterTest,
EXPECT_TRUE(IsBackgroundMonitoring());
EXPECT_FALSE(IsMonitoring());
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kFullscreen);
EXPECT_BACKGROUND_WATCH_TIME(Ac, kWatchTime1);
EXPECT_BACKGROUND_WATCH_TIME(All, kWatchTime1);
@ -1578,7 +1577,7 @@ TEST_P(WatchTimeReporterTest, WatchTimeReporterMultiplePartialFinalize) {
wtr_->OnPlaying();
EXPECT_TRUE(IsMonitoring());
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kFullscreen);
OnPowerStateChange(true);
EXPECT_WATCH_TIME(Ac, kWatchTime1);
@ -1620,7 +1619,7 @@ TEST_P(WatchTimeReporterTest, WatchTimeReporterMultiplePartialFinalize) {
OnNativeControlsEnabled(true);
OnPowerStateChange(true);
OnDisplayTypeChanged(blink::DisplayType::kPictureInPicture);
OnDisplayTypeChanged(DisplayType::kPictureInPicture);
EXPECT_WATCH_TIME(Ac, kWatchTime1);
EXPECT_WATCH_TIME(All, kWatchTime1);
@ -1861,7 +1860,7 @@ TEST_P(WatchTimeReporterTest, WatchTimeCategoryMapping) {
.WillOnce(testing::Return(base::TimeDelta()))
.WillOnce(testing::Return(kWatchTime));
Initialize(false, false, kSizeJustRight);
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kFullscreen);
wtr_->OnPlaying();
SetOnBatteryPower(true);
EXPECT_TRUE(IsMonitoring());
@ -1879,7 +1878,7 @@ TEST_P(WatchTimeReporterTest, WatchTimeCategoryMapping) {
.WillOnce(testing::Return(kWatchTime));
Initialize(false, false, kSizeJustRight);
OnNativeControlsEnabled(true);
OnDisplayTypeChanged(blink::DisplayType::kPictureInPicture);
OnDisplayTypeChanged(DisplayType::kPictureInPicture);
wtr_->OnPlaying();
EXPECT_TRUE(IsMonitoring());
EXPECT_WATCH_TIME(Ac, kWatchTime);
@ -2010,8 +2009,8 @@ TEST_P(DisplayTypeWatchTimeReporterTest,
RunHysteresisTest<kAccumulationContinuesAfterTest |
kFinalizeExitDoesNotRequireCurrentTime |
kStartWithDisplayFullscreen>([this]() {
OnDisplayTypeChanged(blink::DisplayType::kInline);
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kInline);
OnDisplayTypeChanged(DisplayType::kFullscreen);
});
}
@ -2019,15 +2018,15 @@ TEST_P(DisplayTypeWatchTimeReporterTest,
OnDisplayTypeChangeHysteresisNativeFinalized) {
RunHysteresisTest<kAccumulationContinuesAfterTest |
kFinalizeDisplayWatchTime | kStartWithDisplayFullscreen>(
[this]() { OnDisplayTypeChanged(blink::DisplayType::kInline); });
[this]() { OnDisplayTypeChanged(DisplayType::kInline); });
}
TEST_P(DisplayTypeWatchTimeReporterTest,
OnDisplayTypeChangeHysteresisInlineContinuation) {
RunHysteresisTest<kAccumulationContinuesAfterTest |
kFinalizeExitDoesNotRequireCurrentTime>([this]() {
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(blink::DisplayType::kInline);
OnDisplayTypeChanged(DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kInline);
});
}
@ -2035,7 +2034,7 @@ TEST_P(DisplayTypeWatchTimeReporterTest,
OnDisplayTypeChangeHysteresisNativeOffFinalized) {
RunHysteresisTest<kAccumulationContinuesAfterTest |
kFinalizeDisplayWatchTime>(
[this]() { OnDisplayTypeChanged(blink::DisplayType::kFullscreen); });
[this]() { OnDisplayTypeChanged(DisplayType::kFullscreen); });
}
TEST_P(DisplayTypeWatchTimeReporterTest,
@ -2043,14 +2042,14 @@ TEST_P(DisplayTypeWatchTimeReporterTest,
RunHysteresisTest<kAccumulationContinuesAfterTest |
kFinalizeDisplayWatchTime | kStartWithDisplayFullscreen |
kTransitionDisplayWatchTime>(
[this]() { OnDisplayTypeChanged(blink::DisplayType::kInline); });
[this]() { OnDisplayTypeChanged(DisplayType::kInline); });
}
TEST_P(DisplayTypeWatchTimeReporterTest,
OnDisplayTypeChangeFullscreenToInline) {
RunHysteresisTest<kAccumulationContinuesAfterTest |
kFinalizeDisplayWatchTime | kTransitionDisplayWatchTime>(
[this]() { OnDisplayTypeChanged(blink::DisplayType::kFullscreen); });
[this]() { OnDisplayTypeChanged(DisplayType::kFullscreen); });
}
// Tests that the first finalize is the only one that matters.
@ -2345,7 +2344,7 @@ TEST_P(MutedWatchTimeReporterTest, MutedDisplayType) {
EXPECT_TRUE(IsMutedMonitoring());
EXPECT_FALSE(IsMonitoring());
OnDisplayTypeChanged(blink::DisplayType::kFullscreen);
OnDisplayTypeChanged(DisplayType::kFullscreen);
EXPECT_MUTED_WATCH_TIME_IF_AUDIO_VIDEO(Ac, kWatchTime1);
EXPECT_MUTED_WATCH_TIME_IF_AUDIO_VIDEO(All, kWatchTime1);
EXPECT_MUTED_WATCH_TIME_IF_AUDIO_VIDEO(Eme, kWatchTime1);

@ -17,15 +17,15 @@ namespace blink {
// The caller owns the created cdm (passed back using |result|).
static void CreateCdm(
const base::WeakPtr<WebEncryptedMediaClientImpl>& client,
const blink::WebString& key_system,
const blink::WebSecurityOrigin& security_origin,
const WebString& key_system,
const WebSecurityOrigin& security_origin,
const media::CdmConfig& cdm_config,
std::unique_ptr<blink::WebContentDecryptionModuleResult> result) {
std::unique_ptr<WebContentDecryptionModuleResult> result) {
// If |client| is gone (due to the frame getting destroyed), it is
// impossible to create the CDM, so fail.
if (!client) {
result->CompleteWithError(
blink::kWebContentDecryptionModuleExceptionInvalidStateError, 0,
kWebContentDecryptionModuleExceptionInvalidStateError, 0,
"Failed to create CDM.");
return;
}
@ -36,15 +36,15 @@ static void CreateCdm(
// static
WebContentDecryptionModuleAccessImpl*
WebContentDecryptionModuleAccessImpl::From(
blink::WebContentDecryptionModuleAccess* cdm_access) {
WebContentDecryptionModuleAccess* cdm_access) {
return static_cast<WebContentDecryptionModuleAccessImpl*>(cdm_access);
}
std::unique_ptr<WebContentDecryptionModuleAccessImpl>
WebContentDecryptionModuleAccessImpl::Create(
const blink::WebString& key_system,
const blink::WebSecurityOrigin& security_origin,
const blink::WebMediaKeySystemConfiguration& configuration,
const WebString& key_system,
const WebSecurityOrigin& security_origin,
const WebMediaKeySystemConfiguration& configuration,
const media::CdmConfig& cdm_config,
const base::WeakPtr<WebEncryptedMediaClientImpl>& client) {
return std::make_unique<WebContentDecryptionModuleAccessImpl>(
@ -52,9 +52,9 @@ WebContentDecryptionModuleAccessImpl::Create(
}
WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
const blink::WebString& key_system,
const blink::WebSecurityOrigin& security_origin,
const blink::WebMediaKeySystemConfiguration& configuration,
const WebString& key_system,
const WebSecurityOrigin& security_origin,
const WebMediaKeySystemConfiguration& configuration,
const media::CdmConfig& cdm_config,
const base::WeakPtr<WebEncryptedMediaClientImpl>& client)
: key_system_(key_system),
@ -66,24 +66,24 @@ WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() =
default;
blink::WebString WebContentDecryptionModuleAccessImpl::GetKeySystem() {
WebString WebContentDecryptionModuleAccessImpl::GetKeySystem() {
return key_system_;
}
blink::WebMediaKeySystemConfiguration
WebMediaKeySystemConfiguration
WebContentDecryptionModuleAccessImpl::GetConfiguration() {
return configuration_;
}
void WebContentDecryptionModuleAccessImpl::CreateContentDecryptionModule(
blink::WebContentDecryptionModuleResult result,
WebContentDecryptionModuleResult result,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
// This method needs to run asynchronously, as it may need to load the CDM.
// As this object's lifetime is controlled by MediaKeySystemAccess on the
// blink side, copy all values needed by CreateCdm() in case the blink object
// gets garbage-collected.
std::unique_ptr<blink::WebContentDecryptionModuleResult> result_copy(
new blink::WebContentDecryptionModuleResult(result));
std::unique_ptr<WebContentDecryptionModuleResult> result_copy(
new WebContentDecryptionModuleResult(result));
task_runner->PostTask(
FROM_HERE,
base::BindOnce(&CreateCdm, client_, key_system_, security_origin_,

@ -20,22 +20,22 @@ namespace blink {
class WebEncryptedMediaClientImpl;
class PLATFORM_EXPORT WebContentDecryptionModuleAccessImpl
: public blink::WebContentDecryptionModuleAccess {
: public WebContentDecryptionModuleAccess {
public:
// Allow typecasting from blink type as this is the only implementation.
static WebContentDecryptionModuleAccessImpl* From(
blink::WebContentDecryptionModuleAccess* cdm_access);
WebContentDecryptionModuleAccess* cdm_access);
static std::unique_ptr<WebContentDecryptionModuleAccessImpl> Create(
const blink::WebString& key_system,
const blink::WebSecurityOrigin& security_origin,
const blink::WebMediaKeySystemConfiguration& configuration,
const WebString& key_system,
const WebSecurityOrigin& security_origin,
const WebMediaKeySystemConfiguration& configuration,
const media::CdmConfig& cdm_config,
const base::WeakPtr<WebEncryptedMediaClientImpl>& client);
WebContentDecryptionModuleAccessImpl(
const blink::WebString& key_system,
const blink::WebSecurityOrigin& security_origin,
const blink::WebMediaKeySystemConfiguration& configuration,
const WebString& key_system,
const WebSecurityOrigin& security_origin,
const WebMediaKeySystemConfiguration& configuration,
const media::CdmConfig& cdm_config,
const base::WeakPtr<WebEncryptedMediaClientImpl>& client);
WebContentDecryptionModuleAccessImpl(
@ -44,18 +44,18 @@ class PLATFORM_EXPORT WebContentDecryptionModuleAccessImpl
const WebContentDecryptionModuleAccessImpl&) = delete;
~WebContentDecryptionModuleAccessImpl() override;
// blink::WebContentDecryptionModuleAccess interface.
blink::WebString GetKeySystem() override;
blink::WebMediaKeySystemConfiguration GetConfiguration() override;
// WebContentDecryptionModuleAccess interface.
WebString GetKeySystem() override;
WebMediaKeySystemConfiguration GetConfiguration() override;
void CreateContentDecryptionModule(
blink::WebContentDecryptionModuleResult result,
WebContentDecryptionModuleResult result,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) override;
bool UseHardwareSecureCodecs() const override;
private:
const blink::WebString key_system_;
const blink::WebSecurityOrigin security_origin_;
const blink::WebMediaKeySystemConfiguration configuration_;
const WebString key_system_;
const WebSecurityOrigin security_origin_;
const WebMediaKeySystemConfiguration configuration_;
const media::CdmConfig cdm_config_;
// Keep a WeakPtr as client is owned by render_frame_impl.

@ -31,7 +31,7 @@ const char kCreateSessionSessionTypeUMAName[] = "CreateSession.SessionType";
const char kSetServerCertificateUMAName[] = "SetServerCertificate";
const char kGetStatusForPolicyUMAName[] = "GetStatusForPolicy";
bool ConvertHdcpVersion(const blink::WebString& hdcp_version_string,
bool ConvertHdcpVersion(const WebString& hdcp_version_string,
media::HdcpVersion* hdcp_version) {
if (!hdcp_version_string.ContainsOnlyASCII())
return false;
@ -71,7 +71,7 @@ bool ConvertHdcpVersion(const blink::WebString& hdcp_version_string,
void WebContentDecryptionModuleImpl::Create(
media::CdmFactory* cdm_factory,
const std::u16string& key_system,
const blink::WebSecurityOrigin& security_origin,
const WebSecurityOrigin& security_origin,
const media::CdmConfig& cdm_config,
WebCdmCreatedCB web_cdm_created_cb) {
DCHECK(!security_origin.IsNull());
@ -118,9 +118,9 @@ WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl(
WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() = default;
std::unique_ptr<blink::WebContentDecryptionModuleSession>
std::unique_ptr<WebContentDecryptionModuleSession>
WebContentDecryptionModuleImpl::CreateSession(
blink::WebEncryptedMediaSessionType session_type) {
WebEncryptedMediaSessionType session_type) {
base::UmaHistogramEnumeration(
adapter_->GetKeySystemUMAPrefix() + kCreateSessionSessionTypeUMAName,
session_type);
@ -130,7 +130,7 @@ WebContentDecryptionModuleImpl::CreateSession(
void WebContentDecryptionModuleImpl::SetServerCertificate(
const uint8_t* server_certificate,
size_t server_certificate_length,
blink::WebContentDecryptionModuleResult result) {
WebContentDecryptionModuleResult result) {
DCHECK(server_certificate);
adapter_->SetServerCertificate(
std::vector<uint8_t>(server_certificate,
@ -141,13 +141,12 @@ void WebContentDecryptionModuleImpl::SetServerCertificate(
}
void WebContentDecryptionModuleImpl::GetStatusForPolicy(
const blink::WebString& min_hdcp_version_string,
blink::WebContentDecryptionModuleResult result) {
const WebString& min_hdcp_version_string,
WebContentDecryptionModuleResult result) {
media::HdcpVersion min_hdcp_version;
if (!ConvertHdcpVersion(min_hdcp_version_string, &min_hdcp_version)) {
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionTypeError, 0,
"Invalid HDCP version");
result.CompleteWithError(kWebContentDecryptionModuleExceptionTypeError, 0,
"Invalid HDCP version");
return;
}

@ -28,15 +28,15 @@ class CdmSessionAdapter;
class WebSecurityOrigin;
using WebCdmCreatedCB =
base::OnceCallback<void(blink::WebContentDecryptionModule* cdm,
base::OnceCallback<void(WebContentDecryptionModule* cdm,
const std::string& error_message)>;
class PLATFORM_EXPORT WebContentDecryptionModuleImpl
: public blink::WebContentDecryptionModule {
: public WebContentDecryptionModule {
public:
static void Create(media::CdmFactory* cdm_factory,
const std::u16string& key_system,
const blink::WebSecurityOrigin& security_origin,
const WebSecurityOrigin& security_origin,
const media::CdmConfig& cdm_config,
WebCdmCreatedCB web_cdm_created_cb);
@ -46,16 +46,14 @@ class PLATFORM_EXPORT WebContentDecryptionModuleImpl
const WebContentDecryptionModuleImpl&) = delete;
~WebContentDecryptionModuleImpl() override;
// blink::WebContentDecryptionModule implementation.
std::unique_ptr<blink::WebContentDecryptionModuleSession> CreateSession(
blink::WebEncryptedMediaSessionType session_type) override;
void SetServerCertificate(
const uint8_t* server_certificate,
size_t server_certificate_length,
blink::WebContentDecryptionModuleResult result) override;
void GetStatusForPolicy(
const blink::WebString& min_hdcp_version_string,
blink::WebContentDecryptionModuleResult result) override;
// WebContentDecryptionModule implementation.
std::unique_ptr<WebContentDecryptionModuleSession> CreateSession(
WebEncryptedMediaSessionType session_type) override;
void SetServerCertificate(const uint8_t* server_certificate,
size_t server_certificate_length,
WebContentDecryptionModuleResult result) override;
void GetStatusForPolicy(const WebString& min_hdcp_version_string,
WebContentDecryptionModuleResult result) override;
std::unique_ptr<media::CdmContextRef> GetCdmContextRef();
@ -75,7 +73,7 @@ class PLATFORM_EXPORT WebContentDecryptionModuleImpl
// Allow typecasting from blink type as this is the only implementation.
PLATFORM_EXPORT
inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl(
blink::WebContentDecryptionModule* cdm) {
WebContentDecryptionModule* cdm) {
return static_cast<WebContentDecryptionModuleImpl*>(cdm);
}

@ -43,13 +43,13 @@ const char kUpdateSessionUMAName[] = "UpdateSession";
const char kKeyStatusSystemCodeUMAName[] = "KeyStatusSystemCode";
media::CdmSessionType ConvertSessionType(
blink::WebEncryptedMediaSessionType session_type) {
WebEncryptedMediaSessionType session_type) {
switch (session_type) {
case blink::WebEncryptedMediaSessionType::kTemporary:
case WebEncryptedMediaSessionType::kTemporary:
return media::CdmSessionType::kTemporary;
case blink::WebEncryptedMediaSessionType::kPersistentLicense:
case WebEncryptedMediaSessionType::kPersistentLicense:
return media::CdmSessionType::kPersistentLicense;
case blink::WebEncryptedMediaSessionType::kUnknown:
case WebEncryptedMediaSessionType::kUnknown:
break;
}
@ -116,7 +116,7 @@ bool SanitizeInitData(media::EmeInitDataType init_data_type,
return false;
}
bool SanitizeSessionId(const blink::WebString& session_id,
bool SanitizeSessionId(const WebString& session_id,
std::string* sanitized_session_id) {
// The user agent should thoroughly validate the sessionId value before
// passing it to the CDM. At a minimum, this should include checking that
@ -185,7 +185,7 @@ bool SanitizeResponse(const std::string& key_system,
WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
const scoped_refptr<CdmSessionAdapter>& adapter,
blink::WebEncryptedMediaSessionType session_type)
WebEncryptedMediaSessionType session_type)
: adapter_(adapter),
session_type_(ConvertSessionType(session_type)),
has_close_been_called_(false),
@ -220,15 +220,15 @@ void WebContentDecryptionModuleSessionImpl::SetClientInterface(Client* client) {
client_ = client;
}
blink::WebString WebContentDecryptionModuleSessionImpl::SessionId() const {
return blink::WebString::FromUTF8(session_id_);
WebString WebContentDecryptionModuleSessionImpl::SessionId() const {
return WebString::FromUTF8(session_id_);
}
void WebContentDecryptionModuleSessionImpl::InitializeNewSession(
media::EmeInitDataType eme_init_data_type,
const unsigned char* init_data,
size_t init_data_length,
blink::WebContentDecryptionModuleResult result) {
WebContentDecryptionModuleResult result) {
DCHECK(init_data);
DCHECK(session_id_.empty());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
@ -243,8 +243,8 @@ void WebContentDecryptionModuleSessionImpl::InitializeNewSession(
std::string message =
"The initialization data type is not supported by the key system.";
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionNotSupportedError, 0,
blink::WebString::FromUTF8(message));
kWebContentDecryptionModuleExceptionNotSupportedError, 0,
WebString::FromUTF8(message));
return;
}
@ -267,9 +267,8 @@ void WebContentDecryptionModuleSessionImpl::InitializeNewSession(
std::string message;
if (!SanitizeInitData(eme_init_data_type, init_data, init_data_length,
&sanitized_init_data, &message)) {
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionTypeError, 0,
blink::WebString::FromUTF8(message));
result.CompleteWithError(kWebContentDecryptionModuleExceptionTypeError, 0,
WebString::FromUTF8(message));
return;
}
@ -277,7 +276,7 @@ void WebContentDecryptionModuleSessionImpl::InitializeNewSession(
// NotSupportedError.
if (sanitized_init_data.empty()) {
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionNotSupportedError, 0,
kWebContentDecryptionModuleExceptionNotSupportedError, 0,
"No initialization data provided.");
return;
}
@ -305,8 +304,8 @@ void WebContentDecryptionModuleSessionImpl::InitializeNewSession(
}
void WebContentDecryptionModuleSessionImpl::Load(
const blink::WebString& session_id,
blink::WebContentDecryptionModuleResult result) {
const WebString& session_id,
WebContentDecryptionModuleResult result) {
DCHECK(!session_id.IsEmpty());
DCHECK(session_id_.empty());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
@ -321,9 +320,8 @@ void WebContentDecryptionModuleSessionImpl::Load(
// reject promise with a newly created TypeError.
std::string sanitized_session_id;
if (!SanitizeSessionId(session_id, &sanitized_session_id)) {
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionTypeError, 0,
"Invalid session ID.");
result.CompleteWithError(kWebContentDecryptionModuleExceptionTypeError, 0,
"Invalid session ID.");
return;
}
@ -342,7 +340,7 @@ void WebContentDecryptionModuleSessionImpl::Load(
void WebContentDecryptionModuleSessionImpl::Update(
const uint8_t* response,
size_t response_length,
blink::WebContentDecryptionModuleResult result) {
WebContentDecryptionModuleResult result) {
DCHECK(response);
DCHECK(!session_id_.empty());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
@ -360,9 +358,8 @@ void WebContentDecryptionModuleSessionImpl::Update(
std::vector<uint8_t> sanitized_response;
if (!SanitizeResponse(adapter_->GetKeySystem(), response, response_length,
&sanitized_response)) {
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionTypeError, 0,
"Invalid response.");
result.CompleteWithError(kWebContentDecryptionModuleExceptionTypeError, 0,
"Invalid response.");
return;
}
@ -373,7 +370,7 @@ void WebContentDecryptionModuleSessionImpl::Update(
}
void WebContentDecryptionModuleSessionImpl::Close(
blink::WebContentDecryptionModuleResult result) {
WebContentDecryptionModuleResult result) {
DCHECK(!session_id_.empty());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
@ -395,7 +392,7 @@ void WebContentDecryptionModuleSessionImpl::Close(
}
void WebContentDecryptionModuleSessionImpl::Remove(
blink::WebContentDecryptionModuleResult result) {
WebContentDecryptionModuleResult result) {
DCHECK(!session_id_.empty());
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
@ -417,12 +414,11 @@ void WebContentDecryptionModuleSessionImpl::OnSessionKeysChange(
bool has_additional_usable_key,
media::CdmKeysInfo keys_info) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
blink::WebVector<blink::WebEncryptedMediaKeyInformation> keys(
keys_info.size());
WebVector<WebEncryptedMediaKeyInformation> keys(keys_info.size());
for (size_t i = 0; i < keys_info.size(); ++i) {
auto& key_info = keys_info[i];
keys[i].SetId(blink::WebData(reinterpret_cast<char*>(&key_info->key_id[0]),
key_info->key_id.size()));
keys[i].SetId(WebData(reinterpret_cast<char*>(&key_info->key_id[0]),
key_info->key_id.size()));
keys[i].SetStatus(ConvertCdmKeyStatus(key_info->status));
keys[i].SetSystemCode(key_info->system_code);

@ -25,33 +25,32 @@ namespace blink {
class CdmSessionAdapter;
class PLATFORM_EXPORT WebContentDecryptionModuleSessionImpl
: public blink::WebContentDecryptionModuleSession {
: public WebContentDecryptionModuleSession {
public:
WebContentDecryptionModuleSessionImpl(
const scoped_refptr<CdmSessionAdapter>& adapter,
blink::WebEncryptedMediaSessionType session_type);
WebEncryptedMediaSessionType session_type);
WebContentDecryptionModuleSessionImpl(
const WebContentDecryptionModuleSessionImpl&) = delete;
WebContentDecryptionModuleSessionImpl& operator=(
const WebContentDecryptionModuleSessionImpl&) = delete;
~WebContentDecryptionModuleSessionImpl() override;
// blink::WebContentDecryptionModuleSession implementation.
// WebContentDecryptionModuleSession implementation.
void SetClientInterface(Client* client) override;
blink::WebString SessionId() const override;
WebString SessionId() const override;
void InitializeNewSession(
media::EmeInitDataType init_data_type,
const unsigned char* initData,
size_t initDataLength,
blink::WebContentDecryptionModuleResult result) override;
void Load(const blink::WebString& session_id,
blink::WebContentDecryptionModuleResult result) override;
void InitializeNewSession(media::EmeInitDataType init_data_type,
const unsigned char* initData,
size_t initDataLength,
WebContentDecryptionModuleResult result) override;
void Load(const WebString& session_id,
WebContentDecryptionModuleResult result) override;
void Update(const uint8_t* response,
size_t response_length,
blink::WebContentDecryptionModuleResult result) override;
void Close(blink::WebContentDecryptionModuleResult result) override;
void Remove(blink::WebContentDecryptionModuleResult result) override;
WebContentDecryptionModuleResult result) override;
void Close(WebContentDecryptionModuleResult result) override;
void Remove(WebContentDecryptionModuleResult result) override;
// Callbacks.
void OnSessionMessage(media::CdmMessageType message_type,

@ -28,18 +28,18 @@ namespace {
const char kKeySystemSupportUMAPrefix[] =
"Media.EME.RequestMediaKeySystemAccess.";
// A helper function to complete blink::WebContentDecryptionModuleResult. Used
// to convert blink::WebContentDecryptionModuleResult to a callback.
// A helper function to complete WebContentDecryptionModuleResult. Used
// to convert WebContentDecryptionModuleResult to a callback.
void CompleteWebContentDecryptionModuleResult(
std::unique_ptr<blink::WebContentDecryptionModuleResult> result,
blink::WebContentDecryptionModule* cdm,
std::unique_ptr<WebContentDecryptionModuleResult> result,
WebContentDecryptionModule* cdm,
const std::string& error_message) {
DCHECK(result);
if (!cdm) {
result->CompleteWithError(
blink::kWebContentDecryptionModuleExceptionNotSupportedError, 0,
blink::WebString::FromUTF8(error_message));
kWebContentDecryptionModuleExceptionNotSupportedError, 0,
WebString::FromUTF8(error_message));
return;
}
@ -109,7 +109,7 @@ WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl(
WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() = default;
void WebEncryptedMediaClientImpl::RequestMediaKeySystemAccess(
blink::WebEncryptedMediaRequest request) {
WebEncryptedMediaRequest request) {
GetReporter(request.KeySystem())->ReportRequested();
key_system_config_selector_.SelectConfig(
@ -119,10 +119,10 @@ void WebEncryptedMediaClientImpl::RequestMediaKeySystemAccess(
}
void WebEncryptedMediaClientImpl::CreateCdm(
const blink::WebString& key_system,
const blink::WebSecurityOrigin& security_origin,
const WebString& key_system,
const WebSecurityOrigin& security_origin,
const media::CdmConfig& cdm_config,
std::unique_ptr<blink::WebContentDecryptionModuleResult> result) {
std::unique_ptr<WebContentDecryptionModuleResult> result) {
WebContentDecryptionModuleImpl::Create(
cdm_factory_, key_system.Utf16(), security_origin, cdm_config,
base::BindOnce(&CompleteWebContentDecryptionModuleResult,
@ -130,9 +130,9 @@ void WebEncryptedMediaClientImpl::CreateCdm(
}
void WebEncryptedMediaClientImpl::OnConfigSelected(
blink::WebEncryptedMediaRequest request,
WebEncryptedMediaRequest request,
KeySystemConfigSelector::Status status,
blink::WebMediaKeySystemConfiguration* accumulated_configuration,
WebMediaKeySystemConfiguration* accumulated_configuration,
media::CdmConfig* cdm_config) {
// Update encrypted_media_supported_types_browsertest.cc if updating these
// strings.
@ -159,7 +159,7 @@ void WebEncryptedMediaClientImpl::OnConfigSelected(
// requestMediaKeySystemAccess request succeeding. However, the blink
// objects may have been cleared, so check if this is the case and simply
// reject the request.
blink::WebSecurityOrigin origin = request.GetSecurityOrigin();
WebSecurityOrigin origin = request.GetSecurityOrigin();
if (origin.IsNull()) {
request.RequestNotSupported("Unable to create MediaKeySystemAccess");
return;
@ -171,7 +171,7 @@ void WebEncryptedMediaClientImpl::OnConfigSelected(
}
WebEncryptedMediaClientImpl::Reporter* WebEncryptedMediaClientImpl::GetReporter(
const blink::WebString& key_system) {
const WebString& key_system) {
// Assumes that empty will not be found by GetKeySystemNameForUMA().
// TODO(sandersd): Avoid doing ASCII conversion more than once.
std::string key_system_ascii;

@ -9,9 +9,9 @@
namespace blink {
WebInbandTextTrackImpl::WebInbandTextTrackImpl(Kind kind,
const blink::WebString& label,
const blink::WebString& language,
const blink::WebString& id)
const WebString& label,
const WebString& language,
const WebString& id)
: client_(nullptr),
kind_(kind),
label_(label),
@ -22,12 +22,11 @@ WebInbandTextTrackImpl::~WebInbandTextTrackImpl() {
DCHECK(!client_);
}
void WebInbandTextTrackImpl::SetClient(
blink::WebInbandTextTrackClient* client) {
void WebInbandTextTrackImpl::SetClient(WebInbandTextTrackClient* client) {
client_ = client;
}
blink::WebInbandTextTrackClient* WebInbandTextTrackImpl::Client() {
WebInbandTextTrackClient* WebInbandTextTrackImpl::Client() {
return client_;
}
@ -35,15 +34,15 @@ WebInbandTextTrackImpl::Kind WebInbandTextTrackImpl::GetKind() const {
return kind_;
}
blink::WebString WebInbandTextTrackImpl::Label() const {
WebString WebInbandTextTrackImpl::Label() const {
return label_;
}
blink::WebString WebInbandTextTrackImpl::Language() const {
WebString WebInbandTextTrackImpl::Language() const {
return language_;
}
blink::WebString WebInbandTextTrackImpl::Id() const {
WebString WebInbandTextTrackImpl::Id() const {
return id_;
}

@ -11,32 +11,31 @@
namespace blink {
class PLATFORM_EXPORT WebInbandTextTrackImpl
: public blink::WebInbandTextTrack {
class PLATFORM_EXPORT WebInbandTextTrackImpl : public WebInbandTextTrack {
public:
WebInbandTextTrackImpl(Kind kind,
const blink::WebString& label,
const blink::WebString& language,
const blink::WebString& id);
const WebString& label,
const WebString& language,
const WebString& id);
WebInbandTextTrackImpl(const WebInbandTextTrackImpl&) = delete;
WebInbandTextTrackImpl& operator=(const WebInbandTextTrackImpl&) = delete;
~WebInbandTextTrackImpl() override;
void SetClient(blink::WebInbandTextTrackClient* client) override;
blink::WebInbandTextTrackClient* Client() override;
void SetClient(WebInbandTextTrackClient* client) override;
WebInbandTextTrackClient* Client() override;
Kind GetKind() const override;
blink::WebString Label() const override;
blink::WebString Language() const override;
blink::WebString Id() const override;
WebString Label() const override;
WebString Language() const override;
WebString Id() const override;
private:
blink::WebInbandTextTrackClient* client_;
WebInbandTextTrackClient* client_;
Kind kind_;
blink::WebString label_;
blink::WebString language_;
blink::WebString id_;
WebString label_;
WebString language_;
WebString id_;
};
} // namespace blink

@ -109,10 +109,9 @@ void RecordSimpleWatchTimeUMA(media::RendererType type) {
UMA_HISTOGRAM_ENUMERATION(kWatchTimeHistogram, type);
}
void SetSinkIdOnMediaThread(
scoped_refptr<blink::WebAudioSourceProviderImpl> sink,
const std::string& device_id,
media::OutputDeviceStatusCB callback) {
void SetSinkIdOnMediaThread(scoped_refptr<WebAudioSourceProviderImpl> sink,
const std::string& device_id,
media::OutputDeviceStatusCB callback) {
sink->SwitchOutputDevice(device_id, std::move(callback));
}
@ -132,11 +131,11 @@ bool IsBackgroundVideoPauseOptimizationEnabled() {
return base::FeatureList::IsEnabled(media::kBackgroundVideoPauseOptimization);
}
bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) {
bool result = state == blink::WebMediaPlayer::kNetworkStateFormatError ||
state == blink::WebMediaPlayer::kNetworkStateNetworkError ||
state == blink::WebMediaPlayer::kNetworkStateDecodeError;
DCHECK_EQ(state > blink::WebMediaPlayer::kNetworkStateLoaded, result);
bool IsNetworkStateError(WebMediaPlayer::NetworkState state) {
bool result = state == WebMediaPlayer::kNetworkStateFormatError ||
state == WebMediaPlayer::kNetworkStateNetworkError ||
state == WebMediaPlayer::kNetworkStateDecodeError;
DCHECK_EQ(state > WebMediaPlayer::kNetworkStateLoaded, result);
return result;
}
@ -171,11 +170,11 @@ int GetSwitchToLocalMessage(
case media::MediaObserverClient::ReasonToSwitchToLocal::PIPELINE_ERROR:
return IDS_MEDIA_REMOTING_STOP_BY_ERROR_TEXT;
case media::MediaObserverClient::ReasonToSwitchToLocal::ROUTE_TERMINATED:
return blink::WebMediaPlayerClient::kMediaRemotingStopNoText;
return WebMediaPlayerClient::kMediaRemotingStopNoText;
}
NOTREACHED();
// To suppress compiler warning on Windows.
return blink::WebMediaPlayerClient::kMediaRemotingStopNoText;
return WebMediaPlayerClient::kMediaRemotingStopNoText;
}
// These values are persisted to UMA. Entries should not be renumbered and
@ -215,7 +214,7 @@ void DestructionHelper(
std::unique_ptr<media::CdmContextRef> cdm_context_2,
std::unique_ptr<media::MediaLog> media_log,
std::unique_ptr<media::RendererFactorySelector> renderer_factory_selector,
std::unique_ptr<blink::WebSurfaceLayerBridge> bridge,
std::unique_ptr<WebSurfaceLayerBridge> bridge,
bool is_chunk_demuxer) {
// We release |bridge| after pipeline stop to ensure layout tests receive
// painted video frames before test harness exit.
@ -267,7 +266,7 @@ void DestructionHelper(
std::move(media_log)));
}
std::string SanitizeUserStringProperty(blink::WebString value) {
std::string SanitizeUserStringProperty(WebString value) {
std::string converted = value.Utf8();
return base::IsStringUTF8(converted) ? converted : "[invalid property]";
}
@ -338,17 +337,16 @@ STATIC_ASSERT_ENUM(WebMediaPlayer::kCorsModeUseCredentials,
UrlData::CORS_USE_CREDENTIALS);
WebMediaPlayerImpl::WebMediaPlayerImpl(
blink::WebLocalFrame* frame,
blink::WebMediaPlayerClient* client,
blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
blink::WebMediaPlayerDelegate* delegate,
WebLocalFrame* frame,
WebMediaPlayerClient* client,
WebMediaPlayerEncryptedMediaClient* encrypted_client,
WebMediaPlayerDelegate* delegate,
std::unique_ptr<media::RendererFactorySelector> renderer_factory_selector,
UrlIndex* url_index,
std::unique_ptr<VideoFrameCompositor> compositor,
std::unique_ptr<WebMediaPlayerParams> params)
: frame_(frame),
main_task_runner_(
frame->GetTaskRunner(blink::TaskType::kMediaElementEvent)),
main_task_runner_(frame->GetTaskRunner(TaskType::kMediaElementEvent)),
media_task_runner_(params->media_task_runner()),
worker_task_runner_(params->worker_task_runner()),
media_log_(params->take_media_log()),
@ -445,7 +443,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
auto on_audio_source_provider_set_client_callback = base::BindOnce(
[](base::WeakPtr<WebMediaPlayerImpl> self,
blink::WebMediaPlayerClient* const client) {
WebMediaPlayerClient* const client) {
if (!self)
return;
client->DidDisableAudioOutputSinkChanges();
@ -454,7 +452,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
// TODO(xhwang): When we use an external Renderer, many methods won't work,
// e.g. GetCurrentFrameFromCompositor(). See http://crbug.com/434861
audio_source_provider_ = new blink::WebAudioSourceProviderImpl(
audio_source_provider_ = new WebAudioSourceProviderImpl(
params->audio_renderer_sink(), media_log_.get(),
std::move(on_audio_source_provider_set_client_callback));
@ -462,7 +460,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
observer_->SetClient(this);
memory_usage_reporting_timer_.SetTaskRunner(
frame_->GetTaskRunner(blink::TaskType::kInternalMedia));
frame_->GetTaskRunner(TaskType::kInternalMedia));
main_thread_mem_dumper_ = std::make_unique<media::MemoryDumpProviderProxy>(
"WebMediaPlayer_MainThread", main_task_runner_,
@ -522,8 +520,7 @@ WebMediaPlayerImpl::~WebMediaPlayerImpl() {
// Destruct compositor resources in the proper order.
client_->SetCcLayer(nullptr);
client_->MediaRemotingStopped(
blink::WebMediaPlayerClient::kMediaRemotingStopNoText);
client_->MediaRemotingStopped(WebMediaPlayerClient::kMediaRemotingStopNoText);
if (!surface_layer_for_video_enabled_ && video_layer_)
video_layer_->StopUsingProvider();
@ -567,12 +564,12 @@ WebMediaPlayerImpl::~WebMediaPlayerImpl() {
WebMediaPlayer::LoadTiming WebMediaPlayerImpl::Load(
LoadType load_type,
const blink::WebMediaPlayerSource& source,
const WebMediaPlayerSource& source,
CorsMode cors_mode,
bool is_cache_disabled) {
// Only URL or MSE blob URL is supported.
DCHECK(source.IsURL());
blink::WebURL url = source.GetAsURL();
WebURL url = source.GetAsURL();
DVLOG(1) << __func__ << "(" << load_type << ", " << GURL(url) << ", "
<< cors_mode << ")";
@ -684,13 +681,13 @@ void WebMediaPlayerImpl::BecameDominantVisibleContent(bool is_dominant) {
}
void WebMediaPlayerImpl::SetIsEffectivelyFullscreen(
blink::WebFullscreenVideoStatus fullscreen_video_status) {
WebFullscreenVideoStatus fullscreen_video_status) {
if (power_status_helper_) {
// We don't care about pip, so anything that's "not fullscreen" is good
// enough for us.
power_status_helper_->SetIsFullscreen(
fullscreen_video_status !=
blink::WebFullscreenVideoStatus::kNotEffectivelyFullscreen);
WebFullscreenVideoStatus::kNotEffectivelyFullscreen);
}
}
@ -704,26 +701,26 @@ void WebMediaPlayerImpl::OnHasNativeControlsChanged(bool has_native_controls) {
watch_time_reporter_->OnNativeControlsDisabled();
}
void WebMediaPlayerImpl::OnDisplayTypeChanged(blink::DisplayType display_type) {
void WebMediaPlayerImpl::OnDisplayTypeChanged(DisplayType display_type) {
if (surface_layer_for_video_enabled_) {
vfc_task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&VideoFrameCompositor::SetForceSubmit,
base::Unretained(compositor_.get()),
display_type == blink::DisplayType::kPictureInPicture));
display_type == DisplayType::kPictureInPicture));
}
if (!watch_time_reporter_)
return;
switch (display_type) {
case blink::DisplayType::kInline:
case DisplayType::kInline:
watch_time_reporter_->OnDisplayTypeInline();
break;
case blink::DisplayType::kFullscreen:
case DisplayType::kFullscreen:
watch_time_reporter_->OnDisplayTypeFullscreen();
break;
case blink::DisplayType::kPictureInPicture:
case DisplayType::kPictureInPicture:
watch_time_reporter_->OnDisplayTypePictureInPicture();
// Resumes playback if it was paused when hidden.
@ -736,7 +733,7 @@ void WebMediaPlayerImpl::OnDisplayTypeChanged(blink::DisplayType display_type) {
}
void WebMediaPlayerImpl::DoLoad(LoadType load_type,
const blink::WebURL& url,
const WebURL& url,
CorsMode cors_mode,
bool is_cache_disabled) {
TRACE_EVENT1("media", "WebMediaPlayerImpl::DoLoad", "id", media_log_->id());
@ -796,7 +793,7 @@ void WebMediaPlayerImpl::DoLoad(LoadType load_type,
media_metrics_provider_->Initialize(
load_type == kLoadTypeMediaSource,
load_type == kLoadTypeURL ? blink::GetMediaURLScheme(loaded_url_)
load_type == kLoadTypeURL ? GetMediaURLScheme(loaded_url_)
: media::mojom::MediaURLScheme::kUnknown,
media::mojom::MediaStreamType::kNone);
@ -1081,8 +1078,8 @@ void WebMediaPlayerImpl::OnRequestPictureInPicture() {
}
bool WebMediaPlayerImpl::SetSinkId(
const blink::WebString& sink_id,
blink::WebSetSinkIdCompleteCallback completion_callback) {
const WebString& sink_id,
WebSetSinkIdCompleteCallback completion_callback) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
DVLOG(1) << __func__;
@ -1122,7 +1119,7 @@ bool WebMediaPlayerImpl::HasAudio() const {
}
void WebMediaPlayerImpl::EnabledAudioTracksChanged(
const blink::WebVector<blink::WebMediaPlayer::TrackId>& enabledTrackIds) {
const WebVector<WebMediaPlayer::TrackId>& enabledTrackIds) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
std::ostringstream logstr;
@ -1138,7 +1135,7 @@ void WebMediaPlayerImpl::EnabledAudioTracksChanged(
}
void WebMediaPlayerImpl::SelectedVideoTrackChanged(
blink::WebMediaPlayer::TrackId* selectedTrackId) {
WebMediaPlayer::TrackId* selectedTrackId) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
absl::optional<MediaTrack::Id> selected_video_track_id;
@ -1262,17 +1259,17 @@ WebMediaPlayer::ReadyState WebMediaPlayerImpl::GetReadyState() const {
return ready_state_;
}
blink::WebMediaPlayer::SurfaceLayerMode
WebMediaPlayerImpl::GetVideoSurfaceLayerMode() const {
WebMediaPlayer::SurfaceLayerMode WebMediaPlayerImpl::GetVideoSurfaceLayerMode()
const {
return surface_layer_mode_;
}
blink::WebString WebMediaPlayerImpl::GetErrorMessage() const {
WebString WebMediaPlayerImpl::GetErrorMessage() const {
DCHECK(main_task_runner_->BelongsToCurrentThread());
return blink::WebString::FromUTF8(media_log_->GetErrorMessage());
return WebString::FromUTF8(media_log_->GetErrorMessage());
}
blink::WebTimeRanges WebMediaPlayerImpl::Buffered() const {
WebTimeRanges WebMediaPlayerImpl::Buffered() const {
DCHECK(main_task_runner_->BelongsToCurrentThread());
media::Ranges<base::TimeDelta> buffered_time_ranges =
@ -1283,14 +1280,14 @@ blink::WebTimeRanges WebMediaPlayerImpl::Buffered() const {
buffered_data_source_host_->AddBufferedTimeRanges(&buffered_time_ranges,
duration);
}
return blink::ConvertToWebTimeRanges(buffered_time_ranges);
return ConvertToWebTimeRanges(buffered_time_ranges);
}
blink::WebTimeRanges WebMediaPlayerImpl::Seekable() const {
WebTimeRanges WebMediaPlayerImpl::Seekable() const {
DCHECK(main_task_runner_->BelongsToCurrentThread());
if (ready_state_ < WebMediaPlayer::kReadyStateHaveMetadata)
return blink::WebTimeRanges();
return WebTimeRanges();
const double seekable_end = Duration();
@ -1308,9 +1305,9 @@ blink::WebTimeRanges WebMediaPlayerImpl::Seekable() const {
// TODO(dalecurtis): Technically this allows seeking on media which return an
// infinite duration so long as DataSource::IsStreaming() is false. While not
// expected, disabling this breaks semi-live players, http://crbug.com/427412.
const blink::WebTimeRange seekable_range(
0.0, force_seeks_to_zero ? 0.0 : seekable_end);
return blink::WebTimeRanges(&seekable_range, 1);
const WebTimeRange seekable_range(0.0,
force_seeks_to_zero ? 0.0 : seekable_end);
return WebTimeRanges(&seekable_range, 1);
}
bool WebMediaPlayerImpl::IsPrerollAttemptNeeded() {
@ -1436,8 +1433,8 @@ bool WebMediaPlayerImpl::HasAvailableVideoFrame() const {
}
void WebMediaPlayerImpl::SetContentDecryptionModule(
blink::WebContentDecryptionModule* cdm,
blink::WebContentDecryptionModuleResult result) {
WebContentDecryptionModule* cdm,
WebContentDecryptionModuleResult result) {
DVLOG(1) << __func__ << ": cdm = " << cdm;
DCHECK(main_task_runner_->BelongsToCurrentThread());
@ -1446,7 +1443,7 @@ void WebMediaPlayerImpl::SetContentDecryptionModule(
// http://crbug.com/462365#c7.
if (!cdm) {
result.CompleteWithError(
blink::kWebContentDecryptionModuleExceptionInvalidStateError, 0,
kWebContentDecryptionModuleExceptionInvalidStateError, 0,
"The existing ContentDecryptionModule object cannot be removed at this "
"time.");
return;
@ -1457,8 +1454,7 @@ void WebMediaPlayerImpl::SetContentDecryptionModule(
// on the wrong thread in some failure conditions. Blink should prevent
// multiple simultaneous calls.
DCHECK(!set_cdm_result_);
set_cdm_result_ =
std::make_unique<blink::WebContentDecryptionModuleResult>(result);
set_cdm_result_ = std::make_unique<WebContentDecryptionModuleResult>(result);
SetCdmInternal(cdm);
}
@ -1503,20 +1499,18 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
bool is_first_video_track = true;
for (const auto& track : tracks->tracks()) {
if (track->type() == MediaTrack::Audio) {
client_->AddAudioTrack(
blink::WebString::FromUTF8(track->id().value()),
blink::WebMediaPlayerClient::kAudioTrackKindMain,
blink::WebString::FromUTF8(track->label().value()),
blink::WebString::FromUTF8(track->language().value()),
is_first_audio_track);
client_->AddAudioTrack(WebString::FromUTF8(track->id().value()),
WebMediaPlayerClient::kAudioTrackKindMain,
WebString::FromUTF8(track->label().value()),
WebString::FromUTF8(track->language().value()),
is_first_audio_track);
is_first_audio_track = false;
} else if (track->type() == MediaTrack::Video) {
client_->AddVideoTrack(
blink::WebString::FromUTF8(track->id().value()),
blink::WebMediaPlayerClient::kVideoTrackKindMain,
blink::WebString::FromUTF8(track->label().value()),
blink::WebString::FromUTF8(track->language().value()),
is_first_video_track);
client_->AddVideoTrack(WebString::FromUTF8(track->id().value()),
WebMediaPlayerClient::kVideoTrackKindMain,
WebString::FromUTF8(track->label().value()),
WebString::FromUTF8(track->language().value()),
is_first_video_track);
is_first_video_track = false;
} else {
// Text tracks are not supported through this code path yet.
@ -1525,8 +1519,7 @@ void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
}
}
void WebMediaPlayerImpl::SetCdmInternal(
blink::WebContentDecryptionModule* cdm) {
void WebMediaPlayerImpl::SetCdmInternal(WebContentDecryptionModule* cdm) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
DCHECK(cdm);
@ -1596,7 +1589,7 @@ void WebMediaPlayerImpl::OnCdmAttached(bool success) {
pending_cdm_context_ref_.reset();
if (set_cdm_result_) {
set_cdm_result_->CompleteWithError(
blink::kWebContentDecryptionModuleExceptionNotSupportedError, 0,
kWebContentDecryptionModuleExceptionNotSupportedError, 0,
"Unable to set ContentDecryptionModule object");
set_cdm_result_.reset();
}
@ -1870,7 +1863,7 @@ void WebMediaPlayerImpl::OnError(media::PipelineStatus status) {
// be considered a format error.
SetNetworkState(WebMediaPlayer::kNetworkStateFormatError);
} else {
SetNetworkState(blink::PipelineErrorToNetworkState(status));
SetNetworkState(PipelineErrorToNetworkState(status));
}
// PipelineController::Stop() is idempotent.
@ -1943,8 +1936,7 @@ void WebMediaPlayerImpl::OnMetadata(const media::PipelineMetadata& metadata) {
DisableOverlay();
}
if (surface_layer_mode_ ==
blink::WebMediaPlayer::SurfaceLayerMode::kAlways) {
if (surface_layer_mode_ == WebMediaPlayer::SurfaceLayerMode::kAlways) {
ActivateSurfaceLayerForVideo();
} else {
DCHECK(!video_layer_);
@ -2083,7 +2075,7 @@ void WebMediaPlayerImpl::CreateVideoDecodeStatsReporter() {
base::Unretained(this)),
pipeline_metadata_.video_decoder_config.profile(),
pipeline_metadata_.natural_size, key_system_, cdm_config_,
frame_->GetTaskRunner(blink::TaskType::kInternalMedia));
frame_->GetTaskRunner(TaskType::kInternalMedia));
if (delegate_->IsFrameHidden())
video_decode_stats_reporter_->OnHidden();
@ -2270,10 +2262,9 @@ void WebMediaPlayerImpl::OnAddTextTrack(const media::TextTrackConfig& config,
const WebInbandTextTrackImpl::Kind web_kind =
static_cast<WebInbandTextTrackImpl::Kind>(config.kind());
const blink::WebString web_label = blink::WebString::FromUTF8(config.label());
const blink::WebString web_language =
blink::WebString::FromUTF8(config.language());
const blink::WebString web_id = blink::WebString::FromUTF8(config.id());
const WebString web_label = WebString::FromUTF8(config.label());
const WebString web_language = WebString::FromUTF8(config.language());
const WebString web_id = WebString::FromUTF8(config.id());
std::unique_ptr<WebInbandTextTrackImpl> web_inband_text_track(
new WebInbandTextTrackImpl(web_kind, web_label, web_language, web_id));
@ -2615,7 +2606,7 @@ void WebMediaPlayerImpl::OnRemotePlayStateChange(
}
#endif // defined(OS_ANDROID)
void WebMediaPlayerImpl::SetPoster(const blink::WebURL& poster) {
void WebMediaPlayerImpl::SetPoster(const WebURL& poster) {
has_poster_ = !poster.IsEmpty();
}
@ -2913,7 +2904,7 @@ void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) {
client_->ReadyStateChanged();
}
scoped_refptr<blink::WebAudioSourceProviderImpl>
scoped_refptr<WebAudioSourceProviderImpl>
WebMediaPlayerImpl::GetAudioSourceProvider() {
return audio_source_provider_;
}
@ -3337,8 +3328,7 @@ void WebMediaPlayerImpl::ScheduleIdlePauseTimer() {
// Idle timeout chosen arbitrarily.
background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5),
client_,
&blink::WebMediaPlayerClient::PausePlayback);
client_, &WebMediaPlayerClient::PausePlayback);
}
void WebMediaPlayerImpl::CreateWatchTimeReporter() {
@ -3353,7 +3343,7 @@ void WebMediaPlayerImpl::CreateWatchTimeReporter() {
}
// Create the watch time reporter and synchronize its initial state.
watch_time_reporter_ = std::make_unique<blink::WatchTimeReporter>(
watch_time_reporter_ = std::make_unique<WatchTimeReporter>(
media::mojom::PlaybackProperties::New(
pipeline_metadata_.has_audio, has_video, false, false,
!!chunk_demuxer_, is_encrypted_, embedded_media_experience_enabled_,
@ -3364,7 +3354,7 @@ void WebMediaPlayerImpl::CreateWatchTimeReporter() {
base::BindRepeating(&WebMediaPlayerImpl::GetPipelineStatistics,
base::Unretained(this)),
media_metrics_provider_.get(),
frame_->GetTaskRunner(blink::TaskType::kInternalMedia));
frame_->GetTaskRunner(TaskType::kInternalMedia));
watch_time_reporter_->OnVolumeChange(volume_);
watch_time_reporter_->OnDurationChanged(GetPipelineMediaDuration());
@ -3379,13 +3369,13 @@ void WebMediaPlayerImpl::CreateWatchTimeReporter() {
watch_time_reporter_->OnNativeControlsDisabled();
switch (client_->GetDisplayType()) {
case blink::DisplayType::kInline:
case DisplayType::kInline:
watch_time_reporter_->OnDisplayTypeInline();
break;
case blink::DisplayType::kFullscreen:
case DisplayType::kFullscreen:
watch_time_reporter_->OnDisplayTypeFullscreen();
break;
case blink::DisplayType::kPictureInPicture:
case DisplayType::kPictureInPicture:
watch_time_reporter_->OnDisplayTypePictureInPicture();
break;
}
@ -3478,7 +3468,7 @@ void WebMediaPlayerImpl::OnNewFramePresentedCallback() {
client_->OnRequestVideoFrameCallback();
}
std::unique_ptr<blink::WebMediaPlayer::VideoFramePresentationMetadata>
std::unique_ptr<WebMediaPlayer::VideoFramePresentationMetadata>
WebMediaPlayerImpl::GetVideoFramePresentationMetadata() {
return compositor_->GetLastPresentedFrameMetadata();
}
@ -3495,7 +3485,7 @@ void WebMediaPlayerImpl::UpdateFrameIfStale() {
VideoFrameCompositor::UpdateType::kBypassClient));
}
base::WeakPtr<blink::WebMediaPlayer> WebMediaPlayerImpl::AsWeakPtr() {
base::WeakPtr<WebMediaPlayer> WebMediaPlayerImpl::AsWeakPtr() {
return weak_this_;
}
@ -3817,7 +3807,7 @@ void WebMediaPlayerImpl::RecordEncryptionScheme(
bool WebMediaPlayerImpl::IsInPictureInPicture() const {
DCHECK(client_);
return client_->GetDisplayType() == blink::DisplayType::kPictureInPicture;
return client_->GetDisplayType() == DisplayType::kPictureInPicture;
}
void WebMediaPlayerImpl::MaybeSetContainerNameForMetrics() {

@ -118,7 +118,7 @@ MATCHER_P2(PlaybackRateChanged, old_rate_string, new_rate_string, "") {
std::string(new_rate_string));
}
class MockWebMediaPlayerClient : public blink::WebMediaPlayerClient {
class MockWebMediaPlayerClient : public WebMediaPlayerClient {
public:
MockWebMediaPlayerClient() = default;
@ -130,34 +130,31 @@ class MockWebMediaPlayerClient : public blink::WebMediaPlayerClient {
MOCK_METHOD0(SizeChanged, void());
MOCK_METHOD1(SetCcLayer, void(cc::Layer*));
MOCK_METHOD5(AddAudioTrack,
blink::WebMediaPlayer::TrackId(
const blink::WebString&,
blink::WebMediaPlayerClient::AudioTrackKind,
const blink::WebString&,
const blink::WebString&,
bool));
MOCK_METHOD1(RemoveAudioTrack, void(blink::WebMediaPlayer::TrackId));
WebMediaPlayer::TrackId(const WebString&,
WebMediaPlayerClient::AudioTrackKind,
const WebString&,
const WebString&,
bool));
MOCK_METHOD1(RemoveAudioTrack, void(WebMediaPlayer::TrackId));
MOCK_METHOD5(AddVideoTrack,
blink::WebMediaPlayer::TrackId(
const blink::WebString&,
blink::WebMediaPlayerClient::VideoTrackKind,
const blink::WebString&,
const blink::WebString&,
bool));
MOCK_METHOD1(RemoveVideoTrack, void(blink::WebMediaPlayer::TrackId));
MOCK_METHOD1(AddTextTrack, void(blink::WebInbandTextTrack*));
MOCK_METHOD1(RemoveTextTrack, void(blink::WebInbandTextTrack*));
MOCK_METHOD1(MediaSourceOpened, void(blink::WebMediaSource*));
MOCK_METHOD2(RemotePlaybackCompatibilityChanged,
void(const blink::WebURL&, bool));
WebMediaPlayer::TrackId(const WebString&,
WebMediaPlayerClient::VideoTrackKind,
const WebString&,
const WebString&,
bool));
MOCK_METHOD1(RemoveVideoTrack, void(WebMediaPlayer::TrackId));
MOCK_METHOD1(AddTextTrack, void(WebInbandTextTrack*));
MOCK_METHOD1(RemoveTextTrack, void(WebInbandTextTrack*));
MOCK_METHOD1(MediaSourceOpened, void(WebMediaSource*));
MOCK_METHOD2(RemotePlaybackCompatibilityChanged, void(const WebURL&, bool));
MOCK_METHOD0(WasAlwaysMuted, bool());
MOCK_METHOD0(HasSelectedVideoTrack, bool());
MOCK_METHOD0(GetSelectedVideoTrackId, blink::WebMediaPlayer::TrackId());
MOCK_METHOD0(GetSelectedVideoTrackId, WebMediaPlayer::TrackId());
MOCK_METHOD0(HasNativeControls, bool());
MOCK_METHOD0(IsAudioElement, bool());
MOCK_CONST_METHOD0(GetDisplayType, blink::DisplayType());
MOCK_CONST_METHOD0(GetDisplayType, DisplayType());
MOCK_CONST_METHOD0(IsInAutoPIP, bool());
MOCK_METHOD1(MediaRemotingStarted, void(const blink::WebString&));
MOCK_METHOD1(MediaRemotingStarted, void(const WebString&));
MOCK_METHOD1(MediaRemotingStopped, void(int));
MOCK_METHOD0(PictureInPictureStopped, void());
MOCK_METHOD0(OnPictureInPictureStateChange, void());
@ -181,7 +178,7 @@ class MockWebMediaPlayerClient : public blink::WebMediaPlayerClient {
MOCK_METHOD0(DidSeek, void());
MOCK_METHOD0(GetFeatures, Features(void));
MOCK_METHOD0(OnRequestVideoFrameCallback, void());
MOCK_METHOD0(GetTextTrackMetadata, std::vector<blink::TextTrackMetadata>());
MOCK_METHOD0(GetTextTrackMetadata, std::vector<TextTrackMetadata>());
bool was_always_muted_ = false;
@ -190,7 +187,7 @@ class MockWebMediaPlayerClient : public blink::WebMediaPlayerClient {
};
class MockWebMediaPlayerEncryptedMediaClient
: public blink::WebMediaPlayerEncryptedMediaClient {
: public WebMediaPlayerEncryptedMediaClient {
public:
MockWebMediaPlayerEncryptedMediaClient() = default;
@ -203,12 +200,12 @@ class MockWebMediaPlayerEncryptedMediaClient
DISALLOW_COPY_AND_ASSIGN(MockWebMediaPlayerEncryptedMediaClient);
};
class MockWebMediaPlayerDelegate : public blink::WebMediaPlayerDelegate {
class MockWebMediaPlayerDelegate : public WebMediaPlayerDelegate {
public:
MockWebMediaPlayerDelegate() = default;
~MockWebMediaPlayerDelegate() override = default;
// blink::WebMediaPlayerDelegate implementation.
// WebMediaPlayerDelegate implementation.
int AddObserver(Observer* observer) override {
DCHECK_EQ(nullptr, observer_);
observer_ = observer;
@ -283,7 +280,7 @@ class MockWebMediaPlayerDelegate : public blink::WebMediaPlayerDelegate {
bool is_hidden_ = false;
};
class MockSurfaceLayerBridge : public blink::WebSurfaceLayerBridge {
class MockSurfaceLayerBridge : public WebSurfaceLayerBridge {
public:
MOCK_CONST_METHOD0(GetCcLayer, cc::Layer*());
MOCK_CONST_METHOD0(GetFrameSinkId, const viz::FrameSinkId&());
@ -306,7 +303,7 @@ class MockVideoFrameCompositor : public VideoFrameCompositor {
MOCK_METHOD1(SetIsPageVisible, void(bool));
MOCK_METHOD0(
GetLastPresentedFrameMetadata,
std::unique_ptr<blink::WebMediaPlayer::VideoFramePresentationMetadata>());
std::unique_ptr<WebMediaPlayer::VideoFramePresentationMetadata>());
MOCK_METHOD0(GetCurrentFrameOnAnyThread, scoped_refptr<media::VideoFrame>());
MOCK_METHOD1(UpdateCurrentFrameIfStale,
void(VideoFrameCompositor::UpdateType));
@ -318,17 +315,16 @@ class MockVideoFrameCompositor : public VideoFrameCompositor {
class WebMediaPlayerImplTest
: public testing::Test,
private blink::WebTestingSupport::WebScopedMockScrollbars {
private WebTestingSupport::WebScopedMockScrollbars {
public:
WebMediaPlayerImplTest()
: WebMediaPlayerImplTest(
blink::scheduler::WebThreadScheduler::MainThreadScheduler()
scheduler::WebThreadScheduler::MainThreadScheduler()
->CreateAgentGroupScheduler()) {}
explicit WebMediaPlayerImplTest(
std::unique_ptr<blink::scheduler::WebAgentGroupScheduler>
agent_group_scheduler)
std::unique_ptr<scheduler::WebAgentGroupScheduler> agent_group_scheduler)
: media_thread_("MediaThreadForTest"),
web_view_(blink::WebView::Create(
web_view_(WebView::Create(
/*client=*/nullptr,
/*is_hidden=*/false,
/*is_inside_portal=*/false,
@ -339,12 +335,11 @@ class WebMediaPlayerImplTest
*agent_group_scheduler,
/*session_storage_namespace_id=*/base::EmptyString(),
/*page_base_background_color=*/absl::nullopt)),
web_local_frame_(
blink::WebLocalFrame::CreateMainFrame(web_view_,
&web_frame_client_,
nullptr,
blink::LocalFrameToken(),
nullptr)),
web_local_frame_(WebLocalFrame::CreateMainFrame(web_view_,
&web_frame_client_,
nullptr,
LocalFrameToken(),
nullptr)),
context_provider_(viz::TestContextProvider::Create()),
audio_parameters_(media::TestAudioParameters::Normal()),
memory_dump_manager_(
@ -452,7 +447,7 @@ class WebMediaPlayerImplTest
base::BindOnce(&WebMediaPlayerImplTest::CreateMockSurfaceLayerBridge,
base::Unretained(this)),
viz::TestContextProvider::Create(),
blink::WebMediaPlayer::SurfaceLayerMode::kAlways,
WebMediaPlayer::SurfaceLayerMode::kAlways,
is_background_suspend_enabled_, is_background_video_playback_enabled_,
true, std::move(demuxer_override), nullptr);
@ -466,25 +461,25 @@ class WebMediaPlayerImplTest
std::move(params));
}
std::unique_ptr<blink::WebSurfaceLayerBridge> CreateMockSurfaceLayerBridge(
blink::WebSurfaceLayerBridgeObserver*,
std::unique_ptr<WebSurfaceLayerBridge> CreateMockSurfaceLayerBridge(
WebSurfaceLayerBridgeObserver*,
cc::UpdateSubmissionStateCB) {
return std::move(surface_layer_bridge_);
}
blink::WebLocalFrame* GetWebLocalFrame() { return web_local_frame_; }
WebLocalFrame* GetWebLocalFrame() { return web_local_frame_; }
int64_t OnAdjustAllocatedMemory(int64_t delta) {
reported_memory_ += delta;
return 0;
}
void SetNetworkState(blink::WebMediaPlayer::NetworkState state) {
void SetNetworkState(WebMediaPlayer::NetworkState state) {
EXPECT_CALL(client_, NetworkStateChanged());
wmpi_->SetNetworkState(state);
}
void SetReadyState(blink::WebMediaPlayer::ReadyState state) {
void SetReadyState(WebMediaPlayer::ReadyState state) {
EXPECT_CALL(client_, ReadyStateChanged());
wmpi_->SetReadyState(state);
}
@ -519,10 +514,10 @@ class WebMediaPlayerImplTest
}
void SetMetadata(bool has_audio, bool has_video) {
wmpi_->SetNetworkState(blink::WebMediaPlayer::kNetworkStateLoaded);
wmpi_->SetNetworkState(WebMediaPlayer::kNetworkStateLoaded);
EXPECT_CALL(client_, ReadyStateChanged());
wmpi_->SetReadyState(blink::WebMediaPlayer::kReadyStateHaveMetadata);
wmpi_->SetReadyState(WebMediaPlayer::kReadyStateHaveMetadata);
wmpi_->pipeline_metadata_.has_audio = has_audio;
wmpi_->pipeline_metadata_.has_video = has_video;
@ -648,7 +643,7 @@ class WebMediaPlayerImplTest
wmpi_->SetSuspendState(is_suspended);
}
void SetLoadType(blink::WebMediaPlayer::LoadType load_type) {
void SetLoadType(WebMediaPlayer::LoadType load_type) {
wmpi_->load_type_ = load_type;
}
@ -707,7 +702,7 @@ class WebMediaPlayerImplTest
// the resource is fully buffered locally. We can use a fake one here since
// we're injecting the response artificially. It's value is unknown to the
// underlying demuxer.
const blink::KURL kTestURL(
const KURL kTestURL(
String::FromUTF8(std::string(is_streaming ? "http" : "file") +
"://example.com/sample.webm"));
@ -715,19 +710,19 @@ class WebMediaPlayerImplTest
// to the WebAssociatedURLLoaderClient handed out by the DataSource after it
// requests loading of a resource. We then use that client as if we are the
// network stack and "serve" an in memory file to the DataSource.
blink::WebAssociatedURLLoaderClient* client = nullptr;
WebAssociatedURLLoaderClient* client = nullptr;
EXPECT_CALL(mock_resource_fetch_context_, CreateUrlLoader(_))
.WillRepeatedly(
Invoke([&client](const blink::WebAssociatedURLLoaderOptions&) {
Invoke([&client](const WebAssociatedURLLoaderOptions&) {
auto a = std::make_unique<NiceMock<MockWebAssociatedURLLoader>>();
EXPECT_CALL(*a, LoadAsynchronously(_, _))
.WillRepeatedly(testing::SaveArg<1>(&client));
return a;
}));
wmpi_->Load(blink::WebMediaPlayer::kLoadTypeURL,
blink::WebMediaPlayerSource(blink::WebURL(kTestURL)),
blink::WebMediaPlayer::kCorsModeUnspecified,
wmpi_->Load(WebMediaPlayer::kLoadTypeURL,
WebMediaPlayerSource(WebURL(kTestURL)),
WebMediaPlayer::kCorsModeUnspecified,
/*is_cache_disabled=*/false);
base::RunLoop().RunUntilIdle();
@ -739,10 +734,10 @@ class WebMediaPlayerImplTest
// "Serve" the file to the DataSource. Note: We respond with 200 okay, which
// will prevent range requests or partial responses from being used. For
// streaming responses, we'll pretend we don't know the content length.
blink::WebURLResponse response(kTestURL);
WebURLResponse response(kTestURL);
response.SetHttpHeaderField(
blink::WebString::FromUTF8("Content-Length"),
blink::WebString::FromUTF8(
WebString::FromUTF8("Content-Length"),
WebString::FromUTF8(
is_streaming ? "-1" : base::NumberToString(data->data_size())));
response.SetExpectedContentLength(is_streaming ? -1 : data->data_size());
response.SetHttpStatusCode(200);
@ -763,7 +758,7 @@ class WebMediaPlayerImplTest
// unreliable due to asynchronous execution of tasks on the
// base::test:TaskEnvironment.
void LoadAndWaitForReadyState(std::string data_file,
blink::WebMediaPlayer::ReadyState ready_state) {
WebMediaPlayer::ReadyState ready_state) {
Load(data_file);
while (wmpi_->GetReadyState() < ready_state) {
base::RunLoop loop;
@ -779,13 +774,13 @@ class WebMediaPlayerImplTest
EXPECT_TRUE(wmpi_->data_source_);
EXPECT_TRUE(wmpi_->demuxer_);
if (ready_state > blink::WebMediaPlayer::kReadyStateHaveCurrentData)
if (ready_state > WebMediaPlayer::kReadyStateHaveCurrentData)
EXPECT_FALSE(wmpi_->seeking_);
}
void LoadAndWaitForCurrentData(std::string data_file) {
LoadAndWaitForReadyState(data_file,
blink::WebMediaPlayer::kReadyStateHaveCurrentData);
WebMediaPlayer::kReadyStateHaveCurrentData);
}
void CycleThreads() {
@ -802,7 +797,7 @@ class WebMediaPlayerImplTest
void OnProgress() { wmpi_->OnProgress(); }
void OnCdmCreated(base::RepeatingClosure quit_closure,
blink::WebContentDecryptionModule* cdm,
WebContentDecryptionModule* cdm,
const std::string& error_message) {
LOG_IF(ERROR, !error_message.empty()) << error_message;
EXPECT_TRUE(cdm);
@ -813,8 +808,8 @@ class WebMediaPlayerImplTest
void CreateCdm() {
// Must use a supported key system on a secure context.
std::u16string key_system = u"org.w3.clearkey";
auto test_origin = blink::WebSecurityOrigin::CreateFromString(
blink::WebString::FromUTF8("https://test.origin"));
auto test_origin = WebSecurityOrigin::CreateFromString(
WebString::FromUTF8("https://test.origin"));
base::RunLoop run_loop;
WebContentDecryptionModuleImpl::Create(
@ -846,9 +841,9 @@ class WebMediaPlayerImplTest
base::Thread media_thread_;
// Blink state.
blink::WebLocalFrameClient web_frame_client_;
blink::WebView* web_view_;
blink::WebLocalFrame* web_local_frame_;
WebLocalFrameClient web_frame_client_;
WebView* web_view_;
WebLocalFrame* web_local_frame_;
scoped_refptr<viz::TestContextProvider> context_provider_;
NiceMock<MockVideoFrameCompositor>* compositor_;
@ -871,7 +866,7 @@ class WebMediaPlayerImplTest
scoped_refptr<media::MockCdm> mock_cdm_ =
base::MakeRefCounted<media::MockCdm>();
media::MockCdmFactory mock_cdm_factory_{mock_cdm_};
std::unique_ptr<blink::WebContentDecryptionModule> web_cdm_;
std::unique_ptr<WebContentDecryptionModule> web_cdm_;
media::MockCdmContext mock_cdm_context_;
viz::FrameSinkId frame_sink_id_ = viz::FrameSinkId(1, 1);
@ -904,8 +899,7 @@ class WebMediaPlayerImplTest
std::unique_ptr<base::trace_event::MemoryDumpManager> memory_dump_manager_;
std::unique_ptr<blink::scheduler::WebAgentGroupScheduler>
agent_group_scheduler_;
std::unique_ptr<scheduler::WebAgentGroupScheduler> agent_group_scheduler_;
private:
DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImplTest);
@ -920,7 +914,7 @@ TEST_F(WebMediaPlayerImplTest, ConstructAndDestroy) {
TEST_F(WebMediaPlayerImplTest, LoadAndDestroy) {
InitializeWebMediaPlayerImpl();
EXPECT_FALSE(IsSuspended());
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
LoadAndWaitForCurrentData(kAudioOnlyTestFile);
EXPECT_FALSE(IsSuspended());
CycleThreads();
@ -936,9 +930,9 @@ TEST_F(WebMediaPlayerImplTest, LoadAndDestroy) {
TEST_F(WebMediaPlayerImplTest, LoadAndDestroyDataUrl) {
InitializeWebMediaPlayerImpl();
EXPECT_FALSE(IsSuspended());
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
const blink::KURL kMp3DataUrl(
const KURL kMp3DataUrl(
"data://audio/mp3;base64,SUQzAwAAAAAAFlRFTkMAAAAMAAAAQW1hZGV1cyBQcm//"
"+5DEAAAAAAAAAAAAAAAAAAAAAABYaW5nAAAADwAAAAwAAAftABwcHBwcHBwcMTExMTExMTFG"
"RkZGRkZGRlpaWlpaWlpaWm9vb29vb29vhISEhISEhISYmJiYmJiYmJitra2tra2trcLCwsLC"
@ -991,9 +985,9 @@ TEST_F(WebMediaPlayerImplTest, LoadAndDestroyDataUrl) {
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAP8=");
wmpi_->Load(blink::WebMediaPlayer::kLoadTypeURL,
blink::WebMediaPlayerSource(blink::WebURL(kMp3DataUrl)),
blink::WebMediaPlayer::kCorsModeUnspecified,
wmpi_->Load(WebMediaPlayer::kLoadTypeURL,
WebMediaPlayerSource(WebURL(kMp3DataUrl)),
WebMediaPlayer::kCorsModeUnspecified,
/*is_cache_disabled=*/false);
base::RunLoop().RunUntilIdle();
@ -1001,8 +995,7 @@ TEST_F(WebMediaPlayerImplTest, LoadAndDestroyDataUrl) {
// This runs until we reach the have current data state. Attempting to wait
// for states < kReadyStateHaveCurrentData is unreliable due to asynchronous
// execution of tasks on the base::test:TaskEnvironment.
while (wmpi_->GetReadyState() <
blink::WebMediaPlayer::kReadyStateHaveCurrentData) {
while (wmpi_->GetReadyState() < WebMediaPlayer::kReadyStateHaveCurrentData) {
base::RunLoop loop;
EXPECT_CALL(client_, ReadyStateChanged())
.WillRepeatedly(RunClosure(loop.QuitClosure()));
@ -1020,9 +1013,9 @@ TEST_F(WebMediaPlayerImplTest, LoadAndDestroyDataUrl) {
TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspend) {
InitializeWebMediaPlayerImpl();
EXPECT_CALL(client_, CouldPlayIfEnoughData()).WillRepeatedly(Return(false));
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadMetaData);
wmpi_->SetPreload(WebMediaPlayer::kPreloadMetaData);
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveMetadata);
WebMediaPlayer::kReadyStateHaveMetadata);
testing::Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, ReadyStateChanged()).Times(AnyNumber());
CycleThreads();
@ -1040,16 +1033,15 @@ TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspend) {
TEST_F(WebMediaPlayerImplTest, NoBufferSizeIncreaseUntilHaveEnough) {
InitializeWebMediaPlayerImpl();
EXPECT_CALL(client_, CouldPlayIfEnoughData()).WillRepeatedly(Return(true));
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveMetadata);
WebMediaPlayer::kReadyStateHaveMetadata);
testing::Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, ReadyStateChanged()).Times(AnyNumber());
wmpi_->Play();
EXPECT_FALSE(IsDataSourceMarkedAsPlaying());
while (wmpi_->GetReadyState() <
blink::WebMediaPlayer::kReadyStateHaveEnoughData) {
while (wmpi_->GetReadyState() < WebMediaPlayer::kReadyStateHaveEnoughData) {
// Clear the mock so it doesn't have a stale QuitClosure.
testing::Mock::VerifyAndClearExpectations(&client_);
@ -1066,7 +1058,7 @@ TEST_F(WebMediaPlayerImplTest, NoBufferSizeIncreaseUntilHaveEnough) {
TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspendNoStreaming) {
InitializeWebMediaPlayerImpl();
EXPECT_CALL(client_, CouldPlayIfEnoughData()).WillRepeatedly(Return(false));
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadMetaData);
wmpi_->SetPreload(WebMediaPlayer::kPreloadMetaData);
// This test needs a file which is larger than the MultiBuffer block size;
// otherwise we'll never complete initialization of the MultiBufferDataSource.
@ -1074,8 +1066,7 @@ TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspendNoStreaming) {
Load(kLargeAudioOnlyTestFile, LoadType::kStreaming);
// This runs until we reach the metadata state.
while (wmpi_->GetReadyState() <
blink::WebMediaPlayer::kReadyStateHaveMetadata) {
while (wmpi_->GetReadyState() < WebMediaPlayer::kReadyStateHaveMetadata) {
base::RunLoop loop;
EXPECT_CALL(client_, ReadyStateChanged())
.WillRepeatedly(RunClosure(loop.QuitClosure()));
@ -1097,12 +1088,12 @@ TEST_F(WebMediaPlayerImplTest, LazyLoadPreloadMetadataSuspend) {
scoped_feature_list.InitAndEnableFeature(media::kPreloadMetadataLazyLoad);
InitializeWebMediaPlayerImpl();
EXPECT_CALL(client_, CouldPlayIfEnoughData()).WillRepeatedly(Return(false));
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadMetaData);
wmpi_->SetPreload(WebMediaPlayer::kPreloadMetaData);
// Don't set poster, but ensure we still reach suspended state.
LoadAndWaitForReadyState(kVideoOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveMetadata);
WebMediaPlayer::kReadyStateHaveMetadata);
testing::Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, ReadyStateChanged()).Times(AnyNumber());
CycleThreads();
@ -1123,11 +1114,11 @@ TEST_F(WebMediaPlayerImplTest, LazyLoadPreloadMetadataSuspend) {
TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspendNoVideoMemoryUsage) {
InitializeWebMediaPlayerImpl();
EXPECT_CALL(client_, CouldPlayIfEnoughData()).WillRepeatedly(Return(false));
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadMetaData);
wmpi_->SetPoster(blink::WebURL(blink::KURL("file://example.com/sample.jpg")));
wmpi_->SetPreload(WebMediaPlayer::kPreloadMetaData);
wmpi_->SetPoster(WebURL(KURL("file://example.com/sample.jpg")));
LoadAndWaitForReadyState(kVideoOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveMetadata);
WebMediaPlayer::kReadyStateHaveMetadata);
testing::Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, ReadyStateChanged()).Times(AnyNumber());
CycleThreads();
@ -1147,7 +1138,7 @@ TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspendNoVideoMemoryUsage) {
TEST_F(WebMediaPlayerImplTest, LoadPreloadMetadataSuspendCouldPlay) {
InitializeWebMediaPlayerImpl();
EXPECT_CALL(client_, CouldPlayIfEnoughData()).WillRepeatedly(Return(true));
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadMetaData);
wmpi_->SetPreload(WebMediaPlayer::kPreloadMetaData);
LoadAndWaitForCurrentData(kAudioOnlyTestFile);
testing::Mock::VerifyAndClearExpectations(&client_);
EXPECT_CALL(client_, ReadyStateChanged()).Times(AnyNumber());
@ -1177,7 +1168,7 @@ TEST_F(WebMediaPlayerImplTest,
TEST_F(WebMediaPlayerImplTest, IdleSuspendIsEnabledIfLoadingHasStalled) {
InitializeWebMediaPlayerImpl();
SetNetworkState(blink::WebMediaPlayer::kNetworkStateLoading);
SetNetworkState(WebMediaPlayer::kNetworkStateLoading);
base::SimpleTestTickClock clock;
clock.Advance(base::TimeDelta::FromSeconds(1));
SetTickClock(&clock);
@ -1193,7 +1184,7 @@ TEST_F(WebMediaPlayerImplTest, IdleSuspendIsEnabledIfLoadingHasStalled) {
TEST_F(WebMediaPlayerImplTest, DidLoadingProgressTriggersResume) {
// Same setup as IdleSuspendIsEnabledBeforeLoadingBegins.
InitializeWebMediaPlayerImpl();
SetNetworkState(blink::WebMediaPlayer::kNetworkStateLoading);
SetNetworkState(WebMediaPlayer::kNetworkStateLoading);
EXPECT_TRUE(delegate_.ExpireForTesting());
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(IsSuspended());
@ -1266,7 +1257,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_HaveMetadata) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_HaveFutureData) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PAUSED, state.delegate_state);
EXPECT_TRUE(state.is_idle);
@ -1278,7 +1269,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_HaveFutureData) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_PlayingError) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state);
@ -1295,7 +1286,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_PlayingError) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_Playing) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state);
@ -1307,7 +1298,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_Playing) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_PlayingVideoOnly) {
InitializeWebMediaPlayerImpl();
SetMetadata(false, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state);
@ -1319,9 +1310,9 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_PlayingVideoOnly) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_Underflow) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveCurrentData);
SetReadyState(WebMediaPlayer::kReadyStateHaveCurrentData);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state);
EXPECT_FALSE(state.is_idle);
@ -1332,7 +1323,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_Underflow) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameHidden) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
WebMediaPlayerImpl::PlayState state = ComputePlayState_FrameHidden();
@ -1345,7 +1336,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameHidden) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameHiddenAudioOnly) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
SetMetadata(true, false);
@ -1363,7 +1354,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameHiddenSuspendNoResume) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
WebMediaPlayerImpl::PlayState state = ComputePlayState_FrameHidden();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state);
@ -1386,7 +1377,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameHiddenSuspendWithResume) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
WebMediaPlayerImpl::PlayState state = ComputePlayState_FrameHidden();
@ -1399,7 +1390,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameHiddenSuspendWithResume) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameClosed) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
SetWasSuspendedForFrameClosed(true);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
@ -1412,7 +1403,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_FrameClosed) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_PausedSeek) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetSeeking(true);
WebMediaPlayerImpl::PlayState state = ComputePlayState();
EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PAUSED, state.delegate_state);
@ -1424,7 +1415,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_PausedSeek) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_Ended) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(false);
SetEnded(true);
@ -1448,7 +1439,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_Ended) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_DoesNotStaySuspended) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveMetadata);
SetReadyState(WebMediaPlayer::kReadyStateHaveMetadata);
// Should stay suspended even though not stale or backgrounded.
WebMediaPlayerImpl::PlayState state = ComputePlayState_Suspended();
@ -1461,7 +1452,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_DoesNotStaySuspended) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_StaysSuspended) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
// Should stay suspended even though not stale or backgrounded.
WebMediaPlayerImpl::PlayState state = ComputePlayState_Suspended();
@ -1474,7 +1465,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_StaysSuspended) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_ResumeForNeedFirstFrame) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
// Should stay suspended even though not stale or backgrounded.
WebMediaPlayerImpl::PlayState state = ComputePlayState_Suspended();
@ -1494,7 +1485,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_ResumeForNeedFirstFrame) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_Flinging) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
// Remote media via the FlingingRenderer should not be idle.
WebMediaPlayerImpl::PlayState state = ComputePlayState_Flinging();
@ -1507,7 +1498,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_Flinging) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_Fullscreen) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetFullscreen(true);
SetPaused(true);
delegate_.SetStaleForTesting(true);
@ -1523,7 +1514,7 @@ TEST_F(WebMediaPlayerImplTest, ComputePlayState_Fullscreen) {
TEST_F(WebMediaPlayerImplTest, ComputePlayState_Streaming) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
SetPaused(true);
delegate_.SetStaleForTesting(true);
@ -1558,7 +1549,7 @@ TEST_F(WebMediaPlayerImplTest, ResumeEnded) {
EXPECT_CALL(delegate_, DidMediaMetadataChange(_, true, true, _)).Times(2);
OnMetadata(metadata);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
Play();
// Cause PlayerGone
Pause();
@ -1598,7 +1589,7 @@ TEST_F(WebMediaPlayerImplTest, AutoplayMuted) {
TEST_F(WebMediaPlayerImplTest, MediaPositionState_Playing) {
InitializeWebMediaPlayerImpl();
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveFutureData);
WebMediaPlayer::kReadyStateHaveFutureData);
wmpi_->SetRate(1.0);
Play();
@ -1611,7 +1602,7 @@ TEST_F(WebMediaPlayerImplTest, MediaPositionState_Playing) {
TEST_F(WebMediaPlayerImplTest, MediaPositionState_Paused) {
InitializeWebMediaPlayerImpl();
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveFutureData);
WebMediaPlayer::kReadyStateHaveFutureData);
wmpi_->SetRate(1.0);
// The effective playback rate is 0.0 while paused.
@ -1624,7 +1615,7 @@ TEST_F(WebMediaPlayerImplTest, MediaPositionState_Paused) {
TEST_F(WebMediaPlayerImplTest, MediaPositionState_PositionChange) {
InitializeWebMediaPlayerImpl();
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveFutureData);
WebMediaPlayer::kReadyStateHaveFutureData);
wmpi_->SetRate(0.5);
Play();
@ -1643,7 +1634,7 @@ TEST_F(WebMediaPlayerImplTest, MediaPositionState_PositionChange) {
0.5, kAudioOnlyTestFileDuration,
base::TimeDelta::FromSecondsD(0.1), /*end_of_media=*/false))
.InSequence(sequence);
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
wmpi_->OnTimeUpdate();
// No media time progress -> no MediaPositionState change.
@ -1653,10 +1644,10 @@ TEST_F(WebMediaPlayerImplTest, MediaPositionState_PositionChange) {
TEST_F(WebMediaPlayerImplTest, MediaPositionState_EndOfMedia) {
InitializeWebMediaPlayerImpl();
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveFutureData);
WebMediaPlayer::kReadyStateHaveFutureData);
wmpi_->SetRate(1.0);
Play();
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveFutureData);
SetReadyState(WebMediaPlayer::kReadyStateHaveFutureData);
testing::Sequence sequence;
EXPECT_CALL(client_, DidPlayerMediaPositionStateChange(
@ -1677,7 +1668,7 @@ TEST_F(WebMediaPlayerImplTest, MediaPositionState_EndOfMedia) {
TEST_F(WebMediaPlayerImplTest, MediaPositionState_Underflow) {
InitializeWebMediaPlayerImpl();
LoadAndWaitForReadyState(kAudioOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveFutureData);
WebMediaPlayer::kReadyStateHaveFutureData);
wmpi_->SetRate(1.0);
Play();
@ -1685,7 +1676,7 @@ TEST_F(WebMediaPlayerImplTest, MediaPositionState_Underflow) {
EXPECT_CALL(client_, DidPlayerMediaPositionStateChange(
0.0, kAudioOnlyTestFileDuration, base::TimeDelta(),
/*end_of_media=*/false));
SetReadyState(blink::WebMediaPlayer::kReadyStateHaveCurrentData);
SetReadyState(WebMediaPlayer::kReadyStateHaveCurrentData);
wmpi_->OnTimeUpdate();
}
@ -1727,17 +1718,15 @@ TEST_F(WebMediaPlayerImplTest, NoStreams) {
// No assertions in the production code should fail.
OnMetadata(metadata);
EXPECT_EQ(wmpi_->GetNetworkState(),
blink::WebMediaPlayer::kNetworkStateFormatError);
EXPECT_EQ(wmpi_->GetReadyState(),
blink::WebMediaPlayer::kReadyStateHaveNothing);
EXPECT_EQ(wmpi_->GetNetworkState(), WebMediaPlayer::kNetworkStateFormatError);
EXPECT_EQ(wmpi_->GetReadyState(), WebMediaPlayer::kReadyStateHaveNothing);
}
TEST_F(WebMediaPlayerImplTest, Encrypted) {
InitializeWebMediaPlayerImpl();
// To avoid PreloadMetadataLazyLoad.
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
{
base::RunLoop run_loop;
@ -1762,8 +1751,7 @@ TEST_F(WebMediaPlayerImplTest, Encrypted) {
// error.
base::RunLoop run_loop;
EXPECT_CALL(client_, NetworkStateChanged()).WillOnce(Invoke([&] {
if (wmpi_->GetNetworkState() ==
blink::WebMediaPlayer::kNetworkStateFormatError)
if (wmpi_->GetNetworkState() == WebMediaPlayer::kNetworkStateFormatError)
run_loop.QuitClosure().Run();
}));
SetCdm();
@ -1793,7 +1781,7 @@ ACTION(ReportHaveEnough) {
TEST_F(WebMediaPlayerImplTest, FallbackToMediaFoundationRenderer) {
InitializeWebMediaPlayerImpl();
// To avoid PreloadMetadataLazyLoad.
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
// Use MockRendererFactory for kMediaFoundation where the created Renderer
// will take the CDM, complete Renderer initialization and report HAVE_ENOUGH
@ -1961,7 +1949,7 @@ TEST_F(WebMediaPlayerImplTest, VideoLockedWhenPausedWhenHidden) {
// With a user gesture it does unlock the player.
GetWebLocalFrame()->NotifyUserActivation(
blink::mojom::UserActivationNotificationType::kTest);
mojom::UserActivationNotificationType::kTest);
Play();
EXPECT_FALSE(IsVideoLockedWhenPausedWhenHidden());
@ -1972,7 +1960,7 @@ TEST_F(WebMediaPlayerImplTest, VideoLockedWhenPausedWhenHidden) {
// With a user gesture, pause does lock the player.
GetWebLocalFrame()->NotifyUserActivation(
blink::mojom::UserActivationNotificationType::kTest);
mojom::UserActivationNotificationType::kTest);
Pause();
EXPECT_TRUE(IsVideoLockedWhenPausedWhenHidden());
@ -2097,7 +2085,7 @@ TEST_F(WebMediaPlayerImplTest, PictureInPictureStateChange) {
OnMetadata(metadata);
EXPECT_CALL(client_, GetDisplayType())
.WillRepeatedly(Return(blink::DisplayType::kPictureInPicture));
.WillRepeatedly(Return(DisplayType::kPictureInPicture));
EXPECT_CALL(client_, OnPictureInPictureStateChange()).Times(1);
wmpi_->OnSurfaceIdUpdated(surface_id_);
@ -2109,15 +2097,14 @@ TEST_F(WebMediaPlayerImplTest, OnProgressClearsStale) {
InitializeWebMediaPlayerImpl();
SetMetadata(true, true);
for (auto rs = blink::WebMediaPlayer::kReadyStateHaveNothing;
rs <= blink::WebMediaPlayer::kReadyStateHaveEnoughData;
rs = static_cast<blink::WebMediaPlayer::ReadyState>(
static_cast<int>(rs) + 1)) {
for (auto rs = WebMediaPlayer::kReadyStateHaveNothing;
rs <= WebMediaPlayer::kReadyStateHaveEnoughData;
rs = static_cast<WebMediaPlayer::ReadyState>(static_cast<int>(rs) + 1)) {
SetReadyState(rs);
delegate_.SetStaleForTesting(true);
OnProgress();
EXPECT_EQ(delegate_.IsStale(delegate_.player_id()),
rs >= blink::WebMediaPlayer::kReadyStateHaveFutureData);
rs >= WebMediaPlayer::kReadyStateHaveFutureData);
}
}
@ -2131,7 +2118,7 @@ TEST_F(WebMediaPlayerImplTest, MAYBE_MemDumpProvidersRegistration) {
auto* dump_manager = base::trace_event::MemoryDumpManager::GetInstance();
InitializeWebMediaPlayerImpl();
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
auto* main_dumper = GetMainThreadMemDumper();
EXPECT_TRUE(dump_manager->IsDumpProviderRegisteredForTesting(main_dumper));
LoadAndWaitForCurrentData(kVideoAudioTestFile);
@ -2150,7 +2137,7 @@ TEST_F(WebMediaPlayerImplTest, MAYBE_MemDumpProvidersRegistration) {
TEST_F(WebMediaPlayerImplTest, MemDumpReporting) {
InitializeWebMediaPlayerImpl();
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
wmpi_->SetPreload(WebMediaPlayer::kPreloadAuto);
LoadAndWaitForCurrentData(kVideoAudioTestFile);
CycleThreads();
@ -2240,11 +2227,10 @@ TEST_F(WebMediaPlayerImplTest, DISABLED_DemuxerOverride) {
InitializeWebMediaPlayerImplInternal(std::move(demuxer));
EXPECT_FALSE(IsSuspended());
wmpi_->Load(
blink::WebMediaPlayer::kLoadTypeURL,
blink::WebMediaPlayerSource(blink::WebURL(blink::KURL("data://test"))),
blink::WebMediaPlayer::kCorsModeUnspecified,
/*is_cache_disabled=*/false);
wmpi_->Load(WebMediaPlayer::kLoadTypeURL,
WebMediaPlayerSource(WebURL(KURL("data://test"))),
WebMediaPlayer::kCorsModeUnspecified,
/*is_cache_disabled=*/false);
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(IsSuspended());
}
@ -2297,15 +2283,15 @@ class WebMediaPlayerImplBackgroundBehaviorTest
InitializeWebMediaPlayerImpl();
bool is_media_source = std::get<kIsMediaSource>(GetParam());
SetLoadType(is_media_source ? blink::WebMediaPlayer::kLoadTypeMediaSource
: blink::WebMediaPlayer::kLoadTypeURL);
SetLoadType(is_media_source ? WebMediaPlayer::kLoadTypeMediaSource
: WebMediaPlayer::kLoadTypeURL);
SetVideoKeyframeDistanceAverage(
base::TimeDelta::FromSeconds(GetAverageKeyframeDistanceSec()));
SetDuration(base::TimeDelta::FromSeconds(GetDurationSec()));
if (IsPictureInPictureOn()) {
EXPECT_CALL(client_, GetDisplayType())
.WillRepeatedly(Return(blink::DisplayType::kPictureInPicture));
.WillRepeatedly(Return(DisplayType::kPictureInPicture));
wmpi_->OnSurfaceIdUpdated(surface_id_);
}

@ -22,7 +22,7 @@ WebMediaPlayerParams::WebMediaPlayerParams(
const scoped_refptr<base::SingleThreadTaskRunner>&
video_frame_compositor_task_runner,
const AdjustAllocatedMemoryCB& adjust_allocated_memory_cb,
blink::WebContentDecryptionModule* initial_cdm,
WebContentDecryptionModule* initial_cdm,
media::RequestRoutingTokenCallback request_routing_token_cb,
base::WeakPtr<media::MediaObserver> media_observer,
bool enable_instant_source_buffer_gc,
@ -30,7 +30,7 @@ WebMediaPlayerParams::WebMediaPlayerParams(
mojo::PendingRemote<media::mojom::MediaMetricsProvider> metrics_provider,
CreateSurfaceLayerBridgeCB create_bridge_callback,
scoped_refptr<viz::RasterContextProvider> raster_context_provider,
blink::WebMediaPlayer::SurfaceLayerMode use_surface_layer_for_video,
WebMediaPlayer::SurfaceLayerMode use_surface_layer_for_video,
bool is_background_suspend_enabled,
bool is_background_video_playback_enabled,
bool is_background_video_track_optimization_supported,

@ -30,9 +30,9 @@ WebMediaSourceImpl::WebMediaSourceImpl(media::ChunkDemuxer* demuxer)
WebMediaSourceImpl::~WebMediaSourceImpl() = default;
std::unique_ptr<blink::WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
const blink::WebString& content_type,
const blink::WebString& codecs,
std::unique_ptr<WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
const WebString& content_type,
const WebString& codecs,
WebMediaSource::AddStatus& out_status /* out */) {
std::string id = base::GenerateGUID();
@ -45,7 +45,7 @@ std::unique_ptr<blink::WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
return nullptr;
}
std::unique_ptr<blink::WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
std::unique_ptr<WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
std::unique_ptr<media::AudioDecoderConfig> audio_config,
WebMediaSource::AddStatus& out_status /* out */) {
std::string id = base::GenerateGUID();
@ -59,7 +59,7 @@ std::unique_ptr<blink::WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
return nullptr;
}
std::unique_ptr<blink::WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
std::unique_ptr<WebSourceBuffer> WebMediaSourceImpl::AddSourceBuffer(
std::unique_ptr<media::VideoDecoderConfig> video_config,
WebMediaSource::AddStatus& out_status /* out */) {
std::string id = base::GenerateGUID();

@ -18,22 +18,22 @@ class VideoDecoderConfig;
namespace blink {
class PLATFORM_EXPORT WebMediaSourceImpl : public blink::WebMediaSource {
class PLATFORM_EXPORT WebMediaSourceImpl : public WebMediaSource {
public:
WebMediaSourceImpl(media::ChunkDemuxer* demuxer);
WebMediaSourceImpl(const WebMediaSourceImpl&) = delete;
WebMediaSourceImpl& operator=(const WebMediaSourceImpl&) = delete;
~WebMediaSourceImpl() override;
// blink::WebMediaSource implementation.
std::unique_ptr<blink::WebSourceBuffer> AddSourceBuffer(
const blink::WebString& content_type,
const blink::WebString& codecs,
// WebMediaSource implementation.
std::unique_ptr<WebSourceBuffer> AddSourceBuffer(
const WebString& content_type,
const WebString& codecs,
AddStatus& out_status /* out */) override;
std::unique_ptr<blink::WebSourceBuffer> AddSourceBuffer(
std::unique_ptr<WebSourceBuffer> AddSourceBuffer(
std::unique_ptr<media::AudioDecoderConfig> audio_config,
AddStatus& out_status /* out */) override;
std::unique_ptr<blink::WebSourceBuffer> AddSourceBuffer(
std::unique_ptr<WebSourceBuffer> AddSourceBuffer(
std::unique_ptr<media::VideoDecoderConfig> video_config,
AddStatus& out_status /* out */) override;
double Duration() override;

@ -22,11 +22,11 @@
namespace blink {
static blink::WebSourceBufferClient::ParseWarning ParseWarningToBlink(
static WebSourceBufferClient::ParseWarning ParseWarningToBlink(
const media::SourceBufferParseWarning warning) {
#define CHROMIUM_PARSE_WARNING_TO_BLINK_ENUM_CASE(name) \
case media::SourceBufferParseWarning::name: \
return blink::WebSourceBufferClient::ParseWarning::name
return WebSourceBufferClient::ParseWarning::name
switch (warning) {
CHROMIUM_PARSE_WARNING_TO_BLINK_ENUM_CASE(
@ -37,8 +37,7 @@ static blink::WebSourceBufferClient::ParseWarning ParseWarningToBlink(
}
NOTREACHED();
return blink::WebSourceBufferClient::ParseWarning::
kKeyframeTimeGreaterThanDependant;
return WebSourceBufferClient::ParseWarning::kKeyframeTimeGreaterThanDependant;
#undef CHROMIUM_PARSE_WARNING_TO_BLINK_ENUM_CASE
}
@ -77,7 +76,7 @@ WebSourceBufferImpl::WebSourceBufferImpl(const std::string& id,
WebSourceBufferImpl::~WebSourceBufferImpl() = default;
void WebSourceBufferImpl::SetClient(blink::WebSourceBufferClient* client) {
void WebSourceBufferImpl::SetClient(WebSourceBufferClient* client) {
DCHECK(client);
DCHECK(!client_);
client_ = client;
@ -104,9 +103,9 @@ bool WebSourceBufferImpl::SetMode(WebSourceBuffer::AppendMode mode) {
return false;
}
blink::WebTimeRanges WebSourceBufferImpl::Buffered() {
WebTimeRanges WebSourceBufferImpl::Buffered() {
media::Ranges<base::TimeDelta> ranges = demuxer_->GetBufferedRanges(id_);
blink::WebTimeRanges result(ranges.size());
WebTimeRanges result(ranges.size());
for (size_t i = 0; i < ranges.size(); i++) {
result[i].start = ranges.start(i).InSecondsF();
result[i].end = ranges.end(i).InSecondsF();
@ -177,13 +176,13 @@ void WebSourceBufferImpl::Remove(double start, double end) {
demuxer_->Remove(id_, DoubleToTimeDelta(start), DoubleToTimeDelta(end));
}
bool WebSourceBufferImpl::CanChangeType(const blink::WebString& content_type,
const blink::WebString& codecs) {
bool WebSourceBufferImpl::CanChangeType(const WebString& content_type,
const WebString& codecs) {
return demuxer_->CanChangeType(id_, content_type.Utf8(), codecs.Utf8());
}
void WebSourceBufferImpl::ChangeType(const blink::WebString& content_type,
const blink::WebString& codecs) {
void WebSourceBufferImpl::ChangeType(const WebString& content_type,
const WebString& codecs) {
// Caller must first call ResetParserState() to flush any pending frames.
DCHECK(!demuxer_->IsParsingMediaSegment(id_));
@ -219,18 +218,17 @@ void WebSourceBufferImpl::RemovedFromMediaSource() {
client_ = nullptr;
}
blink::WebMediaPlayer::TrackType mediaTrackTypeToBlink(
media::MediaTrack::Type type) {
WebMediaPlayer::TrackType mediaTrackTypeToBlink(media::MediaTrack::Type type) {
switch (type) {
case media::MediaTrack::Audio:
return blink::WebMediaPlayer::kAudioTrack;
return WebMediaPlayer::kAudioTrack;
case media::MediaTrack::Text:
return blink::WebMediaPlayer::kTextTrack;
return WebMediaPlayer::kTextTrack;
case media::MediaTrack::Video:
return blink::WebMediaPlayer::kVideoTrack;
return WebMediaPlayer::kVideoTrack;
}
NOTREACHED();
return blink::WebMediaPlayer::kAudioTrack;
return WebMediaPlayer::kAudioTrack;
}
void WebSourceBufferImpl::InitSegmentReceived(
@ -238,16 +236,16 @@ void WebSourceBufferImpl::InitSegmentReceived(
DCHECK(tracks.get());
DVLOG(1) << __func__ << " tracks=" << tracks->tracks().size();
std::vector<blink::WebSourceBufferClient::MediaTrackInfo> trackInfoVector;
std::vector<WebSourceBufferClient::MediaTrackInfo> trackInfoVector;
for (const auto& track : tracks->tracks()) {
blink::WebSourceBufferClient::MediaTrackInfo trackInfo;
WebSourceBufferClient::MediaTrackInfo trackInfo;
trackInfo.track_type = mediaTrackTypeToBlink(track->type());
trackInfo.id = blink::WebString::FromUTF8(track->id().value());
trackInfo.byte_stream_track_id = blink::WebString::FromUTF8(
base::NumberToString(track->bytestream_track_id()));
trackInfo.kind = blink::WebString::FromUTF8(track->kind().value());
trackInfo.label = blink::WebString::FromUTF8(track->label().value());
trackInfo.language = blink::WebString::FromUTF8(track->language().value());
trackInfo.id = WebString::FromUTF8(track->id().value());
trackInfo.byte_stream_track_id =
WebString::FromUTF8(base::NumberToString(track->bytestream_track_id()));
trackInfo.kind = WebString::FromUTF8(track->kind().value());
trackInfo.label = WebString::FromUTF8(track->label().value());
trackInfo.language = WebString::FromUTF8(track->language().value());
trackInfoVector.push_back(trackInfo);
}

@ -23,18 +23,18 @@ enum class SourceBufferParseWarning;
namespace blink {
class PLATFORM_EXPORT WebSourceBufferImpl : public blink::WebSourceBuffer {
class PLATFORM_EXPORT WebSourceBufferImpl : public WebSourceBuffer {
public:
WebSourceBufferImpl(const std::string& id, media::ChunkDemuxer* demuxer);
WebSourceBufferImpl(const WebSourceBufferImpl&) = delete;
WebSourceBufferImpl& operator=(const WebSourceBufferImpl&) = delete;
~WebSourceBufferImpl() override;
// blink::WebSourceBuffer implementation.
void SetClient(blink::WebSourceBufferClient* client) override;
// WebSourceBuffer implementation.
void SetClient(WebSourceBufferClient* client) override;
bool GetGenerateTimestampsFlag() override;
bool SetMode(AppendMode mode) override;
blink::WebTimeRanges Buffered() override;
WebTimeRanges Buffered() override;
double HighestPresentationTimestamp() override;
bool EvictCodedFrames(double currentPlaybackTime,
size_t newDataSize) override;
@ -46,10 +46,10 @@ class PLATFORM_EXPORT WebSourceBufferImpl : public blink::WebSourceBuffer {
double* timestamp_offset) override;
void ResetParserState() override;
void Remove(double start, double end) override;
bool CanChangeType(const blink::WebString& content_type,
const blink::WebString& codecs) override;
void ChangeType(const blink::WebString& content_type,
const blink::WebString& codecs) override;
bool CanChangeType(const WebString& content_type,
const WebString& codecs) override;
void ChangeType(const WebString& content_type,
const WebString& codecs) override;
bool SetTimestampOffset(double offset) override;
void SetAppendWindowStart(double start) override;
void SetAppendWindowEnd(double end) override;
@ -66,7 +66,7 @@ class PLATFORM_EXPORT WebSourceBufferImpl : public blink::WebSourceBuffer {
std::string id_;
media::ChunkDemuxer* demuxer_; // Owned by WebMediaPlayerImpl.
blink::WebSourceBufferClient* client_;
WebSourceBufferClient* client_;
// Controls the offset applied to timestamps when processing appended media
// segments. It is initially 0, which indicates that no offset is being