#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "content/browser/service_worker/service_worker_internals_ui.h"
#include <stdint.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "content/browser/devtools/devtools_agent_host_impl.h"
#include "content/browser/devtools/service_worker_devtools_agent_host.h"
#include "content/browser/devtools/service_worker_devtools_manager.h"
#include "content/browser/service_worker/service_worker_context_core_observer.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/grit/service_worker_resources.h"
#include "content/grit/service_worker_resources_map.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_host.h"
#include "content/public/browser/console_message.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/url_constants.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
#include "third_party/blink/public/common/service_worker/embedded_worker_status.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom.h"
Value;
WeakPtr;
namespace content {
namespace {
GetRegistrationsCallback;
void OperationCompleteCallback(WeakPtr<ServiceWorkerInternalsHandler> internals,
const std::string& callback_id,
blink::ServiceWorkerStatusCode status) { … }
base::ProcessId GetRealProcessId(int process_host_id) { … }
base::Value::Dict UpdateVersionInfo(const ServiceWorkerVersionInfo& version) { … }
base::Value::List GetRegistrationListValue(
const std::vector<ServiceWorkerRegistrationInfo>& registrations) { … }
base::Value::List GetVersionListValue(
const std::vector<ServiceWorkerVersionInfo>& versions) { … }
void DidGetStoredRegistrations(
scoped_refptr<ServiceWorkerContextWrapper> context,
GetRegistrationsCallback callback,
blink::ServiceWorkerStatusCode status,
const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { … }
}
class ServiceWorkerInternalsHandler::PartitionObserver
: public ServiceWorkerContextCoreObserver { … };
ServiceWorkerInternalsUI::ServiceWorkerInternalsUI(WebUI* web_ui)
: … { … }
ServiceWorkerInternalsUI::~ServiceWorkerInternalsUI() = default;
ServiceWorkerInternalsHandler::ServiceWorkerInternalsHandler() = default;
void ServiceWorkerInternalsHandler::RegisterMessages() { … }
void ServiceWorkerInternalsHandler::OnJavascriptDisallowed() { … }
ServiceWorkerInternalsHandler::~ServiceWorkerInternalsHandler() { … }
void ServiceWorkerInternalsHandler::OnRunningStateChanged() { … }
void ServiceWorkerInternalsHandler::OnVersionStateChanged(int partition_id,
int64_t version_id) { … }
void ServiceWorkerInternalsHandler::OnVersionRouterRulesChanged() { … }
void ServiceWorkerInternalsHandler::OnErrorEvent(
const std::string& event_name,
int partition_id,
int64_t version_id,
const base::Value::Dict& details) { … }
void ServiceWorkerInternalsHandler::OnRegistrationEvent(
const std::string& event_name,
const GURL& scope) { … }
void ServiceWorkerInternalsHandler::OnDidGetRegistrations(
int partition_id,
const base::FilePath& context_path,
const std::vector<ServiceWorkerRegistrationInfo>& live_registrations,
const std::vector<ServiceWorkerVersionInfo>& live_versions,
const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations) { … }
void ServiceWorkerInternalsHandler::OnOperationComplete(
int status,
const std::string& callback_id) { … }
void ServiceWorkerInternalsHandler::HandleGetOptions(const Value::List& args) { … }
void ServiceWorkerInternalsHandler::HandleSetOption(
const Value::List& args_list) { … }
void ServiceWorkerInternalsHandler::HandleGetAllRegistrations(
const Value::List& args) { … }
void ServiceWorkerInternalsHandler::AddContextFromStoragePartition(
StoragePartition* partition) { … }
void ServiceWorkerInternalsHandler::RemoveObserverFromStoragePartition(
StoragePartition* partition) { … }
bool ServiceWorkerInternalsHandler::GetServiceWorkerContext(
int partition_id,
scoped_refptr<ServiceWorkerContextWrapper>* context) { … }
void ServiceWorkerInternalsHandler::HandleStopWorker(const Value::List& args) { … }
void ServiceWorkerInternalsHandler::HandleInspectWorker(
const Value::List& args) { … }
void ServiceWorkerInternalsHandler::HandleUnregister(const Value::List& args) { … }
void ServiceWorkerInternalsHandler::HandleStartWorker(const Value::List& args) { … }
void ServiceWorkerInternalsHandler::StopWorkerWithId(
scoped_refptr<ServiceWorkerContextWrapper> context,
int64_t version_id,
StatusCallback callback) { … }
void ServiceWorkerInternalsHandler::UnregisterWithScope(
scoped_refptr<ServiceWorkerContextWrapper> context,
const GURL& scope,
blink::StorageKey& storage_key,
ServiceWorkerInternalsHandler::StatusCallback callback) const { … }
}