Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "base/bind.h" | |
| 8 #include "base/bind_helpers.h" | |
| 9 | |
| 10 namespace media { | |
| 11 | |
| 12 MojoMediaDrmStorage::MojoMediaDrmStorage( | |
| 13 mojom::MediaDrmStoragePtr media_drm_storage_ptr) | |
| 14 : media_drm_storage_ptr_(std::move(media_drm_storage_ptr)), | |
| 15 weak_factory_(this) { | |
| 16 DVLOG(1) << __func__; | |
| 17 } | |
| 18 | |
| 19 MojoMediaDrmStorage::~MojoMediaDrmStorage() {} | |
| 20 | |
| 21 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
| |
| 22 DVLOG(1) << __func__; | |
| 23 media_drm_storage_ptr_->Initialize(origin); | |
| 24 } | |
| 25 | |
| 26 void MojoMediaDrmStorage::OnProvisioned(ResultCB result_cb) { | |
| 27 DVLOG(1) << __func__; | |
| 28 media_drm_storage_ptr_->OnProvisioned( | |
| 29 base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(), | |
| 30 base::Passed(&result_cb))); | |
| 31 } | |
| 32 | |
| 33 void MojoMediaDrmStorage::SavePersistentSession( | |
| 34 const std::string& session_id, | |
| 35 const std::vector<uint8_t>& key_set_id, | |
| 36 const std::string& mime_type, | |
| 37 ResultCB result_cb) { | |
| 38 DVLOG(1) << __func__; | |
| 39 media_drm_storage_ptr_->SavePersistentSession( | |
| 40 session_id, key_set_id, mime_type, | |
| 41 base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(), | |
| 42 base::Passed(&result_cb))); | |
| 43 } | |
| 44 | |
| 45 void MojoMediaDrmStorage::LoadPersistentSession( | |
| 46 const std::string& session_id, | |
| 47 LoadPersistentSessionCB load_persistent_session_cb) { | |
| 48 DVLOG(1) << __func__; | |
| 49 media_drm_storage_ptr_->LoadPersistentSession( | |
| 50 session_id, base::Bind(&MojoMediaDrmStorage::OnPersistentSessionLoaded, | |
| 51 weak_factory_.GetWeakPtr(), | |
| 52 base::Passed(&load_persistent_session_cb))); | |
| 53 } | |
| 54 | |
| 55 void MojoMediaDrmStorage::RemovePersistentSession(const std::string& session_id, | |
| 56 ResultCB result_cb) { | |
| 57 DVLOG(1) << __func__; | |
| 58 media_drm_storage_ptr_->RemovePersistentSession( | |
| 59 session_id, | |
| 60 base::Bind(&MojoMediaDrmStorage::OnResult, weak_factory_.GetWeakPtr(), | |
| 61 base::Passed(&result_cb))); | |
| 62 } | |
| 63 | |
| 64 void MojoMediaDrmStorage::OnResult(ResultCB result_cb, bool success) { | |
| 65 DVLOG(1) << __func__ << ": success = " << success; | |
| 66 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
| |
| 67 } | |
| 68 | |
| 69 void MojoMediaDrmStorage::OnPersistentSessionLoaded( | |
| 70 LoadPersistentSessionCB load_persistent_session_cb, | |
| 71 bool success, | |
| 72 const std::vector<uint8_t>& key_set_id, | |
| 73 const std::string& mime_type) { | |
| 74 DVLOG(1) << __func__ << ": success = " << success; | |
| 75 DCHECK_EQ(success, !key_set_id.empty()); | |
| 76 DCHECK_EQ(success, !mime_type.empty()); | |
| 77 | |
| 78 std::move(load_persistent_session_cb).Run(success, key_set_id, mime_type); | |
|
dcheng
2017/03/29 01:17:23
#include <utility>
| |
| 79 } | |
| 80 | |
| 81 } // namespace media | |
| OLD | NEW |