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

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

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 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_cdm.h ('k') | media/mojo/services/mojo_cdm_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/mojo/services/mojo_cdm.h" 5 #include "media/mojo/services/mojo_cdm.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "media/base/cdm_key_information.h" 9 #include "media/base/cdm_key_information.h"
10 #include "media/base/cdm_promise.h" 10 #include "media/base/cdm_promise.h"
11 #include "media/mojo/services/media_type_converters.h" 11 #include "media/mojo/services/media_type_converters.h"
12 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h" 12 #include "third_party/mojo/src/mojo/public/cpp/application/connect.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" 13 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
14 #include "third_party/mojo/src/mojo/public/interfaces/application/service_provid er.mojom.h" 14 #include "third_party/mojo/src/mojo/public/interfaces/application/service_provid er.mojom.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace media { 17 namespace media {
18 18
19 static mojo::Array<uint8_t> CreateMojoArray(const uint8_t* data, int length) {
20 DCHECK(data);
21 DCHECK_GT(length, 0);
22 std::vector<uint8_t> vector(data, data + length);
23 mojo::Array<uint8_t> array;
24 array.Swap(&vector);
25 return array.Pass();
26 }
27
28 template <typename PromiseType> 19 template <typename PromiseType>
29 static void RejectPromise(scoped_ptr<PromiseType> promise, 20 static void RejectPromise(scoped_ptr<PromiseType> promise,
30 mojo::CdmPromiseResultPtr result) { 21 mojo::CdmPromiseResultPtr result) {
31 promise->reject(static_cast<MediaKeys::Exception>(result->exception), 22 promise->reject(static_cast<MediaKeys::Exception>(result->exception),
32 result->system_code, result->error_message); 23 result->system_code, result->error_message);
33 } 24 }
34 25
35 MojoCdm::MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm, 26 MojoCdm::MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm,
36 const SessionMessageCB& session_message_cb, 27 const SessionMessageCB& session_message_cb,
37 const SessionClosedCB& session_closed_cb, 28 const SessionClosedCB& session_closed_cb,
(...skipping 17 matching lines...) Expand all
55 46
56 mojo::ContentDecryptionModuleClientPtr client_ptr; 47 mojo::ContentDecryptionModuleClientPtr client_ptr;
57 binding_.Bind(GetProxy(&client_ptr)); 48 binding_.Bind(GetProxy(&client_ptr));
58 remote_cdm_->SetClient(client_ptr.Pass()); 49 remote_cdm_->SetClient(client_ptr.Pass());
59 } 50 }
60 51
61 MojoCdm::~MojoCdm() { 52 MojoCdm::~MojoCdm() {
62 DVLOG(1) << __FUNCTION__; 53 DVLOG(1) << __FUNCTION__;
63 } 54 }
64 55
65 void MojoCdm::SetServerCertificate(const uint8_t* certificate_data, 56 void MojoCdm::SetServerCertificate(const std::vector<uint8_t>& certificate,
66 int certificate_data_length,
67 scoped_ptr<SimpleCdmPromise> promise) { 57 scoped_ptr<SimpleCdmPromise> promise) {
68 remote_cdm_->SetServerCertificate( 58 remote_cdm_->SetServerCertificate(
69 CreateMojoArray(certificate_data, certificate_data_length), 59 mojo::Array<uint8_t>::From(certificate),
70 base::Bind(&MojoCdm::OnPromiseResult<>, weak_factory_.GetWeakPtr(), 60 base::Bind(&MojoCdm::OnPromiseResult<>, weak_factory_.GetWeakPtr(),
71 base::Passed(&promise))); 61 base::Passed(&promise)));
72 } 62 }
73 63
74 void MojoCdm::CreateSessionAndGenerateRequest( 64 void MojoCdm::CreateSessionAndGenerateRequest(
75 SessionType session_type, 65 SessionType session_type,
76 EmeInitDataType init_data_type, 66 EmeInitDataType init_data_type,
77 const uint8_t* init_data, 67 const std::vector<uint8_t>& init_data,
78 int init_data_length,
79 scoped_ptr<NewSessionCdmPromise> promise) { 68 scoped_ptr<NewSessionCdmPromise> promise) {
80 remote_cdm_->CreateSessionAndGenerateRequest( 69 remote_cdm_->CreateSessionAndGenerateRequest(
81 static_cast<mojo::ContentDecryptionModule::SessionType>(session_type), 70 static_cast<mojo::ContentDecryptionModule::SessionType>(session_type),
82 static_cast<mojo::ContentDecryptionModule::InitDataType>(init_data_type), 71 static_cast<mojo::ContentDecryptionModule::InitDataType>(init_data_type),
83 CreateMojoArray(init_data, init_data_length), 72 mojo::Array<uint8_t>::From(init_data),
84 base::Bind(&MojoCdm::OnPromiseResult<std::string>, 73 base::Bind(&MojoCdm::OnPromiseResult<std::string>,
85 weak_factory_.GetWeakPtr(), base::Passed(&promise))); 74 weak_factory_.GetWeakPtr(), base::Passed(&promise)));
86 } 75 }
87 76
88 void MojoCdm::LoadSession(SessionType session_type, 77 void MojoCdm::LoadSession(SessionType session_type,
89 const std::string& session_id, 78 const std::string& session_id,
90 scoped_ptr<NewSessionCdmPromise> promise) { 79 scoped_ptr<NewSessionCdmPromise> promise) {
91 remote_cdm_->LoadSession( 80 remote_cdm_->LoadSession(
92 static_cast<mojo::ContentDecryptionModule::SessionType>(session_type), 81 static_cast<mojo::ContentDecryptionModule::SessionType>(session_type),
93 session_id, 82 session_id,
94 base::Bind(&MojoCdm::OnPromiseResult<std::string>, 83 base::Bind(&MojoCdm::OnPromiseResult<std::string>,
95 weak_factory_.GetWeakPtr(), base::Passed(&promise))); 84 weak_factory_.GetWeakPtr(), base::Passed(&promise)));
96 } 85 }
97 86
98 void MojoCdm::UpdateSession(const std::string& session_id, 87 void MojoCdm::UpdateSession(const std::string& session_id,
99 const uint8_t* response, 88 const std::vector<uint8_t>& response,
100 int response_length,
101 scoped_ptr<SimpleCdmPromise> promise) { 89 scoped_ptr<SimpleCdmPromise> promise) {
102 remote_cdm_->UpdateSession( 90 remote_cdm_->UpdateSession(
103 session_id, CreateMojoArray(response, response_length), 91 session_id, mojo::Array<uint8_t>::From(response),
104 base::Bind(&MojoCdm::OnPromiseResult<>, weak_factory_.GetWeakPtr(), 92 base::Bind(&MojoCdm::OnPromiseResult<>, weak_factory_.GetWeakPtr(),
105 base::Passed(&promise))); 93 base::Passed(&promise)));
106 } 94 }
107 95
108 void MojoCdm::CloseSession(const std::string& session_id, 96 void MojoCdm::CloseSession(const std::string& session_id,
109 scoped_ptr<SimpleCdmPromise> promise) { 97 scoped_ptr<SimpleCdmPromise> promise) {
110 remote_cdm_->CloseSession(session_id, base::Bind(&MojoCdm::OnPromiseResult<>, 98 remote_cdm_->CloseSession(session_id, base::Bind(&MojoCdm::OnPromiseResult<>,
111 weak_factory_.GetWeakPtr(), 99 weak_factory_.GetWeakPtr(),
112 base::Passed(&promise))); 100 base::Passed(&promise)));
113 } 101 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 key_data.Pass()); 155 key_data.Pass());
168 } 156 }
169 157
170 void MojoCdm::OnSessionExpirationUpdate(const mojo::String& session_id, 158 void MojoCdm::OnSessionExpirationUpdate(const mojo::String& session_id,
171 double new_expiry_time_sec) { 159 double new_expiry_time_sec) {
172 session_expiration_update_cb_.Run( 160 session_expiration_update_cb_.Run(
173 session_id, base::Time::FromDoubleT(new_expiry_time_sec)); 161 session_id, base::Time::FromDoubleT(new_expiry_time_sec));
174 } 162 }
175 163
176 } // namespace media 164 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm.h ('k') | media/mojo/services/mojo_cdm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698