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

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

Issue 1102363005: Initialize the CDM asynchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create() changes Created 5 years, 7 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 "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" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
12 #include "media/base/cdm_promise.h"
11 #include "media/base/key_systems.h" 13 #include "media/base/key_systems.h"
14 #include "media/base/media_keys.h"
12 #include "media/cdm/aes_decryptor.h" 15 #include "media/cdm/aes_decryptor.h"
13 #include "url/gurl.h" 16 #include "url/gurl.h"
14 #if defined(ENABLE_PEPPER_CDMS) 17 #if defined(ENABLE_PEPPER_CDMS)
15 #include "content/renderer/media/crypto/ppapi_decryptor.h" 18 #include "content/renderer/media/crypto/ppapi_decryptor.h"
16 #elif defined(ENABLE_BROWSER_CDMS) 19 #elif defined(ENABLE_BROWSER_CDMS)
17 #include "content/renderer/media/crypto/proxy_media_keys.h" 20 #include "content/renderer/media/crypto/proxy_media_keys.h"
18 #endif // defined(ENABLE_PEPPER_CDMS) 21 #endif // defined(ENABLE_PEPPER_CDMS)
19 22
20 namespace content { 23 namespace content {
21 24
(...skipping 20 matching lines...) Expand all
42 void RenderCdmFactory::Create( 45 void RenderCdmFactory::Create(
43 const std::string& key_system, 46 const std::string& key_system,
44 bool allow_distinctive_identifier, 47 bool allow_distinctive_identifier,
45 bool allow_persistent_state, 48 bool allow_persistent_state,
46 const GURL& security_origin, 49 const GURL& security_origin,
47 const media::SessionMessageCB& session_message_cb, 50 const media::SessionMessageCB& session_message_cb,
48 const media::SessionClosedCB& session_closed_cb, 51 const media::SessionClosedCB& session_closed_cb,
49 const media::LegacySessionErrorCB& legacy_session_error_cb, 52 const media::LegacySessionErrorCB& legacy_session_error_cb,
50 const media::SessionKeysChangeCB& session_keys_change_cb, 53 const media::SessionKeysChangeCB& session_keys_change_cb,
51 const media::SessionExpirationUpdateCB& session_expiration_update_cb, 54 const media::SessionExpirationUpdateCB& session_expiration_update_cb,
52 const CdmCreatedCB& cdm_created_cb) { 55 const media::CdmCreatedCB& cdm_created_cb) {
53 DCHECK(thread_checker_.CalledOnValidThread()); 56 DCHECK(thread_checker_.CalledOnValidThread());
54 57
55 if (!security_origin.is_valid()) { 58 if (!security_origin.is_valid()) {
56 base::MessageLoopProxy::current()->PostTask( 59 base::MessageLoopProxy::current()->PostTask(
57 FROM_HERE, base::Bind(cdm_created_cb, nullptr)); 60 FROM_HERE, base::Bind(cdm_created_cb, nullptr));
58 return; 61 return;
59 } 62 }
60 63
61 scoped_ptr<media::MediaKeys> cdm;
62
63 if (media::CanUseAesDecryptor(key_system)) { 64 if (media::CanUseAesDecryptor(key_system)) {
64 // TODO(sandersd): Currently the prefixed API always allows distinctive 65 // TODO(sandersd): Currently the prefixed API always allows distinctive
65 // identifiers and persistent state. Once that changes we can sanity check 66 // identifiers and persistent state. Once that changes we can sanity check
66 // here that neither is allowed for AesDecryptor, since it does not support 67 // here that neither is allowed for AesDecryptor, since it does not support
67 // them and should never be configured that way. http://crbug.com/455271 68 // them and should never be configured that way. http://crbug.com/455271
68 cdm.reset(new media::AesDecryptor(security_origin, session_message_cb, 69 scoped_ptr<media::MediaKeys> cdm(
69 session_closed_cb, 70 new media::AesDecryptor(security_origin, session_message_cb,
70 session_keys_change_cb)); 71 session_closed_cb, session_keys_change_cb));
71 } else { 72 base::MessageLoopProxy::current()->PostTask(
72 #if defined(ENABLE_PEPPER_CDMS) 73 FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm)));
73 cdm = PpapiDecryptor::Create( 74 return;
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)
86 } 75 }
87 76
77 #if defined(ENABLE_PEPPER_CDMS)
78 PpapiDecryptor::Create(
79 key_system, allow_distinctive_identifier, allow_persistent_state,
80 security_origin, create_pepper_cdm_cb_, session_message_cb,
81 session_closed_cb, legacy_session_error_cb, session_keys_change_cb,
82 session_expiration_update_cb, cdm_created_cb);
83 #elif defined(ENABLE_BROWSER_CDMS)
84 DCHECK(allow_distinctive_identifier);
85 DCHECK(allow_persistent_state);
86 ProxyMediaKeys::Create(manager_, session_message_cb, session_closed_cb,
87 legacy_session_error_cb, session_keys_change_cb,
88 session_expiration_update_cb, cdm_created_cb);
89 #else
90 // No possible CDM to create, so fail the request.
88 base::MessageLoopProxy::current()->PostTask( 91 base::MessageLoopProxy::current()->PostTask(
89 FROM_HERE, base::Bind(cdm_created_cb, base::Passed(&cdm))); 92 FROM_HERE, base::Bind(cdm_created_cb, nullptr));
93 #endif // defined(ENABLE_PEPPER_CDMS)
90 } 94 }
91 95
92 } // namespace content 96 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698