Commit 41a8a802 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Set WorkerInspectorController::url_ to GlobalScopeCreationParams::script_url

To avoid ExecutionContext::Url() calls during worker initialization.

Ideally, the URL should be the response URL of the worker top-level script,
but in off-the-main-thread worker top-level script fetch cases,
it isn't available at the time of WorkerInspectorController ctor
that immediately uses the |url_|.

Therefore this CL uses |script_url| (which is the request URL of the
worker top-level script in off-the-main-thread worker top-level script fetch)
and leave the issue tracked by Issue 866666.

Bug: 861564, 866666
Change-Id: I5ccae99996871558762e8a76b141352e17b57216
Reviewed-on: https://chromium-review.googlesource.com/c/1478458
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633873}
parent 497ff623
...@@ -53,18 +53,20 @@ namespace blink { ...@@ -53,18 +53,20 @@ namespace blink {
// static // static
WorkerInspectorController* WorkerInspectorController::Create( WorkerInspectorController* WorkerInspectorController::Create(
WorkerThread* thread, WorkerThread* thread,
const KURL& url,
scoped_refptr<InspectorTaskRunner> inspector_task_runner, scoped_refptr<InspectorTaskRunner> inspector_task_runner,
std::unique_ptr<WorkerDevToolsParams> devtools_params) { std::unique_ptr<WorkerDevToolsParams> devtools_params) {
WorkerThreadDebugger* debugger = WorkerThreadDebugger* debugger =
WorkerThreadDebugger::From(thread->GetIsolate()); WorkerThreadDebugger::From(thread->GetIsolate());
return debugger ? MakeGarbageCollected<WorkerInspectorController>( return debugger ? MakeGarbageCollected<WorkerInspectorController>(
thread, debugger, std::move(inspector_task_runner), thread, url, debugger, std::move(inspector_task_runner),
std::move(devtools_params)) std::move(devtools_params))
: nullptr; : nullptr;
} }
WorkerInspectorController::WorkerInspectorController( WorkerInspectorController::WorkerInspectorController(
WorkerThread* thread, WorkerThread* thread,
const KURL& url,
WorkerThreadDebugger* debugger, WorkerThreadDebugger* debugger,
scoped_refptr<InspectorTaskRunner> inspector_task_runner, scoped_refptr<InspectorTaskRunner> inspector_task_runner,
std::unique_ptr<WorkerDevToolsParams> devtools_params) std::unique_ptr<WorkerDevToolsParams> devtools_params)
...@@ -77,7 +79,7 @@ WorkerInspectorController::WorkerInspectorController( ...@@ -77,7 +79,7 @@ WorkerInspectorController::WorkerInspectorController(
if (auto* scope = DynamicTo<WorkerGlobalScope>(thread->GlobalScope())) { if (auto* scope = DynamicTo<WorkerGlobalScope>(thread->GlobalScope())) {
worker_devtools_token_ = devtools_params->devtools_worker_token; worker_devtools_token_ = devtools_params->devtools_worker_token;
parent_devtools_token_ = scope->GetParentDevToolsToken(); parent_devtools_token_ = scope->GetParentDevToolsToken();
url_ = scope->Url(); url_ = url;
worker_thread_id_ = thread->GetPlatformThreadId(); worker_thread_id_ = thread->GetPlatformThreadId();
} }
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
......
...@@ -60,10 +60,12 @@ class WorkerInspectorController final ...@@ -60,10 +60,12 @@ class WorkerInspectorController final
public: public:
static WorkerInspectorController* Create( static WorkerInspectorController* Create(
WorkerThread*, WorkerThread*,
const KURL&,
scoped_refptr<InspectorTaskRunner>, scoped_refptr<InspectorTaskRunner>,
std::unique_ptr<WorkerDevToolsParams>); std::unique_ptr<WorkerDevToolsParams>);
WorkerInspectorController(WorkerThread*, WorkerInspectorController(WorkerThread*,
const KURL&,
WorkerThreadDebugger*, WorkerThreadDebugger*,
scoped_refptr<InspectorTaskRunner>, scoped_refptr<InspectorTaskRunner>,
std::unique_ptr<WorkerDevToolsParams>); std::unique_ptr<WorkerDevToolsParams>);
......
...@@ -447,6 +447,9 @@ void WorkerThread::InitializeOnWorkerThread( ...@@ -447,6 +447,9 @@ void WorkerThread::InitializeOnWorkerThread(
} }
GetWorkerBackingThread().BackingThread().AddTaskObserver(this); GetWorkerBackingThread().BackingThread().AddTaskObserver(this);
// TODO(crbug.com/866666): Ideally this URL should be the response URL of
// the worker top-level script, while currently can be the request URL
// for off-the-main-thread top-level script fetch cases.
const KURL url_for_debugger = global_scope_creation_params->script_url; const KURL url_for_debugger = global_scope_creation_params->script_url;
console_message_storage_ = MakeGarbageCollected<ConsoleMessageStorage>(); console_message_storage_ = MakeGarbageCollected<ConsoleMessageStorage>();
...@@ -455,7 +458,8 @@ void WorkerThread::InitializeOnWorkerThread( ...@@ -455,7 +458,8 @@ void WorkerThread::InitializeOnWorkerThread(
worker_reporting_proxy_.DidCreateWorkerGlobalScope(GlobalScope()); worker_reporting_proxy_.DidCreateWorkerGlobalScope(GlobalScope());
worker_inspector_controller_ = WorkerInspectorController::Create( worker_inspector_controller_ = WorkerInspectorController::Create(
this, inspector_task_runner_, std::move(devtools_params)); this, url_for_debugger, inspector_task_runner_,
std::move(devtools_params));
// Since context initialization below may fail, we should notify debugger // Since context initialization below may fail, we should notify debugger
// about the new worker thread separately, so that it can resolve it by id // about the new worker thread separately, so that it can resolve it by id
......
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