OLD | NEW |
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 "webcontentdecryptionmodulesession_impl.h" | 5 #include "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/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 client_ = client; | 89 client_ = client; |
90 } | 90 } |
91 | 91 |
92 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { | 92 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { |
93 return blink::WebString::fromUTF8(session_id_); | 93 return blink::WebString::fromUTF8(session_id_); |
94 } | 94 } |
95 | 95 |
96 void WebContentDecryptionModuleSessionImpl::initializeNewSession( | 96 void WebContentDecryptionModuleSessionImpl::initializeNewSession( |
97 const blink::WebString& init_data_type, | 97 const blink::WebString& init_data_type, |
98 const uint8* init_data, | 98 const uint8* init_data, |
99 size_t init_data_length) { | |
100 // TODO(jrummell): Remove once blink updated. | |
101 NOTREACHED(); | |
102 } | |
103 | |
104 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, | |
105 size_t response_length) { | |
106 // TODO(jrummell): Remove once blink updated. | |
107 NOTREACHED(); | |
108 } | |
109 | |
110 void WebContentDecryptionModuleSessionImpl::release() { | |
111 // TODO(jrummell): Remove once blink updated. | |
112 NOTREACHED(); | |
113 } | |
114 | |
115 void WebContentDecryptionModuleSessionImpl::initializeNewSession( | |
116 const blink::WebString& init_data_type, | |
117 const uint8* init_data, | |
118 size_t init_data_length, | 99 size_t init_data_length, |
119 const blink::WebString& session_type, | 100 const blink::WebString& session_type, |
120 blink::WebContentDecryptionModuleResult result) { | 101 blink::WebContentDecryptionModuleResult result) { |
121 DCHECK(session_id_.empty()); | 102 DCHECK(session_id_.empty()); |
122 | 103 |
123 // TODO(ddorwin): Guard against this in supported types check and remove this. | 104 // TODO(ddorwin): Guard against this in supported types check and remove this. |
124 // Chromium only supports ASCII MIME types. | 105 // Chromium only supports ASCII MIME types. |
125 if (!base::IsStringASCII(init_data_type)) { | 106 if (!base::IsStringASCII(init_data_type)) { |
126 NOTREACHED(); | 107 NOTREACHED(); |
127 std::string message = "The initialization data type " + | 108 std::string message = "The initialization data type " + |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 196 |
216 void WebContentDecryptionModuleSessionImpl::remove( | 197 void WebContentDecryptionModuleSessionImpl::remove( |
217 blink::WebContentDecryptionModuleResult result) { | 198 blink::WebContentDecryptionModuleResult result) { |
218 DCHECK(!session_id_.empty()); | 199 DCHECK(!session_id_.empty()); |
219 adapter_->RemoveSession( | 200 adapter_->RemoveSession( |
220 session_id_, | 201 session_id_, |
221 scoped_ptr<SimpleCdmPromise>(new CdmResultPromise<>( | 202 scoped_ptr<SimpleCdmPromise>(new CdmResultPromise<>( |
222 result, adapter_->GetKeySystemUMAPrefix() + kRemoveSessionUMAName))); | 203 result, adapter_->GetKeySystemUMAPrefix() + kRemoveSessionUMAName))); |
223 } | 204 } |
224 | 205 |
225 void WebContentDecryptionModuleSessionImpl::release( | |
226 blink::WebContentDecryptionModuleResult result) { | |
227 close(result); | |
228 } | |
229 | |
230 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( | 206 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( |
231 MediaKeys::MessageType message_type, | 207 MediaKeys::MessageType message_type, |
232 const std::vector<uint8>& message) { | 208 const std::vector<uint8>& message) { |
233 DCHECK(client_) << "Client not set before message event"; | 209 DCHECK(client_) << "Client not set before message event"; |
234 client_->message(convertMessageType(message_type), | 210 client_->message(convertMessageType(message_type), |
235 message.empty() ? NULL : &message[0], message.size()); | 211 message.empty() ? NULL : &message[0], message.size()); |
236 } | 212 } |
237 | 213 |
238 void WebContentDecryptionModuleSessionImpl::OnSessionKeysChange( | 214 void WebContentDecryptionModuleSessionImpl::OnSessionKeysChange( |
239 bool has_additional_usable_key, | 215 bool has_additional_usable_key, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return blink::WebContentDecryptionModuleResult::SessionNotFound; | 249 return blink::WebContentDecryptionModuleResult::SessionNotFound; |
274 | 250 |
275 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; | 251 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; |
276 session_id_ = session_id; | 252 session_id_ = session_id; |
277 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) | 253 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) |
278 ? blink::WebContentDecryptionModuleResult::NewSession | 254 ? blink::WebContentDecryptionModuleResult::NewSession |
279 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; | 255 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; |
280 } | 256 } |
281 | 257 |
282 } // namespace media | 258 } // namespace media |
OLD | NEW |