#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope_proxy.h"
#include <memory>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "services/network/public/mojom/url_loader.mojom-blink.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_client.mojom-blink.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom-blink.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h"
#include "third_party/blink/public/web/modules/service_worker/web_service_worker_context_client.h"
#include "third_party/blink/public/web/web_serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fetch/headers.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/messaging/message_port.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/modules/exported/web_embedded_worker_impl.h"
#include "third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h"
#include "third_party/blink/renderer/modules/service_worker/wait_until_observer.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_response.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink {
ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() { … }
void ServiceWorkerGlobalScopeProxy::BindServiceWorker(
CrossVariantMojoReceiver<mojom::blink::ServiceWorkerInterfaceBase>
receiver) { … }
void ServiceWorkerGlobalScopeProxy::BindControllerServiceWorker(
CrossVariantMojoReceiver<mojom::blink::ControllerServiceWorkerInterfaceBase>
receiver) { … }
void ServiceWorkerGlobalScopeProxy::OnNavigationPreloadResponse(
int fetch_event_id,
std::unique_ptr<WebURLResponse> response,
mojo::ScopedDataPipeConsumerHandle data_pipe) { … }
void ServiceWorkerGlobalScopeProxy::OnNavigationPreloadError(
int fetch_event_id,
std::unique_ptr<WebServiceWorkerError> error) { … }
void ServiceWorkerGlobalScopeProxy::OnNavigationPreloadComplete(
int fetch_event_id,
base::TimeTicks completion_time,
int64_t encoded_data_length,
int64_t encoded_body_length,
int64_t decoded_body_length) { … }
void ServiceWorkerGlobalScopeProxy::CountFeature(WebFeature feature) { … }
void ServiceWorkerGlobalScopeProxy::ReportException(
const String& error_message,
std::unique_ptr<SourceLocation> location,
int exception_id) { … }
void ServiceWorkerGlobalScopeProxy::ReportConsoleMessage(
mojom::ConsoleMessageSource source,
mojom::ConsoleMessageLevel level,
const String& message,
SourceLocation* location) { … }
void ServiceWorkerGlobalScopeProxy::WillInitializeWorkerContext() { … }
void ServiceWorkerGlobalScopeProxy::DidCreateWorkerGlobalScope(
WorkerOrWorkletGlobalScope* worker_global_scope) { … }
void ServiceWorkerGlobalScopeProxy::DidLoadClassicScript() { … }
void ServiceWorkerGlobalScopeProxy::DidFetchScript() { … }
void ServiceWorkerGlobalScopeProxy::DidFailToFetchClassicScript() { … }
void ServiceWorkerGlobalScopeProxy::DidFailToFetchModuleScript() { … }
void ServiceWorkerGlobalScopeProxy::WillEvaluateScript() { … }
void ServiceWorkerGlobalScopeProxy::DidEvaluateTopLevelScript(bool success) { … }
void ServiceWorkerGlobalScopeProxy::DidCloseWorkerGlobalScope() { … }
void ServiceWorkerGlobalScopeProxy::WillDestroyWorkerGlobalScope() { … }
void ServiceWorkerGlobalScopeProxy::DidTerminateWorkerThread() { … }
bool ServiceWorkerGlobalScopeProxy::IsServiceWorkerGlobalScopeProxy() const { … }
void ServiceWorkerGlobalScopeProxy::SetupNavigationPreload(
int fetch_event_id,
const KURL& url,
mojo::PendingReceiver<network::mojom::blink::URLLoaderClient>
preload_url_loader_client_receiver) { … }
void ServiceWorkerGlobalScopeProxy::RequestTermination(
CrossThreadOnceFunction<void(bool)> callback) { … }
bool ServiceWorkerGlobalScopeProxy::
ShouldNotifyServiceWorkerOnWebSocketActivity(
v8::Local<v8::Context> context) { … }
ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(
WebEmbeddedWorkerImpl& embedded_worker,
WebServiceWorkerContextClient& client,
scoped_refptr<base::SingleThreadTaskRunner>
parent_thread_default_task_runner)
: … { … }
void ServiceWorkerGlobalScopeProxy::Detach() { … }
void ServiceWorkerGlobalScopeProxy::TerminateWorkerContext() { … }
bool ServiceWorkerGlobalScopeProxy::IsWindowInteractionAllowed() { … }
void ServiceWorkerGlobalScopeProxy::PauseEvaluation() { … }
void ServiceWorkerGlobalScopeProxy::ResumeEvaluation() { … }
mojom::blink::ServiceWorkerFetchHandlerType
ServiceWorkerGlobalScopeProxy::FetchHandlerType() { … }
bool ServiceWorkerGlobalScopeProxy::HasHidEventHandlers() { … }
bool ServiceWorkerGlobalScopeProxy::HasUsbEventHandlers() { … }
void ServiceWorkerGlobalScopeProxy::GetRemoteAssociatedInterface(
const WebString& name,
mojo::ScopedInterfaceEndpointHandle handle) { … }
blink::AssociatedInterfaceRegistry&
ServiceWorkerGlobalScopeProxy::GetAssociatedInterfaceRegistry() { … }
WebServiceWorkerContextClient& ServiceWorkerGlobalScopeProxy::Client() const { … }
ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::WorkerGlobalScope()
const { … }
}