Commit 193879ec authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Clean up time computation in SearchBox::LogEvent

LogEvent computes the time between the current event and navigation
start. It gets the navigation start time from WebPerformance::
NavigationStart() which is a wall time (i.e. base::Time), but before
this CL, it got the current time from base::TimeTicks::Now(). This CL
fixes that by using base::Time::Now() instead and also cleans up the
code a bit.

I believe this is a pure cleanup, though I'm not entirely sure if the
old way always delivered well-defined results.

Bug: 777568
Change-Id: I81ed3e1fae2650a6bbc053ae8a4917a8e6c91f5e
Reviewed-on: https://chromium-review.googlesource.com/776854
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517866}
parent b2ebd005
......@@ -230,13 +230,10 @@ SearchBox::SearchBox(content::RenderFrame* render_frame)
SearchBox::~SearchBox() = default;
void SearchBox::LogEvent(NTPLoggingEventType event) {
// navigation_start in ms.
uint64_t start =
1000 * (render_frame()->GetWebFrame()->Performance().NavigationStart());
uint64_t now =
(base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InMilliseconds();
DCHECK(now >= start);
base::TimeDelta delta = base::TimeDelta::FromMilliseconds(now - start);
base::Time navigation_start = base::Time::FromDoubleT(
render_frame()->GetWebFrame()->Performance().NavigationStart());
base::Time now = base::Time::Now();
base::TimeDelta delta = now - navigation_start;
embedded_search_service_->LogEvent(page_seq_no_, event, delta);
}
......
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