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

Unified Diff: content/renderer/media/crypto/key_systems.cc

Issue 404613003: Update supported key system info from browser process if needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/crypto/key_systems.cc
diff --git a/content/renderer/media/crypto/key_systems.cc b/content/renderer/media/crypto/key_systems.cc
index 6cd82189a2e94761b6048d6792a06841798706c5..2152378a885bc42d89d83783731f496f543224b1 100644
--- a/content/renderer/media/crypto/key_systems.cc
+++ b/content/renderer/media/crypto/key_systems.cc
@@ -10,6 +10,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
+#include "base/time/time.h"
#include "content/public/common/content_client.h"
#include "content/public/common/eme_codec.h"
#include "content/public/renderer/content_renderer_client.h"
@@ -87,6 +88,8 @@ class KeySystems {
public:
static KeySystems& GetInstance();
+ void UpdateIfNeeded();
+
bool IsConcreteSupportedKeySystem(const std::string& key_system);
bool IsSupportedKeySystemWithMediaMimeType(
@@ -104,6 +107,8 @@ class KeySystems {
void AddCodecMask(const std::string& codec, uint32 mask);
private:
+ void UpdateSupportedKeySystems();
+
void AddConcreteSupportedKeySystems(
const std::vector<KeySystemInfo>& concrete_key_systems);
@@ -161,12 +166,15 @@ class KeySystems {
CodecMaskMap container_codec_masks_;
CodecMaskMap codec_masks_;
+ base::Time last_update_time_;
+
DISALLOW_COPY_AND_ASSIGN(KeySystems);
};
static base::LazyInstance<KeySystems> g_key_systems = LAZY_INSTANCE_INITIALIZER;
KeySystems& KeySystems::GetInstance() {
+ g_key_systems.Get().UpdateIfNeeded();
return g_key_systems.Get();
}
@@ -187,14 +195,45 @@ KeySystems::KeySystems() {
codec_masks_[codec_mask.type] = codec_mask.mask;
}
+ UpdateSupportedKeySystems();
+
+#if defined(WIDEVINE_CDM_AVAILABLE)
+ key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem);
+#endif // defined(WIDEVINE_CDM_AVAILABLE)
+}
+
+void KeySystems::UpdateIfNeeded() {
+#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
+ if (IsConcreteSupportedKeySystem(kWidevineKeySystem))
+ return;
+
+ // The update could involve a sync IPC to the browser process. Use a minimum
+ // update interval to avoid unnecessary frequent IPC to the browser.
+ static const int kMinUpdateIntervalInSeconds = 5;
+ base::Time now = base::Time::Now();
+ if (now - last_update_time_ <
+ base::TimeDelta::FromSeconds(kMinUpdateIntervalInSeconds)) {
+ return;
+ }
+
+ UpdateSupportedKeySystems();
+#endif
+}
+
+void KeySystems::UpdateSupportedKeySystems() {
+ DVLOG(2) << __FUNCTION__;
xhwang 2014/07/18 00:44:15 I'll remove this.
+ concrete_key_system_map_.clear();
+ parent_key_system_map_.clear();
+
+ // Build KeySystemInfo.
std::vector<KeySystemInfo> key_systems_info;
GetContentClient()->renderer()->AddKeySystems(&key_systems_info);
// Clear Key is always supported.
AddClearKey(&key_systems_info);
+
AddConcreteSupportedKeySystems(key_systems_info);
-#if defined(WIDEVINE_CDM_AVAILABLE)
- key_systems_support_uma_.AddKeySystemToReport(kWidevineKeySystem);
-#endif // defined(WIDEVINE_CDM_AVAILABLE)
+
+ last_update_time_ = base::Time::Now();
}
void KeySystems::AddConcreteSupportedKeySystems(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698