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
3 // found in the LICENSE file.
5 #include "media/cdm/default_cdm_factory.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "media/base/key_systems.h"
13 #include "media/cdm/aes_decryptor.h"
18 DefaultCdmFactory::DefaultCdmFactory() {
21 DefaultCdmFactory::~DefaultCdmFactory() {
24 void DefaultCdmFactory::Create(
25 const std::string
& key_system
,
26 bool allow_distinctive_identifier
,
27 bool allow_persistent_state
,
28 const GURL
& security_origin
,
29 const SessionMessageCB
& session_message_cb
,
30 const SessionClosedCB
& session_closed_cb
,
31 const LegacySessionErrorCB
& legacy_session_error_cb
,
32 const SessionKeysChangeCB
& session_keys_change_cb
,
33 const SessionExpirationUpdateCB
& session_expiration_update_cb
,
34 const CdmCreatedCB
& cdm_created_cb
) {
35 if (!security_origin
.is_valid() || !CanUseAesDecryptor(key_system
)) {
36 base::ThreadTaskRunnerHandle::Get()->PostTask(
37 FROM_HERE
, base::Bind(cdm_created_cb
, nullptr));
41 scoped_ptr
<MediaKeys
> cdm(
42 new AesDecryptor(security_origin
, session_message_cb
, session_closed_cb
,
43 session_keys_change_cb
));
44 base::ThreadTaskRunnerHandle::Get()->PostTask(
45 FROM_HERE
, base::Bind(cdm_created_cb
, base::Passed(&cdm
)));