Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
ddorwin
2015/06/08 18:33:10
nit: year is inconsistent with .h. Is that correct
xhwang
2015/06/08 22:12:33
Done.
| |
| 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 mojo::InterfaceRequest<mojo::ContentDecryptionModule> request) { | |
| 23 DVLOG(1) << __FUNCTION__ << ": " << key_system; | |
| 24 | |
| 25 // TODO(xhwang): pass |security_origin| down because CdmFactory needs it. | |
| 26 MojoCdmService* cdm_service = | |
| 27 MojoCdmService::Create(this, key_system, request.Pass()); | |
|
ddorwin
2015/06/08 18:33:10
Should this function be returning a scoped_ptr?
xhwang
2015/06/08 22:12:33
Done.
| |
| 28 if (cdm_service) | |
| 29 services_.add(cdm_id, make_scoped_ptr(cdm_service)); | |
| 30 return cdm_service; | |
| 31 } | |
| 32 | |
| 33 // TODO(xhwang): The returned CdmContext can be destroyed at any time if the | |
|
ddorwin
2015/06/08 18:33:10
This seems worse than what is implied by the comme
xhwang
2015/06/08 22:12:33
Done.
| |
| 34 // pipe is disconnected. When implementing SetCdm(), make sure we never | |
| 35 // dereference garbage. For example, use media::PlayerTracker. | |
| 36 CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) { | |
| 37 MojoCdmService* service = services_.get(cdm_id); | |
| 38 if (!service) { | |
| 39 LOG(ERROR) << "CDM context not found: " << cdm_id; | |
| 40 return nullptr; | |
| 41 } | |
| 42 | |
| 43 return service->GetCdmContext(); | |
| 44 } | |
| 45 | |
| 46 void MojoCdmServiceContext::ServiceHadConnectionError(MojoCdmService* service) { | |
| 47 for (auto it = services_.begin(); it != services_.end(); ++it) { | |
| 48 if (it->second == service) { | |
| 49 services_.erase(it); // This destroys the |service|. | |
| 50 return; | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 NOTREACHED() << "Service " << service << " not found."; | |
| 55 } | |
| 56 | |
| 57 } // namespace media | |
| OLD | NEW |