OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 const char kDot[] = "."; | 23 const char kDot[] = "."; |
24 | 24 |
25 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) { | 25 CdmSessionAdapter::CdmSessionAdapter() : weak_ptr_factory_(this) { |
26 } | 26 } |
27 | 27 |
28 CdmSessionAdapter::~CdmSessionAdapter() {} | 28 CdmSessionAdapter::~CdmSessionAdapter() {} |
29 | 29 |
30 void CdmSessionAdapter::CreateCdm( | 30 void CdmSessionAdapter::CreateCdm( |
31 CdmFactory* cdm_factory, | 31 CdmFactory* cdm_factory, |
32 const std::string& key_system, | 32 const std::string& key_system, |
| 33 bool allow_distinctive_identifier, |
| 34 bool allow_persistent_state, |
33 const GURL& security_origin, | 35 const GURL& security_origin, |
34 const CdmConfig& cdm_config, | |
35 blink::WebContentDecryptionModuleResult result) { | 36 blink::WebContentDecryptionModuleResult result) { |
36 // Note: WebContentDecryptionModuleImpl::Create() calls this method without | 37 // Note: WebContentDecryptionModuleImpl::Create() calls this method without |
37 // holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with | 38 // holding a reference to the CdmSessionAdapter. Bind OnCdmCreated() with |
38 // |this| instead of |weak_this| to prevent |this| from being destructed. | 39 // |this| instead of |weak_this| to prevent |this| from being destructed. |
39 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); | 40 base::WeakPtr<CdmSessionAdapter> weak_this = weak_ptr_factory_.GetWeakPtr(); |
40 cdm_factory->Create( | 41 cdm_factory->Create( |
41 key_system, security_origin, cdm_config, | 42 key_system, allow_distinctive_identifier, allow_persistent_state, |
| 43 security_origin, |
42 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), | 44 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), |
43 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), | 45 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), |
44 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this), | 46 base::Bind(&CdmSessionAdapter::OnLegacySessionError, weak_this), |
45 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), | 47 base::Bind(&CdmSessionAdapter::OnSessionKeysChange, weak_this), |
46 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this), | 48 base::Bind(&CdmSessionAdapter::OnSessionExpirationUpdate, weak_this), |
47 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system, result)); | 49 base::Bind(&CdmSessionAdapter::OnCdmCreated, this, key_system, result)); |
48 } | 50 } |
49 | 51 |
50 void CdmSessionAdapter::SetServerCertificate( | 52 void CdmSessionAdapter::SetServerCertificate( |
51 const std::vector<uint8_t>& certificate, | 53 const std::vector<uint8_t>& certificate, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( | 193 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( |
192 const std::string& session_id) { | 194 const std::string& session_id) { |
193 // Since session objects may get garbage collected, it is possible that there | 195 // Since session objects may get garbage collected, it is possible that there |
194 // are events coming back from the CDM and the session has been unregistered. | 196 // are events coming back from the CDM and the session has been unregistered. |
195 // We can not tell if the CDM is firing events at sessions that never existed. | 197 // We can not tell if the CDM is firing events at sessions that never existed. |
196 SessionMap::iterator session = sessions_.find(session_id); | 198 SessionMap::iterator session = sessions_.find(session_id); |
197 return (session != sessions_.end()) ? session->second.get() : NULL; | 199 return (session != sessions_.end()) ? session->second.get() : NULL; |
198 } | 200 } |
199 | 201 |
200 } // namespace media | 202 } // namespace media |
OLD | NEW |