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

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

Issue 1904253002: Convert //media/blink from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/cdm_session_adapter.h ('k') | media/blink/key_system_config_selector.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 <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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 base::ThreadTaskRunnerHandle::Get()->PostTask( 45 base::ThreadTaskRunnerHandle::Get()->PostTask(
46 FROM_HERE, base::Bind(&ReleaseCdm, cdm_)); 46 FROM_HERE, base::Bind(&ReleaseCdm, cdm_));
47 } 47 }
48 } 48 }
49 49
50 void CdmSessionAdapter::CreateCdm( 50 void CdmSessionAdapter::CreateCdm(
51 CdmFactory* cdm_factory, 51 CdmFactory* cdm_factory,
52 const std::string& key_system, 52 const std::string& key_system,
53 const GURL& security_origin, 53 const GURL& security_origin,
54 const CdmConfig& cdm_config, 54 const CdmConfig& cdm_config,
55 scoped_ptr<blink::WebContentDecryptionModuleResult> result) { 55 std::unique_ptr<blink::WebContentDecryptionModuleResult> result) {
56 TRACE_EVENT_ASYNC_BEGIN0("media", "CdmSessionAdapter::CreateCdm", 56 TRACE_EVENT_ASYNC_BEGIN0("media", "CdmSessionAdapter::CreateCdm",
57 ++trace_id_); 57 ++trace_id_);
58 58
59 base::TimeTicks start_time = base::TimeTicks::Now(); 59 base::TimeTicks start_time = base::TimeTicks::Now();
60 60
61 // Note: WebContentDecryptionModuleImpl::Create() calls this method without 61 // Note: WebContentDecryptionModuleImpl::Create() calls this method without
62 // holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with 62 // holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with
63 // |this| instead of |weak_this| to prevent |this| from being destructed. 63 // |this| instead of |weak_this| to prevent |this| from being destructed.
64 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 64 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
65 65
66 DCHECK(!cdm_created_result_); 66 DCHECK(!cdm_created_result_);
67 cdm_created_result_ = std::move(result); 67 cdm_created_result_ = std::move(result);
68 68
69 cdm_factory->Create( 69 cdm_factory->Create(
70 key_system, security_origin, cdm_config, 70 key_system, security_origin, cdm_config,
71 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 71 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
72 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 72 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
73 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this), 73 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this),
74 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 74 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
75 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this), 75 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this),
76 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system, 76 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system,
77 start_time)); 77 start_time));
78 } 78 }
79 79
80 void CdmSessionAdapter::SetServerCertificate( 80 void CdmSessionAdapter::SetServerCertificate(
81 const std::vector<uint8_t>& certificate, 81 const std::vector<uint8_t>& certificate,
82 scoped_ptr<SimpleCdmPromise> promise) { 82 std::unique_ptr<SimpleCdmPromise> promise) {
83 cdm_->SetServerCertificate(certificate, std::move(promise)); 83 cdm_->SetServerCertificate(certificate, std::move(promise));
84 } 84 }
85 85
86 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() { 86 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() {
87 return new WebContentDecryptionModuleSessionImpl(this); 87 return new WebContentDecryptionModuleSessionImpl(this);
88 } 88 }
89 89
90 bool CdmSessionAdapter::RegisterSession( 90 bool CdmSessionAdapter::RegisterSession(
91 const std::string& session_id, 91 const std::string& session_id,
92 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) { 92 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) {
93 // If this session ID is already registered, don't register it again. 93 // If this session ID is already registered, don't register it again.
94 if (ContainsKey(sessions_, session_id)) 94 if (ContainsKey(sessions_, session_id))
95 return false; 95 return false;
96 96
97 sessions_[session_id] = session; 97 sessions_[session_id] = session;
98 return true; 98 return true;
99 } 99 }
100 100
101 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) { 101 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) {
102 DCHECK(ContainsKey(sessions_, session_id)); 102 DCHECK(ContainsKey(sessions_, session_id));
103 sessions_.erase(session_id); 103 sessions_.erase(session_id);
104 } 104 }
105 105
106 void CdmSessionAdapter::InitializeNewSession( 106 void CdmSessionAdapter::InitializeNewSession(
107 EmeInitDataType init_data_type, 107 EmeInitDataType init_data_type,
108 const std::vector<uint8_t>& init_data, 108 const std::vector<uint8_t>& init_data,
109 MediaKeys::SessionType session_type, 109 MediaKeys::SessionType session_type,
110 scoped_ptr<NewSessionCdmPromise> promise) { 110 std::unique_ptr<NewSessionCdmPromise> promise) {
111 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data, 111 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data,
112 std::move(promise)); 112 std::move(promise));
113 } 113 }
114 114
115 void CdmSessionAdapter::LoadSession(MediaKeys::SessionType session_type, 115 void CdmSessionAdapter::LoadSession(
116 const std::string& session_id, 116 MediaKeys::SessionType session_type,
117 scoped_ptr<NewSessionCdmPromise> promise) { 117 const std::string& session_id,
118 std::unique_ptr<NewSessionCdmPromise> promise) {
118 cdm_->LoadSession(session_type, session_id, std::move(promise)); 119 cdm_->LoadSession(session_type, session_id, std::move(promise));
119 } 120 }
120 121
121 void CdmSessionAdapter::UpdateSession(const std::string& session_id, 122 void CdmSessionAdapter::UpdateSession(
122 const std::vector<uint8_t>& response, 123 const std::string& session_id,
123 scoped_ptr<SimpleCdmPromise> promise) { 124 const std::vector<uint8_t>& response,
125 std::unique_ptr<SimpleCdmPromise> promise) {
124 cdm_->UpdateSession(session_id, response, std::move(promise)); 126 cdm_->UpdateSession(session_id, response, std::move(promise));
125 } 127 }
126 128
127 void CdmSessionAdapter::CloseSession(const std::string& session_id, 129 void CdmSessionAdapter::CloseSession(
128 scoped_ptr<SimpleCdmPromise> promise) { 130 const std::string& session_id,
131 std::unique_ptr<SimpleCdmPromise> promise) {
129 cdm_->CloseSession(session_id, std::move(promise)); 132 cdm_->CloseSession(session_id, std::move(promise));
130 } 133 }
131 134
132 void CdmSessionAdapter::RemoveSession(const std::string& session_id, 135 void CdmSessionAdapter::RemoveSession(
133 scoped_ptr<SimpleCdmPromise> promise) { 136 const std::string& session_id,
137 std::unique_ptr<SimpleCdmPromise> promise) {
134 cdm_->RemoveSession(session_id, std::move(promise)); 138 cdm_->RemoveSession(session_id, std::move(promise));
135 } 139 }
136 140
137 CdmContext* CdmSessionAdapter::GetCdmContext() { 141 CdmContext* CdmSessionAdapter::GetCdmContext() {
138 return cdm_->GetCdmContext(); 142 return cdm_->GetCdmContext();
139 } 143 }
140 144
141 const std::string& CdmSessionAdapter::GetKeySystem() const { 145 const std::string& CdmSessionAdapter::GetKeySystem() const {
142 return key_system_; 146 return key_system_;
143 } 147 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Note: This leaks memory, which is expected behavior. 248 // Note: This leaks memory, which is expected behavior.
245 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet( 249 base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
246 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName, 250 GetKeySystemUMAPrefix() + kTimeToCreateCdmUMAName,
247 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10), 251 base::TimeDelta::FromMilliseconds(1), base::TimeDelta::FromSeconds(10),
248 50, base::HistogramBase::kUmaTargetedHistogramFlag); 252 50, base::HistogramBase::kUmaTargetedHistogramFlag);
249 253
250 histogram->AddTime(time); 254 histogram->AddTime(time);
251 } 255 }
252 256
253 } // namespace media 257 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/cdm_session_adapter.h ('k') | media/blink/key_system_config_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698