chromium/third_party/blink/renderer/core/loader/interactive_detector.cc

// Copyright 2017 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/core/loader/interactive_detector.h"

#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/profiler/sample_metadata.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"

namespace blink {

namespace {

// Used to generate a unique id when emitting the "Long Input Delay" trace
// event and metadata.
int g_num_long_input_events =;

// The threshold to emit the "Long Input Delay" trace event is the 99th
// percentile of the histogram on Windows Stable as of Feb 25, 2020.
constexpr base::TimeDelta kInputDelayTraceEventThreshold =;

// The threshold to emit the "Long First Input Delay" trace event is the 99th
// percentile of the histogram on Windows Stable as of Feb 27, 2020.
constexpr base::TimeDelta kFirstInputDelayTraceEventThreshold =;

}  // namespace

// Required length of main thread and network quiet window for determining
// Time to Interactive.
constexpr auto kTimeToInteractiveWindow =;
// Network is considered "quiet" if there are no more than 2 active network
// requests for this duration of time.
constexpr int kNetworkQuietMaximumConnections =;

const char kHistogramInputDelay[] =;
const char kHistogramInputTimestamp[] =;
const char kHistogramProcessingTime[] =;
const char kHistogramTimeToNextPaint[] =;

// static
const char InteractiveDetector::kSupplementName[] =;

InteractiveDetector* InteractiveDetector::From(Document& document) {}

const char* InteractiveDetector::SupplementName() {}

InteractiveDetector::InteractiveDetector(
    Document& document,
    std::unique_ptr<NetworkActivityChecker> network_activity_checker)
    :{}

void InteractiveDetector::SetNavigationStartTime(
    base::TimeTicks navigation_start_time) {}

int InteractiveDetector::NetworkActivityChecker::GetActiveConnections() {}

int InteractiveDetector::ActiveConnections() {}

void InteractiveDetector::StartOrPostponeCITimer(
    base::TimeTicks timer_fire_time) {}

std::optional<base::TimeDelta> InteractiveDetector::GetFirstInputDelay() const {}

WTF::Vector<std::optional<base::TimeDelta>>
InteractiveDetector::GetFirstInputDelaysAfterBackForwardCacheRestore() const {}

std::optional<base::TimeTicks> InteractiveDetector::GetFirstInputTimestamp()
    const {}

std::optional<base::TimeTicks> InteractiveDetector::GetFirstScrollTimestamp()
    const {}

std::optional<base::TimeDelta> InteractiveDetector::GetFirstScrollDelay()
    const {}

bool InteractiveDetector::PageWasBackgroundedSinceEvent(
    base::TimeTicks event_time) {}

void InteractiveDetector::HandleForInputDelay(
    const Event& event,
    base::TimeTicks event_platform_timestamp,
    base::TimeTicks processing_start) {}

void InteractiveDetector::BeginNetworkQuietPeriod(
    base::TimeTicks current_time) {}

void InteractiveDetector::EndNetworkQuietPeriod(base::TimeTicks current_time) {}

// The optional opt_current_time, if provided, saves us a call to
// clock_->NowTicks().
void InteractiveDetector::UpdateNetworkQuietState(
    double request_count,
    std::optional<base::TimeTicks> opt_current_time) {}

void InteractiveDetector::OnResourceLoadBegin(
    std::optional<base::TimeTicks> load_begin_time) {}

// The optional load_finish_time, if provided, saves us a call to
// clock_->NowTicks.
void InteractiveDetector::OnResourceLoadEnd(
    std::optional<base::TimeTicks> load_finish_time) {}

void InteractiveDetector::OnLongTaskDetected(base::TimeTicks start_time,
                                             base::TimeTicks end_time) {}

void InteractiveDetector::OnFirstContentfulPaint(
    base::TimeTicks first_contentful_paint) {}

void InteractiveDetector::OnDomContentLoadedEnd(base::TimeTicks dcl_end_time) {}

void InteractiveDetector::OnInvalidatingInputEvent(
    base::TimeTicks invalidation_time) {}

void InteractiveDetector::OnPageHiddenChanged(bool is_hidden) {}

void InteractiveDetector::TimeToInteractiveTimerFired(TimerBase*) {}

void InteractiveDetector::AddCurrentlyActiveNetworkQuietInterval(
    base::TimeTicks current_time) {}

void InteractiveDetector::RemoveCurrentlyActiveNetworkQuietInterval() {}

base::TimeTicks InteractiveDetector::FindInteractiveCandidate(
    base::TimeTicks lower_bound,
    base::TimeTicks current_time) {}

void InteractiveDetector::CheckTimeToInteractiveReached() {}

void InteractiveDetector::OnTimeToInteractiveDetected() {}

base::TimeDelta InteractiveDetector::ComputeTotalBlockingTime() {}

void InteractiveDetector::ContextDestroyed() {}

void InteractiveDetector::Trace(Visitor* visitor) const {}

void InteractiveDetector::SetTickClockForTesting(const base::TickClock* clock) {}

void InteractiveDetector::SetTaskRunnerForTesting(
    scoped_refptr<base::SingleThreadTaskRunner> task_runner_for_testing) {}

void InteractiveDetector::RecordInputEventTimingUMA(
    base::TimeDelta processing_time,
    base::TimeDelta time_to_next_paint) {}

void InteractiveDetector::DidObserveFirstScrollDelay(
    base::TimeDelta first_scroll_delay,
    base::TimeTicks first_scroll_timestamp) {}

void InteractiveDetector::OnRestoredFromBackForwardCache() {}

}  // namespace blink