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

Side by Side Diff: media/blink/cdm_session_adapter.cc

Issue 2663483003: media: Add log in CdmSessionAdapter (Closed)
Patch Set: media: Add log in CdmSessionAdapter Created 3 years, 10 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 | « media/base/cdm_key_information.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 CdmSessionType session_type, 94 CdmSessionType 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 CdmSessionType session_type, 101 CdmSessionType 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 DVLOG(2) << __func__ << ": session_id = " << session_id;
104 cdm_->LoadSession(session_type, session_id, std::move(promise)); 105 cdm_->LoadSession(session_type, session_id, std::move(promise));
105 } 106 }
106 107
107 void CdmSessionAdapter::UpdateSession( 108 void CdmSessionAdapter::UpdateSession(
108 const std::string& session_id, 109 const std::string& session_id,
109 const std::vector<uint8_t>& response, 110 const std::vector<uint8_t>& response,
110 std::unique_ptr<SimpleCdmPromise> promise) { 111 std::unique_ptr<SimpleCdmPromise> promise) {
112 DVLOG(3) << __func__ << ": session_id = " << session_id;
111 cdm_->UpdateSession(session_id, response, std::move(promise)); 113 cdm_->UpdateSession(session_id, response, std::move(promise));
112 } 114 }
113 115
114 void CdmSessionAdapter::CloseSession( 116 void CdmSessionAdapter::CloseSession(
115 const std::string& session_id, 117 const std::string& session_id,
116 std::unique_ptr<SimpleCdmPromise> promise) { 118 std::unique_ptr<SimpleCdmPromise> promise) {
119 DVLOG(2) << __func__ << ": session_id = " << session_id;
117 cdm_->CloseSession(session_id, std::move(promise)); 120 cdm_->CloseSession(session_id, std::move(promise));
118 } 121 }
119 122
120 void CdmSessionAdapter::RemoveSession( 123 void CdmSessionAdapter::RemoveSession(
121 const std::string& session_id, 124 const std::string& session_id,
122 std::unique_ptr<SimpleCdmPromise> promise) { 125 std::unique_ptr<SimpleCdmPromise> promise) {
126 DVLOG(2) << __func__ << ": session_id = " << session_id;
123 cdm_->RemoveSession(session_id, std::move(promise)); 127 cdm_->RemoveSession(session_id, std::move(promise));
124 } 128 }
125 129
126 scoped_refptr<ContentDecryptionModule> CdmSessionAdapter::GetCdm() { 130 scoped_refptr<ContentDecryptionModule> CdmSessionAdapter::GetCdm() {
127 return cdm_; 131 return cdm_;
128 } 132 }
129 133
130 const std::string& CdmSessionAdapter::GetKeySystem() const { 134 const std::string& CdmSessionAdapter::GetKeySystem() const {
131 return key_system_; 135 return key_system_;
132 } 136 }
133 137
134 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { 138 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const {
135 DCHECK(!key_system_uma_prefix_.empty()); 139 DCHECK(!key_system_uma_prefix_.empty());
136 return key_system_uma_prefix_; 140 return key_system_uma_prefix_;
137 } 141 }
138 142
139 void CdmSessionAdapter::OnCdmCreated( 143 void CdmSessionAdapter::OnCdmCreated(
140 const std::string& key_system, 144 const std::string& key_system,
141 base::TimeTicks start_time, 145 base::TimeTicks start_time,
142 const scoped_refptr<ContentDecryptionModule>& cdm, 146 const scoped_refptr<ContentDecryptionModule>& cdm,
143 const std::string& error_message) { 147 const std::string& error_message) {
144 DVLOG(2) << __func__ << ": " 148 DVLOG(1) << __func__ << ": "
145 << (cdm ? "success" : "failure (" + error_message + ")"); 149 << (cdm ? "success" : "failure (" + error_message + ")");
146 DCHECK(!cdm_); 150 DCHECK(!cdm_);
147 151
148 TRACE_EVENT_ASYNC_END2("media", "CdmSessionAdapter::CreateCdm", trace_id_, 152 TRACE_EVENT_ASYNC_END2("media", "CdmSessionAdapter::CreateCdm", trace_id_,
149 "success", (cdm ? "true" : "false"), "error_message", 153 "success", (cdm ? "true" : "false"), "error_message",
150 error_message); 154 error_message);
151 155
152 if (!cdm) { 156 if (!cdm) {
153 cdm_created_result_->completeWithError( 157 cdm_created_result_->completeWithError(
154 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, 158 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
(...skipping 16 matching lines...) Expand all
171 cdm_created_result_.reset(); 175 cdm_created_result_.reset();
172 } 176 }
173 177
174 void CdmSessionAdapter::OnSessionMessage( 178 void CdmSessionAdapter::OnSessionMessage(
175 const std::string& session_id, 179 const std::string& session_id,
176 ContentDecryptionModule::MessageType message_type, 180 ContentDecryptionModule::MessageType message_type,
177 const std::vector<uint8_t>& message) { 181 const std::vector<uint8_t>& message) {
178 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 182 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
179 DLOG_IF(WARNING, !session) << __func__ << " for unknown session " 183 DLOG_IF(WARNING, !session) << __func__ << " for unknown session "
180 << session_id; 184 << session_id;
181 if (session) 185 if (session) {
186 DVLOG(3) << __func__ << ": session_id = " << session_id;
182 session->OnSessionMessage(message_type, message); 187 session->OnSessionMessage(message_type, message);
188 }
183 } 189 }
184 190
185 void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id, 191 void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id,
186 bool has_additional_usable_key, 192 bool has_additional_usable_key,
187 CdmKeysInfo keys_info) { 193 CdmKeysInfo keys_info) {
188 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 194 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
189 DLOG_IF(WARNING, !session) << __func__ << " for unknown session " 195 DLOG_IF(WARNING, !session) << __func__ << " for unknown session "
190 << session_id; 196 << session_id;
191 if (session) 197 if (session) {
198 DVLOG(2) << __func__ << ": session_id = " << session_id;
199 DVLOG(2) << " - has_additional_usable_key = " << has_additional_usable_key;
200 for (const CdmKeyInformation* info : keys_info)
201 DVLOG(2) << " - " << *info;
202
192 session->OnSessionKeysChange(has_additional_usable_key, 203 session->OnSessionKeysChange(has_additional_usable_key,
193 std::move(keys_info)); 204 std::move(keys_info));
205 }
194 } 206 }
195 207
196 void CdmSessionAdapter::OnSessionExpirationUpdate(const std::string& session_id, 208 void CdmSessionAdapter::OnSessionExpirationUpdate(const std::string& session_id,
197 base::Time new_expiry_time) { 209 base::Time new_expiry_time) {
198 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 210 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
199 DLOG_IF(WARNING, !session) << __func__ << " for unknown session " 211 DLOG_IF(WARNING, !session) << __func__ << " for unknown session "
200 << session_id; 212 << session_id;
201 if (session) 213 if (session) {
214 DVLOG(2) << __func__ << ": session_id = " << session_id;
215 if (new_expiry_time.is_null())
216 DVLOG(2) << " - new_expiry_time = NaN";
217 else
218 DVLOG(2) << " - new_expiry_time = " << new_expiry_time;
219
202 session->OnSessionExpirationUpdate(new_expiry_time); 220 session->OnSessionExpirationUpdate(new_expiry_time);
221 }
203 } 222 }
204 223
205 void CdmSessionAdapter::OnSessionClosed(const std::string& session_id) { 224 void CdmSessionAdapter::OnSessionClosed(const std::string& session_id) {
206 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 225 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
207 DLOG_IF(WARNING, !session) << __func__ << " for unknown session " 226 DLOG_IF(WARNING, !session) << __func__ << " for unknown session "
208 << session_id; 227 << session_id;
209 if (session) 228 if (session) {
229 DVLOG(2) << __func__ << ": session_id = " << session_id;
210 session->OnSessionClosed(); 230 session->OnSessionClosed();
231 }
211 } 232 }
212 233
213 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 234 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
214 const std::string& session_id) { 235 const std::string& session_id) {
215 // Since session objects may get garbage collected, it is possible that there 236 // Since session objects may get garbage collected, it is possible that there
216 // are events coming back from the CDM and the session has been unregistered. 237 // are events coming back from the CDM and the session has been unregistered.
217 // We can not tell if the CDM is firing events at sessions that never existed. 238 // We can not tell if the CDM is firing events at sessions that never existed.
218 SessionMap::iterator session = sessions_.find(session_id); 239 SessionMap::iterator session = sessions_.find(session_id);
219 return (session != sessions_.end()) ? session->second.get() : NULL; 240 return (session != sessions_.end()) ? session->second.get() : NULL;
220 } 241 }
221 242
222 void CdmSessionAdapter::ReportTimeToCreateCdmUMA(base::TimeDelta time) const { 243 void CdmSessionAdapter::ReportTimeToCreateCdmUMA(base::TimeDelta time) const {
223 // Note: This leaks memory, which is expected behavior. 244 // Note: This leaks memory, which is expected behavior.
224 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( 245 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
225 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName, 246 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName,
226 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10), 247 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10),
227 50, base::HistogramBase::kUmaTargetedHistogramFlag); 248 50, base::HistogramBase::kUmaTargetedHistogramFlag);
228 249
229 histogram->AddTime(time); 250 histogram->AddTime(time);
230 } 251 }
231 252
232 } // namespace media 253 } // namespace media
OLDNEW
« no previous file with comments | « media/base/cdm_key_information.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698