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

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

Issue 1072403009: Use std::vector<uint8_t> instead of uint8*/int for MediaKeys interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 security_origin, 43 security_origin,
44 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 44 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
45 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 45 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
46 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this), 46 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this),
47 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 47 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
48 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this), 48 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this),
49 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system, result)); 49 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system, result));
50 } 50 }
51 51
52 void CdmSessionAdapter::SetServerCertificate( 52 void CdmSessionAdapter::SetServerCertificate(
53 const uint8* server_certificate, 53 const std::vector<uint8>& server_certificate,
54 int server_certificate_length,
55 scoped_ptr<SimpleCdmPromise> promise) { 54 scoped_ptr<SimpleCdmPromise> promise) {
56 cdm_->SetServerCertificate(server_certificate, server_certificate_length, 55 cdm_->SetServerCertificate(server_certificate, promise.Pass());
57 promise.Pass());
58 } 56 }
59 57
60 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() { 58 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() {
61 return new WebContentDecryptionModuleSessionImpl(this); 59 return new WebContentDecryptionModuleSessionImpl(this);
62 } 60 }
63 61
64 bool CdmSessionAdapter::RegisterSession( 62 bool CdmSessionAdapter::RegisterSession(
65 const std::string& session_id, 63 const std::string& session_id,
66 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) { 64 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) {
67 // If this session ID is already registered, don't register it again. 65 // If this session ID is already registered, don't register it again.
68 if (ContainsKey(sessions_, session_id)) 66 if (ContainsKey(sessions_, session_id))
69 return false; 67 return false;
70 68
71 sessions_[session_id] = session; 69 sessions_[session_id] = session;
72 return true; 70 return true;
73 } 71 }
74 72
75 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) { 73 void CdmSessionAdapter::UnregisterSession(const std::string& session_id) {
76 DCHECK(ContainsKey(sessions_, session_id)); 74 DCHECK(ContainsKey(sessions_, session_id));
77 sessions_.erase(session_id); 75 sessions_.erase(session_id);
78 } 76 }
79 77
80 void CdmSessionAdapter::InitializeNewSession( 78 void CdmSessionAdapter::InitializeNewSession(
81 EmeInitDataType init_data_type, 79 EmeInitDataType init_data_type,
82 const uint8* init_data, 80 const std::vector<uint8>& init_data,
83 int init_data_length,
84 MediaKeys::SessionType session_type, 81 MediaKeys::SessionType session_type,
85 scoped_ptr<NewSessionCdmPromise> promise) { 82 scoped_ptr<NewSessionCdmPromise> promise) {
86 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data, 83 cdm_->CreateSessionAndGenerateRequest(session_type, init_data_type, init_data,
87 init_data_length, promise.Pass()); 84 promise.Pass());
88 } 85 }
89 86
90 void CdmSessionAdapter::LoadSession(MediaKeys::SessionType session_type, 87 void CdmSessionAdapter::LoadSession(MediaKeys::SessionType session_type,
91 const std::string& session_id, 88 const std::string& session_id,
92 scoped_ptr<NewSessionCdmPromise> promise) { 89 scoped_ptr<NewSessionCdmPromise> promise) {
93 cdm_->LoadSession(session_type, session_id, promise.Pass()); 90 cdm_->LoadSession(session_type, session_id, promise.Pass());
94 } 91 }
95 92
96 void CdmSessionAdapter::UpdateSession(const std::string& session_id, 93 void CdmSessionAdapter::UpdateSession(const std::string& session_id,
97 const uint8* response, 94 const std::vector<uint8>& response,
98 int response_length,
99 scoped_ptr<SimpleCdmPromise> promise) { 95 scoped_ptr<SimpleCdmPromise> promise) {
100 cdm_->UpdateSession(session_id, response, response_length, promise.Pass()); 96 cdm_->UpdateSession(session_id, response, promise.Pass());
101 } 97 }
102 98
103 void CdmSessionAdapter::CloseSession(const std::string& session_id, 99 void CdmSessionAdapter::CloseSession(const std::string& session_id,
104 scoped_ptr<SimpleCdmPromise> promise) { 100 scoped_ptr<SimpleCdmPromise> promise) {
105 cdm_->CloseSession(session_id, promise.Pass()); 101 cdm_->CloseSession(session_id, promise.Pass());
106 } 102 }
107 103
108 void CdmSessionAdapter::RemoveSession(const std::string& session_id, 104 void CdmSessionAdapter::RemoveSession(const std::string& session_id,
109 scoped_ptr<SimpleCdmPromise> promise) { 105 scoped_ptr<SimpleCdmPromise> promise) {
110 cdm_->RemoveSession(session_id, promise.Pass()); 106 cdm_->RemoveSession(session_id, promise.Pass());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 192 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
197 const std::string& session_id) { 193 const std::string& session_id) {
198 // Since session objects may get garbage collected, it is possible that there 194 // Since session objects may get garbage collected, it is possible that there
199 // are events coming back from the CDM and the session has been unregistered. 195 // are events coming back from the CDM and the session has been unregistered.
200 // We can not tell if the CDM is firing events at sessions that never existed. 196 // We can not tell if the CDM is firing events at sessions that never existed.
201 SessionMap::iterator session = sessions_.find(session_id); 197 SessionMap::iterator session = sessions_.find(session_id);
202 return (session != sessions_.end()) ? session->second.get() : NULL; 198 return (session != sessions_.end()) ? session->second.get() : NULL;
203 } 199 }
204 200
205 } // namespace media 201 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698