#include "third_party/blink/renderer/core/workers/dedicated_worker_global_scope.h"
#include <memory>
#include "base/check_is_test.h"
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/trace_event/trace_id_helper.h"
#include "base/trace_event/typed_macros.h"
#include "base/types/pass_key.h"
#include "net/storage_access_api/status.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/loader/worker_main_script_load_parameters.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/back_forward_cache_controller.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/post_message_helper.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_post_message_options.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
#include "third_party/blink/renderer/core/event_target_names.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/inspector/worker_thread_debugger.h"
#include "third_party/blink/renderer/core/messaging/blink_transferable_message.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/workers/dedicated_worker_object_proxy.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_thread.h"
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include "third_party/blink/renderer/core/workers/worker_classic_script_loader.h"
#include "third_party/blink/renderer/core/workers/worker_clients.h"
#include "third_party/blink/renderer/core/workers/worker_module_tree_client.h"
#include "third_party/blink/renderer/platform/back_forward_cache_buffer_limit_tracker.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/loader/fetch/fetch_client_settings_object_snapshot.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
namespace blink {
DedicatedWorkerGlobalScope* DedicatedWorkerGlobalScope::Create(
std::unique_ptr<GlobalScopeCreationParams> creation_params,
DedicatedWorkerThread* thread,
base::TimeTicks time_origin,
mojo::PendingRemote<mojom::blink::DedicatedWorkerHost>
dedicated_worker_host,
mojo::PendingRemote<mojom::blink::BackForwardCacheControllerHost>
back_forward_cache_controller_host) { … }
DedicatedWorkerGlobalScope::ParsedCreationParams
DedicatedWorkerGlobalScope::ParseCreationParams(
std::unique_ptr<GlobalScopeCreationParams> creation_params) { … }
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(
base::PassKey<DedicatedWorkerGlobalScope>,
std::unique_ptr<GlobalScopeCreationParams> creation_params,
DedicatedWorkerThread* thread,
base::TimeTicks time_origin,
std::unique_ptr<Vector<mojom::blink::OriginTrialFeature>>
inherited_trial_features,
const BeginFrameProviderParams& begin_frame_provider_params,
bool parent_cross_origin_isolated_capability,
bool parent_is_isolated_context,
mojo::PendingRemote<mojom::blink::DedicatedWorkerHost>
dedicated_worker_host,
mojo::PendingRemote<mojom::blink::BackForwardCacheControllerHost>
back_forward_cache_controller_host,
base::TimeTicks dedicated_worker_start_time)
: … { … }
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(
ParsedCreationParams parsed_creation_params,
DedicatedWorkerThread* thread,
base::TimeTicks time_origin,
std::unique_ptr<Vector<mojom::blink::OriginTrialFeature>>
inherited_trial_features,
const BeginFrameProviderParams& begin_frame_provider_params,
bool parent_cross_origin_isolated_capability,
bool parent_is_isolated_context,
mojo::PendingRemote<mojom::blink::DedicatedWorkerHost>
dedicated_worker_host,
mojo::PendingRemote<mojom::blink::BackForwardCacheControllerHost>
back_forward_cache_controller_host,
base::TimeTicks dedicated_worker_start_time)
: … { … }
DedicatedWorkerGlobalScope::~DedicatedWorkerGlobalScope() = default;
void DedicatedWorkerGlobalScope::Dispose() { … }
const AtomicString& DedicatedWorkerGlobalScope::InterfaceName() const { … }
void DedicatedWorkerGlobalScope::Initialize(
const KURL& response_url,
network::mojom::ReferrerPolicy response_referrer_policy,
Vector<network::mojom::blink::ContentSecurityPolicyPtr> response_csp,
const Vector<String>* ) { … }
void DedicatedWorkerGlobalScope::FetchAndRunClassicScript(
const KURL& script_url,
std::unique_ptr<WorkerMainScriptLoadParameters>
worker_main_script_load_params,
std::unique_ptr<PolicyContainer> policy_container,
const FetchClientSettingsObjectSnapshot& outside_settings_object,
WorkerResourceTimingNotifier& outside_resource_timing_notifier,
const v8_inspector::V8StackTraceId& stack_id) { … }
void DedicatedWorkerGlobalScope::FetchAndRunModuleScript(
const KURL& module_url_record,
std::unique_ptr<WorkerMainScriptLoadParameters>
worker_main_script_load_params,
std::unique_ptr<PolicyContainer> policy_container,
const FetchClientSettingsObjectSnapshot& outside_settings_object,
WorkerResourceTimingNotifier& outside_resource_timing_notifier,
network::mojom::CredentialsMode credentials_mode,
RejectCoepUnsafeNone reject_coep_unsafe_none) { … }
bool DedicatedWorkerGlobalScope::IsOffMainThreadScriptFetchDisabled() { … }
const String DedicatedWorkerGlobalScope::name() const { … }
void DedicatedWorkerGlobalScope::postMessage(ScriptState* script_state,
const ScriptValue& message,
HeapVector<ScriptValue>& transfer,
ExceptionState& exception_state) { … }
void DedicatedWorkerGlobalScope::postMessage(ScriptState* script_state,
const ScriptValue& message,
const PostMessageOptions* options,
ExceptionState& exception_state) { … }
void DedicatedWorkerGlobalScope::DidReceiveResponseForClassicScript(
WorkerClassicScriptLoader* classic_script_loader) { … }
void DedicatedWorkerGlobalScope::DidFetchClassicScript(
WorkerClassicScriptLoader* classic_script_loader,
const v8_inspector::V8StackTraceId& stack_id) { … }
int DedicatedWorkerGlobalScope::requestAnimationFrame(
V8FrameRequestCallback* callback,
ExceptionState& exception_state) { … }
void DedicatedWorkerGlobalScope::cancelAnimationFrame(int id) { … }
DedicatedWorkerObjectProxy& DedicatedWorkerGlobalScope::WorkerObjectProxy()
const { … }
void DedicatedWorkerGlobalScope::UpdateBackForwardCacheDisablingFeatures(
BlockingDetails details) { … }
void DedicatedWorkerGlobalScope::Trace(Visitor* visitor) const { … }
void DedicatedWorkerGlobalScope::EvictFromBackForwardCache(
mojom::blink::RendererEvictionReason reason,
std::unique_ptr<SourceLocation> source_location) { … }
void DedicatedWorkerGlobalScope::DidBufferLoadWhileInBackForwardCache(
bool update_process_wide_count,
size_t num_bytes) { … }
void DedicatedWorkerGlobalScope::SetIsInBackForwardCache(
bool is_in_back_forward_cache) { … }
net::StorageAccessApiStatus
DedicatedWorkerGlobalScope::GetStorageAccessApiStatus() const { … }
void DedicatedWorkerGlobalScope::WorkerScriptFetchFinished(
Script& worker_script,
std::optional<v8_inspector::V8StackTraceId> stack_id) { … }
}