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

Side by Side Diff: content/renderer/media/webcontentdecryptionmodulesession_impl.cc

Issue 380953002: Set callback interface on WebCDMSessionImpl after creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + change Created 6 years, 5 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 | « content/renderer/media/webcontentdecryptionmodulesession_impl.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/media/webcontentdecryptionmodulesession_impl.h" 5 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 28 matching lines...) Expand all
39 return blink::WebContentDecryptionModuleExceptionClientError; 39 return blink::WebContentDecryptionModuleExceptionClientError;
40 case media::MediaKeys::OUTPUT_ERROR: 40 case media::MediaKeys::OUTPUT_ERROR:
41 return blink::WebContentDecryptionModuleExceptionOutputError; 41 return blink::WebContentDecryptionModuleExceptionOutputError;
42 default: 42 default:
43 NOTREACHED(); 43 NOTREACHED();
44 return blink::WebContentDecryptionModuleExceptionUnknownError; 44 return blink::WebContentDecryptionModuleExceptionUnknownError;
45 } 45 }
46 } 46 }
47 47
48 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( 48 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
49 Client* client,
50 const scoped_refptr<CdmSessionAdapter>& adapter) 49 const scoped_refptr<CdmSessionAdapter>& adapter)
51 : adapter_(adapter), 50 : adapter_(adapter),
52 client_(client),
53 is_closed_(false), 51 is_closed_(false),
54 next_available_result_index_(1), 52 next_available_result_index_(1),
55 weak_ptr_factory_(this) { 53 weak_ptr_factory_(this) {
56 } 54 }
57 55
58 WebContentDecryptionModuleSessionImpl:: 56 WebContentDecryptionModuleSessionImpl::
59 ~WebContentDecryptionModuleSessionImpl() { 57 ~WebContentDecryptionModuleSessionImpl() {
60 if (!web_session_id_.empty()) 58 if (!web_session_id_.empty())
61 adapter_->RemoveSession(web_session_id_); 59 adapter_->RemoveSession(web_session_id_);
62 60
63 // Release any WebContentDecryptionModuleResult objects that are left. Their 61 // Release any WebContentDecryptionModuleResult objects that are left. Their
64 // index will have been passed down via a CdmPromise, but it uses a WeakPtr. 62 // index will have been passed down via a CdmPromise, but it uses a WeakPtr.
65 DLOG_IF(WARNING, outstanding_results_.size() > 0) 63 DLOG_IF(WARNING, outstanding_results_.size() > 0)
66 << "Clearing " << outstanding_results_.size() << " results"; 64 << "Clearing " << outstanding_results_.size() << " results";
67 for (ResultMap::iterator it = outstanding_results_.begin(); 65 for (ResultMap::iterator it = outstanding_results_.begin();
68 it != outstanding_results_.end(); 66 it != outstanding_results_.end();
69 ++it) { 67 ++it) {
70 it->second.completeWithError( 68 it->second.completeWithError(
71 blink::WebContentDecryptionModuleExceptionInvalidStateError, 69 blink::WebContentDecryptionModuleExceptionInvalidStateError,
72 0, 70 0,
73 "Outstanding request being cancelled."); 71 "Outstanding request being cancelled.");
74 } 72 }
75 outstanding_results_.clear(); 73 outstanding_results_.clear();
76 } 74 }
77 75
76 void WebContentDecryptionModuleSessionImpl::setClientInterface(Client* client) {
77 client_ = client;
78 }
79
78 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { 80 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const {
79 return blink::WebString::fromUTF8(web_session_id_); 81 return blink::WebString::fromUTF8(web_session_id_);
80 } 82 }
81 83
82 void WebContentDecryptionModuleSessionImpl::initializeNewSession( 84 void WebContentDecryptionModuleSessionImpl::initializeNewSession(
83 const blink::WebString& init_data_type, 85 const blink::WebString& init_data_type,
84 const uint8* init_data, 86 const uint8* init_data,
85 size_t init_data_length) { 87 size_t init_data_length) {
86 // TODO(ddorwin): Guard against this in supported types check and remove this. 88 // TODO(ddorwin): Guard against this in supported types check and remove this.
87 // Chromium only supports ASCII MIME types. 89 // Chromium only supports ASCII MIME types.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 result_index), 204 result_index),
203 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionError, 205 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionError,
204 weak_ptr_factory_.GetWeakPtr(), 206 weak_ptr_factory_.GetWeakPtr(),
205 result_index))); 207 result_index)));
206 adapter_->ReleaseSession(web_session_id_, promise.Pass()); 208 adapter_->ReleaseSession(web_session_id_, promise.Pass());
207 } 209 }
208 210
209 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( 211 void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
210 const std::vector<uint8>& message, 212 const std::vector<uint8>& message,
211 const GURL& destination_url) { 213 const GURL& destination_url) {
214 DCHECK(client_) << "Client not set before message event";
212 client_->message( 215 client_->message(
213 message.empty() ? NULL : &message[0], message.size(), destination_url); 216 message.empty() ? NULL : &message[0], message.size(), destination_url);
214 } 217 }
215 218
216 void WebContentDecryptionModuleSessionImpl::OnSessionReady() { 219 void WebContentDecryptionModuleSessionImpl::OnSessionReady() {
217 client_->ready(); 220 client_->ready();
218 } 221 }
219 222
220 void WebContentDecryptionModuleSessionImpl::OnSessionClosed() { 223 void WebContentDecryptionModuleSessionImpl::OnSessionClosed() {
221 if (!is_closed_) { 224 if (!is_closed_) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 298
296 uint32 WebContentDecryptionModuleSessionImpl::AddResult( 299 uint32 WebContentDecryptionModuleSessionImpl::AddResult(
297 blink::WebContentDecryptionModuleResult result) { 300 blink::WebContentDecryptionModuleResult result) {
298 uint32 result_index = next_available_result_index_++; 301 uint32 result_index = next_available_result_index_++;
299 DCHECK(result_index != kReservedIndex); 302 DCHECK(result_index != kReservedIndex);
300 outstanding_results_.insert(std::make_pair(result_index, result)); 303 outstanding_results_.insert(std::make_pair(result_index, result));
301 return result_index; 304 return result_index;
302 } 305 }
303 306
304 } // namespace content 307 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webcontentdecryptionmodulesession_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698