#include "third_party/blink/renderer/core/inspector/devtools_agent.h"
#include <v8-inspector.h>
#include <memory>
#include "base/debug/crash_logging.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/dom/dom_node_ids.h"
#include "third_party/blink/renderer/core/exported/web_dev_tools_agent_impl.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/inspector/devtools_session.h"
#include "third_party/blink/renderer/core/inspector/inspected_frames.h"
#include "third_party/blink/renderer/core/inspector/inspector_task_runner.h"
#include "third_party/blink/renderer/core/inspector/worker_devtools_params.h"
#include "third_party/blink/renderer/core/inspector/worker_inspector_controller.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/platform/heap/cross_thread_handle.h"
#include "third_party/blink/renderer/platform/heap/persistent.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_mojo.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
namespace WTF {
StatePtr;
template <>
struct CrossThreadCopier<StatePtr>
: public CrossThreadCopierByValuePassThrough<StatePtr> { … };
}
namespace blink {
namespace {
DevToolsAgent* DevToolsAgentFromContext(ExecutionContext* execution_context) { … }
}
class DevToolsAgent::IOAgent : public mojom::blink::DevToolsAgent { … };
DevToolsAgent::DevToolsAgent(
Client* client,
InspectedFrames* inspected_frames,
CoreProbeSink* probe_sink,
scoped_refptr<InspectorTaskRunner> inspector_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
: … { … }
DevToolsAgent::~DevToolsAgent() = default;
void DevToolsAgent::Trace(Visitor* visitor) const { … }
void DevToolsAgent::Dispose() { … }
void DevToolsAgent::BindReceiverForWorker(
mojo::PendingRemote<mojom::blink::DevToolsAgentHost> host_remote,
mojo::PendingReceiver<mojom::blink::DevToolsAgent> receiver,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
void DevToolsAgent::BindReceiver(
mojo::PendingAssociatedRemote<mojom::blink::DevToolsAgentHost> host_remote,
mojo::PendingAssociatedReceiver<mojom::blink::DevToolsAgent> receiver,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
namespace {
void UpdateSessionCountCrashKey(int delta) { … }
}
void DevToolsAgent::AttachDevToolsSessionImpl(
mojo::PendingAssociatedRemote<mojom::blink::DevToolsSessionHost> host,
mojo::PendingAssociatedReceiver<mojom::blink::DevToolsSession>
session_receiver,
mojo::PendingReceiver<mojom::blink::DevToolsSession> io_session_receiver,
mojom::blink::DevToolsSessionStatePtr reattach_session_state,
bool client_expects_binary_responses,
bool client_is_trusted,
const WTF::String& session_id,
bool session_waits_for_debugger) { … }
void DevToolsAgent::DetachDevToolsSession(DevToolsSession* session) { … }
void DevToolsAgent::AttachDevToolsSession(
mojo::PendingAssociatedRemote<mojom::blink::DevToolsSessionHost> host,
mojo::PendingAssociatedReceiver<mojom::blink::DevToolsSession>
session_receiver,
mojo::PendingReceiver<mojom::blink::DevToolsSession> io_session_receiver,
mojom::blink::DevToolsSessionStatePtr reattach_session_state,
bool client_expects_binary_responses,
bool client_is_trusted,
const WTF::String& session_id,
bool session_waits_for_debugger) { … }
void DevToolsAgent::InspectElementImpl(const gfx::Point& point) { … }
void DevToolsAgent::InspectElement(const gfx::Point& point) { … }
void DevToolsAgent::FlushProtocolNotifications() { … }
void DevToolsAgent::DebuggerPaused() { … }
void DevToolsAgent::DebuggerResumed() { … }
void DevToolsAgent::ReportChildTargetsPostCallbackToIO(
bool report,
bool wait_for_debugger,
CrossThreadOnceClosure callback) { … }
void DevToolsAgent::ReportChildTargetsImpl(bool report,
bool wait_for_debugger,
base::OnceClosure callback) { … }
void DevToolsAgent::ReportChildTargets(bool report,
bool wait_for_debugger,
base::OnceClosure callback) { … }
std::unique_ptr<WorkerDevToolsParams> DevToolsAgent::WorkerThreadCreated(
ExecutionContext* parent_context,
WorkerThread* worker_thread,
const KURL& url,
const String& global_scope_name,
const std::optional<const blink::DedicatedWorkerToken>& token) { … }
void DevToolsAgent::WorkerThreadTerminated(ExecutionContext* parent_context,
WorkerThread* worker_thread) { … }
void DevToolsAgent::ReportChildTarget(std::unique_ptr<WorkerData> data) { … }
void DevToolsAgent::CleanupConnection() { … }
void DevToolsAgent::BringDevToolsWindowToFocus() { … }
}