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
3 // found in the LICENSE file.
5 #include "media/mojo/services/mojo_cdm_service_context.h"
8 #include "base/logging.h"
9 #include "media/mojo/services/mojo_cdm_service.h"
13 MojoCdmServiceContext::MojoCdmServiceContext() : weak_ptr_factory_(this) {}
15 MojoCdmServiceContext::~MojoCdmServiceContext() {
18 base::WeakPtr
<MojoCdmServiceContext
> MojoCdmServiceContext::GetWeakPtr() {
19 return weak_ptr_factory_
.GetWeakPtr();
22 void MojoCdmServiceContext::RegisterCdm(int cdm_id
,
23 MojoCdmService
* cdm_service
) {
24 DCHECK(!cdm_services_
.count(cdm_id
));
26 cdm_services_
[cdm_id
] = cdm_service
;
29 void MojoCdmServiceContext::UnregisterCdm(int cdm_id
) {
30 DCHECK(cdm_services_
.count(cdm_id
));
31 cdm_services_
.erase(cdm_id
);
34 CdmContext
* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id
) {
35 auto cdm_service
= cdm_services_
.find(cdm_id
);
36 if (cdm_service
== cdm_services_
.end()) {
37 LOG(ERROR
) << "CDM context not found: " << cdm_id
;
41 return cdm_service
->second
->GetCdmContext();