This sets up API to release OutputSurface from LTHClient.
[chromium-blink-merge.git] / media / mojo / services / mojo_cdm_service_context.cc
blob297d5831af29a97b0bbc1f05acaee98d23fb1c2e
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"
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "media/mojo/services/mojo_cdm_service.h"
11 namespace media {
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));
25 DCHECK(cdm_service);
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;
38 return nullptr;
41 return cdm_service->second->GetCdmContext();
44 } // namespace media