#include "third_party/blink/renderer/core/workers/dedicated_worker_messaging_proxy.h"
#include <memory>
#include "base/feature_list.h"
#include "base/trace_event/typed_macros.h"
#include "services/network/public/mojom/fetch_api.mojom-blink.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/tokens/tokens.h"
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
#include "third_party/blink/public/mojom/worker/dedicated_worker_host.mojom-blink-forward.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_worker_options.h"
#include "third_party/blink/renderer/core/dom/document.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/fetch/request.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/inspector/thread_debugger_common_impl.h"
#include "third_party/blink/renderer/core/loader/worker_resource_timing_notifier_impl.h"
#include "third_party/blink/renderer/core/messaging/blink_transferable_message.h"
#include "third_party/blink/renderer/core/script_type_names.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker.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/parent_execution_context_task_runners.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/wtf.h"
#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
namespace blink {
DedicatedWorkerMessagingProxy::DedicatedWorkerMessagingProxy(
ExecutionContext* execution_context,
DedicatedWorker* worker_object)
: … { … }
DedicatedWorkerMessagingProxy::DedicatedWorkerMessagingProxy(
ExecutionContext* execution_context,
DedicatedWorker* worker_object,
base::FunctionRef<std::unique_ptr<DedicatedWorkerObjectProxy>(
DedicatedWorkerMessagingProxy*,
DedicatedWorker*,
ParentExecutionContextTaskRunners*)> worker_object_proxy_factory)
: … { … }
DedicatedWorkerMessagingProxy::~DedicatedWorkerMessagingProxy() = default;
void DedicatedWorkerMessagingProxy::StartWorkerGlobalScope(
std::unique_ptr<GlobalScopeCreationParams> creation_params,
std::unique_ptr<WorkerMainScriptLoadParameters>
worker_main_script_load_params,
const WorkerOptions* options,
const KURL& script_url,
const FetchClientSettingsObjectSnapshot& outside_settings_object,
const v8_inspector::V8StackTraceId& stack_id,
const String& source_code,
RejectCoepUnsafeNone reject_coep_unsafe_none,
const blink::DedicatedWorkerToken& token,
mojo::PendingRemote<mojom::blink::DedicatedWorkerHost>
dedicated_worker_host,
mojo::PendingRemote<mojom::blink::BackForwardCacheControllerHost>
back_forward_cache_controller_host) { … }
void DedicatedWorkerMessagingProxy::PostMessageToWorkerGlobalScope(
BlinkTransferableMessage message) { … }
void DedicatedWorkerMessagingProxy::PostCustomEventToWorkerGlobalScope(
TaskType task_type,
CrossThreadFunction<Event*(ScriptState*, CustomEventMessage)>
event_factory_callback,
CrossThreadFunction<Event*(ScriptState* script_state)>
event_factory_error_callback,
CustomEventMessage message) { … }
bool DedicatedWorkerMessagingProxy::HasPendingActivity() const { … }
void DedicatedWorkerMessagingProxy::DidFailToFetchScript() { … }
void DedicatedWorkerMessagingProxy::Freeze(bool is_in_back_forward_cache) { … }
void DedicatedWorkerMessagingProxy::Resume() { … }
void DedicatedWorkerMessagingProxy::DidEvaluateScript(bool success) { … }
void DedicatedWorkerMessagingProxy::PostMessageToWorkerObject(
BlinkTransferableMessage message) { … }
void DedicatedWorkerMessagingProxy::DispatchErrorEvent(
const String& error_message,
std::unique_ptr<SourceLocation> location,
int exception_id) { … }
void DedicatedWorkerMessagingProxy::Trace(Visitor* visitor) const { … }
std::optional<WorkerBackingThreadStartupData>
DedicatedWorkerMessagingProxy::CreateBackingThreadStartupData(
v8::Isolate* isolate) { … }
std::unique_ptr<WorkerThread>
DedicatedWorkerMessagingProxy::CreateWorkerThread() { … }
}