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/blink/webcontentdecryptionmodulesession_impl.cc

Issue 1904253002: Convert //media/blink from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webcontentdecryptionmodulesession_impl.h" 5 #include "webcontentdecryptionmodulesession_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // (Done in constructor.) 293 // (Done in constructor.)
294 294
295 // 9.5 Let message be null. 295 // 9.5 Let message be null.
296 // (Done by CDM.) 296 // (Done by CDM.)
297 297
298 // 9.6 Let cdm be the CDM instance represented by this object's cdm 298 // 9.6 Let cdm be the CDM instance represented by this object's cdm
299 // instance value. 299 // instance value.
300 // 9.7 Use the cdm to execute the following steps: 300 // 9.7 Use the cdm to execute the following steps:
301 adapter_->InitializeNewSession( 301 adapter_->InitializeNewSession(
302 eme_init_data_type, sanitized_init_data, convertSessionType(session_type), 302 eme_init_data_type, sanitized_init_data, convertSessionType(session_type),
303 scoped_ptr<NewSessionCdmPromise>(new NewSessionCdmResultPromise( 303 std::unique_ptr<NewSessionCdmPromise>(new NewSessionCdmResultPromise(
304 result, adapter_->GetKeySystemUMAPrefix() + kGenerateRequestUMAName, 304 result, adapter_->GetKeySystemUMAPrefix() + kGenerateRequestUMAName,
305 base::Bind( 305 base::Bind(
306 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized, 306 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized,
307 weak_ptr_factory_.GetWeakPtr())))); 307 weak_ptr_factory_.GetWeakPtr()))));
308 } 308 }
309 309
310 void WebContentDecryptionModuleSessionImpl::load( 310 void WebContentDecryptionModuleSessionImpl::load(
311 const blink::WebString& session_id, 311 const blink::WebString& session_id,
312 blink::WebContentDecryptionModuleResult result) { 312 blink::WebContentDecryptionModuleResult result) {
313 DCHECK(!session_id.isEmpty()); 313 DCHECK(!session_id.isEmpty());
314 DCHECK(session_id_.empty()); 314 DCHECK(session_id_.empty());
315 DCHECK(thread_checker_.CalledOnValidThread()); 315 DCHECK(thread_checker_.CalledOnValidThread());
316 316
317 std::string sanitized_session_id; 317 std::string sanitized_session_id;
318 if (!SanitizeSessionId(session_id, &sanitized_session_id)) { 318 if (!SanitizeSessionId(session_id, &sanitized_session_id)) {
319 result.completeWithError( 319 result.completeWithError(
320 blink::WebContentDecryptionModuleExceptionInvalidAccessError, 0, 320 blink::WebContentDecryptionModuleExceptionInvalidAccessError, 0,
321 "Invalid session ID."); 321 "Invalid session ID.");
322 return; 322 return;
323 } 323 }
324 324
325 // TODO(jrummell): Now that there are 2 types of persistent sessions, the 325 // TODO(jrummell): Now that there are 2 types of persistent sessions, the
326 // session type should be passed from blink. Type should also be passed in the 326 // session type should be passed from blink. Type should also be passed in the
327 // constructor (and removed from initializeNewSession()). 327 // constructor (and removed from initializeNewSession()).
328 adapter_->LoadSession( 328 adapter_->LoadSession(
329 MediaKeys::PERSISTENT_LICENSE_SESSION, sanitized_session_id, 329 MediaKeys::PERSISTENT_LICENSE_SESSION, sanitized_session_id,
330 scoped_ptr<NewSessionCdmPromise>(new NewSessionCdmResultPromise( 330 std::unique_ptr<NewSessionCdmPromise>(new NewSessionCdmResultPromise(
331 result, adapter_->GetKeySystemUMAPrefix() + kLoadSessionUMAName, 331 result, adapter_->GetKeySystemUMAPrefix() + kLoadSessionUMAName,
332 base::Bind( 332 base::Bind(
333 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized, 333 &WebContentDecryptionModuleSessionImpl::OnSessionInitialized,
334 weak_ptr_factory_.GetWeakPtr())))); 334 weak_ptr_factory_.GetWeakPtr()))));
335 } 335 }
336 336
337 void WebContentDecryptionModuleSessionImpl::update( 337 void WebContentDecryptionModuleSessionImpl::update(
338 const uint8_t* response, 338 const uint8_t* response,
339 size_t response_length, 339 size_t response_length,
340 blink::WebContentDecryptionModuleResult result) { 340 blink::WebContentDecryptionModuleResult result) {
341 DCHECK(response); 341 DCHECK(response);
342 DCHECK(!session_id_.empty()); 342 DCHECK(!session_id_.empty());
343 DCHECK(thread_checker_.CalledOnValidThread()); 343 DCHECK(thread_checker_.CalledOnValidThread());
344 344
345 std::vector<uint8_t> sanitized_response; 345 std::vector<uint8_t> sanitized_response;
346 if (!SanitizeResponse(adapter_->GetKeySystem(), response, response_length, 346 if (!SanitizeResponse(adapter_->GetKeySystem(), response, response_length,
347 &sanitized_response)) { 347 &sanitized_response)) {
348 result.completeWithError( 348 result.completeWithError(
349 blink::WebContentDecryptionModuleExceptionInvalidAccessError, 0, 349 blink::WebContentDecryptionModuleExceptionInvalidAccessError, 0,
350 "Invalid response."); 350 "Invalid response.");
351 return; 351 return;
352 } 352 }
353 353
354 adapter_->UpdateSession( 354 adapter_->UpdateSession(
355 session_id_, sanitized_response, 355 session_id_, sanitized_response,
356 scoped_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 356 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
357 result, adapter_->GetKeySystemUMAPrefix() + kUpdateSessionUMAName))); 357 result, adapter_->GetKeySystemUMAPrefix() + kUpdateSessionUMAName)));
358 } 358 }
359 359
360 void WebContentDecryptionModuleSessionImpl::close( 360 void WebContentDecryptionModuleSessionImpl::close(
361 blink::WebContentDecryptionModuleResult result) { 361 blink::WebContentDecryptionModuleResult result) {
362 DCHECK(!session_id_.empty()); 362 DCHECK(!session_id_.empty());
363 DCHECK(thread_checker_.CalledOnValidThread()); 363 DCHECK(thread_checker_.CalledOnValidThread());
364 adapter_->CloseSession( 364 adapter_->CloseSession(
365 session_id_, 365 session_id_,
366 scoped_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 366 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
367 result, adapter_->GetKeySystemUMAPrefix() + kCloseSessionUMAName))); 367 result, adapter_->GetKeySystemUMAPrefix() + kCloseSessionUMAName)));
368 } 368 }
369 369
370 void WebContentDecryptionModuleSessionImpl::remove( 370 void WebContentDecryptionModuleSessionImpl::remove(
371 blink::WebContentDecryptionModuleResult result) { 371 blink::WebContentDecryptionModuleResult result) {
372 DCHECK(!session_id_.empty()); 372 DCHECK(!session_id_.empty());
373 DCHECK(thread_checker_.CalledOnValidThread()); 373 DCHECK(thread_checker_.CalledOnValidThread());
374 adapter_->RemoveSession( 374 adapter_->RemoveSession(
375 session_id_, 375 session_id_,
376 scoped_ptr<SimpleCdmPromise>(new CdmResultPromise<>( 376 std::unique_ptr<SimpleCdmPromise>(new CdmResultPromise<>(
377 result, adapter_->GetKeySystemUMAPrefix() + kRemoveSessionUMAName))); 377 result, adapter_->GetKeySystemUMAPrefix() + kRemoveSessionUMAName)));
378 } 378 }
379 379
380 void WebContentDecryptionModuleSessionImpl::OnSessionMessage( 380 void WebContentDecryptionModuleSessionImpl::OnSessionMessage(
381 MediaKeys::MessageType message_type, 381 MediaKeys::MessageType message_type,
382 const std::vector<uint8_t>& message) { 382 const std::vector<uint8_t>& message) {
383 DCHECK(client_) << "Client not set before message event"; 383 DCHECK(client_) << "Client not set before message event";
384 DCHECK(thread_checker_.CalledOnValidThread()); 384 DCHECK(thread_checker_.CalledOnValidThread());
385 client_->message(convertMessageType(message_type), message.data(), 385 client_->message(convertMessageType(message_type), message.data(),
386 message.size()); 386 message.size());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; 432 DCHECK(session_id_.empty()) << "Session ID may not be changed once set.";
433 session_id_ = session_id; 433 session_id_ = session_id;
434 *status = 434 *status =
435 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) 435 adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr())
436 ? SessionInitStatus::NEW_SESSION 436 ? SessionInitStatus::NEW_SESSION
437 : SessionInitStatus::SESSION_ALREADY_EXISTS; 437 : SessionInitStatus::SESSION_ALREADY_EXISTS;
438 } 438 }
439 439
440 } // namespace media 440 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webcontentdecryptionmoduleaccess_impl.cc ('k') | media/blink/webencryptedmediaclient_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698