Bug 1393369. P4 - remove MediaSourceResource::GetCurrentPrincipal().
MozReview-Commit-ID: J96wBGLBQ45
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -55,17 +55,18 @@ MediaSourceDecoder::CreateStateMachine()
nsresult
MediaSourceDecoder::Load(nsIPrincipal* aPrincipal)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!GetStateMachine());
AbstractThread::AutoEnter context(AbstractMainThread());
- mResource = new MediaSourceResource(aPrincipal);
+ mPrincipal = aPrincipal;
+ mResource = new MediaSourceResource();
nsresult rv = MediaShutdownManager::Instance().Register(this);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
SetStateMachine(CreateStateMachine());
if (!GetStateMachine()) {
@@ -361,15 +362,15 @@ MediaSourceDecoder::NotifyInitDataArrive
mDemuxer->NotifyInitDataArrived();
}
}
already_AddRefed<nsIPrincipal>
MediaSourceDecoder::GetCurrentPrincipal()
{
MOZ_ASSERT(NS_IsMainThread());
- return mResource ? mResource->GetCurrentPrincipal() : nullptr;
+ return do_AddRef(mPrincipal);
}
#undef MSE_DEBUG
#undef MSE_DEBUGV
} // namespace mozilla
--- a/dom/media/mediasource/MediaSourceDecoder.h
+++ b/dom/media/mediasource/MediaSourceDecoder.h
@@ -69,16 +69,17 @@ private:
MediaResource* GetResource() const override final;
MediaDecoderStateMachine* CreateStateMachine();
void DoSetMediaSourceDuration(double aDuration);
media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
bool CanPlayThroughImpl() override;
bool IsLiveStream() override final { return !mEnded; }
RefPtr<MediaSourceResource> mResource;
+ RefPtr<nsIPrincipal> mPrincipal;
// The owning MediaSource holds a strong reference to this decoder, and
// calls Attach/DetachMediaSource on this decoder to set and clear
// mMediaSource.
dom::MediaSource* mMediaSource;
RefPtr<MediaSourceDemuxer> mDemuxer;
bool mEnded;
--- a/dom/media/mediasource/MediaSourceResource.h
+++ b/dom/media/mediasource/MediaSourceResource.h
@@ -21,38 +21,32 @@ extern mozilla::LogModule* GetMediaSourc
#define UNIMPLEMENTED() MSE_DEBUG("UNIMPLEMENTED FUNCTION at %s:%d", __FILE__, __LINE__)
namespace mozilla {
class MediaSourceResource final : public MediaResource
{
public:
- explicit MediaSourceResource(nsIPrincipal* aPrincipal = nullptr)
- : mPrincipal(aPrincipal)
- , mMonitor("MediaSourceResource")
+ MediaSourceResource()
+ : mMonitor("MediaSourceResource")
, mEnded(false)
- {}
+ {}
nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) override { UNIMPLEMENTED(); return NS_ERROR_FAILURE; }
bool ShouldCacheReads() override { UNIMPLEMENTED(); return false; }
int64_t Tell() override { UNIMPLEMENTED(); return -1; }
void Pin() override { UNIMPLEMENTED(); }
void Unpin() override { UNIMPLEMENTED(); }
int64_t GetLength() override { UNIMPLEMENTED(); return -1; }
int64_t GetNextCachedData(int64_t aOffset) override { UNIMPLEMENTED(); return -1; }
int64_t GetCachedDataEnd(int64_t aOffset) override { UNIMPLEMENTED(); return -1; }
bool IsDataCachedToEndOfResource(int64_t aOffset) override { UNIMPLEMENTED(); return false; }
nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) override { UNIMPLEMENTED(); return NS_ERROR_FAILURE; }
- already_AddRefed<nsIPrincipal> GetCurrentPrincipal()
- {
- return RefPtr<nsIPrincipal>(mPrincipal).forget();
- }
-
nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
{
UNIMPLEMENTED();
aRanges += MediaByteRange(0, GetLength());
return NS_OK;
}
void SetEnded(bool aEnded)
@@ -68,17 +62,16 @@ private:
return size;
}
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
- RefPtr<nsIPrincipal> mPrincipal;
Monitor mMonitor;
bool mEnded; // protected by mMonitor
};
} // namespace mozilla
#undef MSE_DEBUG
#undef UNIMPLEMENTED