chromium/content/browser/devtools/devtools_session.cc

// Copyright 2016 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/browser/devtools/devtools_session.h"

#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/containers/flat_set.h"
#include "base/debug/stack_trace.h"
#include "base/functional/bind.h"
#include "base/trace_event/trace_event.h"
#include "content/browser/devtools/devtools_manager.h"
#include "content/browser/devtools/protocol/devtools_domain_handler.h"
#include "content/browser/devtools/protocol/protocol.h"
#include "content/browser/devtools/render_frame_devtools_agent_host.h"
#include "content/public/browser/devtools_external_agent_proxy_delegate.h"
#include "content/public/browser/devtools_manager_delegate.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 content {
namespace {
// Keep in sync with WebDevToolsAgent::ShouldInterruptForMethod.
// TODO(petermarshall): find a way to share this.
bool ShouldSendOnIO(crdtp::span<uint8_t> method) {}

// During navigation, we only suspend the main-thread messages. The IO thread
// messages should go through so that the renderer can be woken up
// via the IO thread even if the renderer does not process message loops.
//
// In particular, we are looking to deadlocking the renderer when
// reloading the page during the instrumentation pause (crbug.com/1354043):
//
// - If we are in the pause, there is no way to commit or fail the navigation
//   in the renderer because the instrumentation pause does not process message
//   loops.
// - At the same time, the instrumentation pause could not wake up if
//   the resume message was blocked by the suspension of message sending during
//   navigation.
//
// To give the renderer a chance to wake up, we always forward the messages
// for the IO thread to the renderer.
bool ShouldSuspendDuringNavigation(crdtp::span<uint8_t> method) {}

// Async control commands (such as CSS.enable) are idempotant and can
// be safely replayed in the new RenderFrameHost. We will always forward
// them to the new renderer on cross process navigation. Main rationale for
// it is that the client doesn't expect such calls to fail in normal
// circumstances.
//
// Ideally all non-control async commands shoulds be listed here but we
// conservatively start with Runtime domain where the decision is more
// clear.
bool TerminateOnCrossProcessNavigation(crdtp::span<uint8_t> method) {}

const char kResumeMethod[] =;
const char kSessionId[] =;

// Clients match against this error message verbatim (http://crbug.com/1001678).
const char kTargetClosedMessage[] =;
const char kTargetCrashedMessage[] =;
}  // namespace

DevToolsSession::PendingMessage::PendingMessage(PendingMessage&&) = default;
DevToolsSession::PendingMessage::PendingMessage(int call_id,
                                                crdtp::span<uint8_t> method,
                                                crdtp::span<uint8_t> payload)
    :{}

DevToolsSession::PendingMessage::~PendingMessage() = default;

DevToolsSession::DevToolsSession(DevToolsAgentHostClient* client, Mode mode)
    :{}

DevToolsSession::DevToolsSession(DevToolsAgentHostClient* client,
                                 const std::string& session_id,
                                 DevToolsSession* parent,
                                 Mode mode)
    :{}

DevToolsSession::~DevToolsSession() {}

void DevToolsSession::SetAgentHost(DevToolsAgentHostImpl* agent_host) {}

void DevToolsSession::SetRuntimeResumeCallback(
    base::OnceClosure runtime_resume) {}

bool DevToolsSession::IsWaitingForDebuggerOnStart() const {}

void DevToolsSession::Dispose() {}

DevToolsSession* DevToolsSession::GetRootSession() {}

void DevToolsSession::AddHandler(
    std::unique_ptr<protocol::DevToolsDomainHandler> handler) {}

void DevToolsSession::SetBrowserOnly(bool browser_only) {}

void DevToolsSession::TurnIntoExternalProxy(
    DevToolsExternalAgentProxyDelegate* proxy_delegate) {}

void DevToolsSession::AttachToAgent(blink::mojom::DevToolsAgent* agent,
                                    bool force_using_io_session) {}

void DevToolsSession::MojoConnectionDestroyed() {}

// The client of the devtools session will call this method to send a message
// to handlers / agents that the session is connected with.
void DevToolsSession::DispatchProtocolMessage(
    base::span<const uint8_t> message) {}

void DevToolsSession::DispatchProtocolMessageInternal(
    crdtp::Dispatchable dispatchable,
    base::span<const uint8_t> message) {}

void DevToolsSession::HandleCommand(base::span<const uint8_t> message) {}

void DevToolsSession::HandleCommandInternal(crdtp::Dispatchable dispatchable,
                                            base::span<const uint8_t> message) {}

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

// This method implements DevtoolsAgentHostClientChannel and
// sends messages coming from the browser to the client.
void DevToolsSession::DispatchProtocolMessageToClient(
    std::vector<uint8_t> message) {}

content::DevToolsAgentHost* DevToolsSession::GetAgentHost() {}

content::DevToolsAgentHostClient* DevToolsSession::GetClient() {}

void DevToolsSession::DispatchToAgent(const PendingMessage& message) {}

void DevToolsSession::SuspendSendingMessagesToAgent() {}

void DevToolsSession::ResumeSendingMessagesToAgent() {}

void DevToolsSession::ClearPendingMessages(bool did_crash) {}

// The following methods handle responses or notifications coming from
// the browser to the client.
void DevToolsSession::SendProtocolResponse(
    int call_id,
    std::unique_ptr<protocol::Serializable> message) {}

void DevToolsSession::SendProtocolNotification(
    std::unique_ptr<protocol::Serializable> message) {}

void DevToolsSession::FlushProtocolNotifications() {}

// The following methods handle responses or notifications coming from the
// renderer (blink) to the client. It is important that these messages not be
// parsed and sent as is, since a renderer may be compromised; so therefore,
// we're not sending them via the DevToolsAgentHostClientChannel interface
// (::DispatchProtocolMessageToClient) but directly to the client instead.
static void DispatchProtocolResponseOrNotification(
    DevToolsAgentHostClient* client,
    DevToolsAgentHostImpl* agent_host,
    blink::mojom::DevToolsMessagePtr message) {}

void DevToolsSession::DispatchProtocolResponse(
    blink::mojom::DevToolsMessagePtr message,
    int call_id,
    blink::mojom::DevToolsSessionStatePtr updates) {}

void DevToolsSession::DispatchProtocolNotification(
    blink::mojom::DevToolsMessagePtr message,
    blink::mojom::DevToolsSessionStatePtr updates) {}

void DevToolsSession::DispatchOnClientHost(base::span<const uint8_t> message) {}

void DevToolsSession::ConnectionClosed() {}

void DevToolsSession::ApplySessionStateUpdates(
    blink::mojom::DevToolsSessionStatePtr updates) {}

DevToolsSession* DevToolsSession::AttachChildSession(
    const std::string& session_id,
    DevToolsAgentHostImpl* agent_host,
    DevToolsAgentHostClient* client,
    Mode mode,
    base::OnceClosure resume_callback) {}

void DevToolsSession::DetachChildSession(const std::string& session_id) {}

bool DevToolsSession::HasChildSession(const std::string& session_id) {}

void DevToolsSession::AddObserver(ChildObserver* obs) {}

void DevToolsSession::RemoveObserver(ChildObserver* obs) {}

}  // namespace content