Commit 6d17e158 authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Worker: Remove ThreadedMessagingProxyBase::WorkerThreadCreated() for cleanup

ThreadedMessagingProxyBase::WorkerThreadCreated() is provided as a virtual
function for DedicatedWorkerMessagingProxy to post queued tasks to the worker
after thread creation. However, DedicatedWorkerMessagingProxy itself initiates
the thread creation in StartWorkerGlobalScope() and can know when it's
available, so such the virtual function is not necessary.

For cleanup, this CL removes WorkerThreadCreated() and inlines posting the
queued tasks in StartWorkerGlobalScope().

Bug: 680046
Change-Id: I5248c78d381e0820461e167249ce89bac93e44a5
Reviewed-on: https://chromium-review.googlesource.com/823052
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523719}
parent 6f7e8e17
...@@ -94,6 +94,20 @@ void DedicatedWorkerMessagingProxy::StartWorkerGlobalScope( ...@@ -94,6 +94,20 @@ void DedicatedWorkerMessagingProxy::StartWorkerGlobalScope(
InitializeWorkerThread(std::move(global_scope_creation_params), InitializeWorkerThread(std::move(global_scope_creation_params),
CreateBackingThreadStartupData(ToIsolate(document)), CreateBackingThreadStartupData(ToIsolate(document)),
script_url, stack_id, source_code); script_url, stack_id, source_code);
// Post all queued tasks to the worker.
for (auto& queued_task : queued_early_tasks_) {
WTF::CrossThreadClosure task = CrossThreadBind(
&DedicatedWorkerObjectProxy::ProcessMessageFromWorkerObject,
CrossThreadUnretained(&WorkerObjectProxy()),
WTF::Passed(std::move(queued_task.message)),
WTF::Passed(std::move(queued_task.channels)),
CrossThreadUnretained(GetWorkerThread()), queued_task.stack_id);
GetWorkerThread()
->GetTaskRunner(TaskType::kPostedMessage)
->PostTask(BLINK_FROM_HERE, std::move(task));
}
queued_early_tasks_.clear();
} }
void DedicatedWorkerMessagingProxy::PostMessageToWorkerGlobalScope( void DedicatedWorkerMessagingProxy::PostMessageToWorkerGlobalScope(
...@@ -122,24 +136,6 @@ void DedicatedWorkerMessagingProxy::PostMessageToWorkerGlobalScope( ...@@ -122,24 +136,6 @@ void DedicatedWorkerMessagingProxy::PostMessageToWorkerGlobalScope(
} }
} }
void DedicatedWorkerMessagingProxy::WorkerThreadCreated() {
DCHECK(IsParentContextThread());
ThreadedMessagingProxyBase::WorkerThreadCreated();
for (auto& queued_task : queued_early_tasks_) {
WTF::CrossThreadClosure task = CrossThreadBind(
&DedicatedWorkerObjectProxy::ProcessMessageFromWorkerObject,
CrossThreadUnretained(&WorkerObjectProxy()),
std::move(queued_task.message),
WTF::Passed(std::move(queued_task.channels)),
CrossThreadUnretained(GetWorkerThread()), queued_task.stack_id);
GetWorkerThread()
->GetTaskRunner(TaskType::kPostedMessage)
->PostTask(BLINK_FROM_HERE, std::move(task));
}
queued_early_tasks_.clear();
}
bool DedicatedWorkerMessagingProxy::HasPendingActivity() const { bool DedicatedWorkerMessagingProxy::HasPendingActivity() const {
DCHECK(IsParentContextThread()); DCHECK(IsParentContextThread());
return !AskedToTerminate(); return !AskedToTerminate();
......
...@@ -48,9 +48,6 @@ class CORE_EXPORT DedicatedWorkerMessagingProxy ...@@ -48,9 +48,6 @@ class CORE_EXPORT DedicatedWorkerMessagingProxy
Vector<MessagePortChannel>, Vector<MessagePortChannel>,
const v8_inspector::V8StackTraceId&); const v8_inspector::V8StackTraceId&);
// Implements ThreadedMessagingProxyBase.
void WorkerThreadCreated() override;
bool HasPendingActivity() const; bool HasPendingActivity() const;
// These methods come from worker context thread via // These methods come from worker context thread via
......
...@@ -89,7 +89,6 @@ void ThreadedMessagingProxyBase::InitializeWorkerThread( ...@@ -89,7 +89,6 @@ void ThreadedMessagingProxyBase::InitializeWorkerThread(
GetWorkerInspectorProxy()->ShouldPauseOnWorkerStart(document), GetWorkerInspectorProxy()->ShouldPauseOnWorkerStart(document),
stack_id), stack_id),
GetParentFrameTaskRunners(), source_code); GetParentFrameTaskRunners(), source_code);
WorkerThreadCreated();
GetWorkerInspectorProxy()->WorkerThreadCreated(document, GetWorkerThread(), GetWorkerInspectorProxy()->WorkerThreadCreated(document, GetWorkerThread(),
script_url); script_url);
} }
...@@ -117,12 +116,6 @@ void ThreadedMessagingProxyBase::ReportConsoleMessage( ...@@ -117,12 +116,6 @@ void ThreadedMessagingProxyBase::ReportConsoleMessage(
std::move(location)); std::move(location));
} }
void ThreadedMessagingProxyBase::WorkerThreadCreated() {
DCHECK(IsParentContextThread());
DCHECK(!asked_to_terminate_);
DCHECK(worker_thread_);
}
void ThreadedMessagingProxyBase::ParentObjectDestroyed() { void ThreadedMessagingProxyBase::ParentObjectDestroyed() {
DCHECK(IsParentContextThread()); DCHECK(IsParentContextThread());
if (worker_thread_) { if (worker_thread_) {
......
...@@ -78,7 +78,6 @@ class CORE_EXPORT ThreadedMessagingProxyBase ...@@ -78,7 +78,6 @@ class CORE_EXPORT ThreadedMessagingProxyBase
const KURL& script_url, const KURL& script_url,
const v8_inspector::V8StackTraceId&, const v8_inspector::V8StackTraceId&,
const String& source_code = String()); const String& source_code = String());
virtual void WorkerThreadCreated();
ThreadableLoadingContext* CreateThreadableLoadingContext() const; ThreadableLoadingContext* CreateThreadableLoadingContext() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment