/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class nsWeakReference final : public nsIWeakReference { public: // nsISupports...
NS_DECL_ISUPPORTS
// nsIWeakReference...
NS_DECL_NSIWEAKREFERENCE
private: friendclass nsSupportsWeakReference;
explicit nsWeakReference(nsSupportsWeakReference* aReferent)
: nsIWeakReference(aReferent) // ...I can only be constructed by an |nsSupportsWeakReference|
{}
~nsWeakReference() // ...I will only be destroyed by calling |delete| myself.
{
MOZ_WEAKREF_ASSERT_OWNINGTHREAD; if (mObject) { static_cast<nsSupportsWeakReference*>(mObject)->NoticeProxyDestruction();
}
}
void NoticeReferentDestruction() // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor.
{
MOZ_WEAKREF_ASSERT_OWNINGTHREAD;
mObject = nullptr;
}
};
nsresult nsQueryReferent::operator()(const nsIID& aIID, void** aAnswer) const {
nsresult status; if (mWeakPtr) { if (NS_FAILED(status = mWeakPtr->QueryReferent(aIID, aAnswer))) {
*aAnswer = 0;
}
} else {
status = NS_ERROR_NULL_POINTER;
}
if (mErrorPtr) {
*mErrorPtr = status;
} return status;
}
if (aInstancePtr) {
nsCOMPtr<nsISupportsWeakReference> factoryPtr =
do_QueryInterface(aInstancePtr, &status); if (factoryPtr) {
status = factoryPtr->GetWeakReference(&result);
} // else, |status| has already been set by |do_QueryInterface|
} else {
status = NS_ERROR_NULL_POINTER;
}
if (aErrorPtr) {
*aErrorPtr = status;
} return result;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.