Commit e699a315 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

S13nServiceWorker: Fix `fetchStart` performance timing for subresources

ServiceWorkerSubresourceLoader records loading milestones. These
milestones are used to create web-exposed PerformanceResourceTiming.

Before this CL, ServiceWorkerSubresourceLoader recorded
|service_worker_ready_time| before calling GetControllerServiceWorker().
This doesn't seem a good timing to record it because:
- |service_worker_ready_time| is used to create `fetchStart` of
  PerformanceResourceTiming.
- `fetchStart` should be recorded after the controller service worker is
  ready to handle fetch event.
- But the worker may not be running until we call GetControllerServiceWorker().

This CL moves the timing to record |service_worker_raedy_time| and some others
after calling GetControllerServiceWorker(), as calling it makes sure that
the controller is running and ready to handle a fetch event.

The wpt ervice-workers/service-worker/resource-timing.https.html should
cover this change.

Bug: 782958
Change-Id: Ic6f6abd34ffdc84e002357a905e7a7726e6b5870
Reviewed-on: https://chromium-review.googlesource.com/1212244
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589818}
parent 7b4c707f
...@@ -200,11 +200,6 @@ void ServiceWorkerSubresourceLoader::StartRequest( ...@@ -200,11 +200,6 @@ void ServiceWorkerSubresourceLoader::StartRequest(
fetch_request_restarted_ = false; fetch_request_restarted_ = false;
response_head_.service_worker_start_time = base::TimeTicks::Now(); response_head_.service_worker_start_time = base::TimeTicks::Now();
// TODO(horo): Reset |service_worker_ready_time| when the the connection to
// the service worker is revived.
response_head_.service_worker_ready_time = base::TimeTicks::Now();
response_head_.load_timing.send_start = base::TimeTicks::Now();
response_head_.load_timing.send_end = base::TimeTicks::Now();
DispatchFetchEvent(); DispatchFetchEvent();
} }
...@@ -214,6 +209,14 @@ void ServiceWorkerSubresourceLoader::DispatchFetchEvent() { ...@@ -214,6 +209,14 @@ void ServiceWorkerSubresourceLoader::DispatchFetchEvent() {
mojom::ControllerServiceWorker* controller = mojom::ControllerServiceWorker* controller =
controller_connector_->GetControllerServiceWorker( controller_connector_->GetControllerServiceWorker(
mojom::ControllerServiceWorkerPurpose::FETCH_SUB_RESOURCE); mojom::ControllerServiceWorkerPurpose::FETCH_SUB_RESOURCE);
// GetControllerServiceWorker() makes sure that the connection to the
// service worker is established, which means that the service worker
// has started if it wasn't running.
response_head_.service_worker_ready_time = base::TimeTicks::Now();
response_head_.load_timing.send_start = base::TimeTicks::Now();
response_head_.load_timing.send_end = base::TimeTicks::Now();
TRACE_EVENT1("ServiceWorker", TRACE_EVENT1("ServiceWorker",
"ServiceWorkerSubresourceLoader::DispatchFetchEvent", "ServiceWorkerSubresourceLoader::DispatchFetchEvent",
"controller", (controller ? "exists" : "does not exist")); "controller", (controller ? "exists" : "does not exist"));
......
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