Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: webkit/media/crypto/proxy_decryptor.cc

Issue 10896014: Add a bool return value to media::Decryptor::GenerateKeyRequest(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/media/crypto/proxy_decryptor.h ('k') | webkit/media/webmediaplayer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if(!decryptor_->GenerateKeyRequest(key_system, init_data, init_data_length)) {
92 decryptor_.reset();
93 return false;
94 }
95
96 return true;
92 } 97 }
93 98
94 void ProxyDecryptor::AddKey(const std::string& key_system, 99 void ProxyDecryptor::AddKey(const std::string& key_system,
95 const uint8* key, 100 const uint8* key,
96 int key_length, 101 int key_length,
97 const uint8* init_data, 102 const uint8* init_data,
98 int init_data_length, 103 int init_data_length,
99 const std::string& session_id) { 104 const std::string& session_id) {
100 DVLOG(1) << "AddKey()"; 105 DVLOG(1) << "AddKey()";
101 106
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return; 160 return;
156 } 161 }
157 } 162 }
158 163
159 decryptor->Decrypt(encrypted, base::Bind( 164 decryptor->Decrypt(encrypted, base::Bind(
160 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this), 165 &ProxyDecryptor::OnBufferDecrypted, base::Unretained(this),
161 base::MessageLoopProxy::current(), encrypted, decrypt_cb)); 166 base::MessageLoopProxy::current(), encrypted, decrypt_cb));
162 } 167 }
163 168
164 void ProxyDecryptor::Stop() { 169 void ProxyDecryptor::Stop() {
165 DVLOG(1) << "AddKey()"; 170 DVLOG(1) << "Stop()";
166 171
167 std::vector<base::Closure> closures_to_run; 172 std::vector<base::Closure> closures_to_run;
168 { 173 {
169 base::AutoLock auto_lock(lock_); 174 base::AutoLock auto_lock(lock_);
170 if (decryptor_.get()) 175 if (decryptor_.get())
171 decryptor_->Stop(); 176 decryptor_->Stop();
172 stopped_ = true; 177 stopped_ = true;
173 std::swap(pending_decrypt_closures_, closures_to_run); 178 std::swap(pending_decrypt_closures_, closures_to_run);
174 } 179 }
175 180
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 &ProxyDecryptor::DecryptOnMessageLoop, base::Unretained(this), 269 &ProxyDecryptor::DecryptOnMessageLoop, base::Unretained(this),
265 message_loop_proxy, encrypted, decrypt_cb)); 270 message_loop_proxy, encrypted, decrypt_cb));
266 } 271 }
267 // TODO(xhwang): The same NeedKey may be fired multiple times here and also 272 // 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 273 // in Decrypt(). While the spec says only one NeedKey should be fired. Leave
269 // them as is since the spec about this may change. 274 // them as is since the spec about this may change.
270 FireNeedKey(client_, encrypted); 275 FireNeedKey(client_, encrypted);
271 } 276 }
272 277
273 } // namespace webkit_media 278 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/proxy_decryptor.h ('k') | webkit/media/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698