Bug 1057894 (Part 1) - Make VolatileBufferPtr's moveable. r=mwu

This commit is contained in:
Seth Fowler 2014-09-10 17:06:37 -07:00
parent 9b8255f0c4
commit c6bc53f6f4

View File

@ -91,6 +91,7 @@ public:
}
protected:
RefPtr<VolatileBuffer> mVBuf;
void* mMapping;
void Set(VolatileBuffer* vbuf) {
@ -100,7 +101,6 @@ protected:
}
private:
RefPtr<VolatileBuffer> mVBuf;
bool mPurged;
void Lock() {
@ -126,13 +126,30 @@ public:
explicit VolatileBufferPtr(VolatileBuffer* vbuf) : VolatileBufferPtr_base(vbuf) {}
VolatileBufferPtr() : VolatileBufferPtr_base(nullptr) {}
VolatileBufferPtr(VolatileBufferPtr&& aOther)
: VolatileBufferPtr_base(aOther.mVBuf)
{
aOther.Set(nullptr);
}
operator T*() const {
return (T*) mMapping;
}
void operator =(VolatileBuffer* vbuf) {
Set(vbuf);
VolatileBufferPtr& operator=(VolatileBuffer* aVBuf)
{
Set(aVBuf);
return *this;
}
VolatileBufferPtr& operator=(VolatileBufferPtr&& aOther)
{
MOZ_ASSERT(this != &aOther, "Self-moves are prohibited");
Set(aOther.mVBuf);
aOther.Set(nullptr);
return *this;
}
private:
VolatileBufferPtr(VolatileBufferPtr const& vbufptr) MOZ_DELETE;
};