cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / media / cdm / default_cdm_factory.cc
blobc025fe982db83ee919a8d57b6bad1c923666d5a5
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"
7 #include "base/bind.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"
14 #include "url/gurl.h"
16 namespace media {
18 DefaultCdmFactory::DefaultCdmFactory() {
21 DefaultCdmFactory::~DefaultCdmFactory() {
24 void DefaultCdmFactory::Create(
25 const std::string& key_system,
26 const GURL& security_origin,
27 const CdmConfig& cdm_config,
28 const SessionMessageCB& session_message_cb,
29 const SessionClosedCB& session_closed_cb,
30 const LegacySessionErrorCB& legacy_session_error_cb,
31 const SessionKeysChangeCB& session_keys_change_cb,
32 const SessionExpirationUpdateCB& session_expiration_update_cb,
33 const CdmCreatedCB& cdm_created_cb) {
34 if (!security_origin.is_valid()) {
35 base::ThreadTaskRunnerHandle::Get()->PostTask(
36 FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin."));
37 return;
39 if (!CanUseAesDecryptor(key_system)) {
40 base::ThreadTaskRunnerHandle::Get()->PostTask(
41 FROM_HERE,
42 base::Bind(cdm_created_cb, nullptr, "Unsupported key system."));
43 return;
46 scoped_ptr<MediaKeys> cdm(
47 new AesDecryptor(security_origin, session_message_cb, session_closed_cb,
48 session_keys_change_cb));
49 base::ThreadTaskRunnerHandle::Get()->PostTask(
50 FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm), ""));
53 } // namespace media