#include "content/browser/devtools/protocol/service_worker_handler.h"
#include <memory>
#include "base/containers/flat_set.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/background_sync/background_sync_context_impl.h"
#include "content/browser/background_sync/background_sync_manager.h"
#include "content/browser/devtools/service_worker_devtools_agent_host.h"
#include "content/browser/devtools/service_worker_devtools_manager.h"
#include "content/browser/devtools/shared_worker_devtools_manager.h"
#include "content/browser/renderer_host/frame_tree.h"
#include "content/browser/service_worker/service_worker_context_watcher.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_map.h"
#include "content/browser/web_contents/web_contents_impl.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/devtools_agent_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.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/push_messaging/push_messaging_status.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace protocol {
namespace {
const std::string GetVersionRunningStatusString(
blink::EmbeddedWorkerStatus running_status) { … }
const std::string GetVersionStatusString(
content::ServiceWorkerVersion::Status status) { … }
Response CreateDomainNotEnabledErrorResponse() { … }
Response CreateContextErrorResponse() { … }
Response CreateInvalidVersionIdErrorResponse() { … }
void DidFindRegistrationForDispatchSyncEvent(
scoped_refptr<BackgroundSyncContextImpl> sync_context,
const std::string& tag,
bool last_chance,
blink::ServiceWorkerStatusCode status,
scoped_refptr<content::ServiceWorkerRegistration> registration) { … }
void DidFindRegistrationForDispatchPeriodicSyncEvent(
scoped_refptr<BackgroundSyncContextImpl> sync_context,
const std::string& tag,
blink::ServiceWorkerStatusCode status,
scoped_refptr<content::ServiceWorkerRegistration> registration) { … }
}
ServiceWorkerHandler::ServiceWorkerHandler(bool allow_inspect_worker)
: … { … }
ServiceWorkerHandler::~ServiceWorkerHandler() = default;
void ServiceWorkerHandler::Wire(UberDispatcher* dispatcher) { … }
void ServiceWorkerHandler::SetRenderer(int process_host_id,
RenderFrameHostImpl* frame_host) { … }
Response ServiceWorkerHandler::Enable() { … }
Response ServiceWorkerHandler::Disable() { … }
Response ServiceWorkerHandler::Unregister(const std::string& scope_url) { … }
Response ServiceWorkerHandler::StartWorker(const std::string& scope_url) { … }
Response ServiceWorkerHandler::SkipWaiting(const std::string& scope_url) { … }
Response ServiceWorkerHandler::StopWorker(const std::string& version_id) { … }
void ServiceWorkerHandler::StopAllWorkers(
std::unique_ptr<StopAllWorkersCallback> callback) { … }
Response ServiceWorkerHandler::UpdateRegistration(
const std::string& scope_url) { … }
Response ServiceWorkerHandler::InspectWorker(const std::string& version_id) { … }
Response ServiceWorkerHandler::SetForceUpdateOnPageLoad(
bool force_update_on_page_load) { … }
Response ServiceWorkerHandler::DeliverPushMessage(
const std::string& origin,
const std::string& registration_id,
const std::string& data) { … }
Response ServiceWorkerHandler::DispatchSyncEvent(
const std::string& origin,
const std::string& registration_id,
const std::string& tag,
bool last_chance) { … }
Response ServiceWorkerHandler::DispatchPeriodicSyncEvent(
const std::string& origin,
const std::string& registration_id,
const std::string& tag) { … }
void ServiceWorkerHandler::OpenNewDevToolsWindow(int process_id,
int devtools_agent_route_id) { … }
void ServiceWorkerHandler::OnWorkerRegistrationUpdated(
const std::vector<ServiceWorkerRegistrationInfo>& registrations) { … }
void ServiceWorkerHandler::OnWorkerVersionUpdated(
const std::vector<ServiceWorkerVersionInfo>& versions) { … }
void ServiceWorkerHandler::OnErrorReported(
int64_t registration_id,
int64_t version_id,
const ServiceWorkerContextObserver::ErrorInfo& info) { … }
void ServiceWorkerHandler::ClearForceUpdate() { … }
}
}