| Index: media/mojo/services/mojo_cdm_service_context.cc
|
| diff --git a/media/mojo/services/mojo_cdm_service_context.cc b/media/mojo/services/mojo_cdm_service_context.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e9b3a53e5edb22d9c8f040324989c888934dd225
|
| --- /dev/null
|
| +++ b/media/mojo/services/mojo_cdm_service_context.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "media/mojo/services/mojo_cdm_service_context.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/logging.h"
|
| +
|
| +namespace media {
|
| +
|
| +MojoCdmServiceContext::MojoCdmServiceContext() {
|
| +}
|
| +
|
| +MojoCdmServiceContext::~MojoCdmServiceContext() {
|
| +}
|
| +
|
| +MojoCdmService* MojoCdmServiceContext::Create(
|
| + const mojo::String& key_system,
|
| + const mojo::String& security_origin,
|
| + int32_t cdm_id) {
|
| + DVLOG(1) << __FUNCTION__ << ": " << key_system;
|
| + // TODO(xhwang): How to use |security_origin| here?
|
| + MojoCdmService* cdm_service = MojoCdmService::Create(this, key_system);
|
| + if (cdm_service)
|
| + services_.add(cdm_id, make_scoped_ptr(cdm_service));
|
| + return cdm_service;
|
| +}
|
| +
|
| +CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) {
|
| + MojoCdmService* service = services_.get(cdm_id);
|
| + return service ? service->GetCdmContext() : nullptr;
|
| +}
|
| +
|
| +void MojoCdmServiceContext::ServiceHadConnectionError(MojoCdmService* service) {
|
| + for (auto it = services_.begin(); it != services_.end(); ++it) {
|
| + if (it->second == service) {
|
| + services_.erase(it); // This destroys the |service|.
|
| + return;
|
| + }
|
| + }
|
| +
|
| + NOTREACHED() << "Service " << service << " not found.";
|
| +}
|
| +
|
| +} // namespace media
|
|
|