#include "third_party/blink/renderer/core/workers/worker_global_scope.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/trace_event/typed_macros.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/metrics/public/cpp/mojo_ukm_recorder.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/mojom/browser_interface_broker.mojom-blink.h"
#include "third_party/blink/public/mojom/devtools/inspector_issue.mojom-blink.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_throw_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_void_function.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/css/font_face_set_worker.h"
#include "third_party/blink/renderer/core/css/offscreen_font_selector.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/events/error_event.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/font_matching_metrics.h"
#include "third_party/blink/renderer/core/frame/user_activation.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/console_message_storage.h"
#include "third_party/blink/renderer/core/inspector/inspector_audits_issue.h"
#include "third_party/blink/renderer/core/inspector/inspector_issue_storage.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/inspector/worker_inspector_controller.h"
#include "third_party/blink/renderer/core/inspector/worker_thread_debugger.h"
#include "third_party/blink/renderer/core/loader/threadable_loader.h"
#include "third_party/blink/renderer/core/messaging/blink_transferable_message.h"
#include "third_party/blink/renderer/core/messaging/message_port.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_script_url.h"
#include "third_party/blink/renderer/core/trustedtypes/trusted_type_policy_factory.h"
#include "third_party/blink/renderer/core/workers/custom_event_message.h"
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include "third_party/blink/renderer/core/workers/installed_scripts_manager.h"
#include "third_party/blink/renderer/core/workers/worker_classic_script_loader.h"
#include "third_party/blink/renderer/core/workers/worker_location.h"
#include "third_party/blink/renderer/core/workers/worker_navigator.h"
#include "third_party/blink/renderer/core/workers/worker_reporting_proxy.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/platform/bindings/exception_messages.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/source_location.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/instance_counters.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object_snapshot.h"
#include "third_party/blink/renderer/platform/loader/fetch/memory_cache.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher_properties.h"
#include "third_party/blink/renderer/platform/network/content_security_policy_parsers.h"
#include "third_party/blink/renderer/platform/scheduler/common/features.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/virtual_time_controller.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
namespace blink {
namespace {
void RemoveURLFromMemoryCacheInternal(const KURL& url) { … }
scoped_refptr<SecurityOrigin> CreateSecurityOrigin(
GlobalScopeCreationParams* creation_params,
bool is_service_worker_global_scope) { … }
}
FontFaceSet* WorkerGlobalScope::fonts() { … }
WorkerGlobalScope::~WorkerGlobalScope() { … }
NOINLINE const KURL& WorkerGlobalScope::Url() const { … }
KURL WorkerGlobalScope::CompleteURL(const String& url) const { … }
const KURL& WorkerGlobalScope::BaseURL() const { … }
scheduler::WorkerScheduler* WorkerGlobalScope::GetScheduler() { … }
void WorkerGlobalScope::Dispose() { … }
const base::UnguessableToken& WorkerGlobalScope::GetDevToolsToken() const { … }
void WorkerGlobalScope::ExceptionUnhandled(int exception_id) { … }
WorkerLocation* WorkerGlobalScope::location() const { … }
WorkerNavigator* WorkerGlobalScope::navigator() const { … }
void WorkerGlobalScope::close() { … }
String WorkerGlobalScope::origin() const { … }
void WorkerGlobalScope::importScripts(const Vector<String>& urls) { … }
namespace {
String NetworkErrorMessageAtImportScript(const char* const property_name,
const char* const interface_name,
const KURL& url) { … }
}
void WorkerGlobalScope::ImportScriptsInternal(const Vector<String>& urls) { … }
bool WorkerGlobalScope::FetchClassicImportedScript(
const KURL& script_url,
KURL* out_response_url,
String* out_source_code,
std::unique_ptr<Vector<uint8_t>>* out_cached_meta_data) { … }
bool WorkerGlobalScope::IsContextThread() const { … }
void WorkerGlobalScope::AddConsoleMessageImpl(ConsoleMessage* console_message,
bool discard_duplicates) { … }
void WorkerGlobalScope::AddInspectorIssue(AuditsIssue issue) { … }
void WorkerGlobalScope::WillBeginLoading() { … }
CoreProbeSink* WorkerGlobalScope::GetProbeSink() { … }
const BrowserInterfaceBrokerProxyImpl&
WorkerGlobalScope::GetBrowserInterfaceBroker() const { … }
ExecutionContext* WorkerGlobalScope::GetExecutionContext() const { … }
void WorkerGlobalScope::EvaluateClassicScript(
const KURL& script_url,
String source_code,
std::unique_ptr<Vector<uint8_t>> cached_meta_data,
const v8_inspector::V8StackTraceId& stack_id) { … }
void WorkerGlobalScope::WorkerScriptFetchFinished(
Script& worker_script,
std::optional<v8_inspector::V8StackTraceId> stack_id) { … }
void WorkerGlobalScope::ReadyToRunWorkerScript() { … }
void WorkerGlobalScope::RunWorkerScript() { … }
void WorkerGlobalScope::ReceiveMessage(BlinkTransferableMessage message) { … }
Event* WorkerGlobalScope::ReceiveCustomEventInternal(
CrossThreadFunction<Event*(ScriptState*, CustomEventMessage)>
event_factory_callback,
CrossThreadFunction<Event*(ScriptState* script_state)>
event_factory_error_callback,
CustomEventMessage message) { … }
void WorkerGlobalScope::ReceiveCustomEvent(
CrossThreadFunction<Event*(ScriptState*, CustomEventMessage)>
event_factory_callback,
CrossThreadFunction<Event*(ScriptState* script_state)>
event_factory_error_callback,
CustomEventMessage message) { … }
WorkerGlobalScope::WorkerGlobalScope(
std::unique_ptr<GlobalScopeCreationParams> creation_params,
WorkerThread* thread,
base::TimeTicks time_origin,
bool is_service_worker_global_scope)
: … { … }
void WorkerGlobalScope::ExceptionThrown(ErrorEvent* event) { … }
void WorkerGlobalScope::RemoveURLFromMemoryCache(const KURL& url) { … }
NOINLINE void WorkerGlobalScope::InitializeURL(const KURL& url) { … }
void WorkerGlobalScope::SetWorkerMainScriptLoadingParametersForModules(
std::unique_ptr<WorkerMainScriptLoadParameters>
worker_main_script_load_params_for_modules) { … }
void WorkerGlobalScope::queueMicrotask(V8VoidFunction* callback) { … }
void WorkerGlobalScope::SetWorkerSettings(
std::unique_ptr<WorkerSettings> worker_settings) { … }
TrustedTypePolicyFactory* WorkerGlobalScope::GetTrustedTypes() const { … }
ukm::UkmRecorder* WorkerGlobalScope::UkmRecorder() { … }
std::unique_ptr<WorkerMainScriptLoadParameters>
WorkerGlobalScope::TakeWorkerMainScriptLoadingParametersForModules() { … }
void WorkerGlobalScope::Trace(Visitor* visitor) const { … }
bool WorkerGlobalScope::HasPendingActivity() const { … }
FontMatchingMetrics* WorkerGlobalScope::GetFontMatchingMetrics() { … }
CodeCacheHost* WorkerGlobalScope::GetCodeCacheHost() { … }
}