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 |
| 629 // Special case due to http://crbug.com/408330. CDM is resolving LoadSession() |
| 630 // with this method when the session is not found. Instead it should call |
| 631 // PromiseResolvedWithSession(""), so emulate that here until 408330 is fixed. |
| 632 // TODO(jrummell): Remove this code when the CDM is updated. |
| 633 if (promise && |
| 634 promise->GetResolveParameterType() == media::CdmPromise::STRING_TYPE) { |
| 635 NewSessionCdmPromise* session_promise = |
| 636 static_cast<NewSessionCdmPromise*>(promise.get()); |
| 637 session_promise->resolve(std::string()); |
| 638 return; |
| 639 } |
| 640 |
628 if (!promise || | 641 if (!promise || |
629 promise->GetResolveParameterType() != media::CdmPromise::VOID_TYPE) { | 642 promise->GetResolveParameterType() != media::CdmPromise::VOID_TYPE) { |
630 NOTREACHED(); | 643 NOTREACHED(); |
631 return; | 644 return; |
632 } | 645 } |
633 | 646 |
634 SimpleCdmPromise* simple_promise( | 647 SimpleCdmPromise* simple_promise = |
635 static_cast<SimpleCdmPromise*>(promise.get())); | 648 static_cast<SimpleCdmPromise*>(promise.get()); |
636 simple_promise->resolve(); | 649 simple_promise->resolve(); |
637 } | 650 } |
638 | 651 |
639 void ContentDecryptorDelegate::OnPromiseResolvedWithSession( | 652 void ContentDecryptorDelegate::OnPromiseResolvedWithSession( |
640 uint32 promise_id, | 653 uint32 promise_id, |
641 PP_Var web_session_id) { | 654 PP_Var web_session_id) { |
642 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); | 655 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); |
643 if (!promise || | 656 if (!promise || |
644 promise->GetResolveParameterType() != media::CdmPromise::STRING_TYPE) { | 657 promise->GetResolveParameterType() != media::CdmPromise::STRING_TYPE) { |
645 NOTREACHED(); | 658 NOTREACHED(); |
646 return; | 659 return; |
647 } | 660 } |
648 | 661 |
649 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); | 662 StringVar* web_session_id_string = StringVar::FromPPVar(web_session_id); |
650 DCHECK(web_session_id_string); | 663 DCHECK(web_session_id_string); |
651 | 664 |
652 NewSessionCdmPromise* session_promise( | 665 NewSessionCdmPromise* session_promise = |
653 static_cast<NewSessionCdmPromise*>(promise.get())); | 666 static_cast<NewSessionCdmPromise*>(promise.get()); |
654 session_promise->resolve(web_session_id_string->value()); | 667 session_promise->resolve(web_session_id_string->value()); |
655 } | 668 } |
656 | 669 |
657 void ContentDecryptorDelegate::OnPromiseRejected( | 670 void ContentDecryptorDelegate::OnPromiseRejected( |
658 uint32 promise_id, | 671 uint32 promise_id, |
659 PP_CdmExceptionCode exception_code, | 672 PP_CdmExceptionCode exception_code, |
660 uint32 system_code, | 673 uint32 system_code, |
661 PP_Var error_description) { | 674 PP_Var error_description) { |
662 StringVar* error_description_string = StringVar::FromPPVar(error_description); | 675 StringVar* error_description_string = StringVar::FromPPVar(error_description); |
663 DCHECK(error_description_string); | 676 DCHECK(error_description_string); |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 | 1194 |
1182 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( | 1195 scoped_ptr<CdmPromise> ContentDecryptorDelegate::TakePromise( |
1183 uint32_t promise_id) { | 1196 uint32_t promise_id) { |
1184 PromiseMap::iterator it = promises_.find(promise_id); | 1197 PromiseMap::iterator it = promises_.find(promise_id); |
1185 if (it == promises_.end()) | 1198 if (it == promises_.end()) |
1186 return scoped_ptr<CdmPromise>(); | 1199 return scoped_ptr<CdmPromise>(); |
1187 return promises_.take_and_erase(it); | 1200 return promises_.take_and_erase(it); |
1188 } | 1201 } |
1189 | 1202 |
1190 } // namespace content | 1203 } // namespace content |
OLD | NEW |