chromium/content/services/auction_worklet/auction_v8_devtools_session.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/services/auction_worklet/auction_v8_devtools_session.h"

#include <stdint.h>

#include <set>
#include <string>
#include <vector>

#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/sequence_checker.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "content/services/auction_worklet/auction_v8_helper.h"
#include "content/services/auction_worklet/auction_v8_inspector_util.h"
#include "content/services/auction_worklet/debug_command_queue.h"
#include "content/services/auction_worklet/protocol/event_breakpoints.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/inspector_protocol/crdtp/cbor.h"
#include "third_party/inspector_protocol/crdtp/dispatch.h"
#include "third_party/inspector_protocol/crdtp/frontend_channel.h"
#include "third_party/inspector_protocol/crdtp/json.h"
#include "third_party/inspector_protocol/crdtp/protocol_core.h"
#include "third_party/inspector_protocol/crdtp/span.h"

namespace auction_worklet {

// BreakpointHandler implements the
// EventBreakpoints.setInstrumentationBreakpoint and
// EventBreakpoints.removeInstrumentationBreakpoint messages.
class AuctionV8DevToolsSession::BreakpointHandler
    : public auction_worklet::protocol::EventBreakpoints::Backend {};

// IOSession, which handles the pipe passed to the `io_session` parameter of
// DevToolsAgent::AttachDevToolsSession(), runs on a non-V8 sequence (except
// creation happens on the V8 thread). It's owned by the corresponding pipe.
//
// Its task is to forward messages to the v8 thread via DebugCommandQueue, with
// the `v8_thread_dispatch` callback being asked to run there to execute the
// command. The callback is responsible for dealing with possibility of the main
// session object being deleted.
class AuctionV8DevToolsSession::IOSession
    : public blink::mojom::DevToolsSession {};

AuctionV8DevToolsSession::AuctionV8DevToolsSession(
    AuctionV8Helper* v8_helper,
    scoped_refptr<DebugCommandQueue> debug_command_queue,
    int context_group_id,
    const std::string& session_id,
    bool client_expects_binary_responses,
    bool session_waits_for_debugger,
    mojo::PendingAssociatedRemote<blink::mojom::DevToolsSessionHost> host,
    scoped_refptr<base::SequencedTaskRunner> io_session_receiver_sequence,
    mojo::PendingReceiver<blink::mojom::DevToolsSession> io_session_receiver,
    SessionDestroyedCallback on_delete_callback)
    :{}

AuctionV8DevToolsSession::~AuctionV8DevToolsSession() {}

base::OnceClosure AuctionV8DevToolsSession::MakeAbortPauseCallback() {}

void AuctionV8DevToolsSession::MaybeTriggerInstrumentationBreakpoint(
    const std::string& name) {}

void AuctionV8DevToolsSession::DispatchProtocolCommandFromIO(
    int32_t call_id,
    const std::string& method,
    std::vector<uint8_t> message) {}

void AuctionV8DevToolsSession::DispatchProtocolCommand(
    int32_t call_id,
    const std::string& method,
    base::span<const uint8_t> message) {}

void AuctionV8DevToolsSession::sendResponse(
    int call_id,
    std::unique_ptr<v8_inspector::StringBuffer> message) {}

void AuctionV8DevToolsSession::sendNotification(
    std::unique_ptr<v8_inspector::StringBuffer> message) {}

void AuctionV8DevToolsSession::flushProtocolNotifications() {}

void AuctionV8DevToolsSession::SendProtocolResponse(
    int call_id,
    std::unique_ptr<crdtp::Serializable> message) {}

void AuctionV8DevToolsSession::SendProtocolNotification(
    std::unique_ptr<crdtp::Serializable> message) {}

void AuctionV8DevToolsSession::FallThrough(int call_id,
                                           crdtp::span<uint8_t> method,
                                           crdtp::span<uint8_t> message) {}

void AuctionV8DevToolsSession::FlushProtocolNotifications() {}

void AuctionV8DevToolsSession::AbortDebuggerPause() {}

void AuctionV8DevToolsSession::SendProtocolResponseImpl(
    int call_id,
    std::vector<uint8_t> message) {}

void AuctionV8DevToolsSession::SendNotificationImpl(
    std::vector<uint8_t> message) {}

// Add session ID and maybe convert the message into JSON format, as
// documented as requirements in DevToolsAgent.AttachDevToolsSession mojo
// method documentation, and then encapsulate it inside a mojo
// DevToolsMessage.
//
// This is pretty much a copy-paste job from
// third_party/blink/renderer/core/inspector/devtools_session.cc, just with
// content types.
blink::mojom::DevToolsMessagePtr AuctionV8DevToolsSession::FinalizeMessage(
    std::vector<uint8_t> message) const {}

}  // namespace auction_worklet