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

Side by Side Diff: media/mojo/clients/mojo_cdm.cc

Issue 2268283003: media: Add External Clear Key content browser test on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error Created 4 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
« media/base/key_systems.cc ('K') | « media/mojo/clients/mojo_cdm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/mojo/clients/mojo_cdm.h" 5 #include "media/mojo/clients/mojo_cdm.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 remote_cdm_->SetClient(binding_.CreateInterfacePtrAndBind()); 82 remote_cdm_->SetClient(binding_.CreateInterfacePtrAndBind());
83 } 83 }
84 84
85 MojoCdm::~MojoCdm() { 85 MojoCdm::~MojoCdm() {
86 DVLOG(1) << __FUNCTION__; 86 DVLOG(1) << __FUNCTION__;
87 DCHECK(thread_checker_.CalledOnValidThread()); 87 DCHECK(thread_checker_.CalledOnValidThread());
88 88
89 base::AutoLock auto_lock(lock_); 89 base::AutoLock auto_lock(lock_);
90 90
91 // Release |decryptor_| on the correct thread. If GetDecryptor() is never 91 // Release |decryptor_| on the correct thread. If GetDecryptor() is never
92 // called but |decryptor_ptr_| is not null, it is not bound to any thread and 92 // called but |decryptor_ptr_info_| is not null, it is not bound to any thread
93 // is safe to be released on the current thread. 93 // and is safe to be released on the current thread.
94 if (decryptor_task_runner_ && 94 if (decryptor_task_runner_ &&
95 !decryptor_task_runner_->BelongsToCurrentThread() && decryptor_) { 95 !decryptor_task_runner_->BelongsToCurrentThread() && decryptor_) {
96 decryptor_task_runner_->DeleteSoon(FROM_HERE, decryptor_.release()); 96 decryptor_task_runner_->DeleteSoon(FROM_HERE, decryptor_.release());
97 } 97 }
98 } 98 }
99 99
100 // Using base::Unretained(this) below is safe because |this| owns |remote_cdm_|, 100 // Using base::Unretained(this) below is safe because |this| owns |remote_cdm_|,
101 // and if |this| is destroyed, |remote_cdm_| will be destroyed as well. Then the 101 // and if |this| is destroyed, |remote_cdm_| will be destroyed as well. Then the
102 // error handler can't be invoked and callbacks won't be dispatched. 102 // error handler can't be invoked and callbacks won't be dispatched.
103 103
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 media::Decryptor* MojoCdm::GetDecryptor() { 218 media::Decryptor* MojoCdm::GetDecryptor() {
219 base::AutoLock auto_lock(lock_); 219 base::AutoLock auto_lock(lock_);
220 220
221 if (!decryptor_task_runner_) 221 if (!decryptor_task_runner_)
222 decryptor_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 222 decryptor_task_runner_ = base::ThreadTaskRunnerHandle::Get();
223 223
224 DCHECK(decryptor_task_runner_->BelongsToCurrentThread()); 224 DCHECK(decryptor_task_runner_->BelongsToCurrentThread());
225 225
226 // Can be called on a different thread. 226 // Can be called on a different thread.
227 if (decryptor_ptr_) { 227 if (decryptor_ptr_info_.is_valid()) {
228 DCHECK(!decryptor_); 228 DCHECK(!decryptor_);
229 decryptor_.reset(new MojoDecryptor(std::move(decryptor_ptr_))); 229 mojom::DecryptorPtr decryptor_ptr;
230 decryptor_ptr.Bind(std::move(decryptor_ptr_info_));
231 decryptor_.reset(new MojoDecryptor(std::move(decryptor_ptr)));
230 } 232 }
231 233
232 return decryptor_.get(); 234 return decryptor_.get();
233 } 235 }
234 236
235 int MojoCdm::GetCdmId() const { 237 int MojoCdm::GetCdmId() const {
236 base::AutoLock auto_lock(lock_); 238 base::AutoLock auto_lock(lock_);
237 // Can be called on a different thread. 239 // Can be called on a different thread.
238 DCHECK_NE(CdmContext::kInvalidCdmId, cdm_id_); 240 DCHECK_NE(CdmContext::kInvalidCdmId, cdm_id_);
239 return cdm_id_; 241 return cdm_id_;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 319
318 if (!result->success) { 320 if (!result->success) {
319 RejectPromise(std::move(pending_init_promise_), std::move(result)); 321 RejectPromise(std::move(pending_init_promise_), std::move(result));
320 return; 322 return;
321 } 323 }
322 324
323 { 325 {
324 base::AutoLock auto_lock(lock_); 326 base::AutoLock auto_lock(lock_);
325 DCHECK_NE(CdmContext::kInvalidCdmId, cdm_id); 327 DCHECK_NE(CdmContext::kInvalidCdmId, cdm_id);
326 cdm_id_ = cdm_id; 328 cdm_id_ = cdm_id;
327 decryptor_ptr_ = std::move(decryptor); 329 decryptor_ptr_info_ = decryptor.PassInterface();
328 } 330 }
329 331
330 pending_init_promise_->resolve(); 332 pending_init_promise_->resolve();
331 pending_init_promise_.reset(); 333 pending_init_promise_.reset();
332 } 334 }
333 335
334 void MojoCdm::OnKeyAdded() { 336 void MojoCdm::OnKeyAdded() {
335 base::AutoLock auto_lock(lock_); 337 base::AutoLock auto_lock(lock_);
336 338
337 DCHECK(decryptor_task_runner_); 339 DCHECK(decryptor_task_runner_);
338 DCHECK(decryptor_task_runner_->BelongsToCurrentThread()); 340 DCHECK(decryptor_task_runner_->BelongsToCurrentThread());
339 DCHECK(decryptor_); 341 DCHECK(decryptor_);
340 342
341 decryptor_->OnKeyAdded(); 343 decryptor_->OnKeyAdded();
342 } 344 }
343 345
344 } // namespace media 346 } // namespace media
OLDNEW
« media/base/key_systems.cc ('K') | « media/mojo/clients/mojo_cdm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698