зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1336510 - Part 7: Stop capturing this by value in windows-only code, r=aklotz
MozReview-Commit-ID: B4dYo4ETzkL
This commit is contained in:
Родитель
4ed3440974
Коммит
ac9295ead2
|
@ -13,6 +13,7 @@
|
|||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
using mozilla::DebugOnly;
|
||||
|
||||
|
@ -107,12 +108,11 @@ MainThreadHandoff::Release()
|
|||
if (NS_IsMainThread()) {
|
||||
delete this;
|
||||
} else {
|
||||
mozilla::DebugOnly<nsresult> rv =
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void
|
||||
{
|
||||
delete this;
|
||||
}));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
// We need to delete this object on the main thread, but we aren't on the
|
||||
// main thread right now, so we send a reference to ourselves to the main
|
||||
// thread to be re-released there.
|
||||
RefPtr<MainThreadHandoff> self = this;
|
||||
NS_ReleaseOnMainThread(self.forget());
|
||||
}
|
||||
}
|
||||
return newRefCnt;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/Mutex.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsWindowsHelpers.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
static void
|
||||
InitializeCS(CRITICAL_SECTION& aCS)
|
||||
|
@ -147,14 +148,11 @@ WeakReferenceSupport::Release()
|
|||
if (mFlags != Flags::eDestroyOnMainThread || NS_IsMainThread()) {
|
||||
delete this;
|
||||
} else {
|
||||
// It is possible for the last Release() call to happen off-main-thread.
|
||||
// If so, we need to dispatch an event to delete ourselves.
|
||||
mozilla::DebugOnly<nsresult> rv =
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction([this]() -> void
|
||||
{
|
||||
delete this;
|
||||
}));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
// We need to delete this object on the main thread, but we aren't on the
|
||||
// main thread right now, so we send a reference to ourselves to the main
|
||||
// thread to be re-released there.
|
||||
RefPtr<WeakReferenceSupport> self = this;
|
||||
NS_ReleaseOnMainThread(self.forget());
|
||||
}
|
||||
}
|
||||
return newRefCnt;
|
||||
|
|
Загрузка…
Ссылка в новой задаче