Commit 45675bdb authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Check for null GetResourceLoadTiming() for nav preloads.

This can return null per issue 817691. We only recently started getting crashes for
it being null for navigation preloads. It's possible this is due to
r636598 which allowed extensions to intercept nav preload requests.

Bug: 938639
Change-Id: I03149fa3c61234714611c272e4fa783948f2bf5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1504594
Auto-Submit: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#637987}
parent fc3ad217
...@@ -192,10 +192,15 @@ void FetchEvent::OnNavigationPreloadComplete( ...@@ -192,10 +192,15 @@ void FetchEvent::OnNavigationPreloadComplete(
resource_response.SetEncodedDataLength(encoded_data_length); resource_response.SetEncodedDataLength(encoded_data_length);
resource_response.SetEncodedBodyLength(encoded_body_length); resource_response.SetEncodedBodyLength(encoded_body_length);
resource_response.SetDecodedBodyLength(decoded_body_length); resource_response.SetDecodedBodyLength(decoded_body_length);
ResourceLoadTiming* timing = resource_response.GetResourceLoadTiming();
// |timing| can be null, see https://crbug.com/817691.
base::TimeTicks request_time =
timing ? timing->RequestTime() : base::TimeTicks();
// According to the Resource Timing spec, the initiator type of // According to the Resource Timing spec, the initiator type of
// navigation preload request is "navigation". // navigation preload request is "navigation".
scoped_refptr<ResourceTimingInfo> info = ResourceTimingInfo::Create( scoped_refptr<ResourceTimingInfo> info =
"navigation", resource_response.GetResourceLoadTiming()->RequestTime()); ResourceTimingInfo::Create("navigation", request_time);
info->SetNegativeAllowed(true); info->SetNegativeAllowed(true);
info->SetLoadFinishTime(completion_time); info->SetLoadFinishTime(completion_time);
info->SetInitialURL(request_->url()); info->SetInitialURL(request_->url());
......
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