Bug 1217692. Part 2 - fix some styles to keep 80 cols limit. r=jya.
authorJW Wang <jwwang@mozilla.com>
Mon, 26 Oct 2015 11:29:48 +0800
changeset 304645 2f1393553a489873366cee901b16f3440256ac50
parent 304644 64cbf3e1fe27105f6faee75b7449b9084797ed81
child 304646 8d3d0a2c6bbcf38a9d2a435ad912f3f3cfc94d66
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1217692
milestone44.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 1217692. Part 2 - fix some styles to keep 80 cols limit. r=jya.
dom/media/MediaDecoderReader.h
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -57,48 +57,54 @@ enum class ReadMetadataFailureReason : i
 // performed on a background thread, with the result being returned by
 // callback. Never hold the decoder monitor when calling into this class.
 // Unless otherwise specified, methods and fields of this class can only
 // be accessed on the decode task queue.
 class MediaDecoderReader {
   friend class ReRequestVideoWithSkipTask;
   friend class ReRequestAudioTask;
 
+  static const bool IsExclusive = true;
+
 public:
   enum NotDecodedReason {
     END_OF_STREAM,
     DECODE_ERROR,
     WAITING_FOR_DATA,
     CANCELED
   };
 
-  typedef MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, /* IsExclusive = */ true> MetadataPromise;
-  typedef MozPromise<RefPtr<MediaData>, NotDecodedReason, /* IsExclusive = */ true> AudioDataPromise;
-  typedef MozPromise<RefPtr<MediaData>, NotDecodedReason, /* IsExclusive = */ true> VideoDataPromise;
-  typedef MozPromise<int64_t, nsresult, /* IsExclusive = */ true> SeekPromise;
+  using MetadataPromise =
+    MozPromise<RefPtr<MetadataHolder>, ReadMetadataFailureReason, IsExclusive>;
+  using AudioDataPromise =
+    MozPromise<RefPtr<MediaData>, NotDecodedReason, IsExclusive>;
+  using VideoDataPromise =
+    MozPromise<RefPtr<MediaData>, NotDecodedReason, IsExclusive>;
+  using SeekPromise = MozPromise<int64_t, nsresult, IsExclusive>;
 
   // Note that, conceptually, WaitForData makes sense in a non-exclusive sense.
   // But in the current architecture it's only ever used exclusively (by MDSM),
   // so we mark it that way to verify our assumptions. If you have a use-case
   // for multiple WaitForData consumers, feel free to flip the exclusivity here.
-  typedef MozPromise<MediaData::Type, WaitForDataRejectValue, /* IsExclusive = */ true> WaitForDataPromise;
+  using WaitForDataPromise =
+    MozPromise<MediaData::Type, WaitForDataRejectValue, IsExclusive>;
 
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
 
   // The caller must ensure that Shutdown() is called before aDecoder is
   // destroyed.
   explicit MediaDecoderReader(AbstractMediaDecoder* aDecoder);
 
   // Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE
   // on failure.
   virtual nsresult Init() { return NS_OK; }
 
   // Release media resources they should be released in dormant state
   // The reader can be made usable again by calling ReadMetadata().
-  virtual void ReleaseMediaResources() {};
+  virtual void ReleaseMediaResources() {}
   // Breaks reference-counted cycles. Called during shutdown.
   // WARNING: If you override this, you must call the base implementation
   // in your override.
   virtual void BreakCycles();
 
   // Destroys the decoding state. The reader cannot be made usable again.
   // This is different from ReleaseMediaResources() as it is irreversable,
   // whereas ReleaseMediaResources() is.  Must be called on the decode
@@ -140,17 +146,21 @@ public:
   // the next keyframe at or after aTimeThreshold microseconds.
   virtual RefPtr<VideoDataPromise>
   RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold);
 
   // By default, the state machine polls the reader once per second when it's
   // in buffering mode. Some readers support a promise-based mechanism by which
   // they notify the state machine when the data arrives.
   virtual bool IsWaitForDataSupported() { return false; }
-  virtual RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType) { MOZ_CRASH(); }
+
+  virtual RefPtr<WaitForDataPromise> WaitForData(MediaData::Type aType)
+  {
+    MOZ_CRASH();
+  }
 
   // By default, the reader return the decoded data. Some readers support
   // retuning demuxed data.
   virtual bool IsDemuxOnlySupported() const { return false; }
 
   // Configure the reader to return demuxed or decoded data
   // upon calls to Request{Audio,Video}Data.
   virtual void SetDemuxOnly(bool /*aDemuxedOnly*/) {}
@@ -160,35 +170,34 @@ public:
 
   // The default implementation of AsyncReadMetadata is implemented in terms of
   // synchronous ReadMetadata() calls. Implementations may also
   // override AsyncReadMetadata to create a more proper async implementation.
   virtual RefPtr<MetadataPromise> AsyncReadMetadata();
 
   // Fills aInfo with the latest cached data required to present the media,
   // ReadUpdatedMetadata will always be called once ReadMetadata has succeeded.
-  virtual void ReadUpdatedMetadata(MediaInfo* aInfo) { };
+  virtual void ReadUpdatedMetadata(MediaInfo* aInfo) {}
 
   // Moves the decode head to aTime microseconds. aEndTime denotes the end
   // time of the media in usecs. This is only needed for OggReader, and should
   // probably be removed somehow.
-  virtual RefPtr<SeekPromise>
-  Seek(int64_t aTime, int64_t aEndTime) = 0;
+  virtual RefPtr<SeekPromise> Seek(int64_t aTime, int64_t aEndTime) = 0;
 
   // Called to move the reader into idle state. When the reader is
   // created it is assumed to be active (i.e. not idle). When the media
   // element is paused and we don't need to decode any more data, the state
   // machine calls SetIdle() to inform the reader that its decoder won't be
   // needed for a while. The reader can use these notifications to enter
   // a low power state when the decoder isn't needed, if desired.
   // This is most useful on mobile.
   // Note: DecodeVideoFrame, DecodeAudioData, ReadMetadata and Seek should
   // activate the decoder if necessary. The state machine only needs to know
   // when to call SetIdle().
-  virtual void SetIdle() { }
+  virtual void SetIdle() {}
 
 #ifdef MOZ_EME
   virtual void SetCDMProxy(CDMProxy* aProxy) {}
 #endif
 
   // Tell the reader that the data decoded are not for direct playback, so it
   // can accept more files, in particular those which have more channels than
   // available in the audio output.
@@ -218,47 +227,58 @@ public:
   virtual size_t SizeOfAudioQueueInFrames();
 
   // In situations where these notifications come from stochastic network
   // activity, we can save significant recomputation by throttling the delivery
   // of these updates to the reader implementation. We don't want to do this
   // throttling when the update comes from MSE code, since that code needs the
   // updates to be observable immediately, and is generally less
   // trigger-happy with notifications anyway.
-  void DispatchNotifyDataArrived(uint32_t aLength, int64_t aOffset, bool aThrottleUpdates)
+  void DispatchNotifyDataArrived(uint32_t aLength,
+                                 int64_t aOffset,
+                                 bool aThrottleUpdates)
   {
-    RefPtr<nsRunnable> r =
-      NS_NewRunnableMethodWithArg<media::Interval<int64_t>>(this, aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived
-                                                                                   : &MediaDecoderReader::NotifyDataArrived,
-                                                            media::Interval<int64_t>(aOffset, aOffset + aLength));
-    OwnerThread()->Dispatch(r.forget(), AbstractThread::DontAssertDispatchSuccess);
+    typedef media::Interval<int64_t> Interval;
+    RefPtr<nsRunnable> r = NS_NewRunnableMethodWithArg<Interval>(
+      this,
+      aThrottleUpdates ? &MediaDecoderReader::ThrottledNotifyDataArrived :
+                         &MediaDecoderReader::NotifyDataArrived,
+      Interval(aOffset, aOffset + aLength));
+
+    OwnerThread()->Dispatch(
+      r.forget(), AbstractThread::DontAssertDispatchSuccess);
   }
 
   void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
   {
     MOZ_ASSERT(OnTaskQueue());
     NS_ENSURE_TRUE_VOID(!mShutdown);
     NotifyDataArrivedInternal(aInfo.Length(), aInfo.mStart);
     UpdateBuffered();
   }
 
-  // Notify the reader that data from the resource was evicted (MediaSource only)
+  // Notify the reader that data from the resource was evicted
+  // (MediaSource only).
   virtual void NotifyDataRemoved() {}
 
   virtual MediaQueue<AudioData>& AudioQueue() { return mAudioQueue; }
   virtual MediaQueue<VideoData>& VideoQueue() { return mVideoQueue; }
 
   // Returns a pointer to the decoder.
-  AbstractMediaDecoder* GetDecoder() {
+  AbstractMediaDecoder* GetDecoder()
+  {
     return mDecoder;
   }
 
   MediaInfo GetMediaInfo() { return mInfo; }
 
-  AbstractCanonical<media::TimeIntervals>* CanonicalBuffered() { return &mBuffered; }
+  AbstractCanonical<media::TimeIntervals>* CanonicalBuffered()
+  {
+    return &mBuffered;
+  }
 
   // Indicates if the media is seekable.
   // ReadMetada should be called before calling this method.
   virtual bool IsMediaSeekable() = 0;
 
   void DispatchSetStartTime(int64_t aStartTime)
   {
     RefPtr<MediaDecoderReader> self = this;
@@ -268,33 +288,35 @@ public:
       MOZ_ASSERT(self->OnTaskQueue());
       MOZ_ASSERT(!self->HaveStartTime());
       self->mStartTime.emplace(aStartTime);
       self->UpdateBuffered();
     });
     OwnerThread()->Dispatch(r.forget());
   }
 
-  TaskQueue* OwnerThread() const {
+  TaskQueue* OwnerThread() const
+  {
     return mTaskQueue;
   }
 
   // Returns true if the reader implements RequestAudioData()
   // and RequestVideoData() asynchronously, rather than using the
   // implementation in this class to adapt the old synchronous to
   // the newer async model.
   virtual bool IsAsync() const { return false; }
 
   // Returns true if this decoder reader uses hardware accelerated video
   // decoding.
   virtual bool VideoIsHardwareAccelerated() const { return false; }
 
   virtual void DisableHardwareAcceleration() {}
 
-  TimedMetadataEventSource& TimedMetadataEvent() {
+  TimedMetadataEventSource& TimedMetadataEvent()
+  {
     return mTimedMetadataEvent;
   }
 
 protected:
   virtual ~MediaDecoderReader();
 
   // Populates aBuffered with the time ranges which are buffered. This may only
   // be called on the decode task queue, and should only be used internally by
@@ -311,17 +333,22 @@ protected:
   //
   // The OggReader relies on this base implementation not performing I/O,
   // since in FirefoxOS we can't do I/O on the main thread, where this is
   // called.
   virtual media::TimeIntervals GetBuffered();
 
   RefPtr<VideoDataPromise> DecodeToFirstVideoData();
 
-  bool HaveStartTime() { MOZ_ASSERT(OnTaskQueue()); return mStartTime.isSome(); }
+  bool HaveStartTime()
+  {
+    MOZ_ASSERT(OnTaskQueue());
+    return mStartTime.isSome();
+  }
+
   int64_t StartTime() { MOZ_ASSERT(HaveStartTime()); return mStartTime.ref(); }
 
   // Queue of audio frames. This queue is threadsafe, and is accessed from
   // the audio, decoder, state machine, and main threads.
   MediaQueue<AudioData> mAudioQueue;
 
   // Queue of video frames. This queue is threadsafe, and is accessed from
   // the decoder, state machine, and main threads.
@@ -393,43 +420,48 @@ private:
   // between the two (even though in practice, Init will always run first right
   // now thanks to the tail dispatcher).
   void InitializationTask();
 
   // Read header data for all bitstreams in the file. Fills aInfo with
   // the data required to present the media, and optionally fills *aTags
   // with tag metadata from the file.
   // Returns NS_OK on success, or NS_ERROR_FAILURE on failure.
-  virtual nsresult ReadMetadata(MediaInfo* aInfo,
-                                MetadataTags** aTags) { MOZ_CRASH(); }
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
+  {
+    MOZ_CRASH();
+  }
 
   // Recomputes mBuffered.
   virtual void UpdateBuffered();
 
-  virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) { }
+  virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) {}
 
-  // Invokes NotifyDataArrived while throttling the calls to occur at most every mThrottleDuration ms.
+  // Invokes NotifyDataArrived while throttling the calls to occur
+  // at most every mThrottleDuration ms.
   void ThrottledNotifyDataArrived(const media::Interval<int64_t>& aInterval);
   void DoThrottledNotify();
 
   // Overrides of this function should decodes an unspecified amount of
   // audio data, enqueuing the audio data in mAudioQueue. Returns true
   // when there's more audio to decode, false if the audio is finished,
   // end of file has been reached, or an un-recoverable read error has
   // occured. This function blocks until the decode is complete.
-  virtual bool DecodeAudioData() {
+  virtual bool DecodeAudioData()
+  {
     return false;
   }
 
   // Overrides of this function should read and decodes one video frame.
   // Packets with a timestamp less than aTimeThreshold will be decoded
   // (unless they're not keyframes and aKeyframeSkip is true), but will
   // not be added to the queue. This function blocks until the decode
   // is complete.
-  virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold) {
+  virtual bool DecodeVideoFrame(bool &aKeyframeSkip, int64_t aTimeThreshold)
+  {
     return false;
   }
 
   // Promises used only for the base-class (sync->async adapter) implementation
   // of Request{Audio,Video}Data.
   MozPromiseHolder<AudioDataPromise> mBaseAudioPromise;
   MozPromiseHolder<VideoDataPromise> mBaseVideoPromise;