| 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/ppapi_decryptor.h" | 5 #include "content/renderer/media/crypto/ppapi_decryptor.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 // TODO(jrummell): Intercepting the promise should not be necessary once | 205 // TODO(jrummell): Intercepting the promise should not be necessary once |
| 206 // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. | 206 // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. |
| 207 scoped_ptr<SessionLoadedPromise> session_loaded_promise( | 207 scoped_ptr<SessionLoadedPromise> session_loaded_promise( |
| 208 new SessionLoadedPromise(promise.Pass(), | 208 new SessionLoadedPromise(promise.Pass(), |
| 209 base::Bind(&PpapiDecryptor::ResumePlayback, | 209 base::Bind(&PpapiDecryptor::ResumePlayback, |
| 210 weak_ptr_factory_.GetWeakPtr()))); | 210 weak_ptr_factory_.GetWeakPtr()))); |
| 211 | 211 |
| 212 CdmDelegate()->LoadSession( | 212 CdmDelegate()->LoadSession(web_session_id, session_loaded_promise.Pass()); |
| 213 web_session_id, | |
| 214 session_loaded_promise.PassAs<media::NewSessionCdmPromise>()); | |
| 215 } | 213 } |
| 216 | 214 |
| 217 void PpapiDecryptor::UpdateSession( | 215 void PpapiDecryptor::UpdateSession( |
| 218 const std::string& web_session_id, | 216 const std::string& web_session_id, |
| 219 const uint8* response, | 217 const uint8* response, |
| 220 int response_length, | 218 int response_length, |
| 221 scoped_ptr<media::SimpleCdmPromise> promise) { | 219 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 222 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 220 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 223 | 221 |
| 224 if (!CdmDelegate()) { | 222 if (!CdmDelegate()) { |
| 225 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 223 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 226 return; | 224 return; |
| 227 } | 225 } |
| 228 | 226 |
| 229 // TODO(jrummell): Intercepting the promise should not be necessary once | 227 // TODO(jrummell): Intercepting the promise should not be necessary once |
| 230 // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. | 228 // OnSessionKeysChange() is called in all cases. http://crbug.com/413413. |
| 231 scoped_ptr<SessionUpdatedPromise> session_updated_promise( | 229 scoped_ptr<SessionUpdatedPromise> session_updated_promise( |
| 232 new SessionUpdatedPromise(promise.Pass(), | 230 new SessionUpdatedPromise(promise.Pass(), |
| 233 base::Bind(&PpapiDecryptor::ResumePlayback, | 231 base::Bind(&PpapiDecryptor::ResumePlayback, |
| 234 weak_ptr_factory_.GetWeakPtr()))); | 232 weak_ptr_factory_.GetWeakPtr()))); |
| 235 CdmDelegate()->UpdateSession( | 233 CdmDelegate()->UpdateSession(web_session_id, |
| 236 web_session_id, | 234 response, |
| 237 response, | 235 response_length, |
| 238 response_length, | 236 session_updated_promise.Pass()); |
| 239 session_updated_promise.PassAs<media::SimpleCdmPromise>()); | |
| 240 } | 237 } |
| 241 | 238 |
| 242 void PpapiDecryptor::CloseSession(const std::string& web_session_id, | 239 void PpapiDecryptor::CloseSession(const std::string& web_session_id, |
| 243 scoped_ptr<media::SimpleCdmPromise> promise) { | 240 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 244 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 241 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 245 | 242 |
| 246 if (!CdmDelegate()) { | 243 if (!CdmDelegate()) { |
| 247 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); | 244 promise->reject(INVALID_STATE_ERROR, 0, "CdmDelegate() does not exist."); |
| 248 return; | 245 return; |
| 249 } | 246 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 542 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 546 pepper_cdm_wrapper_.reset(); | 543 pepper_cdm_wrapper_.reset(); |
| 547 } | 544 } |
| 548 | 545 |
| 549 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { | 546 ContentDecryptorDelegate* PpapiDecryptor::CdmDelegate() { |
| 550 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 547 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 551 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; | 548 return (pepper_cdm_wrapper_) ? pepper_cdm_wrapper_->GetCdmDelegate() : NULL; |
| 552 } | 549 } |
| 553 | 550 |
| 554 } // namespace content | 551 } // namespace content |
| OLD | NEW |