Commit 309dda82 authored by Conley Owens's avatar Conley Owens Committed by Commit Bot

Report network_accessed in SubresourceLoadInfo

This change adds a bool `network_accessed` to the list of fields in
SubresourceLoadInfo.  Notably, this is important for recording page
load metrics when the Network Service is enabled.

BUG=816684

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I0192a50584da4a932da98ebd0a84f4c126836ce1
Reviewed-on: https://chromium-review.googlesource.com/963313Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarJay Civelli <jcivelli@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Conley Owens <cco3@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546686}
parent d91428bf
......@@ -71,6 +71,7 @@ void PopulateResourceResponse(
response_info.alpn_negotiated_protocol;
response->head.connection_info = response_info.connection_info;
response->head.socket_address = response_info.socket_address;
response->head.network_accessed = response_info.network_accessed;
const content::ResourceRequestInfo* request_info =
content::ResourceRequestInfo::ForRequest(request);
if (request_info) {
......
......@@ -645,6 +645,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
resource_url, /*referrer=*/page_url, "GET", content::RESOURCE_TYPE_SCRIPT,
"text/html", "127.0.0.1",
/*was_cached=*/false));
EXPECT_TRUE(observer.resource_load_infos()[1]->network_accessed);
EXPECT_TRUE(observer.memory_cached_loaded_urls().empty());
observer.Reset();
......@@ -675,6 +676,27 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
"text/html", "127.0.0.1",
/*was_cached=*/true));
EXPECT_TRUE(observer.memory_cached_loaded_urls().empty());
EXPECT_FALSE(observer.resource_load_infos()[1]->network_accessed);
}
IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
ResourceLoadCompleteFromLocalResource) {
ResourceLoadObserver observer(shell());
ASSERT_TRUE(embedded_test_server()->Start());
NavigateToURL(shell(),
GURL(embedded_test_server()->GetURL("/page_with_image.html")));
ASSERT_EQ(2U, observer.resource_load_infos().size());
// TODO(crbug.com/826082): network_accessed should be true on the frame.
EXPECT_FALSE(observer.resource_load_infos()[0]->network_accessed);
EXPECT_TRUE(observer.resource_load_infos()[1]->network_accessed);
observer.Reset();
NavigateToURL(shell(), GURL("chrome://gpu"));
ASSERT_LE(1U, observer.resource_load_infos().size());
for (const mojom::ResourceLoadInfoPtr& resource_load_info :
observer.resource_load_infos()) {
EXPECT_FALSE(resource_load_info->network_accessed);
}
}
struct LoadProgressDelegateAndObserver : public WebContentsDelegate,
......
......@@ -31,4 +31,7 @@ struct ResourceLoadInfo {
// True if the response was fetched from the network cache.
bool was_cached;
// True if the request accessed the network in the process of retrieving data.
bool network_accessed;
};
......@@ -179,6 +179,7 @@ void ResourceDispatcher::OnReceivedResponse(
if (!IsResourceTypeFrame(request_info->resource_type)) {
request_info->mime_type = response_head.mime_type;
request_info->network_accessed = response_head.network_accessed;
NotifySubresourceStarted(RenderThreadImpl::DeprecatedGetMainTaskRunner(),
request_info->render_frame_id,
request_info->response_url,
......@@ -274,6 +275,7 @@ void ResourceDispatcher::OnRequestComplete(
if (request_info->parsed_ip.IsValid())
resource_load_info->ip = request_info->parsed_ip;
resource_load_info->mime_type = request_info->mime_type;
resource_load_info->network_accessed = request_info->network_accessed;
resource_load_info->was_cached = status.exists_in_cache;
NotifyResourceLoadComplete(RenderThreadImpl::DeprecatedGetMainTaskRunner(),
request_info->render_frame_id,
......
......@@ -192,6 +192,7 @@ class CONTENT_EXPORT ResourceDispatcher {
linked_ptr<base::SharedMemory> buffer;
int buffer_size;
net::IPAddress parsed_ip;
bool network_accessed = false;
std::string mime_type;
// For mojo loading.
......
......@@ -360,6 +360,7 @@ IPC_STRUCT_TRAITS_BEGIN(network::ResourceResponseInfo)
IPC_STRUCT_TRAITS_MEMBER(ct_policy_compliance)
IPC_STRUCT_TRAITS_MEMBER(is_legacy_symantec_cert)
IPC_STRUCT_TRAITS_MEMBER(content_length)
IPC_STRUCT_TRAITS_MEMBER(network_accessed)
IPC_STRUCT_TRAITS_MEMBER(encoded_data_length)
IPC_STRUCT_TRAITS_MEMBER(encoded_body_length)
IPC_STRUCT_TRAITS_MEMBER(appcache_id)
......
......@@ -21,6 +21,7 @@ scoped_refptr<ResourceResponse> ResourceResponse::DeepCopy() const {
new_response->head.ct_policy_compliance = head.ct_policy_compliance;
new_response->head.is_legacy_symantec_cert = head.is_legacy_symantec_cert;
new_response->head.content_length = head.content_length;
new_response->head.network_accessed = head.network_accessed;
new_response->head.encoded_data_length = head.encoded_data_length;
new_response->head.encoded_body_length = head.encoded_body_length;
new_response->head.appcache_id = head.appcache_id;
......
......@@ -15,6 +15,7 @@ ResourceResponseInfo::ResourceResponseInfo()
content_length(-1),
encoded_data_length(-1),
encoded_body_length(-1),
network_accessed(false),
appcache_id(0),
was_fetched_via_spdy(false),
was_alpn_negotiated(false),
......
......@@ -69,6 +69,9 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ResourceResponseInfo {
// has been read to the end.
int64_t encoded_body_length;
// True if the request accessed the network in the process of retrieving data.
bool network_accessed;
// The appcache this response was loaded from, or kAppCacheNoCacheId.
// TODO(rdsmith): Remove conceptual dependence on appcache.
int64_t appcache_id;
......
......@@ -56,6 +56,7 @@ void PopulateResourceResponse(net::URLRequest* request,
response_info.alpn_negotiated_protocol;
response->head.connection_info = response_info.connection_info;
response->head.socket_address = response_info.socket_address;
response->head.network_accessed = response_info.network_accessed;
response->head.effective_connection_type =
net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
......
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