Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: chrome/browser/chromeos/first_run/step.cc

Issue 131023003: Added UMA metrics for ChromeOS first-run UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/first_run/step.h ('k') | chrome/browser/chromeos/first_run/step_names.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/first_run/step.cc
diff --git a/chrome/browser/chromeos/first_run/step.cc b/chrome/browser/chromeos/first_run/step.cc
index a26950c8667f72a6ec04dbc19e2e1e63a22e2aa8..b5432eea7252752e0d86096f13417b4fa5bef905 100644
--- a/chrome/browser/chromeos/first_run/step.cc
+++ b/chrome/browser/chromeos/first_run/step.cc
@@ -4,11 +4,36 @@
#include "chrome/browser/chromeos/first_run/step.h"
+#include <cctype>
+
#include "ash/first_run/first_run_helper.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/metrics/histogram.h"
#include "chrome/browser/ui/webui/chromeos/first_run/first_run_actor.h"
#include "ui/gfx/size.h"
#include "ui/views/widget/widget.h"
+namespace {
+
+// Converts from "with-dashes-names" to "WithDashesNames".
+std::string ToCamelCase(const std::string& name) {
+ std::string result;
+ bool next_to_upper = true;
+ for (size_t i = 0; i < name.length(); ++i) {
+ if (name[i] == '-') {
+ next_to_upper = true;
+ } else if (next_to_upper) {
+ result.push_back(std::toupper(name[i]));
+ next_to_upper = false;
+ } else {
+ result.push_back(name[i]);
+ }
+ }
+ return result;
+}
+
+} // namespace
+
namespace chromeos {
namespace first_run {
@@ -20,19 +45,45 @@ Step::Step(const std::string& name,
actor_(actor) {
}
-Step::~Step() {}
+Step::~Step() { RecordCompletion(); }
+
+void Step::Show() {
+ show_time_ = base::Time::Now();
+ DoShow();
+}
void Step::OnBeforeHide() {
actor()->RemoveBackgroundHoles();
+ DoOnBeforeHide();
}
void Step::OnAfterHide() {
+ RecordCompletion();
+ DoOnAfterHide();
}
gfx::Size Step::GetOverlaySize() const {
return shell_helper()->GetOverlayWidget()->GetWindowBoundsInScreen().size();
}
+void Step::RecordCompletion() {
+ if (show_time_.is_null())
+ return;
+ std::string histogram_name =
+ "CrosFirstRun.TimeSpentOnStep" + ToCamelCase(name());
+ // Equivalent to using UMA_HISTOGRAM_CUSTOM_TIMES with 50 buckets on range
+ // [100ms, 3 min.]. UMA_HISTOGRAM_CUSTOM_TIMES can not be used here, because
+ // |histogram_name| is calculated dynamically and changes from call to call.
+ base::HistogramBase* histogram = base::Histogram::FactoryTimeGet(
+ histogram_name,
+ base::TimeDelta::FromMilliseconds(100),
+ base::TimeDelta::FromMinutes(3),
+ 50,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ histogram->AddTime(base::Time::Now() - show_time_);
+ show_time_ = base::Time();
+}
+
} // namespace first_run
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/first_run/step.h ('k') | chrome/browser/chromeos/first_run/step_names.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698