OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper/content_decryptor_delegate.h" | 5 #include "content/renderer/pepper/content_decryptor_delegate.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 618 |
619 // TODO(tomfinegan): Need to get stream type from media stack. | 619 // TODO(tomfinegan): Need to get stream type from media stack. |
620 ScopedPPResource pp_resource(encrypted_resource.get()); | 620 ScopedPPResource pp_resource(encrypted_resource.get()); |
621 plugin_decryption_interface_->DecryptAndDecode( | 621 plugin_decryption_interface_->DecryptAndDecode( |
622 pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info); | 622 pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info); |
623 return true; | 623 return true; |
624 } | 624 } |
625 | 625 |
626 void ContentDecryptorDelegate::OnPromiseResolved(uint32 promise_id) { | 626 void ContentDecryptorDelegate::OnPromiseResolved(uint32 promise_id) { |
627 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); | 627 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); |
628 if (promise) { | 628 if (!promise || |
629 SimpleCdmPromise* simple_promise( | 629 promise->GetResolveParameterType() != media::CdmPromise::VOID_TYPE) { |
630 static_cast<SimpleCdmPromise*>(promise.get())); | 630 NOTREACHED(); |
631 simple_promise->resolve(); | 631 return; |
632 } | 632 } |
| 633 |
| 634 SimpleCdmPromise* simple_promise( |
| 635 static_cast<SimpleCdmPromise*>(promise.get())); |
| 636 simple_promise->resolve(); |
633 } | 637 } |
634 | 638 |
635 void ContentDecryptorDelegate::OnPromiseResolvedWithSession( | 639 void ContentDecryptorDelegate::OnPromiseResolvedWithSession( |
636 uint32 promise_id, | 640 uint32 promise_id, |
637 PP_Var web_session_id) { | 641 PP_Var web_session_id) { |
638 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); | 642 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); |
| 643 if (!promise || |
| 644 promise->GetResolveParameterType() != media::CdmPromise::STRING_TYPE) { |
| 645 NOTREACHED(); |
| 646 return; |
| 647 } |
639 | 648 |
640 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 649 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
641 DCHECK(web_session_id_string); | 650 DCHECK(web_session_id_string); |
642 | 651 |
643 if (promise) { | 652 NewSessionCdmPromise* session_promise( |
644 NewSessionCdmPromise* session_promise( | 653 static_cast<NewSessionCdmPromise*>(promise.get())); |
645 static_cast<NewSessionCdmPromise*>(promise.get())); | 654 session_promise->resolve(web_session_id_string->value()); |
646 session_promise->resolve(web_session_id_string->value()); | |
647 } | |
648 } | 655 } |
649 | 656 |
650 void ContentDecryptorDelegate::OnPromiseRejected( | 657 void ContentDecryptorDelegate::OnPromiseRejected( |
651 uint32 promise_id, | 658 uint32 promise_id, |
652 PP_CdmExceptionCode exception_code, | 659 PP_CdmExceptionCode exception_code, |
653 uint32 system_code, | 660 uint32 system_code, |
654 PP_Var error_description) { | 661 PP_Var error_description) { |
655 StringVar* error_description_string = StringVar::FromPPVar(error_description); | 662 StringVar* error_description_string = StringVar::FromPPVar(error_description); |
656 DCHECK(error_description_string); | 663 DCHECK(error_description_string); |
657 | 664 |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 | 1181 |
1175 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( | 1182 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( |
1176 uint32_t promise_id) { | 1183 uint32_t promise_id) { |
1177 PromiseMap::iterator it = promises_.find(promise_id); | 1184 PromiseMap::iterator it = promises_.find(promise_id); |
1178 if (it == promises_.end()) | 1185 if (it == promises_.end()) |
1179 return scoped_ptr<CdmPromise>(); | 1186 return scoped_ptr<CdmPromise>(); |
1180 return promises_.take_and_erase(it); | 1187 return promises_.take_and_erase(it); |
1181 } | 1188 } |
1182 | 1189 |
1183 } // namespace content | 1190 } // namespace content |
OLD | NEW |