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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <string> | 10 #include <string> |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 host_->OnSessionMessage(web_session_id.data(), | 693 host_->OnSessionMessage(web_session_id.data(), |
694 web_session_id.length(), | 694 web_session_id.length(), |
695 reinterpret_cast<const char*>(message.data()), | 695 reinterpret_cast<const char*>(message.data()), |
696 message.size(), | 696 message.size(), |
697 destination_url.spec().data(), | 697 destination_url.spec().data(), |
698 destination_url.spec().size()); | 698 destination_url.spec().size()); |
699 } | 699 } |
700 | 700 |
701 void ClearKeyCdm::OnSessionKeysChange(const std::string& web_session_id, | 701 void ClearKeyCdm::OnSessionKeysChange(const std::string& web_session_id, |
702 bool has_additional_usable_key) { | 702 bool has_additional_usable_key) { |
703 // Ignore the message when we are waiting to update the loadable session. | |
704 if (web_session_id == session_id_for_emulated_loadsession_) | |
705 return; | |
706 | |
707 host_->OnSessionUsableKeysChange(web_session_id.data(), | 703 host_->OnSessionUsableKeysChange(web_session_id.data(), |
708 web_session_id.length(), | 704 web_session_id.length(), |
709 has_additional_usable_key); | 705 has_additional_usable_key); |
710 } | 706 } |
711 | 707 |
712 void ClearKeyCdm::OnSessionClosed(const std::string& web_session_id) { | 708 void ClearKeyCdm::OnSessionClosed(const std::string& web_session_id) { |
713 host_->OnSessionClosed(web_session_id.data(), web_session_id.length()); | 709 host_->OnSessionClosed(web_session_id.data(), web_session_id.length()); |
714 } | 710 } |
715 | 711 |
716 void ClearKeyCdm::OnSessionCreated(uint32 promise_id, | 712 void ClearKeyCdm::OnSessionCreated(uint32 promise_id, |
(...skipping 29 matching lines...) Expand all Loading... |
746 | 742 |
747 void ClearKeyCdm::OnSessionUpdated(uint32 promise_id, | 743 void ClearKeyCdm::OnSessionUpdated(uint32 promise_id, |
748 const std::string& web_session_id) { | 744 const std::string& web_session_id) { |
749 // UpdateSession() may be called to finish loading sessions, so handle | 745 // UpdateSession() may be called to finish loading sessions, so handle |
750 // appropriately. | 746 // appropriately. |
751 if (web_session_id == session_id_for_emulated_loadsession_) { | 747 if (web_session_id == session_id_for_emulated_loadsession_) { |
752 session_id_for_emulated_loadsession_ = std::string(); | 748 session_id_for_emulated_loadsession_ = std::string(); |
753 // |promise_id| is the LoadSession() promise, so resolve appropriately. | 749 // |promise_id| is the LoadSession() promise, so resolve appropriately. |
754 host_->OnResolveNewSessionPromise( | 750 host_->OnResolveNewSessionPromise( |
755 promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId)); | 751 promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId)); |
756 // Generate the UsableKeys event now that the session is "loaded". | |
757 host_->OnSessionUsableKeysChange( | |
758 kLoadableWebSessionId, strlen(kLoadableWebSessionId), true); | |
759 return; | 752 return; |
760 } | 753 } |
761 | 754 |
762 host_->OnResolvePromise(promise_id); | 755 host_->OnResolvePromise(promise_id); |
763 } | 756 } |
764 | 757 |
765 void ClearKeyCdm::OnUsableKeyIdsObtained(uint32 promise_id, | 758 void ClearKeyCdm::OnUsableKeyIdsObtained(uint32 promise_id, |
766 const KeyIdsVector& key_ids) { | 759 const KeyIdsVector& key_ids) { |
767 scoped_ptr<cdm::BinaryData[]> result(new cdm::BinaryData[key_ids.size()]); | 760 scoped_ptr<cdm::BinaryData[]> result(new cdm::BinaryData[key_ids.size()]); |
768 for (uint32 i = 0; i < key_ids.size(); ++i) { | 761 for (uint32 i = 0; i < key_ids.size(); ++i) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 host_->OnSessionMessage(last_session_id_.data(), | 852 host_->OnSessionMessage(last_session_id_.data(), |
860 last_session_id_.length(), | 853 last_session_id_.length(), |
861 message.data(), | 854 message.data(), |
862 message.length(), | 855 message.length(), |
863 NULL, | 856 NULL, |
864 0); | 857 0); |
865 file_io_test_runner_.reset(); | 858 file_io_test_runner_.reset(); |
866 } | 859 } |
867 | 860 |
868 } // namespace media | 861 } // namespace media |
OLD | NEW |