#include "content/renderer/service_worker/web_service_worker_provider_impl.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "content/renderer/service_worker/service_worker_provider_context.h"
#include "content/renderer/service_worker/service_worker_type_converters.h"
#include "content/renderer/worker/fetch_client_settings_object_helpers.h"
#include "third_party/blink/public/common/messaging/message_port_channel.h"
#include "third_party/blink/public/common/service_worker/service_worker_scope_match.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_container_type.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration_options.mojom.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_provider_client.h"
#include "third_party/blink/public/platform/web_url.h"
WebURL;
namespace content {
namespace {
const char kLostConnectionErrorMessage[] = …;
template <typename T>
static std::string MojoEnumToString(T mojo_enum) { … }
}
WebServiceWorkerProviderImpl::WebServiceWorkerProviderImpl(
ServiceWorkerProviderContext* context)
: … { … }
WebServiceWorkerProviderImpl::~WebServiceWorkerProviderImpl() = default;
void WebServiceWorkerProviderImpl::SetClient(
blink::WebServiceWorkerProviderClient* client) { … }
void WebServiceWorkerProviderImpl::RegisterServiceWorker(
const WebURL& web_pattern,
const WebURL& web_script_url,
blink::mojom::ScriptType script_type,
blink::mojom::ServiceWorkerUpdateViaCache update_via_cache,
const blink::WebFetchClientSettingsObject& fetch_client_settings_object,
std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) { … }
void WebServiceWorkerProviderImpl::GetRegistration(
const blink::WebURL& web_document_url,
std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> callbacks) { … }
void WebServiceWorkerProviderImpl::GetRegistrations(
std::unique_ptr<WebServiceWorkerGetRegistrationsCallbacks> callbacks) { … }
void WebServiceWorkerProviderImpl::GetRegistrationForReady(
GetRegistrationForReadyCallback callback) { … }
bool WebServiceWorkerProviderImpl::ValidateScopeAndScriptURL(
const blink::WebURL& scope,
const blink::WebURL& script_url,
blink::WebString* error_message) { … }
void WebServiceWorkerProviderImpl::SetController(
blink::mojom::ServiceWorkerObjectInfoPtr controller,
const std::set<blink::mojom::WebFeature>& features,
bool should_notify_controller_change) { … }
void WebServiceWorkerProviderImpl::PostMessageToClient(
blink::mojom::ServiceWorkerObjectInfoPtr source,
blink::TransferableMessage message) { … }
void WebServiceWorkerProviderImpl::CountFeature(
blink::mojom::WebFeature feature) { … }
void WebServiceWorkerProviderImpl::OnRegistered(
std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks,
blink::mojom::ServiceWorkerErrorType error,
const std::optional<std::string>& error_msg,
blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) { … }
void WebServiceWorkerProviderImpl::OnDidGetRegistration(
std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> callbacks,
blink::mojom::ServiceWorkerErrorType error,
const std::optional<std::string>& error_msg,
blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) { … }
void WebServiceWorkerProviderImpl::OnDidGetRegistrations(
std::unique_ptr<WebServiceWorkerGetRegistrationsCallbacks> callbacks,
blink::mojom::ServiceWorkerErrorType error,
const std::optional<std::string>& error_msg,
std::optional<
std::vector<blink::mojom::ServiceWorkerRegistrationObjectInfoPtr>>
infos) { … }
void WebServiceWorkerProviderImpl::OnDidGetRegistrationForReady(
GetRegistrationForReadyCallback callback,
blink::mojom::ServiceWorkerRegistrationObjectInfoPtr registration) { … }
}