Chromium Code Reviews| 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..accb316293debcc1896f370db02ecb20b4372d2c |
| --- /dev/null |
| +++ b/media/mojo/services/mojo_media_drm_storage.cc |
| @@ -0,0 +1,81 @@ |
| +// 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 "base/bind.h" |
| +#include "base/bind_helpers.h" |
| + |
| +namespace media { |
| + |
| +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) { |
|
yucliu1
2017/03/28 18:10:20
I think all of the MediaDrm codes are using GURL a
xhwang
2017/03/28 20:57:09
We have a bug to replace GURL with url::Origin:
ht
|
| + 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 std::vector<uint8_t>& key_set_id, |
| + const std::string& mime_type, |
| + ResultCB result_cb) { |
| + DVLOG(1) << __func__; |
| + media_drm_storage_ptr_->SavePersistentSession( |
| + session_id, key_set_id, 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); |
|
yucliu1
2017/03/28 18:10:20
Just curious, what's the benefit for std::move her
xhwang
2017/03/28 20:57:08
It's a OnceCallback, you have to "move" it before
|
| +} |
| + |
| +void MojoMediaDrmStorage::OnPersistentSessionLoaded( |
| + LoadPersistentSessionCB load_persistent_session_cb, |
| + bool success, |
| + const std::vector<uint8_t>& key_set_id, |
| + const std::string& mime_type) { |
| + DVLOG(1) << __func__ << ": success = " << success; |
| + DCHECK_EQ(success, !key_set_id.empty()); |
| + DCHECK_EQ(success, !mime_type.empty()); |
| + |
| + std::move(load_persistent_session_cb).Run(success, key_set_id, mime_type); |
|
dcheng
2017/03/29 01:17:23
#include <utility>
|
| +} |
| + |
| +} // namespace media |