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

Side by Side Diff: media/mojo/services/mojo_media_drm_storage.cc

Issue 2765343003: media: Add MediaDrmStorage (Closed)
Patch Set: rebase only Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « media/mojo/services/mojo_media_drm_storage.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
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_media_drm_storage.h"
6
7 #include <utility>
8
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11
12 namespace media {
13
14 // TODO(xhwang): When connection error happens, callbacks might be dropped and
15 // never run. Handle connection error to make sure callbacks will always run.
16
17 MojoMediaDrmStorage::MojoMediaDrmStorage(
18 mojom::MediaDrmStoragePtr media_drm_storage_ptr)
19 : media_drm_storage_ptr_(std::move(media_drm_storage_ptr)),
20 weak_factory_(this) {
21 DVLOG(1) << __func__;
22 }
23
24 MojoMediaDrmStorage::~MojoMediaDrmStorage() {}
25
26 void MojoMediaDrmStorage::Initialize(const url::Origin& origin) {
27 DVLOG(1) << __func__;
28 media_drm_storage_ptr_->Initialize(origin);
29 }
30
31 void MojoMediaDrmStorage::OnProvisioned(ResultCB result_cb) {
32 DVLOG(1) << __func__;
33 media_drm_storage_ptr_->OnProvisioned(
34 base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(),
35 base::Passed(&result_cb)));
36 }
37
38 void MojoMediaDrmStorage::SavePersistentSession(const std::string& session_id,
39 const SessionData& session_data,
40 ResultCB result_cb) {
41 DVLOG(1) << __func__;
42 media_drm_storage_ptr_->SavePersistentSession(
43 session_id,
44 mojom::SessionData::New(session_data.key_set_id, session_data.mime_type),
45 base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(),
46 base::Passed(&result_cb)));
47 }
48
49 void MojoMediaDrmStorage::LoadPersistentSession(
50 const std::string& session_id,
51 LoadPersistentSessionCB load_persistent_session_cb) {
52 DVLOG(1) << __func__;
53 media_drm_storage_ptr_->LoadPersistentSession(
54 session_id, base::Bind(&MojoMediaDrmStorage::OnPersistentSessionLoaded,
55 weak_factory_.GetWeakPtr(),
56 base::Passed(&load_persistent_session_cb)));
57 }
58
59 void MojoMediaDrmStorage::RemovePersistentSession(const std::string& session_id,
60 ResultCB result_cb) {
61 DVLOG(1) << __func__;
62 media_drm_storage_ptr_->RemovePersistentSession(
63 session_id,
64 base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(),
65 base::Passed(&result_cb)));
66 }
67
68 void MojoMediaDrmStorage::OnResult(ResultCB result_cb, bool success) {
69 DVLOG(1) << __func__ << ": success = " << success;
70 std::move(result_cb).Run(success);
71 }
72
73 void MojoMediaDrmStorage::OnPersistentSessionLoaded(
74 LoadPersistentSessionCB load_persistent_session_cb,
75 mojom::SessionDataPtr session_data) {
76 DVLOG(1) << __func__ << ": success = " << !!session_data;
77
78 std::move(load_persistent_session_cb)
79 .Run(session_data ? base::MakeUnique<SessionData>(
80 std::move(session_data->key_set_id),
81 std::move(session_data->mime_type))
82 : nullptr);
83 }
84
85 } // namespace media
OLDNEW
« 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