#include "third_party/blink/renderer/core/frame/animation_frame_timing_monitor.h"
#include "base/time/time.h"
#include "base/trace_event/base_tracing.h"
#include "components/viz/common/frame_timing_details.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink-forward.h"
#include "third_party/blink/renderer/bindings/core/v8/js_based_event_listener.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/core_probe_sink.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/script/script.h"
#include "third_party/blink/renderer/core/timing/animation_frame_timing_info.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/core/timing/third_party_script_detector.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "v8-local-handle.h"
#include "v8-message.h"
namespace blink {
namespace {
constexpr base::TimeDelta kLongAnimationFrameDuration = …;
constexpr base::TimeDelta kLongTaskDuration = …;
constexpr base::TimeDelta kLongScriptDuration = …;
}
AnimationFrameTimingMonitor::AnimationFrameTimingMonitor(Client& client,
CoreProbeSink* sink)
: … { … }
void AnimationFrameTimingMonitor::Shutdown() { … }
void AnimationFrameTimingMonitor::WillHandleInput(LocalFrame* frame) { … }
void AnimationFrameTimingMonitor::BeginMainFrame(
LocalDOMWindow& local_root_window) { … }
void AnimationFrameTimingMonitor::WillPerformStyleAndLayoutCalculation() { … }
void AnimationFrameTimingMonitor::DidBeginMainFrame(
LocalDOMWindow& local_root_window) { … }
void AnimationFrameTimingMonitor::WillProcessTask(base::TimeTicks start_time) { … }
void AnimationFrameTimingMonitor::ApplyTaskDuration(
base::TimeDelta task_duration) { … }
void AnimationFrameTimingMonitor::OnTaskCompleted(
base::TimeTicks start_time,
base::TimeTicks end_time,
LocalFrame* frame) { … }
namespace {
perfetto::protos::pbzero::AnimationFrameScriptTimingInfo::InvokerType
ToProtoEnum(ScriptTimingInfo::InvokerType type) { … }
perfetto::protos::pbzero::AnimationFrameScriptTimingInfo::ThirdPartyTechnology
ToProtoEnum(ThirdPartyScriptDetector::Technology technology) { … }
}
void AnimationFrameTimingMonitor::RequestPresentationTimeForTracing(
LocalFrame& frame) { … }
void AnimationFrameTimingMonitor::ReportPresentationTimeToTrace(
uint64_t trace_id,
const viz::FrameTimingDetails& presentation_details) { … }
void AnimationFrameTimingMonitor::RecordLongAnimationFrameTrace(
const AnimationFrameTimingInfo& info,
LocalDOMWindow& window) { … }
void AnimationFrameTimingMonitor::RecordLongAnimationFrameUKMAndTrace(
const AnimationFrameTimingInfo& info,
LocalDOMWindow& window) { … }
void AnimationFrameTimingMonitor::Trace(Visitor* visitor) const { … }
namespace {
bool ShouldAllowScriptURL(const WTF::String& url) { … }
}
bool AnimationFrameTimingMonitor::PushScriptEntryPoint(
ScriptState* script_state) { … }
ScriptTimingInfo* AnimationFrameTimingMonitor::PopScriptEntryPoint(
ScriptState* script_state,
const probe::ProbeBase* probe,
base::TimeTicks end_time) { … }
void AnimationFrameTimingMonitor::WillHandlePromise(
ScriptState* script_state,
bool resolving,
const char* class_like_name,
const String& property_like_name,
const String& script_url) { … }
void AnimationFrameTimingMonitor::Will(
const probe::EvaluateScriptBlock& probe_data) { … }
void AnimationFrameTimingMonitor::Will(const probe::ExecuteScript& probe_data) { … }
namespace {
ScriptTimingInfo::ScriptSourceLocation CaptureScriptSourceLocation(
v8::Isolate* isolate,
v8::MaybeLocal<v8::Value> maybe_value) { … }
}
void AnimationFrameTimingMonitor::Will(
const probe::InvokeCallback& probe_data) { … }
void AnimationFrameTimingMonitor::Will(
const probe::InvokeEventHandler& probe_data) { … }
void AnimationFrameTimingMonitor::Did(
const probe::InvokeEventHandler& probe_data) { … }
void AnimationFrameTimingMonitor::Will(
const probe::RecalculateStyle& probe_data) { … }
void AnimationFrameTimingMonitor::Did(
const probe::RecalculateStyle& probe_data) { … }
void AnimationFrameTimingMonitor::Will(const probe::UpdateLayout& probe_data) { … }
void AnimationFrameTimingMonitor::Did(const probe::UpdateLayout& probe_data) { … }
void AnimationFrameTimingMonitor::WillRunJavaScriptDialog() { … }
void AnimationFrameTimingMonitor::DidRunJavaScriptDialog() { … }
void AnimationFrameTimingMonitor::DidFinishSyncXHR(
base::TimeDelta blocking_time) { … }
}