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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 decryptor_->Decrypt(encrypted, base::Bind( | 237 decryptor_->Decrypt(encrypted, base::Bind( |
238 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), | 238 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), |
239 message_loop_proxy, encrypted, decrypt_cb)); | 239 message_loop_proxy, encrypted, decrypt_cb)); |
240 } | 240 } |
241 | 241 |
242 void ProxyDecryptor::OnBufferDecrypted( | 242 void ProxyDecryptor::OnBufferDecrypted( |
243 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, | 243 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy, |
244 const scoped_refptr<media::DecoderBuffer>& encrypted, | 244 const scoped_refptr<media::DecoderBuffer>& encrypted, |
245 const media::Decryptor::DecryptCB& decrypt_cb, | 245 const media::Decryptor::DecryptCB& decrypt_cb, |
246 media::Decryptor::DecryptStatus status, | 246 media::Decryptor::Status status, |
247 const scoped_refptr<media::DecoderBuffer>& decrypted) { | 247 const scoped_refptr<media::DecoderBuffer>& decrypted) { |
248 if (status == media::Decryptor::kSuccess || | 248 if (status == media::Decryptor::kSuccess || |
249 status == media::Decryptor::kError) { | 249 status == media::Decryptor::kError) { |
250 decrypt_cb.Run(status, decrypted); | 250 decrypt_cb.Run(status, decrypted); |
251 return; | 251 return; |
252 } | 252 } |
253 | 253 |
254 DCHECK_EQ(status, media::Decryptor::kNoKey); | 254 DCHECK_EQ(status, media::Decryptor::kNoKey); |
255 DVLOG(1) << "OnBufferDecrypted(): kNoKey fired"; | 255 DVLOG(1) << "OnBufferDecrypted(): kNoKey fired"; |
256 { | 256 { |
257 base::AutoLock auto_lock(lock_); | 257 base::AutoLock auto_lock(lock_); |
258 if (stopped_) { | 258 if (stopped_) { |
259 DVLOG(1) << "OnBufferDecrypted(): fire decrypt callbacks with kError."; | 259 DVLOG(1) << "OnBufferDecrypted(): fire decrypt callbacks with kError."; |
260 decrypt_cb.Run(kError, NULL); | 260 decrypt_cb.Run(kError, NULL); |
261 return; | 261 return; |
262 } | 262 } |
263 pending_decrypt_closures_.push_back(base::Bind( | 263 pending_decrypt_closures_.push_back(base::Bind( |
264 &ProxyDecryptor::DecryptOnMessageLoop, base::Unretained(this), | 264 &ProxyDecryptor::DecryptOnMessageLoop, base::Unretained(this), |
265 message_loop_proxy, encrypted, decrypt_cb)); | 265 message_loop_proxy, encrypted, decrypt_cb)); |
266 } | 266 } |
267 // TODO(xhwang): The same NeedKey may be fired multiple times here and also | 267 // TODO(xhwang): The same NeedKey may be fired multiple times here and also |
268 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave | 268 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave |
269 // them as is since the spec about this may change. | 269 // them as is since the spec about this may change. |
270 FireNeedKey(client_, encrypted); | 270 FireNeedKey(client_, encrypted); |
271 } | 271 } |
272 | 272 |
273 } // namespace webkit_media | 273 } // namespace webkit_media |
OLD | NEW |