mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 967364: Use every already_AddRefed. r=bsmedberg
This commit is contained in:
parent
2fd18dbde7
commit
56d26ad256
@ -5,6 +5,7 @@
|
||||
|
||||
#include "MediaStreamGraphImpl.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "AudioSegment.h"
|
||||
#include "VideoSegment.h"
|
||||
@ -24,6 +25,7 @@
|
||||
#include <algorithm>
|
||||
#include "DOMMediaStream.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::dom;
|
||||
@ -2387,7 +2389,7 @@ ProcessedMediaStream::AllocateInputPort(MediaStream* aStream, uint32_t aFlags,
|
||||
mPort->Init();
|
||||
// The graph holds its reference implicitly
|
||||
mPort->GraphImpl()->SetStreamOrderDirty();
|
||||
mPort.forget();
|
||||
unused << mPort.forget();
|
||||
}
|
||||
virtual void RunDuringShutdown()
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "nsSVGElement.h"
|
||||
|
||||
@ -49,6 +50,7 @@
|
||||
#include "nsAttrValueOrString.h"
|
||||
#include "nsSMILAnimationController.h"
|
||||
#include "mozilla/dom/SVGElementBinding.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -1363,7 +1365,7 @@ nsSVGElement::UpdateAnimatedContentStyleRule()
|
||||
SMIL_MAPPED_ATTR_STYLERULE_ATOM,
|
||||
animContentStyleRule.get(),
|
||||
ReleaseStyleRule);
|
||||
animContentStyleRule.forget();
|
||||
unused << animContentStyleRule.forget();
|
||||
NS_ABORT_IF_FALSE(rv == NS_OK,
|
||||
"SetProperty failed (or overwrote something)");
|
||||
}
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "ScriptSettings.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
// Other Classes
|
||||
#include "nsEventListenerManager.h"
|
||||
@ -11667,7 +11668,7 @@ nsGlobalWindow::SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
|
||||
}
|
||||
|
||||
// The timeout is now also held in the timer's closure.
|
||||
copy.forget();
|
||||
unused << copy.forget();
|
||||
} else {
|
||||
// If we are frozen, however, then we instead simply set
|
||||
// timeout->mTimeRemaining to be the "time remaining" in the timeout (i.e.,
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/ipc/ProtocolTypes.h"
|
||||
@ -677,7 +678,7 @@ private:
|
||||
{
|
||||
if (mTransport) {
|
||||
CRASH_IN_CHILD_PROCESS("Leaking transport!");
|
||||
mTransport.forget();
|
||||
unused << mTransport.forget();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1533,7 +1534,7 @@ ChildImpl::CreateCallbackRunnable::~CreateCallbackRunnable()
|
||||
{
|
||||
if (mActor) {
|
||||
CRASH_IN_CHILD_PROCESS("Leaking actor!");
|
||||
mActor.forget();
|
||||
unused << mActor.forget();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1676,7 +1677,7 @@ ChildImpl::OpenMainProcessActorRunnable::Run()
|
||||
}
|
||||
|
||||
// Now that Open() has succeeded transfer the ownership of the actors to IPDL.
|
||||
parentActor.forget();
|
||||
unused << parentActor.forget();
|
||||
|
||||
auto threadLocalInfo =
|
||||
static_cast<ThreadLocalInfo*>(PR_GetThreadPrivate(sThreadLocalIndex));
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsTextNode.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -803,7 +804,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
|
||||
if (NS_SUCCEEDED(aPresContext->PresShell()->PostReflowCallback(resize))) {
|
||||
// The reflow callback queue doesn't AddRef so we keep it alive until
|
||||
// it's released in its ReflowFinished / ReflowCallbackCanceled.
|
||||
resize.forget();
|
||||
unused << resize.forget();
|
||||
}
|
||||
|
||||
// Get the width of the vertical scrollbar. That will be the width of the
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <algorithm>
|
||||
#include "Http2Compression.h"
|
||||
#include "mozilla/ChaosMode.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
// defined by the socket transport service while active
|
||||
extern PRThread *gSocketThread;
|
||||
@ -333,7 +334,7 @@ nsHttpConnectionMgr::DoShiftReloadConnectionCleanup(nsHttpConnectionInfo *aCI)
|
||||
nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgDoShiftReloadConnectionCleanup,
|
||||
0, connInfo);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
connInfo.forget();
|
||||
unused << connInfo.forget();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -408,7 +409,7 @@ nsHttpConnectionMgr::SpeculativeConnect(nsHttpConnectionInfo *ci,
|
||||
nsresult rv =
|
||||
PostEvent(&nsHttpConnectionMgr::OnMsgSpeculativeConnect, 0, args);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
args.forget();
|
||||
unused << args.forget();
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -505,7 +506,7 @@ nsHttpConnectionMgr::UpdateRequestTokenBucket(EventTokenBucket *aBucket)
|
||||
nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket,
|
||||
0, bucket);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
bucket.forget();
|
||||
unused << bucket.forget();
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIURI.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
typedef mozilla::net::LoadContextInfo LoadContextInfo;
|
||||
|
||||
@ -38,7 +39,7 @@ public:
|
||||
NS_WARN_IF_FALSE(thread, "Couldn't get the main thread!");
|
||||
if (thread) {
|
||||
nsIWyciwygChannel *chan = static_cast<nsIWyciwygChannel *>(mChannel);
|
||||
mChannel.forget();
|
||||
mozilla::unused << mChannel.forget();
|
||||
NS_ProxyRelease(thread, chan);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "nsHtml5Atom.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
nsHtml5Atom::nsHtml5Atom(const nsAString& aString)
|
||||
{
|
||||
@ -24,7 +25,7 @@ nsHtml5Atom::nsHtml5Atom(const nsAString& aString)
|
||||
NS_ASSERTION(Equals(aString), "correct data");
|
||||
|
||||
// Take ownership of buffer
|
||||
buf.forget();
|
||||
mozilla::unused << buf.forget();
|
||||
}
|
||||
|
||||
nsHtml5Atom::~nsHtml5Atom()
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsIDiskSpaceWatcher.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
@ -55,6 +56,7 @@
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -405,7 +407,7 @@ nsOfflineCacheUpdateService::ScheduleOnDocumentStop(nsIURI *aManifestURI,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// The update will release when it has scheduled itself.
|
||||
update.forget();
|
||||
unused << update.forget();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -36,12 +36,14 @@
|
||||
#include "prdtoa.h"
|
||||
#include "prenv.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "GLConsts.h"
|
||||
#include "LayerScope.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
#include "nsAccessibilityService.h"
|
||||
@ -189,8 +191,8 @@ void nsBaseWidget::DestroyCompositor()
|
||||
mCompositorChild));
|
||||
// The DestroyCompositor task we just added to the MessageLoop will handle
|
||||
// releasing mCompositorParent and mCompositorChild.
|
||||
mCompositorParent.forget();
|
||||
mCompositorChild.forget();
|
||||
unused << mCompositorParent.forget();
|
||||
unused << mCompositorChild.forget();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "nsAtomTable.h"
|
||||
#include "nsStaticAtom.h"
|
||||
@ -344,7 +345,7 @@ AtomImpl::AtomImpl(const nsAString& aString, uint32_t aHash)
|
||||
NS_ASSERTION(Equals(aString), "correct data");
|
||||
|
||||
// Take ownership of buffer
|
||||
buf.forget();
|
||||
mozilla::unused << buf.forget();
|
||||
}
|
||||
|
||||
AtomImpl::AtomImpl(nsStringBuffer* aStringBuffer, uint32_t aLength,
|
||||
|
@ -118,6 +118,12 @@
|
||||
#define NSCAP_LOG_RELEASE(this, ptr)
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
struct unused_t;
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
template <class T>
|
||||
struct already_AddRefed
|
||||
/*
|
||||
@ -156,7 +162,33 @@ struct already_AddRefed
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
T* take() const { return mRawPtr; }
|
||||
already_AddRefed(const already_AddRefed<T>& aOther)
|
||||
: mRawPtr(aOther.take())
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
~already_AddRefed()
|
||||
{
|
||||
MOZ_ASSERT(!mRawPtr);
|
||||
}
|
||||
|
||||
// Specialize the unused operator<< for already_AddRefed, to allow
|
||||
// nsCOMPtr<nsIFoo> foo;
|
||||
// unused << foo.forget();
|
||||
friend void operator<<(const mozilla::unused_t& unused,
|
||||
const already_AddRefed<T>& rhs)
|
||||
{
|
||||
auto mutableAlreadyAddRefed = const_cast<already_AddRefed<T>*>(&rhs);
|
||||
unused << mutableAlreadyAddRefed->take();
|
||||
}
|
||||
|
||||
T* take()
|
||||
{
|
||||
T* rawPtr = mRawPtr;
|
||||
mRawPtr = nullptr;
|
||||
return rawPtr;
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper is useful in cases like
|
||||
|
Loading…
Reference in New Issue
Block a user