OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
ddorwin
2014/08/08 03:35:40
Questions for discussion:
Prefixed EME splits reje
sandersd (OOO until July 31)
2014/08/08 17:22:24
That was the original plan, but Xiaohan convinced
| |
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_session_adapter.h" | 12 #include "content/renderer/media/cdm_session_adapter.h" |
13 #include "media/base/cdm_promise.h" | 13 #include "media/base/cdm_promise.h" |
14 #include "third_party/WebKit/public/platform/WebURL.h" | 14 #include "third_party/WebKit/public/platform/WebURL.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 const char kNewSessionUMASuffix[] = ".NewSession"; | |
ddorwin
2014/08/08 03:35:40
s/Suffix/Name/ - you can't have a prefix and suffi
ddorwin
2014/08/08 03:35:40
The actual method is createSession. It was just od
sandersd (OOO until July 31)
2014/08/08 17:22:24
Done.
sandersd (OOO until July 31)
2014/08/08 17:22:24
Done.
| |
19 | |
18 // For backwards compatibility with blink not using | 20 // For backwards compatibility with blink not using |
19 // WebContentDecryptionModuleResult, reserve an index for |outstanding_results_| | 21 // WebContentDecryptionModuleResult, reserve an index for |outstanding_results_| |
20 // that will not be used when adding a WebContentDecryptionModuleResult. | 22 // that will not be used when adding a WebContentDecryptionModuleResult. |
21 // TODO(jrummell): Remove once blink always uses | 23 // TODO(jrummell): Remove once blink always uses |
22 // WebContentDecryptionModuleResult. | 24 // WebContentDecryptionModuleResult. |
23 const uint32 kReservedIndex = 0; | 25 const uint32 kReservedIndex = 0; |
24 | 26 |
25 static blink::WebContentDecryptionModuleException ConvertException( | 27 static blink::WebContentDecryptionModuleException ConvertException( |
26 media::MediaKeys::Exception exception_code) { | 28 media::MediaKeys::Exception exception_code) { |
27 switch (exception_code) { | 29 switch (exception_code) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 } | 76 } |
75 | 77 |
76 void WebContentDecryptionModuleSessionImpl::setClientInterface(Client* client) { | 78 void WebContentDecryptionModuleSessionImpl::setClientInterface(Client* client) { |
77 client_ = client; | 79 client_ = client; |
78 } | 80 } |
79 | 81 |
80 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { | 82 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { |
81 return blink::WebString::fromUTF8(web_session_id_); | 83 return blink::WebString::fromUTF8(web_session_id_); |
82 } | 84 } |
83 | 85 |
84 void WebContentDecryptionModuleSessionImpl::initializeNewSession( | 86 void WebContentDecryptionModuleSessionImpl::initializeNewSession( |
ddorwin
2014/08/08 03:35:40
I think this should be deleted now - it looks like
sandersd (OOO until July 31)
2014/08/08 17:22:24
That's true, but it's still plumbed through to Bli
| |
85 const blink::WebString& init_data_type, | 87 const blink::WebString& init_data_type, |
86 const uint8* init_data, | 88 const uint8* init_data, |
87 size_t init_data_length) { | 89 size_t init_data_length) { |
88 // TODO(ddorwin): Guard against this in supported types check and remove this. | 90 // TODO(ddorwin): Guard against this in supported types check and remove this. |
89 // Chromium only supports ASCII MIME types. | 91 // Chromium only supports ASCII MIME types. |
90 if (!base::IsStringASCII(init_data_type)) { | 92 if (!base::IsStringASCII(init_data_type)) { |
91 NOTREACHED(); | 93 NOTREACHED(); |
92 OnSessionError(media::MediaKeys::NOT_SUPPORTED_ERROR, | 94 OnSessionError(media::MediaKeys::NOT_SUPPORTED_ERROR, |
93 0, | 95 0, |
94 "The initialization data type " + init_data_type.utf8() + | 96 "The initialization data type " + init_data_type.utf8() + |
95 " is not supported by the key system."); | 97 " is not supported by the key system."); |
96 return; | 98 return; |
97 } | 99 } |
98 | 100 |
99 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); | 101 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); |
100 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) | 102 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) |
101 << "init_data_type '" << init_data_type_as_ascii | 103 << "init_data_type '" << init_data_type_as_ascii |
102 << "' may be a MIME type"; | 104 << "' may be a MIME type"; |
103 | 105 |
104 scoped_ptr<media::NewSessionCdmPromise> promise( | 106 scoped_ptr<media::NewSessionCdmPromise> promise( |
105 new media::NewSessionCdmPromise( | 107 new media::NewSessionCdmPromise( |
106 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, | 108 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, |
107 weak_ptr_factory_.GetWeakPtr(), | 109 weak_ptr_factory_.GetWeakPtr(), |
108 kReservedIndex), | 110 kReservedIndex), |
109 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError, | 111 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError, |
110 weak_ptr_factory_.GetWeakPtr()))); | 112 weak_ptr_factory_.GetWeakPtr()), |
113 adapter_->GetKeySystemUMAPrefix() + kNewSessionUMASuffix)); | |
111 adapter_->InitializeNewSession(init_data_type_as_ascii, | 114 adapter_->InitializeNewSession(init_data_type_as_ascii, |
112 init_data, | 115 init_data, |
113 init_data_length, | 116 init_data_length, |
114 media::MediaKeys::TEMPORARY_SESSION, | 117 media::MediaKeys::TEMPORARY_SESSION, |
115 promise.Pass()); | 118 promise.Pass()); |
116 } | 119 } |
117 | 120 |
118 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, | 121 void WebContentDecryptionModuleSessionImpl::update(const uint8* response, |
119 size_t response_length) { | 122 size_t response_length) { |
120 DCHECK(response); | 123 DCHECK(response); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 << "init_data_type '" << init_data_type_as_ascii | 164 << "init_data_type '" << init_data_type_as_ascii |
162 << "' may be a MIME type"; | 165 << "' may be a MIME type"; |
163 | 166 |
164 scoped_ptr<media::NewSessionCdmPromise> promise( | 167 scoped_ptr<media::NewSessionCdmPromise> promise( |
165 new media::NewSessionCdmPromise( | 168 new media::NewSessionCdmPromise( |
166 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, | 169 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, |
167 weak_ptr_factory_.GetWeakPtr(), | 170 weak_ptr_factory_.GetWeakPtr(), |
168 result_index), | 171 result_index), |
169 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionError, | 172 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionError, |
170 weak_ptr_factory_.GetWeakPtr(), | 173 weak_ptr_factory_.GetWeakPtr(), |
171 result_index))); | 174 result_index), |
175 adapter_->GetKeySystemUMAPrefix() + kNewSessionUMASuffix)); | |
172 adapter_->InitializeNewSession(init_data_type_as_ascii, | 176 adapter_->InitializeNewSession(init_data_type_as_ascii, |
173 init_data, | 177 init_data, |
174 init_data_length, | 178 init_data_length, |
175 media::MediaKeys::TEMPORARY_SESSION, | 179 media::MediaKeys::TEMPORARY_SESSION, |
176 promise.Pass()); | 180 promise.Pass()); |
177 } | 181 } |
178 | 182 |
179 void WebContentDecryptionModuleSessionImpl::update( | 183 void WebContentDecryptionModuleSessionImpl::update( |
180 const uint8* response, | 184 const uint8* response, |
181 size_t response_length, | 185 size_t response_length, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 | 302 |
299 uint32 WebContentDecryptionModuleSessionImpl::AddResult( | 303 uint32 WebContentDecryptionModuleSessionImpl::AddResult( |
300 blink::WebContentDecryptionModuleResult result) { | 304 blink::WebContentDecryptionModuleResult result) { |
301 uint32 result_index = next_available_result_index_++; | 305 uint32 result_index = next_available_result_index_++; |
302 DCHECK(result_index != kReservedIndex); | 306 DCHECK(result_index != kReservedIndex); |
303 outstanding_results_.insert(std::make_pair(result_index, result)); | 307 outstanding_results_.insert(std::make_pair(result_index, result)); |
304 return result_index; | 308 return result_index; |
305 } | 309 } |
306 | 310 |
307 } // namespace content | 311 } // namespace content |
OLD | NEW |