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

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

Issue 131653003: Support LoadSession() in MediaKeys and PPP_ContentDecryptor_Private interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 6 years, 10 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: content/renderer/media/crypto/proxy_decryptor.cc
diff --git a/content/renderer/media/crypto/proxy_decryptor.cc b/content/renderer/media/crypto/proxy_decryptor.cc
index 2e1b81a3df39e32ecea75909c9b411035f1feba6..2c9c0085ecca3667923a96a21e0c92bbdd7136f0 100644
--- a/content/renderer/media/crypto/proxy_decryptor.cc
+++ b/content/renderer/media/crypto/proxy_decryptor.cc
@@ -83,17 +83,32 @@ bool ProxyDecryptor::InitializeCDM(const std::string& key_system,
return true;
}
-bool ProxyDecryptor::GenerateKeyRequest(const std::string& type,
+bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type,
const uint8* init_data,
int init_data_length) {
// Use a unique reference id for this request.
uint32 session_id = next_session_id_++;
- if (!media_keys_->CreateSession(
- session_id, type, init_data, init_data_length)) {
- return false;
+
+ const uint8 kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|";
+ const int kPrefixedApiLoadSessionHeaderLength =
+ sizeof(kPrefixedApiLoadSessionHeader) - 1;
+
+ if (init_data_length > kPrefixedApiLoadSessionHeaderLength &&
+ std::equal(init_data,
+ init_data + kPrefixedApiLoadSessionHeaderLength,
+ kPrefixedApiLoadSessionHeader)) {
+ // TODO(xhwang): Track loadable session to handle OnSessionClosed().
+ // See: http://crbug.com/340859.
+ media_keys_->LoadSession(
+ session_id,
+ std::string(reinterpret_cast<const char*>(
+ init_data + kPrefixedApiLoadSessionHeaderLength),
+ init_data_length - kPrefixedApiLoadSessionHeaderLength));
+ return true;
}
- return true;
+ return media_keys_->CreateSession(
+ session_id, content_type, init_data, init_data_length);
}
void ProxyDecryptor::AddKey(const uint8* key,
@@ -214,8 +229,8 @@ void ProxyDecryptor::OnSessionError(uint32 session_id,
key_error_cb_.Run(LookupWebSessionId(session_id), error_code, system_code);
}
-uint32 ProxyDecryptor::LookupSessionId(const std::string& session_id) {
- for (SessionIdMap::iterator it = sessions_.begin();
+uint32 ProxyDecryptor::LookupSessionId(const std::string& session_id) const {
+ for (SessionIdMap::const_iterator it = sessions_.begin();
it != sessions_.end();
++it) {
if (it->second == session_id)
@@ -229,11 +244,11 @@ uint32 ProxyDecryptor::LookupSessionId(const std::string& session_id) {
return kInvalidSessionId;
}
-const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) {
+const std::string& ProxyDecryptor::LookupWebSessionId(uint32 session_id) const {
DCHECK_NE(session_id, kInvalidSessionId);
// Session may not exist if error happens during GenerateKeyRequest().
- SessionIdMap::iterator it = sessions_.find(session_id);
+ SessionIdMap::const_iterator it = sessions_.find(session_id);
return (it != sessions_.end()) ? it->second : base::EmptyString();
}
« no previous file with comments | « content/renderer/media/crypto/proxy_decryptor.h ('k') | content/renderer/pepper/content_decryptor_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698