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 "webkit/media/crypto/proxy_decryptor.h" | 5 #include "webkit/media/crypto/proxy_decryptor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 pending_buffer_to_decrypt_ = encrypted; | 163 pending_buffer_to_decrypt_ = encrypted; |
164 pending_decrypt_cb_ = decrypt_cb; | 164 pending_decrypt_cb_ = decrypt_cb; |
165 | 165 |
166 // This is safe as we do not replace/delete an existing decryptor at run-time. | 166 // This is safe as we do not replace/delete an existing decryptor at run-time. |
167 media::Decryptor* decryptor = NULL; | 167 media::Decryptor* decryptor = NULL; |
168 { | 168 { |
169 base::AutoLock auto_lock(lock_); | 169 base::AutoLock auto_lock(lock_); |
170 decryptor = decryptor_.get(); | 170 decryptor = decryptor_.get(); |
171 } | 171 } |
172 if (!decryptor) { | 172 if (!decryptor) { |
173 DVLOG(1) << "ProxyDecryptor::Decrypt(): decryptor not initialized."; | 173 DVLOG(1) << "Decrypt(): decryptor not initialized."; |
174 | 174 |
175 // TODO(xhwang): The same NeedKey may be fired here and multiple times in | 175 // TODO(xhwang): The same NeedKey may be fired here and multiple times in |
176 // OnBufferDecrypted(). While the spec says only one NeedKey should be | 176 // OnBufferDecrypted(). While the spec says only one NeedKey should be |
177 // fired. Leave them as is since the spec about this may change. | 177 // fired. Leave them as is since the spec about this may change. |
178 FireNeedKey(client_, encrypted); | 178 FireNeedKey(client_, encrypted); |
179 return; | 179 return; |
180 } | 180 } |
181 | 181 |
182 DecryptPendingBuffer(); | 182 DecryptPendingBuffer(); |
183 } | 183 } |
184 | 184 |
185 void ProxyDecryptor::CancelDecrypt() { | 185 void ProxyDecryptor::CancelDecrypt() { |
186 DVLOG(1) << "CancelDecrypt()"; | |
xhwang
2012/10/12 00:06:44
why this is level one?
ddorwin
2012/10/12 00:21:16
Because it is rarer and much more interesting than
| |
186 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); | 187 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); |
187 | 188 |
188 if (!pending_buffer_to_decrypt_) { | 189 if (!pending_buffer_to_decrypt_) { |
189 DCHECK(pending_decrypt_cb_.is_null()); | 190 DCHECK(pending_decrypt_cb_.is_null()); |
190 DCHECK(!is_waiting_for_decryptor_); | 191 DCHECK(!is_waiting_for_decryptor_); |
191 return; | 192 return; |
192 } | 193 } |
193 | 194 |
194 DecryptCB decrypt_cb; | 195 DecryptCB decrypt_cb; |
195 if (!is_waiting_for_decryptor_) { | 196 if (!is_waiting_for_decryptor_) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 | 275 |
275 if (is_waiting_for_decryptor_) { | 276 if (is_waiting_for_decryptor_) { |
276 has_new_key_added_ = true; | 277 has_new_key_added_ = true; |
277 return; | 278 return; |
278 } | 279 } |
279 | 280 |
280 DecryptPendingBuffer(); | 281 DecryptPendingBuffer(); |
281 } | 282 } |
282 | 283 |
283 void ProxyDecryptor::DecryptPendingBuffer() { | 284 void ProxyDecryptor::DecryptPendingBuffer() { |
285 DVLOG(3) << "DecryptPendingBuffer()"; | |
284 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); | 286 DCHECK(decryption_message_loop_->BelongsToCurrentThread()); |
285 DCHECK(pending_buffer_to_decrypt_); | 287 DCHECK(pending_buffer_to_decrypt_); |
286 DCHECK(!is_waiting_for_decryptor_); | 288 DCHECK(!is_waiting_for_decryptor_); |
287 | 289 |
288 is_waiting_for_decryptor_ = true; | 290 is_waiting_for_decryptor_ = true; |
289 decryptor_->Decrypt( | 291 decryptor_->Decrypt( |
290 pending_buffer_to_decrypt_, | 292 pending_buffer_to_decrypt_, |
291 base::Bind(&ProxyDecryptor::OnBufferDecrypted, base::Unretained(this))); | 293 base::Bind(&ProxyDecryptor::OnBufferDecrypted, base::Unretained(this))); |
292 } | 294 } |
293 | 295 |
294 void ProxyDecryptor::OnBufferDecrypted( | 296 void ProxyDecryptor::OnBufferDecrypted( |
295 media::Decryptor::Status status, | 297 media::Decryptor::Status status, |
296 const scoped_refptr<media::DecoderBuffer>& decrypted) { | 298 const scoped_refptr<media::DecoderBuffer>& decrypted) { |
297 if (!decryption_message_loop_->BelongsToCurrentThread()) { | 299 if (!decryption_message_loop_->BelongsToCurrentThread()) { |
298 decryption_message_loop_->PostTask(FROM_HERE, base::Bind( | 300 decryption_message_loop_->PostTask(FROM_HERE, base::Bind( |
299 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), | 301 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), |
300 status, decrypted)); | 302 status, decrypted)); |
301 return; | 303 return; |
302 } | 304 } |
303 | 305 |
306 DVLOG(2) << "OnBufferDecrypted()"; | |
xhwang
2012/10/12 00:06:44
why this is level 2?
ddorwin
2012/10/12 00:21:16
So we can get level 1 logging without getting spam
| |
304 DCHECK(pending_buffer_to_decrypt_); | 307 DCHECK(pending_buffer_to_decrypt_); |
305 DCHECK(!pending_decrypt_cb_.is_null()); | 308 DCHECK(!pending_decrypt_cb_.is_null()); |
306 DCHECK(is_waiting_for_decryptor_); | 309 DCHECK(is_waiting_for_decryptor_); |
307 | 310 |
308 is_waiting_for_decryptor_ = false; | 311 is_waiting_for_decryptor_ = false; |
309 bool need_to_try_again_if_nokey_is_returned = has_new_key_added_; | 312 bool need_to_try_again_if_nokey_is_returned = has_new_key_added_; |
310 has_new_key_added_ = false; | 313 has_new_key_added_ = false; |
311 | 314 |
312 if (is_canceling_decrypt_) { | 315 if (is_canceling_decrypt_) { |
313 pending_buffer_to_decrypt_ = NULL; | 316 pending_buffer_to_decrypt_ = NULL; |
(...skipping 16 matching lines...) Expand all Loading... | |
330 return; | 333 return; |
331 } | 334 } |
332 | 335 |
333 // TODO(xhwang): The same NeedKey may be fired multiple times here and also | 336 // TODO(xhwang): The same NeedKey may be fired multiple times here and also |
334 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave | 337 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave |
335 // them as is since the spec about this may change. | 338 // them as is since the spec about this may change. |
336 FireNeedKey(client_, pending_buffer_to_decrypt_); | 339 FireNeedKey(client_, pending_buffer_to_decrypt_); |
337 } | 340 } |
338 | 341 |
339 } // namespace webkit_media | 342 } // namespace webkit_media |
OLD | NEW |