зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1605130. Make it harder to misuse OwningNonNull::forget. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D57805 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e649934e9f
Коммит
0e01c0c207
|
@ -68,21 +68,6 @@ class MOZ_IS_SMARTPTR_TO_REFCOUNTED OwningNonNull {
|
|||
// Don't allow assigning nullptr, it makes no sense
|
||||
void operator=(decltype(nullptr)) = delete;
|
||||
|
||||
already_AddRefed<T> forget() {
|
||||
#ifdef DEBUG
|
||||
mInited = false;
|
||||
#endif
|
||||
return mPtr.forget();
|
||||
}
|
||||
|
||||
template <class U>
|
||||
void forget(U** aOther) {
|
||||
#ifdef DEBUG
|
||||
mInited = false;
|
||||
#endif
|
||||
mPtr.forget(aOther);
|
||||
}
|
||||
|
||||
T& ref() const {
|
||||
MOZ_ASSERT(mInited);
|
||||
MOZ_ASSERT(mPtr, "OwningNonNull<T> was set to null");
|
||||
|
@ -112,6 +97,17 @@ class MOZ_IS_SMARTPTR_TO_REFCOUNTED OwningNonNull {
|
|||
return mPtr;
|
||||
}
|
||||
|
||||
private:
|
||||
already_AddRefed<T> forget() {
|
||||
#ifdef DEBUG
|
||||
mInited = false;
|
||||
#endif
|
||||
return mPtr.forget();
|
||||
}
|
||||
|
||||
// Allow ImplCycleCollectionUnlink to call forget().
|
||||
friend void ImplCycleCollectionUnlink(OwningNonNull<T>& aField);
|
||||
|
||||
protected:
|
||||
template <typename U>
|
||||
void init(U&& aValue) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче