Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1331)

Unified Diff: media/mojo/services/mojo_cdm_service_context.cc

Issue 1165633004: media: Add MojoCdmServiceContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ddcf62cd4acf69532388bd24068168b8fb843c59
--- /dev/null
+++ b/media/mojo/services/mojo_cdm_service_context.cc
@@ -0,0 +1,53 @@
+// Copyright 2015 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() {
+}
+
+void MojoCdmServiceContext::CreateCdmService(
+ const mojo::String& key_system,
+ const mojo::String& security_origin,
+ int32_t cdm_id,
+ mojo::InterfaceRequest<mojo::ContentDecryptionModule> request) {
+ DVLOG(1) << __FUNCTION__ << ": " << key_system;
+
+ // TODO(xhwang): pass |security_origin| down because CdmFactory needs it.
+ scopted_ptr<MojoCdmService> cdm_service =
+ MojoCdmService::Create(key_system, this, request.Pass());
+ if (cdm_service)
+ services_.add(cdm_id, cdm_service.Pass());
+}
+
+CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) {
+ MojoCdmService* service = services_.get(cdm_id);
+ if (!service) {
+ LOG(ERROR) << "CDM context not found: " << cdm_id;
+ return nullptr;
+ }
+
+ return service->GetCdmContext();
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698