chromium/third_party/blink/renderer/core/probe/core_probes.pidl

/*
 * Copyright (C) 2013 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * make_instrumenting_probes.py uses this file as a source to generate
 * core_probes_inl.h, core_probes_impl.cc and core_probe_sink.h.
 *
 * The code below is not a correct IDL but a mix of IDL and C++.
 *
 * The syntax for an instrumentation method is as follows:
 *
 *    returnValue methodName([paramAttr1] param1, [paramAttr2] param2, ...)
 *
 * Where:
 *   paramAttr - optional attribute controlling the parameters handling (one attribute per parameter max).
 *       Keep - pass first parameter (used to access the CoreProbeSink instance) to agents.
 *
 *   returnValue: "void" for instant probes.
 *                Omitted for the scoped probes.
 *
 *   methodName: C++ name for the public instrumentation method and agents methods.
 *
 *   paramList: C++ parameter list with optional names. Names will be deduced from types if omitted but you have to
 *        specify explicit names for multiple parameters of the same type.
 */

interface CoreProbes {

  class ClassicScript;
  class ConsoleMessage;
  class FontCustomPlatformData;
  class FontFace;
  class HTMLDocumentParser;
  class HTMLInputElement;
  class JSBasedEventListener;
  class PerformanceEntry;
  class Script;
  class ScriptState;
  class SpeculationCandidate;
  class XMLHttpRequest;

  void DidClearDocumentOfWindowObject([Keep] LocalFrame*);
  void DidCreateMainWorldContext([Keep] LocalFrame*);
  void WillInsertDOMNode([Keep] Node* parent);
  void DidInsertDOMNode([Keep] Node*);
  void WillRemoveDOMNode([Keep] Node*);
  void WillModifyDOMAttr([Keep] Element*, const AtomicString& old_value, const AtomicString& new_value);
  void DidModifyDOMAttr([Keep] Element*, const QualifiedName& name, const AtomicString& value);
  void DidRemoveDOMAttr([Keep] Element*, const QualifiedName& name);
  void WillChangeStyleElement([Keep] Element*);
  void CharacterDataModified([Keep] CharacterData*);
  void DidInvalidateStyleAttr([Keep] Node*);
  void DidPerformSlotDistribution([Keep] HTMLSlotElement*);
  void DocumentDetached([Keep] Document*);
  void ActiveStyleSheetsUpdated([Keep] Document*);
  void FontsUpdated(ExecutionContext*, const FontFace* face, const String& src, const FontCustomPlatformData* font_custom_platform_data);
  void MediaQueryResultChanged(Document*);
  void DidPushShadowRoot([Keep] Element* host, ShadowRoot*);
  void WillPopShadowRoot([Keep] Element* host, ShadowRoot*);
  void WillSendXMLHttpOrFetchNetworkRequest(ExecutionContext*, const String& url);
  void DidCreateCanvasContext(Document*);
  void DidCreateOffscreenCanvasContext(OffscreenCanvas*);
  void DidFireWebGLError(Element*, const String& error_name);
  void DidFireWebGLWarning(Element*);
  void DidFireWebGLErrorOrWarning(Element*, const String& message);
  void DidResizeMainFrame(LocalFrame*);
  void ApplyAcceptLanguageOverride(ExecutionContext*, String* accept_language);
  void ApplyAcceptLanguageOverride(CoreProbeSink*, String* accept_language);
  void ApplyHardwareConcurrencyOverride(CoreProbeSink*, unsigned int& hardware_concurrency);
  void ApplyUserAgentOverride(CoreProbeSink*, String* user_agent);
  void ApplyUserAgentMetadataOverride(CoreProbeSink*, std::optional<blink::UserAgentMetadata>* ua_metadata_override);
  void DidBlockRequest(CoreProbeSink*, const ResourceRequest&, DocumentLoader*, const KURL& fetch_context_url, const ResourceLoaderOptions&, ResourceRequestBlockedReason, ResourceType);
  void DidChangeResourcePriority(LocalFrame*, DocumentLoader*, uint64_t identifier, ResourceLoadPriority load_priority);
  void PrepareRequest(CoreProbeSink*, DocumentLoader*, ResourceRequest&, ResourceLoaderOptions&, ResourceType);
  void WillSendRequest([Keep] ExecutionContext*, DocumentLoader*, const KURL& fetch_context_url, const ResourceRequest&, const ResourceResponse& redirect_response, const ResourceLoaderOptions&, ResourceType, RenderBlockingBehavior, base::TimeTicks timestamp);
  void WillSendNavigationRequest(CoreProbeSink*, uint64_t identifier, DocumentLoader*, const KURL&, const AtomicString& http_method, EncodedFormData*);
  void MarkResourceAsCached(LocalFrame*, DocumentLoader*, uint64_t identifier);
  void DidReceiveResourceResponse(CoreProbeSink*, uint64_t identifier, DocumentLoader*, const ResourceResponse&, const Resource*);
  void DidReceiveData(CoreProbeSink*, uint64_t identifier, DocumentLoader*, const char* data, uint64_t data_length);
  void DidReceiveBlob(CoreProbeSink*, uint64_t identifier, DocumentLoader*, BlobDataHandle*);
  void DidReceiveEncodedDataLength(CoreProbeSink*, DocumentLoader* loader, uint64_t identifier, size_t encoded_data_length);
  void DidFinishLoading(CoreProbeSink*, uint64_t identifier, DocumentLoader*, base::TimeTicks finish_time, int64_t encoded_data_length, int64_t decoded_body_length);
  void DidReceiveCorsRedirectResponse(ExecutionContext*, uint64_t identifier, DocumentLoader*, const ResourceResponse&, Resource*);
  void DidFailLoading([Keep] CoreProbeSink*, uint64_t identifier, DocumentLoader*, const ResourceError&, const base::UnguessableToken&);
  void WillSendEventSourceRequest(ExecutionContext*);
  void WillDispatchEventSourceEvent(ExecutionContext*, uint64_t identifier, const AtomicString& event_name, const AtomicString& event_id, const String& data);
  void WillLoadXHR([Keep] ExecutionContext*, const AtomicString& method, const KURL& url, bool async, const HTTPHeaderMap& headers, bool include_credentials);
  void DidFinishXHR(ExecutionContext*, XMLHttpRequest* xhr);
  void DidFinishSyncXHR(ExecutionContext* context, const base::TimeDelta blocking_time);
  void ScriptImported(ExecutionContext*, uint64_t identifier, const String& source_string);
  void ScriptExecutionBlockedByCSP(ExecutionContext*, const String& directive_text);
  void DidReceiveScriptResponse(ExecutionContext*, uint64_t identifier);
  void DomContentLoadedEventFired([Keep] LocalFrame*);
  void LoadEventFired([Keep] LocalFrame*);
  void FrameAttachedToParent([Keep] LocalFrame*, const std::optional<AdScriptIdentifier>& ad_script_on_stack);
  void FrameDetachedFromParent([Keep] LocalFrame*, FrameDetachType);
  void FrameSubtreeWillBeDetached(LocalFrame*, Frame*);
  void DidStartProvisionalLoad([Keep] LocalFrame*);
  void DidFailProvisionalLoad([Keep] LocalFrame*);
  void WillCommitLoad([Keep] LocalFrame*, DocumentLoader*);
  void DidCommitLoad([Keep] LocalFrame*, DocumentLoader*);
  void DidNavigateWithinDocument([Keep] LocalFrame*, blink::mojom::SameDocumentNavigationType);
  void DidRestoreFromBackForwardCache([Keep] LocalFrame*);
  void DidOpenDocument([Keep] LocalFrame*, DocumentLoader*);
  void WillCreateDocumentParser(Document*, bool& force_sync_parsing);
  void FrameDocumentUpdated([Keep] LocalFrame*);
  void FrameOwnerContentUpdated([Keep] LocalFrame*, HTMLFrameOwnerElement*);
  void FrameStartedLoading([Keep] LocalFrame*);
  void FrameStoppedLoading([Keep] LocalFrame*);
  void FrameRequestedNavigation(LocalFrame*, Frame* target_frame, const KURL& url, ClientNavigationReason reason, NavigationPolicy policy);
  void FrameScheduledNavigation([Keep] LocalFrame*, const KURL& url, base::TimeDelta delay, ClientNavigationReason reason);
  void FrameClearedScheduledNavigation([Keep] LocalFrame*);
  void WillCreateWebSocket([Keep] ExecutionContext*, uint64_t identifier, const KURL& request_url, const String& protocol, std::optional<base::UnguessableToken>* devtools_token);
  void WillSendWebSocketHandshakeRequest([Keep] ExecutionContext*, uint64_t identifier, network::mojom::blink::WebSocketHandshakeRequest* request);
  void DidReceiveWebSocketHandshakeResponse([Keep] ExecutionContext*, uint64_t identifier, network::mojom::blink::WebSocketHandshakeRequest* request, network::mojom::blink::WebSocketHandshakeResponse* response);
  void DidCloseWebSocket([Keep] ExecutionContext*, uint64_t identifier);
  void DidReceiveWebSocketMessage(ExecutionContext*, uint64_t identifier, int opcode, bool masked, const Vector<base::span<const char>>& data);
  void DidSendWebSocketMessage(ExecutionContext*, uint64_t identifier, int opcode, bool masked, const char* payload, size_t payload_length);
  void DidReceiveWebSocketMessageError(ExecutionContext*, uint64_t identifier, const String& error_message);
  void WebTransportCreated([Keep] ExecutionContext*, uint64_t transport_id, const KURL& request_url);
  void WebTransportConnectionEstablished(ExecutionContext*, uint64_t transport_id);
  void WebTransportClosed(ExecutionContext*, uint64_t transport_id);
  void WillCreateP2PSocketUdp(ExecutionContext*, std::optional<base::UnguessableToken>* devtools_token);
  /* This is for pre-BlinkGenPropertyTrees. TODO(wangxianzhu): Remove this function for BlinkGenPropertyTrees. */
  void LayerTreeDidChange(LocalFrame*);
  void LayerTreePainted(LocalFrame*);
  void PseudoElementCreated([Keep] PseudoElement*);
  void TopLayerElementsChanged(Document*);
  void PseudoElementDestroyed([Keep] PseudoElement*);
  void DidCreateAnimation(Document*, unsigned);
  void AnimationUpdated(Document*, Animation*);
  void WindowOpen(ExecutionContext*, const KURL& url, const AtomicString& window_name, const WebWindowFeatures& window_features, bool user_gestrue);
  void ConsoleMessageAdded(ExecutionContext*, ConsoleMessage*);
  void InspectorIssueAdded(CoreProbeSink*, protocol::Audits::InspectorIssue*);
  void WillRunJavaScriptDialog(LocalFrame* frame);
  void DidRunJavaScriptDialog(LocalFrame* frame);
  void DocumentWriteFetchScript([Keep] Document*);
  void DidChangeViewport(LocalFrame* document);
  void BreakableLocation(ExecutionContext* context, const char* name);
  void WillHandlePromise(ExecutionContext* context, ScriptState* script_state, bool resolving, const char* class_like_name, const String& property_like_name, const String& script_url);
  RecalculateStyle(Document* document);
  UpdateLayout(Document* document);

  /* This is called only for script generated from script blocks (script element, setTimeout with code */
  EvaluateScriptBlock(ScriptState* script_state, const KURL& source_url, bool is_module, bool sanitize);

  /* This is called once the script is ready to execute */
  ExecuteScript([Keep] ExecutionContext* context, v8::Local<v8::Context> v8_context, const String& script_url, int script_id);

  CallFunction([Keep] ExecutionContext* context, v8::Local<v8::Context> v8_context, v8::Local<v8::Function> function, int depth = 0);
  UserCallback([Keep] ExecutionContext* context, const char* name, AtomicString atomic_name, bool recurring, EventTarget* event_target = nullptr, Event* event = nullptr, EventListener* listener = nullptr);
  InvokeCallback(ScriptState* script_state, const char* name, CallbackFunctionBase* callback, v8::MaybeLocal<v8::Value> function = v8::MaybeLocal<v8::Value>());
  InvokeEventHandler(ScriptState* script_state, Event* event = nullptr, JSBasedEventListener* listener = nullptr);
  V8Compile([Keep] ExecutionContext* context, const String& file_name, int line, int column);
  ParseHTML(Document* document, HTMLDocumentParser* parser);
  void ForcePseudoState([Keep] Element* element, CSSSelector::PseudoType pseudo_state, bool* result);
  void ShouldForceCorsPreflight(ExecutionContext*, bool* result);
  void ShouldBlockRequest(CoreProbeSink*, const KURL&, bool* result);
  void ShouldBypassServiceWorker(ExecutionContext* context, bool* result);
  void ConsoleTimeStamp([Keep] v8::Isolate* isolate, v8::Local<v8::String> label);
  void WillStartDebuggerTask(CoreProbeSink*);
  void DidFinishDebuggerTask(CoreProbeSink*);
  void LifecycleEvent([Keep] LocalFrame*, DocumentLoader*, const char* name, double timestamp);
  void PaintTiming([Keep] Document*, const char* name, double timestamp);
  void DidCreateAudioContext(ExecutionContext*);
  void DidCloseAudioContext(ExecutionContext*);
  void DidResumeAudioContext(ExecutionContext*);
  void DidSuspendAudioContext(ExecutionContext*);
  void DidProduceCompilationCache(CoreProbeSink*, const ClassicScript&, v8::Local<v8::Script> script);
  void ApplyCompilationModeOverride(ExecutionContext*, const ClassicScript&, v8::ScriptCompiler::CachedData** cached_data, v8::ScriptCompiler::CompileOptions*);
  void NodeCreated([Keep] Node* node);
  void FileChooserOpened([Keep] LocalFrame* frame, HTMLInputElement* element, bool multiple, bool* intercepted);
  void PlayerErrorsRaised(ExecutionContext* context, String player_id, const Vector<InspectorPlayerError>& errors);
  void PlayerEventsAdded(ExecutionContext* context, String player_id, const Vector<InspectorPlayerEvent>& events);
  void PlayerMessagesLogged(ExecutionContext* context, String player_id, const Vector<InspectorPlayerMessage>& messages);
  void PlayerPropertiesChanged(ExecutionContext* context, String player_id, const Vector<InspectorPlayerProperty>& properties);
  void PlayersCreated(ExecutionContext* context, const Vector<WebString>& players);
  void SetDevToolsIds(CoreProbeSink*, ResourceRequest& request, const FetchInitiatorInfo&);
  void DidMutateStyleSheet(Document*, CSSStyleSheet* style_sheet);
  void DidReplaceStyleSheetText(Document*, CSSStyleSheet* style_sheet, const String& text);
  void GetTextPosition(Document*, wtf_size_t offset, const String* text, TextPosition* result);
  void LocalFontsEnabled(ExecutionContext*, bool* result);
  void DidUpdateComputedStyle([Keep] Element*, const ComputedStyle* old_style, const ComputedStyle* new_style);
  void GetDisabledImageTypes(ExecutionContext*, HashSet<String>* result);
  void OnContentSecurityPolicyViolation(ExecutionContext* context, const blink::ContentSecurityPolicyViolationType violationType);
  void IsCacheDisabled(ExecutionContext*, bool* is_cache_disabled);
  void PerformanceEntryAdded([Keep] ExecutionContext*, PerformanceEntry*);
  void ApplyAutomationOverride(ExecutionContext*, bool& enabled);
  void DidAddSpeculationRuleSet([Keep] Document&, const SpeculationRuleSet& rule_set);
  void DidRemoveSpeculationRuleSet(Document&, const SpeculationRuleSet& rule_set);
  void SpeculationCandidatesUpdated([Keep] Document&, const HeapVector<Member<SpeculationCandidate>>& candidates);
  void DidInitializeFrameWidget(LocalFrame* document);
}