#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/inspector/devtools_session.h"
#include <string>
#include <utility>
#include <vector>
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/inspector/devtools_agent.h"
#include "third_party/blink/renderer/core/inspector/inspected_frames.h"
#include "third_party/blink/renderer/core/inspector/inspector_base_agent.h"
#include "third_party/blink/renderer/core/inspector/inspector_session_state.h"
#include "third_party/blink/renderer/core/inspector/inspector_task_runner.h"
#include "third_party/blink/renderer/core/inspector/protocol/protocol.h"
#include "third_party/blink/renderer/core/inspector/v8_inspector_string.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/platform/heap/cross_thread_handle.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/web_test_support.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_mojo.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/text/string_utf8_adaptor.h"
#include "third_party/inspector_protocol/crdtp/cbor.h"
#include "third_party/inspector_protocol/crdtp/dispatch.h"
#include "third_party/inspector_protocol/crdtp/json.h"
namespace blink {
namespace {
const char kV8StateKey[] = …;
const char kSessionId[] = …;
bool ShouldInterruptForMethod(const String& method) { … }
std::vector<uint8_t> Get8BitStringFrom(v8_inspector::StringBuffer* msg) { … }
}
class DevToolsSession::IOSession : public mojom::blink::DevToolsSession { … };
DevToolsSession::DevToolsSession(
DevToolsAgent* agent,
mojo::PendingAssociatedRemote<mojom::blink::DevToolsSessionHost>
host_remote,
mojo::PendingAssociatedReceiver<mojom::blink::DevToolsSession>
main_receiver,
mojo::PendingReceiver<mojom::blink::DevToolsSession> io_receiver,
mojom::blink::DevToolsSessionStatePtr reattach_session_state,
bool client_expects_binary_responses,
bool client_is_trusted,
const String& session_id,
bool session_waits_for_debugger,
scoped_refptr<base::SequencedTaskRunner> mojo_task_runner)
: … { … }
DevToolsSession::~DevToolsSession() { … }
void DevToolsSession::ConnectToV8(v8_inspector::V8Inspector* inspector,
int context_group_id) { … }
bool DevToolsSession::IsDetached() { … }
void DevToolsSession::Append(InspectorAgent* agent) { … }
void DevToolsSession::Detach() { … }
void DevToolsSession::DetachFromV8() { … }
void DevToolsSession::DispatchProtocolCommand(
int call_id,
const String& method,
base::span<const uint8_t> message) { … }
void DevToolsSession::DispatchProtocolCommandImpl(
int call_id,
const String& method,
base::span<const uint8_t> data) { … }
void DevToolsSession::DidStartProvisionalLoad(LocalFrame* frame) { … }
void DevToolsSession::DidFailProvisionalLoad(LocalFrame* frame) { … }
void DevToolsSession::DidCommitLoad(LocalFrame* frame, DocumentLoader*) { … }
void DevToolsSession::PaintTiming(Document* document,
const char* name,
double timestamp) { … }
void DevToolsSession::DomContentLoadedEventFired(LocalFrame* local_frame) { … }
void DevToolsSession::SendProtocolResponse(
int call_id,
std::unique_ptr<protocol::Serializable> message) { … }
void DevToolsSession::FallThrough(int call_id,
crdtp::span<uint8_t> method,
crdtp::span<uint8_t> message) { … }
void DevToolsSession::sendResponse(
int call_id,
std::unique_ptr<v8_inspector::StringBuffer> message) { … }
void DevToolsSession::SendProtocolResponse(int call_id,
std::vector<uint8_t> message) { … }
void DevToolsSession::SendProtocolNotification(
std::unique_ptr<protocol::Serializable> notification) { … }
void DevToolsSession::sendNotification(
std::unique_ptr<v8_inspector::StringBuffer> notification) { … }
void DevToolsSession::flushProtocolNotifications() { … }
void DevToolsSession::FlushProtocolNotifications() { … }
void DevToolsSession::Trace(Visitor* visitor) const { … }
blink::mojom::blink::DevToolsMessagePtr DevToolsSession::FinalizeMessage(
std::vector<uint8_t> message) const { … }
}