Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(700)

Unified Diff: media/base/key_systems.cc

Issue 2712983004: Simplify/Cleanup MediaClient (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/key_systems.cc
diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc
index 4dee18a97ee5413bf527431b7c93ba5c6bf90e31..95d17af2888e0ed8086a49f55fb15984b0952092 100644
--- a/media/base/key_systems.cc
+++ b/media/base/key_systems.cc
@@ -169,8 +169,6 @@ class KeySystemsImpl : public KeySystems {
public:
static KeySystemsImpl* GetInstance();
- void UpdateIfNeeded();
-
std::string GetKeySystemNameForUMA(const std::string& key_system) const;
bool UseAesDecryptor(const std::string& key_system) const;
@@ -234,7 +232,6 @@ class KeySystemsImpl : public KeySystems {
typedef base::hash_map<std::string, SupportedCodecs> MimeTypeCodecsMap;
typedef base::hash_map<std::string, EmeCodec> CodecsMap;
typedef base::hash_map<std::string, EmeInitDataType> InitDataTypesMap;
- typedef base::hash_map<std::string, std::string> KeySystemNameForUMAMap;
// TODO(sandersd): Separate container enum from codec mask value.
// http://crbug.com/417440
@@ -249,7 +246,6 @@ class KeySystemsImpl : public KeySystems {
// This member should only be modified by RegisterMimeType().
MimeTypeCodecsMap mime_type_to_codec_mask_map_;
CodecsMap codec_string_map_;
- KeySystemNameForUMAMap key_system_name_for_uma_map_;
SupportedCodecs audio_codec_mask_;
SupportedCodecs video_codec_mask_;
@@ -262,7 +258,6 @@ class KeySystemsImpl : public KeySystems {
KeySystemsImpl* KeySystemsImpl::GetInstance() {
static KeySystemsImpl* key_systems = new KeySystemsImpl();
- key_systems->UpdateIfNeeded();
return key_systems;
}
@@ -281,8 +276,6 @@ KeySystemsImpl::KeySystemsImpl()
kMimeTypeToCodecMasks[i].type);
}
- InitializeUMAInfo();
-
// Always update supported key systems during construction.
UpdateSupportedKeySystems();
}
@@ -308,29 +301,6 @@ EmeCodec KeySystemsImpl::GetCodecForString(const std::string& codec) const {
return EME_CODEC_NONE;
}
-void KeySystemsImpl::InitializeUMAInfo() {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(key_system_name_for_uma_map_.empty());
-
- std::vector<KeySystemInfoForUMA> key_systems_info_for_uma;
- if (GetMediaClient())
- GetMediaClient()->AddKeySystemsInfoForUMA(&key_systems_info_for_uma);
-
- for (const KeySystemInfoForUMA& info : key_systems_info_for_uma) {
- key_system_name_for_uma_map_[info.key_system] =
- info.key_system_name_for_uma;
- }
-
- // Clear Key is always supported.
- key_system_name_for_uma_map_[kClearKeyKeySystem] =
- kClearKeyKeySystemNameForUMA;
-}
-
-void KeySystemsImpl::UpdateIfNeeded() {
- if (GetMediaClient() && GetMediaClient()->IsKeySystemsUpdateNeeded())
- UpdateSupportedKeySystems();
-}
-
void KeySystemsImpl::UpdateSupportedKeySystems() {
DCHECK(thread_checker_.CalledOnValidThread());
key_system_properties_map_.clear();
@@ -338,8 +308,11 @@ void KeySystemsImpl::UpdateSupportedKeySystems() {
std::vector<std::unique_ptr<KeySystemProperties>> key_systems_properties;
// Add key systems supported by the MediaClient implementation.
- if (GetMediaClient())
+ if (GetMediaClient()) {
GetMediaClient()->AddSupportedKeySystems(&key_systems_properties);
+ } else {
+ DVLOG(1) << __func__ << " No media client to provide key systems";
+ }
// Clear Key is always supported.
key_systems_properties.emplace_back(new ClearKeyProperties());
@@ -443,6 +416,8 @@ void KeySystemsImpl::AddSupportedKeySystems(
}
#endif // defined(OS_ANDROID)
+ DVLOG(1) << __func__
+ << " Adding key system:" << properties->GetKeySystemName();
key_system_properties_map_[properties->GetKeySystemName()] =
std::move(properties);
}
@@ -494,12 +469,16 @@ std::string KeySystemsImpl::GetKeySystemNameForUMA(
const std::string& key_system) const {
DCHECK(thread_checker_.CalledOnValidThread());
- KeySystemNameForUMAMap::const_iterator iter =
- key_system_name_for_uma_map_.find(key_system);
- if (iter == key_system_name_for_uma_map_.end())
- return kUnknownKeySystemNameForUMA;
+ // Here we maintain a short list of known key systems to facilitate UMA
+ // reporting. Mentioned key systems are not necessarily supported by
+ // the current platform.
+ if (key_system == kWidevineKeySystem)
+ return kWidevineKeySystemNameForUMA;
- return iter->second;
+ if (key_system == kClearKeyKeySystem)
+ return kClearKeyKeySystemNameForUMA;
+
+ return kUnknownKeySystemNameForUMA;
}
bool KeySystemsImpl::UseAesDecryptor(const std::string& key_system) const {

Powered by Google App Engine
This is Rietveld 408576698