Backed out 2 changesets (bug 1882698) for causing build bustages @ gtest/internal/gtest-internal.h CLOSED TREE

Backed out changeset 0c82ff77321a (bug 1882698)
Backed out changeset cc4cf5f6e66a (bug 1882698)
This commit is contained in:
Sandor Molnar 2024-03-14 10:14:11 +02:00
Родитель 46bc8aab00
Коммит b58ddfc546
4 изменённых файлов: 3 добавлений и 147 удалений

Просмотреть файл

@ -50,25 +50,13 @@ bool nsAutoOwningThread::IsCurrentThread() const {
nsAutoOwningEventTarget::nsAutoOwningEventTarget()
: mTarget(GetCurrentSerialEventTarget()) {
NS_ADDREF(mTarget);
mTarget->AddRef();
}
nsAutoOwningEventTarget::nsAutoOwningEventTarget(
const nsAutoOwningEventTarget& aOther)
: mTarget(aOther.mTarget) {
NS_ADDREF(mTarget);
nsAutoOwningEventTarget::~nsAutoOwningEventTarget() {
nsCOMPtr<nsISerialEventTarget> target = dont_AddRef(mTarget);
}
nsAutoOwningEventTarget& nsAutoOwningEventTarget::operator=(
const nsAutoOwningEventTarget& aRhs) {
nsISerialEventTarget* previous = std::exchange(mTarget, aRhs.mTarget);
NS_ADDREF(mTarget);
NS_RELEASE(previous);
return *this;
}
nsAutoOwningEventTarget::~nsAutoOwningEventTarget() { NS_RELEASE(mTarget); }
void nsAutoOwningEventTarget ::AssertCurrentThreadOwnsMe(
const char* msg) const {
if (MOZ_UNLIKELY(!IsCurrentThread())) {

Просмотреть файл

@ -71,20 +71,6 @@ class nsISerialEventTarget;
class nsAutoOwningEventTarget {
public:
nsAutoOwningEventTarget();
nsAutoOwningEventTarget(const nsAutoOwningEventTarget& aOther);
// Per https://en.cppreference.com/w/cpp/language/move_constructor
// there's no implicitly-declared move constructor if there are user-declared
// copy constructors, and we have one, immediately above.
nsAutoOwningEventTarget& operator=(const nsAutoOwningEventTarget& aRhs);
// Per https://en.cppreference.com/w/cpp/language/move_assignment
// there's no implicitly-declared move assignment operator if there are
// user-declared copy assignment operators, and we have one, immediately
// above.
~nsAutoOwningEventTarget();
// We move the actual assertion checks out-of-line to minimize code bloat,
@ -102,7 +88,6 @@ class nsAutoOwningEventTarget {
private:
void AssertCurrentThreadOwnsMe(const char* aMsg) const;
// A raw pointer to avoid nsCOMPtr.h dependency.
nsISerialEventTarget* mTarget;
};

Просмотреть файл

@ -1,116 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:cindent:ts=4:et:sw=4:
/* 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/. */
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h"
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "gtest/gtest.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/gtest/MozAssertions.h"
namespace TestAutoOwningEventTarget {
using namespace mozilla;
#ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
namespace {
static MozExternalRefCountType GetRefCount(nsISupports* aSupports) {
aSupports->AddRef();
return aSupports->Release();
}
void CheckAutoOwningEventTarget(
nsISerialEventTarget* aSerialEventTarget,
const nsAutoOwningEventTarget& aAutoOwningEventTarget,
const bool aIsCurrent) {
ASSERT_TRUE(aSerialEventTarget);
ASSERT_EQ(aAutoOwningEventTarget.IsCurrentThread(), aIsCurrent);
{
const auto refCountBefore = GetRefCount(aSerialEventTarget);
{
nsAutoOwningEventTarget copyConstructedEventTarget(
aAutoOwningEventTarget);
ASSERT_EQ(copyConstructedEventTarget.IsCurrentThread(), aIsCurrent);
}
const auto refCountAfter = GetRefCount(aSerialEventTarget);
ASSERT_GE(refCountAfter, refCountBefore);
ASSERT_EQ(refCountAfter - refCountBefore, 0u);
}
{
const auto refCountBefore = GetRefCount(aSerialEventTarget);
{
nsAutoOwningEventTarget copyAssignedEventTarget;
ASSERT_TRUE(copyAssignedEventTarget.IsCurrentThread());
copyAssignedEventTarget = aAutoOwningEventTarget;
ASSERT_EQ(copyAssignedEventTarget.IsCurrentThread(), aIsCurrent);
}
const auto refCountAfter = GetRefCount(aSerialEventTarget);
ASSERT_GE(refCountAfter, refCountBefore);
ASSERT_EQ(refCountAfter - refCountBefore, 0u);
}
}
} // namespace
TEST(TestAutoOwningEventTarget, Simple)
{
{
nsAutoOwningEventTarget autoOwningEventTarget;
ASSERT_NO_FATAL_FAILURE(CheckAutoOwningEventTarget(
GetCurrentSerialEventTarget(), autoOwningEventTarget,
/* aIsCurrent */ true));
}
}
TEST(TestAutoOwningEventTarget, TaskQueue)
{
nsresult rv;
nsCOMPtr<nsIEventTarget> threadPool =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
ASSERT_NS_SUCCEEDED(rv);
auto taskQueue = TaskQueue::Create(threadPool.forget(), "TestTaskQueue",
/* aSupportsTailDispatch */ false);
nsAutoOwningEventTarget autoOwningEventTarget;
ASSERT_NS_SUCCEEDED(SyncRunnable::DispatchToThread(
taskQueue,
NS_NewRunnableFunction(
"TestRunnable", [taskQueue, &autoOwningEventTarget] {
{
ASSERT_NO_FATAL_FAILURE(CheckAutoOwningEventTarget(
taskQueue, autoOwningEventTarget, /* aIsCurrent */ false));
}
{
nsAutoOwningEventTarget autoOwningEventTarget;
ASSERT_NO_FATAL_FAILURE(CheckAutoOwningEventTarget(
taskQueue, autoOwningEventTarget, /* aIsCurrent */ true));
}
})));
}
#endif
} // namespace TestAutoOwningEventTarget

Просмотреть файл

@ -9,7 +9,6 @@ UNIFIED_SOURCES += [
"TestArenaAllocator.cpp",
"TestArrayAlgorithm.cpp",
"TestAtoms.cpp",
"TestAutoOwningEventTarget.cpp",
"TestAutoRefCnt.cpp",
"TestBase64.cpp",
"TestCallTemplates.cpp",