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

Side by Side Diff: content/renderer/media/crypto/render_cdm_factory.cc

Issue 1070853004: media: CdmFactory creates CDM (MediaKeys) asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use ScopedVector Created 5 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
« no previous file with comments | « content/renderer/media/crypto/render_cdm_factory.h ('k') | media/base/cdm_factory.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 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 "content/renderer/media/crypto/render_cdm_factory.h" 5 #include "content/renderer/media/crypto/render_cdm_factory.h"
6 6
7 #include "base/bind.h"
8 #include "base/location.h"
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop_proxy.h"
8 #include "media/base/key_systems.h" 11 #include "media/base/key_systems.h"
9 #include "media/cdm/aes_decryptor.h" 12 #include "media/cdm/aes_decryptor.h"
10 #include "url/gurl.h" 13 #include "url/gurl.h"
11
12 #if defined(ENABLE_PEPPER_CDMS) 14 #if defined(ENABLE_PEPPER_CDMS)
13 #include "content/renderer/media/crypto/ppapi_decryptor.h" 15 #include "content/renderer/media/crypto/ppapi_decryptor.h"
14 #elif defined(ENABLE_BROWSER_CDMS) 16 #elif defined(ENABLE_BROWSER_CDMS)
15 #include "content/renderer/media/crypto/proxy_media_keys.h" 17 #include "content/renderer/media/crypto/proxy_media_keys.h"
16 #endif // defined(ENABLE_PEPPER_CDMS) 18 #endif // defined(ENABLE_PEPPER_CDMS)
17 19
18 namespace content { 20 namespace content {
19 21
20 RenderCdmFactory::RenderCdmFactory( 22 RenderCdmFactory::RenderCdmFactory(
21 #if defined(ENABLE_PEPPER_CDMS) 23 #if defined(ENABLE_PEPPER_CDMS)
22 const CreatePepperCdmCB& create_pepper_cdm_cb, 24 const CreatePepperCdmCB& create_pepper_cdm_cb,
23 #elif defined(ENABLE_BROWSER_CDMS) 25 #elif defined(ENABLE_BROWSER_CDMS)
24 RendererCdmManager* manager, 26 RendererCdmManager* manager,
25 #endif // defined(ENABLE_PEPPER_CDMS) 27 #endif // defined(ENABLE_PEPPER_CDMS)
26 RenderFrame* render_frame) 28 RenderFrame* render_frame)
27 : RenderFrameObserver(render_frame) 29 : RenderFrameObserver(render_frame)
28 #if defined(ENABLE_PEPPER_CDMS) 30 #if defined(ENABLE_PEPPER_CDMS)
29 , create_pepper_cdm_cb_(create_pepper_cdm_cb) 31 , create_pepper_cdm_cb_(create_pepper_cdm_cb)
30 #elif defined(ENABLE_BROWSER_CDMS) 32 #elif defined(ENABLE_BROWSER_CDMS)
31 , manager_(manager) 33 , manager_(manager)
32 #endif // defined(ENABLE_PEPPER_CDMS) 34 #endif // defined(ENABLE_PEPPER_CDMS)
33 { 35 {
34 } 36 }
35 37
36 RenderCdmFactory::~RenderCdmFactory() { 38 RenderCdmFactory::~RenderCdmFactory() {
37 DCHECK(thread_checker_.CalledOnValidThread()); 39 DCHECK(thread_checker_.CalledOnValidThread());
38 } 40 }
39 41
40 scoped_ptr<media::MediaKeys> RenderCdmFactory::Create( 42 void RenderCdmFactory::Create(
41 const std::string& key_system, 43 const std::string& key_system,
42 bool allow_distinctive_identifier, 44 bool allow_distinctive_identifier,
43 bool allow_persistent_state, 45 bool allow_persistent_state,
44 const GURL& security_origin, 46 const GURL& security_origin,
45 const media::SessionMessageCB& session_message_cb, 47 const media::SessionMessageCB& session_message_cb,
46 const media::SessionClosedCB& session_closed_cb, 48 const media::SessionClosedCB& session_closed_cb,
47 const media::LegacySessionErrorCB& legacy_session_error_cb, 49 const media::LegacySessionErrorCB& legacy_session_error_cb,
48 const media::SessionKeysChangeCB& session_keys_change_cb, 50 const media::SessionKeysChangeCB& session_keys_change_cb,
49 const media::SessionExpirationUpdateCB& session_expiration_update_cb) { 51 const media::SessionExpirationUpdateCB& session_expiration_update_cb,
52 const CdmCreatedCB& cdm_created_cb) {
50 DCHECK(thread_checker_.CalledOnValidThread()); 53 DCHECK(thread_checker_.CalledOnValidThread());
51 54
52 if (!security_origin.is_valid()) 55 if (!security_origin.is_valid()) {
53 return nullptr; 56 base::MessageLoopProxy::current()->PostTask(
57 FROM_HERE, base::Bind(cdm_created_cb, nullptr));
58 return;
59 }
60
61 scoped_ptr<media::MediaKeys> cdm;
54 62
55 if (media::CanUseAesDecryptor(key_system)) { 63 if (media::CanUseAesDecryptor(key_system)) {
56 // TODO(sandersd): Currently the prefixed API always allows distinctive 64 // TODO(sandersd): Currently the prefixed API always allows distinctive
57 // identifiers and persistent state. Once that changes we can sanity check 65 // identifiers and persistent state. Once that changes we can sanity check
58 // here that neither is allowed for AesDecryptor, since it does not support 66 // here that neither is allowed for AesDecryptor, since it does not support
59 // them and should never be configured that way. http://crbug.com/455271 67 // them and should never be configured that way. http://crbug.com/455271
60 return scoped_ptr<media::MediaKeys>( 68 cdm.reset(new media::AesDecryptor(security_origin, session_message_cb,
61 new media::AesDecryptor(security_origin, session_message_cb, 69 session_closed_cb,
62 session_closed_cb, session_keys_change_cb)); 70 session_keys_change_cb));
71 } else {
72 #if defined(ENABLE_PEPPER_CDMS)
73 cdm = PpapiDecryptor::Create(
74 key_system, allow_distinctive_identifier, allow_persistent_state,
75 security_origin, create_pepper_cdm_cb_, session_message_cb,
76 session_closed_cb, legacy_session_error_cb, session_keys_change_cb,
77 session_expiration_update_cb);
78 #elif defined(ENABLE_BROWSER_CDMS)
79 DCHECK(allow_distinctive_identifier);
80 DCHECK(allow_persistent_state);
81 cdm = ProxyMediaKeys::Create(
82 key_system, security_origin, manager_, session_message_cb,
83 session_closed_cb, legacy_session_error_cb, session_keys_change_cb,
84 session_expiration_update_cb);
85 #endif // defined(ENABLE_PEPPER_CDMS)
63 } 86 }
64 87
65 #if defined(ENABLE_PEPPER_CDMS) 88 base::MessageLoopProxy::current()->PostTask(
66 return scoped_ptr<media::MediaKeys>(PpapiDecryptor::Create( 89 FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm)));
67 key_system, allow_distinctive_identifier, allow_persistent_state,
68 security_origin, create_pepper_cdm_cb_, session_message_cb,
69 session_closed_cb, legacy_session_error_cb, session_keys_change_cb,
70 session_expiration_update_cb));
71 #elif defined(ENABLE_BROWSER_CDMS)
72 DCHECK(allow_distinctive_identifier);
73 DCHECK(allow_persistent_state);
74 return scoped_ptr<media::MediaKeys>(ProxyMediaKeys::Create(
75 key_system, security_origin, manager_, session_message_cb,
76 session_closed_cb, legacy_session_error_cb, session_keys_change_cb,
77 session_expiration_update_cb));
78 #else
79 return nullptr;
80 #endif // defined(ENABLE_PEPPER_CDMS)
81 } 90 }
82 91
83 } // namespace content 92 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/crypto/render_cdm_factory.h ('k') | media/base/cdm_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698