Commit bb2025ae authored by Conley Owens's avatar Conley Owens Committed by Commit Bot

Report was_cached in SubresourceLoadInfo

This change adds a boolean `was_cached` to the SubresourceLoadInfo
struct. This lets consumers know whether or not the response was
fetched from the network cache. Notably, this is important for
recording page load metrics when the Network Service is enabled.

This reverts commit 0b2b1a92.

Issues in the previous commit are fixed by retaining the exists_in_cache
field.

In a many cases when NavigationURLLoaderDelegate::OnRequestFailed() is
called, NavigationURLLoaderNetworkService::OnResponseStarted() has not
been called. In these cases, we cannot rely on using a stored
was_cached value, since it may not be properly updated.

BUG=816684,822237

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I0beb72b825ae0a12122170cec2e4f4358dda58af
Reviewed-on: https://chromium-review.googlesource.com/966792Reviewed-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@{#545626}
parent 56744e97
...@@ -594,6 +594,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, ...@@ -594,6 +594,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
GURL subresource_url = embedded_test_server()->GetURL("/cachetime"); GURL subresource_url = embedded_test_server()->GetURL("/cachetime");
ASSERT_TRUE(subresource_load_info); ASSERT_TRUE(subresource_load_info);
EXPECT_EQ(subresource_url, subresource_load_info->url); EXPECT_EQ(subresource_url, subresource_load_info->url);
EXPECT_FALSE(subresource_load_info->was_cached);
observer.Reset(); observer.Reset();
// Loading again should serve the request out of the in-memory cache. // Loading again should serve the request out of the in-memory cache.
...@@ -611,6 +612,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, ...@@ -611,6 +612,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
subresource_load_info = observer.last_subresource_load_info(); subresource_load_info = observer.last_subresource_load_info();
ASSERT_TRUE(subresource_load_info); ASSERT_TRUE(subresource_load_info);
EXPECT_EQ(subresource_url, subresource_load_info->url); EXPECT_EQ(subresource_url, subresource_load_info->url);
EXPECT_TRUE(subresource_load_info->was_cached);
EXPECT_FALSE(observer.last_memory_cached_loaded_url().is_valid()); EXPECT_FALSE(observer.last_memory_cached_loaded_url().is_valid());
} }
......
...@@ -25,4 +25,7 @@ struct SubresourceLoadInfo { ...@@ -25,4 +25,7 @@ struct SubresourceLoadInfo {
// The host IP. // The host IP.
net.interfaces.IPAddress? ip; net.interfaces.IPAddress? ip;
// True if the response was fetched from the network cache.
bool was_cached;
}; };
...@@ -273,6 +273,7 @@ void ResourceDispatcher::OnRequestComplete( ...@@ -273,6 +273,7 @@ void ResourceDispatcher::OnRequestComplete(
subresource_load_info->resource_type = request_info->resource_type; subresource_load_info->resource_type = request_info->resource_type;
if (request_info->parsed_ip.IsValid()) if (request_info->parsed_ip.IsValid())
subresource_load_info->ip = request_info->parsed_ip; subresource_load_info->ip = request_info->parsed_ip;
subresource_load_info->was_cached = status.exists_in_cache;
NotifySubresourceLoadComplete( NotifySubresourceLoadComplete(
RenderThreadImpl::DeprecatedGetMainTaskRunner(), RenderThreadImpl::DeprecatedGetMainTaskRunner(),
request_info->render_frame_id, std::move(subresource_load_info)); request_info->render_frame_id, std::move(subresource_load_info));
......
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