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

Side by Side Diff: media/blink/webcontentdecryptionmoduleaccess_impl.cc

Issue 886393003: Handle createCDM() when frame destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 "webcontentdecryptionmoduleaccess_impl.h" 5 #include "webcontentdecryptionmoduleaccess_impl.h"
xhwang 2015/02/03 18:45:48 full path relative to src/
jrummell 2015/02/03 20:01:14 Done.
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
11 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 11 #include "webencryptedmediaclient_impl.h"
xhwang 2015/02/03 18:45:49 full path relative to src/
jrummell 2015/02/03 20:01:13 Done.
12 #include "webcontentdecryptionmodule_impl.h"
13 12
14 namespace media { 13 namespace media {
15 14
16 // The caller owns the created cdm (passed back using |result|). 15 // The caller owns the created cdm (passed back using |result|).
17 static void CreateCdm(CdmFactory* cdm_factory, 16 static void CreateCdm(base::WeakPtr<WebEncryptedMediaClientImpl> client,
xhwang 2015/02/03 18:45:49 Add include for weak ptr.
jrummell 2015/02/03 20:01:14 Already in the .h file.
18 blink::WebSecurityOrigin security_origin, 17 blink::WebSecurityOrigin security_origin,
19 blink::WebString key_system, 18 blink::WebString key_system,
20 blink::WebContentDecryptionModuleResult result) { 19 blink::WebContentDecryptionModuleResult result) {
xhwang 2015/02/03 18:45:49 Pass parameters by const-ref where possible?
jrummell 2015/02/03 20:01:14 Done.
21 WebContentDecryptionModuleImpl::Create(cdm_factory, security_origin, 20 // If |client| is gone (due to the frame getting destroyed), it is
22 key_system, result); 21 // impossible to create the CDM, so fail.
22 if (client.get() == nullptr) {
xhwang 2015/02/03 18:45:48 WeakPtr is Testable, no need to use get() and comp
jrummell 2015/02/03 20:01:13 Done.
23 result.completeWithError(
24 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0,
25 "Failed to create CDM.");
26 return;
27 }
28
29 client->CreateCdm(security_origin, key_system, result);
23 } 30 }
24 31
25 WebContentDecryptionModuleAccessImpl* 32 WebContentDecryptionModuleAccessImpl*
26 WebContentDecryptionModuleAccessImpl::Create( 33 WebContentDecryptionModuleAccessImpl::Create(
27 const blink::WebString& key_system, 34 const blink::WebString& key_system,
28 const blink::WebMediaKeySystemConfiguration& configuration, 35 const blink::WebMediaKeySystemConfiguration& configuration,
29 const blink::WebSecurityOrigin& security_origin, 36 const blink::WebSecurityOrigin& security_origin,
30 CdmFactory* cdm_factory) { 37 base::WeakPtr<WebEncryptedMediaClientImpl> client) {
xhwang 2015/02/03 18:45:48 ditto
jrummell 2015/02/03 20:01:13 Done.
31 return new WebContentDecryptionModuleAccessImpl(key_system, configuration, 38 return new WebContentDecryptionModuleAccessImpl(key_system, configuration,
32 security_origin, cdm_factory); 39 security_origin, client);
33 } 40 }
34 41
35 WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl( 42 WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
36 const blink::WebString& key_system, 43 const blink::WebString& key_system,
37 const blink::WebMediaKeySystemConfiguration& configuration, 44 const blink::WebMediaKeySystemConfiguration& configuration,
38 const blink::WebSecurityOrigin& security_origin, 45 const blink::WebSecurityOrigin& security_origin,
39 CdmFactory* cdm_factory) 46 base::WeakPtr<WebEncryptedMediaClientImpl> client)
xhwang 2015/02/03 18:45:49 ditto
jrummell 2015/02/03 20:01:14 Done.
40 : key_system_(key_system), 47 : key_system_(key_system),
41 configuration_(configuration), 48 configuration_(configuration),
42 security_origin_(security_origin), 49 security_origin_(security_origin),
43 cdm_factory_(cdm_factory) { 50 client_(client) {
44 } 51 }
45 52
46 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() { 53 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() {
47 } 54 }
48 55
49 blink::WebMediaKeySystemConfiguration 56 blink::WebMediaKeySystemConfiguration
50 WebContentDecryptionModuleAccessImpl::getConfiguration() { 57 WebContentDecryptionModuleAccessImpl::getConfiguration() {
51 return configuration_; 58 return configuration_;
52 } 59 }
53 60
54 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule( 61 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule(
55 blink::WebContentDecryptionModuleResult result) { 62 blink::WebContentDecryptionModuleResult result) {
56 // This method needs to run asynchronously, as it may need to load the CDM. 63 // This method needs to run asynchronously, as it may need to load the CDM.
57 // As this object's lifetime is controlled by MediaKeySystemAccess on the 64 // As this object's lifetime is controlled by MediaKeySystemAccess on the
58 // blink side, copy all values needed by CreateCdm() in case the blink object 65 // blink side, copy all values needed by CreateCdm() in case the blink object
59 // gets garbage-collected. 66 // gets garbage-collected.
60 base::MessageLoopProxy::current()->PostTask( 67 base::MessageLoopProxy::current()->PostTask(
61 FROM_HERE, base::Bind(&CreateCdm, cdm_factory_, security_origin_, 68 FROM_HERE,
62 key_system_, result)); 69 base::Bind(&CreateCdm, client_, security_origin_, key_system_, result));
63 } 70 }
64 71
65 } // namespace media 72 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698