Commit 199fda5b authored by oka@chromium.org's avatar oka@chromium.org Committed by Commit Bot

Make sure sane first load time UMA is exported.

In the following scenario, time between (1) to (4) was exported.
We should export the time for (4).

(1) ShowKeyboard is called
(2) Before animation finishes, HideKeyboard is called
(3) time passes.
(4) ShowKeyboard is called and keyboard is actually shown.

Bug: 742721
Change-Id: I1fc3a92cea7bfce25e8efb407a3e41508a367c36
Reviewed-on: https://chromium-review.googlesource.com/571108Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Commit-Queue: Keigo Oka <oka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486712}
parent e6175fba
...@@ -44,6 +44,7 @@ void SendProcessKeyEvent(ui::EventType type, ...@@ -44,6 +44,7 @@ void SendProcessKeyEvent(ui::EventType type,
CHECK(!details.dispatcher_destroyed); CHECK(!details.dispatcher_destroyed);
} }
bool g_keyboard_load_time_logged = false;
base::LazyInstance<base::Time>::DestructorAtExit g_keyboard_load_time_start = base::LazyInstance<base::Time>::DestructorAtExit g_keyboard_load_time_start =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
...@@ -282,7 +283,7 @@ bool SendKeyEvent(const std::string type, ...@@ -282,7 +283,7 @@ bool SendKeyEvent(const std::string type,
} }
void MarkKeyboardLoadStarted() { void MarkKeyboardLoadStarted() {
if (g_keyboard_load_time_start.Get().is_null()) if (!g_keyboard_load_time_logged)
g_keyboard_load_time_start.Get() = base::Time::Now(); g_keyboard_load_time_start.Get() = base::Time::Now();
} }
...@@ -292,13 +293,12 @@ void MarkKeyboardLoadFinished() { ...@@ -292,13 +293,12 @@ void MarkKeyboardLoadFinished() {
if (g_keyboard_load_time_start.Get().is_null()) if (g_keyboard_load_time_start.Get().is_null())
return; return;
static bool logged = false; if (!g_keyboard_load_time_logged) {
if (!logged) {
// Log the delta only once. // Log the delta only once.
UMA_HISTOGRAM_TIMES( UMA_HISTOGRAM_TIMES(
"VirtualKeyboard.InitLatency.FirstLoad", "VirtualKeyboard.InitLatency.FirstLoad",
base::Time::Now() - g_keyboard_load_time_start.Get()); base::Time::Now() - g_keyboard_load_time_start.Get());
logged = true; g_keyboard_load_time_logged = true;
} }
} }
......
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