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

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

Issue 1407933010: media: Make MediaKeys ref-counted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 1 month 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/blink/cdm_session_adapter.h ('k') | media/cdm/aes_decryptor.h » ('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 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 const std::string& CdmSessionAdapter::GetKeySystem() const { 122 const std::string& CdmSessionAdapter::GetKeySystem() const {
123 return key_system_; 123 return key_system_;
124 } 124 }
125 125
126 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { 126 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const {
127 DCHECK(!key_system_uma_prefix_.empty()); 127 DCHECK(!key_system_uma_prefix_.empty());
128 return key_system_uma_prefix_; 128 return key_system_uma_prefix_;
129 } 129 }
130 130
131 void CdmSessionAdapter::OnCdmCreated( 131 void CdmSessionAdapter::OnCdmCreated(const std::string& key_system,
132 const std::string& key_system, 132 base::TimeTicks start_time,
133 base::TimeTicks start_time, 133 const scoped_refptr<MediaKeys>& cdm,
134 scoped_ptr<MediaKeys> cdm, 134 const std::string& error_message) {
135 const std::string& error_message) {
136 DVLOG(2) << __FUNCTION__; 135 DVLOG(2) << __FUNCTION__;
137 DCHECK(!cdm_); 136 DCHECK(!cdm_);
138 137
139 TRACE_EVENT_ASYNC_END2("media", "CdmSessionAdapter::CreateCdm", trace_id_, 138 TRACE_EVENT_ASYNC_END2("media", "CdmSessionAdapter::CreateCdm", trace_id_,
140 "success", (cdm ? "true" : "false"), "error_message", 139 "success", (cdm ? "true" : "false"), "error_message",
141 error_message); 140 error_message);
142 141
143 if (!cdm) { 142 if (!cdm) {
144 cdm_created_result_->completeWithError( 143 cdm_created_result_->completeWithError(
145 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, 144 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
146 blink::WebString::fromUTF8(error_message)); 145 blink::WebString::fromUTF8(error_message));
147 cdm_created_result_.reset(); 146 cdm_created_result_.reset();
148 return; 147 return;
149 } 148 }
150 149
151 key_system_ = key_system; 150 key_system_ = key_system;
152 key_system_uma_prefix_ = 151 key_system_uma_prefix_ =
153 kMediaEME + GetKeySystemNameForUMA(key_system) + kDot; 152 kMediaEME + GetKeySystemNameForUMA(key_system) + kDot;
154 153
155 // Only report time for successful CDM creation. 154 // Only report time for successful CDM creation.
156 ReportTimeToCreateCdmUMA(base::TimeTicks::Now() - start_time); 155 ReportTimeToCreateCdmUMA(base::TimeTicks::Now() - start_time);
157 156
158 cdm_ = cdm.Pass(); 157 cdm_ = cdm;
159 158
160 cdm_created_result_->completeWithContentDecryptionModule( 159 cdm_created_result_->completeWithContentDecryptionModule(
161 new WebContentDecryptionModuleImpl(this)); 160 new WebContentDecryptionModuleImpl(this));
162 cdm_created_result_.reset(); 161 cdm_created_result_.reset();
163 } 162 }
164 163
165 void CdmSessionAdapter::OnSessionMessage( 164 void CdmSessionAdapter::OnSessionMessage(
166 const std::string& session_id, 165 const std::string& session_id,
167 MediaKeys::MessageType message_type, 166 MediaKeys::MessageType message_type,
168 const std::vector<uint8_t>& message, 167 const std::vector<uint8_t>& message,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // Note: This leaks memory, which is expected behavior. 224 // Note: This leaks memory, which is expected behavior.
226 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( 225 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
227 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName, 226 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName,
228 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10), 227 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10),
229 50, base::HistogramBase::kUmaTargetedHistogramFlag); 228 50, base::HistogramBase::kUmaTargetedHistogramFlag);
230 229
231 histogram->AddTime(time); 230 histogram->AddTime(time);
232 } 231 }
233 232
234 } // namespace media 233 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/cdm_session_adapter.h ('k') | media/cdm/aes_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698