bindings: Require creation key for ActiveScriptWrappable ASW is error prone and may lead to temporary memory leaks. Require users to add classes to a creation key to acknowledge that they have tried to keep the object alive through other means. Change-Id: I5497f21b6fb8a18228b0bdeb85cf8cfe15e25619 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3898697 Commit-Queue: Anton Bikineev <bikineev@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Cr-Commit-Position: refs/heads/main@{#1127589}
diff --git a/third_party/blink/renderer/bindings/bindings.gni b/third_party/blink/renderer/bindings/bindings.gni index 562b101..684e12c 100644 --- a/third_party/blink/renderer/bindings/bindings.gni +++ b/third_party/blink/renderer/bindings/bindings.gni
@@ -13,6 +13,7 @@ get_path_info([ "core/v8/active_script_wrappable.cc", "core/v8/active_script_wrappable.h", + "core/v8/active_script_wrappable_creation_key.h", "core/v8/array_value.cc", "core/v8/array_value.h", "core/v8/binding_security.cc",
diff --git a/third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h b/third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h index 6dc3233..8d51d0d0 100644 --- a/third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h +++ b/third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h
@@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_H_ #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_H_ +#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/bindings/active_script_wrappable_base.h" namespace blink { @@ -15,21 +16,27 @@ // asynchronous activity, even if they are not referenced in the JavaScript or // Blink heap. // -// This is useful for ScriptWrappable objects that are not held alive by regular -// references from the object graph. E.g., XMLHttpRequest may have a pending -// activity that may be visible (e.g. firing event listeners or resolving -// promises) and should thus not be collected. +// This can be useful for ScriptWrappable objects that are not held alive by +// regular references from the object graph. E.g., XMLHttpRequest may have a +// pending activity that may be visible (e.g. firing event listeners or +// resolving promises) and should thus not be collected. // -// Such objects should derive from ActiveScriptWrappable<T>, and override -// ScriptWrappable::HasPendingActivity: -// bool HasPendingActivity() const final; -// which returns true if there may be pending activity which requires the -// wrappable remain alive. +// Alternatively, it is generally less error prone though to attach the +// wrappable object to the regular Blink heap. ActiveScriptWrappable negatively +// affects garbage collection performance and is thus preferred to keep objects +// alive through other means, e.g. normal Member<> pointers. When not easily +// feasibly, a new ActiveScriptWrappable should be allow-listed in +// ActiveScriptWrappableCreationKey as a friend. // -// To avoid leaking objects after the context is destroyed, users of -// ActiveScriptWrappable<T> also have to provide a GetExecutionContext() method -// that returns the ExecutionContext or nullptr. A nullptr or already destroyed -// context results in ignoring HasPendingActivity(). +// The objects should derive from ActiveScriptWrappable<T>, and override +// `ScriptWrappable::HasPendingActivity()`. The method is not allowed to +// allocate. +// +// Caveat: +// - To avoid leaking objects after the context is destroyed, users of +// ActiveScriptWrappable<T> also have to provide a `GetExecutionContext()` +// method that returns the ExecutionContext or nullptr. A nullptr or already +// destroyed context results in ignoring `HasPendingActivity()`. // // Automatically activates the ASW behavior after construction. For lazy // initialization, see LazyActiveScriptWrappable below. @@ -46,6 +53,9 @@ RegisterActiveScriptWrappable(); } + protected: + explicit ActiveScriptWrappable(ActiveScriptWrappableCreationKey) {} + bool IsContextDestroyed() const final { return IsContextDestroyedForActiveScriptWrappable( static_cast<const T*>(this)->GetExecutionContext()); @@ -54,9 +64,6 @@ bool DispatchHasPendingActivity() const final { return static_cast<const T*>(this)->HasPendingActivity(); } - - protected: - ActiveScriptWrappable() = default; }; // Same as ActiveScriptWrappable with the difference the the object is not @@ -87,7 +94,7 @@ } protected: - LazyActiveScriptWrappable() = default; + explicit LazyActiveScriptWrappable(ActiveScriptWrappableCreationKey) {} }; // Helper for ActiveScriptWrappable<T>::IsContextDestroyed();
diff --git a/third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h b/third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h new file mode 100644 index 0000000..6fac5de6 --- /dev/null +++ b/third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h
@@ -0,0 +1,123 @@ +// Copyright 2023 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_CREATION_KEY_H_ +#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_CREATION_KEY_H_ + +namespace blink { + +// Creation key needed to instantiate ActiveScriptWrappable objects. +// +// By adding your class as friend below you acknowledge that you have checked +// alternatives for keeping the object alive, see class comment of +// `ActiveScriptWrappable`. +class ActiveScriptWrappableCreationKey final { + private: + // NOLINTNEXTLINE: No =default to disallow aggregate initialization. + ActiveScriptWrappableCreationKey() {} + + friend class AbortSignal; + friend class Animation; + friend class AudioScheduledSourceNode; + friend class AudioWorkletNode; + friend class BackgroundFetchRegistration; + friend class BaseAudioContext; + friend class BatteryManager; + friend class BeforeInstallPromptEvent; + friend class BluetoothDevice; + friend class BluetoothRemoteGATTCharacteristic; + friend class BroadcastChannel; + friend class CacheStorage; + friend class CanvasRenderingContext; + template <typename Traits> + friend class DecoderTemplate; + friend class DedicatedWorker; + friend class DocumentTransition; + friend class DOMFileSystem; + friend class DOMWebSocket; + friend class EditContext; + template <typename Traits> + friend class EncoderBase; + friend class EventSource; + friend class FetchEvent; + friend class FileReader; + friend class FileSystemDirectoryIterator; + friend class FileWriter; + friend class FontFace; + template <typename NativeFrameType> + friend class FrameQueueUnderlyingSource; + friend class Geolocation; + friend class HIDDevice; + friend class HTMLImageElement; + friend class HTMLInputElement; + friend class HTMLMediaElement; + friend class HTMLPlugInElement; + friend class IDBDatabase; + friend class IDBRequest; + friend class IDBTransaction; + friend class IdleDetector; + friend class ImageDecoderExternal; + friend class IntersectionObserver; + friend class MediaElementAudioSourceNode; + friend class MediaDevices; + friend class MediaKeys; + friend class MediaKeySession; + friend class MediaQueryList; + friend class MediaSource; + friend class MediaRecorder; + friend class MediaStream; + friend class MediaStreamAudioSourceNode; + friend class MediaStreamTrack; + friend class MessagePort; + friend class MIDIAccess; + friend class MIDIPort; + friend class MojoInterfaceInterceptor; + friend class MojoWatcher; + friend class MutationObserver; + friend class NavigatorManagedData; + friend class NDEFReader; + friend class NetworkInformation; + friend class Notification; + friend class PaymentRequest; + friend class PaymentResponse; + friend class PerformanceObserver; + friend class PermissionStatus; + friend class PictureInPictureWindow; + friend class PresentationAvailability; + friend class PresentationRequest; + friend class ReadableStreamDefaultReader; + friend class RemotePlayback; + friend class ReportingObserver; + friend class Request; + friend class ResizeObserver; + friend class Response; + friend class RTCDataChannel; + friend class RTCIceTransport; + friend class RTCPeerConnection; + friend class ScriptProcessorNode; + friend class Sensor; + friend class SerialPort; + friend class ServiceWorker; + friend class ServiceWorkerRegistration; + friend class SharedWorker; + friend class SmartCardReader; + friend class SmartCardReaderPresenceObserver; + friend class SourceBuffer; + friend class SpeechRecognition; + friend class SVGImageElement; + friend class TCPSocket; + friend class UDPSocket; + friend class ViewTransition; + friend class WakeLockSentinel; + friend class WebSocketStream; + friend class WebTransport; + friend class WorkerGlobalScope; + friend class WorkletGlobalScope; + friend class XMLHttpRequest; + friend class XRSession; +}; + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_CREATION_KEY_H_
diff --git a/third_party/blink/renderer/core/animation/animation.cc b/third_party/blink/renderer/core/animation/animation.cc index 78497ef..4c62467 100644 --- a/third_party/blink/renderer/core/animation/animation.cc +++ b/third_party/blink/renderer/core/animation/animation.cc
@@ -269,7 +269,8 @@ Animation::Animation(ExecutionContext* execution_context, AnimationTimeline* timeline, AnimationEffect* content) - : ExecutionContextLifecycleObserver(nullptr), + : ActiveScriptWrappable<Animation>({}), + ExecutionContextLifecycleObserver(nullptr), reported_play_state_(kIdle), playback_rate_(1), start_time_(),
diff --git a/third_party/blink/renderer/core/css/font_face.cc b/third_party/blink/renderer/core/css/font_face.cc index 4936d69..06a30820 100644 --- a/third_party/blink/renderer/core/css/font_face.cc +++ b/third_party/blink/renderer/core/css/font_face.cc
@@ -243,7 +243,8 @@ FontFace::FontFace(ExecutionContext* context, const StyleRuleFontFace* style_rule, bool is_user_style) - : ExecutionContextClient(context), + : ActiveScriptWrappable<FontFace>({}), + ExecutionContextClient(context), style_rule_(style_rule), status_(kUnloaded), is_user_style_(is_user_style) {} @@ -251,7 +252,10 @@ FontFace::FontFace(ExecutionContext* context, const AtomicString& family, const FontFaceDescriptors* descriptors) - : ExecutionContextClient(context), family_(family), status_(kUnloaded) { + : ActiveScriptWrappable<FontFace>({}), + ExecutionContextClient(context), + family_(family), + status_(kUnloaded) { SetPropertyFromString(context, descriptors->style(), AtRuleDescriptorID::FontStyle); SetPropertyFromString(context, descriptors->weight(),
diff --git a/third_party/blink/renderer/core/css/media_query_list.cc b/third_party/blink/renderer/core/css/media_query_list.cc index a978614b..6fdd1b02 100644 --- a/third_party/blink/renderer/core/css/media_query_list.cc +++ b/third_party/blink/renderer/core/css/media_query_list.cc
@@ -36,7 +36,8 @@ MediaQueryList::MediaQueryList(ExecutionContext* context, MediaQueryMatcher* matcher, MediaQuerySet* media) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<MediaQueryList>({}), + ExecutionContextLifecycleObserver(context), matcher_(matcher), media_(media), matches_dirty_(true),
diff --git a/third_party/blink/renderer/core/dom/abort_signal.cc b/third_party/blink/renderer/core/dom/abort_signal.cc index ec6f17d..10ed36c 100644 --- a/third_party/blink/renderer/core/dom/abort_signal.cc +++ b/third_party/blink/renderer/core/dom/abort_signal.cc
@@ -161,7 +161,8 @@ : AbortSignal(execution_context, SignalType::kInternal) {} AbortSignal::AbortSignal(ExecutionContext* execution_context, - SignalType signal_type) { + SignalType signal_type) + : LazyActiveScriptWrappable<AbortSignal>({}) { DCHECK_NE(signal_type, SignalType::kComposite); InitializeCommon(execution_context, signal_type); @@ -172,7 +173,8 @@ } AbortSignal::AbortSignal(ScriptState* script_state, - HeapVector<Member<AbortSignal>>& source_signals) { + HeapVector<Member<AbortSignal>>& source_signals) + : LazyActiveScriptWrappable<AbortSignal>({}) { DCHECK(RuntimeEnabledFeatures::AbortSignalCompositionEnabled()); InitializeCommon(ExecutionContext::From(script_state), SignalType::kComposite);
diff --git a/third_party/blink/renderer/core/dom/mutation_observer.cc b/third_party/blink/renderer/core/dom/mutation_observer.cc index 9e1e464d..c3ac35441 100644 --- a/third_party/blink/renderer/core/dom/mutation_observer.cc +++ b/third_party/blink/renderer/core/dom/mutation_observer.cc
@@ -191,7 +191,8 @@ MutationObserver::MutationObserver(ExecutionContext* execution_context, Delegate* delegate) - : ExecutionContextLifecycleStateObserver(execution_context), + : ActiveScriptWrappable<MutationObserver>({}), + ExecutionContextLifecycleStateObserver(execution_context), delegate_(delegate) { priority_ = g_observer_priority++; UpdateStateIfNeeded();
diff --git a/third_party/blink/renderer/core/editing/ime/edit_context.cc b/third_party/blink/renderer/core/editing/ime/edit_context.cc index e946cd2..bde0f54 100644 --- a/third_party/blink/renderer/core/editing/ime/edit_context.cc +++ b/third_party/blink/renderer/core/editing/ime/edit_context.cc
@@ -35,7 +35,8 @@ namespace blink { EditContext::EditContext(ScriptState* script_state, const EditContextInit* dict) - : ExecutionContextClient(ExecutionContext::From(script_state)) { + : ActiveScriptWrappable<EditContext>({}), + ExecutionContextClient(ExecutionContext::From(script_state)) { DCHECK(IsMainThread()); if (dict->hasText())
diff --git a/third_party/blink/renderer/core/fetch/request.cc b/third_party/blink/renderer/core/fetch/request.cc index 65c65104..ab8c93b 100644 --- a/third_party/blink/renderer/core/fetch/request.cc +++ b/third_party/blink/renderer/core/fetch/request.cc
@@ -856,11 +856,11 @@ FetchRequestData* request, Headers* headers, AbortSignal* signal) - : Body(ExecutionContext::From(script_state)), + : ActiveScriptWrappable<Request>({}), + Body(ExecutionContext::From(script_state)), request_(request), headers_(headers), - signal_(signal) { -} + signal_(signal) {} Request::Request(ScriptState* script_state, FetchRequestData* request) : Request(script_state,
diff --git a/third_party/blink/renderer/core/fetch/response.cc b/third_party/blink/renderer/core/fetch/response.cc index ba8c4e94..0f11686f 100644 --- a/third_party/blink/renderer/core/fetch/response.cc +++ b/third_party/blink/renderer/core/fetch/response.cc
@@ -559,7 +559,10 @@ Response::Response(ExecutionContext* context, FetchResponseData* response, Headers* headers) - : Body(context), response_(response), headers_(headers) {} + : ActiveScriptWrappable<Response>({}), + Body(context), + response_(response), + headers_(headers) {} bool Response::HasBody() const { return response_->InternalBuffer();
diff --git a/third_party/blink/renderer/core/fileapi/file_reader.cc b/third_party/blink/renderer/core/fileapi/file_reader.cc index 9010da3a..17f54131 100644 --- a/third_party/blink/renderer/core/fileapi/file_reader.cc +++ b/third_party/blink/renderer/core/fileapi/file_reader.cc
@@ -197,7 +197,8 @@ } FileReader::FileReader(ExecutionContext* context) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<FileReader>({}), + ExecutionContextLifecycleObserver(context), state_(kEmpty), loading_state_(kLoadingStateNone), still_firing_events_(false),
diff --git a/third_party/blink/renderer/core/frame/reporting_observer.cc b/third_party/blink/renderer/core/frame/reporting_observer.cc index 7b931cd..89c04a3 100644 --- a/third_party/blink/renderer/core/frame/reporting_observer.cc +++ b/third_party/blink/renderer/core/frame/reporting_observer.cc
@@ -25,7 +25,8 @@ ReportingObserver::ReportingObserver(ExecutionContext* execution_context, V8ReportingObserverCallback* callback, ReportingObserverOptions* options) - : ExecutionContextClient(execution_context), + : ActiveScriptWrappable<ReportingObserver>({}), + ExecutionContextClient(execution_context), execution_context_(execution_context), callback_(callback), options_(options),
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_rendering_context.cc b/third_party/blink/renderer/core/html/canvas/canvas_rendering_context.cc index 32f8195..9d24c520 100644 --- a/third_party/blink/renderer/core/html/canvas/canvas_rendering_context.cc +++ b/third_party/blink/renderer/core/html/canvas/canvas_rendering_context.cc
@@ -41,7 +41,8 @@ CanvasRenderingContextHost* host, const CanvasContextCreationAttributesCore& attrs, CanvasRenderingAPI canvas_rendering_API) - : host_(host), + : ActiveScriptWrappable<CanvasRenderingContext>({}), + host_(host), color_params_(attrs.color_space, attrs.pixel_format, attrs.alpha), creation_attributes_(attrs), canvas_rendering_type_(canvas_rendering_API) {}
diff --git a/third_party/blink/renderer/core/html/forms/html_input_element.cc b/third_party/blink/renderer/core/html/forms/html_input_element.cc index 7d5f4ea..8e926a8 100644 --- a/third_party/blink/renderer/core/html/forms/html_input_element.cc +++ b/third_party/blink/renderer/core/html/forms/html_input_element.cc
@@ -125,6 +125,7 @@ HTMLInputElement::HTMLInputElement(Document& document, const CreateElementFlags flags) : TextControlElement(html_names::kInputTag, document), + LazyActiveScriptWrappable<HTMLInputElement>({}), size_(kDefaultSize), has_dirty_value_(false), is_checked_(false),
diff --git a/third_party/blink/renderer/core/html/html_image_element.cc b/third_party/blink/renderer/core/html/html_image_element.cc index 3e939b03..3c8d5da 100644 --- a/third_party/blink/renderer/core/html/html_image_element.cc +++ b/third_party/blink/renderer/core/html/html_image_element.cc
@@ -99,6 +99,7 @@ HTMLImageElement::HTMLImageElement(Document& document, bool created_by_parser) : HTMLElement(html_names::kImgTag, document), + ActiveScriptWrappable<HTMLImageElement>({}), image_loader_(MakeGarbageCollected<HTMLImageLoader>(this)), image_device_pixel_ratio_(1.0f), source_(nullptr),
diff --git a/third_party/blink/renderer/core/html/html_plugin_element.cc b/third_party/blink/renderer/core/html/html_plugin_element.cc index 006a54ab..9cd1afb 100644 --- a/third_party/blink/renderer/core/html/html_plugin_element.cc +++ b/third_party/blink/renderer/core/html/html_plugin_element.cc
@@ -127,6 +127,7 @@ Document& doc, const CreateElementFlags flags) : HTMLFrameOwnerElement(tag_name, doc), + ActiveScriptWrappable<HTMLPlugInElement>({}), is_delaying_load_event_(false), // needs_plugin_update_(!IsCreatedByParser) allows HTMLObjectElement to // delay EmbeddedContentView updates until after all children are
diff --git a/third_party/blink/renderer/core/html/media/html_media_element.cc b/third_party/blink/renderer/core/html/media/html_media_element.cc index 3a562d8..e2348c37 100644 --- a/third_party/blink/renderer/core/html/media/html_media_element.cc +++ b/third_party/blink/renderer/core/html/media/html_media_element.cc
@@ -442,6 +442,7 @@ HTMLMediaElement::HTMLMediaElement(const QualifiedName& tag_name, Document& document) : HTMLElement(tag_name, document), + ActiveScriptWrappable<HTMLMediaElement>({}), ExecutionContextLifecycleStateObserver(GetExecutionContext()), load_timer_(document.GetTaskRunner(TaskType::kInternalMedia), this,
diff --git a/third_party/blink/renderer/core/inspector/dom_editor.cc b/third_party/blink/renderer/core/inspector/dom_editor.cc index fbe844f2..190e951 100644 --- a/third_party/blink/renderer/core/inspector/dom_editor.cc +++ b/third_party/blink/renderer/core/inspector/dom_editor.cc
@@ -44,8 +44,6 @@ namespace blink { -using protocol::Response; - class DOMEditor::RemoveChildAction final : public InspectorHistory::Action { public: RemoveChildAction(ContainerNode* parent_node, Node* node) @@ -413,7 +411,7 @@ MakeGarbageCollected<SetNodeValueAction>(node, value), exception_state); } -static Response ToResponse(ExceptionState& exception_state) { +static protocol::Response ToResponse(ExceptionState& exception_state) { if (exception_state.HadException()) { String name_prefix = IsDOMExceptionCode(exception_state.Code()) ? DOMException::GetErrorName( @@ -421,48 +419,51 @@ " " : g_empty_string; String msg = name_prefix + exception_state.Message(); - return Response::ServerError(msg.Utf8()); + return protocol::Response::ServerError(msg.Utf8()); } - return Response::Success(); + return protocol::Response::Success(); } -Response DOMEditor::InsertBefore(ContainerNode* parent_node, - Node* node, - Node* anchor_node) { +protocol::Response DOMEditor::InsertBefore(ContainerNode* parent_node, + Node* node, + Node* anchor_node) { DummyExceptionStateForTesting exception_state; InsertBefore(parent_node, node, anchor_node, exception_state); return ToResponse(exception_state); } -Response DOMEditor::RemoveChild(ContainerNode* parent_node, Node* node) { +protocol::Response DOMEditor::RemoveChild(ContainerNode* parent_node, + Node* node) { DummyExceptionStateForTesting exception_state; RemoveChild(parent_node, node, exception_state); return ToResponse(exception_state); } -Response DOMEditor::SetAttribute(Element* element, - const String& name, - const String& value) { +protocol::Response DOMEditor::SetAttribute(Element* element, + const String& name, + const String& value) { DummyExceptionStateForTesting exception_state; SetAttribute(element, name, value, exception_state); return ToResponse(exception_state); } -Response DOMEditor::RemoveAttribute(Element* element, const String& name) { +protocol::Response DOMEditor::RemoveAttribute(Element* element, + const String& name) { DummyExceptionStateForTesting exception_state; RemoveAttribute(element, name, exception_state); return ToResponse(exception_state); } -Response DOMEditor::SetOuterHTML(Node* node, - const String& html, - Node** new_node) { +protocol::Response DOMEditor::SetOuterHTML(Node* node, + const String& html, + Node** new_node) { DummyExceptionStateForTesting exception_state; SetOuterHTML(node, html, new_node, exception_state); return ToResponse(exception_state); } -Response DOMEditor::SetNodeValue(Node* parent_node, const String& value) { +protocol::Response DOMEditor::SetNodeValue(Node* parent_node, + const String& value) { DummyExceptionStateForTesting exception_state; SetNodeValue(parent_node, value, exception_state); return ToResponse(exception_state);
diff --git a/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc b/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc index c05a4b37..c65eeac2 100644 --- a/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_animation_agent.cc
@@ -61,8 +61,6 @@ } // namespace -using protocol::Response; - InspectorAnimationAgent::InspectorAnimationAgent( InspectedFrames* inspected_frames, InspectorCSSAgent* css_agent, @@ -83,13 +81,13 @@ } } -Response InspectorAnimationAgent::enable() { +protocol::Response InspectorAnimationAgent::enable() { enabled_.Set(true); instrumenting_agents_->AddInspectorAnimationAgent(this); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::disable() { +protocol::Response InspectorAnimationAgent::disable() { setPlaybackRate(1.0); for (const auto& clone : id_to_animation_clone_.Values()) clone->cancel(); @@ -98,7 +96,7 @@ id_to_animation_.clear(); id_to_animation_clone_.clear(); cleared_animations_.clear(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorAnimationAgent::DidCommitLoadForLocalFrame(LocalFrame* frame) { @@ -222,22 +220,25 @@ return animation_object; } -Response InspectorAnimationAgent::getPlaybackRate(double* playback_rate) { +protocol::Response InspectorAnimationAgent::getPlaybackRate( + double* playback_rate) { *playback_rate = ReferenceTimeline().PlaybackRate(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::setPlaybackRate(double playback_rate) { +protocol::Response InspectorAnimationAgent::setPlaybackRate( + double playback_rate) { for (LocalFrame* frame : *inspected_frames_) frame->GetDocument()->Timeline().SetPlaybackRate(playback_rate); playback_rate_.Set(playback_rate); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::getCurrentTime(const String& id, - double* current_time) { +protocol::Response InspectorAnimationAgent::getCurrentTime( + const String& id, + double* current_time) { blink::Animation* animation = nullptr; - Response response = AssertAnimation(id, animation); + protocol::Response response = AssertAnimation(id, animation); if (!response.IsSuccess()) return response; @@ -266,20 +267,22 @@ } } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::setPaused( +protocol::Response InspectorAnimationAgent::setPaused( std::unique_ptr<protocol::Array<String>> animation_ids, bool paused) { for (const String& animation_id : *animation_ids) { blink::Animation* animation = nullptr; - Response response = AssertAnimation(animation_id, animation); + protocol::Response response = AssertAnimation(animation_id, animation); if (!response.IsSuccess()) return response; blink::Animation* clone = AnimationClone(animation); - if (!clone) - return Response::ServerError("Failed to clone detached animation"); + if (!clone) { + return protocol::Response::ServerError( + "Failed to clone detached animation"); + } if (paused && !clone->Paused()) { // Ensure we restore a current time if the animation is limited. absl::optional<AnimationTimeDelta> current_time; @@ -303,7 +306,7 @@ clone->Unpause(); } } - return Response::Success(); + return protocol::Response::Success(); } blink::Animation* InspectorAnimationAgent::AnimationClone( @@ -352,26 +355,28 @@ return clone; } -Response InspectorAnimationAgent::seekAnimations( +protocol::Response InspectorAnimationAgent::seekAnimations( std::unique_ptr<protocol::Array<String>> animation_ids, double current_time) { for (const String& animation_id : *animation_ids) { blink::Animation* animation = nullptr; - Response response = AssertAnimation(animation_id, animation); + protocol::Response response = AssertAnimation(animation_id, animation); if (!response.IsSuccess()) return response; blink::Animation* clone = AnimationClone(animation); - if (!clone) - return Response::ServerError("Failed to clone a detached animation."); + if (!clone) { + return protocol::Response::ServerError( + "Failed to clone a detached animation."); + } if (!clone->Paused()) clone->play(); clone->SetCurrentTimeInternal( ANIMATION_TIME_DELTA_FROM_MILLISECONDS(current_time)); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::releaseAnimations( +protocol::Response InspectorAnimationAgent::releaseAnimations( std::unique_ptr<protocol::Array<String>> animation_ids) { for (const String& animation_id : *animation_ids) { auto it = id_to_animation_.find(animation_id); @@ -386,14 +391,15 @@ id_to_animation_.erase(animation_id); cleared_animations_.insert(animation_id); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::setTiming(const String& animation_id, - double duration, - double delay) { +protocol::Response InspectorAnimationAgent::setTiming( + const String& animation_id, + double duration, + double delay) { blink::Animation* animation = nullptr; - Response response = AssertAnimation(animation_id, animation); + protocol::Response response = AssertAnimation(animation_id, animation); if (!response.IsSuccess()) return response; @@ -406,15 +412,15 @@ duration)); timing->setDelay(MakeGarbageCollected<Timing::V8Delay>(delay)); animation->effect()->updateTiming(timing, exception_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAnimationAgent::resolveAnimation( +protocol::Response InspectorAnimationAgent::resolveAnimation( const String& animation_id, std::unique_ptr<v8_inspector::protocol::Runtime::API::RemoteObject>* result) { blink::Animation* animation = nullptr; - Response response = AssertAnimation(animation_id, animation); + protocol::Response response = AssertAnimation(animation_id, animation); if (!response.IsSuccess()) return response; @@ -427,8 +433,10 @@ Document* document = element->ownerDocument(); LocalFrame* frame = document ? document->GetFrame() : nullptr; ScriptState* script_state = ToScriptStateForMainWorld(frame); - if (!script_state) - return Response::ServerError("Element not associated with a document."); + if (!script_state) { + return protocol::Response::ServerError( + "Element not associated with a document."); + } ScriptState::Scope scope(script_state); static const char kAnimationObjectGroup[] = "animation"; @@ -440,9 +448,11 @@ script_state->GetIsolate()), ToV8InspectorStringView(kAnimationObjectGroup), false /* generatePreview */); - if (!*result) - return Response::ServerError("Element not associated with a document."); - return Response::Success(); + if (!*result) { + return protocol::Response::ServerError( + "Element not associated with a document."); + } + return protocol::Response::Success(); } String InspectorAnimationAgent::CreateCSSId(blink::Animation& animation) { @@ -537,15 +547,17 @@ ReferenceTimeline().PlaybackRate()); } -Response InspectorAnimationAgent::AssertAnimation(const String& id, - blink::Animation*& result) { +protocol::Response InspectorAnimationAgent::AssertAnimation( + const String& id, + blink::Animation*& result) { auto it = id_to_animation_.find(id); if (it == id_to_animation_.end()) { result = nullptr; - return Response::ServerError("Could not find animation with given id"); + return protocol::Response::ServerError( + "Could not find animation with given id"); } result = it->value; - return Response::Success(); + return protocol::Response::Success(); } DocumentTimeline& InspectorAnimationAgent::ReferenceTimeline() {
diff --git a/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc b/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc index 2ddfcf37..440c745 100644 --- a/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_audits_agent.cc
@@ -26,7 +26,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace encoding_enum = protocol::Audits::GetEncodedResponse::EncodingEnum; @@ -141,7 +140,7 @@ String body; bool is_base64_encoded; - Response response = + protocol::Response response = network_agent_->GetResponseBody(request_id, &body, &is_base64_encoded); if (!response.IsSuccess()) return response; @@ -149,14 +148,15 @@ Vector<char> base64_decoded_buffer; if (!is_base64_encoded || !Base64Decode(body, base64_decoded_buffer) || base64_decoded_buffer.size() == 0) { - return Response::ServerError("Failed to decode original image"); + return protocol::Response::ServerError("Failed to decode original image"); } Vector<unsigned char> encoded_image; if (!EncodeAsImage(base64_decoded_buffer.data(), base64_decoded_buffer.size(), encoding, quality.fromMaybe(kDefaultEncodeQuality), &encoded_image)) { - return Response::ServerError("Could not encode image with given settings"); + return protocol::Response::ServerError( + "Could not encode image with given settings"); } *out_original_size = static_cast<int>(base64_decoded_buffer.size()); @@ -165,7 +165,7 @@ if (!size_only.fromMaybe(false)) { *out_body = protocol::Binary::fromVector(std::move(encoded_image)); } - return Response::Success(); + return protocol::Response::Success(); } void InspectorAuditsAgent::CheckContrastForDocument(Document* document, @@ -180,38 +180,41 @@ GetFrontend()->flush(); } -Response InspectorAuditsAgent::checkContrast(protocol::Maybe<bool> report_aaa) { - if (!inspected_frames_) - return Response::ServerError("Inspected frames are not available"); +protocol::Response InspectorAuditsAgent::checkContrast( + protocol::Maybe<bool> report_aaa) { + if (!inspected_frames_) { + return protocol::Response::ServerError( + "Inspected frames are not available"); + } auto* main_window = inspected_frames_->Root()->DomWindow(); if (!main_window) - return Response::ServerError("Document is not available"); + return protocol::Response::ServerError("Document is not available"); CheckContrastForDocument(main_window->document(), report_aaa.fromMaybe(false)); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAuditsAgent::enable() { +protocol::Response InspectorAuditsAgent::enable() { if (enabled_.Get()) { - return Response::Success(); + return protocol::Response::Success(); } enabled_.Set(true); InnerEnable(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorAuditsAgent::disable() { +protocol::Response InspectorAuditsAgent::disable() { if (!enabled_.Get()) { - return Response::Success(); + return protocol::Response::Success(); } enabled_.Clear(); instrumenting_agents_->RemoveInspectorAuditsAgent(this); - return Response::Success(); + return protocol::Response::Success(); } void InspectorAuditsAgent::Restore() {
diff --git a/third_party/blink/renderer/core/inspector/inspector_css_agent.cc b/third_party/blink/renderer/core/inspector/inspector_css_agent.cc index a2d550c..4d10c121 100644 --- a/third_party/blink/renderer/core/inspector/inspector_css_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_css_agent.cc
@@ -127,8 +127,6 @@ namespace blink { -using protocol::Response; - namespace { int g_frontend_operation_counter = 0; @@ -650,8 +648,8 @@ void InspectorCSSAgent::enable(std::unique_ptr<EnableCallback> prp_callback) { if (!dom_agent_->Enabled()) { - prp_callback->sendFailure( - Response::ServerError("DOM agent needs to be enabled first.")); + prp_callback->sendFailure(protocol::Response::ServerError( + "DOM agent needs to be enabled first.")); return; } enable_requested_.Set(true); @@ -699,7 +697,7 @@ } } -Response InspectorCSSAgent::disable() { +protocol::Response InspectorCSSAgent::disable() { Reset(); dom_agent_->RemoveDOMListener(this); instrumenting_agents_->RemoveInspectorCSSAgent(this); @@ -709,7 +707,7 @@ coverage_enabled_.Set(false); local_fonts_enabled_.Set(true); SetCoverageEnabled(false); - return Response::Success(); + return protocol::Response::Success(); } void InspectorCSSAgent::DidCommitLoadForLocalFrame(LocalFrame* frame) { @@ -901,7 +899,7 @@ *result = true; } -Response InspectorCSSAgent::getMediaQueries( +protocol::Response InspectorCSSAgent::getMediaQueries( std::unique_ptr<protocol::Array<protocol::CSS::CSSMedia>>* medias) { *medias = std::make_unique<protocol::Array<protocol::CSS::CSSMedia>>(); for (auto& style : id_to_inspector_style_sheet_) { @@ -916,7 +914,7 @@ CollectMediaQueriesFromRule(rule, medias->get()); } } - return Response::Success(); + return protocol::Response::Success(); } std::unique_ptr<protocol::CSS::CSSLayerData> @@ -941,11 +939,12 @@ return layer_data; } -Response InspectorCSSAgent::getLayersForNode( +protocol::Response InspectorCSSAgent::getLayersForNode( int node_id, std::unique_ptr<protocol::CSS::CSSLayerData>* root_layer) { Element* element = nullptr; - const Response response = dom_agent_->AssertElement(node_id, element); + const protocol::Response response = + dom_agent_->AssertElement(node_id, element); if (!response.IsSuccess()) return response; @@ -959,12 +958,12 @@ // GetScopedStyleResolver returns a nullptr if the tree scope has no // stylesheets. if (!scoped_resolver) - return Response::Success(); + return protocol::Response::Success(); const CascadeLayerMap* layer_map = scoped_resolver->GetCascadeLayerMap(); if (!layer_map) - return Response::Success(); + return protocol::Response::Success(); const CascadeLayer* root = layer_map->GetRootLayer(); unsigned max_order = 0; @@ -975,10 +974,10 @@ (*root_layer)->setOrder(max_order + 1); (*root_layer)->setSubLayers(std::move(sublayers_data)); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::getMatchedStylesForNode( +protocol::Response InspectorCSSAgent::getMatchedStylesForNode( int node_id, Maybe<protocol::CSS::CSSStyle>* inline_style, Maybe<protocol::CSS::CSSStyle>* attributes_style, @@ -994,7 +993,7 @@ Maybe<protocol::Array<protocol::CSS::CSSPositionFallbackRule>>* css_position_fallback_rules, Maybe<int>* parentLayoutNodeId) { - Response response = AssertEnabled(); + protocol::Response response = AssertEnabled(); if (!response.IsSuccess()) return response; @@ -1009,12 +1008,12 @@ AtomicString view_transition_name = g_null_atom; element = GetPseudoIdAndTag(element, element_pseudo_id, view_transition_name); if (!element) - return Response::ServerError("Pseudo element has no parent"); + return protocol::Response::ServerError("Pseudo element has no parent"); Document& document = element->GetDocument(); // A non-active document has no styles. if (!document.IsActive()) - return Response::ServerError("Document is not active"); + return protocol::Response::ServerError("Document is not active"); // The source text of mutable stylesheets needs to be updated // to sync the latest changes. @@ -1052,7 +1051,7 @@ // Pseudo elements. if (element_pseudo_id) - return Response::Success(); + return protocol::Response::Success(); InspectorStyleSheetForInlineStyle* inline_style_sheet = AsInspectorStyleSheet(element); @@ -1117,7 +1116,7 @@ *parentLayoutNodeId = boundNodeId; } - return Response::Success(); + return protocol::Response::Success(); } template <class CSSRuleCollection> @@ -1305,11 +1304,11 @@ return css_keyframes_rules; } -Response InspectorCSSAgent::getInlineStylesForNode( +protocol::Response InspectorCSSAgent::getInlineStylesForNode( int node_id, Maybe<protocol::CSS::CSSStyle>* inline_style, Maybe<protocol::CSS::CSSStyle>* attributes_style) { - Response response = AssertEnabled(); + protocol::Response response = AssertEnabled(); if (!response.IsSuccess()) return response; Element* element = nullptr; @@ -1320,26 +1319,28 @@ InspectorStyleSheetForInlineStyle* style_sheet = AsInspectorStyleSheet(element); if (!style_sheet) - return Response::ServerError("Element is not a style sheet"); + return protocol::Response::ServerError("Element is not a style sheet"); *inline_style = style_sheet->BuildObjectForStyle(element->style()); *attributes_style = BuildObjectForAttributesStyle(element); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::getComputedStyleForNode( +protocol::Response InspectorCSSAgent::getComputedStyleForNode( int node_id, std::unique_ptr<protocol::Array<protocol::CSS::CSSComputedStyleProperty>>* style) { - Response response = AssertEnabled(); + protocol::Response response = AssertEnabled(); if (!response.IsSuccess()) return response; Node* node = nullptr; response = dom_agent_->AssertNode(node_id, node); if (!response.IsSuccess()) return response; - if (!node->ownerDocument()) - return Response::ServerError("Node does not have an owner document"); + if (!node->ownerDocument()) { + return protocol::Response::ServerError( + "Node does not have an owner document"); + } auto* computed_style_info = MakeGarbageCollected<CSSComputedStyleDeclaration>(node, true); @@ -1364,7 +1365,7 @@ .setValue(it.value->CssText()) .build()); } - return Response::Success(); + return protocol::Response::Success(); } void InspectorCSSAgent::CollectPlatformFontsForLayoutObject( @@ -1409,11 +1410,11 @@ } } -Response InspectorCSSAgent::getPlatformFontsForNode( +protocol::Response InspectorCSSAgent::getPlatformFontsForNode( int node_id, std::unique_ptr<protocol::Array<protocol::CSS::PlatformFontUsage>>* platform_fonts) { - Response response = AssertEnabled(); + protocol::Response response = AssertEnabled(); if (!response.IsSuccess()) return response; Node* node = nullptr; @@ -1441,40 +1442,41 @@ .setGlyphCount(font.value) .build()); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::getStyleSheetText(const String& style_sheet_id, - String* result) { +protocol::Response InspectorCSSAgent::getStyleSheetText( + const String& style_sheet_id, + String* result) { InspectorStyleSheetBase* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; inspector_style_sheet->GetText(result); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::collectClassNames( +protocol::Response InspectorCSSAgent::collectClassNames( const String& style_sheet_id, std::unique_ptr<protocol::Array<String>>* class_names) { InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; *class_names = inspector_style_sheet->CollectClassNames(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::setStyleSheetText( +protocol::Response InspectorCSSAgent::setStyleSheetText( const String& style_sheet_id, const String& text, protocol::Maybe<String>* source_map_url) { FrontendOperationScope scope; InspectorStyleSheetBase* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1488,27 +1490,27 @@ return response; if (!inspector_style_sheet->SourceMapURL().empty()) *source_map_url = inspector_style_sheet->SourceMapURL(); - return Response::Success(); + return protocol::Response::Success(); } -static Response JsonRangeToSourceRange( +static protocol::Response JsonRangeToSourceRange( InspectorStyleSheetBase* inspector_style_sheet, protocol::CSS::SourceRange* range, SourceRange* source_range) { if (range->getStartLine() < 0) { - return Response::ServerError( + return protocol::Response::ServerError( "range.startLine must be a non-negative integer"); } if (range->getStartColumn() < 0) { - return Response::ServerError( + return protocol::Response::ServerError( "range.startColumn must be a non-negative integer"); } if (range->getEndLine() < 0) { - return Response::ServerError( + return protocol::Response::ServerError( "range.endLine must be a non-negative integer"); } if (range->getEndColumn() < 0) { - return Response::ServerError( + return protocol::Response::ServerError( "range.endColumn must be a non-negative integer"); } @@ -1520,23 +1522,25 @@ inspector_style_sheet->LineNumberAndColumnToOffset( range->getEndLine(), range->getEndColumn(), &end_offset); if (!success) - return Response::ServerError("Specified range is out of bounds"); + return protocol::Response::ServerError("Specified range is out of bounds"); - if (start_offset > end_offset) - return Response::ServerError("Range start must not succeed its end"); + if (start_offset > end_offset) { + return protocol::Response::ServerError( + "Range start must not succeed its end"); + } source_range->start = start_offset; source_range->end = end_offset; - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::setRuleSelector( +protocol::Response InspectorCSSAgent::setRuleSelector( const String& style_sheet_id, std::unique_ptr<protocol::CSS::SourceRange> range, const String& selector, std::unique_ptr<protocol::CSS::SelectorList>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1555,7 +1559,7 @@ CSSStyleRule* rule = InspectorCSSAgent::AsCSSStyleRule(action->TakeRule()); inspector_style_sheet = InspectorStyleSheetForRule(rule); if (!inspector_style_sheet) { - return Response::ServerError( + return protocol::Response::ServerError( "Failed to get inspector style sheet for rule."); } *result = inspector_style_sheet->BuildObjectForSelectorList(rule); @@ -1563,14 +1567,14 @@ return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::setKeyframeKey( +protocol::Response InspectorCSSAgent::setKeyframeKey( const String& style_sheet_id, std::unique_ptr<protocol::CSS::SourceRange> range, const String& key_text, std::unique_ptr<protocol::CSS::Value>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1589,7 +1593,7 @@ auto* rule = To<CSSKeyframeRule>(action->TakeRule()); inspector_style_sheet = BindStyleSheet(rule->parentStyleSheet()); if (!inspector_style_sheet) { - return Response::ServerError( + return protocol::Response::ServerError( "Failed to get inspector style sheet for rule."); } CSSRuleSourceData* source_data = @@ -1603,20 +1607,20 @@ return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::MultipleStyleTextsActions( +protocol::Response InspectorCSSAgent::MultipleStyleTextsActions( std::unique_ptr<protocol::Array<protocol::CSS::StyleDeclarationEdit>> edits, HeapVector<Member<StyleSheetAction>>* actions) { size_t n = edits->size(); if (n == 0) - return Response::ServerError("Edits should not be empty"); + return protocol::Response::ServerError("Edits should not be empty"); for (size_t i = 0; i < n; ++i) { protocol::CSS::StyleDeclarationEdit* edit = (*edits)[i].get(); InspectorStyleSheetBase* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertStyleSheetForId(edit->getStyleSheetId(), inspector_style_sheet); if (!response.IsSuccess()) { - return Response::ServerError( + return protocol::Response::ServerError( String::Format("StyleSheet not found for edit #%zu of %zu", i + 1, n) .Utf8()); } @@ -1643,15 +1647,16 @@ actions->push_back(action); } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::setStyleTexts( +protocol::Response InspectorCSSAgent::setStyleTexts( std::unique_ptr<protocol::Array<protocol::CSS::StyleDeclarationEdit>> edits, std::unique_ptr<protocol::Array<protocol::CSS::CSSStyle>>* result) { FrontendOperationScope scope; HeapVector<Member<StyleSheetAction>> actions; - Response response = MultipleStyleTextsActions(std::move(edits), &actions); + protocol::Response response = + MultipleStyleTextsActions(std::move(edits), &actions); if (!response.IsSuccess()) return response; @@ -1670,7 +1675,7 @@ revert->Undo(undo_exception_state); DCHECK(!undo_exception_state.HadException()); } - return Response::ServerError( + return protocol::Response::ServerError( String::Format("Failed applying edit #%d: ", i).Utf8() + InspectorDOMAgent::ToResponse(exception_state).Message()); } @@ -1682,10 +1687,10 @@ dom_agent_->History()->AppendPerformedAction(action); } *result = std::move(serialized_styles); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::SetStyleText( +protocol::Response InspectorCSSAgent::SetStyleText( InspectorStyleSheetBase* inspector_style_sheet, const SourceRange& range, const String& text, @@ -1699,7 +1704,7 @@ bool success = dom_agent_->History()->Perform(action, exception_state); if (success) { result = inline_style_sheet->InlineStyle(); - return Response::Success(); + return protocol::Response::Success(); } } else { ModifyRuleAction* action = MakeGarbageCollected<ModifyRuleAction>( @@ -1710,25 +1715,25 @@ CSSRule* rule = action->TakeRule(); if (auto* style_rule = DynamicTo<CSSStyleRule>(rule)) { result = style_rule->style(); - return Response::Success(); + return protocol::Response::Success(); } if (auto* keyframe_rule = DynamicTo<CSSKeyframeRule>(rule)) { result = keyframe_rule->style(); - return Response::Success(); + return protocol::Response::Success(); } } } return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::setMediaText( +protocol::Response InspectorCSSAgent::setMediaText( const String& style_sheet_id, std::unique_ptr<protocol::CSS::SourceRange> range, const String& text, std::unique_ptr<protocol::CSS::CSSMedia>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1755,14 +1760,14 @@ return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::setContainerQueryText( +protocol::Response InspectorCSSAgent::setContainerQueryText( const String& style_sheet_id, std::unique_ptr<protocol::CSS::SourceRange> range, const String& text, std::unique_ptr<protocol::CSS::CSSContainerQuery>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1785,14 +1790,14 @@ return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::setScopeText( +protocol::Response InspectorCSSAgent::setScopeText( const String& style_sheet_id, std::unique_ptr<protocol::CSS::SourceRange> range, const String& text, std::unique_ptr<protocol::CSS::CSSScope>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1814,14 +1819,14 @@ return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::setSupportsText( +protocol::Response InspectorCSSAgent::setSupportsText( const String& style_sheet_id, std::unique_ptr<protocol::CSS::SourceRange> range, const String& text, std::unique_ptr<protocol::CSS::CSSSupports>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1844,36 +1849,36 @@ return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorCSSAgent::createStyleSheet( +protocol::Response InspectorCSSAgent::createStyleSheet( const String& frame_id, protocol::CSS::StyleSheetId* out_style_sheet_id) { LocalFrame* frame = IdentifiersFactory::FrameById(inspected_frames_, frame_id); if (!frame) - return Response::ServerError("Frame not found"); + return protocol::Response::ServerError("Frame not found"); Document* document = frame->GetDocument(); if (!document) - return Response::ServerError("Frame does not have a document"); + return protocol::Response::ServerError("Frame does not have a document"); InspectorStyleSheet* inspector_style_sheet = ViaInspectorStyleSheet(document); if (!inspector_style_sheet) - return Response::ServerError("No target stylesheet found"); + return protocol::Response::ServerError("No target stylesheet found"); UpdateActiveStyleSheets(document); *out_style_sheet_id = inspector_style_sheet->Id(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::addRule( +protocol::Response InspectorCSSAgent::addRule( const String& style_sheet_id, const String& rule_text, std::unique_ptr<protocol::CSS::SourceRange> location, std::unique_ptr<protocol::CSS::CSSRule>* result) { FrontendOperationScope scope; InspectorStyleSheet* inspector_style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, inspector_style_sheet); if (!response.IsSuccess()) return response; @@ -1892,13 +1897,13 @@ CSSStyleRule* rule = action->TakeRule(); *result = BuildObjectForRule(rule); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::forcePseudoState( +protocol::Response InspectorCSSAgent::forcePseudoState( int node_id, std::unique_ptr<protocol::Array<String>> forced_pseudo_classes) { - Response response = AssertEnabled(); + protocol::Response response = AssertEnabled(); if (!response.IsSuccess()) return response; Element* element = nullptr; @@ -1914,7 +1919,7 @@ it == node_id_to_forced_pseudo_state_.end() ? 0 : it->value; bool need_style_recalc = forced_pseudo_state != current_forced_pseudo_state; if (!need_style_recalc) - return Response::Success(); + return protocol::Response::Success(); if (forced_pseudo_state) node_id_to_forced_pseudo_state_.Set(node_id, forced_pseudo_state); @@ -1943,7 +1948,7 @@ element->GetDocument().GetStyleEngine().MarkAllElementsForStyleRecalc( StyleChangeReasonForTracing::Create(style_change_reason::kInspector)); - return Response::Success(); + return protocol::Response::Success(); } void InspectorCSSAgent::IncrementFocusedCountForAncestors(Element* element) { @@ -2466,30 +2471,33 @@ : nullptr; } -Response InspectorCSSAgent::AssertEnabled() { - return enable_completed_ ? Response::Success() - : Response::ServerError("CSS agent was not enabled"); +protocol::Response InspectorCSSAgent::AssertEnabled() { + return enable_completed_ + ? protocol::Response::Success() + : protocol::Response::ServerError("CSS agent was not enabled"); } -Response InspectorCSSAgent::AssertInspectorStyleSheetForId( +protocol::Response InspectorCSSAgent::AssertInspectorStyleSheetForId( const String& style_sheet_id, InspectorStyleSheet*& result) { - Response response = AssertEnabled(); + protocol::Response response = AssertEnabled(); if (!response.IsSuccess()) return response; IdToInspectorStyleSheet::iterator it = id_to_inspector_style_sheet_.find(style_sheet_id); - if (it == id_to_inspector_style_sheet_.end()) - return Response::ServerError("No style sheet with given id found"); + if (it == id_to_inspector_style_sheet_.end()) { + return protocol::Response::ServerError( + "No style sheet with given id found"); + } result = it->value.Get(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::AssertStyleSheetForId( +protocol::Response InspectorCSSAgent::AssertStyleSheetForId( const String& style_sheet_id, InspectorStyleSheetBase*& result) { InspectorStyleSheet* style_sheet = nullptr; - Response response = + protocol::Response response = AssertInspectorStyleSheetForId(style_sheet_id, style_sheet); if (response.IsSuccess()) { result = style_sheet; @@ -2497,10 +2505,12 @@ } IdToInspectorStyleSheetForInlineStyle::iterator it = id_to_inspector_style_sheet_for_inline_style_.find(style_sheet_id); - if (it == id_to_inspector_style_sheet_for_inline_style_.end()) - return Response::ServerError("No style sheet with given id found"); + if (it == id_to_inspector_style_sheet_for_inline_style_.end()) { + return protocol::Response::ServerError( + "No style sheet with given id found"); + } result = it->value.Get(); - return Response::Success(); + return protocol::Response::Success(); } protocol::CSS::StyleSheetOrigin InspectorCSSAgent::DetectOrigin( @@ -2754,31 +2764,31 @@ return found_style ? found_style : styles.at(0).Get(); } -Response InspectorCSSAgent::setEffectivePropertyValueForNode( +protocol::Response InspectorCSSAgent::setEffectivePropertyValueForNode( int node_id, const String& property_name, const String& value) { Element* element = nullptr; - Response response = dom_agent_->AssertElement(node_id, element); + protocol::Response response = dom_agent_->AssertElement(node_id, element); if (!response.IsSuccess()) return response; if (element->GetPseudoId()) - return Response::ServerError("Elements is pseudo"); + return protocol::Response::ServerError("Elements is pseudo"); if (!element->GetDocument().IsActive()) { - return Response::ServerError( + return protocol::Response::ServerError( "Can't edit a node from a non-active document"); } absl::optional<CSSPropertyName> css_property_name = CSSPropertyName::From(element->GetExecutionContext(), property_name); if (!css_property_name.has_value()) - return Response::ServerError("Invalid property name"); + return protocol::Response::ServerError("Invalid property name"); CSSStyleDeclaration* style = FindEffectiveDeclaration(*css_property_name, MatchingStyles(element)); if (!style) - return Response::ServerError("Can't find a style to edit"); + return protocol::Response::ServerError("Can't find a style to edit"); bool force_important = false; InspectorStyleSheetBase* inspector_style_sheet = nullptr; @@ -2797,7 +2807,7 @@ } if (!source_data) - return Response::ServerError("Can't find a source to edit"); + return protocol::Response::ServerError("Can't find a source to edit"); Vector<StylePropertyShorthand, 4> shorthands; getMatchingShorthandsForLonghand(css_property_name->Id(), &shorthands); @@ -2863,13 +2873,13 @@ result_style); } -Response InspectorCSSAgent::getBackgroundColors( +protocol::Response InspectorCSSAgent::getBackgroundColors( int node_id, Maybe<protocol::Array<String>>* background_colors, Maybe<String>* computed_font_size, Maybe<String>* computed_font_weight) { Element* element = nullptr; - Response response = dom_agent_->AssertElement(node_id, element); + protocol::Response response = dom_agent_->AssertElement(node_id, element); if (!response.IsSuccess()) return response; @@ -2891,7 +2901,7 @@ *computed_font_size = fs; if (!fw.empty()) *computed_font_weight = fw; - return Response::Success(); + return protocol::Response::Success(); } // static @@ -2920,7 +2930,7 @@ resource_container_->EraseStyleElementContent(DOMNodeIds::IdForNode(element)); } -Response InspectorCSSAgent::startRuleUsageTracking() { +protocol::Response InspectorCSSAgent::startRuleUsageTracking() { coverage_enabled_.Set(true); SetCoverageEnabled(true); @@ -2930,15 +2940,15 @@ document->UpdateStyleAndLayoutTree(); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::stopRuleUsageTracking( +protocol::Response InspectorCSSAgent::stopRuleUsageTracking( std::unique_ptr<protocol::Array<protocol::CSS::RuleUsage>>* result) { for (Document* document : dom_agent_->Documents()) document->UpdateStyleAndLayoutTree(); double timestamp; - Response response = takeCoverageDelta(result, ×tamp); + protocol::Response response = takeCoverageDelta(result, ×tamp); SetCoverageEnabled(false); return response; } @@ -2967,11 +2977,13 @@ } } -Response InspectorCSSAgent::takeCoverageDelta( +protocol::Response InspectorCSSAgent::takeCoverageDelta( std::unique_ptr<protocol::Array<protocol::CSS::RuleUsage>>* result, double* out_timestamp) { - if (!tracker_) - return Response::ServerError("CSS rule usage tracking is not enabled"); + if (!tracker_) { + return protocol::Response::ServerError( + "CSS rule usage tracking is not enabled"); + } StyleRuleUsageTracker::RuleListByStyleSheet coverage_delta = tracker_->TakeDelta(); @@ -3015,10 +3027,10 @@ } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorCSSAgent::trackComputedStyleUpdates( +protocol::Response InspectorCSSAgent::trackComputedStyleUpdates( std::unique_ptr<protocol::Array<protocol::CSS::CSSComputedStyleProperty>> properties_to_track) { tracked_computed_styles_.clear(); @@ -3029,7 +3041,7 @@ computed_style_updated_callback_ = nullptr; } computed_style_updated_node_ids_.clear(); - return Response::Success(); + return protocol::Response::Success(); } for (const auto& property : *properties_to_track) { @@ -3045,20 +3057,20 @@ } } - return Response::Success(); + return protocol::Response::Success(); } void InspectorCSSAgent::takeComputedStyleUpdates( std::unique_ptr<TakeComputedStyleUpdatesCallback> callback) { if (tracked_computed_styles_.empty()) { - callback->sendFailure(Response::ServerError( + callback->sendFailure(protocol::Response::ServerError( "No computed styles are being tracked right now.")); return; } if (computed_style_updated_callback_) { - callback->sendFailure( - Response::ServerError("A previous request has not been resolved yet.")); + callback->sendFailure(protocol::Response::ServerError( + "A previous request has not been resolved yet.")); return; } @@ -3163,11 +3175,11 @@ *result = false; } -Response InspectorCSSAgent::setLocalFontsEnabled(bool enabled) { +protocol::Response InspectorCSSAgent::setLocalFontsEnabled(bool enabled) { local_fonts_enabled_.Set(enabled); // TODO(alexrudenko): how to rerender fonts so that // local_fonts_enabled_ applies without page reload? - return Response::Success(); + return protocol::Response::Success(); } } // namespace blink
diff --git a/third_party/blink/renderer/core/inspector/inspector_dom_agent.cc b/third_party/blink/renderer/core/inspector/inspector_dom_agent.cc index a2936a4..fbe48c2f 100644 --- a/third_party/blink/renderer/core/inspector/inspector_dom_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_dom_agent.cc
@@ -104,7 +104,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace { @@ -173,7 +172,8 @@ visitor->Trace(timer_); } -Response InspectorDOMAgent::ToResponse(ExceptionState& exception_state) { +protocol::Response InspectorDOMAgent::ToResponse( + ExceptionState& exception_state) { if (exception_state.HadException()) { String name_prefix = IsDOMExceptionCode(exception_state.Code()) ? DOMException::GetErrorName( @@ -181,9 +181,9 @@ " " : g_empty_string; String msg = name_prefix + exception_state.Message(); - return Response::ServerError(msg.Utf8()); + return protocol::Response::ServerError(msg.Utf8()); } - return Response::Success(); + return protocol::Response::Success(); } protocol::DOM::PseudoType InspectorDOMAgent::ProtocolPseudoElementType( @@ -410,14 +410,14 @@ cached_child_count_.erase(id); } -Response InspectorDOMAgent::AssertNode(int node_id, Node*& node) { +protocol::Response InspectorDOMAgent::AssertNode(int node_id, Node*& node) { node = NodeForId(node_id); if (!node) - return Response::ServerError("Could not find node with given id"); - return Response::Success(); + return protocol::Response::ServerError("Could not find node with given id"); + return protocol::Response::Success(); } -Response InspectorDOMAgent::AssertNode( +protocol::Response InspectorDOMAgent::AssertNode( const protocol::Maybe<int>& node_id, const protocol::Maybe<int>& backend_node_id, const protocol::Maybe<String>& object_id, @@ -427,27 +427,29 @@ if (backend_node_id.isJust()) { node = DOMNodeIds::NodeForId(backend_node_id.fromJust()); - return !node ? Response::ServerError("No node found for given backend id") - : Response::Success(); + return !node ? protocol::Response::ServerError( + "No node found for given backend id") + : protocol::Response::Success(); } if (object_id.isJust()) return NodeForRemoteObjectId(object_id.fromJust(), node); - return Response::ServerError( + return protocol::Response::ServerError( "Either nodeId, backendNodeId or objectId must be specified"); } -Response InspectorDOMAgent::AssertElement(int node_id, Element*& element) { +protocol::Response InspectorDOMAgent::AssertElement(int node_id, + Element*& element) { Node* node = nullptr; - Response response = AssertNode(node_id, node); + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; element = DynamicTo<Element>(node); if (!element) - return Response::ServerError("Node is not an Element"); - return Response::Success(); + return protocol::Response::ServerError("Node is not an Element"); + return protocol::Response::Success(); } // static @@ -464,51 +466,53 @@ return shadow_root->IsUserAgent() ? shadow_root : nullptr; } -Response InspectorDOMAgent::AssertEditableNode(int node_id, Node*& node) { - Response response = AssertNode(node_id, node); +protocol::Response InspectorDOMAgent::AssertEditableNode(int node_id, + Node*& node) { + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; if (node->IsInShadowTree()) { if (IsA<ShadowRoot>(node)) - return Response::ServerError("Cannot edit shadow roots"); + return protocol::Response::ServerError("Cannot edit shadow roots"); if (UserAgentShadowRoot(node)) { - return Response::ServerError( + return protocol::Response::ServerError( "Cannot edit nodes from user-agent shadow trees"); } } if (node->IsPseudoElement()) - return Response::ServerError("Cannot edit pseudo elements"); - return Response::Success(); + return protocol::Response::ServerError("Cannot edit pseudo elements"); + return protocol::Response::Success(); } -Response InspectorDOMAgent::AssertEditableChildNode(Element* parent_element, - int node_id, - Node*& node) { - Response response = AssertEditableNode(node_id, node); +protocol::Response InspectorDOMAgent::AssertEditableChildNode( + Element* parent_element, + int node_id, + Node*& node) { + protocol::Response response = AssertEditableNode(node_id, node); if (!response.IsSuccess()) return response; if (node->parentNode() != parent_element) { - return Response::ServerError( + return protocol::Response::ServerError( "Anchor node must be child of the target element"); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::AssertEditableElement(int node_id, - Element*& element) { - Response response = AssertElement(node_id, element); +protocol::Response InspectorDOMAgent::AssertEditableElement(int node_id, + Element*& element) { + protocol::Response response = AssertElement(node_id, element); if (!response.IsSuccess()) return response; if (element->IsInShadowTree() && UserAgentShadowRoot(element)) { - return Response::ServerError( + return protocol::Response::ServerError( "Cannot edit elements from user-agent shadow trees"); } if (element->IsPseudoElement()) - return Response::ServerError("Cannot edit pseudo elements"); + return protocol::Response::ServerError("Cannot edit pseudo elements"); - return Response::Success(); + return protocol::Response::Success(); } void InspectorDOMAgent::EnableAndReset() { @@ -519,7 +523,7 @@ instrumenting_agents_->AddInspectorDOMAgent(this); } -Response InspectorDOMAgent::enable(Maybe<String> includeWhitespace) { +protocol::Response InspectorDOMAgent::enable(Maybe<String> includeWhitespace) { if (!enabled_.Get()) { EnableAndReset(); include_whitespace_.Set(static_cast<int32_t>( @@ -529,22 +533,22 @@ ? InspectorDOMAgent::IncludeWhitespaceEnum::ALL : InspectorDOMAgent::IncludeWhitespaceEnum::NONE)); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::disable() { +protocol::Response InspectorDOMAgent::disable() { if (!enabled_.Get()) - return Response::ServerError("DOM agent hasn't been enabled"); + return protocol::Response::ServerError("DOM agent hasn't been enabled"); include_whitespace_.Clear(); enabled_.Clear(); instrumenting_agents_->RemoveInspectorDOMAgent(this); history_.Clear(); dom_editor_.Clear(); SetDocument(nullptr); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getDocument( +protocol::Response InspectorDOMAgent::getDocument( Maybe<int> depth, Maybe<bool> pierce, std::unique_ptr<protocol::DOM::Node>* root) { @@ -553,7 +557,7 @@ enable(Maybe<String>()); if (!document_) - return Response::ServerError("Document is not available"); + return protocol::Response::ServerError("Document is not available"); DiscardFrontendBindings(); @@ -564,7 +568,7 @@ *root = BuildObjectForNode(document_.Get(), sanitized_depth, pierce.fromMaybe(false), document_node_to_id_map_.Get()); - return Response::Success(); + return protocol::Response::Success(); } namespace { @@ -589,20 +593,20 @@ } // namespace -Response InspectorDOMAgent::getNodesForSubtreeByStyle( +protocol::Response InspectorDOMAgent::getNodesForSubtreeByStyle( int node_id, std::unique_ptr<protocol::Array<protocol::DOM::CSSComputedStyleProperty>> computed_styles, Maybe<bool> pierce, std::unique_ptr<protocol::Array<int>>* node_ids) { if (!enabled_.Get()) - return Response::ServerError("DOM agent hasn't been enabled"); + return protocol::Response::ServerError("DOM agent hasn't been enabled"); if (!document_) - return Response::ServerError("Document is not available"); + return protocol::Response::ServerError("Document is not available"); Node* root_node = nullptr; - Response response = AssertNode(node_id, root_node); + protocol::Response response = AssertNode(node_id, root_node); if (!response.IsSuccess()) return response; @@ -611,7 +615,7 @@ absl::optional<CSSPropertyName> property_name = CSSPropertyName::From( document_->GetExecutionContext(), style->getName()); if (!property_name) - return Response::InvalidParams("Invalid CSS property name"); + return protocol::Response::InvalidParams("Invalid CSS property name"); auto property_id = property_name->Id(); HashMap<CSSPropertyID, HashSet<String>>::iterator it = properties.find(property_id); @@ -635,18 +639,18 @@ (*node_ids)->push_back(id); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getFlattenedDocument( +protocol::Response InspectorDOMAgent::getFlattenedDocument( Maybe<int> depth, Maybe<bool> pierce, std::unique_ptr<protocol::Array<protocol::DOM::Node>>* nodes) { if (!enabled_.Get()) - return Response::ServerError("DOM agent hasn't been enabled"); + return protocol::Response::ServerError("DOM agent hasn't been enabled"); if (!document_) - return Response::ServerError("Document is not available"); + return protocol::Response::ServerError("Document is not available"); DiscardFrontendBindings(); @@ -658,7 +662,7 @@ (*nodes)->emplace_back(BuildObjectForNode( document_.Get(), sanitized_depth, pierce.fromMaybe(false), document_node_to_id_map_.Get(), nodes->get())); - return Response::Success(); + return protocol::Response::Success(); } void InspectorDOMAgent::PushChildNodesToFrontend(int node_id, @@ -718,18 +722,22 @@ return nullptr; } -Response InspectorDOMAgent::collectClassNamesFromSubtree( +protocol::Response InspectorDOMAgent::collectClassNamesFromSubtree( int node_id, std::unique_ptr<protocol::Array<String>>* class_names) { HashSet<String> unique_names; *class_names = std::make_unique<protocol::Array<String>>(); Node* parent_node = NodeForId(node_id); - if (!parent_node) - return Response::ServerError("No suitable node with given id found"); + if (!parent_node) { + return protocol::Response::ServerError( + "No suitable node with given id found"); + } auto* parent_element = DynamicTo<Element>(parent_node); if (!parent_element && !parent_node->IsDocumentNode() && - !parent_node->IsDocumentFragment()) - return Response::ServerError("No suitable node with given id found"); + !parent_node->IsDocumentFragment()) { + return protocol::Response::ServerError( + "No suitable node with given id found"); + } for (Node* node = parent_node; node; node = FlatTreeTraversal::Next(*node, parent_node)) { @@ -743,16 +751,16 @@ } for (const String& class_name : unique_names) (*class_names)->emplace_back(class_name); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::requestChildNodes( +protocol::Response InspectorDOMAgent::requestChildNodes( int node_id, Maybe<int> depth, Maybe<bool> maybe_taverse_frames) { int sanitized_depth = depth.fromMaybe(1); if (sanitized_depth == 0 || sanitized_depth < -1) { - return Response::ServerError( + return protocol::Response::ServerError( "Please provide a positive integer as a depth or -1 for entire " "subtree"); } @@ -761,61 +769,61 @@ PushChildNodesToFrontend(node_id, sanitized_depth, maybe_taverse_frames.fromMaybe(false)); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::querySelector(int node_id, - const String& selectors, - int* element_id) { +protocol::Response InspectorDOMAgent::querySelector(int node_id, + const String& selectors, + int* element_id) { *element_id = 0; Node* node = nullptr; - Response response = AssertNode(node_id, node); + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; auto* container_node = DynamicTo<ContainerNode>(node); if (!container_node) - return Response::ServerError("Not a container node"); + return protocol::Response::ServerError("Not a container node"); DummyExceptionStateForTesting exception_state; Element* element = container_node->QuerySelector(AtomicString(selectors), exception_state); if (exception_state.HadException()) - return Response::ServerError("DOM Error while querying"); + return protocol::Response::ServerError("DOM Error while querying"); if (element) *element_id = PushNodePathToFrontend(element); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::querySelectorAll( +protocol::Response InspectorDOMAgent::querySelectorAll( int node_id, const String& selectors, std::unique_ptr<protocol::Array<int>>* result) { Node* node = nullptr; - Response response = AssertNode(node_id, node); + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; auto* container_node = DynamicTo<ContainerNode>(node); if (!container_node) - return Response::ServerError("Not a container node"); + return protocol::Response::ServerError("Not a container node"); DummyExceptionStateForTesting exception_state; StaticElementList* elements = container_node->QuerySelectorAll( AtomicString(selectors), exception_state); if (exception_state.HadException()) - return Response::ServerError("DOM Error while querying"); + return protocol::Response::ServerError("DOM Error while querying"); *result = std::make_unique<protocol::Array<int>>(); for (unsigned i = 0; i < elements->length(); ++i) (*result)->emplace_back(PushNodePathToFrontend(elements->item(i))); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getTopLayerElements( +protocol::Response InspectorDOMAgent::getTopLayerElements( std::unique_ptr<protocol::Array<int>>* result) { if (!document_) - return Response::ServerError("DOM agent hasn't been enabled"); + return protocol::Response::ServerError("DOM agent hasn't been enabled"); *result = std::make_unique<protocol::Array<int>>(); for (auto document : Documents()) { @@ -826,7 +834,7 @@ } } - return Response::Success(); + return protocol::Response::Success(); } int InspectorDOMAgent::PushNodePathToFrontend(Node* node_to_push, @@ -895,21 +903,21 @@ return it != document_node_to_id_map_->end() ? it->value : 0; } -Response InspectorDOMAgent::setAttributeValue(int element_id, - const String& name, - const String& value) { +protocol::Response InspectorDOMAgent::setAttributeValue(int element_id, + const String& name, + const String& value) { Element* element = nullptr; - Response response = AssertEditableElement(element_id, element); + protocol::Response response = AssertEditableElement(element_id, element); if (!response.IsSuccess()) return response; return dom_editor_->SetAttribute(element, name, value); } -Response InspectorDOMAgent::setAttributesAsText(int element_id, - const String& text, - Maybe<String> name) { +protocol::Response InspectorDOMAgent::setAttributesAsText(int element_id, + const String& text, + Maybe<String> name) { Element* element = nullptr; - Response response = AssertEditableElement(element_id, element); + protocol::Response response = AssertEditableElement(element_id, element); if (!response.IsSuccess()) return response; @@ -949,8 +957,10 @@ Element* parsed_element = getParsedElement(element, contextElement, text, is_html_document); - if (!parsed_element) - return Response::ServerError("Could not parse value as attributes"); + if (!parsed_element) { + return protocol::Response::ServerError( + "Could not parse value as attributes"); + } bool should_ignore_case = is_html_document && element->IsHTMLElement(); String case_adjusted_name = should_ignore_case @@ -979,39 +989,39 @@ name.fromJust().LengthWithStrippedWhiteSpace() > 0) { return dom_editor_->RemoveAttribute(element, case_adjusted_name); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::removeAttribute(int element_id, - const String& name) { +protocol::Response InspectorDOMAgent::removeAttribute(int element_id, + const String& name) { Element* element = nullptr; - Response response = AssertEditableElement(element_id, element); + protocol::Response response = AssertEditableElement(element_id, element); if (!response.IsSuccess()) return response; return dom_editor_->RemoveAttribute(element, name); } -Response InspectorDOMAgent::removeNode(int node_id) { +protocol::Response InspectorDOMAgent::removeNode(int node_id) { Node* node = nullptr; - Response response = AssertEditableNode(node_id, node); + protocol::Response response = AssertEditableNode(node_id, node); if (!response.IsSuccess()) return response; ContainerNode* parent_node = node->parentNode(); if (!parent_node) - return Response::ServerError("Cannot remove detached node"); + return protocol::Response::ServerError("Cannot remove detached node"); return dom_editor_->RemoveChild(parent_node, node); } -Response InspectorDOMAgent::setNodeName(int node_id, - const String& tag_name, - int* new_id) { +protocol::Response InspectorDOMAgent::setNodeName(int node_id, + const String& tag_name, + int* new_id) { *new_id = 0; Element* old_element = nullptr; - Response response = AssertElement(node_id, old_element); + protocol::Response response = AssertElement(node_id, old_element); if (!response.IsSuccess()) return response; @@ -1045,33 +1055,34 @@ *new_id = PushNodePathToFrontend(new_elem); if (children_requested_.Contains(node_id)) PushChildNodesToFrontend(*new_id); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getOuterHTML(Maybe<int> node_id, - Maybe<int> backend_node_id, - Maybe<String> object_id, - WTF::String* outer_html) { +protocol::Response InspectorDOMAgent::getOuterHTML(Maybe<int> node_id, + Maybe<int> backend_node_id, + Maybe<String> object_id, + WTF::String* outer_html) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; *outer_html = CreateMarkup(node); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::setOuterHTML(int node_id, - const String& outer_html) { +protocol::Response InspectorDOMAgent::setOuterHTML(int node_id, + const String& outer_html) { if (!node_id) { DCHECK(document_); DOMPatchSupport dom_patch_support(dom_editor_.Get(), *document_.Get()); dom_patch_support.PatchDocument(outer_html); - return Response::Success(); + return protocol::Response::Success(); } Node* node = nullptr; - Response response = AssertEditableNode(node_id, node); + protocol::Response response = AssertEditableNode(node_id, node); if (!response.IsSuccess()) return response; @@ -1079,7 +1090,7 @@ IsA<Document>(node) ? To<Document>(node) : node->ownerDocument(); if (!document || (!IsA<HTMLDocument>(document) && !IsA<XMLDocument>(document))) - return Response::ServerError("Not an HTML/XML document"); + return protocol::Response::ServerError("Not an HTML/XML document"); Node* new_node = nullptr; response = dom_editor_->SetOuterHTML(node, outer_html, &new_node); @@ -1088,7 +1099,7 @@ if (!new_node) { // The only child node has been deleted. - return Response::Success(); + return protocol::Response::Success(); } int new_id = PushNodePathToFrontend(new_node); @@ -1096,17 +1107,18 @@ bool children_requested = children_requested_.Contains(node_id); if (children_requested) PushChildNodesToFrontend(new_id); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::setNodeValue(int node_id, const String& value) { +protocol::Response InspectorDOMAgent::setNodeValue(int node_id, + const String& value) { Node* node = nullptr; - Response response = AssertEditableNode(node_id, node); + protocol::Response response = AssertEditableNode(node_id, node); if (!response.IsSuccess()) return response; if (node->getNodeType() != Node::kTextNode) - return Response::ServerError("Can only set value of text nodes"); + return protocol::Response::ServerError("Can only set value of text nodes"); return dom_editor_->SetNodeValue(node, value); } @@ -1142,13 +1154,13 @@ return nullptr; } -Response InspectorDOMAgent::performSearch( +protocol::Response InspectorDOMAgent::performSearch( const String& whitespace_trimmed_query, Maybe<bool> optional_include_user_agent_shadow_dom, String* search_id, int* result_count) { if (!enabled_.Get()) - return Response::ServerError("DOM agent is not enabled"); + return protocol::Response::ServerError("DOM agent is not enabled"); // FIXME: Few things are missing here: // 1) Search works with node granularity - number of matches within node is @@ -1290,58 +1302,66 @@ results_it->push_back(result); *result_count = results_it->size(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getSearchResults( +protocol::Response InspectorDOMAgent::getSearchResults( const String& search_id, int from_index, int to_index, std::unique_ptr<protocol::Array<int>>* node_ids) { SearchResults::iterator it = search_results_.find(search_id); - if (it == search_results_.end()) - return Response::ServerError("No search session with given id found"); + if (it == search_results_.end()) { + return protocol::Response::ServerError( + "No search session with given id found"); + } int size = it->value->size(); if (from_index < 0 || to_index > size || from_index >= to_index) - return Response::ServerError("Invalid search result range"); + return protocol::Response::ServerError("Invalid search result range"); *node_ids = std::make_unique<protocol::Array<int>>(); for (int i = from_index; i < to_index; ++i) (*node_ids)->emplace_back(PushNodePathToFrontend((*it->value)[i].Get())); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::discardSearchResults(const String& search_id) { +protocol::Response InspectorDOMAgent::discardSearchResults( + const String& search_id) { search_results_.erase(search_id); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::NodeForRemoteObjectId(const String& object_id, - Node*& node) { +protocol::Response InspectorDOMAgent::NodeForRemoteObjectId( + const String& object_id, + Node*& node) { v8::HandleScope handles(isolate_); v8::Local<v8::Value> value; v8::Local<v8::Context> context; std::unique_ptr<v8_inspector::StringBuffer> error; if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), - &value, &context, nullptr)) - return Response::ServerError(ToCoreString(std::move(error)).Utf8()); - if (!V8Node::HasInstance(value, isolate_)) - return Response::ServerError("Object id doesn't reference a Node"); + &value, &context, nullptr)) { + return protocol::Response::ServerError( + ToCoreString(std::move(error)).Utf8()); + } + if (!V8Node::HasInstance(value, isolate_)) { + return protocol::Response::ServerError( + "Object id doesn't reference a Node"); + } node = V8Node::ToImpl(v8::Local<v8::Object>::Cast(value)); if (!node) { - return Response::ServerError( + return protocol::Response::ServerError( "Couldn't convert object with given objectId to Node"); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::copyTo(int node_id, - int target_element_id, - Maybe<int> anchor_node_id, - int* new_node_id) { +protocol::Response InspectorDOMAgent::copyTo(int node_id, + int target_element_id, + Maybe<int> anchor_node_id, + int* new_node_id) { Node* node = nullptr; - Response response = AssertEditableNode(node_id, node); + protocol::Response response = AssertEditableNode(node_id, node); if (!response.IsSuccess()) return response; @@ -1361,22 +1381,22 @@ // The clone is deep by default. Node* cloned_node = node->cloneNode(true); if (!cloned_node) - return Response::ServerError("Failed to clone node"); + return protocol::Response::ServerError("Failed to clone node"); response = dom_editor_->InsertBefore(target_element, cloned_node, anchor_node); if (!response.IsSuccess()) return response; *new_node_id = PushNodePathToFrontend(cloned_node); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::moveTo(int node_id, - int target_element_id, - Maybe<int> anchor_node_id, - int* new_node_id) { +protocol::Response InspectorDOMAgent::moveTo(int node_id, + int target_element_id, + Maybe<int> anchor_node_id, + int* new_node_id) { Node* node = nullptr; - Response response = AssertEditableNode(node_id, node); + protocol::Response response = AssertEditableNode(node_id, node); if (!response.IsSuccess()) return response; @@ -1388,7 +1408,7 @@ Node* current = target_element; while (current) { if (current == node) { - return Response::ServerError( + return protocol::Response::ServerError( "Unable to move node into self or descendant"); } current = current->parentNode(); @@ -1407,82 +1427,84 @@ return response; *new_node_id = PushNodePathToFrontend(node); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::undo() { +protocol::Response InspectorDOMAgent::undo() { if (!enabled_.Get()) - return Response::ServerError("DOM agent is not enabled"); + return protocol::Response::ServerError("DOM agent is not enabled"); DummyExceptionStateForTesting exception_state; history_->Undo(exception_state); return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorDOMAgent::redo() { +protocol::Response InspectorDOMAgent::redo() { if (!enabled_.Get()) - return Response::ServerError("DOM agent is not enabled"); + return protocol::Response::ServerError("DOM agent is not enabled"); DummyExceptionStateForTesting exception_state; history_->Redo(exception_state); return InspectorDOMAgent::ToResponse(exception_state); } -Response InspectorDOMAgent::markUndoableState() { +protocol::Response InspectorDOMAgent::markUndoableState() { if (!enabled_.Get()) - return Response::ServerError("DOM agent is not enabled"); + return protocol::Response::ServerError("DOM agent is not enabled"); history_->MarkUndoableState(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::focus(Maybe<int> node_id, - Maybe<int> backend_node_id, - Maybe<String> object_id) { +protocol::Response InspectorDOMAgent::focus(Maybe<int> node_id, + Maybe<int> backend_node_id, + Maybe<String> object_id) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; auto* element = DynamicTo<Element>(node); if (!element) - return Response::ServerError("Node is not an Element"); + return protocol::Response::ServerError("Node is not an Element"); element->GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kInspector); if (!element->IsFocusable()) - return Response::ServerError("Element is not focusable"); + return protocol::Response::ServerError("Element is not focusable"); element->Focus(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::setFileInputFiles( +protocol::Response InspectorDOMAgent::setFileInputFiles( std::unique_ptr<protocol::Array<String>> files, Maybe<int> node_id, Maybe<int> backend_node_id, Maybe<String> object_id) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; auto* html_input_element = DynamicTo<HTMLInputElement>(node); if (!html_input_element || html_input_element->type() != input_type_names::kFile) - return Response::ServerError("Node is not a file input element"); + return protocol::Response::ServerError("Node is not a file input element"); Vector<String> paths; for (const String& file : *files) paths.push_back(file); To<HTMLInputElement>(node)->SetFilesFromPaths(paths); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::setNodeStackTracesEnabled(bool enable) { +protocol::Response InspectorDOMAgent::setNodeStackTracesEnabled(bool enable) { capture_node_stack_traces_.Set(enable); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getNodeStackTraces( +protocol::Response InspectorDOMAgent::getNodeStackTraces( int node_id, protocol::Maybe<v8_inspector::protocol::Runtime::API::StackTrace>* creation) { Node* node = nullptr; - Response response = AssertNode(node_id, node); + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; @@ -1491,41 +1513,43 @@ SourceLocation& source_location = it->value->GetSourceLocation(); *creation = source_location.BuildInspectorObject(); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getBoxModel( +protocol::Response InspectorDOMAgent::getBoxModel( Maybe<int> node_id, Maybe<int> backend_node_id, Maybe<String> object_id, std::unique_ptr<protocol::DOM::BoxModel>* model) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; bool result = InspectorHighlight::GetBoxModel(node, model, true); if (!result) - return Response::ServerError("Could not compute box model."); - return Response::Success(); + return protocol::Response::ServerError("Could not compute box model."); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getContentQuads( +protocol::Response InspectorDOMAgent::getContentQuads( Maybe<int> node_id, Maybe<int> backend_node_id, Maybe<String> object_id, std::unique_ptr<protocol::Array<protocol::Array<double>>>* quads) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; bool result = InspectorHighlight::GetContentQuads(node, quads); if (!result) - return Response::ServerError("Could not compute content quads."); - return Response::Success(); + return protocol::Response::ServerError("Could not compute content quads."); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getNodeForLocation( +protocol::Response InspectorDOMAgent::getNodeForLocation( int x, int y, Maybe<bool> optional_include_user_agent_shadow_dom, @@ -1554,7 +1578,7 @@ while (node && node->getNodeType() == Node::kTextNode) node = node->parentNode(); if (!node) - return Response::ServerError("No node found at given location"); + return protocol::Response::ServerError("No node found at given location"); *backend_node_id = IdentifiersFactory::IntIdForNode(node); LocalFrame* frame = node->GetDocument().GetFrame(); *frame_id = IdentifiersFactory::FrameId(frame); @@ -1562,10 +1586,10 @@ document_node_to_id_map_->Contains(document_)) { *node_id = PushNodePathToFrontend(node); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::resolveNode( +protocol::Response InspectorDOMAgent::resolveNode( protocol::Maybe<int> node_id, protocol::Maybe<int> backend_node_id, protocol::Maybe<String> object_group, @@ -1576,7 +1600,7 @@ Node* node = nullptr; if (node_id.isJust() == backend_node_id.isJust()) { - return Response::ServerError( + return protocol::Response::ServerError( "Either nodeId or backendNodeId must be specified."); } @@ -1586,45 +1610,46 @@ node = DOMNodeIds::NodeForId(backend_node_id.fromJust()); if (!node) - return Response::ServerError("No node with given id found"); + return protocol::Response::ServerError("No node with given id found"); *result = ResolveNode(v8_session_, node, object_group_name, std::move(execution_context_id)); if (!*result) { - return Response::ServerError( + return protocol::Response::ServerError( "Node with given id does not belong to the document"); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getAttributes( +protocol::Response InspectorDOMAgent::getAttributes( int node_id, std::unique_ptr<protocol::Array<String>>* result) { Element* element = nullptr; - Response response = AssertElement(node_id, element); + protocol::Response response = AssertElement(node_id, element); if (!response.IsSuccess()) return response; *result = BuildArrayForElementAttributes(element); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::requestNode(const String& object_id, int* node_id) { +protocol::Response InspectorDOMAgent::requestNode(const String& object_id, + int* node_id) { Node* node = nullptr; - Response response = NodeForRemoteObjectId(object_id, node); + protocol::Response response = NodeForRemoteObjectId(object_id, node); if (!response.IsSuccess()) return response; *node_id = PushNodePathToFrontend(node); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getContainerForNode( +protocol::Response InspectorDOMAgent::getContainerForNode( int node_id, protocol::Maybe<String> container_name, protocol::Maybe<protocol::DOM::PhysicalAxes> physical_axes, protocol::Maybe<protocol::DOM::LogicalAxes> logical_axes, Maybe<int>* container_node_id) { Element* element = nullptr; - Response response = AssertElement(node_id, element); + protocol::Response response = AssertElement(node_id, element); if (!response.IsSuccess()) return response; @@ -1666,14 +1691,14 @@ physical, logical)); if (container) *container_node_id = PushNodePathToFrontend(container); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getQueryingDescendantsForContainer( +protocol::Response InspectorDOMAgent::getQueryingDescendantsForContainer( int node_id, std::unique_ptr<protocol::Array<int>>* node_ids) { Element* container = nullptr; - Response response = AssertElement(node_id, container); + protocol::Response response = AssertElement(node_id, container); if (!response.IsSuccess()) return response; @@ -1684,7 +1709,7 @@ (*node_ids)->push_back(id); } - return Response::Success(); + return protocol::Response::Success(); } // static @@ -2479,22 +2504,25 @@ return node; } -Response InspectorDOMAgent::pushNodeByPathToFrontend(const String& path, - int* node_id) { +protocol::Response InspectorDOMAgent::pushNodeByPathToFrontend( + const String& path, + int* node_id) { if (!enabled_.Get()) - return Response::ServerError("DOM agent is not enabled"); + return protocol::Response::ServerError("DOM agent is not enabled"); if (Node* node = NodeForPath(path)) *node_id = PushNodePathToFrontend(node); else - return Response::ServerError("No node with given path found"); - return Response::Success(); + return protocol::Response::ServerError("No node with given path found"); + return protocol::Response::Success(); } -Response InspectorDOMAgent::pushNodesByBackendIdsToFrontend( +protocol::Response InspectorDOMAgent::pushNodesByBackendIdsToFrontend( std::unique_ptr<protocol::Array<int>> backend_node_ids, std::unique_ptr<protocol::Array<int>>* result) { - if (!document_ || !BoundNodeId(document_)) - return Response::ServerError("Document needs to be requested first"); + if (!document_ || !BoundNodeId(document_)) { + return protocol::Response::ServerError( + "Document needs to be requested first"); + } *result = std::make_unique<protocol::Array<int>>(); for (int id : *backend_node_ids) { @@ -2505,7 +2533,7 @@ else (*result)->emplace_back(0); } - return Response::Success(); + return protocol::Response::Success(); } class InspectableNode final @@ -2522,25 +2550,25 @@ DOMNodeId node_id_; }; -Response InspectorDOMAgent::setInspectedNode(int node_id) { +protocol::Response InspectorDOMAgent::setInspectedNode(int node_id) { Node* node = nullptr; - Response response = AssertNode(node_id, node); + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; v8_session_->addInspectedObject(std::make_unique<InspectableNode>(node)); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getRelayoutBoundary( +protocol::Response InspectorDOMAgent::getRelayoutBoundary( int node_id, int* relayout_boundary_node_id) { Node* node = nullptr; - Response response = AssertNode(node_id, node); + protocol::Response response = AssertNode(node_id, node); if (!response.IsSuccess()) return response; LayoutObject* layout_object = node->GetLayoutObject(); if (!layout_object) { - return Response::ServerError( + return protocol::Response::ServerError( "No layout object for node, perhaps orphan or hidden node"); } while (layout_object && !layout_object->IsDocumentElement() && @@ -2549,7 +2577,7 @@ Node* result_node = layout_object ? layout_object->GeneratingNode() : node->ownerDocument(); *relayout_boundary_node_id = PushNodePathToFrontend(result_node); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorDOMAgent::describeNode( @@ -2560,14 +2588,15 @@ protocol::Maybe<bool> pierce, std::unique_ptr<protocol::DOM::Node>* result) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; if (!node) - return Response::ServerError("Node not found"); + return protocol::Response::ServerError("Node not found"); *result = BuildObjectForNode(node, depth.fromMaybe(0), pierce.fromMaybe(false), nullptr, nullptr); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorDOMAgent::scrollIntoViewIfNeeded( @@ -2576,21 +2605,24 @@ protocol::Maybe<String> object_id, protocol::Maybe<protocol::DOM::Rect> rect) { Node* node = nullptr; - Response response = AssertNode(node_id, backend_node_id, object_id, node); + protocol::Response response = + AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; node->GetDocument().EnsurePaintLocationDataValidForNode( node, DocumentUpdateReason::kInspector); if (!node->isConnected()) - return Response::ServerError("Node is detached from document"); + return protocol::Response::ServerError("Node is detached from document"); LayoutObject* layout_object = node->GetLayoutObject(); if (!layout_object) { node = LayoutTreeBuilderTraversal::FirstLayoutChild(*node); if (node) layout_object = node->GetLayoutObject(); } - if (!layout_object) - return Response::ServerError("Node does not have a layout object"); + if (!layout_object) { + return protocol::Response::ServerError( + "Node does not have a layout object"); + } PhysicalRect rect_to_scroll = PhysicalRect::EnclosingRect(layout_object->AbsoluteBoundingBoxRectF()); if (rect.isJust()) { @@ -2609,7 +2641,7 @@ true /* make_visible_in_visual_viewport */, mojom::blink::ScrollBehavior::kInstant, true /* is_for_scroll_sequence */)); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorDOMAgent::getFrameOwner( @@ -2650,11 +2682,13 @@ } } } - if (!found_frame) - return Response::ServerError("Frame with the given id was not found."); + if (!found_frame) { + return protocol::Response::ServerError( + "Frame with the given id was not found."); + } auto* frame_owner = DynamicTo<HTMLFrameOwnerElement>(found_frame->Owner()); if (!frame_owner) { - return Response::ServerError( + return protocol::Response::ServerError( "Frame with the given id does not belong to the target."); } @@ -2663,28 +2697,33 @@ if (enabled_.Get() && document_ && BoundNodeId(document_)) { *node_id = PushNodePathToFrontend(frame_owner); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMAgent::getFileInfo(const String& object_id, String* path) { +protocol::Response InspectorDOMAgent::getFileInfo(const String& object_id, + String* path) { v8::HandleScope handles(isolate_); v8::Local<v8::Value> value; v8::Local<v8::Context> context; std::unique_ptr<v8_inspector::StringBuffer> error; if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), - &value, &context, nullptr)) - return Response::ServerError(ToCoreString(std::move(error)).Utf8()); + &value, &context, nullptr)) { + return protocol::Response::ServerError( + ToCoreString(std::move(error)).Utf8()); + } - if (!V8File::HasInstance(value, isolate_)) - return Response::ServerError("Object id doesn't reference a File"); + if (!V8File::HasInstance(value, isolate_)) { + return protocol::Response::ServerError( + "Object id doesn't reference a File"); + } File* file = V8File::ToImpl(v8::Local<v8::Object>::Cast(value)); if (!file) { - return Response::ServerError( + return protocol::Response::ServerError( "Couldn't convert object with given objectId to File"); } *path = file->GetPath(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorDOMAgent::Trace(Visitor* visitor) const {
diff --git a/third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.cc b/third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.cc index 429572a..1091208b 100644 --- a/third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_dom_debugger_agent.cc
@@ -78,7 +78,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace { // Returns the key that we use to identify the brekpoint in // event_listener_breakpoints_. |target_name| may be "", in which case @@ -225,11 +224,11 @@ InspectorBaseAgent::Trace(visitor); } -Response InspectorDOMDebuggerAgent::disable() { +protocol::Response InspectorDOMDebuggerAgent::disable() { SetEnabled(false); dom_breakpoints_.clear(); agent_state_.ClearAllFields(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorDOMDebuggerAgent::Restore() { @@ -237,51 +236,52 @@ instrumenting_agents_->AddInspectorDOMDebuggerAgent(this); } -Response InspectorDOMDebuggerAgent::setEventListenerBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::setEventListenerBreakpoint( const String& event_name, Maybe<String> target_name) { return SetBreakpoint(String(listenerEventCategoryType) + event_name, target_name.fromMaybe(String())); } -Response InspectorDOMDebuggerAgent::setInstrumentationBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::setInstrumentationBreakpoint( const String& event_name) { return SetBreakpoint(String(instrumentationEventCategoryType) + event_name, String()); } -Response InspectorDOMDebuggerAgent::SetBreakpoint(const String& event_name, - const String& target_name) { +protocol::Response InspectorDOMDebuggerAgent::SetBreakpoint( + const String& event_name, + const String& target_name) { if (event_name.empty()) - return Response::ServerError("Event name is empty"); + return protocol::Response::ServerError("Event name is empty"); event_listener_breakpoints_.Set( EventListenerBreakpointKey(event_name, target_name), true); DidAddBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMDebuggerAgent::removeEventListenerBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::removeEventListenerBreakpoint( const String& event_name, Maybe<String> target_name) { return RemoveBreakpoint(String(listenerEventCategoryType) + event_name, target_name.fromMaybe(String())); } -Response InspectorDOMDebuggerAgent::removeInstrumentationBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::removeInstrumentationBreakpoint( const String& event_name) { return RemoveBreakpoint(String(instrumentationEventCategoryType) + event_name, String()); } -Response InspectorDOMDebuggerAgent::RemoveBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::RemoveBreakpoint( const String& event_name, const String& target_name) { if (event_name.empty()) - return Response::ServerError("Event name is empty"); + return protocol::Response::ServerError("Event name is empty"); event_listener_breakpoints_.Clear( EventListenerBreakpointKey(event_name, target_name)); DidRemoveBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorDOMDebuggerAgent::DidInvalidateStyleAttr(Node* node) { @@ -323,20 +323,20 @@ } } -static Response DomTypeForName(const String& type_string, int& type) { +static protocol::Response DomTypeForName(const String& type_string, int& type) { if (type_string == "subtree-modified") { type = SubtreeModified; - return Response::Success(); + return protocol::Response::Success(); } if (type_string == "attribute-modified") { type = AttributeModified; - return Response::Success(); + return protocol::Response::Success(); } if (type_string == "node-removed") { type = NodeRemoved; - return Response::Success(); + return protocol::Response::Success(); } - return Response::ServerError( + return protocol::Response::ServerError( String("Unknown DOM breakpoint type: " + type_string).Utf8()); } @@ -366,12 +366,12 @@ return false; } -Response InspectorDOMDebuggerAgent::setBreakOnCSPViolation( +protocol::Response InspectorDOMDebuggerAgent::setBreakOnCSPViolation( std::unique_ptr<protocol::Array<String>> violationTypes) { csp_violation_breakpoints_.Clear(); if (violationTypes->empty()) { DidRemoveBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } for (const auto& violationString : *violationTypes) { if (IsValidViolationType(violationString)) { @@ -379,18 +379,18 @@ } else { csp_violation_breakpoints_.Clear(); DidRemoveBreakpoint(); - return Response::InvalidParams("Invalid violation type"); + return protocol::Response::InvalidParams("Invalid violation type"); } } DidAddBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMDebuggerAgent::setDOMBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::setDOMBreakpoint( int node_id, const String& type_string) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(node_id, node); + protocol::Response response = dom_agent_->AssertNode(node_id, node); if (!response.IsSuccess()) return response; @@ -411,14 +411,14 @@ UpdateSubtreeBreakpoints(child, root_bit, true); } DidAddBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMDebuggerAgent::removeDOMBreakpoint( +protocol::Response InspectorDOMDebuggerAgent::removeDOMBreakpoint( int node_id, const String& type_string) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(node_id, node); + protocol::Response response = dom_agent_->AssertNode(node_id, node); if (!response.IsSuccess()) return response; @@ -445,10 +445,10 @@ UpdateSubtreeBreakpoints(child, root_bit, false); } DidRemoveBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMDebuggerAgent::getEventListeners( +protocol::Response InspectorDOMDebuggerAgent::getEventListeners( const String& object_id, Maybe<int> depth, Maybe<bool> pierce, @@ -461,7 +461,8 @@ std::unique_ptr<v8_inspector::StringBuffer> object_group; if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), &object, &context, &object_group)) { - return Response::ServerError(ToCoreString(std::move(error)).Utf8()); + return protocol::Response::ServerError( + ToCoreString(std::move(error)).Utf8()); } v8::Context::Scope scope(context); V8EventListenerInfoList event_information; @@ -471,7 +472,7 @@ &event_information); *listeners_array = BuildObjectsForEventListeners(event_information, context, object_group->string()); - return Response::Success(); + return protocol::Response::Success(); } std::unique_ptr<protocol::Array<protocol::DOMDebugger::EventListener>> @@ -752,22 +753,24 @@ AllowNativeBreakpoint(name, nullptr, true); } -Response InspectorDOMDebuggerAgent::setXHRBreakpoint(const String& url) { +protocol::Response InspectorDOMDebuggerAgent::setXHRBreakpoint( + const String& url) { if (url.empty()) pause_on_all_xhrs_.Set(true); else xhr_breakpoints_.Set(url, true); DidAddBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMDebuggerAgent::removeXHRBreakpoint(const String& url) { +protocol::Response InspectorDOMDebuggerAgent::removeXHRBreakpoint( + const String& url) { if (url.empty()) pause_on_all_xhrs_.Set(false); else xhr_breakpoints_.Clear(url); DidRemoveBreakpoint(); - return Response::Success(); + return protocol::Response::Success(); } // Returns the breakpoint url if a match is found, or WTF::String().
diff --git a/third_party/blink/renderer/core/inspector/inspector_dom_snapshot_agent.cc b/third_party/blink/renderer/core/inspector/inspector_dom_snapshot_agent.cc index b526e436..992f2f0 100644 --- a/third_party/blink/renderer/core/inspector/inspector_dom_snapshot_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_dom_snapshot_agent.cc
@@ -47,7 +47,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace { @@ -234,22 +233,24 @@ EnableAndReset(); } -Response InspectorDOMSnapshotAgent::enable() { +protocol::Response InspectorDOMSnapshotAgent::enable() { if (!enabled_.Get()) EnableAndReset(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMSnapshotAgent::disable() { - if (!enabled_.Get()) - return Response::ServerError("DOM snapshot agent hasn't been enabled."); +protocol::Response InspectorDOMSnapshotAgent::disable() { + if (!enabled_.Get()) { + return protocol::Response::ServerError( + "DOM snapshot agent hasn't been enabled."); + } enabled_.Clear(); origin_url_map_.reset(); instrumenting_agents_->RemoveInspectorDOMSnapshotAgent(this); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMSnapshotAgent::getSnapshot( +protocol::Response InspectorDOMSnapshotAgent::getSnapshot( std::unique_ptr<protocol::Array<String>> style_filter, protocol::Maybe<bool> include_event_listeners, protocol::Maybe<bool> include_paint_order, @@ -261,7 +262,7 @@ computed_styles) { Document* document = inspected_frames_->Root()->GetDocument(); if (!document) - return Response::ServerError("Document is not available"); + return protocol::Response::ServerError("Document is not available"); LegacyDOMSnapshotAgent legacySupport(dom_debugger_agent_, origin_url_map_.get()); return legacySupport.GetSnapshot( @@ -285,7 +286,7 @@ auto* main_window = inspected_frames_->Root()->DomWindow(); if (!main_window) - return Response::ServerError("Document is not available"); + return protocol::Response::ServerError("Document is not available"); // Update layout before traversal of document so that we inspect a // current and consistent state of all trees. @@ -302,7 +303,7 @@ const CSSPropertyID id = UnresolvedCSSPropertyID(main_window, property_name); if (id == CSSPropertyID::kInvalid || id == CSSPropertyID::kVariable) - return Response::InvalidParams("invalid CSS property"); + return protocol::Response::InvalidParams("invalid CSS property"); const auto& property = CSSProperty::Get(ResolveCSSPropertyID(id)); css_property_filter_->push_back(&property); } @@ -336,7 +337,7 @@ documents_.reset(); css_value_cache_.clear(); style_cache_.clear(); - return Response::Success(); + return protocol::Response::Success(); } int InspectorDOMSnapshotAgent::AddString(const String& string) {
diff --git a/third_party/blink/renderer/core/inspector/inspector_emulation_agent.cc b/third_party/blink/renderer/core/inspector/inspector_emulation_agent.cc index 11217f3..16cbaa0 100644 --- a/third_party/blink/renderer/core/inspector/inspector_emulation_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_emulation_agent.cc
@@ -33,7 +33,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; InspectorEmulationAgent::InspectorEmulationAgent( WebLocalFrameImpl* web_local_frame_impl, @@ -159,7 +158,7 @@ &virtual_time_ticks_base_ms); } -Response InspectorEmulationAgent::disable() { +protocol::Response InspectorEmulationAgent::disable() { if (enabled_) { instrumenting_agents_->RemoveInspectorEmulationAgent(this); enabled_ = false; @@ -172,7 +171,7 @@ if (!locale_override_.Get().empty()) setLocaleOverride(String()); if (!web_local_frame_) - return Response::Success(); + return protocol::Response::Success(); setScriptExecutionDisabled(false); setScrollbarsHidden(false); setDocumentCookieDisabled(false); @@ -195,27 +194,29 @@ } setDefaultBackgroundColorOverride(Maybe<protocol::DOM::RGBA>()); disabled_image_types_.Clear(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorEmulationAgent::resetPageScaleFactor() { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::resetPageScaleFactor() { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; GetWebViewImpl()->ResetScaleStateImmediately(); return response; } -Response InspectorEmulationAgent::setPageScaleFactor(double page_scale_factor) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setPageScaleFactor( + double page_scale_factor) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; GetWebViewImpl()->SetPageScaleFactor(static_cast<float>(page_scale_factor)); return response; } -Response InspectorEmulationAgent::setScriptExecutionDisabled(bool value) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setScriptExecutionDisabled( + bool value) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; if (script_execution_disabled_.Get() == value) @@ -225,8 +226,8 @@ return response; } -Response InspectorEmulationAgent::setScrollbarsHidden(bool hidden) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setScrollbarsHidden(bool hidden) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; if (scrollbars_hidden_.Get() == hidden) @@ -236,8 +237,9 @@ return response; } -Response InspectorEmulationAgent::setDocumentCookieDisabled(bool disabled) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setDocumentCookieDisabled( + bool disabled) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; if (document_cookie_disabled_.Get() == disabled) @@ -247,10 +249,10 @@ return response; } -Response InspectorEmulationAgent::setTouchEmulationEnabled( +protocol::Response InspectorEmulationAgent::setTouchEmulationEnabled( bool enabled, protocol::Maybe<int> max_touch_points) { - Response response = AssertPage(); + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; int max_points = max_touch_points.fromMaybe(1); @@ -258,7 +260,7 @@ String msg = "Touch points must be between 1 and " + String::Number(static_cast<uint16_t>(WebTouchEvent::kTouchesLengthCap)); - return Response::InvalidParams(msg.Utf8()); + return protocol::Response::InvalidParams(msg.Utf8()); } touch_event_emulation_enabled_.Set(enabled); max_touch_points_.Set(max_points); @@ -267,10 +269,10 @@ return response; } -Response InspectorEmulationAgent::setEmulatedMedia( +protocol::Response InspectorEmulationAgent::setEmulatedMedia( Maybe<String> media, Maybe<protocol::Array<protocol::Emulation::MediaFeature>> features) { - Response response = AssertPage(); + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; if (media.isJust()) { @@ -355,9 +357,9 @@ return response; } -Response InspectorEmulationAgent::setEmulatedVisionDeficiency( +protocol::Response InspectorEmulationAgent::setEmulatedVisionDeficiency( const String& type) { - Response response = AssertPage(); + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; @@ -379,15 +381,15 @@ else if (type == TypeEnum::Tritanopia) vision_deficiency = VisionDeficiency::kTritanopia; else - return Response::InvalidParams("Unknown vision deficiency type"); + return protocol::Response::InvalidParams("Unknown vision deficiency type"); emulated_vision_deficiency_.Set(type); GetWebViewImpl()->GetPage()->SetVisionDeficiency(vision_deficiency); return response; } -Response InspectorEmulationAgent::setCPUThrottlingRate(double rate) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setCPUThrottlingRate(double rate) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; cpu_throttling_rate_.Set(rate); @@ -395,8 +397,9 @@ return response; } -Response InspectorEmulationAgent::setFocusEmulationEnabled(bool enabled) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setFocusEmulationEnabled( + bool enabled) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; emulate_focus_.Set(enabled); @@ -405,8 +408,9 @@ return response; } -Response InspectorEmulationAgent::setAutoDarkModeOverride(Maybe<bool> enabled) { - Response response = AssertPage(); +protocol::Response InspectorEmulationAgent::setAutoDarkModeOverride( + Maybe<bool> enabled) { + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; if (enabled.isJust()) { @@ -421,7 +425,7 @@ return response; } -Response InspectorEmulationAgent::setVirtualTimePolicy( +protocol::Response InspectorEmulationAgent::setVirtualTimePolicy( const String& policy, Maybe<double> virtual_time_budget_ms, protocol::Maybe<int> max_virtual_time_task_starvation_count, @@ -439,11 +443,11 @@ DCHECK_EQ(scheduler_policy, VirtualTimeController::VirtualTimePolicy::kPause); if (virtual_time_budget_ms.isJust()) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "Can only specify budget for non-Pause policy"); } if (max_virtual_time_task_starvation_count.isJust()) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "Can only specify starvation count for non-Pause policy"); } } @@ -489,7 +493,7 @@ ? 0 : (virtual_time_base_ticks_ - base::TimeTicks()).InMillisecondsF(); - return Response::Success(); + return protocol::Response::Success(); } AtomicString InspectorEmulationAgent::OverrideAcceptImageHeader( @@ -537,9 +541,9 @@ request.SetCacheMode(mojom::blink::FetchCacheMode::kBypassCache); } -Response InspectorEmulationAgent::setNavigatorOverrides( +protocol::Response InspectorEmulationAgent::setNavigatorOverrides( const String& platform) { - Response response = AssertPage(); + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; navigator_platform_override_.Set(platform); @@ -560,16 +564,16 @@ frontend->virtualTimeBudgetExpired(); } -Response InspectorEmulationAgent::setDefaultBackgroundColorOverride( +protocol::Response InspectorEmulationAgent::setDefaultBackgroundColorOverride( Maybe<protocol::DOM::RGBA> color) { - Response response = AssertPage(); + protocol::Response response = AssertPage(); if (!response.IsSuccess()) return response; if (!color.isJust()) { // Clear the override and state. GetWebViewImpl()->SetBaseBackgroundColorOverrideForInspector(absl::nullopt); default_background_color_override_rgba_.Clear(); - return Response::Success(); + return protocol::Response::Success(); } blink::protocol::DOM::RGBA* rgba = color.fromJust(); @@ -578,10 +582,10 @@ int alpha = static_cast<int>(lroundf(255.0f * rgba->getA(1.0f))); GetWebViewImpl()->SetBaseBackgroundColorOverrideForInspector( Color(rgba->getR(), rgba->getG(), rgba->getB(), alpha).Rgb()); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorEmulationAgent::setDeviceMetricsOverride( +protocol::Response InspectorEmulationAgent::setDeviceMetricsOverride( int width, int height, double device_scale_factor, @@ -601,26 +605,26 @@ return AssertPage(); } -Response InspectorEmulationAgent::clearDeviceMetricsOverride() { +protocol::Response InspectorEmulationAgent::clearDeviceMetricsOverride() { // We don't have to do anything other than reply to the client, as the // emulation parameters should have already been cleared by the handling of // blink::mojom::FrameWidget::DisableDeviceEmulation. return AssertPage(); } -Response InspectorEmulationAgent::setHardwareConcurrencyOverride( +protocol::Response InspectorEmulationAgent::setHardwareConcurrencyOverride( int hardware_concurrency) { if (hardware_concurrency <= 0) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "HardwareConcurrency must be a positive number"); } InnerEnable(); hardware_concurrency_override_.Set(hardware_concurrency); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorEmulationAgent::setUserAgentOverride( +protocol::Response InspectorEmulationAgent::setUserAgentOverride( const String& user_agent, protocol::Maybe<String> accept_language, protocol::Maybe<String> platform, @@ -643,7 +647,7 @@ if (user_agent.empty()) { ua_metadata_override_ = absl::nullopt; serialized_ua_metadata_override_.Set(std::vector<uint8_t>()); - return Response::InvalidParams( + return protocol::Response::InvalidParams( "Can't specify UserAgentMetadata but no UA string"); } std::unique_ptr<protocol::Emulation::UserAgentMetadata> ua_metadata = @@ -712,26 +716,26 @@ marshalled.end()); serialized_ua_metadata_override_.Set(std::move(marshalled_as_bytes)); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorEmulationAgent::setLocaleOverride( +protocol::Response InspectorEmulationAgent::setLocaleOverride( protocol::Maybe<String> maybe_locale) { // Only allow resetting overrides set by the same agent. if (locale_override_.Get().empty() && LocaleController::instance().has_locale_override()) { - return Response::ServerError( + return protocol::Response::ServerError( "Another locale override is already in effect"); } String locale = maybe_locale.fromMaybe(String()); String error = LocaleController::instance().SetLocaleOverride(locale); if (!error.empty()) - return Response::ServerError(error.Utf8()); + return protocol::Response::ServerError(error.Utf8()); locale_override_.Set(locale); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorEmulationAgent::setTimezoneOverride( +protocol::Response InspectorEmulationAgent::setTimezoneOverride( const String& timezone_id) { if (timezone_id == TimeZoneController::TimeZoneIdOverride()) { // Do nothing. @@ -745,15 +749,15 @@ } if (!timezone_override_) { return TimeZoneController::HasTimeZoneOverride() - ? Response::ServerError( + ? protocol::Response::ServerError( "Timezone override is already in effect") - : Response::InvalidParams("Invalid timezone id"); + : protocol::Response::InvalidParams("Invalid timezone id"); } } timezone_id_override_.Set(timezone_id); - return Response::Success(); + return protocol::Response::Success(); } void InspectorEmulationAgent::GetDisabledImageTypes(HashSet<String>* result) { @@ -814,12 +818,12 @@ void InspectorEmulationAgent::SetSystemThemeState() {} -Response InspectorEmulationAgent::AssertPage() { +protocol::Response InspectorEmulationAgent::AssertPage() { if (!web_local_frame_) { - return Response::ServerError( + return protocol::Response::ServerError( "Operation is only supported for pages, not workers"); } - return Response::Success(); + return protocol::Response::Success(); } void InspectorEmulationAgent::Trace(Visitor* visitor) const { @@ -843,9 +847,9 @@ continue; } disabled_image_types_.Clear(); - return Response::InvalidParams("Invalid image type"); + return protocol::Response::InvalidParams("Invalid image type"); } - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorEmulationAgent::setAutomationOverride( @@ -853,7 +857,7 @@ if (enabled) InnerEnable(); automation_override_.Set(enabled); - return Response::Success(); + return protocol::Response::Success(); } void InspectorEmulationAgent::ApplyAutomationOverride(bool& enabled) const {
diff --git a/third_party/blink/renderer/core/inspector/inspector_io_agent.cc b/third_party/blink/renderer/core/inspector/inspector_io_agent.cc index e166739..161edb25 100644 --- a/third_party/blink/renderer/core/inspector/inspector_io_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_io_agent.cc
@@ -10,34 +10,37 @@ namespace blink { -using protocol::Response; - InspectorIOAgent::InspectorIOAgent(v8::Isolate* isolate, v8_inspector::V8InspectorSession* session) : isolate_(isolate), v8_session_(session) {} InspectorIOAgent::~InspectorIOAgent() = default; -Response InspectorIOAgent::resolveBlob(const String& object_id, String* uuid) { +protocol::Response InspectorIOAgent::resolveBlob(const String& object_id, + String* uuid) { v8::HandleScope handles(isolate_); v8::Local<v8::Value> value; v8::Local<v8::Context> context; std::unique_ptr<v8_inspector::StringBuffer> error; if (!v8_session_->unwrapObject(&error, ToV8InspectorStringView(object_id), - &value, &context, nullptr)) - return Response::ServerError(ToCoreString(std::move(error)).Utf8()); + &value, &context, nullptr)) { + return protocol::Response::ServerError( + ToCoreString(std::move(error)).Utf8()); + } - if (!V8Blob::HasInstance(value, isolate_)) - return Response::ServerError("Object id doesn't reference a Blob"); + if (!V8Blob::HasInstance(value, isolate_)) { + return protocol::Response::ServerError( + "Object id doesn't reference a Blob"); + } Blob* blob = V8Blob::ToImpl(v8::Local<v8::Object>::Cast(value)); if (!blob) { - return Response::ServerError( + return protocol::Response::ServerError( "Couldn't convert object with given objectId to Blob"); } *uuid = blob->Uuid(); - return Response::Success(); + return protocol::Response::Success(); } } // namespace blink
diff --git a/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc b/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc index 5279b84..74ced4e3 100644 --- a/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_layer_tree_agent.cc
@@ -64,7 +64,6 @@ using protocol::Array; using protocol::Maybe; -using protocol::Response; unsigned InspectorLayerTreeAgent::last_snapshot_id_; inline String IdForLayer(const cc::Layer* layer) { @@ -260,19 +259,19 @@ // front-end request document and re-enable the agent manually after this. } -Response InspectorLayerTreeAgent::enable() { +protocol::Response InspectorLayerTreeAgent::enable() { instrumenting_agents_->AddInspectorLayerTreeAgent(this); if (auto* view = inspected_frames_->Root()->View()) { view->ScheduleAnimation(); - return Response::Success(); + return protocol::Response::Success(); } - return Response::ServerError("The root frame doesn't have a view"); + return protocol::Response::ServerError("The root frame doesn't have a view"); } -Response InspectorLayerTreeAgent::disable() { +protocol::Response InspectorLayerTreeAgent::disable() { instrumenting_agents_->RemoveInspectorLayerTreeAgent(this); snapshot_by_id_.clear(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorLayerTreeAgent::LayerTreeDidChange() { @@ -327,25 +326,26 @@ return nullptr; } -Response InspectorLayerTreeAgent::LayerById(const String& layer_id, - const cc::Layer*& result) { +protocol::Response InspectorLayerTreeAgent::LayerById( + const String& layer_id, + const cc::Layer*& result) { bool ok; int id = layer_id.ToInt(&ok); if (!ok) - return Response::ServerError("Invalid layer id"); + return protocol::Response::ServerError("Invalid layer id"); result = FindLayerById(RootLayer(), id); if (!result) - return Response::ServerError("No layer matching given id found"); - return Response::Success(); + return protocol::Response::ServerError("No layer matching given id found"); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::compositingReasons( +protocol::Response InspectorLayerTreeAgent::compositingReasons( const String& layer_id, std::unique_ptr<Array<String>>* compositing_reasons, std::unique_ptr<Array<String>>* compositing_reason_ids) { const cc::Layer* layer = nullptr; - Response response = LayerById(layer_id, layer); + protocol::Response response = LayerById(layer_id, layer); if (!response.IsSuccess()) return response; *compositing_reasons = std::make_unique<protocol::Array<String>>(); @@ -361,11 +361,11 @@ } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::makeSnapshot(const String& layer_id, - String* snapshot_id) { +protocol::Response InspectorLayerTreeAgent::makeSnapshot(const String& layer_id, + String* snapshot_id) { suppress_layer_paint_events_ = true; // If we hit a devtool break point in the middle of document lifecycle, for @@ -375,7 +375,7 @@ ->GetDocument() ->Lifecycle() .LifecyclePostponed()) - return Response::ServerError("Layer does not draw content"); + return protocol::Response::ServerError("Layer does not draw content"); inspected_frames_->Root()->View()->UpdateAllLifecyclePhases( DocumentUpdateReason::kInspector); @@ -383,30 +383,34 @@ suppress_layer_paint_events_ = false; const cc::Layer* layer = nullptr; - Response response = LayerById(layer_id, layer); + protocol::Response response = LayerById(layer_id, layer); if (!response.IsSuccess()) return response; if (!layer->draws_content()) - return Response::ServerError("Layer does not draw content"); + return protocol::Response::ServerError("Layer does not draw content"); auto picture = layer->GetPicture(); if (!picture) - return Response::ServerError("Layer does not produce picture"); + return protocol::Response::ServerError("Layer does not produce picture"); auto snapshot = base::MakeRefCounted<PictureSnapshot>(std::move(picture)); *snapshot_id = String::Number(++last_snapshot_id_); bool new_entry = snapshot_by_id_.insert(*snapshot_id, snapshot).is_new_entry; DCHECK(new_entry); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::loadSnapshot( +protocol::Response InspectorLayerTreeAgent::loadSnapshot( std::unique_ptr<Array<protocol::LayerTree::PictureTile>> tiles, String* snapshot_id) { - if (tiles->empty()) - return Response::ServerError("Invalid argument, no tiles provided"); - if (tiles->size() > UINT_MAX) - return Response::ServerError("Invalid argument, too many tiles provided"); + if (tiles->empty()) { + return protocol::Response::ServerError( + "Invalid argument, no tiles provided"); + } + if (tiles->size() > UINT_MAX) { + return protocol::Response::ServerError( + "Invalid argument, too many tiles provided"); + } wtf_size_t tiles_length = static_cast<wtf_size_t>(tiles->size()); Vector<scoped_refptr<PictureSnapshot::TilePictureStream>> decoded_tiles; decoded_tiles.Grow(tiles_length); @@ -421,49 +425,51 @@ scoped_refptr<PictureSnapshot> snapshot = PictureSnapshot::Load(decoded_tiles); if (!snapshot) - return Response::ServerError("Invalid snapshot format"); + return protocol::Response::ServerError("Invalid snapshot format"); if (snapshot->IsEmpty()) - return Response::ServerError("Empty snapshot"); + return protocol::Response::ServerError("Empty snapshot"); *snapshot_id = String::Number(++last_snapshot_id_); bool new_entry = snapshot_by_id_.insert(*snapshot_id, snapshot).is_new_entry; DCHECK(new_entry); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::releaseSnapshot(const String& snapshot_id) { +protocol::Response InspectorLayerTreeAgent::releaseSnapshot( + const String& snapshot_id) { SnapshotById::iterator it = snapshot_by_id_.find(snapshot_id); if (it == snapshot_by_id_.end()) - return Response::ServerError("Snapshot not found"); + return protocol::Response::ServerError("Snapshot not found"); snapshot_by_id_.erase(it); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::GetSnapshotById( +protocol::Response InspectorLayerTreeAgent::GetSnapshotById( const String& snapshot_id, const PictureSnapshot*& result) { SnapshotById::iterator it = snapshot_by_id_.find(snapshot_id); if (it == snapshot_by_id_.end()) - return Response::ServerError("Snapshot not found"); + return protocol::Response::ServerError("Snapshot not found"); result = it->value.get(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::replaySnapshot(const String& snapshot_id, - Maybe<int> from_step, - Maybe<int> to_step, - Maybe<double> scale, - String* data_url) { +protocol::Response InspectorLayerTreeAgent::replaySnapshot( + const String& snapshot_id, + Maybe<int> from_step, + Maybe<int> to_step, + Maybe<double> scale, + String* data_url) { const PictureSnapshot* snapshot = nullptr; - Response response = GetSnapshotById(snapshot_id, snapshot); + protocol::Response response = GetSnapshotById(snapshot_id, snapshot); if (!response.IsSuccess()) return response; auto png_data = snapshot->Replay(from_step.fromMaybe(0), to_step.fromMaybe(0), scale.fromMaybe(1.0)); if (png_data.empty()) - return Response::ServerError("Image encoding failed"); + return protocol::Response::ServerError("Image encoding failed"); *data_url = "data:image/png;base64," + Base64Encode(png_data); - return Response::Success(); + return protocol::Response::Success(); } static void ParseRect(protocol::DOM::Rect* object, gfx::RectF* rect) { @@ -471,14 +477,14 @@ object->getHeight()); } -Response InspectorLayerTreeAgent::profileSnapshot( +protocol::Response InspectorLayerTreeAgent::profileSnapshot( const String& snapshot_id, Maybe<int> min_repeat_count, Maybe<double> min_duration, Maybe<protocol::DOM::Rect> clip_rect, std::unique_ptr<protocol::Array<protocol::Array<double>>>* out_timings) { const PictureSnapshot* snapshot = nullptr; - Response response = GetSnapshotById(snapshot_id, snapshot); + protocol::Response response = GetSnapshotById(snapshot_id, snapshot); if (!response.IsSuccess()) return response; gfx::RectF rect; @@ -494,14 +500,14 @@ out_row->emplace_back(delta.InSecondsF()); (*out_timings)->emplace_back(std::move(out_row)); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLayerTreeAgent::snapshotCommandLog( +protocol::Response InspectorLayerTreeAgent::snapshotCommandLog( const String& snapshot_id, std::unique_ptr<Array<protocol::DictionaryValue>>* command_log) { const PictureSnapshot* snapshot = nullptr; - Response response = GetSnapshotById(snapshot_id, snapshot); + protocol::Response response = GetSnapshotById(snapshot_id, snapshot); if (!response.IsSuccess()) return response; protocol::ErrorSupport errors; @@ -523,8 +529,8 @@ &errors); auto err = errors.Errors(); if (err.empty()) - return Response::Success(); - return Response::ServerError(std::string(err.begin(), err.end())); + return protocol::Response::Success(); + return protocol::Response::ServerError(std::string(err.begin(), err.end())); } } // namespace blink
diff --git a/third_party/blink/renderer/core/inspector/inspector_log_agent.cc b/third_party/blink/renderer/core/inspector/inspector_log_agent.cc index 44d3238..ad5d09e 100644 --- a/third_party/blink/renderer/core/inspector/inspector_log_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_log_agent.cc
@@ -16,7 +16,6 @@ #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" namespace blink { -using protocol::Response; namespace { @@ -192,26 +191,26 @@ ConsoleMessageAdded(storage_->at(i)); } -Response InspectorLogAgent::enable() { +protocol::Response InspectorLogAgent::enable() { if (enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Set(true); InnerEnable(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLogAgent::disable() { +protocol::Response InspectorLogAgent::disable() { if (!enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Clear(); stopViolationsReport(); instrumenting_agents_->RemoveInspectorLogAgent(this); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLogAgent::clear() { +protocol::Response InspectorLogAgent::clear() { storage_->Clear(); - return Response::Success(); + return protocol::Response::Success(); } static PerformanceMonitor::Violation ParseViolation(const String& name) { @@ -232,12 +231,12 @@ return PerformanceMonitor::kAfterLast; } -Response InspectorLogAgent::startViolationsReport( +protocol::Response InspectorLogAgent::startViolationsReport( std::unique_ptr<protocol::Array<ViolationSetting>> settings) { if (!enabled_.Get()) - return Response::ServerError("Log is not enabled"); + return protocol::Response::ServerError("Log is not enabled"); if (!performance_monitor_) { - return Response::ServerError( + return protocol::Response::ServerError( "Violations are not supported for this target"); } performance_monitor_->UnsubscribeAll(this); @@ -252,17 +251,17 @@ this); violation_thresholds_.Set(name, threshold); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorLogAgent::stopViolationsReport() { +protocol::Response InspectorLogAgent::stopViolationsReport() { violation_thresholds_.Clear(); if (!performance_monitor_) { - return Response::ServerError( + return protocol::Response::ServerError( "Violations are not supported for this target"); } performance_monitor_->UnsubscribeAll(this); - return Response::Success(); + return protocol::Response::Success(); } void InspectorLogAgent::ReportLongLayout(base::TimeDelta duration) {
diff --git a/third_party/blink/renderer/core/inspector/inspector_memory_agent.cc b/third_party/blink/renderer/core/inspector/inspector_memory_agent.cc index 79bce018..f73fc791 100644 --- a/third_party/blink/renderer/core/inspector/inspector_memory_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_memory_agent.cc
@@ -49,26 +49,25 @@ constexpr int kDefaultNativeMemorySamplingInterval = 128 * 1024; -using protocol::Response; - InspectorMemoryAgent::InspectorMemoryAgent(InspectedFrames* inspected_frames) : frames_(inspected_frames), sampling_profile_interval_(&agent_state_, /*default_value=*/0) {} InspectorMemoryAgent::~InspectorMemoryAgent() = default; -Response InspectorMemoryAgent::getDOMCounters(int* documents, - int* nodes, - int* js_event_listeners) { +protocol::Response InspectorMemoryAgent::getDOMCounters( + int* documents, + int* nodes, + int* js_event_listeners) { *documents = InstanceCounters::CounterValue(InstanceCounters::kDocumentCounter); *nodes = InstanceCounters::CounterValue(InstanceCounters::kNodeCounter); *js_event_listeners = InstanceCounters::CounterValue(InstanceCounters::kJSEventListenerCounter); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorMemoryAgent::forciblyPurgeJavaScriptMemory() { +protocol::Response InspectorMemoryAgent::forciblyPurgeJavaScriptMemory() { for (const auto& page : Page::OrdinaryPages()) { for (Frame* frame = page->MainFrame(); frame; frame = frame->Tree().TraverseNext()) { @@ -80,7 +79,7 @@ } V8PerIsolateData::MainThreadIsolate()->MemoryPressureNotification( v8::MemoryPressureLevel::kCritical); - return Response::Success(); + return protocol::Response::Success(); } void InspectorMemoryAgent::Trace(Visitor* visitor) const { @@ -94,13 +93,13 @@ protocol::Maybe<bool>()); } -Response InspectorMemoryAgent::startSampling( +protocol::Response InspectorMemoryAgent::startSampling( protocol::Maybe<int> in_sampling_interval, protocol::Maybe<bool> in_suppressRandomness) { int interval = in_sampling_interval.fromMaybe(kDefaultNativeMemorySamplingInterval); if (interval <= 0) - return Response::ServerError("Invalid sampling rate."); + return protocol::Response::ServerError("Invalid sampling rate."); base::SamplingHeapProfiler::Get()->SetSamplingInterval(interval); sampling_profile_interval_.Set(interval); if (in_suppressRandomness.fromMaybe(false)) { @@ -108,28 +107,28 @@ base::PoissonAllocationSampler::ScopedSuppressRandomnessForTesting>(); } profile_id_ = base::SamplingHeapProfiler::Get()->Start(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorMemoryAgent::stopSampling() { +protocol::Response InspectorMemoryAgent::stopSampling() { if (sampling_profile_interval_.Get() == 0) - return Response::ServerError("Sampling profiler is not started."); + return protocol::Response::ServerError("Sampling profiler is not started."); base::SamplingHeapProfiler::Get()->Stop(); sampling_profile_interval_.Clear(); randomness_suppressor_.reset(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorMemoryAgent::getAllTimeSamplingProfile( +protocol::Response InspectorMemoryAgent::getAllTimeSamplingProfile( std::unique_ptr<protocol::Memory::SamplingProfile>* out_profile) { *out_profile = GetSamplingProfileById(0); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorMemoryAgent::getSamplingProfile( +protocol::Response InspectorMemoryAgent::getSamplingProfile( std::unique_ptr<protocol::Memory::SamplingProfile>* out_profile) { *out_profile = GetSamplingProfileById(profile_id_); - return Response::Success(); + return protocol::Response::Success(); } std::unique_ptr<protocol::Memory::SamplingProfile>
diff --git a/third_party/blink/renderer/core/inspector/inspector_network_agent.cc b/third_party/blink/renderer/core/inspector/inspector_network_agent.cc index 7f3a18dd..3715244 100644 --- a/third_party/blink/renderer/core/inspector/inspector_network_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_network_agent.cc
@@ -114,7 +114,6 @@ protocol::Network::Backend::GetRequestPostDataCallback; using GetResponseBodyCallback = protocol::Network::Backend::GetResponseBodyCallback; -using protocol::Response; namespace { @@ -259,7 +258,8 @@ std::unique_ptr<GetResponseBodyCallback> callback, scoped_refptr<SharedBuffer> raw_data) { if (!raw_data) { - callback->sendFailure(Response::ServerError("Couldn't read BLOB")); + callback->sendFailure( + protocol::Response::ServerError("Couldn't read BLOB")); return; } String result; @@ -268,7 +268,8 @@ raw_data, mime_type, text_encoding_name, &result, &base64_encoded)) { callback->sendSuccess(result, base64_encoded); } else { - callback->sendFailure(Response::ServerError("Couldn't encode data")); + callback->sendFailure( + protocol::Response::ServerError("Couldn't encode data")); } } @@ -1914,15 +1915,16 @@ base::TimeTicks::Now().since_origin().InSecondsF()); } -Response InspectorNetworkAgent::enable(Maybe<int> total_buffer_size, - Maybe<int> resource_buffer_size, - Maybe<int> max_post_data_size) { +protocol::Response InspectorNetworkAgent::enable( + Maybe<int> total_buffer_size, + Maybe<int> resource_buffer_size, + Maybe<int> max_post_data_size) { total_buffer_size_.Set(total_buffer_size.fromMaybe(kDefaultTotalBufferSize)); resource_buffer_size_.Set( resource_buffer_size.fromMaybe(kDefaultResourceBufferSize)); max_post_data_size_.Set(max_post_data_size.fromMaybe(0)); Enable(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorNetworkAgent::Enable() { @@ -1934,7 +1936,7 @@ instrumenting_agents_->AddInspectorNetworkAgent(this); } -Response InspectorNetworkAgent::disable() { +protocol::Response InspectorNetworkAgent::disable() { DCHECK(!pending_request_type_); if (IsMainThread()) GetNetworkStateNotifier().ClearOverride(); @@ -1942,10 +1944,10 @@ agent_state_.ClearAllFields(); resources_data_->Clear(); clearAcceptedEncodingsOverride(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::setExtraHTTPHeaders( +protocol::Response InspectorNetworkAgent::setExtraHTTPHeaders( std::unique_ptr<protocol::Network::Headers> headers) { extra_request_headers_.Clear(); std::unique_ptr<protocol::DictionaryValue> in = headers->toValue(); @@ -1955,14 +1957,14 @@ if (entry.second && entry.second->asString(&value)) extra_request_headers_.Set(entry.first, value); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::setAttachDebugStack(bool enabled) { +protocol::Response InspectorNetworkAgent::setAttachDebugStack(bool enabled) { if (enabled && !enabled_.Get()) - return Response::InvalidParams("Domain must be enabled"); + return protocol::Response::InvalidParams("Domain must be enabled"); attach_debug_stack_enabled_.Set(enabled); - return Response::Success(); + return protocol::Response::Success(); } bool InspectorNetworkAgent::CanGetResponseBodyBlob(const String& request_id) { @@ -1987,7 +1989,7 @@ BlobDataHandle* blob = resource_data->DownloadedFileBlob(); ExecutionContext* context = GetTargetExecutionContext(); if (!context) { - callback->sendFailure(Response::InternalError()); + callback->sendFailure(protocol::Response::InternalError()); return; } InspectorFileReaderLoaderClient* client = @@ -2009,7 +2011,8 @@ String content; bool base64_encoded; - Response response = GetResponseBody(request_id, &content, &base64_encoded); + protocol::Response response = + GetResponseBody(request_id, &content, &base64_encoded); if (response.IsSuccess()) { callback->sendSuccess(content, base64_encoded); } else { @@ -2017,26 +2020,28 @@ } } -Response InspectorNetworkAgent::setBlockedURLs( +protocol::Response InspectorNetworkAgent::setBlockedURLs( std::unique_ptr<protocol::Array<String>> urls) { blocked_urls_.Clear(); for (const String& url : *urls) blocked_urls_.Set(url, true); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::replayXHR(const String& request_id) { +protocol::Response InspectorNetworkAgent::replayXHR(const String& request_id) { String actual_request_id = request_id; XHRReplayData* xhr_replay_data = resources_data_->XhrReplayData(request_id); auto* data = resources_data_->Data(request_id); - if (!xhr_replay_data || !data) - return Response::ServerError("Given id does not correspond to XHR"); + if (!xhr_replay_data || !data) { + return protocol::Response::ServerError( + "Given id does not correspond to XHR"); + } ExecutionContext* execution_context = xhr_replay_data->GetExecutionContext(); if (!execution_context || execution_context->IsContextDestroyed()) { resources_data_->SetXHRReplayData(request_id, nullptr); - return Response::ServerError("Document is already detached"); + return protocol::Response::ServerError("Document is already detached"); } XMLHttpRequest* xhr = XMLHttpRequest::Create(execution_context); @@ -2055,28 +2060,28 @@ IGNORE_EXCEPTION_FOR_TESTING); replay_xhrs_.insert(xhr); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::canClearBrowserCache(bool* result) { +protocol::Response InspectorNetworkAgent::canClearBrowserCache(bool* result) { *result = true; - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::canClearBrowserCookies(bool* result) { +protocol::Response InspectorNetworkAgent::canClearBrowserCookies(bool* result) { *result = true; - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::setAcceptedEncodings( +protocol::Response InspectorNetworkAgent::setAcceptedEncodings( std::unique_ptr<protocol::Array<protocol::Network::ContentEncoding>> encodings) { HashSet<String> accepted_encodings; for (const protocol::Network::ContentEncoding& encoding : *encodings) { absl::optional<String> value = AcceptedEncodingFromProtocol(encoding); if (!value) { - return Response::InvalidParams("Unknown encoding type: " + - encoding.Utf8()); + return protocol::Response::InvalidParams("Unknown encoding type: " + + encoding.Utf8()); } accepted_encodings.insert(value.value()); } @@ -2090,15 +2095,15 @@ for (auto encoding : accepted_encodings) accepted_encodings_.Set(encoding, true); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::clearAcceptedEncodingsOverride() { +protocol::Response InspectorNetworkAgent::clearAcceptedEncodingsOverride() { accepted_encodings_.Clear(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::emulateNetworkConditions( +protocol::Response InspectorNetworkAgent::emulateNetworkConditions( bool offline, double latency, double download_throughput, @@ -2108,7 +2113,7 @@ if (connection_type.isJust()) { type = ToWebConnectionType(connection_type.fromJust()); if (type == kWebConnectionTypeUnknown) - return Response::ServerError("Unknown connection type"); + return protocol::Response::ServerError("Unknown connection type"); } if (worker_global_scope_) { @@ -2123,33 +2128,34 @@ FROM_HERE, CrossThreadBindOnce(SetNetworkStateOverride, offline, latency, download_throughput, upload_throughput, type)); - return Response::Success(); + return protocol::Response::Success(); } - return Response::ServerError("Not supported"); + return protocol::Response::ServerError("Not supported"); } SetNetworkStateOverride(offline, latency, download_throughput, upload_throughput, type); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::setCacheDisabled(bool cache_disabled) { +protocol::Response InspectorNetworkAgent::setCacheDisabled( + bool cache_disabled) { // TODO(ananta) // We should extract network cache state into a global entity which can be // queried from FrameLoader and other places. cache_disabled_.Set(cache_disabled); if (cache_disabled && IsMainThread()) MemoryCache::Get()->EvictResources(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::setBypassServiceWorker(bool bypass) { +protocol::Response InspectorNetworkAgent::setBypassServiceWorker(bool bypass) { bypass_service_worker_.Set(bypass); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorNetworkAgent::getCertificate( +protocol::Response InspectorNetworkAgent::getCertificate( const String& origin, std::unique_ptr<protocol::Array<String>>* certificate) { *certificate = std::make_unique<protocol::Array<String>>(); @@ -2168,10 +2174,10 @@ ->push_back( Base64Encode(net::x509_util::CryptoBufferAsSpan(buf.get()))); } - return Response::Success(); + return protocol::Response::Success(); } } - return Response::Success(); + return protocol::Response::Success(); } void InspectorNetworkAgent::DidCommitLoad(LocalFrame* frame, @@ -2203,23 +2209,25 @@ frame_navigation_initiator_map_.erase(IdentifiersFactory::FrameId(frame)); } -Response InspectorNetworkAgent::GetResponseBody(const String& request_id, - String* content, - bool* base64_encoded) { +protocol::Response InspectorNetworkAgent::GetResponseBody( + const String& request_id, + String* content, + bool* base64_encoded) { NetworkResourcesData::ResourceData const* resource_data = resources_data_->Data(request_id); if (!resource_data) { - return Response::ServerError("No resource with given identifier found"); + return protocol::Response::ServerError( + "No resource with given identifier found"); } if (resource_data->HasContent()) { *content = resource_data->Content(); *base64_encoded = resource_data->Base64Encoded(); - return Response::Success(); + return protocol::Response::Success(); } if (resource_data->IsContentEvicted()) { - return Response::ServerError( + return protocol::Response::ServerError( "Request content was evicted from inspector cache"); } @@ -2228,20 +2236,20 @@ resource_data->Buffer(), resource_data->MimeType(), resource_data->TextEncodingName(), content, base64_encoded); DCHECK(success); - return Response::Success(); + return protocol::Response::Success(); } if (resource_data->CachedResource() && InspectorPageAgent::CachedResourceContent(resource_data->CachedResource(), content, base64_encoded)) { - return Response::Success(); + return protocol::Response::Success(); } - return Response::ServerError( + return protocol::Response::ServerError( "No data found for resource with given identifier"); } -Response InspectorNetworkAgent::searchInResponseBody( +protocol::Response InspectorNetworkAgent::searchInResponseBody( const String& request_id, const String& query, Maybe<bool> case_sensitive, @@ -2251,7 +2259,8 @@ matches) { String content; bool base64_encoded; - Response response = GetResponseBody(request_id, &content, &base64_encoded); + protocol::Response response = + GetResponseBody(request_id, &content, &base64_encoded); if (!response.IsSuccess()) return response; @@ -2261,7 +2270,7 @@ *matches = std::make_unique< protocol::Array<v8_inspector::protocol::Debugger::API::SearchMatch>>( std::move(results)); - return Response::Success(); + return protocol::Response::Success(); } bool InspectorNetworkAgent::FetchResourceContent(Document* document, @@ -2354,18 +2363,18 @@ resources_data_->Data(request_id); if (!resource_data) { callback->sendFailure( - Response::ServerError("No resource with given id was found")); + protocol::Response::ServerError("No resource with given id was found")); return; } scoped_refptr<EncodedFormData> post_data = resource_data->PostData(); if (!post_data || post_data->IsEmpty()) { - callback->sendFailure( - Response::ServerError("No post data available for the request")); + callback->sendFailure(protocol::Response::ServerError( + "No post data available for the request")); return; } ExecutionContext* context = GetTargetExecutionContext(); if (!context) { - callback->sendFailure(Response::InternalError()); + callback->sendFailure(protocol::Response::InternalError()); return; } scoped_refptr<InspectorPostBodyParser> parser =
diff --git a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc index be4713c7..6f1f76c 100644 --- a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc
@@ -97,7 +97,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace { @@ -436,9 +435,9 @@ disposed_ = true; } -Response InspectorOverlayAgent::enable() { +protocol::Response InspectorOverlayAgent::enable() { if (!dom_agent_->Enabled()) - return Response::ServerError("DOM should be enabled first"); + return protocol::Response::ServerError("DOM should be enabled first"); enabled_.Set(true); if (backend_node_id_to_inspect_) { GetFrontend()->inspectNodeRequested( @@ -446,7 +445,7 @@ } backend_node_id_to_inspect_ = 0; SetNeedsUnbufferedInput(true); - return Response::Success(); + return protocol::Response::Success(); } void InspectorOverlayAgent::EnsureAXContext(Node* node) { @@ -457,7 +456,7 @@ } } -Response InspectorOverlayAgent::disable() { +protocol::Response InspectorOverlayAgent::disable() { enabled_.Clear(); setShowAdHighlights(false); setShowViewportSizeOnResize(false); @@ -485,19 +484,19 @@ PickTheRightTool(); SetNeedsUnbufferedInput(false); document_to_ax_context_.clear(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowAdHighlights(bool show) { +protocol::Response InspectorOverlayAgent::setShowAdHighlights(bool show) { show_ad_highlights_.Set(show); frame_impl_->ViewImpl()->GetPage()->GetSettings().SetHighlightAds(show); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowDebugBorders(bool show) { +protocol::Response InspectorOverlayAgent::setShowDebugBorders(bool show) { show_debug_borders_.Set(show); if (show) { - Response response = CompositingEnabled(); + protocol::Response response = CompositingEnabled(); if (!response.IsSuccess()) return response; } @@ -508,13 +507,13 @@ else debug_state.show_debug_borders.reset(); widget->SetLayerTreeDebugState(debug_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowFPSCounter(bool show) { +protocol::Response InspectorOverlayAgent::setShowFPSCounter(bool show) { show_fps_counter_.Set(show); if (show) { - Response response = CompositingEnabled(); + protocol::Response response = CompositingEnabled(); if (!response.IsSuccess()) return response; } @@ -522,13 +521,13 @@ cc::LayerTreeDebugState debug_state = widget->GetLayerTreeDebugState(); debug_state.show_fps_counter = show; widget->SetLayerTreeDebugState(debug_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowPaintRects(bool show) { +protocol::Response InspectorOverlayAgent::setShowPaintRects(bool show) { show_paint_rects_.Set(show); if (show) { - Response response = CompositingEnabled(); + protocol::Response response = CompositingEnabled(); if (!response.IsSuccess()) return response; } @@ -536,13 +535,13 @@ cc::LayerTreeDebugState debug_state = widget->GetLayerTreeDebugState(); debug_state.show_paint_rects = show; widget->SetLayerTreeDebugState(debug_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowLayoutShiftRegions(bool show) { +protocol::Response InspectorOverlayAgent::setShowLayoutShiftRegions(bool show) { show_layout_shift_regions_.Set(show); if (show) { - Response response = CompositingEnabled(); + protocol::Response response = CompositingEnabled(); if (!response.IsSuccess()) return response; } @@ -550,13 +549,14 @@ cc::LayerTreeDebugState debug_state = widget->GetLayerTreeDebugState(); debug_state.show_layout_shift_regions = show; widget->SetLayerTreeDebugState(debug_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowScrollBottleneckRects(bool show) { +protocol::Response InspectorOverlayAgent::setShowScrollBottleneckRects( + bool show) { show_scroll_bottleneck_rects_.Set(show); if (show) { - Response response = CompositingEnabled(); + protocol::Response response = CompositingEnabled(); if (!response.IsSuccess()) return response; } @@ -567,23 +567,24 @@ debug_state.show_non_fast_scrollable_rects = show; debug_state.show_main_thread_scrolling_reason_rects = show; widget->SetLayerTreeDebugState(debug_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowHitTestBorders(bool show) { +protocol::Response InspectorOverlayAgent::setShowHitTestBorders(bool show) { // This CDP command has been deprecated. Don't do anything and return success. - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowViewportSizeOnResize(bool show) { +protocol::Response InspectorOverlayAgent::setShowViewportSizeOnResize( + bool show) { show_size_on_resize_.Set(show); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowWebVitals(bool show) { +protocol::Response InspectorOverlayAgent::setShowWebVitals(bool show) { show_web_vitals_.Set(show); if (show) { - Response response = CompositingEnabled(); + protocol::Response response = CompositingEnabled(); if (!response.IsSuccess()) return response; } @@ -591,17 +592,17 @@ cc::LayerTreeDebugState debug_state = widget->GetLayerTreeDebugState(); debug_state.show_web_vital_metrics = show; widget->SetLayerTreeDebugState(debug_state); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setPausedInDebuggerMessage( +protocol::Response InspectorOverlayAgent::setPausedInDebuggerMessage( Maybe<String> message) { paused_in_debugger_message_.Set(message.fromMaybe(String())); PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::highlightRect( +protocol::Response InspectorOverlayAgent::highlightRect( int x, int y, int width, @@ -616,20 +617,20 @@ InspectorDOMAgent::ParseColor(outline_color.fromMaybe(nullptr)))); } -Response InspectorOverlayAgent::highlightQuad( +protocol::Response InspectorOverlayAgent::highlightQuad( std::unique_ptr<protocol::Array<double>> quad_array, Maybe<protocol::DOM::RGBA> color, Maybe<protocol::DOM::RGBA> outline_color) { std::unique_ptr<gfx::QuadF> quad = std::make_unique<gfx::QuadF>(); if (!ParseQuad(std::move(quad_array), quad.get())) - return Response::ServerError("Invalid Quad format"); + return protocol::Response::ServerError("Invalid Quad format"); return SetInspectTool(MakeGarbageCollected<QuadHighlightTool>( this, GetFrontend(), std::move(quad), InspectorDOMAgent::ParseColor(color.fromMaybe(nullptr)), InspectorDOMAgent::ParseColor(outline_color.fromMaybe(nullptr)))); } -Response InspectorOverlayAgent::setShowHinge( +protocol::Response InspectorOverlayAgent::setShowHinge( protocol::Maybe<protocol::Overlay::HingeConfig> tool_config) { // Hide the hinge when called without a configuration. if (!tool_config.isJust()) { @@ -637,7 +638,7 @@ if (!inspect_tool_) DisableFrameOverlay(); ScheduleUpdate(); - return Response::Success(); + return protocol::Response::Success(); } // Create a hinge @@ -648,7 +649,7 @@ int width = rect->getWidth(); int height = rect->getHeight(); if (x < 0 || y < 0 || width < 0 || height < 0) - return Response::InvalidParams("Invalid hinge rectangle."); + return protocol::Response::InvalidParams("Invalid hinge rectangle."); // Use default color if a content color is not provided. Color content_color = @@ -671,10 +672,10 @@ ScheduleUpdate(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::highlightNode( +protocol::Response InspectorOverlayAgent::highlightNode( std::unique_ptr<protocol::Overlay::HighlightConfig> highlight_inspector_object, Maybe<int> node_id, @@ -682,14 +683,15 @@ Maybe<String> object_id, Maybe<String> selector_list) { Node* node = nullptr; - Response response = + protocol::Response response = dom_agent_->AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; if (node->GetDocument().Lifecycle().GetState() <= DocumentLifecycle::LifecycleState::kInactive) { - return Response::InvalidRequest("The node's document is not active"); + return protocol::Response::InvalidRequest( + "The node's document is not active"); } std::unique_ptr<InspectorHighlightConfig> highlight_config; @@ -703,7 +705,7 @@ std::move(highlight_config))); } -Response InspectorOverlayAgent::setShowGridOverlays( +protocol::Response InspectorOverlayAgent::setShowGridOverlays( std::unique_ptr<protocol::Array<protocol::Overlay::GridNodeHighlightConfig>> grid_node_highlight_configs) { if (!persistent_tool_) { @@ -716,7 +718,8 @@ for (std::unique_ptr<protocol::Overlay::GridNodeHighlightConfig>& config : *grid_node_highlight_configs) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(config->getNodeId(), node); + protocol::Response response = + dom_agent_->AssertNode(config->getNodeId(), node); if (!response.IsSuccess()) return response; configs.insert(node, InspectorOverlayAgent::ToGridHighlightConfig( @@ -727,10 +730,10 @@ PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowFlexOverlays( +protocol::Response InspectorOverlayAgent::setShowFlexOverlays( std::unique_ptr<protocol::Array<protocol::Overlay::FlexNodeHighlightConfig>> flex_node_highlight_configs) { if (!persistent_tool_) { @@ -745,7 +748,8 @@ for (std::unique_ptr<protocol::Overlay::FlexNodeHighlightConfig>& config : *flex_node_highlight_configs) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(config->getNodeId(), node); + protocol::Response response = + dom_agent_->AssertNode(config->getNodeId(), node); if (!response.IsSuccess()) return response; configs.insert(node, InspectorOverlayAgent::ToFlexContainerHighlightConfig( @@ -756,10 +760,10 @@ PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowScrollSnapOverlays( +protocol::Response InspectorOverlayAgent::setShowScrollSnapOverlays( std::unique_ptr< protocol::Array<protocol::Overlay::ScrollSnapHighlightConfig>> scroll_snap_highlight_configs) { @@ -775,7 +779,8 @@ for (std::unique_ptr<protocol::Overlay::ScrollSnapHighlightConfig>& config : *scroll_snap_highlight_configs) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(config->getNodeId(), node); + protocol::Response response = + dom_agent_->AssertNode(config->getNodeId(), node); if (!response.IsSuccess()) return response; configs.insert(node, @@ -787,10 +792,10 @@ PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowContainerQueryOverlays( +protocol::Response InspectorOverlayAgent::setShowContainerQueryOverlays( std::unique_ptr< protocol::Array<protocol::Overlay::ContainerQueryHighlightConfig>> container_query_highlight_configs) { @@ -806,7 +811,8 @@ for (std::unique_ptr<protocol::Overlay::ContainerQueryHighlightConfig>& config : *container_query_highlight_configs) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(config->getNodeId(), node); + protocol::Response response = + dom_agent_->AssertNode(config->getNodeId(), node); if (!response.IsSuccess()) return response; configs.insert( @@ -818,10 +824,10 @@ PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::setShowIsolatedElements( +protocol::Response InspectorOverlayAgent::setShowIsolatedElements( std::unique_ptr< protocol::Array<protocol::Overlay::IsolatedElementHighlightConfig>> isolated_element_highlight_configs) { @@ -839,7 +845,8 @@ config : *isolated_element_highlight_configs) { Element* element = nullptr; // Isolation mode can only be triggered on elements - Response response = dom_agent_->AssertElement(config->getNodeId(), element); + protocol::Response response = + dom_agent_->AssertElement(config->getNodeId(), element); if (!response.IsSuccess()) return response; configs.insert(element, @@ -852,17 +859,17 @@ PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::highlightSourceOrder( +protocol::Response InspectorOverlayAgent::highlightSourceOrder( std::unique_ptr<protocol::Overlay::SourceOrderConfig> source_order_inspector_object, Maybe<int> node_id, Maybe<int> backend_node_id, Maybe<String> object_id) { Node* node = nullptr; - Response response = + protocol::Response response = dom_agent_->AssertNode(node_id, backend_node_id, object_id, node); if (!response.IsSuccess()) return response; @@ -876,7 +883,7 @@ this, GetFrontend(), node, std::move(source_order_config))); } -Response InspectorOverlayAgent::highlightFrame( +protocol::Response InspectorOverlayAgent::highlightFrame( const String& frame_id, Maybe<protocol::DOM::RGBA> color, Maybe<protocol::DOM::RGBA> outline_color) { @@ -884,10 +891,10 @@ IdentifiersFactory::FrameById(inspected_frames_, frame_id); // FIXME: Inspector doesn't currently work cross process. if (!frame) - return Response::ServerError("Invalid frame id"); + return protocol::Response::ServerError("Invalid frame id"); if (!frame->DeprecatedLocalOwner()) { PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } std::unique_ptr<InspectorHighlightConfig> highlight_config = @@ -903,14 +910,14 @@ std::move(highlight_config))); } -Response InspectorOverlayAgent::hideHighlight() { +protocol::Response InspectorOverlayAgent::hideHighlight() { if (inspect_tool_ && inspect_tool_->HideOnHideHighlight()) PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::getHighlightObjectForTest( +protocol::Response InspectorOverlayAgent::getHighlightObjectForTest( int node_id, Maybe<bool> include_distance, Maybe<bool> include_style, @@ -918,7 +925,7 @@ Maybe<bool> show_accessibility_info, std::unique_ptr<protocol::DictionaryValue>* result) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(node_id, node); + protocol::Response response = dom_agent_->AssertNode(node_id, node); if (!response.IsSuccess()) return response; @@ -943,10 +950,10 @@ node, DocumentUpdateReason::kInspector); *result = tool.GetNodeInspectorHighlightAsJson( true /* append_element_info */, include_distance.fromMaybe(false)); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::getGridHighlightObjectsForTest( +protocol::Response InspectorOverlayAgent::getGridHighlightObjectsForTest( std::unique_ptr<protocol::Array<int>> node_ids, std::unique_ptr<protocol::DictionaryValue>* highlights) { PersistentTool persistent_tool(this, GetFrontend()); @@ -955,7 +962,7 @@ configs; for (const int node_id : *node_ids) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(node_id, node); + protocol::Response response = dom_agent_->AssertNode(node_id, node); if (!response.IsSuccess()) return response; configs.insert(node, std::make_unique<InspectorGridHighlightConfig>( @@ -963,14 +970,14 @@ } persistent_tool.SetGridConfigs(std::move(configs)); *highlights = persistent_tool.GetGridInspectorHighlightsAsJson(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorOverlayAgent::getSourceOrderHighlightObjectForTest( +protocol::Response InspectorOverlayAgent::getSourceOrderHighlightObjectForTest( int node_id, std::unique_ptr<protocol::DictionaryValue>* result) { Node* node = nullptr; - Response response = dom_agent_->AssertNode(node_id, node); + protocol::Response response = dom_agent_->AssertNode(node_id, node); if (!response.IsSuccess()) return response; @@ -979,7 +986,7 @@ SourceOrderTool tool(this, GetFrontend(), node, std::move(config)); *result = tool.GetNodeInspectorSourceOrderHighlightAsJson(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorOverlayAgent::UpdatePrePaint() { @@ -1421,14 +1428,14 @@ ScheduleUpdate(); } -Response InspectorOverlayAgent::CompositingEnabled() { +protocol::Response InspectorOverlayAgent::CompositingEnabled() { bool main_frame = frame_impl_->ViewImpl() && !frame_impl_->Parent(); if (!main_frame || !frame_impl_->ViewImpl() ->GetPage() ->GetSettings() .GetAcceleratedCompositingEnabled()) - return Response::ServerError("Compositing mode is not supported"); - return Response::Success(); + return protocol::Response::ServerError("Compositing mode is not supported"); + return protocol::Response::Success(); } bool InspectorOverlayAgent::InSomeInspectMode() { @@ -1455,7 +1462,7 @@ GetFrontend()->inspectNodeRequested(IdentifiersFactory::IntIdForNode(node)); } -Response InspectorOverlayAgent::setInspectMode( +protocol::Response InspectorOverlayAgent::setInspectMode( const String& mode, Maybe<protocol::Overlay::HighlightConfig> highlight_inspector_object) { if (mode != protocol::Overlay::InspectModeEnum::None && @@ -1463,7 +1470,7 @@ mode != protocol::Overlay::InspectModeEnum::SearchForUAShadowDOM && mode != protocol::Overlay::InspectModeEnum::CaptureAreaScreenshot && mode != protocol::Overlay::InspectModeEnum::ShowDistances) { - return Response::ServerError( + return protocol::Response::ServerError( String("Unknown mode \"" + mode + "\" was provided.").Utf8()); } @@ -1472,14 +1479,14 @@ highlight_inspector_object.fromJust()->AppendSerialized(&serialized_config); } std::unique_ptr<InspectorHighlightConfig> config; - Response response = HighlightConfigFromInspectorObject( + protocol::Response response = HighlightConfigFromInspectorObject( std::move(highlight_inspector_object), &config); if (!response.IsSuccess()) return response; inspect_mode_.Set(mode); inspect_mode_protocol_config_.Set(serialized_config); PickTheRightTool(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorOverlayAgent::PickTheRightTool() { @@ -1544,21 +1551,22 @@ DisableFrameOverlay(); } -Response InspectorOverlayAgent::SetInspectTool(InspectTool* inspect_tool) { +protocol::Response InspectorOverlayAgent::SetInspectTool( + InspectTool* inspect_tool) { ClearInspectTool(); if (!inspect_tool) - return Response::Success(); + return protocol::Response::Success(); if (!enabled_.Get()) { - return Response::InvalidRequest( + return protocol::Response::InvalidRequest( "Overlay must be enabled before a tool can be shown"); } LocalFrameView* view = frame_impl_->GetFrameView(); LocalFrame* frame = GetFrame(); if (!view || !frame) - return Response::InternalError(); + return protocol::Response::InternalError(); inspect_tool_ = inspect_tool; // If the tool supports persistent overlays, the resources of the persistent @@ -1567,7 +1575,7 @@ EvaluateInOverlay("setOverlay", inspect_tool->GetOverlayName()); EnsureEnableFrameOverlay(); ScheduleUpdate(); - return Response::Success(); + return protocol::Response::Success(); } InspectorSourceOrderConfig @@ -1583,11 +1591,11 @@ return source_order_config; } -Response InspectorOverlayAgent::HighlightConfigFromInspectorObject( +protocol::Response InspectorOverlayAgent::HighlightConfigFromInspectorObject( Maybe<protocol::Overlay::HighlightConfig> highlight_inspector_object, std::unique_ptr<InspectorHighlightConfig>* out_config) { if (!highlight_inspector_object.isJust()) { - return Response::ServerError( + return protocol::Response::ServerError( "Internal error: highlight configuration parameter is missing"); } protocol::Overlay::HighlightConfig* config = @@ -1599,11 +1607,11 @@ if (format != ColorFormatEnum::Rgb && format != ColorFormatEnum::Hex && format != ColorFormatEnum::Hsl && format != ColorFormatEnum::Hwb) { - return Response::InvalidParams("Unknown color format"); + return protocol::Response::InvalidParams("Unknown color format"); } *out_config = InspectorOverlayAgent::ToHighlightConfig(config); - return Response::Success(); + return protocol::Response::Success(); } // static
diff --git a/third_party/blink/renderer/core/inspector/inspector_page_agent.cc b/third_party/blink/renderer/core/inspector/inspector_page_agent.cc index 8419f1c..8f4b06c5 100644 --- a/third_party/blink/renderer/core/inspector/inspector_page_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_page_agent.cc
@@ -100,8 +100,6 @@ namespace blink { -using protocol::Response; - namespace { String ClientNavigationReasonToProtocol(ClientNavigationReason reason) { @@ -537,13 +535,13 @@ } } -Response InspectorPageAgent::enable() { +protocol::Response InspectorPageAgent::enable() { enabled_.Set(true); instrumenting_agents_->AddInspectorPageAgent(this); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::disable() { +protocol::Response InspectorPageAgent::disable() { agent_state_.ClearAllFields(); pending_isolated_worlds_.clear(); script_to_evaluate_on_load_once_ = String(); @@ -556,10 +554,10 @@ ad_script_identifiers_.clear(); stopScreencast(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::addScriptToEvaluateOnNewDocument( +protocol::Response InspectorPageAgent::addScriptToEvaluateOnNewDocument( const String& source, Maybe<String> world_name, Maybe<bool> include_command_line_api, @@ -589,34 +587,35 @@ } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::removeScriptToEvaluateOnNewDocument( +protocol::Response InspectorPageAgent::removeScriptToEvaluateOnNewDocument( const String& identifier) { if (scripts_to_evaluate_on_load_.Get(identifier).IsNull()) - return Response::ServerError("Script not found"); + return protocol::Response::ServerError("Script not found"); scripts_to_evaluate_on_load_.Clear(identifier); worlds_to_evaluate_on_load_.Clear(identifier); include_command_line_api_for_scripts_to_evaluate_on_load_.Clear(identifier); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::addScriptToEvaluateOnLoad(const String& source, - String* identifier) { +protocol::Response InspectorPageAgent::addScriptToEvaluateOnLoad( + const String& source, + String* identifier) { return addScriptToEvaluateOnNewDocument(source, Maybe<String>(""), Maybe<bool>(false), identifier); } -Response InspectorPageAgent::removeScriptToEvaluateOnLoad( +protocol::Response InspectorPageAgent::removeScriptToEvaluateOnLoad( const String& identifier) { return removeScriptToEvaluateOnNewDocument(identifier); } -Response InspectorPageAgent::setLifecycleEventsEnabled(bool enabled) { +protocol::Response InspectorPageAgent::setLifecycleEventsEnabled(bool enabled) { lifecycle_events_enabled_.Set(enabled); if (!enabled) - return Response::Success(); + return protocol::Response::Success(); for (LocalFrame* frame : *inspected_frames_) { Document* document = frame->GetDocument(); @@ -659,24 +658,24 @@ } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::setAdBlockingEnabled(bool enable) { - return Response::Success(); +protocol::Response InspectorPageAgent::setAdBlockingEnabled(bool enable) { + return protocol::Response::Success(); } -Response InspectorPageAgent::reload( +protocol::Response InspectorPageAgent::reload( Maybe<bool> optional_bypass_cache, Maybe<String> optional_script_to_evaluate_on_load) { pending_script_to_evaluate_on_load_once_ = optional_script_to_evaluate_on_load.fromMaybe(""); v8_session_->setSkipAllPauses(true); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::stopLoading() { - return Response::Success(); +protocol::Response InspectorPageAgent::stopLoading() { + return protocol::Response::Success(); } static void CachedResourcesForDocument(Document* document, @@ -707,16 +706,16 @@ return result; } -Response InspectorPageAgent::getResourceTree( +protocol::Response InspectorPageAgent::getResourceTree( std::unique_ptr<protocol::Page::FrameResourceTree>* object) { *object = BuildObjectForResourceTree(inspected_frames_->Root()); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::getFrameTree( +protocol::Response InspectorPageAgent::getFrameTree( std::unique_ptr<protocol::Page::FrameTree>* object) { *object = BuildObjectForFrameTree(inspected_frames_->Root()); - return Response::Success(); + return protocol::Response::Success(); } void InspectorPageAgent::GetResourceContentAfterResourcesContentLoaded( @@ -726,7 +725,8 @@ LocalFrame* frame = IdentifiersFactory::FrameById(inspected_frames_, frame_id); if (!frame) { - callback->sendFailure(Response::ServerError("No frame for given id found")); + callback->sendFailure( + protocol::Response::ServerError("No frame for given id found")); return; } String content; @@ -737,7 +737,7 @@ callback->sendSuccess(content, base64_encoded); } else { callback->sendFailure( - Response::ServerError("No resource with given URL found")); + protocol::Response::ServerError("No resource with given URL found")); } } @@ -746,7 +746,8 @@ const String& url, std::unique_ptr<GetResourceContentCallback> callback) { if (!enabled_.Get()) { - callback->sendFailure(Response::ServerError("Agent is not enabled.")); + callback->sendFailure( + protocol::Response::ServerError("Agent is not enabled.")); return; } inspector_resource_content_loader_->EnsureResourcesContentLoaded( @@ -770,7 +771,7 @@ .build(); } - return Response::Success(); + return protocol::Response::Success(); } void InspectorPageAgent::SearchContentAfterResourcesContentLoaded( @@ -783,7 +784,8 @@ LocalFrame* frame = IdentifiersFactory::FrameById(inspected_frames_, frame_id); if (!frame) { - callback->sendFailure(Response::ServerError("No frame for given id found")); + callback->sendFailure( + protocol::Response::ServerError("No frame for given id found")); return; } String content; @@ -792,7 +794,7 @@ CachedResource(frame, KURL(url), inspector_resource_content_loader_), &content, &base64_encoded)) { callback->sendFailure( - Response::ServerError("No resource with given URL found")); + protocol::Response::ServerError("No resource with given URL found")); return; } @@ -813,7 +815,8 @@ Maybe<bool> optional_is_regex, std::unique_ptr<SearchInResourceCallback> callback) { if (!enabled_.Get()) { - callback->sendFailure(Response::ServerError("Agent is not enabled.")); + callback->sendFailure( + protocol::Response::ServerError("Agent is not enabled.")); return; } inspector_resource_content_loader_->EnsureResourcesContentLoaded( @@ -825,11 +828,11 @@ optional_is_regex.fromMaybe(false), std::move(callback))); } -Response InspectorPageAgent::setBypassCSP(bool enabled) { +protocol::Response InspectorPageAgent::setBypassCSP(bool enabled) { LocalFrame* frame = inspected_frames_->Root(); frame->GetSettings()->SetBypassCSP(enabled); bypass_csp_enabled_.Set(enabled); - return Response::Success(); + return protocol::Response::Success(); } namespace { @@ -862,7 +865,7 @@ } } // namespace -Response InspectorPageAgent::getPermissionsPolicyState( +protocol::Response InspectorPageAgent::getPermissionsPolicyState( const String& frame_id, std::unique_ptr< protocol::Array<protocol::Page::PermissionsPolicyFeatureState>>* @@ -870,14 +873,16 @@ LocalFrame* frame = IdentifiersFactory::FrameById(inspected_frames_, frame_id); - if (!frame) - return Response::ServerError("No frame for given id found in this target"); + if (!frame) { + return protocol::Response::ServerError( + "No frame for given id found in this target"); + } const blink::PermissionsPolicy* permissions_policy = frame->GetSecurityContext()->GetPermissionsPolicy(); if (!permissions_policy) - return Response::ServerError("Frame not ready"); + return protocol::Response::ServerError("Frame not ready"); auto feature_states = std::make_unique< protocol::Array<protocol::Page::PermissionsPolicyFeatureState>>(); @@ -906,21 +911,24 @@ } *states = std::move(feature_states); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::setDocumentContent(const String& frame_id, - const String& html) { +protocol::Response InspectorPageAgent::setDocumentContent( + const String& frame_id, + const String& html) { LocalFrame* frame = IdentifiersFactory::FrameById(inspected_frames_, frame_id); if (!frame) - return Response::ServerError("No frame for given id found"); + return protocol::Response::ServerError("No frame for given id found"); Document* document = frame->GetDocument(); - if (!document) - return Response::ServerError("No Document instance to set HTML for"); + if (!document) { + return protocol::Response::ServerError( + "No Document instance to set HTML for"); + } document->SetContent(html); - return Response::Success(); + return protocol::Response::Success(); } void InspectorPageAgent::DidNavigateWithinDocument(LocalFrame* frame) { @@ -1525,21 +1533,22 @@ return result; } -Response InspectorPageAgent::startScreencast(Maybe<String> format, - Maybe<int> quality, - Maybe<int> max_width, - Maybe<int> max_height, - Maybe<int> every_nth_frame) { +protocol::Response InspectorPageAgent::startScreencast( + Maybe<String> format, + Maybe<int> quality, + Maybe<int> max_width, + Maybe<int> max_height, + Maybe<int> every_nth_frame) { screencast_enabled_.Set(true); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::stopScreencast() { +protocol::Response InspectorPageAgent::stopScreencast() { screencast_enabled_.Set(false); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::getLayoutMetrics( +protocol::Response InspectorPageAgent::getLayoutMetrics( std::unique_ptr<protocol::Page::LayoutViewport>* out_layout_viewport, std::unique_ptr<protocol::Page::VisualViewport>* out_visual_viewport, std::unique_ptr<protocol::DOM::Rect>* out_content_size, @@ -1634,7 +1643,7 @@ .setScale(scale) .setZoom(page_zoom_factor) .build(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorPageAgent::createIsolatedWorld( @@ -1646,7 +1655,7 @@ IdentifiersFactory::FrameById(inspected_frames_, frame_id); if (!frame) { callback->sendFailure( - Response::InvalidParams("No frame for given id found")); + protocol::Response::InvalidParams("No frame for given id found")); return; } if (frame->IsProvisional()) { @@ -1654,7 +1663,7 @@ // won't work! if (!enabled_.Get()) { callback->sendFailure( - Response::ServerError("Agent needs to be enabled first")); + protocol::Response::ServerError("Agent needs to be enabled first")); return; } pending_isolated_worlds_.insert(frame, Vector<IsolatedWorldRequest>()) @@ -1678,7 +1687,7 @@ EnsureDOMWrapperWorld(&frame, world_name, grant_universal_access); if (!world) { callback->sendFailure( - Response::ServerError("Could not create isolated world")); + protocol::Response::ServerError("Could not create isolated world")); return; } @@ -1690,15 +1699,15 @@ isolated_world_window_proxy->ContextIfInitialized())); } -Response InspectorPageAgent::setFontFamilies( +protocol::Response InspectorPageAgent::setFontFamilies( GenericFontFamilySettings& family_settings, const protocol::Array<protocol::Page::ScriptFontFamilies>& script_font_families) { for (const auto& entry : script_font_families) { UScriptCode script = ScriptNameToCode(entry->getScript()); if (script == USCRIPT_INVALID_CODE) { - return Response::InvalidParams("Invalid script name: " + - entry->getScript().Utf8()); + return protocol::Response::InvalidParams("Invalid script name: " + + entry->getScript().Utf8()); } auto* font_families = entry->getFontFamilies(); if (font_families->hasStandard()) { @@ -1730,19 +1739,22 @@ script); } } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::setFontFamilies( +protocol::Response InspectorPageAgent::setFontFamilies( std::unique_ptr<protocol::Page::FontFamilies> font_families, Maybe<protocol::Array<protocol::Page::ScriptFontFamilies>> for_scripts) { LocalFrame* frame = inspected_frames_->Root(); auto* settings = frame->GetSettings(); - if (!settings) - return Response::ServerError("No settings"); + if (!settings) { + return protocol::Response::ServerError("No settings"); + } - if (!script_font_families_cbor_.Get().empty()) - return Response::ServerError("Font families can only be set once"); + if (!script_font_families_cbor_.Get().empty()) { + return protocol::Response::ServerError( + "Font families can only be set once"); + } if (!for_scripts.isJust()) { for_scripts = @@ -1764,10 +1776,10 @@ &serialized); script_font_families_cbor_.Set(serialized); settings->NotifyGenericFontFamilyChange(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::setFontSizes( +protocol::Response InspectorPageAgent::setFontSizes( std::unique_ptr<protocol::Page::FontSizes> font_sizes) { LocalFrame* frame = inspected_frames_->Root(); auto* settings = frame->GetSettings(); @@ -1782,7 +1794,7 @@ } } - return Response::Success(); + return protocol::Response::Success(); } void InspectorPageAgent::ApplyCompilationModeOverride( @@ -1855,45 +1867,47 @@ element ? Maybe<int>(DOMNodeIds::IdForNode(element)) : Maybe<int>()); } -Response InspectorPageAgent::produceCompilationCache( +protocol::Response InspectorPageAgent::produceCompilationCache( std::unique_ptr<protocol::Array<protocol::Page::CompilationCacheParams>> scripts) { if (!enabled_.Get()) - return Response::ServerError("Agent needs to be enabled first"); + return protocol::Response::ServerError("Agent needs to be enabled first"); for (const auto& script : *scripts) { requested_compilation_cache_.Set(script->getUrl(), script->getEager(false)); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::addCompilationCache(const String& url, - const protocol::Binary& data) { +protocol::Response InspectorPageAgent::addCompilationCache( + const String& url, + const protocol::Binary& data) { // TODO(caseq): this is temporary undocumented behavior, remove after m91. if (!data.size()) { requested_compilation_cache_.Set(url, true); } else { compilation_cache_.Set(url, data); } - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::clearCompilationCache() { +protocol::Response InspectorPageAgent::clearCompilationCache() { compilation_cache_.clear(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::waitForDebugger() { +protocol::Response InspectorPageAgent::waitForDebugger() { client_->WaitForDebugger(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::setInterceptFileChooserDialog(bool enabled) { +protocol::Response InspectorPageAgent::setInterceptFileChooserDialog( + bool enabled) { intercept_file_chooser_.Set(enabled); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorPageAgent::generateTestReport(const String& message, - Maybe<String> group) { +protocol::Response InspectorPageAgent::generateTestReport(const String& message, + Maybe<String> group) { LocalDOMWindow* window = inspected_frames_->Root()->DomWindow(); // Construct the test report. @@ -1904,7 +1918,7 @@ // Send the test report to any ReportingObservers. ReportingContext::From(window)->QueueReport(report); - return Response::Success(); + return protocol::Response::Success(); } void InspectorPageAgent::Trace(Visitor* visitor) const { @@ -1915,7 +1929,7 @@ InspectorBaseAgent::Trace(visitor); } -Response InspectorPageAgent::getOriginTrials( +protocol::Response InspectorPageAgent::getOriginTrials( const String& frame_id, std::unique_ptr<protocol::Array<protocol::Page::OriginTrial>>* originTrials) { @@ -1923,11 +1937,11 @@ IdentifiersFactory::FrameById(inspected_frames_, frame_id); if (!frame) - return Response::InvalidParams("Invalid frame id"); + return protocol::Response::InvalidParams("Invalid frame id"); *originTrials = CreateOriginTrials(frame->DomWindow()); - return Response::Success(); + return protocol::Response::Success(); } } // namespace blink
diff --git a/third_party/blink/renderer/core/inspector/inspector_performance_agent.cc b/third_party/blink/renderer/core/inspector/inspector_performance_agent.cc index 968251a..1beafa3 100644 --- a/third_party/blink/renderer/core/inspector/inspector_performance_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_performance_agent.cc
@@ -24,8 +24,6 @@ namespace TimeDomain = protocol::Performance::SetTimeDomain::TimeDomainEnum; -using protocol::Response; - namespace { constexpr bool isPlural(const char* str, int len) { return len > 1 && str[len - 2] == 's'; @@ -87,29 +85,29 @@ String time_domain = optional_time_domain.fromMaybe(TimeDomain::TimeTicks); if (enabled_.Get()) { if (!HasTimeDomain(time_domain)) { - return Response::ServerError( + return protocol::Response::ServerError( "Cannot change time domain while performance metrics collection is " "enabled."); } - return Response::Success(); + return protocol::Response::Success(); } - Response response = InnerSetTimeDomain(time_domain); + protocol::Response response = InnerSetTimeDomain(time_domain); if (!response.IsSuccess()) return response; enabled_.Set(true); InnerEnable(); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorPerformanceAgent::disable() { if (!enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Clear(); instrumenting_agents_->RemoveInspectorPerformanceAgent(this); Thread::Current()->RemoveTaskTimeObserver(this); - return Response::Success(); + return protocol::Response::Success(); } namespace { @@ -124,9 +122,10 @@ } // namespace // TODO(crbug.com/1056306): remove this redundant API. -Response InspectorPerformanceAgent::setTimeDomain(const String& time_domain) { +protocol::Response InspectorPerformanceAgent::setTimeDomain( + const String& time_domain) { if (enabled_.Get()) { - return Response::ServerError( + return protocol::Response::ServerError( "Cannot set time domain while performance metrics collection" " is enabled."); } @@ -154,35 +153,35 @@ : time_domain == TimeDomain::TimeTicks; } -Response InspectorPerformanceAgent::InnerSetTimeDomain( +protocol::Response InspectorPerformanceAgent::InnerSetTimeDomain( const String& time_domain) { DCHECK(!enabled_.Get()); if (time_domain == TimeDomain::TimeTicks) { use_thread_ticks_.Clear(); - return Response::Success(); + return protocol::Response::Success(); } if (time_domain == TimeDomain::ThreadTicks) { if (!base::ThreadTicks::IsSupported()) { - return Response::ServerError( + return protocol::Response::ServerError( "Thread time is not supported on this platform."); } base::ThreadTicks::WaitUntilInitialized(); use_thread_ticks_.Set(true); - return Response::Success(); + return protocol::Response::Success(); } - return Response::ServerError("Invalid time domain specification."); + return protocol::Response::ServerError("Invalid time domain specification."); } -Response InspectorPerformanceAgent::getMetrics( +protocol::Response InspectorPerformanceAgent::getMetrics( std::unique_ptr<protocol::Array<protocol::Performance::Metric>>* out_result) { if (!enabled_.Get()) { *out_result = std::make_unique<protocol::Array<protocol::Performance::Metric>>(); - return Response::Success(); + return protocol::Response::Success(); } auto result = @@ -272,7 +271,7 @@ } *out_result = std::move(result); - return Response::Success(); + return protocol::Response::Success(); } void InspectorPerformanceAgent::ConsoleTimeStamp(const String& title) {
diff --git a/third_party/blink/renderer/core/inspector/inspector_performance_timeline_agent.cc b/third_party/blink/renderer/core/inspector/inspector_performance_timeline_agent.cc index dc08f3e..d9f6f38 100644 --- a/third_party/blink/renderer/core/inspector/inspector_performance_timeline_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_performance_timeline_agent.cc
@@ -113,8 +113,6 @@ } // namespace -using protocol::Response; - InspectorPerformanceTimelineAgent::InspectorPerformanceTimelineAgent( InspectedFrames* inspected_frames) : inspected_frames_(inspected_frames), @@ -169,7 +167,8 @@ PerformanceEntry::ToEntryTypeEnum(type_atomic); if (type_enum == PerformanceEntry::EntryType::kInvalid || (type_enum & kSupportedTypes) != type_enum) { - return Response::InvalidParams("Unknown or unsupported entry type"); + return protocol::Response::InvalidParams( + "Unknown or unsupported entry type"); } // Gather buffered entries for types that haven't been enabled previously @@ -187,13 +186,13 @@ for (auto& event : buffered_events) GetFrontend()->timelineEventAdded(std::move(event)); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorPerformanceTimelineAgent::disable() { enabled_types_.Clear(); instrumenting_agents_->RemoveInspectorPerformanceTimelineAgent(this); - return Response::Success(); + return protocol::Response::Success(); } bool InspectorPerformanceTimelineAgent::IsEnabled() const {
diff --git a/third_party/blink/renderer/core/inspector/inspector_preload_agent.cc b/third_party/blink/renderer/core/inspector/inspector_preload_agent.cc index feb92d94..ca499264 100644 --- a/third_party/blink/renderer/core/inspector/inspector_preload_agent.cc +++ b/third_party/blink/renderer/core/inspector/inspector_preload_agent.cc
@@ -13,8 +13,6 @@ namespace blink { -using protocol::Response; - namespace { absl::optional<protocol::Preload::RuleSetErrorType> GetProtocolRuleSetErrorType( @@ -246,13 +244,13 @@ protocol::Response InspectorPreloadAgent::enable() { EnableInternal(); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorPreloadAgent::disable() { enabled_.Clear(); instrumenting_agents_->RemoveInspectorPreloadAgent(this); - return Response::Success(); + return protocol::Response::Success(); } void InspectorPreloadAgent::EnableInternal() {
diff --git a/third_party/blink/renderer/core/inspector/legacy_dom_snapshot_agent.cc b/third_party/blink/renderer/core/inspector/legacy_dom_snapshot_agent.cc index 1658414..ec3b9cf 100644 --- a/third_party/blink/renderer/core/inspector/legacy_dom_snapshot_agent.cc +++ b/third_party/blink/renderer/core/inspector/legacy_dom_snapshot_agent.cc
@@ -42,7 +42,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace { @@ -101,7 +100,7 @@ LegacyDOMSnapshotAgent::~LegacyDOMSnapshotAgent() = default; -Response LegacyDOMSnapshotAgent::GetSnapshot( +protocol::Response LegacyDOMSnapshotAgent::GetSnapshot( Document* document, std::unique_ptr<protocol::Array<String>> style_filter, protocol::Maybe<bool> include_event_listeners, @@ -147,7 +146,7 @@ computed_styles_map_.reset(); css_property_filter_.reset(); paint_order_map_ = nullptr; - return Response::Success(); + return protocol::Response::Success(); } int LegacyDOMSnapshotAgent::VisitNode(Node* node,
diff --git a/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc b/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc index a022377fd..9abc009 100644 --- a/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc +++ b/third_party/blink/renderer/core/intersection_observer/intersection_observer.cc
@@ -273,7 +273,8 @@ bool always_report_root_bounds, MarginTarget margin_target, bool use_overflow_clip_edge) - : ExecutionContextClient(delegate.GetExecutionContext()), + : ActiveScriptWrappable<IntersectionObserver>({}), + ExecutionContextClient(delegate.GetExecutionContext()), delegate_(&delegate), root_(root), thresholds_(thresholds),
diff --git a/third_party/blink/renderer/core/messaging/message_port.cc b/third_party/blink/renderer/core/messaging/message_port.cc index b38bbd1d..515143a8 100644 --- a/third_party/blink/renderer/core/messaging/message_port.cc +++ b/third_party/blink/renderer/core/messaging/message_port.cc
@@ -60,7 +60,8 @@ namespace blink { MessagePort::MessagePort(ExecutionContext& execution_context) - : ExecutionContextLifecycleObserver(execution_context.IsContextDestroyed() + : ActiveScriptWrappable<MessagePort>({}), + ExecutionContextLifecycleObserver(execution_context.IsContextDestroyed() ? nullptr : &execution_context), // Ports in a destroyed context start out in a closed state.
diff --git a/third_party/blink/renderer/core/mojo/mojo_watcher.cc b/third_party/blink/renderer/core/mojo/mojo_watcher.cc index 33ba0ae..e7913aa 100644 --- a/third_party/blink/renderer/core/mojo/mojo_watcher.cc +++ b/third_party/blink/renderer/core/mojo/mojo_watcher.cc
@@ -66,7 +66,8 @@ MojoWatcher::MojoWatcher(ExecutionContext* context, V8MojoWatchCallback* callback) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<MojoWatcher>({}), + ExecutionContextLifecycleObserver(context), task_runner_(context->GetTaskRunner(TaskType::kInternalDefault)), callback_(callback) {}
diff --git a/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc b/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc index ee43ee58..831898a 100644 --- a/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc +++ b/third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.cc
@@ -155,7 +155,8 @@ MojoInterfaceInterceptor::MojoInterfaceInterceptor(ExecutionContext* context, const String& interface_name, Scope::Enum scope) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<MojoInterfaceInterceptor>({}), + ExecutionContextLifecycleObserver(context), interface_name_(interface_name), scope_(scope) {}
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer.cc b/third_party/blink/renderer/core/resize_observer/resize_observer.cc index 19e52ef..6f7f976 100644 --- a/third_party/blink/renderer/core/resize_observer/resize_observer.cc +++ b/third_party/blink/renderer/core/resize_observer/resize_observer.cc
@@ -36,7 +36,8 @@ ResizeObserver::ResizeObserver(V8ResizeObserverCallback* callback, LocalDOMWindow* window) - : ExecutionContextClient(window), + : ActiveScriptWrappable<ResizeObserver>({}), + ExecutionContextClient(window), callback_(callback), skipped_observations_(false) { DCHECK(callback_); @@ -47,7 +48,8 @@ } ResizeObserver::ResizeObserver(Delegate* delegate, LocalDOMWindow* window) - : ExecutionContextClient(window), + : ActiveScriptWrappable<ResizeObserver>({}), + ExecutionContextClient(window), delegate_(delegate), skipped_observations_(false) { DCHECK(delegate_);
diff --git a/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc b/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc index c6ea035..b6678377 100644 --- a/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc +++ b/third_party/blink/renderer/core/streams/readable_stream_default_reader.cc
@@ -76,7 +76,8 @@ ScriptState* script_state, ReadableStream* stream, ExceptionState& exception_state) - : ExecutionContextClient(ExecutionContext::From(script_state)) { + : ActiveScriptWrappable<ReadableStreamDefaultReader>({}), + ExecutionContextClient(ExecutionContext::From(script_state)) { // https://streams.spec.whatwg.org/#default-reader-constructor // 1. Perform ? SetUpReadableStreamDefaultReader(this, stream). SetUpDefaultReader(script_state, this, stream, exception_state);
diff --git a/third_party/blink/renderer/core/svg/svg_image_element.cc b/third_party/blink/renderer/core/svg/svg_image_element.cc index f541d56..5ac13b33 100644 --- a/third_party/blink/renderer/core/svg/svg_image_element.cc +++ b/third_party/blink/renderer/core/svg/svg_image_element.cc
@@ -39,6 +39,7 @@ SVGImageElement::SVGImageElement(Document& document) : SVGGraphicsElement(svg_names::kImageTag, document), SVGURIReference(this), + ActiveScriptWrappable<SVGImageElement>({}), is_default_overridden_intrinsic_size_( GetExecutionContext() && !GetExecutionContext()->IsFeatureEnabled(
diff --git a/third_party/blink/renderer/core/timing/performance_observer.cc b/third_party/blink/renderer/core/timing/performance_observer.cc index af7967d..f426e1ed 100644 --- a/third_party/blink/renderer/core/timing/performance_observer.cc +++ b/third_party/blink/renderer/core/timing/performance_observer.cc
@@ -102,7 +102,8 @@ ExecutionContext* execution_context, Performance* performance, V8PerformanceObserverCallback* callback) - : ExecutionContextLifecycleStateObserver(execution_context), + : ActiveScriptWrappable<PerformanceObserver>({}), + ExecutionContextLifecycleStateObserver(execution_context), callback_(callback), performance_(performance), filter_options_(PerformanceEntry::kInvalid),
diff --git a/third_party/blink/renderer/core/view_transition/view_transition.cc b/third_party/blink/renderer/core/view_transition/view_transition.cc index 30950b13..87b2510 100644 --- a/third_party/blink/renderer/core/view_transition/view_transition.cc +++ b/third_party/blink/renderer/core/view_transition/view_transition.cc
@@ -210,7 +210,8 @@ ScriptState* script_state, V8ViewTransitionCallback* update_dom_callback, Delegate* delegate) - : ExecutionContextLifecycleObserver(document->GetExecutionContext()), + : ActiveScriptWrappable<ViewTransition>({}), + ExecutionContextLifecycleObserver(document->GetExecutionContext()), creation_type_(CreationType::kScript), document_(document), delegate_(delegate), @@ -236,7 +237,8 @@ ViewTransition::ViewTransition(Document* document, ViewTransitionStateCallback callback, Delegate* delegate) - : ExecutionContextLifecycleObserver(document->GetExecutionContext()), + : ActiveScriptWrappable<ViewTransition>({}), + ExecutionContextLifecycleObserver(document->GetExecutionContext()), creation_type_(CreationType::kForSnapshot), document_(document), delegate_(delegate), @@ -262,7 +264,8 @@ ViewTransition::ViewTransition(Document* document, ViewTransitionState transition_state, Delegate* delegate) - : ExecutionContextLifecycleObserver(document->GetExecutionContext()), + : ActiveScriptWrappable<ViewTransition>({}), + ExecutionContextLifecycleObserver(document->GetExecutionContext()), creation_type_(CreationType::kFromSnapshot), document_(document), delegate_(delegate),
diff --git a/third_party/blink/renderer/core/workers/dedicated_worker.cc b/third_party/blink/renderer/core/workers/dedicated_worker.cc index 922f037..c7a4b9f 100644 --- a/third_party/blink/renderer/core/workers/dedicated_worker.cc +++ b/third_party/blink/renderer/core/workers/dedicated_worker.cc
@@ -110,6 +110,7 @@ base::FunctionRef<DedicatedWorkerMessagingProxy*(DedicatedWorker*)> context_proxy_factory) : AbstractWorker(context), + ActiveScriptWrappable<DedicatedWorker>({}), script_request_url_(script_request_url), options_(options), context_proxy_(context_proxy_factory(this)),
diff --git a/third_party/blink/renderer/core/workers/shared_worker.cc b/third_party/blink/renderer/core/workers/shared_worker.cc index 1e19049..1e35209 100644 --- a/third_party/blink/renderer/core/workers/shared_worker.cc +++ b/third_party/blink/renderer/core/workers/shared_worker.cc
@@ -68,6 +68,7 @@ SharedWorker::SharedWorker(ExecutionContext* context) : AbstractWorker(context), + ActiveScriptWrappable<SharedWorker>({}), is_being_connected_(false), feature_handle_for_scheduler_(context->GetScheduler()->RegisterFeature( SchedulingPolicy::Feature::kSharedWorker,
diff --git a/third_party/blink/renderer/core/workers/worker_global_scope.cc b/third_party/blink/renderer/core/workers/worker_global_scope.cc index 4e827ae..df5729b2 100644 --- a/third_party/blink/renderer/core/workers/worker_global_scope.cc +++ b/third_party/blink/renderer/core/workers/worker_global_scope.cc
@@ -612,6 +612,7 @@ std::move(creation_params->web_worker_fetch_context), thread->GetWorkerReportingProxy(), creation_params->script_url.ProtocolIsData()), + ActiveScriptWrappable<WorkerGlobalScope>({}), script_type_(creation_params->script_type), user_agent_(creation_params->user_agent), ua_metadata_(creation_params->ua_metadata),
diff --git a/third_party/blink/renderer/core/workers/worklet_global_scope.cc b/third_party/blink/renderer/core/workers/worklet_global_scope.cc index f11fb70..9dfd614 100644 --- a/third_party/blink/renderer/core/workers/worklet_global_scope.cc +++ b/third_party/blink/renderer/core/workers/worklet_global_scope.cc
@@ -94,6 +94,7 @@ std::move(creation_params->web_worker_fetch_context), reporting_proxy, /*is_worker_loaded_from_data_url=*/false), + ActiveScriptWrappable<WorkletGlobalScope>({}), url_(creation_params->script_url), user_agent_(creation_params->user_agent), document_security_origin_(creation_params->starter_origin),
diff --git a/third_party/blink/renderer/core/xmlhttprequest/xml_http_request.cc b/third_party/blink/renderer/core/xmlhttprequest/xml_http_request.cc index c648e963..16f7796 100644 --- a/third_party/blink/renderer/core/xmlhttprequest/xml_http_request.cc +++ b/third_party/blink/renderer/core/xmlhttprequest/xml_http_request.cc
@@ -295,7 +295,8 @@ XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, v8::Isolate* isolate, scoped_refptr<const DOMWrapperWorld> world) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<XMLHttpRequest>({}), + ExecutionContextLifecycleObserver(context), progress_event_throttle_( MakeGarbageCollected<XMLHttpRequestProgressEventThrottle>(this)), isolate_(isolate),
diff --git a/third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.cc b/third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.cc index c7fd319..2b11c71a 100644 --- a/third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.cc +++ b/third_party/blink/renderer/modules/accessibility/inspector_accessibility_agent.cc
@@ -30,7 +30,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; using protocol::Accessibility::AXNode; using protocol::Accessibility::AXNodeId; using protocol::Accessibility::AXProperty; @@ -524,14 +523,14 @@ dom_agent_(dom_agent), enabled_(&agent_state_, /*default_value=*/false) {} -Response InspectorAccessibilityAgent::getPartialAXTree( +protocol::Response InspectorAccessibilityAgent::getPartialAXTree( Maybe<int> dom_node_id, Maybe<int> backend_node_id, Maybe<String> object_id, Maybe<bool> fetch_relatives, std::unique_ptr<protocol::Array<AXNode>>* nodes) { Node* dom_node = nullptr; - Response response = + protocol::Response response = dom_agent_->AssertNode(dom_node_id, backend_node_id, object_id, dom_node); if (!response.IsSuccess()) return response; @@ -542,7 +541,7 @@ document.Lifecycle()); LocalFrame* local_frame = document.GetFrame(); if (!local_frame) - return Response::ServerError("Frame is detached."); + return protocol::Response::ServerError("Frame is detached."); auto& cache = AttachToAXObjectCache(&document); @@ -557,7 +556,7 @@ } if (!fetch_relatives.fromMaybe(true)) - return Response::Success(); + return protocol::Response::Success(); if (inspected_ax_object && !inspected_ax_object->AccessibilityIsIgnored()) AddChildren(*inspected_ax_object, true, *nodes, cache); @@ -579,10 +578,10 @@ } } if (!parent_ax_object) - return Response::Success(); + return protocol::Response::Success(); AddAncestors(*parent_ax_object, inspected_ax_object, *nodes, cache); - return Response::Success(); + return protocol::Response::Success(); } void InspectorAccessibilityAgent::AddAncestors( @@ -769,25 +768,25 @@ return inspected_frames_->Root(); } -Response InspectorAccessibilityAgent::getFullAXTree( +protocol::Response InspectorAccessibilityAgent::getFullAXTree( protocol::Maybe<int> depth, Maybe<String> frame_id, std::unique_ptr<protocol::Array<AXNode>>* nodes) { LocalFrame* frame = FrameFromIdOrRoot(frame_id); if (!frame) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "Frame with the given frameId is not found."); } Document* document = frame->GetDocument(); if (!document) - return Response::InternalError(); + return protocol::Response::InternalError(); if (document->View()->NeedsLayout() || document->NeedsLayoutTreeUpdate()) document->UpdateStyleAndLayout(DocumentUpdateReason::kInspector); *nodes = WalkAXNodesToDepth(document, depth.fromMaybe(-1)); - return Response::Success(); + return protocol::Response::Success(); } std::unique_ptr<protocol::Array<AXNode>> @@ -822,20 +821,22 @@ return nodes; } -Response InspectorAccessibilityAgent::getRootAXNode( +protocol::Response InspectorAccessibilityAgent::getRootAXNode( Maybe<String> frame_id, std::unique_ptr<AXNode>* node) { LocalFrame* frame = FrameFromIdOrRoot(frame_id); if (!frame) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "Frame with the given frameId is not found."); } - if (!enabled_.Get()) - return Response::ServerError("Accessibility has not been enabled."); + if (!enabled_.Get()) { + return protocol::Response::ServerError( + "Accessibility has not been enabled."); + } Document* document = frame->GetDocument(); if (!document) - return Response::InternalError(); + return protocol::Response::InternalError(); if (document->View()->NeedsLayout() || document->NeedsLayoutTreeUpdate()) document->UpdateStyleAndLayout(DocumentUpdateReason::kInspector); @@ -845,7 +846,7 @@ *node = BuildProtocolAXNodeForAXObject(root); nodes_requested_.insert(root.AXObjectID()); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorAccessibilityAgent::getAXNodeAndAncestors( @@ -854,11 +855,13 @@ Maybe<String> object_id, std::unique_ptr<protocol::Array<protocol::Accessibility::AXNode>>* out_nodes) { - if (!enabled_.Get()) - return Response::ServerError("Accessibility has not been enabled."); + if (!enabled_.Get()) { + return protocol::Response::ServerError( + "Accessibility has not been enabled."); + } Node* dom_node = nullptr; - Response response = + protocol::Response response = dom_agent_->AssertNode(dom_node_id, backend_node_id, object_id, dom_node); if (!response.IsSuccess()) return response; @@ -869,7 +872,7 @@ document.Lifecycle()); LocalFrame* local_frame = document.GetFrame(); if (!local_frame) - return Response::ServerError("Frame is detached."); + return protocol::Response::ServerError("Frame is detached."); auto& cache = AttachToAXObjectCache(&document); @@ -882,7 +885,7 @@ (*out_nodes) ->emplace_back(BuildProtocolAXNodeForDOMNodeWithNoAXNode( IdentifiersFactory::IntIdForNode(dom_node))); - return Response::Success(); + return protocol::Response::Success(); } do { @@ -893,7 +896,7 @@ ax_object = ax_object->ParentObjectIncludedInTree(); } while (ax_object); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorAccessibilityAgent::getChildAXNodes( @@ -901,18 +904,20 @@ Maybe<String> frame_id, std::unique_ptr<protocol::Array<protocol::Accessibility::AXNode>>* out_nodes) { - if (!enabled_.Get()) - return Response::ServerError("Accessibility has not been enabled."); + if (!enabled_.Get()) { + return protocol::Response::ServerError( + "Accessibility has not been enabled."); + } LocalFrame* frame = FrameFromIdOrRoot(frame_id); if (!frame) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "Frame with the given frameId is not found."); } Document* document = frame->GetDocument(); if (!document) - return Response::InternalError(); + return protocol::Response::InternalError(); if (document->View()->NeedsLayout() || document->NeedsLayoutTreeUpdate()) document->UpdateStyleAndLayout(DocumentUpdateReason::kInspector); @@ -923,7 +928,7 @@ AXObject* ax_object = cache.ObjectFromAXID(ax_id); if (!ax_object || ax_object->IsDetached()) - return Response::InvalidParams("Invalid ID"); + return protocol::Response::InvalidParams("Invalid ID"); *out_nodes = std::make_unique<protocol::Array<protocol::Accessibility::AXNode>>(); @@ -933,7 +938,7 @@ for (const auto& child : **out_nodes) nodes_requested_.insert(child->getNodeId().ToInt()); - return Response::Success(); + return protocol::Response::Success(); } void InspectorAccessibilityAgent::FillCoreProperties( @@ -999,8 +1004,8 @@ Maybe<String> role, std::unique_ptr<QueryAXTreeCallback> callback) { Node* root_dom_node = nullptr; - Response response = dom_agent_->AssertNode(dom_node_id, backend_node_id, - object_id, root_dom_node); + protocol::Response response = dom_agent_->AssertNode( + dom_node_id, backend_node_id, object_id, root_dom_node); if (!response.IsSuccess()) { callback->sendFailure(response); return; @@ -1014,7 +1019,7 @@ } if (!root_dom_node) { callback->sendFailure( - Response::InvalidParams("Root DOM node could not be found")); + protocol::Response::InvalidParams("Root DOM node could not be found")); return; } @@ -1041,7 +1046,7 @@ void InspectorAccessibilityAgent::CompleteQuery(AXQuery& query) { Node* root_dom_node = nullptr; - Response response = dom_agent_->AssertNode( + protocol::Response response = dom_agent_->AssertNode( query.dom_node_id, query.backend_node_id, query.object_id, root_dom_node); if (!response.IsSuccess()) { query.callback->sendFailure(response); @@ -1055,7 +1060,7 @@ root_dom_node = root_dom_node->OwnerShadowHost(); if (!root_dom_node) { query.callback->sendFailure( - Response::InvalidParams("Root DOM node could not be found")); + protocol::Response::InvalidParams("Root DOM node could not be found")); return; } Document& document = root_dom_node->GetDocument(); @@ -1261,12 +1266,12 @@ protocol::Response InspectorAccessibilityAgent::enable() { if (!enabled_.Get()) EnableAndReset(); - return Response::Success(); + return protocol::Response::Success(); } protocol::Response InspectorAccessibilityAgent::disable() { if (!enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Set(false); document_to_context_map_.clear(); nodes_requested_.clear(); @@ -1281,7 +1286,7 @@ auto& cache = To<AXObjectCacheImpl>(context->GetAXObjectCache()); cache.RemoveInspectorAgent(this); } - return Response::Success(); + return protocol::Response::Success(); } void InspectorAccessibilityAgent::Restore() {
diff --git a/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc b/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc index ffdc8273..a8a6081 100644 --- a/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc +++ b/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc
@@ -24,6 +24,7 @@ mojo::PendingReceiver<mojom::blink::AppBannerEvent> event_receiver, const Vector<String>& platforms) : Event(name, Bubbles::kNo, Cancelable::kYes), + ActiveScriptWrappable<BeforeInstallPromptEvent>({}), ExecutionContextClient(&context), banner_service_remote_(&context), receiver_(this, &context), @@ -44,6 +45,7 @@ const AtomicString& name, const BeforeInstallPromptEventInit* init) : Event(name, init), + ActiveScriptWrappable<BeforeInstallPromptEvent>({}), ExecutionContextClient(execution_context), banner_service_remote_(execution_context), receiver_(this, execution_context) {
diff --git a/third_party/blink/renderer/modules/background_fetch/background_fetch_registration.cc b/third_party/blink/renderer/modules/background_fetch/background_fetch_registration.cc index e3642ee..a77cf85 100644 --- a/third_party/blink/renderer/modules/background_fetch/background_fetch_registration.cc +++ b/third_party/blink/renderer/modules/background_fetch/background_fetch_registration.cc
@@ -35,7 +35,8 @@ BackgroundFetchRegistration::BackgroundFetchRegistration( ServiceWorkerRegistration* service_worker_registration, mojom::blink::BackgroundFetchRegistrationPtr registration) - : developer_id_(registration->registration_data->developer_id), + : ActiveScriptWrappable<BackgroundFetchRegistration>({}), + developer_id_(registration->registration_data->developer_id), upload_total_(registration->registration_data->upload_total), uploaded_(registration->registration_data->uploaded), download_total_(registration->registration_data->download_total),
diff --git a/third_party/blink/renderer/modules/battery/battery_manager.cc b/third_party/blink/renderer/modules/battery/battery_manager.cc index 848f452..e8512cf 100644 --- a/third_party/blink/renderer/modules/battery/battery_manager.cc +++ b/third_party/blink/renderer/modules/battery/battery_manager.cc
@@ -51,7 +51,8 @@ BatteryManager::~BatteryManager() = default; BatteryManager::BatteryManager(Navigator& navigator) - : Supplement<Navigator>(navigator), + : ActiveScriptWrappable<BatteryManager>({}), + Supplement<Navigator>(navigator), ExecutionContextLifecycleStateObserver(navigator.DomWindow()), PlatformEventController(*navigator.DomWindow()), battery_dispatcher_(
diff --git a/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc b/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc index 87d4a01..c706778 100644 --- a/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc +++ b/third_party/blink/renderer/modules/bluetooth/bluetooth_device.cc
@@ -35,6 +35,7 @@ mojom::blink::WebBluetoothDevicePtr device, Bluetooth* bluetooth) : ExecutionContextClient(context), + ActiveScriptWrappable<BluetoothDevice>({}), attribute_instance_map_( MakeGarbageCollected<BluetoothAttributeInstanceMap>(this)), device_(std::move(device)),
diff --git a/third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_characteristic.cc b/third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_characteristic.cc index 209edb3..a9f8642 100644 --- a/third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_characteristic.cc +++ b/third_party/blink/renderer/modules/bluetooth/bluetooth_remote_gatt_characteristic.cc
@@ -35,7 +35,8 @@ mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr characteristic, BluetoothRemoteGATTService* service, BluetoothDevice* device) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<BluetoothRemoteGATTCharacteristic>({}), + ExecutionContextLifecycleObserver(context), characteristic_(std::move(characteristic)), service_(service), device_(device),
diff --git a/third_party/blink/renderer/modules/breakout_box/frame_queue_underlying_source.cc b/third_party/blink/renderer/modules/breakout_box/frame_queue_underlying_source.cc index 9611a04..f5f25e3 100644 --- a/third_party/blink/renderer/modules/breakout_box/frame_queue_underlying_source.cc +++ b/third_party/blink/renderer/modules/breakout_box/frame_queue_underlying_source.cc
@@ -41,6 +41,7 @@ std::string device_id, wtf_size_t frame_pool_size) : UnderlyingSourceBase(script_state), + ActiveScriptWrappable<FrameQueueUnderlyingSource<NativeFrameType>>({}), realm_task_runner_(ExecutionContext::From(script_state) ->GetTaskRunner(TaskType::kInternalMediaRealTime)), frame_queue_handle_( @@ -64,6 +65,7 @@ ScriptState* script_state, FrameQueueUnderlyingSource<NativeFrameType>* other_source) : UnderlyingSourceBase(script_state), + ActiveScriptWrappable<FrameQueueUnderlyingSource<NativeFrameType>>({}), realm_task_runner_(ExecutionContext::From(script_state) ->GetTaskRunner(TaskType::kInternalMediaRealTime)), frame_queue_handle_(other_source->frame_queue_handle_.Queue()),
diff --git a/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc b/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc index 1b56281..09ccb79 100644 --- a/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc +++ b/third_party/blink/renderer/modules/broadcastchannel/broadcast_channel.cc
@@ -212,7 +212,8 @@ mojo::PendingAssociatedReceiver<mojom::blink::BroadcastChannelClient> receiver, mojo::PendingAssociatedRemote<mojom::blink::BroadcastChannelClient> remote) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<BroadcastChannel>({}), + ExecutionContextLifecycleObserver(execution_context), name_(name), feature_handle_for_scheduler_( execution_context->GetScheduler()->RegisterFeature(
diff --git a/third_party/blink/renderer/modules/buckets/storage_bucket.cc b/third_party/blink/renderer/modules/buckets/storage_bucket.cc index d712f8e..684c47ef 100644 --- a/third_party/blink/renderer/modules/buckets/storage_bucket.cc +++ b/third_party/blink/renderer/modules/buckets/storage_bucket.cc
@@ -6,6 +6,7 @@ #include "base/time/time.h" #include "third_party/blink/public/platform/task_type.h" +#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_storage_estimate.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_storage_usage_details.h"
diff --git a/third_party/blink/renderer/modules/cache_storage/cache_storage.cc b/third_party/blink/renderer/modules/cache_storage/cache_storage.cc index c3a1852..7f88eb3 100644 --- a/third_party/blink/renderer/modules/cache_storage/cache_storage.cc +++ b/third_party/blink/renderer/modules/cache_storage/cache_storage.cc
@@ -535,7 +535,8 @@ ExecutionContext* context, GlobalFetch::ScopedFetcher* fetcher, mojo::PendingRemote<mojom::blink::CacheStorage> pending_remote) - : ExecutionContextClient(context), + : ActiveScriptWrappable<CacheStorage>({}), + ExecutionContextClient(context), scoped_fetcher_(fetcher), blob_client_list_(MakeGarbageCollected<CacheStorageBlobClientList>()), cache_storage_remote_(context) {
diff --git a/third_party/blink/renderer/modules/clipboard/clipboard_promise.cc b/third_party/blink/renderer/modules/clipboard/clipboard_promise.cc index 92b72c5..0a89ccac 100644 --- a/third_party/blink/renderer/modules/clipboard/clipboard_promise.cc +++ b/third_party/blink/renderer/modules/clipboard/clipboard_promise.cc
@@ -44,7 +44,6 @@ namespace blink { -using mojom::blink::PermissionStatus; using mojom::blink::PermissionService; // This class deals with all the Blob promises and executes the write @@ -338,11 +337,12 @@ WrapPersistent(this))); } -void ClipboardPromise::HandleReadWithPermission(PermissionStatus status) { +void ClipboardPromise::HandleReadWithPermission( + mojom::blink::PermissionStatus status) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!GetExecutionContext()) return; - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { script_promise_resolver_->Reject(MakeGarbageCollected<DOMException>( DOMExceptionCode::kNotAllowedError, "Read permission denied.")); return; @@ -425,11 +425,12 @@ ReadNextRepresentation(); } -void ClipboardPromise::HandleReadTextWithPermission(PermissionStatus status) { +void ClipboardPromise::HandleReadTextWithPermission( + mojom::blink::PermissionStatus status) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!GetExecutionContext()) return; - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { script_promise_resolver_->Reject(MakeGarbageCollected<DOMException>( DOMExceptionCode::kNotAllowedError, "Read permission denied.")); return; @@ -473,11 +474,12 @@ WriteNextRepresentation(); } -void ClipboardPromise::HandleWriteWithPermission(PermissionStatus status) { +void ClipboardPromise::HandleWriteWithPermission( + mojom::blink::PermissionStatus status) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!GetExecutionContext()) return; - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { script_promise_resolver_->Reject(MakeGarbageCollected<DOMException>( DOMExceptionCode::kNotAllowedError, "Write permission denied.")); return; @@ -506,11 +508,12 @@ script_state_, ScriptPromise::All(script_state_, promise_list), this); } -void ClipboardPromise::HandleWriteTextWithPermission(PermissionStatus status) { +void ClipboardPromise::HandleWriteTextWithPermission( + mojom::blink::PermissionStatus status) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!GetExecutionContext()) return; - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { script_promise_resolver_->Reject(MakeGarbageCollected<DOMException>( DOMExceptionCode::kNotAllowedError, "Write permission denied.")); return;
diff --git a/third_party/blink/renderer/modules/device_orientation/device_orientation_inspector_agent.cc b/third_party/blink/renderer/modules/device_orientation/device_orientation_inspector_agent.cc index 494552d0..0de0a77 100644 --- a/third_party/blink/renderer/modules/device_orientation/device_orientation_inspector_agent.cc +++ b/third_party/blink/renderer/modules/device_orientation/device_orientation_inspector_agent.cc
@@ -12,8 +12,6 @@ namespace blink { -using protocol::Response; - DeviceOrientationInspectorAgent::~DeviceOrientationInspectorAgent() = default; DeviceOrientationInspectorAgent::DeviceOrientationInspectorAgent( @@ -37,10 +35,10 @@ *inspected_frames_->Root()->DomWindow()); } -Response DeviceOrientationInspectorAgent::setDeviceOrientationOverride( - double alpha, - double beta, - double gamma) { +protocol::Response +DeviceOrientationInspectorAgent::setDeviceOrientationOverride(double alpha, + double beta, + double gamma) { enabled_.Set(true); alpha_.Set(alpha); beta_.Set(beta); @@ -48,19 +46,20 @@ Controller().SetOverride( DeviceOrientationData::Create(alpha, beta, gamma, false)); sensor_agent_->SetOrientationSensorOverride(alpha, beta, gamma); - return Response::Success(); + return protocol::Response::Success(); } -Response DeviceOrientationInspectorAgent::clearDeviceOrientationOverride() { +protocol::Response +DeviceOrientationInspectorAgent::clearDeviceOrientationOverride() { return disable(); } -Response DeviceOrientationInspectorAgent::disable() { +protocol::Response DeviceOrientationInspectorAgent::disable() { agent_state_.ClearAllFields(); if (!inspected_frames_->Root()->DomWindow()->IsContextDestroyed()) Controller().ClearOverride(); sensor_agent_->Disable(); - return Response::Success(); + return protocol::Response::Success(); } void DeviceOrientationInspectorAgent::Restore() {
diff --git a/third_party/blink/renderer/modules/direct_sockets/tcp_socket.cc b/third_party/blink/renderer/modules/direct_sockets/tcp_socket.cc index 45a2db10..6ce5de6 100644 --- a/third_party/blink/renderer/modules/direct_sockets/tcp_socket.cc +++ b/third_party/blink/renderer/modules/direct_sockets/tcp_socket.cc
@@ -134,6 +134,7 @@ TCPSocket::TCPSocket(ScriptState* script_state) : Socket(script_state), + ActiveScriptWrappable<TCPSocket>({}), tcp_socket_{GetExecutionContext()}, socket_observer_{this, GetExecutionContext()} {}
diff --git a/third_party/blink/renderer/modules/direct_sockets/udp_socket.cc b/third_party/blink/renderer/modules/direct_sockets/udp_socket.cc index 95387a86..cf785f4a 100644 --- a/third_party/blink/renderer/modules/direct_sockets/udp_socket.cc +++ b/third_party/blink/renderer/modules/direct_sockets/udp_socket.cc
@@ -194,6 +194,7 @@ UDPSocket::UDPSocket(ScriptState* script_state) : Socket(script_state), + ActiveScriptWrappable<UDPSocket>({}), udp_socket_( MakeGarbageCollected<UDPSocketMojoRemote>(GetExecutionContext())) {}
diff --git a/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc b/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc index f549fbb..b349dc2 100644 --- a/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc +++ b/third_party/blink/renderer/modules/encryptedmedia/media_key_session.cc
@@ -38,6 +38,7 @@ #include "third_party/blink/public/platform/web_encrypted_media_key_information.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/platform/web_url.h" +#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.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/core/dom/dom_exception.h" @@ -403,7 +404,8 @@ MediaKeys* media_keys, WebEncryptedMediaSessionType session_type, const MediaKeysConfig& config) - : ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ActiveScriptWrappable<MediaKeySession>({}), + ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), async_event_queue_( MakeGarbageCollected<EventQueue>(GetExecutionContext(), TaskType::kMediaElementEvent)),
diff --git a/third_party/blink/renderer/modules/encryptedmedia/media_keys.cc b/third_party/blink/renderer/modules/encryptedmedia/media_keys.cc index fb826b4..cfb4a50 100644 --- a/third_party/blink/renderer/modules/encryptedmedia/media_keys.cc +++ b/third_party/blink/renderer/modules/encryptedmedia/media_keys.cc
@@ -274,7 +274,8 @@ const WebVector<WebEncryptedMediaSessionType>& supported_session_types, std::unique_ptr<WebContentDecryptionModule> cdm, const MediaKeysConfig& config) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<MediaKeys>({}), + ExecutionContextLifecycleObserver(context), supported_session_types_(supported_session_types), cdm_(std::move(cdm)), config_(config),
diff --git a/third_party/blink/renderer/modules/eventsource/event_source.cc b/third_party/blink/renderer/modules/eventsource/event_source.cc index 02f42fe..546aeed 100644 --- a/third_party/blink/renderer/modules/eventsource/event_source.cc +++ b/third_party/blink/renderer/modules/eventsource/event_source.cc
@@ -92,7 +92,8 @@ inline EventSource::EventSource(ExecutionContext* context, const KURL& url, const EventSourceInit* event_source_init) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<EventSource>({}), + ExecutionContextLifecycleObserver(context), url_(url), current_url_(url), with_credentials_(event_source_init->withCredentials()),
diff --git a/third_party/blink/renderer/modules/file_system_access/file_system_directory_iterator.cc b/third_party/blink/renderer/modules/file_system_access/file_system_directory_iterator.cc index 0a694d8..c2e9ea3 100644 --- a/third_party/blink/renderer/modules/file_system_access/file_system_directory_iterator.cc +++ b/third_party/blink/renderer/modules/file_system_access/file_system_directory_iterator.cc
@@ -17,7 +17,8 @@ FileSystemDirectoryHandle* directory, Mode mode, ExecutionContext* execution_context) - : ExecutionContextClient(execution_context), + : ActiveScriptWrappable<FileSystemDirectoryIterator>({}), + ExecutionContextClient(execution_context), mode_(mode), directory_(directory), receiver_(this, execution_context) {
diff --git a/third_party/blink/renderer/modules/filesystem/dom_file_system.cc b/third_party/blink/renderer/modules/filesystem/dom_file_system.cc index bfa366a..5f301136 100644 --- a/third_party/blink/renderer/modules/filesystem/dom_file_system.cc +++ b/third_party/blink/renderer/modules/filesystem/dom_file_system.cc
@@ -96,6 +96,7 @@ mojom::blink::FileSystemType type, const KURL& root_url) : DOMFileSystemBase(context, name, type, root_url), + ActiveScriptWrappable<DOMFileSystem>({}), ExecutionContextClient(context), number_of_pending_callbacks_(0), root_entry_(
diff --git a/third_party/blink/renderer/modules/filesystem/file_writer.cc b/third_party/blink/renderer/modules/filesystem/file_writer.cc index 88936d5..4eb3b7ef 100644 --- a/third_party/blink/renderer/modules/filesystem/file_writer.cc +++ b/third_party/blink/renderer/modules/filesystem/file_writer.cc
@@ -48,7 +48,8 @@ std::numeric_limits<uint64_t>::max(); FileWriter::FileWriter(ExecutionContext* context) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<FileWriter>({}), + ExecutionContextLifecycleObserver(context), ready_state_(kInit), operation_in_progress_(kOperationNone), queued_operation_(kOperationNone),
diff --git a/third_party/blink/renderer/modules/geolocation/geolocation.cc b/third_party/blink/renderer/modules/geolocation/geolocation.cc index 962df1c..c9d7e9ae 100644 --- a/third_party/blink/renderer/modules/geolocation/geolocation.cc +++ b/third_party/blink/renderer/modules/geolocation/geolocation.cc
@@ -124,7 +124,8 @@ } Geolocation::Geolocation(Navigator& navigator) - : Supplement<Navigator>(navigator), + : ActiveScriptWrappable<Geolocation>({}), + Supplement<Navigator>(navigator), ExecutionContextLifecycleObserver(navigator.DomWindow()), PageVisibilityObserver(navigator.DomWindow()->GetFrame()->GetPage()), one_shots_(MakeGarbageCollected<GeoNotifierSet>()),
diff --git a/third_party/blink/renderer/modules/hid/hid_device.cc b/third_party/blink/renderer/modules/hid/hid_device.cc index 544b39d..dc698f6 100644 --- a/third_party/blink/renderer/modules/hid/hid_device.cc +++ b/third_party/blink/renderer/modules/hid/hid_device.cc
@@ -200,6 +200,7 @@ device::mojom::blink::HidDeviceInfoPtr info, ExecutionContext* context) : ExecutionContextLifecycleObserver(context), + ActiveScriptWrappable<HIDDevice>({}), parent_(parent), connection_(context), receiver_(this, context) {
diff --git a/third_party/blink/renderer/modules/idle/idle_detector.cc b/third_party/blink/renderer/modules/idle/idle_detector.cc index dac3ecb..0cfe740 100644 --- a/third_party/blink/renderer/modules/idle/idle_detector.cc +++ b/third_party/blink/renderer/modules/idle/idle_detector.cc
@@ -72,7 +72,8 @@ } IdleDetector::IdleDetector(ExecutionContext* context) - : ExecutionContextClient(context), + : ActiveScriptWrappable<IdleDetector>({}), + ExecutionContextClient(context), task_runner_(context->GetTaskRunner(TaskType::kMiscPlatformAPI)), timer_(task_runner_, this, &IdleDetector::DispatchUserIdleEvent), receiver_(this, context) {}
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_database.cc b/third_party/blink/renderer/modules/indexeddb/idb_database.cc index 1a34c86..18b79fbc 100644 --- a/third_party/blink/renderer/modules/indexeddb/idb_database.cc +++ b/third_party/blink/renderer/modules/indexeddb/idb_database.cc
@@ -101,7 +101,8 @@ mojo::PendingAssociatedReceiver<mojom::blink::IDBDatabaseCallbacks> callbacks_receiver, mojo::PendingRemote<mojom::blink::ObservedFeature> connection_lifetime) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<IDBDatabase>({}), + ExecutionContextLifecycleObserver(context), backend_(std::move(backend)), connection_lifetime_(std::move(connection_lifetime)), event_queue_(
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_request.cc b/third_party/blink/renderer/modules/indexeddb/idb_request.cc index 9582116..9054edf 100644 --- a/third_party/blink/renderer/modules/indexeddb/idb_request.cc +++ b/third_party/blink/renderer/modules/indexeddb/idb_request.cc
@@ -138,15 +138,15 @@ const Source* source, IDBTransaction* transaction, AsyncTraceState metrics) - : ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ActiveScriptWrappable<IDBRequest>({}), + ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), transaction_(transaction), isolate_(script_state->GetIsolate()), metrics_(std::move(metrics)), source_(source), event_queue_( MakeGarbageCollected<EventQueue>(ExecutionContext::From(script_state), - TaskType::kDatabaseAccess)) { -} + TaskType::kDatabaseAccess)) {} IDBRequest::~IDBRequest() { if (!GetExecutionContext())
diff --git a/third_party/blink/renderer/modules/indexeddb/idb_transaction.cc b/third_party/blink/renderer/modules/indexeddb/idb_transaction.cc index 71337770..bb6fa63 100644 --- a/third_party/blink/renderer/modules/indexeddb/idb_transaction.cc +++ b/third_party/blink/renderer/modules/indexeddb/idb_transaction.cc
@@ -30,6 +30,7 @@ #include "base/feature_list.h" #include "third_party/blink/public/common/features.h" +#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h" #include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/events/event_queue.h" #include "third_party/blink/renderer/core/execution_context/agent.h" @@ -86,7 +87,8 @@ mojom::IDBTransactionMode mode, mojom::IDBTransactionDurability durability, IDBDatabase* db) - : ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ActiveScriptWrappable<IDBTransaction>({}), + ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), transaction_backend_(std::move(transaction_backend)), id_(id), database_(db), @@ -129,7 +131,8 @@ IDBDatabase* db, IDBOpenDBRequest* open_db_request, const IDBDatabaseMetadata& old_metadata) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<IDBTransaction>({}), + ExecutionContextLifecycleObserver(execution_context), transaction_backend_(std::move(transaction_backend)), id_(id), database_(db),
diff --git a/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc b/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc index 67c3dd3..a7602cb 100644 --- a/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc +++ b/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc
@@ -70,6 +70,7 @@ #include "third_party/blink/renderer/platform/wtf/vector.h" using blink::protocol::Array; +using blink::protocol::Maybe; using blink::protocol::IndexedDB::DatabaseWithObjectStores; using blink::protocol::IndexedDB::DataEntry; using blink::protocol::IndexedDB::Key; @@ -77,8 +78,6 @@ using blink::protocol::IndexedDB::KeyRange; using blink::protocol::IndexedDB::ObjectStore; using blink::protocol::IndexedDB::ObjectStoreIndex; -using blink::protocol::Maybe; -using blink::protocol::Response; typedef blink::protocol::IndexedDB::Backend::RequestDatabaseNamesCallback RequestDatabaseNamesCallback; @@ -101,15 +100,20 @@ const char kIndexedDBObjectGroup[] = "indexeddb"; const char kNoDocumentError[] = "No document for given frame found"; -Response AssertIDBFactory(LocalDOMWindow* dom_window, IDBFactory*& result) { - if (!dom_window) - return Response::ServerError("No IndexedDB factory for given frame found"); +protocol::Response AssertIDBFactory(LocalDOMWindow* dom_window, + IDBFactory*& result) { + if (!dom_window) { + return protocol::Response::ServerError( + "No IndexedDB factory for given frame found"); + } IDBFactory* idb_factory = GlobalIndexedDB::indexedDB(*dom_window); - if (!idb_factory) - return Response::ServerError("No IndexedDB factory for given frame found"); + if (!idb_factory) { + return protocol::Response::ServerError( + "No IndexedDB factory for given frame found"); + } result = idb_factory; - return Response::Success(); + return protocol::Response::Success(); } class GetDatabaseNamesCallback final : public mojom::blink::IDBCallbacks { @@ -121,7 +125,7 @@ void Error(mojom::blink::IDBException code, const String& message) override { request_callback_->sendFailure( - Response::ServerError("Could not obtain database names.")); + protocol::Response::ServerError("Could not obtain database names.")); } void SuccessNamesAndVersionsList( @@ -168,7 +172,7 @@ void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { request_callback_->sendFailure( - Response::ServerError("Failed to delete database.")); + protocol::Response::ServerError("Failed to delete database.")); return; } request_callback_->sendSuccess(); @@ -193,11 +197,12 @@ virtual RequestCallback* GetRequestCallback() = 0; void Start(LocalFrame* frame, const String& database_name) { if (!frame) { - SendFailure(Response::ServerError(kNoDocumentError)); + SendFailure(protocol::Response::ServerError(kNoDocumentError)); return; } IDBFactory* idb_factory = nullptr; - Response response = AssertIDBFactory(frame->DomWindow(), idb_factory); + protocol::Response response = + AssertIDBFactory(frame->DomWindow(), idb_factory); if (!response.IsSuccess()) { SendFailure(response); return; @@ -205,7 +210,7 @@ ScriptState* script_state = ToScriptStateForMainWorld(frame); if (!script_state) { - SendFailure(Response::InternalError()); + SendFailure(protocol::Response::InternalError()); return; } @@ -227,7 +232,7 @@ IDBOpenDBRequest* idb_open_db_request = idb_factory->open(script_state, database_name, exception_state); if (exception_state.HadException()) { - SendFailure(Response::ServerError("Could not open database.")); + SendFailure(protocol::Response::ServerError("Could not open database.")); return; } idb_open_db_request->addEventListener(event_type_names::kUpgradeneeded, @@ -236,7 +241,7 @@ open_callback, false); } - void SendFailure(Response response) { + void SendFailure(protocol::Response response) { GetRequestCallback()->sendFailure(response); } }; @@ -261,7 +266,7 @@ void Invoke(ExecutionContext* context, Event* event) override { if (event->type() != event_type_names::kSuccess) { executable_with_database_->GetRequestCallback()->sendFailure( - Response::ServerError("Unexpected event type.")); + protocol::Response::ServerError("Unexpected event type.")); return; } @@ -270,7 +275,7 @@ IDBAny* request_result = idb_open_db_request->ResultAsAny(); if (request_result->GetType() != IDBAny::kIDBDatabaseType) { executable_with_database_->GetRequestCallback()->sendFailure( - Response::ServerError("Unexpected result type.")); + protocol::Response::ServerError("Unexpected result type.")); return; } @@ -308,7 +313,7 @@ void Invoke(ExecutionContext* context, Event* event) override { if (event->type() != event_type_names::kUpgradeneeded) { executable_with_database_->GetRequestCallback()->sendFailure( - Response::ServerError("Unexpected event type.")); + protocol::Response::ServerError("Unexpected event type.")); return; } @@ -320,7 +325,7 @@ NonThrowableExceptionState exception_state; idb_open_db_request->transaction()->abort(exception_state); executable_with_database_->GetRequestCallback()->sendFailure( - Response::ServerError("Aborted upgrade.")); + protocol::Response::ServerError("Aborted upgrade.")); } private: @@ -550,7 +555,7 @@ void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { request_callback_->sendFailure( - Response::ServerError("Unexpected event type.")); + protocol::Response::ServerError("Unexpected event type.")); return; } @@ -562,7 +567,7 @@ } if (request_result->GetType() != IDBAny::kIDBCursorWithValueType) { request_callback_->sendFailure( - Response::ServerError("Unexpected result type.")); + protocol::Response::ServerError("Unexpected result type.")); return; } @@ -573,7 +578,7 @@ idb_cursor->advance(skip_count_, exception_state); if (exception_state.HadException()) { request_callback_->sendFailure( - Response::ServerError("Could not advance cursor.")); + protocol::Response::ServerError("Could not advance cursor.")); } skip_count_ = 0; return; @@ -591,7 +596,7 @@ exception_state); if (exception_state.HadException()) { request_callback_->sendFailure( - Response::ServerError("Could not continue cursor.")); + protocol::Response::ServerError("Could not continue cursor.")); return; } @@ -656,14 +661,14 @@ TransactionForDatabase(script_state, idb_database, object_store_name_); if (!idb_transaction) { request_callback_->sendFailure( - Response::ServerError("Could not get transaction")); + protocol::Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::ServerError("Could not get object store")); + protocol::Response::ServerError("Could not get object store")); return; } @@ -672,7 +677,7 @@ IDBIndex* idb_index = IndexForObjectStore(idb_object_store, index_name_); if (!idb_index) { request_callback_->sendFailure( - Response::ServerError("Could not get index")); + protocol::Response::ServerError("Could not get index")); return; } @@ -740,26 +745,26 @@ } } -Response InspectorIndexedDBAgent::enable() { +protocol::Response InspectorIndexedDBAgent::enable() { enabled_.Set(true); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorIndexedDBAgent::disable() { +protocol::Response InspectorIndexedDBAgent::disable() { enabled_.Clear(); v8_session_->releaseObjectGroup( ToV8InspectorStringView(kIndexedDBObjectGroup)); - return Response::Success(); + return protocol::Response::Success(); } namespace { -absl::variant<LocalFrame*, Response> ResolveFrame( +absl::variant<LocalFrame*, protocol::Response> ResolveFrame( protocol::Maybe<String> security_origin, protocol::Maybe<String> storage_key, InspectedFrames* inspected_frames) { if (security_origin.isJust() == storage_key.isJust()) { - return Response::InvalidParams( + return protocol::Response::InvalidParams( "At least and at most one of security_origin, " "storage_key must be specified."); } @@ -775,18 +780,22 @@ protocol::Maybe<String> security_origin, protocol::Maybe<String> storage_key, std::unique_ptr<RequestDatabaseNamesCallback> request_callback) { - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); } LocalFrame* frame = absl::get<LocalFrame*>(frame_or_response); if (!frame) { - request_callback->sendFailure(Response::ServerError(kNoDocumentError)); + request_callback->sendFailure( + protocol::Response::ServerError(kNoDocumentError)); return; } IDBFactory* idb_factory = nullptr; - Response response = AssertIDBFactory(frame->DomWindow(), idb_factory); + protocol::Response response = + AssertIDBFactory(frame->DomWindow(), idb_factory); if (!response.IsSuccess()) { request_callback->sendFailure(response); return; @@ -794,7 +803,7 @@ ScriptState* script_state = ToScriptStateForMainWorld(frame); if (!script_state) { - request_callback->sendFailure(Response::InternalError()); + request_callback->sendFailure(protocol::Response::InternalError()); return; } idb_factory->GetDatabaseInfo( @@ -807,10 +816,12 @@ protocol::Maybe<String> storage_key, const String& database_name, std::unique_ptr<RequestDatabaseCallback> request_callback) { - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); } scoped_refptr<DatabaseLoader> database_loader = DatabaseLoader::Create(std::move(request_callback)); @@ -833,13 +844,15 @@ : nullptr; if (key_range.isJust() && !idb_key_range) { request_callback->sendFailure( - Response::ServerError("Can not parse key range.")); + protocol::Response::ServerError("Can not parse key range.")); return; } - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); } scoped_refptr<DataLoader> data_loader = DataLoader::Create( v8_session_, std::move(request_callback), object_store_name, index_name, @@ -890,7 +903,8 @@ void NotifySubtaskDone(const String& error) { if (!error.IsNull()) { - request_callback_->sendFailure(Response::ServerError(error.Utf8())); + request_callback_->sendFailure( + protocol::Response::ServerError(error.Utf8())); return; } if (--subtask_pending_ == 0) { @@ -914,14 +928,14 @@ indexed_db_names::kReadonly); if (!idb_transaction) { request_callback_->sendFailure( - Response::ServerError("Could not get transaction")); + protocol::Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::ServerError("Could not get object store")); + protocol::Response::ServerError("Could not get object store")); return; } @@ -934,7 +948,7 @@ DCHECK(!exception_state.HadException()); if (exception_state.HadException()) { ExceptionCode ec = exception_state.Code(); - request_callback_->sendFailure(Response::ServerError( + request_callback_->sendFailure(protocol::Response::ServerError( String::Format("Could not count entries in object store '%s': %d", object_store_name_.Latin1().c_str(), ec) .Utf8())); @@ -982,10 +996,12 @@ const String& database_name, const String& object_store_name, std::unique_ptr<GetMetadataCallback> request_callback) { - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); return; } scoped_refptr<GetMetadata> get_metadata = @@ -1002,8 +1018,8 @@ void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { - request_callback_->sendFailure( - Response::ServerError("Failed to delete specified entries")); + request_callback_->sendFailure(protocol::Response::ServerError( + "Failed to delete specified entries")); return; } @@ -1039,14 +1055,14 @@ indexed_db_names::kReadwrite); if (!idb_transaction) { request_callback_->sendFailure( - Response::ServerError("Could not get transaction")); + protocol::Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::ServerError("Could not get object store")); + protocol::Response::ServerError("Could not get object store")); return; } @@ -1079,13 +1095,15 @@ IDBKeyRange* idb_key_range = IdbKeyRangeFromKeyRange(key_range.get()); if (!idb_key_range) { request_callback->sendFailure( - Response::ServerError("Can not parse key range")); + protocol::Response::ServerError("Can not parse key range")); return; } - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); return; } scoped_refptr<DeleteObjectStoreEntries> delete_object_store_entries = @@ -1105,7 +1123,7 @@ void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kComplete) { request_callback_->sendFailure( - Response::ServerError("Unexpected event type.")); + protocol::Response::ServerError("Unexpected event type.")); return; } @@ -1137,14 +1155,14 @@ indexed_db_names::kReadwrite); if (!idb_transaction) { request_callback_->sendFailure( - Response::ServerError("Could not get transaction")); + protocol::Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::ServerError("Could not get object store")); + protocol::Response::ServerError("Could not get object store")); return; } @@ -1153,7 +1171,7 @@ DCHECK(!exception_state.HadException()); if (exception_state.HadException()) { ExceptionCode ec = exception_state.Code(); - request_callback_->sendFailure(Response::ServerError( + request_callback_->sendFailure(protocol::Response::ServerError( String::Format("Could not clear object store '%s': %d", object_store_name_.Latin1().c_str(), ec) .Utf8())); @@ -1181,10 +1199,12 @@ const String& database_name, const String& object_store_name, std::unique_ptr<ClearObjectStoreCallback> request_callback) { - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); return; } scoped_refptr<ClearObjectStore> clear_object_store = @@ -1198,19 +1218,23 @@ protocol::Maybe<String> storage_key, const String& database_name, std::unique_ptr<DeleteDatabaseCallback> request_callback) { - absl::variant<LocalFrame*, Response> frame_or_response = ResolveFrame( - std::move(security_origin), std::move(storage_key), inspected_frames_); - if (absl::holds_alternative<Response>(frame_or_response)) { - request_callback->sendFailure(absl::get<Response>(frame_or_response)); + absl::variant<LocalFrame*, protocol::Response> frame_or_response = + ResolveFrame(std::move(security_origin), std::move(storage_key), + inspected_frames_); + if (absl::holds_alternative<protocol::Response>(frame_or_response)) { + request_callback->sendFailure( + absl::get<protocol::Response>(frame_or_response)); return; } LocalFrame* frame = absl::get<LocalFrame*>(frame_or_response); if (!frame) { - request_callback->sendFailure(Response::ServerError(kNoDocumentError)); + request_callback->sendFailure( + protocol::Response::ServerError(kNoDocumentError)); return; } IDBFactory* idb_factory = nullptr; - Response response = AssertIDBFactory(frame->DomWindow(), idb_factory); + protocol::Response response = + AssertIDBFactory(frame->DomWindow(), idb_factory); if (!response.IsSuccess()) { request_callback->sendFailure(response); return; @@ -1218,7 +1242,7 @@ ScriptState* script_state = ToScriptStateForMainWorld(frame); if (!script_state) { - request_callback->sendFailure(Response::InternalError()); + request_callback->sendFailure(protocol::Response::InternalError()); return; } ScriptState::Scope scope(script_state); @@ -1227,7 +1251,7 @@ script_state, database_name, exception_state); if (exception_state.HadException()) { request_callback->sendFailure( - Response::ServerError("Could not delete database.")); + protocol::Response::ServerError("Could not delete database.")); return; } idb_request->addEventListener(
diff --git a/third_party/blink/renderer/modules/managed_device/navigator_managed_data.cc b/third_party/blink/renderer/modules/managed_device/navigator_managed_data.cc index 92af4bc..360de39 100644 --- a/third_party/blink/renderer/modules/managed_device/navigator_managed_data.cc +++ b/third_party/blink/renderer/modules/managed_device/navigator_managed_data.cc
@@ -39,7 +39,8 @@ } NavigatorManagedData::NavigatorManagedData(Navigator& navigator) - : Supplement<Navigator>(navigator), + : ActiveScriptWrappable<NavigatorManagedData>({}), + Supplement<Navigator>(navigator), device_api_service_(navigator.DomWindow()), managed_configuration_service_(navigator.DomWindow()), configuration_observer_(this, navigator.DomWindow()) {}
diff --git a/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc b/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc index bfb5f7e..5baf2d78 100644 --- a/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc +++ b/third_party/blink/renderer/modules/mediarecorder/media_recorder.cc
@@ -203,7 +203,8 @@ MediaStream* stream, const MediaRecorderOptions* options, ExceptionState& exception_state) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<MediaRecorder>({}), + ExecutionContextLifecycleObserver(context), stream_(stream), mime_type_(options->mimeType()) { if (context->IsContextDestroyed()) {
diff --git a/third_party/blink/renderer/modules/mediasource/media_source.cc b/third_party/blink/renderer/modules/mediasource/media_source.cc index a0ee20b9..5344c9d 100644 --- a/third_party/blink/renderer/modules/mediasource/media_source.cc +++ b/third_party/blink/renderer/modules/mediasource/media_source.cc
@@ -113,7 +113,8 @@ } MediaSource::MediaSource(ExecutionContext* context) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<MediaSource>({}), + ExecutionContextLifecycleObserver(context), ready_state_(ReadyState::kClosed), async_event_queue_( MakeGarbageCollected<EventQueue>(GetExecutionContext(),
diff --git a/third_party/blink/renderer/modules/mediasource/source_buffer.cc b/third_party/blink/renderer/modules/mediasource/source_buffer.cc index a99ec3f2..3655eb8 100644 --- a/third_party/blink/renderer/modules/mediasource/source_buffer.cc +++ b/third_party/blink/renderer/modules/mediasource/source_buffer.cc
@@ -200,7 +200,8 @@ SourceBuffer::SourceBuffer(std::unique_ptr<WebSourceBuffer> web_source_buffer, MediaSource* source, EventQueue* async_event_queue) - : ExecutionContextLifecycleObserver(source->GetExecutionContext()), + : ActiveScriptWrappable<SourceBuffer>({}), + ExecutionContextLifecycleObserver(source->GetExecutionContext()), web_source_buffer_(std::move(web_source_buffer)), source_(source), track_defaults_(MakeGarbageCollected<TrackDefaultList>()),
diff --git a/third_party/blink/renderer/modules/mediastream/media_devices.cc b/third_party/blink/renderer/modules/mediastream/media_devices.cc index 141a66a..d9760c6 100644 --- a/third_party/blink/renderer/modules/mediastream/media_devices.cc +++ b/third_party/blink/renderer/modules/mediastream/media_devices.cc
@@ -365,7 +365,8 @@ } MediaDevices::MediaDevices(Navigator& navigator) - : Supplement<Navigator>(navigator), + : ActiveScriptWrappable<MediaDevices>({}), + Supplement<Navigator>(navigator), ExecutionContextLifecycleObserver(navigator.DomWindow()), stopped_(false), dispatcher_host_(navigator.GetExecutionContext()),
diff --git a/third_party/blink/renderer/modules/mediastream/media_stream.cc b/third_party/blink/renderer/modules/mediastream/media_stream.cc index 7b69b683..c1f81f7 100644 --- a/third_party/blink/renderer/modules/mediastream/media_stream.cc +++ b/third_party/blink/renderer/modules/mediastream/media_stream.cc
@@ -123,6 +123,7 @@ TransferredMediaStreamTrack* transferred_track, base::OnceCallback<void(MediaStream*)> callback) : ExecutionContextClient(context), + ActiveScriptWrappable<MediaStream>({}), descriptor_(stream_descriptor), media_stream_initialized_callback_(std::move(callback)), scheduled_event_timer_( @@ -183,6 +184,7 @@ const MediaStreamTrackVector& audio_tracks, const MediaStreamTrackVector& video_tracks) : ExecutionContextClient(context), + ActiveScriptWrappable<MediaStream>({}), descriptor_(stream_descriptor), scheduled_event_timer_( context->GetTaskRunner(TaskType::kMediaElementEvent), @@ -213,6 +215,7 @@ const MediaStreamTrackVector& audio_tracks, const MediaStreamTrackVector& video_tracks) : ExecutionContextClient(context), + ActiveScriptWrappable<MediaStream>({}), scheduled_event_timer_( context->GetTaskRunner(TaskType::kMediaElementEvent), this,
diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_track.cc b/third_party/blink/renderer/modules/mediastream/media_stream_track.cc index 8dc248d..f961aea5 100644 --- a/third_party/blink/renderer/modules/mediastream/media_stream_track.cc +++ b/third_party/blink/renderer/modules/mediastream/media_stream_track.cc
@@ -29,6 +29,9 @@ } // namespace +MediaStreamTrack::MediaStreamTrack() + : ActiveScriptWrappable<MediaStreamTrack>({}) {} + String ContentHintToString( const WebMediaStreamTrack::ContentHintType& content_hint) { switch (content_hint) {
diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_track.h b/third_party/blink/renderer/modules/mediastream/media_stream_track.h index 75864f3..743afc5b 100644 --- a/third_party/blink/renderer/modules/mediastream/media_stream_track.h +++ b/third_party/blink/renderer/modules/mediastream/media_stream_track.h
@@ -84,6 +84,8 @@ static MediaStreamTrack* FromTransferredState(ScriptState* script_state, const TransferredValues& data); + MediaStreamTrack(); + // MediaStreamTrack.idl virtual String kind() const = 0; virtual String id() const = 0;
diff --git a/third_party/blink/renderer/modules/netinfo/network_information.cc b/third_party/blink/renderer/modules/netinfo/network_information.cc index 4a4455bb..30bfe76 100644 --- a/third_party/blink/renderer/modules/netinfo/network_information.cc +++ b/third_party/blink/renderer/modules/netinfo/network_information.cc
@@ -273,7 +273,8 @@ } NetworkInformation::NetworkInformation(NavigatorBase& navigator) - : Supplement<NavigatorBase>(navigator), + : ActiveScriptWrappable<NetworkInformation>({}), + Supplement<NavigatorBase>(navigator), ExecutionContextLifecycleObserver(navigator.GetExecutionContext()), web_holdback_console_message_shown_(false), context_stopped_(false) {
diff --git a/third_party/blink/renderer/modules/nfc/ndef_reader.cc b/third_party/blink/renderer/modules/nfc/ndef_reader.cc index b458f24..19c25738 100644 --- a/third_party/blink/renderer/modules/nfc/ndef_reader.cc +++ b/third_party/blink/renderer/modules/nfc/ndef_reader.cc
@@ -34,7 +34,6 @@ using mojom::blink::PermissionName; using mojom::blink::PermissionService; -using mojom::blink::PermissionStatus; namespace { @@ -149,7 +148,8 @@ } NDEFReader::NDEFReader(ExecutionContext* context) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<NDEFReader>({}), + ExecutionContextLifecycleObserver(context), nfc_proxy_(NFCProxy::From(*DomWindow())), permission_service_(context) {} @@ -211,8 +211,9 @@ return scan_resolver_->Promise(); } -void NDEFReader::ReadOnRequestPermission(const NDEFScanOptions* options, - PermissionStatus status) { +void NDEFReader::ReadOnRequestPermission( + const NDEFScanOptions* options, + mojom::blink::PermissionStatus status) { if (!scan_resolver_) return; @@ -226,7 +227,7 @@ ScriptState::Scope script_state_scope(script_state); - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { scan_resolver_->Reject(V8ThrowDOMException::CreateOrDie( script_state->GetIsolate(), DOMExceptionCode::kNotAllowedError, "NFC permission request denied.")); @@ -378,7 +379,7 @@ std::unique_ptr<ScopedAbortState> scoped_abort_state, const NDEFWriteOptions* options, device::mojom::blink::NDEFMessagePtr message, - PermissionStatus status) { + mojom::blink::PermissionStatus status) { DCHECK(resolver); ScriptState* script_state = resolver->GetScriptState(); @@ -390,7 +391,7 @@ ScriptState::Scope script_state_scope(script_state); - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { resolver->Reject(V8ThrowDOMException::CreateOrDie( script_state->GetIsolate(), DOMExceptionCode::kNotAllowedError, "NFC permission request denied.")); @@ -500,7 +501,7 @@ ScriptPromiseResolver* resolver, std::unique_ptr<ScopedAbortState> scoped_abort_state, const NDEFMakeReadOnlyOptions* options, - PermissionStatus status) { + mojom::blink::PermissionStatus status) { DCHECK(resolver); ScriptState* script_state = resolver->GetScriptState(); @@ -512,7 +513,7 @@ ScriptState::Scope script_state_scope(resolver->GetScriptState()); - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { resolver->Reject(V8ThrowDOMException::CreateOrDie( script_state->GetIsolate(), DOMExceptionCode::kNotAllowedError, "NFC permission request denied."));
diff --git a/third_party/blink/renderer/modules/notifications/notification.cc b/third_party/blink/renderer/modules/notifications/notification.cc index 573fdede..9e8a67b 100644 --- a/third_party/blink/renderer/modules/notifications/notification.cc +++ b/third_party/blink/renderer/modules/notifications/notification.cc
@@ -164,7 +164,8 @@ Notification::Notification(ExecutionContext* context, Type type, mojom::blink::NotificationDataPtr data) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<Notification>({}), + ExecutionContextLifecycleObserver(context), type_(type), state_(State::kLoading), data_(std::move(data)),
diff --git a/third_party/blink/renderer/modules/payments/payment_request.cc b/third_party/blink/renderer/modules/payments/payment_request.cc index 509270e..3bda1295 100644 --- a/third_party/blink/renderer/modules/payments/payment_request.cc +++ b/third_party/blink/renderer/modules/payments/payment_request.cc
@@ -1267,6 +1267,7 @@ mock_payment_provider, ExceptionState& exception_state) : ExecutionContextLifecycleObserver(execution_context), + ActiveScriptWrappable<PaymentRequest>({}), options_(options), payment_provider_(execution_context), client_receiver_(this, execution_context),
diff --git a/third_party/blink/renderer/modules/payments/payment_response.cc b/third_party/blink/renderer/modules/payments/payment_response.cc index 88db8904..5ab415d 100644 --- a/third_party/blink/renderer/modules/payments/payment_response.cc +++ b/third_party/blink/renderer/modules/payments/payment_response.cc
@@ -75,6 +75,7 @@ PaymentStateResolver* payment_state_resolver, const String& request_id) : ExecutionContextClient(ExecutionContext::From(script_state)), + ActiveScriptWrappable<PaymentResponse>({}), request_id_(request_id), method_name_(response->method_name), shipping_address_(shipping_address),
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc b/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc index 2e6e315..87feebc 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_data_channel.cc
@@ -305,7 +305,8 @@ ExecutionContext* context, rtc::scoped_refptr<webrtc::DataChannelInterface> channel, RTCPeerConnectionHandler* peer_connection_handler) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<RTCDataChannel>({}), + ExecutionContextLifecycleObserver(context), scheduled_event_timer_(context->GetTaskRunner(TaskType::kNetworking), this, &RTCDataChannel::ScheduledEventTimerFired),
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc b/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc index ce65a84..28ee1f0 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc
@@ -92,7 +92,8 @@ scoped_refptr<base::SingleThreadTaskRunner> host_thread, std::unique_ptr<IceTransportAdapterCrossThreadFactory> adapter_factory, RTCPeerConnection* peer_connection) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<RTCIceTransport>({}), + ExecutionContextLifecycleObserver(context), peer_connection_(peer_connection) { DCHECK(context); DCHECK(proxy_thread);
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc index 1ac5983..e3e9203 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
@@ -583,7 +583,8 @@ bool encoded_insertable_streams, GoogMediaConstraints* media_constraints, ExceptionState& exception_state) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<RTCPeerConnection>({}), + ExecutionContextLifecycleObserver(context), pending_local_description_(nullptr), current_local_description_(nullptr), pending_remote_description_(nullptr),
diff --git a/third_party/blink/renderer/modules/permissions/permission_status.cc b/third_party/blink/renderer/modules/permissions/permission_status.cc index 49cdeeb..9a49685 100644 --- a/third_party/blink/renderer/modules/permissions/permission_status.cc +++ b/third_party/blink/renderer/modules/permissions/permission_status.cc
@@ -27,7 +27,8 @@ PermissionStatus::PermissionStatus(PermissionStatusListener* listener, ExecutionContext* execution_context) - : ExecutionContextLifecycleStateObserver(execution_context), + : ActiveScriptWrappable<PermissionStatus>({}), + ExecutionContextLifecycleStateObserver(execution_context), listener_(listener) {} PermissionStatus::~PermissionStatus() = default;
diff --git a/third_party/blink/renderer/modules/permissions/permission_utils.cc b/third_party/blink/renderer/modules/permissions/permission_utils.cc index 7ecbe43..e1b4c01 100644 --- a/third_party/blink/renderer/modules/permissions/permission_utils.cc +++ b/third_party/blink/renderer/modules/permissions/permission_utils.cc
@@ -32,7 +32,6 @@ using MojoPermissionDescriptor = mojom::blink::PermissionDescriptor; using mojom::blink::PermissionDescriptorPtr; using mojom::blink::PermissionName; -using mojom::blink::PermissionStatus; void ConnectToPermissionService( ExecutionContext* execution_context, @@ -41,13 +40,13 @@ std::move(receiver)); } -String PermissionStatusToString(PermissionStatus status) { +String PermissionStatusToString(mojom::blink::PermissionStatus status) { switch (status) { - case PermissionStatus::GRANTED: + case mojom::blink::PermissionStatus::GRANTED: return "granted"; - case PermissionStatus::DENIED: + case mojom::blink::PermissionStatus::DENIED: return "denied"; - case PermissionStatus::ASK: + case mojom::blink::PermissionStatus::ASK: return "prompt"; } NOTREACHED();
diff --git a/third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_window.cc b/third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_window.cc index de13686..56390b6 100644 --- a/third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_window.cc +++ b/third_party/blink/renderer/modules/picture_in_picture/picture_in_picture_window.cc
@@ -14,7 +14,9 @@ PictureInPictureWindow::PictureInPictureWindow( ExecutionContext* execution_context, const gfx::Size& size) - : ExecutionContextClient(execution_context), size_(size) {} + : ActiveScriptWrappable<PictureInPictureWindow>({}), + ExecutionContextClient(execution_context), + size_(size) {} void PictureInPictureWindow::OnClose() { size_ = gfx::Size();
diff --git a/third_party/blink/renderer/modules/presentation/presentation_availability.cc b/third_party/blink/renderer/modules/presentation/presentation_availability.cc index caded34e..0973a968 100644 --- a/third_party/blink/renderer/modules/presentation/presentation_availability.cc +++ b/third_party/blink/renderer/modules/presentation/presentation_availability.cc
@@ -34,7 +34,8 @@ ExecutionContext* execution_context, const WTF::Vector<KURL>& urls, bool value) - : ExecutionContextLifecycleStateObserver(execution_context), + : ActiveScriptWrappable<PresentationAvailability>({}), + ExecutionContextLifecycleStateObserver(execution_context), PageVisibilityObserver( To<LocalDOMWindow>(execution_context)->GetFrame()->GetPage()), urls_(urls),
diff --git a/third_party/blink/renderer/modules/presentation/presentation_request.cc b/third_party/blink/renderer/modules/presentation/presentation_request.cc index 0e662cc6..9a3e5632 100644 --- a/third_party/blink/renderer/modules/presentation/presentation_request.cc +++ b/third_party/blink/renderer/modules/presentation/presentation_request.cc
@@ -299,6 +299,8 @@ PresentationRequest::PresentationRequest(ExecutionContext* execution_context, const Vector<KURL>& urls) - : ExecutionContextClient(execution_context), urls_(urls) {} + : ActiveScriptWrappable<PresentationRequest>({}), + ExecutionContextClient(execution_context), + urls_(urls) {} } // namespace blink
diff --git a/third_party/blink/renderer/modules/quota/storage_manager.cc b/third_party/blink/renderer/modules/quota/storage_manager.cc index 70142589..9732e10 100644 --- a/third_party/blink/renderer/modules/quota/storage_manager.cc +++ b/third_party/blink/renderer/modules/quota/storage_manager.cc
@@ -30,7 +30,6 @@ using mojom::blink::PermissionName; using mojom::blink::PermissionService; -using mojom::blink::PermissionStatus; using mojom::blink::UsageBreakdownPtr; namespace { @@ -229,12 +228,13 @@ permission_service_.reset(); } -void StorageManager::PermissionRequestComplete(ScriptPromiseResolver* resolver, - PermissionStatus status) { +void StorageManager::PermissionRequestComplete( + ScriptPromiseResolver* resolver, + mojom::blink::PermissionStatus status) { if (!resolver->GetExecutionContext() || resolver->GetExecutionContext()->IsContextDestroyed()) return; - resolver->Resolve(status == PermissionStatus::GRANTED); + resolver->Resolve(status == mojom::blink::PermissionStatus::GRANTED); } void StorageManager::StartObserving() {
diff --git a/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc b/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc index 96e885ad..a627c98 100644 --- a/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc +++ b/third_party/blink/renderer/modules/remoteplayback/remote_playback.cc
@@ -102,6 +102,7 @@ RemotePlayback::RemotePlayback(HTMLMediaElement& element) : ExecutionContextLifecycleObserver(element.GetExecutionContext()), + ActiveScriptWrappable<RemotePlayback>({}), RemotePlaybackController(element), state_(mojom::blink::PresentationConnectionState::CLOSED), availability_(mojom::ScreenAvailability::UNKNOWN),
diff --git a/third_party/blink/renderer/modules/sensor/sensor.cc b/third_party/blink/renderer/modules/sensor/sensor.cc index da2a3e24..f1666406 100644 --- a/third_party/blink/renderer/modules/sensor/sensor.cc +++ b/third_party/blink/renderer/modules/sensor/sensor.cc
@@ -43,7 +43,8 @@ ExceptionState& exception_state, device::mojom::blink::SensorType type, const Vector<mojom::blink::PermissionsPolicyFeature>& features) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<Sensor>({}), + ExecutionContextLifecycleObserver(execution_context), frequency_(0.0), type_(type), state_(SensorState::kIdle),
diff --git a/third_party/blink/renderer/modules/serial/serial_port.cc b/third_party/blink/renderer/modules/serial/serial_port.cc index bfcd8b9b..e7661cc 100644 --- a/third_party/blink/renderer/modules/serial/serial_port.cc +++ b/third_party/blink/renderer/modules/serial/serial_port.cc
@@ -113,7 +113,8 @@ } // namespace SerialPort::SerialPort(Serial* parent, mojom::blink::SerialPortInfoPtr info) - : info_(std::move(info)), + : ActiveScriptWrappable<SerialPort>({}), + info_(std::move(info)), parent_(parent), port_(parent->GetExecutionContext()), client_receiver_(this, parent->GetExecutionContext()) {}
diff --git a/third_party/blink/renderer/modules/service_worker/fetch_event.cc b/third_party/blink/renderer/modules/service_worker/fetch_event.cc index 80038ce..790fe9e0f 100644 --- a/third_party/blink/renderer/modules/service_worker/fetch_event.cc +++ b/third_party/blink/renderer/modules/service_worker/fetch_event.cc
@@ -102,6 +102,7 @@ WaitUntilObserver* wait_until_observer, bool navigation_preload_sent) : ExtendableEvent(type, initializer, wait_until_observer), + ActiveScriptWrappable<FetchEvent>({}), ExecutionContextClient(ExecutionContext::From(script_state)), observer_(respond_with_observer), preload_response_property_(MakeGarbageCollected<PreloadResponseProperty>(
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker.cc b/third_party/blink/renderer/modules/service_worker/service_worker.cc index c5e84185..54e0225 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker.cc +++ b/third_party/blink/renderer/modules/service_worker/service_worker.cc
@@ -199,6 +199,7 @@ ServiceWorker::ServiceWorker(ExecutionContext* execution_context, WebServiceWorkerObjectInfo info) : AbstractWorker(execution_context), + ActiveScriptWrappable<ServiceWorker>({}), url_(info.url), state_(info.state), host_(execution_context),
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc b/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc index c45ee57..f565fa3 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc +++ b/third_party/blink/renderer/modules/service_worker/service_worker_registration.cc
@@ -140,7 +140,8 @@ ServiceWorkerRegistration::ServiceWorkerRegistration( ExecutionContext* execution_context, WebServiceWorkerRegistrationObjectInfo info) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<ServiceWorkerRegistration>({}), + ExecutionContextLifecycleObserver(execution_context), registration_id_(info.registration_id), scope_(std::move(info.scope)), stopped_(false) { @@ -152,7 +153,8 @@ ServiceWorkerRegistration::ServiceWorkerRegistration( ExecutionContext* execution_context, mojom::blink::ServiceWorkerRegistrationObjectInfoPtr info) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<ServiceWorkerRegistration>({}), + ExecutionContextLifecycleObserver(execution_context), registration_id_(info->registration_id), scope_(std::move(info->scope)), stopped_(false) {
diff --git a/third_party/blink/renderer/modules/smart_card/smart_card_reader.cc b/third_party/blink/renderer/modules/smart_card/smart_card_reader.cc index 7d2f60c..aab0870 100644 --- a/third_party/blink/renderer/modules/smart_card/smart_card_reader.cc +++ b/third_party/blink/renderer/modules/smart_card/smart_card_reader.cc
@@ -34,6 +34,7 @@ SmartCardReader::SmartCardReader(SmartCardReaderInfoPtr info, ExecutionContext* context) : ExecutionContextLifecycleObserver(context), + ActiveScriptWrappable<SmartCardReader>({}), name_(info->name), state_(V8StateFromMojoState(info->state)), atr_(info->atr) {}
diff --git a/third_party/blink/renderer/modules/smart_card/smart_card_reader_presence_observer.cc b/third_party/blink/renderer/modules/smart_card/smart_card_reader_presence_observer.cc index 87cee54..93ae687 100644 --- a/third_party/blink/renderer/modules/smart_card/smart_card_reader_presence_observer.cc +++ b/third_party/blink/renderer/modules/smart_card/smart_card_reader_presence_observer.cc
@@ -9,7 +9,8 @@ SmartCardReaderPresenceObserver::SmartCardReaderPresenceObserver( ExecutionContext* context) - : ExecutionContextLifecycleObserver(context) {} + : ExecutionContextLifecycleObserver(context), + blink::ActiveScriptWrappable<SmartCardReaderPresenceObserver>({}) {} SmartCardReaderPresenceObserver::~SmartCardReaderPresenceObserver() = default;
diff --git a/third_party/blink/renderer/modules/speech/speech_recognition.cc b/third_party/blink/renderer/modules/speech/speech_recognition.cc index 3bb1f98..06ff605 100644 --- a/third_party/blink/renderer/modules/speech/speech_recognition.cc +++ b/third_party/blink/renderer/modules/speech/speech_recognition.cc
@@ -246,7 +246,8 @@ } SpeechRecognition::SpeechRecognition(LocalDOMWindow* window) - : ExecutionContextLifecycleObserver(window), + : ActiveScriptWrappable<SpeechRecognition>({}), + ExecutionContextLifecycleObserver(window), PageVisibilityObserver(window->GetFrame() ? window->GetFrame()->GetPage() : nullptr), grammars_(SpeechGrammarList::Create()), // FIXME: The spec is not clear
diff --git a/third_party/blink/renderer/modules/storage/inspector_dom_storage_agent.cc b/third_party/blink/renderer/modules/storage/inspector_dom_storage_agent.cc index 7d176f9e..50f285a 100644 --- a/third_party/blink/renderer/modules/storage/inspector_dom_storage_agent.cc +++ b/third_party/blink/renderer/modules/storage/inspector_dom_storage_agent.cc
@@ -45,11 +45,10 @@ #include "third_party/blink/renderer/platform/storage/blink_storage_key.h" namespace blink { -using protocol::Response; -static Response ToResponse(ExceptionState& exception_state) { +static protocol::Response ToResponse(ExceptionState& exception_state) { if (!exception_state.HadException()) - return Response::Success(); + return protocol::Response::Success(); String name_prefix = IsDOMExceptionCode(exception_state.Code()) ? DOMException::GetErrorName( @@ -57,7 +56,7 @@ " " : g_empty_string; String msg = name_prefix + exception_state.Message(); - return Response::ServerError(msg.Utf8()); + return protocol::Response::ServerError(msg.Utf8()); } InspectorDOMStorageAgent::InspectorDOMStorageAgent( @@ -85,17 +84,17 @@ ns->AddInspectorStorageAgent(this); } -Response InspectorDOMStorageAgent::enable() { +protocol::Response InspectorDOMStorageAgent::enable() { if (enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Set(true); InnerEnable(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMStorageAgent::disable() { +protocol::Response InspectorDOMStorageAgent::disable() { if (!enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Set(false); StorageController::GetInstance()->RemoveLocalStorageInspectorStorageAgent( this); @@ -103,27 +102,29 @@ StorageNamespace::From(inspected_frames_->Root()->GetPage()); if (ns) ns->RemoveInspectorStorageAgent(this); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMStorageAgent::clear( +protocol::Response InspectorDOMStorageAgent::clear( std::unique_ptr<protocol::DOMStorage::StorageId> storage_id) { StorageArea* storage_area = nullptr; - Response response = FindStorageArea(std::move(storage_id), storage_area); + protocol::Response response = + FindStorageArea(std::move(storage_id), storage_area); if (!response.IsSuccess()) return response; DummyExceptionStateForTesting exception_state; storage_area->clear(exception_state); if (exception_state.HadException()) - return Response::ServerError("Could not clear the storage"); - return Response::Success(); + return protocol::Response::ServerError("Could not clear the storage"); + return protocol::Response::Success(); } -Response InspectorDOMStorageAgent::getDOMStorageItems( +protocol::Response InspectorDOMStorageAgent::getDOMStorageItems( std::unique_ptr<protocol::DOMStorage::StorageId> storage_id, std::unique_ptr<protocol::Array<protocol::Array<String>>>* items) { StorageArea* storage_area = nullptr; - Response response = FindStorageArea(std::move(storage_id), storage_area); + protocol::Response response = + FindStorageArea(std::move(storage_id), storage_area); if (!response.IsSuccess()) return response; @@ -146,15 +147,16 @@ storage_items->emplace_back(std::move(entry)); } *items = std::move(storage_items); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDOMStorageAgent::setDOMStorageItem( +protocol::Response InspectorDOMStorageAgent::setDOMStorageItem( std::unique_ptr<protocol::DOMStorage::StorageId> storage_id, const String& key, const String& value) { StorageArea* storage_area = nullptr; - Response response = FindStorageArea(std::move(storage_id), storage_area); + protocol::Response response = + FindStorageArea(std::move(storage_id), storage_area); if (!response.IsSuccess()) return response; @@ -163,11 +165,12 @@ return ToResponse(exception_state); } -Response InspectorDOMStorageAgent::removeDOMStorageItem( +protocol::Response InspectorDOMStorageAgent::removeDOMStorageItem( std::unique_ptr<protocol::DOMStorage::StorageId> storage_id, const String& key) { StorageArea* storage_area = nullptr; - Response response = FindStorageArea(std::move(storage_id), storage_area); + protocol::Response response = + FindStorageArea(std::move(storage_id), storage_area); if (!response.IsSuccess()) return response; @@ -224,7 +227,7 @@ } } // namespace -Response InspectorDOMStorageAgent::FindStorageArea( +protocol::Response InspectorDOMStorageAgent::FindStorageArea( std::unique_ptr<protocol::DOMStorage::StorageId> storage_id, StorageArea*& storage_area) { String security_origin = storage_id->getSecurityOrigin(""); @@ -236,11 +239,12 @@ : inspected_frames_->FrameWithSecurityOrigin(security_origin); if (!frame) { - return Response::ServerError("Frame not found for the given storage id"); + return protocol::Response::ServerError( + "Frame not found for the given storage id"); } if (is_local_storage) { if (!frame->DomWindow()->GetSecurityOrigin()->CanAccessLocalStorage()) { - return Response::ServerError( + return protocol::Response::ServerError( "Security origin cannot access local storage"); } storage_area = StorageArea::CreateForInspectorAgent( @@ -248,23 +252,23 @@ StorageController::GetInstance()->GetLocalStorageArea( frame->DomWindow()), StorageArea::StorageType::kLocalStorage); - return Response::Success(); + return protocol::Response::Success(); } if (!frame->DomWindow()->GetSecurityOrigin()->CanAccessSessionStorage()) { - return Response::ServerError( + return protocol::Response::ServerError( "Security origin cannot access session storage"); } StorageNamespace* session_namespace = StorageNamespace::From(frame->GetPage()); if (!session_namespace) - return Response::ServerError("SessionStorage is not supported"); + return protocol::Response::ServerError("SessionStorage is not supported"); DCHECK(session_namespace->IsSessionStorage()); storage_area = StorageArea::CreateForInspectorAgent( frame->DomWindow(), session_namespace->GetCachedArea(frame->DomWindow()), StorageArea::StorageType::kSessionStorage); - return Response::Success(); + return protocol::Response::Success(); } } // namespace blink
diff --git a/third_party/blink/renderer/modules/wake_lock/wake_lock.cc b/third_party/blink/renderer/modules/wake_lock/wake_lock.cc index fbb17041..880e31813 100644 --- a/third_party/blink/renderer/modules/wake_lock/wake_lock.cc +++ b/third_party/blink/renderer/modules/wake_lock/wake_lock.cc
@@ -25,7 +25,6 @@ namespace blink { using mojom::blink::PermissionService; -using mojom::blink::PermissionStatus; // static const char WakeLock::kSupplementName[] = "WakeLock"; @@ -184,18 +183,19 @@ WrapPersistent(this), type))); } -void WakeLock::DidReceivePermissionResponse(V8WakeLockType::Enum type, - ScriptPromiseResolver* resolver, - PermissionStatus status) { +void WakeLock::DidReceivePermissionResponse( + V8WakeLockType::Enum type, + ScriptPromiseResolver* resolver, + mojom::blink::PermissionStatus status) { // https://w3c.github.io/screen-wake-lock/#the-request-method - DCHECK(status == PermissionStatus::GRANTED || - status == PermissionStatus::DENIED); + DCHECK(status == mojom::blink::PermissionStatus::GRANTED || + status == mojom::blink::PermissionStatus::DENIED); // 8.2. If state is "denied", then: // 8.2.1. Queue a global task on the screen wake lock task source given // document's relevant global object to reject promise with a // "NotAllowedError" DOMException. // 8.2.2. Abort these steps. - if (status != PermissionStatus::GRANTED) { + if (status != mojom::blink::PermissionStatus::GRANTED) { resolver->Reject(V8ThrowDOMException::CreateOrDie( resolver->GetScriptState()->GetIsolate(), DOMExceptionCode::kNotAllowedError,
diff --git a/third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.cc b/third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.cc index c23bdf1..27aa6f5 100644 --- a/third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.cc +++ b/third_party/blink/renderer/modules/wake_lock/wake_lock_sentinel.cc
@@ -16,7 +16,8 @@ WakeLockSentinel::WakeLockSentinel(ScriptState* script_state, V8WakeLockType::Enum type, WakeLockManager* manager) - : ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ActiveScriptWrappable<WakeLockSentinel>({}), + ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), manager_(manager), type_(type) {}
diff --git a/third_party/blink/renderer/modules/wake_lock/wake_lock_test_utils.cc b/third_party/blink/renderer/modules/wake_lock/wake_lock_test_utils.cc index b3dcba47..8c1d45f8 100644 --- a/third_party/blink/renderer/modules/wake_lock/wake_lock_test_utils.cc +++ b/third_party/blink/renderer/modules/wake_lock/wake_lock_test_utils.cc
@@ -28,7 +28,6 @@ namespace blink { using mojom::blink::PermissionDescriptorPtr; -using mojom::blink::PermissionStatus; namespace { @@ -163,10 +162,11 @@ &MockPermissionService::OnConnectionError, WTF::Unretained(this))); } -void MockPermissionService::SetPermissionResponse(V8WakeLockType::Enum type, - PermissionStatus status) { - DCHECK(status == PermissionStatus::GRANTED || - status == PermissionStatus::DENIED); +void MockPermissionService::SetPermissionResponse( + V8WakeLockType::Enum type, + mojom::blink::PermissionStatus status) { + DCHECK(status == mojom::blink::PermissionStatus::GRANTED || + status == mojom::blink::PermissionStatus::DENIED); permission_responses_[static_cast<size_t>(type)] = status; } @@ -201,13 +201,13 @@ HasPermissionCallback callback) { V8WakeLockType::Enum type; if (!GetWakeLockTypeFromDescriptor(permission, &type)) { - std::move(callback).Run(PermissionStatus::DENIED); + std::move(callback).Run(mojom::blink::PermissionStatus::DENIED); return; } size_t pos = static_cast<size_t>(type); DCHECK(permission_responses_[pos].has_value()); - std::move(callback).Run( - permission_responses_[pos].value_or(PermissionStatus::DENIED)); + std::move(callback).Run(permission_responses_[pos].value_or( + mojom::blink::PermissionStatus::DENIED)); } void MockPermissionService::RequestPermission( @@ -216,7 +216,7 @@ RequestPermissionCallback callback) { V8WakeLockType::Enum type; if (!GetWakeLockTypeFromDescriptor(permission, &type)) { - std::move(callback).Run(PermissionStatus::DENIED); + std::move(callback).Run(mojom::blink::PermissionStatus::DENIED); return; } @@ -224,8 +224,8 @@ DCHECK(permission_responses_[pos].has_value()); if (request_permission_callbacks_[pos]) std::move(request_permission_callbacks_[pos]).Run(); - std::move(callback).Run( - permission_responses_[pos].value_or(PermissionStatus::DENIED)); + std::move(callback).Run(permission_responses_[pos].value_or( + mojom::blink::PermissionStatus::DENIED)); } void MockPermissionService::RequestPermissions( @@ -242,7 +242,7 @@ void MockPermissionService::AddPermissionObserver( PermissionDescriptorPtr permission, - PermissionStatus last_known_status, + mojom::blink::PermissionStatus last_known_status, mojo::PendingRemote<mojom::blink::PermissionObserver>) { NOTREACHED(); }
diff --git a/third_party/blink/renderer/modules/webaudio/audio_scheduled_source_node.cc b/third_party/blink/renderer/modules/webaudio/audio_scheduled_source_node.cc index 6b25505..a845b4f 100644 --- a/third_party/blink/renderer/modules/webaudio/audio_scheduled_source_node.cc +++ b/third_party/blink/renderer/modules/webaudio/audio_scheduled_source_node.cc
@@ -41,7 +41,7 @@ namespace blink { AudioScheduledSourceNode::AudioScheduledSourceNode(BaseAudioContext& context) - : AudioNode(context) {} + : AudioNode(context), ActiveScriptWrappable<AudioScheduledSourceNode>({}) {} AudioScheduledSourceHandler& AudioScheduledSourceNode::GetAudioScheduledSourceHandler() const {
diff --git a/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc b/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc index d226460..fca07d7 100644 --- a/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc +++ b/third_party/blink/renderer/modules/webaudio/audio_worklet_node.cc
@@ -39,7 +39,9 @@ const AudioWorkletNodeOptions* options, const Vector<CrossThreadAudioParamInfo> param_info_list, MessagePort* node_port) - : AudioNode(context), node_port_(node_port) { + : AudioNode(context), + ActiveScriptWrappable<AudioWorkletNode>({}), + node_port_(node_port) { HeapHashMap<String, Member<AudioParam>> audio_param_map; HashMap<String, scoped_refptr<AudioParamHandler>> param_handler_map; for (const auto& param_info : param_info_list) {
diff --git a/third_party/blink/renderer/modules/webaudio/base_audio_context.cc b/third_party/blink/renderer/modules/webaudio/base_audio_context.cc index bd52135..14e86ce 100644 --- a/third_party/blink/renderer/modules/webaudio/base_audio_context.cc +++ b/third_party/blink/renderer/modules/webaudio/base_audio_context.cc
@@ -88,7 +88,8 @@ // Constructor for rendering to the audio hardware. BaseAudioContext::BaseAudioContext(Document* document, enum ContextType context_type) - : ExecutionContextLifecycleStateObserver(document->GetExecutionContext()), + : ActiveScriptWrappable<BaseAudioContext>({}), + ExecutionContextLifecycleStateObserver(document->GetExecutionContext()), InspectorHelperMixin(*AudioGraphTracer::FromDocument(*document), String()), destination_node_(nullptr),
diff --git a/third_party/blink/renderer/modules/webaudio/inspector_web_audio_agent.cc b/third_party/blink/renderer/modules/webaudio/inspector_web_audio_agent.cc index ce1eb7a2..acff74ed1 100644 --- a/third_party/blink/renderer/modules/webaudio/inspector_web_audio_agent.cc +++ b/third_party/blink/renderer/modules/webaudio/inspector_web_audio_agent.cc
@@ -55,8 +55,6 @@ } // namespace -using protocol::Response; - InspectorWebAudioAgent::InspectorWebAudioAgent(Page* page) : page_(page), enabled_(&agent_state_, /*default_value=*/false) { @@ -73,41 +71,42 @@ graph_tracer->SetInspectorAgent(this); } -Response InspectorWebAudioAgent::enable() { +protocol::Response InspectorWebAudioAgent::enable() { if (enabled_.Get()) { - return Response::Success(); + return protocol::Response::Success(); } enabled_.Set(true); AudioGraphTracer* graph_tracer = AudioGraphTracer::FromPage(page_); graph_tracer->SetInspectorAgent(this); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorWebAudioAgent::disable() { +protocol::Response InspectorWebAudioAgent::disable() { if (!enabled_.Get()) { - return Response::Success(); + return protocol::Response::Success(); } enabled_.Clear(); AudioGraphTracer* graph_tracer = AudioGraphTracer::FromPage(page_); graph_tracer->SetInspectorAgent(nullptr); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorWebAudioAgent::getRealtimeData( +protocol::Response InspectorWebAudioAgent::getRealtimeData( const protocol::WebAudio::GraphObjectId& contextId, std::unique_ptr<ContextRealtimeData>* out_data) { auto* const graph_tracer = AudioGraphTracer::FromPage(page_); if (!enabled_.Get()) { - return Response::ServerError("Enable agent first."); + return protocol::Response::ServerError("Enable agent first."); } BaseAudioContext* context = graph_tracer->GetContextById(contextId); if (!context) { - return Response::ServerError("Cannot find BaseAudioContext with such id."); + return protocol::Response::ServerError( + "Cannot find BaseAudioContext with such id."); } if (!context->HasRealtimeConstraint()) { - return Response::ServerError( + return protocol::Response::ServerError( "ContextRealtimeData is only avaliable for an AudioContext."); } @@ -120,7 +119,7 @@ .setCallbackIntervalMean(metric.mean_callback_interval) .setCallbackIntervalVariance(metric.variance_callback_interval) .build(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorWebAudioAgent::DidCreateBaseAudioContext(
diff --git a/third_party/blink/renderer/modules/webaudio/media_element_audio_source_node.cc b/third_party/blink/renderer/modules/webaudio/media_element_audio_source_node.cc index ef60a484..4ac19fa3 100644 --- a/third_party/blink/renderer/modules/webaudio/media_element_audio_source_node.cc +++ b/third_party/blink/renderer/modules/webaudio/media_element_audio_source_node.cc
@@ -46,7 +46,9 @@ MediaElementAudioSourceNode::MediaElementAudioSourceNode( AudioContext& context, HTMLMediaElement& media_element) - : AudioNode(context), media_element_(&media_element) { + : AudioNode(context), + ActiveScriptWrappable<MediaElementAudioSourceNode>({}), + media_element_(&media_element) { SetHandler(MediaElementAudioSourceHandler::Create(*this, media_element)); }
diff --git a/third_party/blink/renderer/modules/webaudio/media_stream_audio_source_node.cc b/third_party/blink/renderer/modules/webaudio/media_stream_audio_source_node.cc index deae021..ef62a1b 100644 --- a/third_party/blink/renderer/modules/webaudio/media_stream_audio_source_node.cc +++ b/third_party/blink/renderer/modules/webaudio/media_stream_audio_source_node.cc
@@ -41,6 +41,7 @@ MediaStreamTrack* audio_track, std::unique_ptr<AudioSourceProvider> audio_source_provider) : AudioNode(context), + ActiveScriptWrappable<MediaStreamAudioSourceNode>({}), audio_track_(audio_track), media_stream_(media_stream) { SetHandler(MediaStreamAudioSourceHandler::Create(
diff --git a/third_party/blink/renderer/modules/webaudio/script_processor_node.cc b/third_party/blink/renderer/modules/webaudio/script_processor_node.cc index 6afc07f..91d824f 100644 --- a/third_party/blink/renderer/modules/webaudio/script_processor_node.cc +++ b/third_party/blink/renderer/modules/webaudio/script_processor_node.cc
@@ -31,6 +31,7 @@ #include "base/trace_event/trace_event.h" #include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/task_type.h" +#include "third_party/blink/renderer/bindings/core/v8/active_script_wrappable_creation_key.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/inspector/console_message.h" @@ -92,7 +93,7 @@ uint32_t buffer_size, uint32_t number_of_input_channels, uint32_t number_of_output_channels) - : AudioNode(context) { + : AudioNode(context), ActiveScriptWrappable<ScriptProcessorNode>({}) { // Regardless of the allowed buffer sizes, we still need to process at the // granularity of the AudioNode. if (buffer_size < context.GetDeferredTaskHandler().RenderQuantumFrames()) {
diff --git a/third_party/blink/renderer/modules/webcodecs/decoder_template.cc b/third_party/blink/renderer/modules/webcodecs/decoder_template.cc index 9471e97..6d047fc 100644 --- a/third_party/blink/renderer/modules/webcodecs/decoder_template.cc +++ b/third_party/blink/renderer/modules/webcodecs/decoder_template.cc
@@ -73,7 +73,8 @@ DecoderTemplate<Traits>::DecoderTemplate(ScriptState* script_state, const InitType* init, ExceptionState& exception_state) - : ReclaimableCodec(ReclaimableCodec::CodecType::kDecoder, + : ActiveScriptWrappable<DecoderTemplate<Traits>>({}), + ReclaimableCodec(ReclaimableCodec::CodecType::kDecoder, ExecutionContext::From(script_state)), script_state_(script_state), state_(V8CodecState::Enum::kUnconfigured),
diff --git a/third_party/blink/renderer/modules/webcodecs/encoder_base.cc b/third_party/blink/renderer/modules/webcodecs/encoder_base.cc index 671758b6..3c325cd 100644 --- a/third_party/blink/renderer/modules/webcodecs/encoder_base.cc +++ b/third_party/blink/renderer/modules/webcodecs/encoder_base.cc
@@ -62,7 +62,8 @@ EncoderBase<Traits>::EncoderBase(ScriptState* script_state, const InitType* init, ExceptionState& exception_state) - : ReclaimableCodec(ReclaimableCodec::CodecType::kEncoder, + : ActiveScriptWrappable<EncoderBase<Traits>>({}), + ReclaimableCodec(ReclaimableCodec::CodecType::kEncoder, ExecutionContext::From(script_state)), state_(V8CodecState::Enum::kUnconfigured), script_state_(script_state),
diff --git a/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc b/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc index c5741a91..4e9802a4 100644 --- a/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc +++ b/third_party/blink/renderer/modules/webcodecs/image_decoder_external.cc
@@ -119,7 +119,8 @@ ImageDecoderExternal::ImageDecoderExternal(ScriptState* script_state, const ImageDecoderInit* init, ExceptionState& exception_state) - : ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), + : ActiveScriptWrappable<ImageDecoderExternal>({}), + ExecutionContextLifecycleObserver(ExecutionContext::From(script_state)), script_state_(script_state), tracks_(MakeGarbageCollected<ImageTrackList>(this)), completed_property_(
diff --git a/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc b/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc index eb217331..054330b 100644 --- a/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc +++ b/third_party/blink/renderer/modules/webdatabase/inspector_database_agent.cc
@@ -49,7 +49,6 @@ namespace blink { using protocol::Maybe; -using protocol::Response; namespace { @@ -232,22 +231,22 @@ WrapPersistent(this))); } -Response InspectorDatabaseAgent::enable() { +protocol::Response InspectorDatabaseAgent::enable() { if (enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Set(true); InnerEnable(); - return Response::Success(); + return protocol::Response::Success(); } -Response InspectorDatabaseAgent::disable() { +protocol::Response InspectorDatabaseAgent::disable() { if (!enabled_.Get()) - return Response::Success(); + return protocol::Response::Success(); enabled_.Set(false); if (DatabaseClient* client = DatabaseClient::FromPage(page_)) client->SetInspectorAgent(nullptr); resources_.clear(); - return Response::Success(); + return protocol::Response::Success(); } void InspectorDatabaseAgent::Restore() { @@ -255,11 +254,11 @@ InnerEnable(); } -Response InspectorDatabaseAgent::getDatabaseTableNames( +protocol::Response InspectorDatabaseAgent::getDatabaseTableNames( const String& database_id, std::unique_ptr<protocol::Array<String>>* names) { if (!enabled_.Get()) - return Response::ServerError("Database agent is not enabled"); + return protocol::Response::ServerError("Database agent is not enabled"); blink::Database* database = DatabaseForId(database_id); if (database) { @@ -269,7 +268,7 @@ } else { *names = std::make_unique<protocol::Array<String>>(); } - return Response::Success(); + return protocol::Response::Success(); } void InspectorDatabaseAgent::executeSQL( @@ -278,13 +277,14 @@ std::unique_ptr<ExecuteSQLCallback> request_callback) { if (!enabled_.Get()) { request_callback->sendFailure( - Response::ServerError("Database agent is not enabled")); + protocol::Response::ServerError("Database agent is not enabled")); return; } blink::Database* database = DatabaseForId(database_id); if (!database) { - request_callback->sendFailure(Response::ServerError("Database not found")); + request_callback->sendFailure( + protocol::Response::ServerError("Database not found")); return; }
diff --git a/third_party/blink/renderer/modules/webmidi/midi_access.cc b/third_party/blink/renderer/modules/webmidi/midi_access.cc index f5a8601..44b5734 100644 --- a/third_party/blink/renderer/modules/webmidi/midi_access.cc +++ b/third_party/blink/renderer/modules/webmidi/midi_access.cc
@@ -69,7 +69,8 @@ bool sysex_enabled, const Vector<MIDIAccessInitializer::PortDescriptor>& ports, ExecutionContext* execution_context) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<MIDIAccess>({}), + ExecutionContextLifecycleObserver(execution_context), dispatcher_(dispatcher), sysex_enabled_(sysex_enabled), has_pending_activity_(false) {
diff --git a/third_party/blink/renderer/modules/webmidi/midi_access_initializer.cc b/third_party/blink/renderer/modules/webmidi/midi_access_initializer.cc index 042965e..220185b 100644 --- a/third_party/blink/renderer/modules/webmidi/midi_access_initializer.cc +++ b/third_party/blink/renderer/modules/webmidi/midi_access_initializer.cc
@@ -26,7 +26,6 @@ using midi::mojom::PortState; using midi::mojom::Result; -using mojom::blink::PermissionStatus; MIDIAccessInitializer::MIDIAccessInitializer(ScriptState* script_state, const MIDIOptions* options) @@ -136,9 +135,10 @@ dispatcher_->SetClient(this); } -void MIDIAccessInitializer::OnPermissionsUpdated(PermissionStatus status) { +void MIDIAccessInitializer::OnPermissionsUpdated( + mojom::blink::PermissionStatus status) { permission_service_.reset(); - if (status == PermissionStatus::GRANTED) { + if (status == mojom::blink::PermissionStatus::GRANTED) { StartSession(); } else { Reject( @@ -146,9 +146,10 @@ } } -void MIDIAccessInitializer::OnPermissionUpdated(PermissionStatus status) { +void MIDIAccessInitializer::OnPermissionUpdated( + mojom::blink::PermissionStatus status) { permission_service_.reset(); - if (status == PermissionStatus::GRANTED) { + if (status == mojom::blink::PermissionStatus::GRANTED) { StartSession(); } else { Reject(
diff --git a/third_party/blink/renderer/modules/webmidi/midi_port.cc b/third_party/blink/renderer/modules/webmidi/midi_port.cc index 73be814..35c0ac0b 100644 --- a/third_party/blink/renderer/modules/webmidi/midi_port.cc +++ b/third_party/blink/renderer/modules/webmidi/midi_port.cc
@@ -53,7 +53,8 @@ MIDIPortType type, const String& version, PortState state) - : ExecutionContextLifecycleObserver(access->GetExecutionContext()), + : ActiveScriptWrappable<MIDIPort>({}), + ExecutionContextLifecycleObserver(access->GetExecutionContext()), id_(id), manufacturer_(manufacturer), name_(name),
diff --git a/third_party/blink/renderer/modules/websockets/dom_websocket.cc b/third_party/blink/renderer/modules/websockets/dom_websocket.cc index 467102d..556e5ae 100644 --- a/third_party/blink/renderer/modules/websockets/dom_websocket.cc +++ b/third_party/blink/renderer/modules/websockets/dom_websocket.cc
@@ -172,7 +172,8 @@ constexpr WebSocketCommon::State DOMWebSocket::kClosed; DOMWebSocket::DOMWebSocket(ExecutionContext* context) - : ExecutionContextLifecycleStateObserver(context), + : ActiveScriptWrappable<DOMWebSocket>({}), + ExecutionContextLifecycleStateObserver(context), buffered_amount_(0), consumed_buffered_amount_(0), buffered_amount_after_close_(0),
diff --git a/third_party/blink/renderer/modules/websockets/websocket_stream.cc b/third_party/blink/renderer/modules/websockets/websocket_stream.cc index 72f5fc0..6a350358 100644 --- a/third_party/blink/renderer/modules/websockets/websocket_stream.cc +++ b/third_party/blink/renderer/modules/websockets/websocket_stream.cc
@@ -436,7 +436,8 @@ WebSocketStream::WebSocketStream(ExecutionContext* execution_context, ScriptState* script_state) - : ExecutionContextLifecycleObserver(execution_context), + : ActiveScriptWrappable<WebSocketStream>({}), + ExecutionContextLifecycleObserver(execution_context), script_state_(script_state), connection_resolver_( MakeGarbageCollected<ScriptPromiseResolver>(script_state)),
diff --git a/third_party/blink/renderer/modules/webtransport/web_transport.cc b/third_party/blink/renderer/modules/webtransport/web_transport.cc index e23787b1..5be71aa 100644 --- a/third_party/blink/renderer/modules/webtransport/web_transport.cc +++ b/third_party/blink/renderer/modules/webtransport/web_transport.cc
@@ -754,7 +754,8 @@ WebTransport::WebTransport(ScriptState* script_state, const String& url, ExecutionContext* context) - : ExecutionContextLifecycleObserver(context), + : ActiveScriptWrappable<WebTransport>({}), + ExecutionContextLifecycleObserver(context), script_state_(script_state), url_(NullURL(), url), connector_(context),
diff --git a/third_party/blink/renderer/modules/xr/xr_session.cc b/third_party/blink/renderer/modules/xr/xr_session.cc index 768ff34..cce8a6ec 100644 --- a/third_party/blink/renderer/modules/xr/xr_session.cc +++ b/third_party/blink/renderer/modules/xr/xr_session.cc
@@ -344,7 +344,8 @@ device::mojom::blink::XRSessionDeviceConfigPtr device_config, bool sensorless_session, XRSessionFeatureSet enabled_features) - : xr_(xr), + : ActiveScriptWrappable<XRSession>({}), + xr_(xr), mode_(mode), environment_integration_( mode == device::mojom::blink::XRSessionMode::kImmersiveAr),