diff options
author | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-27 18:32:44 +0000 |
---|---|---|
committer | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-27 18:32:44 +0000 |
commit | 1f8c6499def067317e79febee33aa0853dc8db95 (patch) | |
tree | 3aa7295974f893815d2a8af2b6e0c5efd341517b /chrome/browser/net/load_timing_observer.cc | |
parent | 6494823b83620eb43763364d4bb775e36f4d452e (diff) | |
download | chromium_src-1f8c6499def067317e79febee33aa0853dc8db95.zip chromium_src-1f8c6499def067317e79febee33aa0853dc8db95.tar.gz chromium_src-1f8c6499def067317e79febee33aa0853dc8db95.tar.bz2 |
Fix bug where Navigation Timing reports negative load time when redirecting to
a cached page.
The problem is that the same ResourceLoadTiming struct is re-used for each
redirect. So, we record the deltas for connect time, headers, send request, etc.,
for each redirect. But, after the last redirect, we simply have a cache hit. So,
the base_time is updated for that cache hit, but the deltas are still relative
to the old base_time value. When we apply the old deltas to the new base_time,
we end up with a time in the future.
To fix this, I clear ResourceLoadTimingInfo after each redirect.
I've added a UI test for this. I could've done a unit test, but we have no end-
to-end Navigation Timing tests and it'd be easy for this to be broken by some
unrelated change to NetLog and redirects, so I prefer having this test be a
safe guard.
On a related note, I noticed that LoadTimingObserver::OnAddURLRequestEntry() is
called at least twice for each source.id. Once for the normal URLRequest, and
once for the AppCacheURLRequest. Fortunately, they're only 100 ns apart, so it
doesn't screw up the times. But, it was a surprise to me. Perhaps we should
ignore the AppCache requests?
BUG=None
TEST=ui_tests
Review URL: http://codereview.chromium.org/8336012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/load_timing_observer.cc')
-rw-r--r-- | chrome/browser/net/load_timing_observer.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/chrome/browser/net/load_timing_observer.cc b/chrome/browser/net/load_timing_observer.cc index 788394f..87be841 100644 --- a/chrome/browser/net/load_timing_observer.cc +++ b/chrome/browser/net/load_timing_observer.cc @@ -150,6 +150,7 @@ void LoadTimingObserver::OnAddURLRequestEntry( URLRequestRecord& record = url_request_to_record_[source.id]; record.base_ticks = time; + record.timing = ResourceLoadTimingInfo(); record.timing.base_time = TimeTicksToTime(time); } return; @@ -206,9 +207,9 @@ void LoadTimingObserver::OnAddURLRequestEntry( break; case net::NetLog::TYPE_HTTP_TRANSACTION_READ_HEADERS: if (is_begin) - timing.receive_headers_start = TimeTicksToOffset(time, record); + timing.receive_headers_start = TimeTicksToOffset(time, record); else if (is_end) - timing.receive_headers_end = TimeTicksToOffset(time, record); + timing.receive_headers_end = TimeTicksToOffset(time, record); break; default: break; |