#include "third_party/blink/renderer/controller/performance_manager/v8_worker_memory_reporter.h"
#include <memory>
#include <utility>
#include "base/check.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "third_party/blink/renderer/core/timing/measure_memory/measure_memory_controller.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/platform/heap/member.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/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_std.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace WTF {
template <>
struct CrossThreadCopier<blink::V8WorkerMemoryReporter::WorkerMemoryUsage>
: public CrossThreadCopierPassThrough<
blink::V8WorkerMemoryReporter::WorkerMemoryUsage> { … };
}
namespace blink {
const base::TimeDelta V8WorkerMemoryReporter::kTimeout = …;
namespace {
constexpr size_t kMaxReportedUrlLength = …;
class WorkerMeasurementDelegate : public v8::MeasureMemoryDelegate { … };
WorkerMeasurementDelegate::~WorkerMeasurementDelegate() { … }
void WorkerMeasurementDelegate::MeasurementComplete(
v8::MeasureMemoryDelegate::Result result) { … }
void WorkerMeasurementDelegate::NotifyMeasurementFailure() { … }
void WorkerMeasurementDelegate::NotifyMeasurementSuccess(
std::unique_ptr<V8WorkerMemoryReporter::WorkerMemoryUsage> memory_usage) { … }
}
void V8WorkerMemoryReporter::GetMemoryUsage(ResultCallback callback,
v8::MeasureMemoryExecution mode) { … }
void V8WorkerMemoryReporter::StartMeasurement(
WorkerThread* worker_thread,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
base::WeakPtr<V8WorkerMemoryReporter> worker_memory_reporter,
v8::MeasureMemoryExecution measurement_mode) { … }
void V8WorkerMemoryReporter::NotifyMeasurementSuccess(
WorkerThread* worker_thread,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
base::WeakPtr<V8WorkerMemoryReporter> worker_memory_reporter,
std::unique_ptr<WorkerMemoryUsage> memory_usage) { … }
void V8WorkerMemoryReporter::NotifyMeasurementFailure(
WorkerThread* worker_thread,
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
base::WeakPtr<V8WorkerMemoryReporter> worker_memory_reporter) { … }
void V8WorkerMemoryReporter::OnMeasurementFailure() { … }
void V8WorkerMemoryReporter::OnMeasurementSuccess(
std::unique_ptr<WorkerMemoryUsage> memory_usage) { … }
void V8WorkerMemoryReporter::SetWorkerCount(unsigned worker_count) { … }
void V8WorkerMemoryReporter::OnTimeout() { … }
void V8WorkerMemoryReporter::InvokeCallback() { … }
}