| 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_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 PpapiDecryptor::~PpapiDecryptor() { | 92 PpapiDecryptor::~PpapiDecryptor() { |
| 93 plugin_cdm_delegate_ = NULL; | 93 plugin_cdm_delegate_ = NULL; |
| 94 plugin_instance_ = NULL; | 94 plugin_instance_ = NULL; |
| 95 if (!destroy_plugin_cb_.is_null()) | 95 if (!destroy_plugin_cb_.is_null()) |
| 96 base::ResetAndReturn(&destroy_plugin_cb_).Run(); | 96 base::ResetAndReturn(&destroy_plugin_cb_).Run(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool PpapiDecryptor::CreateSession(uint32 session_id, | 99 bool PpapiDecryptor::CreateSession(uint32 session_id, |
| 100 const std::string& type, | 100 const std::string& content_type, |
| 101 const uint8* init_data, | 101 const uint8* init_data, |
| 102 int init_data_length) { | 102 int init_data_length) { |
| 103 DVLOG(2) << __FUNCTION__; | 103 DVLOG(2) << __FUNCTION__; |
| 104 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 104 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 105 DCHECK(plugin_cdm_delegate_); | |
| 106 | 105 |
| 107 if (!plugin_cdm_delegate_ || | 106 if (!plugin_cdm_delegate_ || |
| 108 !plugin_cdm_delegate_->CreateSession( | 107 !plugin_cdm_delegate_->CreateSession( |
| 109 session_id, type, init_data, init_data_length)) { | 108 session_id, content_type, init_data, init_data_length)) { |
| 110 ReportFailureToCallPlugin(session_id); | 109 ReportFailureToCallPlugin(session_id); |
| 111 return false; | 110 return false; |
| 112 } | 111 } |
| 113 | 112 |
| 114 return true; | 113 return true; |
| 115 } | 114 } |
| 116 | 115 |
| 116 void PpapiDecryptor::LoadSession(uint32 session_id, |
| 117 const std::string& web_session_id) { |
| 118 DVLOG(2) << __FUNCTION__; |
| 119 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 120 |
| 121 if (!plugin_cdm_delegate_) { |
| 122 ReportFailureToCallPlugin(session_id); |
| 123 return; |
| 124 } |
| 125 |
| 126 plugin_cdm_delegate_->LoadSession(session_id, web_session_id); |
| 127 } |
| 128 |
| 117 void PpapiDecryptor::UpdateSession(uint32 session_id, | 129 void PpapiDecryptor::UpdateSession(uint32 session_id, |
| 118 const uint8* response, | 130 const uint8* response, |
| 119 int response_length) { | 131 int response_length) { |
| 120 DVLOG(2) << __FUNCTION__; | 132 DVLOG(2) << __FUNCTION__; |
| 121 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 133 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 122 | 134 |
| 123 if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession( | 135 if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession( |
| 124 session_id, response, response_length)) { | 136 session_id, response, response_length)) { |
| 125 ReportFailureToCallPlugin(session_id); | 137 ReportFailureToCallPlugin(session_id); |
| 138 return; |
| 126 } | 139 } |
| 127 | 140 |
| 128 if (!new_audio_key_cb_.is_null()) | 141 if (!new_audio_key_cb_.is_null()) |
| 129 new_audio_key_cb_.Run(); | 142 new_audio_key_cb_.Run(); |
| 130 | 143 |
| 131 if (!new_video_key_cb_.is_null()) | 144 if (!new_video_key_cb_.is_null()) |
| 132 new_video_key_cb_.Run(); | 145 new_video_key_cb_.Run(); |
| 133 } | 146 } |
| 134 | 147 |
| 135 void PpapiDecryptor::ReleaseSession(uint32 session_id) { | 148 void PpapiDecryptor::ReleaseSession(uint32 session_id) { |
| 136 DVLOG(2) << __FUNCTION__; | 149 DVLOG(2) << __FUNCTION__; |
| 137 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 150 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 138 | 151 |
| 139 if (!plugin_cdm_delegate_ || | 152 if (!plugin_cdm_delegate_ || |
| 140 !plugin_cdm_delegate_->ReleaseSession(session_id)) { | 153 !plugin_cdm_delegate_->ReleaseSession(session_id)) { |
| 141 ReportFailureToCallPlugin(session_id); | 154 ReportFailureToCallPlugin(session_id); |
| 155 return; |
| 142 } | 156 } |
| 143 } | 157 } |
| 144 | 158 |
| 145 media::Decryptor* PpapiDecryptor::GetDecryptor() { | 159 media::Decryptor* PpapiDecryptor::GetDecryptor() { |
| 146 return this; | 160 return this; |
| 147 } | 161 } |
| 148 | 162 |
| 149 void PpapiDecryptor::RegisterNewKeyCB(StreamType stream_type, | 163 void PpapiDecryptor::RegisterNewKeyCB(StreamType stream_type, |
| 150 const NewKeyCB& new_key_cb) { | 164 const NewKeyCB& new_key_cb) { |
| 151 if (!render_loop_proxy_->BelongsToCurrentThread()) { | 165 if (!render_loop_proxy_->BelongsToCurrentThread()) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 369 |
| 356 void PpapiDecryptor::OnFatalPluginError() { | 370 void PpapiDecryptor::OnFatalPluginError() { |
| 357 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 371 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
| 358 DCHECK(plugin_cdm_delegate_); | 372 DCHECK(plugin_cdm_delegate_); |
| 359 plugin_cdm_delegate_ = NULL; | 373 plugin_cdm_delegate_ = NULL; |
| 360 plugin_instance_ = NULL; | 374 plugin_instance_ = NULL; |
| 361 base::ResetAndReturn(&destroy_plugin_cb_).Run(); | 375 base::ResetAndReturn(&destroy_plugin_cb_).Run(); |
| 362 } | 376 } |
| 363 | 377 |
| 364 } // namespace content | 378 } // namespace content |
| OLD | NEW |