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

Side by Side Diff: media/cdm/default_cdm_factory.cc

Issue 2445433003: media: Enable encrypted media content browsertests when MojoCdm is used (Closed)
Patch Set: media: Enable encrypted media content browsertests when MojoCdm is used Created 4 years, 2 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
« media/base/key_systems.cc ('K') | « media/base/key_systems.cc ('k') | no next file » | 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/cdm/default_cdm_factory.h" 5 #include "media/cdm/default_cdm_factory.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 "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "media/base/key_system_names.h"
12 #include "media/base/key_systems.h" 13 #include "media/base/key_systems.h"
14 #include "media/base/media_switches.h"
13 #include "media/cdm/aes_decryptor.h" 15 #include "media/cdm/aes_decryptor.h"
14 #include "url/gurl.h" 16 #include "url/gurl.h"
15 17
16 namespace media { 18 namespace media {
17 19
18 DefaultCdmFactory::DefaultCdmFactory() { 20 DefaultCdmFactory::DefaultCdmFactory() {
xhwang 2016/11/03 07:14:44 This class is only used for testing. I'd like to r
19 } 21 }
20 22
21 DefaultCdmFactory::~DefaultCdmFactory() { 23 DefaultCdmFactory::~DefaultCdmFactory() {
22 } 24 }
23 25
26 static bool ShouldUseAesDecryptor(const std::string& key_system) {
ddorwin 2016/10/28 19:03:47 s/Use/Create/?
xhwang 2016/11/03 07:14:44 Done.
27 if (CanUseAesDecryptor(key_system))
28 return true;
29
30 // Create AesDecryptor here to support External Clear Key key system.
ddorwin 2016/10/28 19:03:48 nit: This comment is a bit odd ("Create... here").
xhwang 2016/11/03 07:14:44 Done.
31 // This is used for testing.
32 return base::FeatureList::IsEnabled(media::kExternalClearKeyForTesting) &&
33 IsExternalClearKey(key_system);
34 }
35
24 void DefaultCdmFactory::Create( 36 void DefaultCdmFactory::Create(
25 const std::string& key_system, 37 const std::string& key_system,
26 const GURL& security_origin, 38 const GURL& security_origin,
27 const CdmConfig& cdm_config, 39 const CdmConfig& cdm_config,
28 const SessionMessageCB& session_message_cb, 40 const SessionMessageCB& session_message_cb,
29 const SessionClosedCB& session_closed_cb, 41 const SessionClosedCB& session_closed_cb,
30 const SessionKeysChangeCB& session_keys_change_cb, 42 const SessionKeysChangeCB& session_keys_change_cb,
31 const SessionExpirationUpdateCB& session_expiration_update_cb, 43 const SessionExpirationUpdateCB& session_expiration_update_cb,
32 const CdmCreatedCB& cdm_created_cb) { 44 const CdmCreatedCB& cdm_created_cb) {
33 if (!security_origin.is_valid()) { 45 if (!security_origin.is_valid()) {
34 base::ThreadTaskRunnerHandle::Get()->PostTask( 46 base::ThreadTaskRunnerHandle::Get()->PostTask(
35 FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin.")); 47 FROM_HERE, base::Bind(cdm_created_cb, nullptr, "Invalid origin."));
36 return; 48 return;
37 } 49 }
38 if (!CanUseAesDecryptor(key_system)) { 50
51 if (!ShouldUseAesDecryptor(key_system)) {
39 base::ThreadTaskRunnerHandle::Get()->PostTask( 52 base::ThreadTaskRunnerHandle::Get()->PostTask(
40 FROM_HERE, 53 FROM_HERE,
41 base::Bind(cdm_created_cb, nullptr, "Unsupported key system.")); 54 base::Bind(cdm_created_cb, nullptr, "Unsupported key system."));
42 return; 55 return;
43 } 56 }
44 57
45 scoped_refptr<MediaKeys> cdm( 58 scoped_refptr<MediaKeys> cdm(
46 new AesDecryptor(security_origin, session_message_cb, session_closed_cb, 59 new AesDecryptor(security_origin, session_message_cb, session_closed_cb,
47 session_keys_change_cb)); 60 session_keys_change_cb));
48 base::ThreadTaskRunnerHandle::Get()->PostTask( 61 base::ThreadTaskRunnerHandle::Get()->PostTask(
49 FROM_HERE, base::Bind(cdm_created_cb, cdm, "")); 62 FROM_HERE, base::Bind(cdm_created_cb, cdm, ""));
50 } 63 }
51 64
52 } // namespace media 65 } // namespace media
OLDNEW
« media/base/key_systems.cc ('K') | « media/base/key_systems.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698