Bug 905513 - Annotate functions with virtual/MOZ_OVERRIDE and document use of SBR monitor.
authorMatthew Gregan <kinetik@flim.org>
Fri, 27 Sep 2013 17:22:38 +1200
changeset 148933 a98471699e919ec06e6f6d555e9e7608862fbc93
parent 148932 1a134e410e123bd145fe8a6239ca50114282e8fe
child 148934 473c72edc9ca5589bf416364fe0b50335b7161f1
push id34385
push usermgregan@mozilla.com
push dateFri, 27 Sep 2013 05:23:17 +0000
treeherdermozilla-inbound@808a8b288ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs905513
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 905513 - Annotate functions with virtual/MOZ_OVERRIDE and document use of SBR monitor.
content/media/BufferDecoder.h
content/media/mediasource/AsyncEventRunner.h
content/media/mediasource/MediaSourceDecoder.h
content/media/mediasource/SourceBufferResource.h
content/media/mediasource/SubBufferDecoder.h
--- a/content/media/BufferDecoder.h
+++ b/content/media/BufferDecoder.h
@@ -25,59 +25,59 @@ public:
   explicit BufferDecoder(MediaResource* aResource);
   virtual ~BufferDecoder();
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
   // This has to be called before decoding begins
   void BeginDecoding(nsIThread* aDecodeThread);
 
-  ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
+  virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
 
-  bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE;
+  virtual bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE;
 
-  bool OnStateMachineThread() const MOZ_OVERRIDE;
+  virtual bool OnStateMachineThread() const MOZ_OVERRIDE;
 
-  bool OnDecodeThread() const MOZ_OVERRIDE;
+  virtual bool OnDecodeThread() const MOZ_OVERRIDE;
 
-  MediaResource* GetResource() const MOZ_OVERRIDE;
+  virtual MediaResource* GetResource() const MOZ_OVERRIDE;
 
-  void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE;
+  virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE;
 
-  void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE;
+  virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE;
 
-  int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE;
+  virtual int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE;
 
-  int64_t GetMediaDuration() MOZ_FINAL MOZ_OVERRIDE;
+  virtual int64_t GetMediaDuration() MOZ_FINAL MOZ_OVERRIDE;
 
-  void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
+  virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
 
-  void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
+  virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
 
-  void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
+  virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
 
-  void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE;
+  virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE;
 
-  VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
-  layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
+  virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
+  virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
 
-  bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE;
+  virtual bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE;
 
-  bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE;
+  virtual bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE;
 
-  void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
-  void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
+  virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
+  virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
 
-  void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
+  virtual void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
 
-  void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
+  virtual void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
 
-  void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE;
+  virtual void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE;
 
-  MediaDecoderOwner* GetOwner() MOZ_FINAL MOZ_OVERRIDE;
+  virtual MediaDecoderOwner* GetOwner() MOZ_FINAL MOZ_OVERRIDE;
 
 protected:
   // This monitor object is not really used to synchronize access to anything.
   // It's just there in order for us to be able to override
   // GetReentrantMonitor correctly.
   ReentrantMonitor mReentrantMonitor;
   nsCOMPtr<nsIThread> mDecodeThread;
   nsRefPtr<MediaResource> mResource;
--- a/content/media/mediasource/AsyncEventRunner.h
+++ b/content/media/mediasource/AsyncEventRunner.h
@@ -15,17 +15,17 @@ template <typename T>
 class AsyncEventRunner : public nsRunnable
 {
 public:
   AsyncEventRunner(T* aTarget, const char* aName)
     : mTarget(aTarget)
     , mName(aName)
   {}
 
-  NS_IMETHOD Run()
+  NS_IMETHOD Run() MOZ_OVERRIDE
   {
     mTarget->DispatchSimpleEvent(mName);
     return NS_OK;
   }
 
 private:
   nsRefPtr<T> mTarget;
   const char* mName;
--- a/content/media/mediasource/MediaSourceDecoder.h
+++ b/content/media/mediasource/MediaSourceDecoder.h
@@ -33,19 +33,19 @@ class MediaSource;
 
 } // namespace dom
 
 class MediaSourceDecoder : public MediaDecoder
 {
 public:
   MediaSourceDecoder(HTMLMediaElement* aElement);
 
-  MediaDecoder* Clone() MOZ_OVERRIDE;
-  MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE;
-  nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE;
+  virtual MediaDecoder* Clone() MOZ_OVERRIDE;
+  virtual MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE;
+  virtual nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE;
 
   void AttachMediaSource(MediaSource* aMediaSource);
   void DetachMediaSource();
 
   SubBufferDecoder* CreateSubDecoder(const nsACString& aType);
 
   const nsTArray<MediaDecoderReader*>& GetReaders()
   {
@@ -86,161 +86,52 @@ private:
 
   MediaDecoderReader* mVideoReader;
   MediaDecoderReader* mAudioReader;
 };
 
 class MediaSourceResource MOZ_FINAL : public MediaResource
 {
 public:
-  MediaSourceResource()
-  {
-  }
-
-  nsresult Close()
-  {
-    return NS_OK;
-  }
-
-  void Suspend(bool aCloseImmediately)
-  {
-  }
-
-  void Resume()
-  {
-  }
-
-  already_AddRefed<nsIPrincipal> GetCurrentPrincipal()
-  {
-    return nullptr;
-  }
-
-  bool CanClone()
-  {
-    return false;
-  }
-
-  already_AddRefed<MediaResource> CloneData(MediaDecoder* aDecoder)
-  {
-    return nullptr;
-  }
-
-  void SetReadMode(MediaCacheStream::ReadMode aMode)
-  {
-  }
-
-  void SetPlaybackRate(uint32_t aBytesPerSecond)
-  {
-  }
-
-  nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-  nsresult Seek(int32_t aWhence, int64_t aOffset)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-  void StartSeekingForMetadata()
-  {
-  }
-
-  void EndSeekingForMetadata()
-  {
-  }
+  MediaSourceResource() {}
 
-  int64_t Tell()
-  {
-    return -1;
-  }
-
-  void Pin()
-  {
-  }
-
-  void Unpin()
-  {
-  }
-
-  double GetDownloadRate(bool* aIsReliable)
-  {
-    return 0;
-  }
-
-  int64_t GetLength()
-  {
-    return -1;
-  }
-
-  int64_t GetNextCachedData(int64_t aOffset)
-  {
-    return aOffset;
-  }
-
-  int64_t GetCachedDataEnd(int64_t aOffset)
-  {
-    return GetLength();
-  }
+  virtual nsresult Close() MOZ_OVERRIDE { return NS_OK; }
+  virtual void Suspend(bool aCloseImmediately) MOZ_OVERRIDE {}
+  virtual void Resume() MOZ_OVERRIDE {}
+  virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() MOZ_OVERRIDE { return nullptr; }
+  virtual bool CanClone() MOZ_OVERRIDE { return false; }
+  virtual already_AddRefed<MediaResource> CloneData(MediaDecoder* aDecoder) MOZ_OVERRIDE { return nullptr; }
+  virtual void SetReadMode(MediaCacheStream::ReadMode aMode) MOZ_OVERRIDE {}
+  virtual void SetPlaybackRate(uint32_t aBytesPerSecond) MOZ_OVERRIDE  {}
+  virtual nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
+  virtual nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
+  virtual nsresult Seek(int32_t aWhence, int64_t aOffset) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
+  virtual void StartSeekingForMetadata() MOZ_OVERRIDE {}
+  virtual void EndSeekingForMetadata() MOZ_OVERRIDE {}
+  virtual int64_t Tell() MOZ_OVERRIDE { return -1; }
+  virtual void Pin() MOZ_OVERRIDE {}
+  virtual void Unpin() MOZ_OVERRIDE {}
+  virtual double GetDownloadRate(bool* aIsReliable) MOZ_OVERRIDE { return 0; }
+  virtual int64_t GetLength() MOZ_OVERRIDE { return -1; }
+  virtual int64_t GetNextCachedData(int64_t aOffset) MOZ_OVERRIDE { return aOffset; }
+  virtual int64_t GetCachedDataEnd(int64_t aOffset) MOZ_OVERRIDE { return GetLength(); }
+  virtual bool IsDataCachedToEndOfResource(int64_t aOffset) MOZ_OVERRIDE { return true; }
+  virtual bool IsSuspendedByCache() MOZ_OVERRIDE { return false; }
+  virtual bool IsSuspended() MOZ_OVERRIDE { return false; }
+  virtual nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
+  virtual nsresult Open(nsIStreamListener** aStreamListener) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
 
-  bool IsDataCachedToEndOfResource(int64_t aOffset)
-  {
-    return true;
-  }
-
-  bool IsSuspendedByCache()
-  {
-    return false;
-  }
-
-  bool IsSuspended()
-  {
-    return false;
-  }
-
-  nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-
-  nsresult Open(nsIStreamListener** aStreamListener)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-#ifdef MOZ_DASH
-  nsresult OpenByteRange(nsIStreamListener** aStreamListener,
-                         const MediaByteRange& aByteRange)
-  {
-    return NS_ERROR_FAILURE;
-  }
-#endif
-
-  nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges)
+  virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) MOZ_OVERRIDE
   {
     aRanges.AppendElement(MediaByteRange(0, GetLength()));
     return NS_OK;
   }
 
-  bool IsTransportSeekable() MOZ_OVERRIDE
-  {
-    return true;
-  }
-
-  const nsCString& GetContentType() const MOZ_OVERRIDE
-  {
-    return mType;
-  }
+  virtual bool IsTransportSeekable() MOZ_OVERRIDE { return true; }
+  virtual const nsCString& GetContentType() const MOZ_OVERRIDE { return mType; }
 
 private:
   const nsAutoCString mType;
 };
 
 } // namespace mozilla
 
 #endif /* MOZILLA_MEDIASOURCEDECODER_H_ */
--- a/content/media/mediasource/SourceBufferResource.h
+++ b/content/media/mediasource/SourceBufferResource.h
@@ -32,112 +32,71 @@ class SourceBuffer;
 
 class SourceBufferResource MOZ_FINAL : public MediaResource
 {
 public:
   SourceBufferResource(nsIPrincipal* aPrincipal,
                        const nsACString& aType);
   ~SourceBufferResource();
 
-  nsresult Close();
-  void Suspend(bool aCloseImmediately) {}
-  void Resume() {}
+  virtual nsresult Close() MOZ_OVERRIDE;
+  virtual void Suspend(bool aCloseImmediately) MOZ_OVERRIDE {}
+  virtual void Resume() MOZ_OVERRIDE {}
 
-  already_AddRefed<nsIPrincipal> GetCurrentPrincipal()
+  virtual already_AddRefed<nsIPrincipal> GetCurrentPrincipal() MOZ_OVERRIDE
   {
     return nsCOMPtr<nsIPrincipal>(mPrincipal).forget();
   }
 
-  bool CanClone()
-  {
-    return false;
-  }
-
-  already_AddRefed<MediaResource> CloneData(MediaDecoder* aDecoder)
+  virtual already_AddRefed<MediaResource> CloneData(MediaDecoder* aDecoder) MOZ_OVERRIDE
   {
     return nullptr;
   }
 
-  void SetReadMode(MediaCacheStream::ReadMode aMode)
-  {
-  }
-
-  void SetPlaybackRate(uint32_t aBytesPerSecond)
-  {
-  }
-
-  nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes);
-  nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes);
-  nsresult Seek(int32_t aWhence, int64_t aOffset);
-
-  void StartSeekingForMetadata()
-  {
-  }
-
-  void EndSeekingForMetadata()
-  {
-  }
-
-  int64_t Tell()
-  {
-    return mOffset;
-  }
+  virtual void SetReadMode(MediaCacheStream::ReadMode aMode) MOZ_OVERRIDE {}
+  virtual void SetPlaybackRate(uint32_t aBytesPerSecond) MOZ_OVERRIDE {}
+  virtual nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE;
+  virtual nsresult ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) MOZ_OVERRIDE;
+  virtual nsresult Seek(int32_t aWhence, int64_t aOffset) MOZ_OVERRIDE;
+  virtual void StartSeekingForMetadata() MOZ_OVERRIDE { }
+  virtual void EndSeekingForMetadata() MOZ_OVERRIDE {}
+  virtual int64_t Tell() MOZ_OVERRIDE { return mOffset; }
+  virtual void Pin() MOZ_OVERRIDE {}
+  virtual void Unpin() MOZ_OVERRIDE {}
+  virtual double GetDownloadRate(bool* aIsReliable) MOZ_OVERRIDE { return 0; }
+  virtual int64_t GetLength() MOZ_OVERRIDE { return mInputBuffer.Length(); }
+  virtual int64_t GetNextCachedData(int64_t aOffset) MOZ_OVERRIDE { return aOffset; }
+  virtual int64_t GetCachedDataEnd(int64_t aOffset) MOZ_OVERRIDE { return GetLength(); }
+  virtual bool IsDataCachedToEndOfResource(int64_t aOffset) MOZ_OVERRIDE { return true; }
+  virtual bool IsSuspendedByCache() MOZ_OVERRIDE { return false; }
+  virtual bool IsSuspended() MOZ_OVERRIDE { return false; }
+  virtual nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) MOZ_OVERRIDE;
+  virtual bool IsTransportSeekable() MOZ_OVERRIDE { return true; }
+  virtual nsresult Open(nsIStreamListener** aStreamListener) MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
 
-  void Pin()
-  {
-  }
-
-  void Unpin()
-  {
-  }
-
-  double GetDownloadRate(bool* aIsReliable) { return 0; }
-  int64_t GetLength() { return mInputBuffer.Length(); }
-  int64_t GetNextCachedData(int64_t aOffset) { return aOffset; }
-  int64_t GetCachedDataEnd(int64_t aOffset) { return GetLength(); }
-  bool IsDataCachedToEndOfResource(int64_t aOffset) { return true; }
-  bool IsSuspendedByCache() { return false; }
-  bool IsSuspended() { return false; }
-  nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount);
-
-  nsresult Open(nsIStreamListener** aStreamListener)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-#ifdef MOZ_DASH
-  nsresult OpenByteRange(nsIStreamListener** aStreamListener,
-                         const MediaByteRange& aByteRange)
-  {
-    return NS_ERROR_FAILURE;
-  }
-#endif
-
-  nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges)
+  virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges) MOZ_OVERRIDE
   {
     aRanges.AppendElement(MediaByteRange(0, GetLength()));
     return NS_OK;
   }
 
-  bool IsTransportSeekable() MOZ_OVERRIDE { return true; }
-
-  const nsCString& GetContentType() const MOZ_OVERRIDE
-  {
-    return mType;
-  }
+  virtual const nsCString& GetContentType() const MOZ_OVERRIDE { return mType; }
 
   // Used by SourceBuffer.
   void AppendData(const uint8_t* aData, uint32_t aLength);
   void Ended();
 
 private:
   nsCOMPtr<nsIPrincipal> mPrincipal;
   const nsAutoCString mType;
 
   // Provides synchronization between SourceBuffers and InputAdapters.
+  // Protects all of the member variables below.  Read() will await a
+  // Notify() (from Seek, AppendData, Ended, or Close) when insufficient
+  // data is available in mData.
   ReentrantMonitor mMonitor;
   nsTArray<uint8_t> mInputBuffer;
 
   int64_t mOffset;
   bool mClosed;
   bool mEnded;
 };
 
--- a/content/media/mediasource/SubBufferDecoder.h
+++ b/content/media/mediasource/SubBufferDecoder.h
@@ -25,25 +25,25 @@ public:
   }
 
   void SetReader(MediaDecoderReader* aReader)
   {
     MOZ_ASSERT(!mReader);
     mReader = aReader;
   }
 
-  ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
-  bool OnStateMachineThread() const MOZ_OVERRIDE;
-  bool OnDecodeThread() const MOZ_OVERRIDE;
-  SourceBufferResource* GetResource() const MOZ_OVERRIDE;
-  void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
-  void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
-  void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
-  void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE;
-  layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
+  virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
+  virtual bool OnStateMachineThread() const MOZ_OVERRIDE;
+  virtual bool OnDecodeThread() const MOZ_OVERRIDE;
+  virtual SourceBufferResource* GetResource() const MOZ_OVERRIDE;
+  virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
+  virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
+  virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
+  virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE;
+  virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
 
   void NotifyDataArrived(const char* aBuffer, uint32_t aLength, int64_t aOffset)
   {
     mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
 
     // XXX: aOffset makes no sense here, need view of "data timeline".
     mParentDecoder->NotifyDataArrived(aBuffer, aLength, aOffset);
   }