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

Side by Side Diff: media/base/mock_filters.cc

Issue 2592913002: [eme] Break mojo connection during call (Closed)
Patch Set: changes Created 3 years, 11 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/base/mock_filters.h ('k') | media/mojo/clients/mojo_cdm.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/mock_filters.h" 5 #include "media/base/mock_filters.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 using ::testing::_; 9 using ::testing::_;
10 using ::testing::Return; 10 using ::testing::Return;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 EXPECT_CALL(*this, resolve(_)).Times(0); 173 EXPECT_CALL(*this, resolve(_)).Times(0);
174 EXPECT_CALL(*this, reject(_, _, NotEmpty())); 174 EXPECT_CALL(*this, reject(_, _, NotEmpty()));
175 } 175 }
176 } 176 }
177 177
178 MockCdmSessionPromise::~MockCdmSessionPromise() { 178 MockCdmSessionPromise::~MockCdmSessionPromise() {
179 // The EXPECT calls will verify that the promise is in fact fulfilled. 179 // The EXPECT calls will verify that the promise is in fact fulfilled.
180 MarkPromiseSettled(); 180 MarkPromiseSettled();
181 } 181 }
182 182
183 MockCdm::MockCdm() {}
184
185 MockCdm::~MockCdm() {}
186
187 void MockCdm::SetServerCertificate(const std::vector<uint8_t>& certificate,
188 std::unique_ptr<SimpleCdmPromise> promise) {
189 OnSetServerCertificate(certificate, promise);
190 }
191
192 void MockCdm::CreateSessionAndGenerateRequest(
193 CdmSessionType session_type,
194 EmeInitDataType init_data_type,
195 const std::vector<uint8_t>& init_data,
196 std::unique_ptr<NewSessionCdmPromise> promise) {
197 OnCreateSessionAndGenerateRequest(session_type, init_data_type, init_data,
198 promise);
199 }
200
201 void MockCdm::LoadSession(CdmSessionType session_type,
202 const std::string& session_id,
203 std::unique_ptr<NewSessionCdmPromise> promise) {
204 OnLoadSession(session_type, session_id, promise);
205 }
206
207 void MockCdm::UpdateSession(const std::string& session_id,
208 const std::vector<uint8_t>& response,
209 std::unique_ptr<SimpleCdmPromise> promise) {
210 OnUpdateSession(session_id, response, promise);
211 }
212
213 void MockCdm::CloseSession(const std::string& session_id,
214 std::unique_ptr<SimpleCdmPromise> promise) {
215 OnCloseSession(session_id, promise);
216 }
217
218 void MockCdm::RemoveSession(const std::string& session_id,
219 std::unique_ptr<SimpleCdmPromise> promise) {
220 OnRemoveSession(session_id, promise);
221 }
222
223 void MockCdm::SetCallbacks(
224 const SessionMessageCB& session_message_cb,
225 const SessionClosedCB& session_closed_cb,
226 const SessionKeysChangeCB& session_keys_change_cb,
227 const SessionExpirationUpdateCB& session_expiration_update_cb) {
228 session_message_cb_ = session_message_cb;
229 session_closed_cb_ = session_closed_cb;
230 session_keys_change_cb_ = session_keys_change_cb;
231 session_expiration_update_cb_ = session_expiration_update_cb;
232 }
233
234 void MockCdm::CallSessionMessageCB(
235 const std::string& session_id,
236 ContentDecryptionModule::MessageType message_type,
237 const std::vector<uint8_t>& message) {
238 session_message_cb_.Run(session_id, message_type, message);
239 }
240
241 void MockCdm::CallSessionClosedCB(const std::string& session_id) {
242 session_closed_cb_.Run(session_id);
243 }
244
245 void MockCdm::CallSessionKeysChangeCB(const std::string& session_id,
246 bool has_additional_usable_key,
247 CdmKeysInfo keys_info) {
248 session_keys_change_cb_.Run(session_id, has_additional_usable_key,
249 std::move(keys_info));
250 }
251
252 void MockCdm::CallSessionExpirationUpdateCB(const std::string& session_id,
253 base::Time new_expiry_time) {
254 session_expiration_update_cb_.Run(session_id, new_expiry_time);
255 }
256
257 MockCdmFactory::MockCdmFactory() {}
258
259 MockCdmFactory::~MockCdmFactory() {}
260
261 void MockCdmFactory::Create(
262 const std::string& key_system,
263 const GURL& security_origin,
264 const CdmConfig& cdm_config,
265 const SessionMessageCB& session_message_cb,
266 const SessionClosedCB& session_closed_cb,
267 const SessionKeysChangeCB& session_keys_change_cb,
268 const SessionExpirationUpdateCB& session_expiration_update_cb,
269 const CdmCreatedCB& cdm_created_cb) {
270 // If no CDM provided, notify that Create() failed.
271 if (!cdm_) {
272 cdm_created_cb.Run(nullptr, "CDM creation failed");
273 return;
274 }
275
276 // Since there is a CDM, call |before_creation_cb_| first.
277 if (!before_creation_cb_.is_null())
278 before_creation_cb_.Run();
279
280 // Update the callbacks on the MockCDM, and then return it.
281 cdm_->SetCallbacks(session_message_cb, session_closed_cb,
282 session_keys_change_cb, session_expiration_update_cb);
xhwang 2017/01/06 06:21:36 Can we create the CDM within this factory so that
jrummell 2017/01/06 18:59:28 Done.
283 cdm_created_cb.Run(std::move(cdm_), "");
284 }
285
286 void MockCdmFactory::Initialize(const scoped_refptr<MockCdm>& cdm,
287 const base::Closure& before_creation_cb) {
288 cdm_ = cdm;
289 before_creation_cb_ = before_creation_cb;
xhwang 2017/01/06 06:21:36 If we create the CDM within this factory, we don't
jrummell 2017/01/06 18:59:28 Done.
290 }
291
183 MockStreamParser::MockStreamParser() {} 292 MockStreamParser::MockStreamParser() {}
184 293
185 MockStreamParser::~MockStreamParser() {} 294 MockStreamParser::~MockStreamParser() {}
186 295
187 } // namespace media 296 } // namespace media
OLDNEW
« no previous file with comments | « media/base/mock_filters.h ('k') | media/mojo/clients/mojo_cdm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698