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

Side by Side Diff: media/base/cdm_promise_adapter.cc

Issue 1375663003: Verify EME calls made on same thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « media/base/cdm_promise_adapter.h ('k') | media/blink/webcontentdecryptionmodulesession_impl.h » ('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 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/base/cdm_promise_adapter.h" 5 #include "media/base/cdm_promise_adapter.h"
6 6
7 #include "media/base/media_keys.h" 7 #include "media/base/media_keys.h"
8 8
9 namespace media { 9 namespace media {
10 10
11 CdmPromiseAdapter::CdmPromiseAdapter() : next_promise_id_(1) { 11 CdmPromiseAdapter::CdmPromiseAdapter() : next_promise_id_(1) {
12 } 12 }
13 13
14 CdmPromiseAdapter::~CdmPromiseAdapter() { 14 CdmPromiseAdapter::~CdmPromiseAdapter() {
15 DCHECK(promises_.empty()); 15 DCHECK(promises_.empty());
16 DCHECK(thread_checker_.CalledOnValidThread());
16 Clear(); 17 Clear();
17 } 18 }
18 19
19 uint32_t CdmPromiseAdapter::SavePromise(scoped_ptr<CdmPromise> promise) { 20 uint32_t CdmPromiseAdapter::SavePromise(scoped_ptr<CdmPromise> promise) {
21 DCHECK(thread_checker_.CalledOnValidThread());
20 uint32_t promise_id = next_promise_id_++; 22 uint32_t promise_id = next_promise_id_++;
21 promises_.add(promise_id, promise.Pass()); 23 promises_.add(promise_id, promise.Pass());
22 return promise_id; 24 return promise_id;
23 } 25 }
24 26
25 template <typename... T> 27 template <typename... T>
26 void CdmPromiseAdapter::ResolvePromise(uint32_t promise_id, 28 void CdmPromiseAdapter::ResolvePromise(uint32_t promise_id,
27 const T&... result) { 29 const T&... result) {
28 scoped_ptr<CdmPromise> promise = TakePromise(promise_id); 30 scoped_ptr<CdmPromise> promise = TakePromise(promise_id);
29 if (!promise) { 31 if (!promise) {
(...skipping 20 matching lines...) Expand all
50 if (!promise) { 52 if (!promise) {
51 NOTREACHED() << "No promise found for promise_id " << promise_id; 53 NOTREACHED() << "No promise found for promise_id " << promise_id;
52 return; 54 return;
53 } 55 }
54 56
55 promise->reject(exception_code, system_code, error_message); 57 promise->reject(exception_code, system_code, error_message);
56 } 58 }
57 59
58 void CdmPromiseAdapter::Clear() { 60 void CdmPromiseAdapter::Clear() {
59 // Reject all outstanding promises. 61 // Reject all outstanding promises.
62 DCHECK(thread_checker_.CalledOnValidThread());
60 for (auto& promise : promises_) 63 for (auto& promise : promises_)
61 promise.second->reject(MediaKeys::UNKNOWN_ERROR, 0, "Operation aborted."); 64 promise.second->reject(MediaKeys::UNKNOWN_ERROR, 0, "Operation aborted.");
62 promises_.clear(); 65 promises_.clear();
63 } 66 }
64 67
65 scoped_ptr<CdmPromise> CdmPromiseAdapter::TakePromise(uint32_t promise_id) { 68 scoped_ptr<CdmPromise> CdmPromiseAdapter::TakePromise(uint32_t promise_id) {
69 DCHECK(thread_checker_.CalledOnValidThread());
66 PromiseMap::iterator it = promises_.find(promise_id); 70 PromiseMap::iterator it = promises_.find(promise_id);
67 if (it == promises_.end()) 71 if (it == promises_.end())
68 return nullptr; 72 return nullptr;
69 return promises_.take_and_erase(it); 73 return promises_.take_and_erase(it);
70 } 74 }
71 75
72 // Explicit instantiation of function templates. 76 // Explicit instantiation of function templates.
73 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise(uint32_t); 77 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise(uint32_t);
74 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise( 78 template MEDIA_EXPORT void CdmPromiseAdapter::ResolvePromise(
75 uint32_t, 79 uint32_t,
76 const std::string&); 80 const std::string&);
77 81
78 } // namespace media 82 } // namespace media
OLDNEW
« no previous file with comments | « media/base/cdm_promise_adapter.h ('k') | media/blink/webcontentdecryptionmodulesession_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698