Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 WebKit::WebFrame* web_frame) | 65 WebKit::WebFrame* web_frame) |
| 66 : client_(decryptor_client), | 66 : client_(decryptor_client), |
| 67 web_media_player_client_(web_media_player_client), | 67 web_media_player_client_(web_media_player_client), |
| 68 web_frame_(web_frame), | 68 web_frame_(web_frame), |
| 69 stopped_(false) { | 69 stopped_(false) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 ProxyDecryptor::~ProxyDecryptor() { | 72 ProxyDecryptor::~ProxyDecryptor() { |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ProxyDecryptor::GenerateKeyRequest(const std::string& key_system, | 75 bool ProxyDecryptor::GenerateKeyRequest(const std::string& key_system, |
| 76 const uint8* init_data, | 76 const uint8* init_data, |
| 77 int init_data_length) { | 77 int init_data_length) { |
| 78 // We do not support run-time switching of decryptors. GenerateKeyRequest() | 78 // We do not support run-time switching of decryptors. GenerateKeyRequest() |
| 79 // only creates a new decryptor when |decryptor_| is not initialized. | 79 // only creates a new decryptor when |decryptor_| is not initialized. |
| 80 DVLOG(1) << "GenerateKeyRequest: key_system = " << key_system; | 80 DVLOG(1) << "GenerateKeyRequest: key_system = " << key_system; |
| 81 if (!decryptor_.get()) { | 81 if (!decryptor_.get()) { |
| 82 base::AutoLock auto_lock(lock_); | 82 base::AutoLock auto_lock(lock_); |
| 83 decryptor_ = CreateDecryptor(key_system); | 83 decryptor_ = CreateDecryptor(key_system); |
| 84 } | 84 } |
| 85 | 85 |
| 86 if (!decryptor_.get()) { | 86 if (!decryptor_.get()) { |
| 87 client_->KeyError(key_system, "", media::Decryptor::kUnknownError, 0); | 87 client_->KeyError(key_system, "", media::Decryptor::kUnknownError, 0); |
| 88 return; | 88 return false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length); | 91 return decryptor_->GenerateKeyRequest(key_system, |
|
ddorwin
2012/08/28 21:59:14
For the meaning of the return value to be consiste
| |
| 92 init_data, init_data_length); | |
| 92 } | 93 } |
| 93 | 94 |
| 94 void ProxyDecryptor::AddKey(const std::string& key_system, | 95 void ProxyDecryptor::AddKey(const std::string& key_system, |
| 95 const uint8* key, | 96 const uint8* key, |
| 96 int key_length, | 97 int key_length, |
| 97 const uint8* init_data, | 98 const uint8* init_data, |
| 98 int init_data_length, | 99 int init_data_length, |
| 99 const std::string& session_id) { | 100 const std::string& session_id) { |
| 100 DVLOG(1) << "AddKey()"; | 101 DVLOG(1) << "AddKey()"; |
| 101 | 102 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 return; | 156 return; |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 | 159 |
| 159 decryptor->Decrypt(encrypted, base::Bind( | 160 decryptor->Decrypt(encrypted, base::Bind( |
| 160 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), | 161 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), |
| 161 base::MessageLoopProxy::current(), encrypted, decrypt_cb)); | 162 base::MessageLoopProxy::current(), encrypted, decrypt_cb)); |
| 162 } | 163 } |
| 163 | 164 |
| 164 void ProxyDecryptor::Stop() { | 165 void ProxyDecryptor::Stop() { |
| 165 DVLOG(1) << "AddKey()"; | 166 DVLOG(1) << "Stop()"; |
| 166 | 167 |
| 167 std::vector<base::Closure> closures_to_run; | 168 std::vector<base::Closure> closures_to_run; |
| 168 { | 169 { |
| 169 base::AutoLock auto_lock(lock_); | 170 base::AutoLock auto_lock(lock_); |
| 170 if (decryptor_.get()) | 171 if (decryptor_.get()) |
| 171 decryptor_->Stop(); | 172 decryptor_->Stop(); |
| 172 stopped_ = true; | 173 stopped_ = true; |
| 173 std::swap(pending_decrypt_closures_, closures_to_run); | 174 std::swap(pending_decrypt_closures_, closures_to_run); |
| 174 } | 175 } |
| 175 | 176 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 &ProxyDecryptor::DecryptOnMessageLoop, base::Unretained(this), | 265 &ProxyDecryptor::DecryptOnMessageLoop, base::Unretained(this), |
| 265 message_loop_proxy, encrypted, decrypt_cb)); | 266 message_loop_proxy, encrypted, decrypt_cb)); |
| 266 } | 267 } |
| 267 // TODO(xhwang): The same NeedKey may be fired multiple times here and also | 268 // 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 | 269 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave |
| 269 // them as is since the spec about this may change. | 270 // them as is since the spec about this may change. |
| 270 FireNeedKey(client_, encrypted); | 271 FireNeedKey(client_, encrypted); |
| 271 } | 272 } |
| 272 | 273 |
| 273 } // namespace webkit_media | 274 } // namespace webkit_media |
| OLD | NEW |