Commit b5febf7e authored by jeremy@chromium.org's avatar jeremy@chromium.org

Add a histogram to measure browser window display

Measure the amount of time from app startup to when the first browser window becomes visible.

TEST=None
BUG=None


Review URL: https://chromiumcodereview.appspot.com/10662046

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148917 0039d316-1c4b-4281-b951-d872f2087c98
parent 8c1affaf
......@@ -19,6 +19,7 @@
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/process_info.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
......@@ -152,6 +153,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/profiling.h"
#include "chrome/common/startup_metric_utils.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/web_apps.h"
#include "content/public/browser/color_chooser.h"
......@@ -1195,6 +1197,26 @@ void Browser::OnWindowDidShow() {
return;
window_has_shown_ = true;
// CurrentProcessInfo::CreationTime() is currently only implemented on Mac and
// Windows.
#if defined(OS_MACOSX) || defined(OS_WIN)
// Measure the latency from startup till the first browser window becomes
// visible.
static bool is_first_browser_window = true;
if (is_first_browser_window &&
!startup_metric_utils::WasNonBrowserUIDisplayed()) {
is_first_browser_window = false;
const base::Time* process_creation_time =
base::CurrentProcessInfo::CreationTime();
if (process_creation_time) {
UMA_HISTOGRAM_LONG_TIMES(
"Startup.BrowserWindowDisplay",
base::Time::Now() - *process_creation_time);
}
}
#endif // OS_MACOSX || OS_WIN
// Nothing to do for non-tabbed windows.
if (!is_type_tabbed())
return;
......
......@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include "base/sys_string_conversions.h"
#include "chrome/common/startup_metric_utils.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -16,6 +17,8 @@ MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message,
MessageBoxType type) {
startup_metric_utils::SetNonBrowserUIDisplayed();
// Ignore the title; it's the window title on other platforms and ignorable.
NSAlert* alert = [[[NSAlert alloc] init] autorelease];
[alert setMessageText:base::SysUTF16ToNSString(message)];
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/ui/simple_message_box.h"
#include "chrome/common/startup_metric_utils.h"
#include "ui/base/win/message_box_win.h"
namespace chrome {
......@@ -12,6 +13,8 @@ MessageBoxResult ShowMessageBox(gfx::NativeWindow parent,
const string16& title,
const string16& message,
MessageBoxType type) {
startup_metric_utils::SetNonBrowserUIDisplayed();
UINT flags = MB_SETFOREGROUND;
flags |= ((type == MESSAGE_BOX_TYPE_QUESTION) ? MB_YESNO : MB_OK);
flags |= ((type == MESSAGE_BOX_TYPE_INFORMATION) ?
......
......@@ -267,6 +267,8 @@
'common/spellcheck_common.h',
'common/spellcheck_messages.h',
'common/spellcheck_result.h',
'common/startup_metric_utils.cc',
'common/startup_metric_utils.h',
'common/string_ordinal.cc',
'common/string_ordinal.h',
'common/switch_utils.cc',
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/startup_metric_utils.h"
namespace {
// Mark as volatile to defensively make sure usage is thread-safe.
// Note that at the time of this writing, access is only on the UI thread.
static volatile bool g_non_browser_ui_displayed = false;
} // namespace
namespace startup_metric_utils {
bool WasNonBrowserUIDisplayed() {
return g_non_browser_ui_displayed;
}
void SetNonBrowserUIDisplayed() {
g_non_browser_ui_displayed = true;
}
} // namespace startup_metric_utils
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_COMMON_STARTUP_METRIC_UTILS_H_
#define CHROME_COMMON_STARTUP_METRIC_UTILS_H_
// Utility functions to support metric collection for browser startup.
namespace startup_metric_utils {
// Returns true if any UI other than the browser window has been displayed
// so far. Useful to test if UI has been displayed before the first browser
// window was shown, which would invalidate any surrounding timing metrics.
bool WasNonBrowserUIDisplayed();
// Call this when displaying UI that might potentially delay the appearance
// of the initial browser window on Chrome startup.
//
// Note on usage: This function is idempotent and its overhead is low enough
// in comparison with UI display that it's OK to call it on every
// UI invocation regardless of whether the browser window has already
// been displayed or not.
void SetNonBrowserUIDisplayed();
} // namespace startup_metric_utils
#endif // CHROME_COMMON_STARTUP_METRIC_UTILS_H_
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