chromium/third_party/blink/renderer/modules/compute_pressure/pressure_observer.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/modules/compute_pressure/pressure_observer.h"

#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_pressure_observer_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_pressure_record.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_pressure_source.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/modules/compute_pressure/pressure_observer_manager.h"
#include "third_party/blink/renderer/modules/compute_pressure/pressure_record.h"
#include "third_party/blink/renderer/modules/compute_pressure/pressure_source_index.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"

namespace blink {

namespace {

constexpr char kFeaturePolicyBlocked[] =;

}  // namespace

PressureObserver::PressureObserver(V8PressureUpdateCallback* observer_callback)
    :{}

PressureObserver::~PressureObserver() = default;

// static
PressureObserver* PressureObserver::Create(V8PressureUpdateCallback* callback) {}

// static
Vector<V8PressureSource> PressureObserver::knownSources() {}

ScriptPromise<IDLUndefined> PressureObserver::observe(
    ScriptState* script_state,
    V8PressureSource source,
    PressureObserverOptions* options,
    ExceptionState& exception_state) {}

void PressureObserver::unobserve(V8PressureSource source) {}

void PressureObserver::disconnect() {}

void PressureObserver::Trace(blink::Visitor* visitor) const {}

void PressureObserver::OnUpdate(ExecutionContext* execution_context,
                                V8PressureSource::Enum source,
                                V8PressureState::Enum state,
                                DOMHighResTimeStamp timestamp) {}

// Steps 4.6.3.1.1-3 of
// https://w3c.github.io/compute-pressure/#dfn-data-delivery
void PressureObserver::QueueAfterPenaltyRecord(
    ExecutionContext* execution_context,
    V8PressureSource::Enum source) {}

// https://w3c.github.io/compute-pressure/#queue-a-pressurerecord
void PressureObserver::QueuePressureRecord(ExecutionContext* execution_context,
                                           V8PressureSource::Enum source,
                                           PressureRecord* record) {}

void PressureObserver::OnBindingSucceeded(V8PressureSource::Enum source) {}

void PressureObserver::OnBindingFailed(V8PressureSource::Enum source,
                                       DOMExceptionCode exception_code) {}

void PressureObserver::OnConnectionError() {}

void PressureObserver::ReportToCallback(ExecutionContext* execution_context) {}

HeapVector<Member<PressureRecord>> PressureObserver::takeRecords() {}

// https://w3c.github.io/compute-pressure/#dfn-passes-rate-test
bool PressureObserver::PassesRateTest(
    V8PressureSource::Enum source,
    const DOMHighResTimeStamp& timestamp) const {}

// https://w3c.github.io/compute-pressure/#dfn-has-change-in-data
bool PressureObserver::HasChangeInData(V8PressureSource::Enum source,
                                       V8PressureState::Enum state) const {}

// This function only checks the status of the rate obfuscation test.
// Incrementing of change count should happen before this call as described in
// https://w3c.github.io/compute-pressure/#dfn-passes-rate-obfuscation-test
bool PressureObserver::PassesRateObfuscation(
    V8PressureSource::Enum source) const {}

void PressureObserver::ResolvePendingResolvers(V8PressureSource::Enum source) {}

void PressureObserver::RejectPendingResolvers(V8PressureSource::Enum source,
                                              DOMExceptionCode exception_code,
                                              const String& message) {}

}  // namespace blink