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

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

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reorder Created 6 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
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/webcontentdecryptionmodule_impl.h" 5 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/renderer/media/cdm_session_adapter.h" 15 #include "content/renderer/media/cdm_session_adapter.h"
16 #include "content/renderer/media/crypto/key_systems.h" 16 #include "content/renderer/media/crypto/key_systems.h"
17 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" 17 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
18 #include "media/base/cdm_promise.h"
18 #include "media/base/media_keys.h" 19 #include "media/base/media_keys.h"
19 #include "third_party/WebKit/public/platform/WebString.h" 20 #include "third_party/WebKit/public/platform/WebString.h"
20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 21 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 #if defined(ENABLE_PEPPER_CDMS) 24 #if defined(ENABLE_PEPPER_CDMS)
24 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" 25 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
25 #endif 26 #endif
26 27
27 namespace content { 28 namespace content {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 key_system_ascii, 72 key_system_ascii,
72 security_origin_as_gurl)) { 73 security_origin_as_gurl)) {
73 return NULL; 74 return NULL;
74 } 75 }
75 76
76 return new WebContentDecryptionModuleImpl(adapter); 77 return new WebContentDecryptionModuleImpl(adapter);
77 } 78 }
78 79
79 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( 80 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl(
80 scoped_refptr<CdmSessionAdapter> adapter) 81 scoped_refptr<CdmSessionAdapter> adapter)
81 : adapter_(adapter) {} 82 : adapter_(adapter), weak_ptr_factory_(this) {
83 }
82 84
83 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { 85 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() {
84 } 86 }
85 87
86 // The caller owns the created session. 88 // The caller owns the created session.
87 blink::WebContentDecryptionModuleSession* 89 blink::WebContentDecryptionModuleSession*
88 WebContentDecryptionModuleImpl::createSession() { 90 WebContentDecryptionModuleImpl::createSession() {
89 return adapter_->CreateSession(); 91 return adapter_->CreateSession();
90 } 92 }
91 93
92 blink::WebContentDecryptionModuleSession* 94 blink::WebContentDecryptionModuleSession*
93 WebContentDecryptionModuleImpl::createSession( 95 WebContentDecryptionModuleImpl::createSession(
94 blink::WebContentDecryptionModuleSession::Client* client) { 96 blink::WebContentDecryptionModuleSession::Client* client) {
95 WebContentDecryptionModuleSessionImpl* session = adapter_->CreateSession(); 97 WebContentDecryptionModuleSessionImpl* session = adapter_->CreateSession();
96 session->setClientInterface(client); 98 session->setClientInterface(client);
97 return session; 99 return session;
98 } 100 }
99 101
102 void WebContentDecryptionModuleImpl::setServerCertificate(
103 const uint8* server_certificate,
104 size_t server_certificate_length,
105 blink::WebContentDecryptionModuleResult result) {
106 DCHECK(server_certificate);
107 uint32 result_index = outstanding_results_.AddResult(result);
108 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise(
109 base::Bind(&WebContentDecryptionModuleImpl::OnPromiseResolved,
110 weak_ptr_factory_.GetWeakPtr(),
111 result_index),
112 base::Bind(&WebContentDecryptionModuleImpl::OnPromiseRejected,
113 weak_ptr_factory_.GetWeakPtr(),
114 result_index)));
115 adapter_->SetServerCertificate(
116 server_certificate, server_certificate_length, promise.Pass());
117 }
118
100 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { 119 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() {
101 return adapter_->GetDecryptor(); 120 return adapter_->GetDecryptor();
102 } 121 }
103 122
104 #if defined(ENABLE_BROWSER_CDMS) 123 #if defined(ENABLE_BROWSER_CDMS)
105 int WebContentDecryptionModuleImpl::GetCdmId() const { 124 int WebContentDecryptionModuleImpl::GetCdmId() const {
106 return adapter_->GetCdmId(); 125 return adapter_->GetCdmId();
107 } 126 }
108 #endif // defined(ENABLE_BROWSER_CDMS) 127 #endif // defined(ENABLE_BROWSER_CDMS)
109 128
129 void WebContentDecryptionModuleImpl::OnPromiseResolved(uint32 result_index) {
130 outstanding_results_.Complete(result_index);
131 }
132
133 void WebContentDecryptionModuleImpl::OnPromiseRejected(
134 uint32 result_index,
135 media::MediaKeys::Exception exception_code,
136 uint32 system_code,
137 const std::string& error_message) {
138 outstanding_results_.CompleteWithError(
139 result_index, exception_code, system_code, error_message);
140 }
141
110 } // namespace content 142 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698