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 "content/renderer/media/cdm_session_adapter.h" | 5 #include "content/renderer/media/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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #endif // defined(ENABLE_PEPPER_CDMS) | 44 #endif // defined(ENABLE_PEPPER_CDMS) |
45 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), | 45 base::Bind(&CdmSessionAdapter::OnSessionMessage, weak_this), |
46 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), | 46 base::Bind(&CdmSessionAdapter::OnSessionReady, weak_this), |
47 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), | 47 base::Bind(&CdmSessionAdapter::OnSessionClosed, weak_this), |
48 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this)); | 48 base::Bind(&CdmSessionAdapter::OnSessionError, weak_this)); |
49 | 49 |
50 // Success if |media_keys_| created. | 50 // Success if |media_keys_| created. |
51 return media_keys_; | 51 return media_keys_; |
52 } | 52 } |
53 | 53 |
54 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession( | 54 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::CreateSession() { |
55 blink::WebContentDecryptionModuleSession::Client* client) { | 55 return new WebContentDecryptionModuleSessionImpl(this); |
56 return new WebContentDecryptionModuleSessionImpl(client, this); | |
57 } | 56 } |
58 | 57 |
59 bool CdmSessionAdapter::RegisterSession( | 58 bool CdmSessionAdapter::RegisterSession( |
60 const std::string& web_session_id, | 59 const std::string& web_session_id, |
61 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) { | 60 base::WeakPtr<WebContentDecryptionModuleSessionImpl> session) { |
62 // If this session ID is already registered, don't register it again. | 61 // If this session ID is already registered, don't register it again. |
63 if (ContainsKey(sessions_, web_session_id)) | 62 if (ContainsKey(sessions_, web_session_id)) |
64 return false; | 63 return false; |
65 | 64 |
66 sessions_[web_session_id] = session; | 65 sessions_[web_session_id] = session; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( | 150 WebContentDecryptionModuleSessionImpl* CdmSessionAdapter::GetSession( |
152 const std::string& web_session_id) { | 151 const std::string& web_session_id) { |
153 // Since session objects may get garbage collected, it is possible that there | 152 // Since session objects may get garbage collected, it is possible that there |
154 // are events coming back from the CDM and the session has been unregistered. | 153 // are events coming back from the CDM and the session has been unregistered. |
155 // We can not tell if the CDM is firing events at sessions that never existed. | 154 // We can not tell if the CDM is firing events at sessions that never existed. |
156 SessionMap::iterator session = sessions_.find(web_session_id); | 155 SessionMap::iterator session = sessions_.find(web_session_id); |
157 return (session != sessions_.end()) ? session->second.get() : NULL; | 156 return (session != sessions_.end()) ? session->second.get() : NULL; |
158 } | 157 } |
159 | 158 |
160 } // namespace content | 159 } // namespace content |
OLD | NEW |