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

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: changes 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
« no previous file with comments | « media/blink/webcontentdecryptionmoduleaccess_impl.h ('k') | media/blink/webencryptedmediaclient_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webcontentdecryptionmoduleaccess_impl.cc
diff --git a/media/blink/webcontentdecryptionmoduleaccess_impl.cc b/media/blink/webcontentdecryptionmoduleaccess_impl.cc
index ec4e9194added92b6dcb5407db4501c732283a5a..ab98b432058f8cff3981b761ef2072e61507df79 100644
--- a/media/blink/webcontentdecryptionmoduleaccess_impl.cc
+++ b/media/blink/webcontentdecryptionmoduleaccess_impl.cc
@@ -2,24 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webcontentdecryptionmoduleaccess_impl.h"
+#include "media/blink/webcontentdecryptionmoduleaccess_impl.h"
#include "base/basictypes.h"
#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 "media/blink/webencryptedmediaclient_impl.h"
namespace media {
// The caller owns the created cdm (passed back using |result|).
-static void CreateCdm(CdmFactory* cdm_factory,
- blink::WebSecurityOrigin security_origin,
- blink::WebString key_system,
+static void CreateCdm(const base::WeakPtr<WebEncryptedMediaClientImpl>& client,
+ const blink::WebString& key_system,
+ const blink::WebSecurityOrigin& security_origin,
blink::WebContentDecryptionModuleResult result) {
- 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) {
+ result.completeWithError(
+ blink::WebContentDecryptionModuleExceptionInvalidStateError, 0,
+ "Failed to create CDM.");
+ return;
+ }
+
+ client->CreateCdm(key_system, security_origin, 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) {
+ const base::WeakPtr<WebEncryptedMediaClientImpl>& client) {
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)
+ const base::WeakPtr<WebEncryptedMediaClientImpl>& client)
: 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_, key_system_, security_origin_, result));
}
} // namespace media
« no previous file with comments | « media/blink/webcontentdecryptionmoduleaccess_impl.h ('k') | media/blink/webencryptedmediaclient_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698