OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/mojo/services/mojo_cdm_service_context.h" | 5 #include "media/mojo/services/mojo_cdm_service_context.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 "media/mojo/services/mojo_cdm_service.h" |
9 | 10 |
10 namespace media { | 11 namespace media { |
11 | 12 |
12 MojoCdmServiceContext::MojoCdmServiceContext() { | 13 MojoCdmServiceContext::MojoCdmServiceContext() : weak_ptr_factory_(this) {} |
| 14 |
| 15 MojoCdmServiceContext::~MojoCdmServiceContext() { |
13 } | 16 } |
14 | 17 |
15 MojoCdmServiceContext::~MojoCdmServiceContext() { | 18 base::WeakPtr<MojoCdmServiceContext> MojoCdmServiceContext::GetWeakPtr() { |
| 19 return weak_ptr_factory_.GetWeakPtr(); |
16 } | 20 } |
17 | 21 |
18 void MojoCdmServiceContext::RegisterCdm(int cdm_id, | 22 void MojoCdmServiceContext::RegisterCdm(int cdm_id, |
19 MojoCdmService* cdm_service) { | 23 MojoCdmService* cdm_service) { |
20 DCHECK(!cdm_services_.count(cdm_id)); | 24 DCHECK(!cdm_services_.count(cdm_id)); |
21 DCHECK(cdm_service); | 25 DCHECK(cdm_service); |
22 cdm_services_[cdm_id] = cdm_service; | 26 cdm_services_[cdm_id] = cdm_service; |
23 } | 27 } |
24 | 28 |
25 void MojoCdmServiceContext::UnregisterCdm(int cdm_id) { | 29 void MojoCdmServiceContext::UnregisterCdm(int cdm_id) { |
26 DCHECK(cdm_services_.count(cdm_id)); | 30 DCHECK(cdm_services_.count(cdm_id)); |
27 cdm_services_.erase(cdm_id); | 31 cdm_services_.erase(cdm_id); |
28 } | 32 } |
29 | 33 |
30 CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) { | 34 CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) { |
31 auto cdm_service = cdm_services_.find(cdm_id); | 35 auto cdm_service = cdm_services_.find(cdm_id); |
32 if (cdm_service == cdm_services_.end()) { | 36 if (cdm_service == cdm_services_.end()) { |
33 LOG(ERROR) << "CDM context not found: " << cdm_id; | 37 LOG(ERROR) << "CDM context not found: " << cdm_id; |
34 return nullptr; | 38 return nullptr; |
35 } | 39 } |
36 | 40 |
37 return cdm_service->second->GetCdmContext(); | 41 return cdm_service->second->GetCdmContext(); |
38 } | 42 } |
39 | 43 |
40 } // namespace media | 44 } // namespace media |
OLD | NEW |