From 23c5c4b2daecc9ff7a3d546f7202b7c4e0487249 Mon Sep 17 00:00:00 2001 From: trav90 Date: Thu, 4 May 2017 02:26:52 -0500 Subject: [PATCH] Remove "Diamond Problem" with MediaDecoder inheritance MediaDecoder inherited from nsIObserver which inherits from nsISupport while also inheriting from AbstractMediaDecoder which itself inherits from nsISupport. This causes a "diamond problem", and prevents using some utility classes like NS_ProxyRelease or nsMainThreadPtrHandle. MediaDecoder will assert if destructed on anything but the main thread. --- dom/media/AbstractMediaDecoder.h | 6 +++++- dom/media/MediaDecoder.h | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dom/media/AbstractMediaDecoder.h b/dom/media/AbstractMediaDecoder.h index 18e71a56ca..49e24fb903 100644 --- a/dom/media/AbstractMediaDecoder.h +++ b/dom/media/AbstractMediaDecoder.h @@ -41,7 +41,7 @@ enum class MediaDecoderEventVisibility : int8_t { * The AbstractMediaDecoder class describes the public interface for a media decoder * and is used by the MediaReader classes. */ -class AbstractMediaDecoder : public nsISupports +class AbstractMediaDecoder : public nsIObserver { public: // Returns the monitor for other threads to synchronise access to @@ -150,6 +150,10 @@ public: AbstractMediaDecoder* mDecoder; }; + // Classes directly inheriting from AbstractMediaDecoder do not support + // Observe and it should never be called directly. + NS_IMETHOD Observe(nsISupports *aSubject, const char * aTopic, const char16_t * aData) override + { MOZ_CRASH("Forbidden method"); return NS_OK; } }; class MetadataContainer diff --git a/dom/media/MediaDecoder.h b/dom/media/MediaDecoder.h index 0db5822387..3e469eb71d 100644 --- a/dom/media/MediaDecoder.h +++ b/dom/media/MediaDecoder.h @@ -264,8 +264,7 @@ struct SeekTarget { MediaDecoderEventVisibility mEventVisibility; }; -class MediaDecoder : public nsIObserver, - public AbstractMediaDecoder +class MediaDecoder : public AbstractMediaDecoder { public: struct SeekResolveValue {