#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_GARBAGE_COLLECTED_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_HEAP_GARBAGE_COLLECTED_H_
#include <type_traits>
#include "base/functional/unretained_traits.h"
#include "third_party/blink/renderer/platform/heap/thread_state_storage.h"
#include "v8/include/cppgc/allocation.h"
#include "v8/include/cppgc/garbage-collected.h"
#include "v8/include/cppgc/liveness-broker.h"
#include "v8/include/cppgc/type-traits.h"
namespace cppgc {
class LivenessBroker;
class Visitor;
}
namespace blink {
template <typename T>
using GarbageCollected = cppgc::GarbageCollected<T>;
using GarbageCollectedMixin = cppgc::GarbageCollectedMixin;
using LivenessBroker = cppgc::LivenessBroker;
using Visitor = cppgc::Visitor;
template <typename T, typename... Args>
T* MakeGarbageCollected(Args&&... args) {
return cppgc::MakeGarbageCollected<T>(
ThreadStateStorageFor<ThreadingTrait<T>::kAffinity>::GetState()
->allocation_handle(),
std::forward<Args>(args)...);
}
using AdditionalBytes = cppgc::AdditionalBytes;
template <typename T, typename... Args>
T* MakeGarbageCollected(AdditionalBytes additional_bytes, Args&&... args) {
return cppgc::MakeGarbageCollected<T>(
ThreadStateStorageFor<ThreadingTrait<T>::kAffinity>::GetState()
->allocation_handle(),
std::forward<AdditionalBytes>(additional_bytes),
std::forward<Args>(args)...);
}
}
namespace base::internal {
template <typename T>
requires cppgc::IsGarbageCollectedOrMixinTypeV<T>
inline constexpr bool kCustomizeSupportsUnretained<T> = false;
}
#endif