#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/functional/bind.h"
#include <functional>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/allocator/partition_alloc_features.h"
#include "base/allocator/partition_alloc_support.h"
#include "base/functional/callback.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "partition_alloc/buildflags.h"
#include "partition_alloc/dangling_raw_ptr_checks.h"
#include "partition_alloc/partition_alloc_for_testing.h"
#include "partition_alloc/partition_root.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
AnyNumber;
ByMove;
Mock;
Return;
StrictMock;
namespace base {
namespace …
template <typename T>
struct MockRacyWeakPtr { … };
IsWeakReceiver<MockRacyWeakPtr<T>>;
BindUnwrapTraits<MockRacyWeakPtr<T>>;
MaybeValidTraits<MockRacyWeakPtr<T>>;
namespace {
TEST_F(BindTest, BindRacyWeakPtrTest) { … }
TEST(BindDeathTest, NullCallback) { … }
TEST(BindDeathTest, NullFunctionPointer) { … }
TEST(BindDeathTest, NullCallbackWithoutBoundArgs) { … }
TEST(BindDeathTest, BanFirstOwnerOfRefCountedType) { … }
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && \
PA_BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
void HandleOOM(size_t unused_size) { … }
static constexpr auto kOnlyEnableBackupRefPtrOptions = …::PartitionOptions opts;
opts.backup_ref_ptr = …;
class BindUnretainedDanglingInternalFixture : public BindTest { … };
class BindUnretainedDanglingTest
: public BindUnretainedDanglingInternalFixture { … };
class BindUnretainedDanglingDeathTest
: public BindUnretainedDanglingInternalFixture { … };
bool PtrCheckFn(int* p) { … }
bool RefCheckFn(const int& p) { … }
bool MayBeDanglingCheckFn(MayBeDangling<int> p) { … }
bool MayBeDanglingAndDummyTraitCheckFn(
MayBeDangling<int, RawPtrTraits::kDummyForTest> p) { … }
class ClassWithWeakPtr { … };
TEST_F(BindUnretainedDanglingTest, UnretainedNoDanglingPtr) { … }
TEST_F(BindUnretainedDanglingTest, UnsafeDanglingPtr) { … }
TEST_F(BindUnretainedDanglingTest, UnsafeDanglingPtrWithDummyTrait) { … }
TEST_F(BindUnretainedDanglingTest,
UnsafeDanglingPtrWithDummyAndDanglingTraits) { … }
TEST_F(BindUnretainedDanglingTest, UnsafeDanglingPtrNoRawPtrReceiver) { … }
TEST_F(BindUnretainedDanglingTest, UnsafeDanglingUntriagedPtr) { … }
TEST_F(BindUnretainedDanglingTest, UnretainedWeakReceiverValidNoDangling) { … }
TEST_F(BindUnretainedDanglingTest, UnretainedRefWeakReceiverValidNoDangling) { … }
TEST_F(BindUnretainedDanglingTest, UnretainedWeakReceiverInvalidNoDangling) { … }
TEST_F(BindUnretainedDanglingTest, UnretainedRefWeakReceiverInvalidNoDangling) { … }
TEST_F(BindUnretainedDanglingTest, UnretainedRefUnsafeDangling) { … }
TEST_F(BindUnretainedDanglingTest, UnretainedRefUnsafeDanglingUntriaged) { … }
#if defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID)
int FuncWithRefArgument(int& i_ptr) { … }
TEST_F(BindUnretainedDanglingDeathTest, UnretainedDanglingPtr) { … }
TEST_F(BindUnretainedDanglingDeathTest, UnretainedRefDanglingPtr) { … }
TEST_F(BindUnretainedDanglingDeathTest,
UnretainedRefWithManualUnretainedDanglingPtr) { … }
TEST_F(BindUnretainedDanglingDeathTest, UnretainedWeakReceiverDangling) { … }
#endif
#endif
}
}