Bug 1393369. P2 - remove MediaResource::GetCurrentPrincipal().
MozReview-Commit-ID: 9as5ya2xXdL
--- a/dom/media/BufferMediaResource.h
+++ b/dom/media/BufferMediaResource.h
@@ -31,22 +31,16 @@ public:
}
protected:
virtual ~BufferMediaResource()
{
}
private:
- // Get the current principal for the channel
- already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override
- {
- nsCOMPtr<nsIPrincipal> principal = mPrincipal;
- return principal.forget();
- }
// These methods are called off the main thread.
nsresult ReadAt(int64_t aOffset, char* aBuffer,
uint32_t aCount, uint32_t* aBytes) override
{
if (aOffset < 0 || aOffset > mLength) {
return NS_ERROR_FAILURE;
}
*aBytes = std::min(mLength - static_cast<uint32_t>(aOffset), aCount);
--- a/dom/media/MediaResource.h
+++ b/dom/media/MediaResource.h
@@ -155,19 +155,16 @@ public:
// Our refcounting is threadsafe, and when our refcount drops to zero
// we dispatch an event to the main thread to delete the MediaResource.
// Note that this means it's safe for references to this object to be
// released on a non main thread, but the destructor will always run on
// the main thread.
NS_METHOD_(MozExternalRefCountType) AddRef(void);
NS_METHOD_(MozExternalRefCountType) Release(void);
- // Get the current principal for the channel
- virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() = 0;
-
// These methods are called off the main thread.
// Read up to aCount bytes from the stream. The read starts at
// aOffset in the stream, seeking to that location initially if
// it is not the current stream offset. The remaining arguments,
// results and requirements are the same as per the Read method.
virtual nsresult ReadAt(int64_t aOffset, char* aBuffer,
uint32_t aCount, uint32_t* aBytes) = 0;
// Indicate whether caching data in advance of reads is worth it.
@@ -285,16 +282,19 @@ public:
// The mode is initially MODE_PLAYBACK.
virtual void SetReadMode(MediaCacheStream::ReadMode aMode) = 0;
// Returns true if the resource can be seeked to unbuffered ranges, i.e.
// for an HTTP network stream this returns true if HTTP1.1 Byte Range
// requests are supported by the connection/server.
virtual bool IsTransportSeekable() = 0;
+ // Get the current principal for the channel
+ virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() = 0;
+
/**
* Open the stream. This creates a stream listener and returns it in
* aStreamListener; this listener needs to be notified of incoming data.
*/
virtual nsresult Open(nsIStreamListener** aStreamListener) = 0;
// If this returns false, then we shouldn't try to clone this MediaResource
// because its underlying resources are not suitable for reuse (e.g.
--- a/dom/media/gtest/MockMediaResource.h
+++ b/dom/media/gtest/MockMediaResource.h
@@ -11,20 +11,16 @@
namespace mozilla
{
class MockMediaResource : public MediaResource
{
public:
explicit MockMediaResource(const char* aFileName);
- already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override
- {
- return nullptr;
- }
nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount,
uint32_t* aBytes) override;
// Data stored in file, caching recommended.
bool ShouldCacheReads() override { return true; }
int64_t Tell() override { return 0; }
void Pin() override {}
void Unpin() override {}
int64_t GetLength() override;
--- a/dom/media/hls/HLSResource.h
+++ b/dom/media/hls/HLSResource.h
@@ -54,17 +54,17 @@ public:
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() override
+ already_AddRefed<nsIPrincipal> GetCurrentPrincipal()
{
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
nsCOMPtr<nsIPrincipal> principal;
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
if (!secMan || !mChannel)
return nullptr;
secMan->GetChannelResultPrincipal(mChannel, getter_AddRefs(principal));
--- a/dom/media/mediasource/MediaSourceResource.h
+++ b/dom/media/mediasource/MediaSourceResource.h
@@ -38,17 +38,17 @@ public:
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() override
+ already_AddRefed<nsIPrincipal> GetCurrentPrincipal()
{
return RefPtr<nsIPrincipal>(mPrincipal).forget();
}
nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
{
UNIMPLEMENTED();
aRanges += MediaByteRange(0, GetLength());
--- a/dom/media/mediasource/SourceBufferResource.h
+++ b/dom/media/mediasource/SourceBufferResource.h
@@ -26,21 +26,16 @@ class SourceBuffer;
} // namespace dom
// SourceBufferResource is not thread safe.
class SourceBufferResource final : public MediaResource
{
public:
SourceBufferResource();
nsresult Close();
- already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override
- {
- UNIMPLEMENTED();
- return nullptr;
- }
nsresult ReadAt(int64_t aOffset,
char* aBuffer,
uint32_t aCount,
uint32_t* aBytes) override;
// Memory-based and no locks, caching discouraged.
bool ShouldCacheReads() override { return false; }
int64_t Tell() override { return mOffset; }
void Pin() override { UNIMPLEMENTED(); }