OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/mojo/services/mojo_cdm_service_context.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/logging.h" | |
9 | |
10 namespace media { | |
11 | |
12 MojoCdmServiceContext::MojoCdmServiceContext() { | |
13 } | |
14 | |
15 MojoCdmServiceContext::~MojoCdmServiceContext() { | |
16 } | |
17 | |
18 MojoCdmService* MojoCdmServiceContext::Create( | |
19 const mojo::String& key_system, | |
20 const mojo::String& security_origin, | |
21 int32_t cdm_id) { | |
22 DVLOG(1) << __FUNCTION__ << ": " << key_system; | |
23 | |
24 // TODO(xhwang): How to use |security_origin| here? | |
ddorwin
2015/05/15 19:10:07
It needs to be used for any persistence. Probably
xhwang
2015/06/01 21:21:25
Currently we are using WebEncryptedMediaClientImpl
| |
25 MojoCdmService* cdm_service = MojoCdmService::Create(this, key_system); | |
26 if (cdm_service) | |
27 services_.add(cdm_id, make_scoped_ptr(cdm_service)); | |
28 return cdm_service; | |
29 } | |
30 | |
31 CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) { | |
32 MojoCdmService* service = services_.get(cdm_id); | |
33 if (!service) { | |
34 LOG(ERROR) << "CDM context not found: " << cdm_id; | |
35 return nullptr; | |
36 } | |
37 | |
38 return service->GetCdmContext(); | |
39 } | |
40 | |
41 void MojoCdmServiceContext::ServiceHadConnectionError(MojoCdmService* service) { | |
42 for (auto it = services_.begin(); it != services_.end(); ++it) { | |
43 if (it->second == service) { | |
44 services_.erase(it); // This destroys the |service|. | |
45 return; | |
46 } | |
47 } | |
48 | |
49 NOTREACHED() << "Service " << service << " not found."; | |
50 } | |
51 | |
52 } // namespace media | |
OLD | NEW |