OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/blink/cdm_session_adapter.h" | 5 #include "media/blink/cdm_session_adapter.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) { | 86 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) { |
87 DCHECK(base::ContainsKey(sessions_, session_id)); | 87 DCHECK(base::ContainsKey(sessions_, session_id)); |
88 sessions_.erase(session_id); | 88 sessions_.erase(session_id); |
89 } | 89 } |
90 | 90 |
91 void CdmSessionAdapter::InitializeNewSession( | 91 void CdmSessionAdapter::InitializeNewSession( |
92 EmeInitDataType init_data_type, | 92 EmeInitDataType init_data_type, |
93 const std::vector<uint8_t>& init_data, | 93 const std::vector<uint8_t>& init_data, |
94 MediaKeys::SessionType session_type, | 94 ContentDecryptionModule::SessionType session_type, |
95 std::unique_ptr<NewSessionCdmPromise> promise) { | 95 std::unique_ptr<NewSessionCdmPromise> promise) { |
96 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data, | 96 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data, |
97 std::move(promise)); | 97 std::move(promise)); |
98 } | 98 } |
99 | 99 |
100 void CdmSessionAdapter::LoadSession( | 100 void CdmSessionAdapter::LoadSession( |
101 MediaKeys::SessionType session_type, | 101 ContentDecryptionModule::SessionType session_type, |
102 const std::string& session_id, | 102 const std::string& session_id, |
103 std::unique_ptr<NewSessionCdmPromise> promise) { | 103 std::unique_ptr<NewSessionCdmPromise> promise) { |
104 cdm_->LoadSession(session_type, session_id, std::move(promise)); | 104 cdm_->LoadSession(session_type, session_id, std::move(promise)); |
105 } | 105 } |
106 | 106 |
107 void CdmSessionAdapter::UpdateSession( | 107 void CdmSessionAdapter::UpdateSession( |
108 const std::string& session_id, | 108 const std::string& session_id, |
109 const std::vector<uint8_t>& response, | 109 const std::vector<uint8_t>& response, |
110 std::unique_ptr<SimpleCdmPromise> promise) { | 110 std::unique_ptr<SimpleCdmPromise> promise) { |
111 cdm_->UpdateSession(session_id, response, std::move(promise)); | 111 cdm_->UpdateSession(session_id, response, std::move(promise)); |
112 } | 112 } |
113 | 113 |
114 void CdmSessionAdapter::CloseSession( | 114 void CdmSessionAdapter::CloseSession( |
115 const std::string& session_id, | 115 const std::string& session_id, |
116 std::unique_ptr<SimpleCdmPromise> promise) { | 116 std::unique_ptr<SimpleCdmPromise> promise) { |
117 cdm_->CloseSession(session_id, std::move(promise)); | 117 cdm_->CloseSession(session_id, std::move(promise)); |
118 } | 118 } |
119 | 119 |
120 void CdmSessionAdapter::RemoveSession( | 120 void CdmSessionAdapter::RemoveSession( |
121 const std::string& session_id, | 121 const std::string& session_id, |
122 std::unique_ptr<SimpleCdmPromise> promise) { | 122 std::unique_ptr<SimpleCdmPromise> promise) { |
123 cdm_->RemoveSession(session_id, std::move(promise)); | 123 cdm_->RemoveSession(session_id, std::move(promise)); |
124 } | 124 } |
125 | 125 |
126 scoped_refptr<MediaKeys> CdmSessionAdapter::GetCdm() { | 126 scoped_refptr<ContentDecryptionModule> CdmSessionAdapter::GetCdm() { |
127 return cdm_; | 127 return cdm_; |
128 } | 128 } |
129 | 129 |
130 const std::string& CdmSessionAdapter::GetKeySystem() const { | 130 const std::string& CdmSessionAdapter::GetKeySystem() const { |
131 return key_system_; | 131 return key_system_; |
132 } | 132 } |
133 | 133 |
134 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { | 134 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { |
135 DCHECK(!key_system_uma_prefix_.empty()); | 135 DCHECK(!key_system_uma_prefix_.empty()); |
136 return key_system_uma_prefix_; | 136 return key_system_uma_prefix_; |
137 } | 137 } |
138 | 138 |
139 void CdmSessionAdapter::OnCdmCreated(const std::string& key_system, | 139 void CdmSessionAdapter::OnCdmCreated( |
140 base::TimeTicks start_time, | 140 const std::string& key_system, |
141 const scoped_refptr<MediaKeys>& cdm, | 141 base::TimeTicks start_time, |
142 const std::string& error_message) { | 142 const scoped_refptr<ContentDecryptionModule>& cdm, |
| 143 const std::string& error_message) { |
143 DVLOG(2) << __func__ << ": " | 144 DVLOG(2) << __func__ << ": " |
144 << (cdm ? "success" : "failure (" + error_message + ")"); | 145 << (cdm ? "success" : "failure (" + error_message + ")"); |
145 DCHECK(!cdm_); | 146 DCHECK(!cdm_); |
146 | 147 |
147 TRACE_EVENT_ASYNC_END2("media", "CdmSessionAdapter::CreateCdm", trace_id_, | 148 TRACE_EVENT_ASYNC_END2("media", "CdmSessionAdapter::CreateCdm", trace_id_, |
148 "success", (cdm ? "true" : "false"), "error_message", | 149 "success", (cdm ? "true" : "false"), "error_message", |
149 error_message); | 150 error_message); |
150 | 151 |
151 if (!cdm) { | 152 if (!cdm) { |
152 cdm_created_result_->completeWithError( | 153 cdm_created_result_->completeWithError( |
(...skipping 10 matching lines...) Expand all Loading... |
163 // Only report time for successful CDM creation. | 164 // Only report time for successful CDM creation. |
164 ReportTimeToCreateCdmUMA(base::TimeTicks::Now() - start_time); | 165 ReportTimeToCreateCdmUMA(base::TimeTicks::Now() - start_time); |
165 | 166 |
166 cdm_ = cdm; | 167 cdm_ = cdm; |
167 | 168 |
168 cdm_created_result_->completeWithContentDecryptionModule( | 169 cdm_created_result_->completeWithContentDecryptionModule( |
169 new WebContentDecryptionModuleImpl(this)); | 170 new WebContentDecryptionModuleImpl(this)); |
170 cdm_created_result_.reset(); | 171 cdm_created_result_.reset(); |
171 } | 172 } |
172 | 173 |
173 void CdmSessionAdapter::OnSessionMessage(const std::string& session_id, | 174 void CdmSessionAdapter::OnSessionMessage( |
174 MediaKeys::MessageType message_type, | 175 const std::string& session_id, |
175 const std::vector<uint8_t>& message) { | 176 ContentDecryptionModule::MessageType message_type, |
| 177 const std::vector<uint8_t>& message) { |
176 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); | 178 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); |
177 DLOG_IF(WARNING, !session) << __func__ << " for unknown session " | 179 DLOG_IF(WARNING, !session) << __func__ << " for unknown session " |
178 << session_id; | 180 << session_id; |
179 if (session) | 181 if (session) |
180 session->OnSessionMessage(message_type, message); | 182 session->OnSessionMessage(message_type, message); |
181 } | 183 } |
182 | 184 |
183 void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id, | 185 void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id, |
184 bool has_additional_usable_key, | 186 bool has_additional_usable_key, |
185 CdmKeysInfo keys_info) { | 187 CdmKeysInfo keys_info) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // Note: This leaks memory, which is expected behavior. | 223 // Note: This leaks memory, which is expected behavior. |
222 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( | 224 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( |
223 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName, | 225 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName, |
224 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10), | 226 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10), |
225 50, base::HistogramBase::kUmaTargetedHistogramFlag); | 227 50, base::HistogramBase::kUmaTargetedHistogramFlag); |
226 | 228 |
227 histogram->AddTime(time); | 229 histogram->AddTime(time); |
228 } | 230 } |
229 | 231 |
230 } // namespace media | 232 } // namespace media |
OLD | NEW |