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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: media/blink/webcontentdecryptionmoduleaccess_impl.cc
diff --git a/media/blink/webcontentdecryptionmoduleaccess_impl.cc b/media/blink/webcontentdecryptionmoduleaccess_impl.cc
index ec4e9194added92b6dcb5407db4501c732283a5a..c5d10d0ba25c69efdbf102a9032f58363f91943e 100644
--- a/media/blink/webcontentdecryptionmoduleaccess_impl.cc
+++ b/media/blink/webcontentdecryptionmoduleaccess_impl.cc
@@ -8,18 +8,25 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
-#include "webcontentdecryptionmodule_impl.h"
+#include "webencryptedmediaclient_impl.h"
xhwang 2015/02/03 18:45:49 full path relative to src/
jrummell 2015/02/03 20:01:13 Done.
namespace media {
// The caller owns the created cdm (passed back using |result|).
-static void CreateCdm(CdmFactory* cdm_factory,
+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.
blink::WebSecurityOrigin security_origin,
blink::WebString key_system,
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.
- WebContentDecryptionModuleImpl::Create(cdm_factory, security_origin,
- key_system, result);
+ // If |client| is gone (due to the frame getting destroyed), it is
+ // impossible to create the CDM, so fail.
+ 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.
+ result.completeWithError(
+ blink::WebContentDecryptionModuleExceptionInvalidStateError, 0,
+ "Failed to create CDM.");
+ return;
+ }
+
+ client->CreateCdm(security_origin, key_system, result);
}
WebContentDecryptionModuleAccessImpl*
@@ -27,20 +34,20 @@ WebContentDecryptionModuleAccessImpl::Create(
const blink::WebString& key_system,
const blink::WebMediaKeySystemConfiguration& configuration,
const blink::WebSecurityOrigin& security_origin,
- CdmFactory* cdm_factory) {
+ base::WeakPtr<WebEncryptedMediaClientImpl> client) {
xhwang 2015/02/03 18:45:48 ditto
jrummell 2015/02/03 20:01:13 Done.
return new WebContentDecryptionModuleAccessImpl(key_system, configuration,
- security_origin, cdm_factory);
+ security_origin, client);
}
WebContentDecryptionModuleAccessImpl::WebContentDecryptionModuleAccessImpl(
const blink::WebString& key_system,
const blink::WebMediaKeySystemConfiguration& configuration,
const blink::WebSecurityOrigin& security_origin,
- CdmFactory* cdm_factory)
+ base::WeakPtr<WebEncryptedMediaClientImpl> client)
xhwang 2015/02/03 18:45:49 ditto
jrummell 2015/02/03 20:01:14 Done.
: key_system_(key_system),
configuration_(configuration),
security_origin_(security_origin),
- cdm_factory_(cdm_factory) {
+ client_(client) {
}
WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() {
@@ -58,8 +65,8 @@ void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule(
// blink side, copy all values needed by CreateCdm() in case the blink object
// gets garbage-collected.
base::MessageLoopProxy::current()->PostTask(
- FROM_HERE, base::Bind(&CreateCdm, cdm_factory_, security_origin_,
- key_system_, result));
+ FROM_HERE,
+ base::Bind(&CreateCdm, client_, security_origin_, key_system_, result));
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698