Bug 1394651 - remove MediaResource from the base class of HLSResource. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 25 Aug 2017 14:03:45 +0800
changeset 654641 704ac308b4c696a1581969aadc9d73d766d75a11
parent 654639 b3d51ee17d672c3baff64ea404979263f5f2a709
child 654642 99de50c7c14630a85b125b4da3c301c7d4dc507b
push id76627
push userjwwang@mozilla.com
push dateTue, 29 Aug 2017 02:42:55 +0000
bugs1394651
milestone57.0a1
Bug 1394651 - remove MediaResource from the base class of HLSResource. MozReview-Commit-ID: 3RaLXA1kKzA
dom/media/hls/HLSDecoder.cpp
dom/media/hls/HLSDecoder.h
dom/media/hls/HLSResource.h
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -68,17 +68,17 @@ HLSDecoder::Load(nsIChannel* aChannel)
   MOZ_ASSERT(!mResource);
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  mResource = new HLSResource(this, aChannel, uri);
+  mResource = MakeUnique<HLSResource>(this, aChannel, uri);
 
   rv = MediaShutdownManager::Instance().Register(this);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   SetStateMachine(CreateStateMachine());
   NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE);
--- a/dom/media/hls/HLSDecoder.h
+++ b/dom/media/hls/HLSDecoder.h
@@ -53,14 +53,14 @@ private:
   {
     // TODO: We don't know how to estimate 'canplaythrough' for this decoder.
     // For now we just return true for 'autoplay' can work.
     return true;
   }
 
   bool IsLiveStream() override final { return false; }
 
-  RefPtr<HLSResource> mResource;
+  UniquePtr<HLSResource> mResource;
 };
 
 } // namespace mozilla
 
 #endif /* HLSDecoder_h_ */
--- a/dom/media/hls/HLSResource.h
+++ b/dom/media/hls/HLSResource.h
@@ -5,21 +5,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef HLSResource_h_
 #define HLSResource_h_
 
 #include "GeneratedJNINatives.h"
 #include "GeneratedJNIWrappers.h"
 #include "HLSUtils.h"
-#include "MediaResource.h"
 #include "nsContentUtils.h"
 
-#define UNIMPLEMENTED() HLS_DEBUG("HLSResource", "UNIMPLEMENTED FUNCTION")
-
 using namespace mozilla::java;
 
 namespace mozilla {
 
 class HLSDecoder;
 class HLSResource;
 
 class HLSResourceCallbacksSupport
@@ -36,52 +33,36 @@ public:
   void OnDataArrived();
   void OnError(int aErrorCode);
 
 private:
   ~HLSResourceCallbacksSupport() {}
   HLSResource* mResource;
 };
 
-class HLSResource final : public MediaResource
+class HLSResource final
 {
 public:
   HLSResource(HLSDecoder* aDecoder, nsIChannel* aChannel, nsIURI* aURI);
   ~HLSResource();
   void Suspend();
   void Resume();
-  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()
   {
     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));
     return principal.forget();
   }
 
-  nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override
-  {
-    UNIMPLEMENTED();
-    return NS_OK;
-  }
-
   java::GeckoHLSResourceWrapper::GlobalRef GetResourceWrapper() {
     return mHLSResourceWrapper;
   }
 
   void Detach() { mDecoder = nullptr; }
 
   size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
   {