#include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h"
#include <utility>
#include "base/metrics/histogram_functions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "services/network/public/mojom/web_sandbox_flags.mojom-blink.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_sample_collector.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/mojom/loader/content_security_notifier.mojom-blink.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom-blink.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_content_security_policy_struct.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "third_party/blink/public/platform/web_worker_fetch_context.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/dom/events/event_queue.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/deprecation/deprecation.h"
#include "third_party/blink/renderer/core/frame/policy_container.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/inspector/inspector_audits_issue.h"
#include "third_party/blink/renderer/core/loader/loader_factory_for_worker.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_creation_params.h"
#include "third_party/blink/renderer/core/loader/modulescript/module_script_fetch_request.h"
#include "third_party/blink/renderer/core/loader/resource_load_observer_for_worker.h"
#include "third_party/blink/renderer/core/loader/subresource_filter.h"
#include "third_party/blink/renderer/core/loader/worker_fetch_context.h"
#include "third_party/blink/renderer/core/loader/worker_resource_fetcher_properties.h"
#include "third_party/blink/renderer/core/loader/worker_resource_timing_notifier_impl.h"
#include "third_party/blink/renderer/core/origin_trials/origin_trial_context.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/fetch_client_settings_object_impl.h"
#include "third_party/blink/renderer/core/workers/worker_global_scope.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/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/detachable_use_counter.h"
#include "third_party/blink/renderer/platform/loader/fetch/fetch_client_settings_object_snapshot.h"
#include "third_party/blink/renderer/platform/loader/fetch/null_resource_fetcher_properties.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_load_observer.h"
#include "third_party/blink/renderer/platform/network/http_parsers.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
namespace {
class OutsideSettingsCSPDelegate final
: public GarbageCollected<OutsideSettingsCSPDelegate>,
public ContentSecurityPolicyDelegate { … };
enum class WorkerOrWorkletInterfaceNameType { … };
}
WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope(
v8::Isolate* isolate,
scoped_refptr<SecurityOrigin> origin,
bool is_creator_secure_context,
Agent* agent,
const String& name,
const base::UnguessableToken& parent_devtools_token,
mojom::blink::V8CacheOptions v8_cache_options,
WorkerClients* worker_clients,
std::unique_ptr<WebContentSettingsClient> content_settings_client,
scoped_refptr<WebWorkerFetchContext> web_worker_fetch_context,
WorkerReportingProxy& reporting_proxy,
bool is_worker_loaded_from_data_url,
bool is_default_world_of_isolate)
: … { … }
WorkerOrWorkletGlobalScope::~WorkerOrWorkletGlobalScope() = default;
const AtomicString& WorkerOrWorkletGlobalScope::InterfaceName() const { … }
v8::Local<v8::Value> WorkerOrWorkletGlobalScope::Wrap(ScriptState*) { … }
v8::Local<v8::Object> WorkerOrWorkletGlobalScope::AssociateWithWrapper(
v8::Isolate*,
const WrapperTypeInfo*,
v8::Local<v8::Object> wrapper) { … }
void WorkerOrWorkletGlobalScope::CountUse(WebFeature feature) { … }
void WorkerOrWorkletGlobalScope::CountDeprecation(WebFeature feature) { … }
void WorkerOrWorkletGlobalScope::CountWebDXFeature(WebDXFeature feature) { … }
ResourceLoadScheduler::ThrottleOptionOverride
WorkerOrWorkletGlobalScope::GetThrottleOptionOverride() const { … }
void WorkerOrWorkletGlobalScope::UpdateFetcherThrottleOptionOverride() { … }
void WorkerOrWorkletGlobalScope::InitializeWebFetchContextIfNeeded() { … }
ResourceFetcher* WorkerOrWorkletGlobalScope::Fetcher() { … }
ResourceFetcher* WorkerOrWorkletGlobalScope::CreateFetcherInternal(
const FetchClientSettingsObject& fetch_client_settings_object,
ContentSecurityPolicy& content_security_policy,
WorkerResourceTimingNotifier& resource_timing_notifier) { … }
ResourceFetcher* WorkerOrWorkletGlobalScope::CreateOutsideSettingsFetcher(
const FetchClientSettingsObject& outside_settings_object,
WorkerResourceTimingNotifier& outside_resource_timing_notifier) { … }
bool WorkerOrWorkletGlobalScope::IsJSExecutionForbidden() const { … }
void WorkerOrWorkletGlobalScope::DisableEval(const String& error_message) { … }
void WorkerOrWorkletGlobalScope::SetWasmEvalErrorMessage(
const String& error_message) { … }
bool WorkerOrWorkletGlobalScope::CanExecuteScripts(
ReasonForCallingCanExecuteScripts) { … }
bool WorkerOrWorkletGlobalScope::HasInsecureContextInAncestors() const { … }
void WorkerOrWorkletGlobalScope::Dispose() { … }
scoped_refptr<base::SingleThreadTaskRunner>
WorkerOrWorkletGlobalScope::GetTaskRunner(TaskType type) { … }
void WorkerOrWorkletGlobalScope::SetSandboxFlags(
network::mojom::blink::WebSandboxFlags mask) { … }
void WorkerOrWorkletGlobalScope::SetOutsideContentSecurityPolicies(
Vector<network::mojom::blink::ContentSecurityPolicyPtr> policies) { … }
void WorkerOrWorkletGlobalScope::InitContentSecurityPolicyFromVector(
Vector<network::mojom::blink::ContentSecurityPolicyPtr> policies) { … }
void WorkerOrWorkletGlobalScope::BindContentSecurityPolicyToExecutionContext() { … }
void WorkerOrWorkletGlobalScope::FetchModuleScript(
const KURL& module_url_record,
const FetchClientSettingsObjectSnapshot& fetch_client_settings_object,
WorkerResourceTimingNotifier& resource_timing_notifier,
mojom::blink::RequestContextType context_type,
network::mojom::RequestDestination destination,
network::mojom::CredentialsMode credentials_mode,
ModuleScriptCustomFetchType custom_fetch_type,
ModuleTreeClient* client) { … }
void WorkerOrWorkletGlobalScope::SetDefersLoadingForResourceFetchers(
LoaderFreezeMode mode) { … }
int WorkerOrWorkletGlobalScope::GetOutstandingThrottledLimit() const { … }
String WorkerOrWorkletGlobalScope::GetAcceptLanguages() const { … }
void WorkerOrWorkletGlobalScope::OnConsoleApiMessage(
mojom::ConsoleMessageLevel level,
const String& message,
SourceLocation* location) { … }
void WorkerOrWorkletGlobalScope::Trace(Visitor* visitor) const { … }
}