Commit f29d24d1 authored by haraken@chromium.org's avatar haraken@chromium.org

Oilpan: Enable Oilpan by default in modules/encryptedmedia

This CL changes generated bindings so that both toV8(RawPtr<X>) and toV8(X*) are generated. Otherwise, if someone uses RawPtr<X> instead of X* in the code base, it can be bound to unexpected toV8() and a wrong wrapper can be returned to V8. For more details, see my comment in the patch set 3.

BUG=340522

Review URL: https://codereview.chromium.org/257503003

git-svn-id: svn://svn.chromium.org/blink/trunk@175248 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9b2a28fd
......@@ -975,6 +975,12 @@ crbug.com/308992 svg/as-object/sizing/svg-in-object-placeholder-height-percentag
crbug.com/368531 virtual/gpu/fast/canvas/canvas-path-addpath.html [ Failure Pass ]
# Oilpan's conservative GC makes the test results flaky.
# If we can rewrite these tests using asyncGC() the flakiness is gone, but we cannot do it
# because these tests rely on not going back to the event loop during the test.
crbug.com/378245 media/encrypted-media/encrypted-media-lifetime-mediakeys.html [ Pass Failure ]
crbug.com/378245 media/encrypted-media/encrypted-media-lifetime-mediakeysession-reference.html [ Pass Failure ]
# Expectations changes due to switiching to In-renderer Shared Worker.
crbug.com/327256 fast/workers/shared-worker-lifecycle.html [ Failure Pass ]
......
......@@ -86,12 +86,7 @@ void HTMLMediaElementEncryptedMedia::setMediaKeysInternal(HTMLMediaElement& elem
return;
ASSERT(m_emeMode == EmeModeUnprefixed);
if (m_mediaKeys)
m_mediaKeys->setMediaElement(0);
m_mediaKeys = mediaKeys;
if (m_mediaKeys)
m_mediaKeys->setMediaElement(&element);
// If a player is connected, tell it that the CDM has changed.
if (element.webMediaPlayer())
......
......@@ -76,7 +76,7 @@ private:
EmeMode m_emeMode;
RefPtrWillBeMember<MediaKeys> m_mediaKeys;
PersistentWillBeMember<MediaKeys> m_mediaKeys;
};
}
......
......@@ -60,14 +60,14 @@ MediaKeySession::PendingAction::~PendingAction()
{
}
PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeySession::create(ExecutionContext* context, blink::WebContentDecryptionModule* cdm, WeakPtrWillBeRawPtr<MediaKeys> keys)
MediaKeySession* MediaKeySession::create(ExecutionContext* context, blink::WebContentDecryptionModule* cdm, MediaKeys* keys)
{
RefPtrWillBeRawPtr<MediaKeySession> session(adoptRefWillBeRefCountedGarbageCollected(new MediaKeySession(context, cdm, keys)));
MediaKeySession* session = adoptRefCountedGarbageCollected(new MediaKeySession(context, cdm, keys));
session->suspendIfNeeded();
return session.release();
return session;
}
MediaKeySession::MediaKeySession(ExecutionContext* context, blink::WebContentDecryptionModule* cdm, WeakPtrWillBeRawPtr<MediaKeys> keys)
MediaKeySession::MediaKeySession(ExecutionContext* context, blink::WebContentDecryptionModule* cdm, MediaKeys* keys)
: ActiveDOMObject(context)
, m_keySystem(keys->keySystem())
, m_asyncEventQueue(GenericEventQueue::create(this))
......
......@@ -64,12 +64,12 @@ class MediaKeys;
// it may outlive any JavaScript references as long as the MediaKeys object is alive.
// The WebContentDecryptionModuleSession has the same lifetime as this object.
class MediaKeySession FINAL
: public RefCountedWillBeRefCountedGarbageCollected<MediaKeySession>, public ActiveDOMObject, public ScriptWrappable, public EventTargetWithInlineData
: public RefCountedGarbageCollected<MediaKeySession>, public ActiveDOMObject, public ScriptWrappable, public EventTargetWithInlineData
, private blink::WebContentDecryptionModuleSession::Client {
REFCOUNTED_EVENT_TARGET(MediaKeySession);
DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedGarbageCollected<MediaKeySession>);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MediaKeySession);
public:
static PassRefPtrWillBeRawPtr<MediaKeySession> create(ExecutionContext*, blink::WebContentDecryptionModule*, WeakPtrWillBeRawPtr<MediaKeys>);
static MediaKeySession* create(ExecutionContext*, blink::WebContentDecryptionModule*, MediaKeys*);
virtual ~MediaKeySession();
const String& keySystem() const { return m_keySystem; }
......@@ -112,7 +112,7 @@ private:
PendingAction(Type, PassRefPtr<Uint8Array> data);
};
MediaKeySession(ExecutionContext*, blink::WebContentDecryptionModule*, WeakPtrWillBeRawPtr<MediaKeys>);
MediaKeySession(ExecutionContext*, blink::WebContentDecryptionModule*, MediaKeys*);
void actionTimerFired(Timer<MediaKeySession>*);
// blink::WebContentDecryptionModuleSession::Client
......@@ -127,7 +127,7 @@ private:
OwnPtr<blink::WebContentDecryptionModuleSession> m_session;
// Used to determine if MediaKeys is still active.
WeakPtrWillBeWeakMember<MediaKeys> m_keys;
WeakMember<MediaKeys> m_keys;
// Is the CDM finished with this session?
bool m_isClosed;
......
......@@ -26,7 +26,7 @@
[
ActiveDOMObject,
RuntimeEnabled=EncryptedMedia,
WillBeGarbageCollected,
GarbageCollected,
TypeChecking=Interface|Nullable
] interface MediaKeySession : EventTarget {
// error state
......
......@@ -53,7 +53,7 @@ static bool isKeySystemSupportedWithContentType(const String& keySystem, const S
return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.type(), codecs);
}
PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, const String& keySystem, ExceptionState& exceptionState)
MediaKeys* MediaKeys::create(ExecutionContext* context, const String& keySystem, ExceptionState& exceptionState)
{
// From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#dom-media-keys-constructor>:
// The MediaKeys(keySystem) constructor must run the following steps:
......@@ -61,13 +61,13 @@ PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c
// 1. If keySystem is an empty string, throw an InvalidAccessError exception and abort these steps.
if (keySystem.isEmpty()) {
exceptionState.throwDOMException(InvalidAccessError, "The key system provided is invalid.");
return nullptr;
return 0;
}
// 2. If keySystem is not one of the user agent's supported Key Systems, throw a NotSupportedError and abort these steps.
if (!isKeySystemSupportedWithContentType(keySystem, "")) {
exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported.");
return nullptr;
return 0;
}
// 3. Let cdm be the content decryption module corresponding to keySystem.
......@@ -77,24 +77,20 @@ PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c
OwnPtr<blink::WebContentDecryptionModule> cdm = controller->createContentDecryptionModule(context, keySystem);
if (!cdm) {
exceptionState.throwDOMException(NotSupportedError, "A content decryption module could not be loaded for the '" + keySystem + "' key system.");
return nullptr;
return 0;
}
// 5. Create a new MediaKeys object.
// 5.1 Let the keySystem attribute be keySystem.
// 6. Return the new object to the caller.
return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release()));
return new MediaKeys(context, keySystem, cdm.release());
}
MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwnPtr<blink::WebContentDecryptionModule> cdm)
: ContextLifecycleObserver(context)
, m_mediaElement(0)
, m_keySystem(keySystem)
, m_cdm(cdm)
, m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFired)
#if !ENABLE(OILPAN)
, m_weakFactory(this)
#endif
{
WTF_LOG(Media, "MediaKeys::MediaKeys");
ScriptWrappable::init(this);
......@@ -104,7 +100,7 @@ MediaKeys::~MediaKeys()
{
}
PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContext* context, const String& contentType, Uint8Array* initData, ExceptionState& exceptionState)
MediaKeySession* MediaKeys::createSession(ExecutionContext* context, const String& contentType, Uint8Array* initData, ExceptionState& exceptionState)
{
WTF_LOG(Media, "MediaKeys::createSession");
......@@ -114,27 +110,23 @@ PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex
if (contentType.isEmpty()) {
exceptionState.throwDOMException(InvalidAccessError, "The contentType provided ('" + contentType + "') is empty.");
return nullptr;
return 0;
}
if (!initData->length()) {
exceptionState.throwDOMException(InvalidAccessError, "The initData provided is empty.");
return nullptr;
return 0;
}
// 1. If type contains a MIME type that is not supported or is not supported by the keySystem,
// throw a NOT_SUPPORTED_ERR exception and abort these steps.
if (!isKeySystemSupportedWithContentType(m_keySystem, contentType)) {
exceptionState.throwDOMException(NotSupportedError, "The type provided ('" + contentType + "') is unsupported.");
return nullptr;
return 0;
}
// 2. Create a new MediaKeySession object.
#if ENABLE(OILPAN)
MediaKeySession* session = MediaKeySession::create(context, m_cdm.get(), this);
#else
RefPtr<MediaKeySession> session = MediaKeySession::create(context, m_cdm.get(), m_weakFactory.createWeakPtr());
#endif
// 2.1 Let the keySystem attribute be keySystem.
ASSERT(!session->keySystem().isEmpty());
// FIXME: 2.2 Let the state of the session be CREATED.
......@@ -173,14 +165,6 @@ bool MediaKeys::isTypeSupported(const String& keySystem, const String& contentTy
return isKeySystemSupportedWithContentType(keySystem, contentType);
}
void MediaKeys::setMediaElement(HTMLMediaElement* element)
{
// FIXME: Cause HTMLMediaElement::setMediaKeys() to throw an exception if m_mediaElement is not 0
// and remove the code that prevents the assert below in HTMLMediaElement.
ASSERT(!m_mediaElement != !element);
m_mediaElement = element;
}
blink::WebContentDecryptionModule* MediaKeys::contentDecryptionModule()
{
return m_cdm.get();
......
......@@ -51,19 +51,17 @@ class ExceptionState;
// References are held by JS and HTMLMediaElement.
// The WebContentDecryptionModule has the same lifetime as this object.
class MediaKeys : public RefCountedWillBeGarbageCollectedFinalized<MediaKeys>, public ContextLifecycleObserver, public ScriptWrappable {
class MediaKeys : public GarbageCollectedFinalized<MediaKeys>, public ContextLifecycleObserver, public ScriptWrappable {
public:
static PassRefPtrWillBeRawPtr<MediaKeys> create(ExecutionContext*, const String& keySystem, ExceptionState&);
static MediaKeys* create(ExecutionContext*, const String& keySystem, ExceptionState&);
~MediaKeys();
const String& keySystem() const { return m_keySystem; }
PassRefPtrWillBeRawPtr<MediaKeySession> createSession(ExecutionContext*, const String& contentType, Uint8Array* initData, ExceptionState&);
MediaKeySession* createSession(ExecutionContext*, const String& contentType, Uint8Array* initData, ExceptionState&);
static bool isTypeSupported(const String& keySystem, const String& contentType);
void setMediaElement(HTMLMediaElement*);
blink::WebContentDecryptionModule* contentDecryptionModule();
void trace(Visitor*);
......@@ -75,31 +73,26 @@ protected:
MediaKeys(ExecutionContext*, const String& keySystem, PassOwnPtr<blink::WebContentDecryptionModule>);
void initializeNewSessionTimerFired(Timer<MediaKeys>*);
HTMLMediaElement* m_mediaElement;
const String m_keySystem;
OwnPtr<blink::WebContentDecryptionModule> m_cdm;
// FIXME: Check whether |initData| can be changed by JS. Maybe we should not pass it as a pointer.
struct InitializeNewSessionData {
class InitializeNewSessionData {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
InitializeNewSessionData(PassRefPtrWillBeRawPtr<MediaKeySession> session, const String& contentType, PassRefPtr<Uint8Array> initData)
InitializeNewSessionData(MediaKeySession* session, const String& contentType, PassRefPtr<Uint8Array> initData)
: session(session)
, contentType(contentType)
, initData(initData) { }
void trace(Visitor*);
RefPtrWillBeMember<MediaKeySession> session;
Member<MediaKeySession> session;
String contentType;
RefPtr<Uint8Array> initData;
};
Deque<InitializeNewSessionData> m_pendingInitializeNewSessionData;
HeapDeque<InitializeNewSessionData> m_pendingInitializeNewSessionData;
Timer<MediaKeys> m_initializeNewSessionTimer;
#if !ENABLE(OILPAN)
WeakPtrFactory<MediaKeys> m_weakFactory;
#endif
};
}
......
......@@ -28,7 +28,7 @@
Constructor(DOMString keySystem),
ConstructorCallWith=ExecutionContext,
RaisesException=Constructor,
WillBeGarbageCollected,
GarbageCollected,
TypeChecking=Interface|Nullable
] interface MediaKeys {
readonly attribute DOMString keySystem;
......
......@@ -28,6 +28,7 @@
#include "platform/PlatformExport.h"
#include "platform/TraceLocation.h"
#include "platform/heap/Handle.h"
#include "wtf/Noncopyable.h"
#include "wtf/Threading.h"
#include "wtf/Vector.h"
......@@ -128,6 +129,7 @@ private:
// FIXME: oilpan: TimerBase should be moved to the heap and m_object should be traced.
// This raw pointer is safe as long as Timer<X> is held by the X itself (That's the case
// in the current code base).
GC_PLUGIN_IGNORE("363031")
TimerFiredClass* m_object;
TimerFiredFunction m_function;
};
......@@ -183,6 +185,7 @@ private:
// FIXME: oilpan: TimerBase should be moved to the heap and m_object should be traced.
// This raw pointer is safe as long as Timer<X> is held by the X itself (That's the case
// in the current code base).
GC_PLUGIN_IGNORE("363031")
TimerFiredClass* m_object;
TimerFiredFunction m_function;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment