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_); | 105 DCHECK(plugin_cdm_delegate_); |
106 | 106 |
107 if (!plugin_cdm_delegate_ || | 107 if (!plugin_cdm_delegate_ || |
108 !plugin_cdm_delegate_->CreateSession( | 108 !plugin_cdm_delegate_->CreateSession( |
109 session_id, type, init_data, init_data_length)) { | 109 session_id, content_type, init_data, init_data_length)) { |
110 ReportFailureToCallPlugin(session_id); | 110 ReportFailureToCallPlugin(session_id); |
111 return false; | 111 return false; |
112 } | 112 } |
113 | |
114 return true; | |
115 } | |
116 | |
117 bool PpapiDecryptor::LoadSession(uint32 session_id, | |
118 const std::string& web_session_id) { | |
119 DVLOG(2) << __FUNCTION__; | |
120 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | |
121 DCHECK(plugin_cdm_delegate_); | |
ddorwin
2014/02/10 19:05:25
Why can this never happen here or in CreateSession
xhwang
2014/02/10 22:30:55
Removed.
| |
122 | |
123 if (!plugin_cdm_delegate_ || | |
124 !plugin_cdm_delegate_->LoadSession(session_id, web_session_id)) { | |
125 ReportFailureToCallPlugin(session_id); | |
126 return false; | |
127 } | |
113 | 128 |
114 return true; | 129 return true; |
115 } | 130 } |
116 | 131 |
117 void PpapiDecryptor::UpdateSession(uint32 session_id, | 132 void PpapiDecryptor::UpdateSession(uint32 session_id, |
118 const uint8* response, | 133 const uint8* response, |
119 int response_length) { | 134 int response_length) { |
120 DVLOG(2) << __FUNCTION__; | 135 DVLOG(2) << __FUNCTION__; |
121 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 136 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
122 | 137 |
123 if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession( | 138 if (!plugin_cdm_delegate_ || !plugin_cdm_delegate_->UpdateSession( |
124 session_id, response, response_length)) { | 139 session_id, response, response_length)) { |
125 ReportFailureToCallPlugin(session_id); | 140 ReportFailureToCallPlugin(session_id); |
ddorwin
2014/02/10 19:05:25
Why don't we return here?
xhwang
2014/02/10 22:30:55
Done.
| |
126 } | 141 } |
127 | 142 |
128 if (!new_audio_key_cb_.is_null()) | 143 if (!new_audio_key_cb_.is_null()) |
129 new_audio_key_cb_.Run(); | 144 new_audio_key_cb_.Run(); |
130 | 145 |
131 if (!new_video_key_cb_.is_null()) | 146 if (!new_video_key_cb_.is_null()) |
132 new_video_key_cb_.Run(); | 147 new_video_key_cb_.Run(); |
133 } | 148 } |
134 | 149 |
135 void PpapiDecryptor::ReleaseSession(uint32 session_id) { | 150 void PpapiDecryptor::ReleaseSession(uint32 session_id) { |
136 DVLOG(2) << __FUNCTION__; | 151 DVLOG(2) << __FUNCTION__; |
137 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 152 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
138 | 153 |
139 if (!plugin_cdm_delegate_ || | 154 if (!plugin_cdm_delegate_ || |
140 !plugin_cdm_delegate_->ReleaseSession(session_id)) { | 155 !plugin_cdm_delegate_->ReleaseSession(session_id)) { |
141 ReportFailureToCallPlugin(session_id); | 156 ReportFailureToCallPlugin(session_id); |
ddorwin
2014/02/10 19:05:25
and here for consistency
xhwang
2014/02/10 22:30:55
Done.
| |
142 } | 157 } |
143 } | 158 } |
144 | 159 |
145 media::Decryptor* PpapiDecryptor::GetDecryptor() { | 160 media::Decryptor* PpapiDecryptor::GetDecryptor() { |
146 return this; | 161 return this; |
147 } | 162 } |
148 | 163 |
149 void PpapiDecryptor::RegisterNewKeyCB(StreamType stream_type, | 164 void PpapiDecryptor::RegisterNewKeyCB(StreamType stream_type, |
150 const NewKeyCB& new_key_cb) { | 165 const NewKeyCB& new_key_cb) { |
151 if (!render_loop_proxy_->BelongsToCurrentThread()) { | 166 if (!render_loop_proxy_->BelongsToCurrentThread()) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 | 370 |
356 void PpapiDecryptor::OnFatalPluginError() { | 371 void PpapiDecryptor::OnFatalPluginError() { |
357 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); | 372 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); |
358 DCHECK(plugin_cdm_delegate_); | 373 DCHECK(plugin_cdm_delegate_); |
359 plugin_cdm_delegate_ = NULL; | 374 plugin_cdm_delegate_ = NULL; |
360 plugin_instance_ = NULL; | 375 plugin_instance_ = NULL; |
361 base::ResetAndReturn(&destroy_plugin_cb_).Run(); | 376 base::ResetAndReturn(&destroy_plugin_cb_).Run(); |
362 } | 377 } |
363 | 378 |
364 } // namespace content | 379 } // namespace content |
OLD | NEW |