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

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

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/blink/buffered_resource_loader.cc ('k') | media/blink/key_system_config_selector.cc » ('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 <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
10 #include "base/stl_util.h" 12 #include "base/stl_util.h"
11 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
12 #include "media/base/cdm_factory.h" 14 #include "media/base/cdm_factory.h"
13 #include "media/base/cdm_key_information.h" 15 #include "media/base/cdm_key_information.h"
14 #include "media/base/cdm_promise.h" 16 #include "media/base/cdm_promise.h"
15 #include "media/base/key_systems.h" 17 #include "media/base/key_systems.h"
16 #include "media/blink/webcontentdecryptionmodule_impl.h" 18 #include "media/blink/webcontentdecryptionmodule_impl.h"
(...skipping 21 matching lines...) Expand all
38 ++trace_id_); 40 ++trace_id_);
39 41
40 base::TimeTicks start_time = base::TimeTicks::Now(); 42 base::TimeTicks start_time = base::TimeTicks::Now();
41 43
42 // Note: WebContentDecryptionModuleImpl::Create() calls this method without 44 // Note: WebContentDecryptionModuleImpl::Create() calls this method without
43 // holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with 45 // holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with
44 // |this| instead of |weak_this| to prevent |this| from being destructed. 46 // |this| instead of |weak_this| to prevent |this| from being destructed.
45 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 47 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
46 48
47 DCHECK(!cdm_created_result_); 49 DCHECK(!cdm_created_result_);
48 cdm_created_result_ = result.Pass(); 50 cdm_created_result_ = std::move(result);
49 51
50 cdm_factory->Create( 52 cdm_factory->Create(
51 key_system, security_origin, cdm_config, 53 key_system, security_origin, cdm_config,
52 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 54 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
53 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 55 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
54 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this), 56 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this),
55 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 57 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
56 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this), 58 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this),
57 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system, 59 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system,
58 start_time)); 60 start_time));
59 } 61 }
60 62
61 void CdmSessionAdapter::SetServerCertificate( 63 void CdmSessionAdapter::SetServerCertificate(
62 const std::vector<uint8_t>& certificate, 64 const std::vector<uint8_t>& certificate,
63 scoped_ptr<SimpleCdmPromise> promise) { 65 scoped_ptr<SimpleCdmPromise> promise) {
64 cdm_->SetServerCertificate(certificate, promise.Pass()); 66 cdm_->SetServerCertificate(certificate, std::move(promise));
65 } 67 }
66 68
67 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() { 69 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() {
68 return new WebContentDecryptionModuleSessionImpl(this); 70 return new WebContentDecryptionModuleSessionImpl(this);
69 } 71 }
70 72
71 bool CdmSessionAdapter::RegisterSession( 73 bool CdmSessionAdapter::RegisterSession(
72 const std::string& session_id, 74 const std::string& session_id,
73 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) { 75 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) {
74 // If this session ID is already registered, don't register it again. 76 // If this session ID is already registered, don't register it again.
75 if (ContainsKey(sessions_, session_id)) 77 if (ContainsKey(sessions_, session_id))
76 return false; 78 return false;
77 79
78 sessions_[session_id] = session; 80 sessions_[session_id] = session;
79 return true; 81 return true;
80 } 82 }
81 83
82 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) { 84 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) {
83 DCHECK(ContainsKey(sessions_, session_id)); 85 DCHECK(ContainsKey(sessions_, session_id));
84 sessions_.erase(session_id); 86 sessions_.erase(session_id);
85 } 87 }
86 88
87 void CdmSessionAdapter::InitializeNewSession( 89 void CdmSessionAdapter::InitializeNewSession(
88 EmeInitDataType init_data_type, 90 EmeInitDataType init_data_type,
89 const std::vector<uint8_t>& init_data, 91 const std::vector<uint8_t>& init_data,
90 MediaKeys::SessionType session_type, 92 MediaKeys::SessionType session_type,
91 scoped_ptr<NewSessionCdmPromise> promise) { 93 scoped_ptr<NewSessionCdmPromise> promise) {
92 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data, 94 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data,
93 promise.Pass()); 95 std::move(promise));
94 } 96 }
95 97
96 void CdmSessionAdapter::LoadSession(MediaKeys::SessionType session_type, 98 void CdmSessionAdapter::LoadSession(MediaKeys::SessionType session_type,
97 const std::string& session_id, 99 const std::string& session_id,
98 scoped_ptr<NewSessionCdmPromise> promise) { 100 scoped_ptr<NewSessionCdmPromise> promise) {
99 cdm_->LoadSession(session_type, session_id, promise.Pass()); 101 cdm_->LoadSession(session_type, session_id, std::move(promise));
100 } 102 }
101 103
102 void CdmSessionAdapter::UpdateSession(const std::string& session_id, 104 void CdmSessionAdapter::UpdateSession(const std::string& session_id,
103 const std::vector<uint8_t>& response, 105 const std::vector<uint8_t>& response,
104 scoped_ptr<SimpleCdmPromise> promise) { 106 scoped_ptr<SimpleCdmPromise> promise) {
105 cdm_->UpdateSession(session_id, response, promise.Pass()); 107 cdm_->UpdateSession(session_id, response, std::move(promise));
106 } 108 }
107 109
108 void CdmSessionAdapter::CloseSession(const std::string& session_id, 110 void CdmSessionAdapter::CloseSession(const std::string& session_id,
109 scoped_ptr<SimpleCdmPromise> promise) { 111 scoped_ptr<SimpleCdmPromise> promise) {
110 cdm_->CloseSession(session_id, promise.Pass()); 112 cdm_->CloseSession(session_id, std::move(promise));
111 } 113 }
112 114
113 void CdmSessionAdapter::RemoveSession(const std::string& session_id, 115 void CdmSessionAdapter::RemoveSession(const std::string& session_id,
114 scoped_ptr<SimpleCdmPromise> promise) { 116 scoped_ptr<SimpleCdmPromise> promise) {
115 cdm_->RemoveSession(session_id, promise.Pass()); 117 cdm_->RemoveSession(session_id, std::move(promise));
116 } 118 }
117 119
118 CdmContext* CdmSessionAdapter::GetCdmContext() { 120 CdmContext* CdmSessionAdapter::GetCdmContext() {
119 return cdm_->GetCdmContext(); 121 return cdm_->GetCdmContext();
120 } 122 }
121 123
122 const std::string& CdmSessionAdapter::GetKeySystem() const { 124 const std::string& CdmSessionAdapter::GetKeySystem() const {
123 return key_system_; 125 return key_system_;
124 } 126 }
125 127
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 176 }
175 177
176 void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id, 178 void CdmSessionAdapter::OnSessionKeysChange(const std::string& session_id,
177 bool has_additional_usable_key, 179 bool has_additional_usable_key,
178 CdmKeysInfo keys_info) { 180 CdmKeysInfo keys_info) {
179 // TODO(jrummell): Pass |keys_info| on. 181 // TODO(jrummell): Pass |keys_info| on.
180 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 182 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
181 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " 183 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session "
182 << session_id; 184 << session_id;
183 if (session) 185 if (session)
184 session->OnSessionKeysChange(has_additional_usable_key, keys_info.Pass()); 186 session->OnSessionKeysChange(has_additional_usable_key,
187 std::move(keys_info));
185 } 188 }
186 189
187 void CdmSessionAdapter::OnSessionExpirationUpdate( 190 void CdmSessionAdapter::OnSessionExpirationUpdate(
188 const std::string& session_id, 191 const std::string& session_id,
189 const base::Time& new_expiry_time) { 192 const base::Time& new_expiry_time) {
190 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 193 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
191 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session " 194 DLOG_IF(WARNING, !session) << __FUNCTION__ << " for unknown session "
192 << session_id; 195 << session_id;
193 if (session) 196 if (session)
194 session->OnSessionExpirationUpdate(new_expiry_time); 197 session->OnSessionExpirationUpdate(new_expiry_time);
(...skipping 29 matching lines...) Expand all
224 // Note: This leaks memory, which is expected behavior. 227 // Note: This leaks memory, which is expected behavior.
225 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( 228 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
226 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName, 229 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName,
227 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10), 230 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10),
228 50, base::HistogramBase::kUmaTargetedHistogramFlag); 231 50, base::HistogramBase::kUmaTargetedHistogramFlag);
229 232
230 histogram->AddTime(time); 233 histogram->AddTime(time);
231 } 234 }
232 235
233 } // namespace media 236 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/buffered_resource_loader.cc ('k') | media/blink/key_system_config_selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698