Index: media/mojo/services/mojo_cdm_factory.cc |
diff --git a/media/mojo/services/mojo_cdm_factory.cc b/media/mojo/services/mojo_cdm_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..39ec19cd271b549bb2592c6df082bfa09e7cd789 |
--- /dev/null |
+++ b/media/mojo/services/mojo_cdm_factory.cc |
@@ -0,0 +1,50 @@ |
+// 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_factory.h" |
+ |
+#include "media/mojo/services/mojo_cdm.h" |
+ |
+namespace media { |
+ |
+int MojoCdmFactory::next_cdm_id_ = MojoCdm::kInvalidCdmId + 1; |
ddorwin
2015/05/15 19:10:07
This somewhat assumes that the Invalid value is a
|
+ |
+MojoCdmFactory::MojoCdmFactory( |
+ mojo::ContentDecryptionModuleFactoryPtr remote_factory) |
+ : remote_factory_(remote_factory.Pass()) { |
+ DCHECK(remote_factory_); |
+} |
+ |
+MojoCdmFactory::~MojoCdmFactory() { |
+} |
+ |
+// TODO(xhwang): Pass |allow_distinctive_identifier| and |
+// |allow_persistent_state| down to the remote CDM. |
+scoped_ptr<MediaKeys> MojoCdmFactory::Create( |
+ const std::string& key_system, |
+ bool /* allow_distinctive_identifier */, |
+ bool /* allow_persistent_state */, |
+ const GURL& security_origin, |
+ const SessionMessageCB& session_message_cb, |
+ const SessionClosedCB& session_closed_cb, |
+ const SessionErrorCB& session_error_cb, |
+ const SessionKeysChangeCB& session_keys_change_cb, |
+ const SessionExpirationUpdateCB& session_expiration_update_cb) { |
+ DVLOG(2) << __FUNCTION__ << ": " << key_system; |
+ |
+ int32_t cdm_id = next_cdm_id_++; |
+ mojo::ContentDecryptionModulePtr cdm_service; |
+ |
+ remote_factory_->Create(key_system, security_origin.spec(), cdm_id, |
+ GetProxy(&cdm_service)); |
+ |
+ // TODO(xhwang): Handle CDM creation failure more gracefully when we switch to |
+ // asynchronous creation. See http://crbug.com/469003 |
+ |
+ return make_scoped_ptr(new MojoCdm( |
+ cdm_service.Pass(), cdm_id, session_message_cb, session_closed_cb, |
+ session_error_cb, session_keys_change_cb, session_expiration_update_cb)); |
+} |
+ |
+} // namespace media |