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

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

Issue 651113002: Move CdmResultPromise to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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 | « content/renderer/media/webcontentdecryptionmodule_impl.cc ('k') | media/blink/BUILD.gn » ('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 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"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/renderer/media/cdm_result_promise.h"
13 #include "content/renderer/media/cdm_session_adapter.h" 12 #include "content/renderer/media/cdm_session_adapter.h"
14 #include "media/base/cdm_promise.h" 13 #include "media/base/cdm_promise.h"
14 #include "media/base/media_keys.h"
15 #include "media/blink/cdm_result_promise.h"
16 #include "media/blink/new_session_cdm_result_promise.h"
15 #include "third_party/WebKit/public/platform/WebURL.h" 17 #include "third_party/WebKit/public/platform/WebURL.h"
16 18
17 namespace content { 19 namespace content {
18 20
19 const char kCreateSessionUMAName[] = "CreateSession"; 21 const char kCreateSessionUMAName[] = "CreateSession";
20 const char kLoadSessionUMAName[] = "LoadSession"; 22 const char kLoadSessionUMAName[] = "LoadSession";
21 23
22 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl( 24 WebContentDecryptionModuleSessionImpl::WebContentDecryptionModuleSessionImpl(
23 const scoped_refptr<CdmSessionAdapter>& adapter) 25 const scoped_refptr<CdmSessionAdapter>& adapter)
24 : adapter_(adapter), 26 : adapter_(adapter),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); 86 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type);
85 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) 87 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos)
86 << "init_data_type '" << init_data_type_as_ascii 88 << "init_data_type '" << init_data_type_as_ascii
87 << "' may be a MIME type"; 89 << "' may be a MIME type";
88 90
89 adapter_->InitializeNewSession( 91 adapter_->InitializeNewSession(
90 init_data_type_as_ascii, 92 init_data_type_as_ascii,
91 init_data, 93 init_data,
92 init_data_length, 94 init_data_length,
93 media::MediaKeys::TEMPORARY_SESSION, 95 media::MediaKeys::TEMPORARY_SESSION,
94 scoped_ptr<media::NewSessionCdmPromise>(new NewSessionCdmResultPromise( 96 scoped_ptr<media::NewSessionCdmPromise>(
95 result, 97 new media::NewSessionCdmResultPromise(
96 adapter_->GetKeySystemUMAPrefix() + kCreateSessionUMAName, 98 result,
97 base::Bind( 99 adapter_->GetKeySystemUMAPrefix() + kCreateSessionUMAName,
98 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized, 100 base::Bind(
99 base::Unretained(this))))); 101 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized,
102 base::Unretained(this)))));
100 } 103 }
101 104
102 void WebContentDecryptionModuleSessionImpl::load( 105 void WebContentDecryptionModuleSessionImpl::load(
103 const blink::WebString& session_id, 106 const blink::WebString& session_id,
104 blink::WebContentDecryptionModuleResult result) { 107 blink::WebContentDecryptionModuleResult result) {
105 DCHECK(!session_id.isEmpty()); 108 DCHECK(!session_id.isEmpty());
106 DCHECK(web_session_id_.empty()); 109 DCHECK(web_session_id_.empty());
107 110
108 adapter_->LoadSession( 111 adapter_->LoadSession(
109 base::UTF16ToASCII(session_id), 112 base::UTF16ToASCII(session_id),
110 scoped_ptr<media::NewSessionCdmPromise>(new NewSessionCdmResultPromise( 113 scoped_ptr<media::NewSessionCdmPromise>(
111 result, 114 new media::NewSessionCdmResultPromise(
112 adapter_->GetKeySystemUMAPrefix() + kLoadSessionUMAName, 115 result,
113 base::Bind( 116 adapter_->GetKeySystemUMAPrefix() + kLoadSessionUMAName,
114 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized, 117 base::Bind(
115 base::Unretained(this))))); 118 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized,
119 base::Unretained(this)))));
116 } 120 }
117 121
118 void WebContentDecryptionModuleSessionImpl::update( 122 void WebContentDecryptionModuleSessionImpl::update(
119 const uint8* response, 123 const uint8* response,
120 size_t response_length, 124 size_t response_length,
121 blink::WebContentDecryptionModuleResult result) { 125 blink::WebContentDecryptionModuleResult result) {
122 DCHECK(response); 126 DCHECK(response);
123 DCHECK(!web_session_id_.empty()); 127 DCHECK(!web_session_id_.empty());
124 adapter_->UpdateSession(web_session_id_, 128 adapter_->UpdateSession(
125 response, 129 web_session_id_,
126 response_length, 130 response,
127 scoped_ptr<media::SimpleCdmPromise>( 131 response_length,
128 new CdmResultPromise<>(result, std::string()))); 132 scoped_ptr<media::SimpleCdmPromise>(
133 new media::CdmResultPromise<>(result, std::string())));
129 } 134 }
130 135
131 void WebContentDecryptionModuleSessionImpl::close( 136 void WebContentDecryptionModuleSessionImpl::close(
132 blink::WebContentDecryptionModuleResult result) { 137 blink::WebContentDecryptionModuleResult result) {
133 DCHECK(!web_session_id_.empty()); 138 DCHECK(!web_session_id_.empty());
134 adapter_->CloseSession(web_session_id_, 139 adapter_->CloseSession(
135 scoped_ptr<media::SimpleCdmPromise>( 140 web_session_id_,
136 new CdmResultPromise<>(result, std::string()))); 141 scoped_ptr<media::SimpleCdmPromise>(
142 new media::CdmResultPromise<>(result, std::string())));
137 } 143 }
138 144
139 void WebContentDecryptionModuleSessionImpl::remove( 145 void WebContentDecryptionModuleSessionImpl::remove(
140 blink::WebContentDecryptionModuleResult result) { 146 blink::WebContentDecryptionModuleResult result) {
141 DCHECK(!web_session_id_.empty()); 147 DCHECK(!web_session_id_.empty());
142 adapter_->RemoveSession(web_session_id_, 148 adapter_->RemoveSession(
143 scoped_ptr<media::SimpleCdmPromise>( 149 web_session_id_,
144 new CdmResultPromise<>(result, std::string()))); 150 scoped_ptr<media::SimpleCdmPromise>(
151 new media::CdmResultPromise<>(result, std::string())));
145 } 152 }
146 153
147 void WebContentDecryptionModuleSessionImpl::getUsableKeyIds( 154 void WebContentDecryptionModuleSessionImpl::getUsableKeyIds(
148 blink::WebContentDecryptionModuleResult result) { 155 blink::WebContentDecryptionModuleResult result) {
149 DCHECK(!web_session_id_.empty()); 156 DCHECK(!web_session_id_.empty());
150 adapter_->GetUsableKeyIds( 157 adapter_->GetUsableKeyIds(
151 web_session_id_, 158 web_session_id_,
152 scoped_ptr<media::KeyIdsPromise>( 159 scoped_ptr<media::KeyIdsPromise>(
153 new CdmResultPromise<media::KeyIdsVector>(result, std::string()))); 160 new media::CdmResultPromise<media::KeyIdsVector>(result,
161 std::string())));
154 } 162 }
155 163
156 void WebContentDecryptionModuleSessionImpl::release( 164 void WebContentDecryptionModuleSessionImpl::release(
157 blink::WebContentDecryptionModuleResult result) { 165 blink::WebContentDecryptionModuleResult result) {
158 close(result); 166 close(result);
159 } 167 }
160 168
161 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( 169 void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
162 const std::vector<uint8>& message, 170 const std::vector<uint8>& message,
163 const GURL& destination_url) { 171 const GURL& destination_url) {
(...skipping 10 matching lines...) Expand all
174 void WebContentDecryptionModuleSessionImpl::OnSessionExpirationUpdate( 182 void WebContentDecryptionModuleSessionImpl::OnSessionExpirationUpdate(
175 const base::Time& new_expiry_time) { 183 const base::Time& new_expiry_time) {
176 client_->expirationChanged(new_expiry_time.ToJsTime()); 184 client_->expirationChanged(new_expiry_time.ToJsTime());
177 } 185 }
178 186
179 void WebContentDecryptionModuleSessionImpl::OnSessionReady() { 187 void WebContentDecryptionModuleSessionImpl::OnSessionReady() {
180 client_->ready(); 188 client_->ready();
181 } 189 }
182 190
183 void WebContentDecryptionModuleSessionImpl::OnSessionClosed() { 191 void WebContentDecryptionModuleSessionImpl::OnSessionClosed() {
184 if (!is_closed_) { 192 if (is_closed_)
185 is_closed_ = true; 193 return;
186 client_->close(); 194
187 } 195 is_closed_ = true;
196 client_->close();
188 } 197 }
189 198
190 void WebContentDecryptionModuleSessionImpl::OnSessionError( 199 void WebContentDecryptionModuleSessionImpl::OnSessionError(
191 media::MediaKeys::Exception exception_code, 200 media::MediaKeys::Exception exception_code,
192 uint32 system_code, 201 uint32 system_code,
193 const std::string& error_message) { 202 const std::string& error_message) {
194 // Convert |exception_code| back to MediaKeyErrorCode if possible. 203 // Convert |exception_code| back to MediaKeyErrorCode if possible.
195 // TODO(jrummell): Update this conversion when promises flow 204 // TODO(jrummell): Update this conversion when promises flow
196 // back into blink:: (as blink:: will have its own error definition). 205 // back into blink:: (as blink:: will have its own error definition).
197 switch (exception_code) { 206 switch (exception_code) {
(...skipping 17 matching lines...) Expand all
215 224
216 DCHECK(web_session_id_.empty()) << "Session ID may not be changed once set."; 225 DCHECK(web_session_id_.empty()) << "Session ID may not be changed once set.";
217 web_session_id_ = web_session_id; 226 web_session_id_ = web_session_id;
218 return adapter_->RegisterSession(web_session_id_, 227 return adapter_->RegisterSession(web_session_id_,
219 weak_ptr_factory_.GetWeakPtr()) 228 weak_ptr_factory_.GetWeakPtr())
220 ? blink::WebContentDecryptionModuleResult::NewSession 229 ? blink::WebContentDecryptionModuleResult::NewSession
221 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; 230 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists;
222 } 231 }
223 232
224 } // namespace content 233 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webcontentdecryptionmodule_impl.cc ('k') | media/blink/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698