Commit 1da7d4a9 authored by Tsuyoshi Horo's avatar Tsuyoshi Horo Committed by Commit Bot

Show "from prefetch cache" in DevTools if unused_since_prefetch is set for non-prefetch requests.

This is the follow-up CL of kinuko@'s comment:
https://crrev.com/c/1619527/5/services/network/public/cpp/resource_response.cc#67

Change-Id: If8dc0b534f39d2d6e097a35dfa552421b865b6f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1621988Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Tsuyoshi Horo <horo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664092}
parent c98e7541
...@@ -90,6 +90,9 @@ void PopulateResourceResponse( ...@@ -90,6 +90,9 @@ void PopulateResourceResponse(
response->head.network_accessed = response_info.network_accessed; response->head.network_accessed = response_info.network_accessed;
response->head.async_revalidation_requested = response->head.async_revalidation_requested =
response_info.async_revalidation_requested; response_info.async_revalidation_requested;
response->head.was_in_prefetch_cache =
!(request->load_flags() & net::LOAD_PREFETCH) &&
response_info.unused_since_prefetch;
if (info->ShouldReportRawHeaders()) { if (info->ShouldReportRawHeaders()) {
response->head.raw_request_response_info = response->head.raw_request_response_info =
network::BuildRawRequestResponseInfo(*request, raw_request_headers, network::BuildRawRequestResponseInfo(*request, raw_request_headers,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "mojo/public/cpp/system/simple_watcher.h" #include "mojo/public/cpp/system/simple_watcher.h"
#include "net/base/elements_upload_data_stream.h" #include "net/base/elements_upload_data_stream.h"
#include "net/base/ip_endpoint.h" #include "net/base/ip_endpoint.h"
#include "net/base/load_flags.h"
#include "net/base/mime_sniffer.h" #include "net/base/mime_sniffer.h"
#include "net/base/static_cookie_policy.h" #include "net/base/static_cookie_policy.h"
#include "net/base/upload_bytes_element_reader.h" #include "net/base/upload_bytes_element_reader.h"
...@@ -83,7 +84,9 @@ void PopulateResourceResponse(net::URLRequest* request, ...@@ -83,7 +84,9 @@ void PopulateResourceResponse(net::URLRequest* request,
response->head.network_accessed = response_info.network_accessed; response->head.network_accessed = response_info.network_accessed;
response->head.async_revalidation_requested = response->head.async_revalidation_requested =
response_info.async_revalidation_requested; response_info.async_revalidation_requested;
response->head.was_in_prefetch_cache =
!(request->load_flags() & net::LOAD_PREFETCH) &&
response_info.unused_since_prefetch;
response->head.effective_connection_type = response->head.effective_connection_type =
net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN; net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
......
...@@ -488,9 +488,7 @@ class PLATFORM_EXPORT ResourceResponse final { ...@@ -488,9 +488,7 @@ class PLATFORM_EXPORT ResourceResponse final {
// https://wicg.github.io/webpackage/draft-yasskin-http-origin-signed-responses.html // https://wicg.github.io/webpackage/draft-yasskin-http-origin-signed-responses.html
bool is_signed_exchange_inner_response_ = false; bool is_signed_exchange_inner_response_ = false;
// True if this resource is served from the prefetch cache. Currently this // True if this resource is served from the prefetch cache.
// flag is used only for prefetched signed exchanges.
// TODO(horo): Mark this also for general prefetch cases.
bool was_in_prefetch_cache_ = false; bool was_in_prefetch_cache_ = false;
// True if this resource was loaded from the network. // True if this resource was loaded from the network.
......
fromPrefetchCache flag must be set for prefetched resousces.
http://127.0.0.1:8000/devtools/network/resources/network-prefetch-target.html
fromPrefetchCache: true
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`fromPrefetchCache flag must be set for prefetched resousces.\n`);
await TestRunner.loadModule('network_test_runner');
await TestRunner.showPanel('network');
const ret = await TestRunner.evaluateInPageAsync(`
(function(){
return new Promise(resolve => {
const link = document.createElement('link');
link.rel = 'prefetch';
link.href = 'resources/network-prefetch-target.html';
link.addEventListener('load', resolve);
document.body.appendChild(link);
});
})();
`);
NetworkTestRunner.recordNetwork();
await TestRunner.addIframe('resources/network-prefetch-target.html');
var request1 = NetworkTestRunner.networkRequests().pop();
TestRunner.addResult(request1.url());
TestRunner.addResult('fromPrefetchCache: ' + request1.fromPrefetchCache());
TestRunner.completeTest();
})();
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