Bug 1264199: P0. Fix nsDequeue/MediaQueue methods constness. r?jwwang,r?froydn
MozReview-Commit-ID: BiOedq3IHt
--- 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;