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

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

Issue 2765343003: media: Add MediaDrmStorage (Closed)
Patch Set: rebase only Created 3 years, 9 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
« no previous file with comments | « media/mojo/services/mojo_media_drm_storage.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/services/mojo_media_drm_storage.cc
diff --git a/media/mojo/services/mojo_media_drm_storage.cc b/media/mojo/services/mojo_media_drm_storage.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f7dd3e194e081397c23c9383bc09d6b6ae9d2783
--- /dev/null
+++ b/media/mojo/services/mojo_media_drm_storage.cc
@@ -0,0 +1,85 @@
+// Copyright 2017 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_media_drm_storage.h"
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+
+namespace media {
+
+// TODO(xhwang): When connection error happens, callbacks might be dropped and
+// never run. Handle connection error to make sure callbacks will always run.
+
+MojoMediaDrmStorage::MojoMediaDrmStorage(
+ mojom::MediaDrmStoragePtr media_drm_storage_ptr)
+ : media_drm_storage_ptr_(std::move(media_drm_storage_ptr)),
+ weak_factory_(this) {
+ DVLOG(1) << __func__;
+}
+
+MojoMediaDrmStorage::~MojoMediaDrmStorage() {}
+
+void MojoMediaDrmStorage::Initialize(const url::Origin& origin) {
+ DVLOG(1) << __func__;
+ media_drm_storage_ptr_->Initialize(origin);
+}
+
+void MojoMediaDrmStorage::OnProvisioned(ResultCB result_cb) {
+ DVLOG(1) << __func__;
+ media_drm_storage_ptr_->OnProvisioned(
+ base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(),
+ base::Passed(&result_cb)));
+}
+
+void MojoMediaDrmStorage::SavePersistentSession(const std::string& session_id,
+ const SessionData& session_data,
+ ResultCB result_cb) {
+ DVLOG(1) << __func__;
+ media_drm_storage_ptr_->SavePersistentSession(
+ session_id,
+ mojom::SessionData::New(session_data.key_set_id, session_data.mime_type),
+ base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(),
+ base::Passed(&result_cb)));
+}
+
+void MojoMediaDrmStorage::LoadPersistentSession(
+ const std::string& session_id,
+ LoadPersistentSessionCB load_persistent_session_cb) {
+ DVLOG(1) << __func__;
+ media_drm_storage_ptr_->LoadPersistentSession(
+ session_id, base::Bind(&MojoMediaDrmStorage::OnPersistentSessionLoaded,
+ weak_factory_.GetWeakPtr(),
+ base::Passed(&load_persistent_session_cb)));
+}
+
+void MojoMediaDrmStorage::RemovePersistentSession(const std::string& session_id,
+ ResultCB result_cb) {
+ DVLOG(1) << __func__;
+ media_drm_storage_ptr_->RemovePersistentSession(
+ session_id,
+ base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(),
+ base::Passed(&result_cb)));
+}
+
+void MojoMediaDrmStorage::OnResult(ResultCB result_cb, bool success) {
+ DVLOG(1) << __func__ << ": success = " << success;
+ std::move(result_cb).Run(success);
+}
+
+void MojoMediaDrmStorage::OnPersistentSessionLoaded(
+ LoadPersistentSessionCB load_persistent_session_cb,
+ mojom::SessionDataPtr session_data) {
+ DVLOG(1) << __func__ << ": success = " << !!session_data;
+
+ std::move(load_persistent_session_cb)
+ .Run(session_data ? base::MakeUnique<SessionData>(
+ std::move(session_data->key_set_id),
+ std::move(session_data->mime_type))
+ : nullptr);
+}
+
+} // namespace media
« no previous file with comments | « media/mojo/services/mojo_media_drm_storage.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698