diff options
author | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-05 23:59:24 +0000 |
---|---|---|
committer | simonjam@chromium.org <simonjam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-05 23:59:24 +0000 |
commit | d30237313646c9636991f6cb0d278761dbe775fb (patch) | |
tree | 63a84179e90dd83ef4e353ea4ee8e66e874cf207 /content/renderer/render_view_impl.cc | |
parent | 433f3edb01e1b8a3e58a115e40ac52ff00a61862 (diff) | |
download | chromium_src-d30237313646c9636991f6cb0d278761dbe775fb.zip chromium_src-d30237313646c9636991f6cb0d278761dbe775fb.tar.gz chromium_src-d30237313646c9636991f6cb0d278761dbe775fb.tar.bz2 |
Fix performance.timing.navigationStart on cross-renderer navigation.
According to the Navigation Timing spec, this value should be right after
beforeunload fires on the previous document. On cross-renderer navigations,
we were instead using the no-previous-document code path. The result is that
navigationStart is 80 - 500 ms earlier and lines up better with other load
time metrics.
I have a test case in mind that should be pretty reliable, but it will no
longer work once we update to make navigationStart 0 and base all other times
from that. Given that, I'm not sure it's worth writing the test, only to have
it removed in the next test. My idea was to have one tab initiate the navigation
in another tab, then record the time. navigationStart should be < the recorded
time. If you have any other ideas how to test this, please let me know.
See also: https://bugs.webkit.org/show_bug.cgi?id=75922
BUG=104788
TEST=Added printfs.
Review URL: http://codereview.chromium.org/9166003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/render_view_impl.cc')
-rw-r--r-- | content/renderer/render_view_impl.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index e423d61..3da74dc 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -787,6 +787,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) + IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime, + OnSetNavigationStartTime) #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) @@ -4301,8 +4303,12 @@ void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( } void RenderViewImpl::OnShouldClose() { + base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); bool should_close = webview()->dispatchBeforeUnloadEvent(); - Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close)); + base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); + Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, + before_unload_start_time, + before_unload_end_time)); } void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { @@ -4548,6 +4554,25 @@ void RenderViewImpl::OnSetActive(bool active) { #endif } +void RenderViewImpl::OnSetNavigationStartTime( + const base::TimeTicks& browser_navigation_start) { + if (!webview()) + return; + + // Only the initial navigation can be a cross-renderer navigation. If we've + // already navigated away from that page, we can ignore this message. + if (page_id_ != -1) + return; + + // browser_navigation_start is likely before this process existed, so we can't + // use InterProcessTimeTicksConverter. Instead, the best we can do is just + // ensure we don't report a bogus value in the future. + base::TimeTicks navigation_start = std::min(base::TimeTicks::Now(), + browser_navigation_start); + webview()->mainFrame()->provisionalDataSource()->setNavigationStartTime( + (navigation_start - base::TimeTicks()).InSecondsF()); +} + #if defined(OS_MACOSX) void RenderViewImpl::OnSetWindowVisibility(bool visible) { // Inform plugins that their container has changed visibility. |