chromium/content/browser/devtools/service_worker_devtools_agent_host.cc

// Copyright 2014 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/service_worker_devtools_agent_host.h"

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "content/browser/devtools/devtools_renderer_channel.h"
#include "content/browser/devtools/devtools_session.h"
#include "content/browser/devtools/network_service_devtools_observer.h"
#include "content/browser/devtools/protocol/fetch_handler.h"
#include "content/browser/devtools/protocol/inspector_handler.h"
#include "content/browser/devtools/protocol/io_handler.h"
#include "content/browser/devtools/protocol/network_handler.h"
#include "content/browser/devtools/protocol/protocol.h"
#include "content/browser/devtools/protocol/schema_handler.h"
#include "content/browser/devtools/protocol/target_handler.h"
#include "content/browser/devtools/service_worker_devtools_manager.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/browser/storage_partition_impl.h"
#include "content/browser/url_loader_factory_params_helper.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/cookies/site_for_cookies.h"
#include "services/network/public/mojom/client_security_state.mojom.h"
#include "services/network/public/mojom/network_context.mojom-forward.h"

namespace content {

namespace {

/*
 In addition to watching for dedicated workers (as all auto-attachers dealing
 with renderer targets do), the service worker auto-attacher below would also
 watch for the new versions of the same service workers. While these may
 already be covered by the parent page auto-attacher, this is essemtial for
 supporting a client that is only attached to the service worker target.
 Please note that this may result with multiple `AutoAttach()` calls to
 the client, but that's ok, as the client only sends CDP notifications for
 that tatgets it hasn't seen previously.
 Here is an example scenario.

      Client                                    Backend
                                           (SW v1 created)
 Target.getTargets()                   ->
 Target.attachTarget(SW_v1)            ->
 Target.autoAttachRelated(SW_v1)       ->
                                           (SW v2 created)
                                       <-  Target.attachedToTarget(SW_v2)
 Target.autoAttachRelated(SW_v2)       ->
 Runtime.runIfWaitingForDebugger       ->
                                           (SW v1 stopped)
                                           Target.detachedFromTarget(SW_v1)
*/

class ServiceWorkerAutoAttacher
    : public protocol::RendererAutoAttacherBase,
      public ServiceWorkerDevToolsManager::Observer {};

}  // namespace

// static
scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForServiceWorker(
    ServiceWorkerContext* context,
    int64_t version_id) {}

ServiceWorkerDevToolsAgentHost::ServiceWorkerDevToolsAgentHost(
    int worker_process_id,
    int worker_route_id,
    scoped_refptr<ServiceWorkerContextWrapper> context_wrapper,
    int64_t version_id,
    const GURL& url,
    const GURL& scope,
    bool is_installed_version,
    network::mojom::ClientSecurityStatePtr client_security_state,
    mojo::PendingRemote<network::mojom::CrossOriginEmbedderPolicyReporter>
        coep_reporter,
    const base::UnguessableToken& devtools_worker_token)
    :{}

BrowserContext* ServiceWorkerDevToolsAgentHost::GetBrowserContext() {}

std::string ServiceWorkerDevToolsAgentHost::GetType() {}

std::string ServiceWorkerDevToolsAgentHost::GetTitle() {}

GURL ServiceWorkerDevToolsAgentHost::GetURL() {}

bool ServiceWorkerDevToolsAgentHost::Activate() {}

void ServiceWorkerDevToolsAgentHost::Reload() {}

bool ServiceWorkerDevToolsAgentHost::Close() {}

void ServiceWorkerDevToolsAgentHost::WorkerVersionInstalled() {}

void ServiceWorkerDevToolsAgentHost::WorkerVersionDoomed() {}

void ServiceWorkerDevToolsAgentHost::WorkerMainScriptFetchingFailed() {}

ServiceWorkerDevToolsAgentHost::~ServiceWorkerDevToolsAgentHost() {}

bool ServiceWorkerDevToolsAgentHost::AttachSession(DevToolsSession* session,
                                                   bool acquire_wake_lock) {}

void ServiceWorkerDevToolsAgentHost::DetachSession(DevToolsSession* session) {}

protocol::TargetAutoAttacher* ServiceWorkerDevToolsAgentHost::auto_attacher() {}

void ServiceWorkerDevToolsAgentHost::WorkerReadyForInspection(
    mojo::PendingRemote<blink::mojom::DevToolsAgent> agent_remote,
    mojo::PendingReceiver<blink::mojom::DevToolsAgentHost> host_receiver) {}

void ServiceWorkerDevToolsAgentHost::UpdateClientSecurityState(
    network::mojom::ClientSecurityStatePtr client_security_state,
    mojo::PendingRemote<network::mojom::CrossOriginEmbedderPolicyReporter>
        coep_reporter) {}

void ServiceWorkerDevToolsAgentHost::WorkerStarted(int worker_process_id,
                                                   int worker_route_id) {}

void ServiceWorkerDevToolsAgentHost::WorkerStopped() {}

void ServiceWorkerDevToolsAgentHost::UpdateIsAttached(bool attached) {}

void ServiceWorkerDevToolsAgentHost::UpdateProcessHost() {}

void ServiceWorkerDevToolsAgentHost::RenderProcessHostDestroyed(
    RenderProcessHost* host) {}

void ServiceWorkerDevToolsAgentHost::UpdateLoaderFactories(
    base::OnceClosure callback) {}

DevToolsAgentHostImpl::NetworkLoaderFactoryParamsAndInfo
ServiceWorkerDevToolsAgentHost::CreateNetworkFactoryParamsForDevTools() {}

RenderProcessHost* ServiceWorkerDevToolsAgentHost::GetProcessHost() {}

std::optional<network::CrossOriginEmbedderPolicy>
ServiceWorkerDevToolsAgentHost::cross_origin_embedder_policy(
    const std::string&) {}

void ServiceWorkerDevToolsAgentHost::set_should_pause_on_start(
    bool should_pause_on_start) {}

}  // namespace content