#include "third_party/blink/renderer/core/workers/worker_backing_thread.h"
#include <memory>
#include "base/location.h"
#include "base/synchronization/lock.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_context_snapshot.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_gc_controller.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_idle_task_runner.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_initializer.h"
#include "third_party/blink/renderer/core/inspector/worker_thread_debugger.h"
#include "third_party/blink/renderer/core/workers/worker_backing_thread_startup_data.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace blink {
namespace {
base::Lock& IsolatesLock() { … }
HashSet<v8::Isolate*>& Isolates() EXCLUSIVE_LOCKS_REQUIRED(IsolatesLock()) { … }
HashSet<v8::Isolate*>& ForegroundedIsolates()
EXCLUSIVE_LOCKS_REQUIRED(IsolatesLock()) { … }
v8::Isolate::Priority& IsolateCurrentPriority()
EXCLUSIVE_LOCKS_REQUIRED(IsolatesLock()) { … }
bool& BatterySaverModeEnabled() EXCLUSIVE_LOCKS_REQUIRED(IsolatesLock()) { … }
void AddWorkerIsolate(v8::Isolate* isolate) { … }
void RemoveWorkerIsolate(v8::Isolate* isolate) { … }
void AddForegroundedWorkerIsolate(v8::Isolate* isolate) { … }
void RemoveForegroundedWorkerIsolate(v8::Isolate* isolate) { … }
}
void MemoryPressureNotificationToAllIsolates(v8::MemoryPressureLevel level) { … }
void SetBatterySaverModeForAllIsolates(bool battery_saver_mode_enabled) { … }
WorkerBackingThread::WorkerBackingThread(const ThreadCreationParams& params)
: … { … }
WorkerBackingThread::~WorkerBackingThread() = default;
void WorkerBackingThread::InitializeOnBackingThread(
const WorkerBackingThreadStartupData& startup_data) { … }
void WorkerBackingThread::ShutdownOnBackingThread() { … }
void WorkerBackingThread::SetForegrounded() { … }
void WorkerBackingThread::MemoryPressureNotificationToWorkerThreadIsolates(
v8::MemoryPressureLevel level) { … }
void WorkerBackingThread::SetWorkerThreadIsolatesPriority(
v8::Isolate::Priority priority) { … }
void WorkerBackingThread::SetBatterySaverModeForWorkerThreadIsolates(
bool battery_saver_mode_enabled) { … }
}