Bug 1264199: P0. Fix nsDequeue/MediaQueue methods constness. r?jwwang,r?froydn draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 25 Apr 2016 12:13:55 +1000
changeset 356262 227854dfb623e7cb8ed5e73ef0bc66043e509944
parent 356261 6dea77da7a76062a676111d78c8290306cf3b817
child 356263 ac085003b82e7fd76ab4c3302ab716edcbc45f09
child 356279 ad5d064e03fb123f6bdceff00df385ac75321a7a
push id16483
push userbmo:jyavenard@mozilla.com
push dateTue, 26 Apr 2016 02:13:35 +0000
reviewersjwwang, froydn
bugs1264199
milestone49.0a1
Bug 1264199: P0. Fix nsDequeue/MediaQueue methods constness. r?jwwang,r?froydn MozReview-Commit-ID: BiOedq3IHt
dom/media/MediaQueue.h
xpcom/glue/nsDeque.cpp
xpcom/glue/nsDeque.h
--- a/dom/media/MediaQueue.h
+++ b/dom/media/MediaQueue.h
@@ -31,17 +31,17 @@ public:
       mReentrantMonitor("mediaqueue"),
       mEndOfStream(false)
   {}
 
   ~MediaQueue() {
     Reset();
   }
 
-  inline size_t GetSize() {
+  inline size_t GetSize() const {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return nsDeque::GetSize();
   }
 
   inline void Push(T* aItem) {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     MOZ_ASSERT(aItem);
     NS_ADDREF(aItem);
@@ -60,43 +60,43 @@ public:
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     RefPtr<T> rv = dont_AddRef(static_cast<T*>(nsDeque::PopFront()));
     if (rv) {
       mPopEvent.Notify(rv);
     }
     return rv.forget();
   }
 
-  inline RefPtr<T> Peek() {
+  inline RefPtr<T> Peek() const {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return static_cast<T*>(nsDeque::Peek());
   }
 
-  inline RefPtr<T> PeekFront() {
+  inline RefPtr<T> PeekFront() const {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return static_cast<T*>(nsDeque::PeekFront());
   }
 
   void Reset() {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     while (GetSize() > 0) {
       RefPtr<T> x = dont_AddRef(static_cast<T*>(nsDeque::PopFront()));
     }
     mEndOfStream = false;
   }
 
-  bool AtEndOfStream() {
+  bool AtEndOfStream() const {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return GetSize() == 0 && mEndOfStream;
   }
 
   // Returns true if the media queue has had its last item added to it.
   // This happens when the media stream has been completely decoded. Note this
   // does not mean that the corresponding stream has finished playback.
-  bool IsFinished() {
+  bool IsFinished() const {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mEndOfStream;
   }
 
   // Informs the media queue that it won't be receiving any more items.
   void Finish() {
     ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mEndOfStream = true;
--- a/xpcom/glue/nsDeque.cpp
+++ b/xpcom/glue/nsDeque.cpp
@@ -295,33 +295,33 @@ nsDeque::PopFront()
 
 /**
  * This method gets called you want to peek at the bottom
  * member without removing it.
  *
  * @return  last item in container
  */
 void*
-nsDeque::Peek()
+nsDeque::Peek() const
 {
   void* result = 0;
   if (mSize > 0) {
     result = mData[modulus(mSize - 1 + mOrigin, mCapacity)];
   }
   return result;
 }
 
 /**
  * This method gets called you want to peek at the topmost
  * member without removing it.
  *
  * @return  last item in container
  */
 void*
-nsDeque::PeekFront()
+nsDeque::PeekFront() const
 {
   void* result = 0;
   if (mSize > 0) {
     result = mData[mOrigin];
   }
   return result;
 }
 
--- a/xpcom/glue/nsDeque.h
+++ b/xpcom/glue/nsDeque.h
@@ -119,23 +119,23 @@ public:
   void* PopFront();
 
   /**
    * Retrieve the bottom item without removing it.
    *
    * @return  the first item in container
    */
 
-  void* Peek();
+  void* Peek() const;
   /**
    * Return topmost item without removing it.
    *
    * @return  the first item in container
    */
-  void* PeekFront();
+  void* PeekFront() const;
 
   /**
    * Retrieve a member from the deque without removing it.
    *
    * @param   index of desired item
    * @return  element in list
    */
   void* ObjectAt(size_t aIndex) const;