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

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

Issue 897133002: Check InitDateType is supported by key system when creating session (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 11 matching lines...) Expand all
22 const char kDot[] = "."; 22 const char kDot[] = ".";
23 23
24 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) { 24 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) {
25 } 25 }
26 26
27 CdmSessionAdapter::~CdmSessionAdapter() {} 27 CdmSessionAdapter::~CdmSessionAdapter() {}
28 28
29 bool CdmSessionAdapter::Initialize(CdmFactory* cdm_factory, 29 bool CdmSessionAdapter::Initialize(CdmFactory* cdm_factory,
30 const std::string& key_system, 30 const std::string& key_system,
31 const GURL& security_origin) { 31 const GURL& security_origin) {
32 key_system_ = key_system;
32 key_system_uma_prefix_ = 33 key_system_uma_prefix_ =
33 kMediaEME + GetKeySystemNameForUMA(key_system) + kDot; 34 kMediaEME + GetKeySystemNameForUMA(key_system) + kDot;
34 35
35 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); 36 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr();
36 media_keys_ = cdm_factory->Create( 37 media_keys_ = cdm_factory->Create(
37 key_system, security_origin, 38 key_system, security_origin,
38 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), 39 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this),
39 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), 40 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this),
40 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this), 41 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this),
41 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), 42 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 104
104 void CdmSessionAdapter::RemoveSession(const std::string& session_id, 105 void CdmSessionAdapter::RemoveSession(const std::string& session_id,
105 scoped_ptr<SimpleCdmPromise> promise) { 106 scoped_ptr<SimpleCdmPromise> promise) {
106 media_keys_->RemoveSession(session_id, promise.Pass()); 107 media_keys_->RemoveSession(session_id, promise.Pass());
107 } 108 }
108 109
109 CdmContext* CdmSessionAdapter::GetCdmContext() { 110 CdmContext* CdmSessionAdapter::GetCdmContext() {
110 return media_keys_->GetCdmContext(); 111 return media_keys_->GetCdmContext();
111 } 112 }
112 113
114 const std::string& CdmSessionAdapter::GetKeySystem() const {
115 return key_system_;
116 }
117
113 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const { 118 const std::string& CdmSessionAdapter::GetKeySystemUMAPrefix() const {
114 return key_system_uma_prefix_; 119 return key_system_uma_prefix_;
115 } 120 }
116 121
117 void CdmSessionAdapter::OnSessionMessage( 122 void CdmSessionAdapter::OnSessionMessage(
118 const std::string& session_id, 123 const std::string& session_id,
119 MediaKeys::MessageType message_type, 124 MediaKeys::MessageType message_type,
120 const std::vector<uint8>& message, 125 const std::vector<uint8>& message,
121 const GURL& /* legacy_destination_url */) { 126 const GURL& /* legacy_destination_url */) {
122 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id); 127 WebContentDecryptionModuleSessionImpl* session = GetSession(session_id);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( 171 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession(
167 const std::string& session_id) { 172 const std::string& session_id) {
168 // Since session objects may get garbage collected, it is possible that there 173 // Since session objects may get garbage collected, it is possible that there
169 // are events coming back from the CDM and the session has been unregistered. 174 // are events coming back from the CDM and the session has been unregistered.
170 // We can not tell if the CDM is firing events at sessions that never existed. 175 // We can not tell if the CDM is firing events at sessions that never existed.
171 SessionMap::iterator session = sessions_.find(session_id); 176 SessionMap::iterator session = sessions_.find(session_id);
172 return (session != sessions_.end()) ? session->second.get() : NULL; 177 return (session != sessions_.end()) ? session->second.get() : NULL;
173 } 178 }
174 179
175 } // namespace media 180 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698