Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/crypto/proxy_decryptor.h" | 5 #include "content/renderer/media/crypto/proxy_decryptor.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 std::equal(data, data + header.size(), header.begin()); | 95 std::equal(data, data + header.size(), header.begin()); |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type, | 98 bool ProxyDecryptor::GenerateKeyRequest(const std::string& content_type, |
| 99 const uint8* init_data, | 99 const uint8* init_data, |
| 100 int init_data_length) { | 100 int init_data_length) { |
| 101 DVLOG(1) << "GenerateKeyRequest()"; | 101 DVLOG(1) << "GenerateKeyRequest()"; |
| 102 const char kPrefixedApiPersistentSessionHeader[] = "PERSISTENT|"; | 102 const char kPrefixedApiPersistentSessionHeader[] = "PERSISTENT|"; |
| 103 const char kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|"; | 103 const char kPrefixedApiLoadSessionHeader[] = "LOAD_SESSION|"; |
| 104 | 104 |
| 105 bool loadSession = | 105 bool loadSession = |
|
ddorwin
2014/08/08 23:36:23
is_load_session
jrummell
2014/08/11 18:59:03
Done.
| |
| 106 HasHeader(init_data, init_data_length, kPrefixedApiLoadSessionHeader); | 106 HasHeader(init_data, init_data_length, kPrefixedApiLoadSessionHeader); |
| 107 bool persistent = HasHeader( | 107 bool persistent = HasHeader( |
|
ddorwin
2014/08/08 23:36:23
is_
is_create_persistent?
jrummell
2014/08/11 18:59:03
Done.
| |
| 108 init_data, init_data_length, kPrefixedApiPersistentSessionHeader); | 108 init_data, init_data_length, kPrefixedApiPersistentSessionHeader); |
| 109 | 109 |
| 110 scoped_ptr<media::NewSessionCdmPromise> promise( | 110 scoped_ptr<media::NewSessionCdmPromise> promise( |
| 111 new media::NewSessionCdmPromise( | 111 new media::NewSessionCdmPromise( |
| 112 base::Bind(&ProxyDecryptor::SetSessionId, | 112 base::Bind(&ProxyDecryptor::SetSessionId, |
| 113 weak_ptr_factory_.GetWeakPtr(), | 113 weak_ptr_factory_.GetWeakPtr(), |
| 114 persistent || loadSession), | 114 persistent, |
| 115 loadSession), | |
| 115 base::Bind(&ProxyDecryptor::OnSessionError, | 116 base::Bind(&ProxyDecryptor::OnSessionError, |
| 116 weak_ptr_factory_.GetWeakPtr(), | 117 weak_ptr_factory_.GetWeakPtr(), |
| 117 std::string()))); // No session id until created. | 118 std::string()))); // No session id until created. |
| 118 | 119 |
| 119 if (loadSession) { | 120 if (loadSession) { |
| 120 media_keys_->LoadSession( | 121 media_keys_->LoadSession( |
| 121 std::string(reinterpret_cast<const char*>( | 122 std::string(reinterpret_cast<const char*>( |
| 122 init_data + strlen(kPrefixedApiLoadSessionHeader)), | 123 init_data + strlen(kPrefixedApiLoadSessionHeader)), |
| 123 init_data_length - strlen(kPrefixedApiLoadSessionHeader)), | 124 init_data_length - strlen(kPrefixedApiLoadSessionHeader)), |
| 124 promise.Pass()); | 125 promise.Pass()); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 default: | 281 default: |
| 281 // This will include all other CDM4 errors and any error generated | 282 // This will include all other CDM4 errors and any error generated |
| 282 // by CDM5 or later. | 283 // by CDM5 or later. |
| 283 error_code = media::MediaKeys::kUnknownError; | 284 error_code = media::MediaKeys::kUnknownError; |
| 284 break; | 285 break; |
| 285 } | 286 } |
| 286 key_error_cb_.Run(web_session_id, error_code, system_code); | 287 key_error_cb_.Run(web_session_id, error_code, system_code); |
| 287 } | 288 } |
| 288 | 289 |
| 289 void ProxyDecryptor::SetSessionId(bool persistent, | 290 void ProxyDecryptor::SetSessionId(bool persistent, |
| 291 bool load_session, | |
| 290 const std::string& web_session_id) { | 292 const std::string& web_session_id) { |
| 291 active_sessions_.insert(std::make_pair(web_session_id, persistent)); | 293 active_sessions_.insert( |
| 294 std::make_pair(web_session_id, persistent || load_session)); | |
|
ddorwin
2014/08/08 23:36:23
it might be nice to use a local variable to descri
jrummell
2014/08/11 18:59:03
Done.
| |
| 295 | |
| 296 // For LoadSession(), generate the SessionReady event. | |
| 297 if (load_session) | |
| 298 OnSessionReady(web_session_id); | |
| 292 } | 299 } |
| 293 | 300 |
| 294 } // namespace content | 301 } // namespace content |
| OLD | NEW |