#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "base/feature_list.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/interface_endpoint_client.h"
#include "third_party/abseil-cpp/absl/base/attributes.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/scheduler/worker/compositor_thread.h"
#include "third_party/blink/renderer/platform/scheduler/worker/compositor_thread_scheduler_impl.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/threading.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#include <unistd.h>
#endif
namespace blink {
namespace {
ABSL_CONST_INIT thread_local Thread* current_thread = …;
std::unique_ptr<MainThread>& GetMainThread() { … }
std::unique_ptr<NonMainThread>& GetCompositorThread() { … }
}
void Thread::UpdateThreadTLS(Thread* thread) { … }
ThreadCreationParams::ThreadCreationParams(ThreadType thread_type)
: … { … }
ThreadCreationParams& ThreadCreationParams::SetThreadNameForTest(
const char* thread_name) { … }
ThreadCreationParams& ThreadCreationParams::SetFrameOrWorkerScheduler(
FrameOrWorkerScheduler* scheduler) { … }
ThreadCreationParams& ThreadCreationParams::SetSupportsGC(bool gc_enabled) { … }
void Thread::CreateAndSetCompositorThread() { … }
Thread* Thread::Current() { … }
MainThread* Thread::MainThread() { … }
NonMainThread* Thread::CompositorThread() { … }
std::unique_ptr<MainThread> MainThread::SetMainThread(
std::unique_ptr<MainThread> main_thread) { … }
Thread::Thread() = default;
Thread::~Thread() = default;
bool Thread::IsCurrentThread() const { … }
void Thread::AddTaskObserver(TaskObserver* task_observer) { … }
void Thread::RemoveTaskObserver(TaskObserver* task_observer) { … }
#if BUILDFLAG(IS_WIN)
static_assert(sizeof(blink::PlatformThreadId) >= sizeof(DWORD),
"size of platform thread id is too small");
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
static_assert …;
#else
#error Unexpected platform
#endif
}