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) ...@@ -230,13 +230,10 @@ SearchBox::SearchBox(content::RenderFrame* render_frame)
SearchBox::~SearchBox() = default; SearchBox::~SearchBox() = default;
void SearchBox::LogEvent(NTPLoggingEventType event) { void SearchBox::LogEvent(NTPLoggingEventType event) {
// navigation_start in ms. base::Time navigation_start = base::Time::FromDoubleT(
uint64_t start = render_frame()->GetWebFrame()->Performance().NavigationStart());
1000 * (render_frame()->GetWebFrame()->Performance().NavigationStart()); base::Time now = base::Time::Now();
uint64_t now = base::TimeDelta delta = now - navigation_start;
(base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InMilliseconds();
DCHECK(now >= start);
base::TimeDelta delta = base::TimeDelta::FromMilliseconds(now - start);
embedded_search_service_->LogEvent(page_seq_no_, event, delta); 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