1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_STARTUP_METRIC_UTILS_STARTUP_METRIC_UTILS_H_
6 #define COMPONENTS_STARTUP_METRIC_UTILS_STARTUP_METRIC_UTILS_H_
10 #include "base/time/time.h"
12 // Utility functions to support metric collection for browser startup.
14 namespace startup_metric_utils
{
16 // Returns true if any UI other than the browser window has been displayed
17 // so far. Useful to test if UI has been displayed before the first browser
18 // window was shown, which would invalidate any surrounding timing metrics.
19 bool WasNonBrowserUIDisplayed();
21 // Call this when displaying UI that might potentially delay the appearance
22 // of the initial browser window on Chrome startup.
24 // Note on usage: This function is idempotent and its overhead is low enough
25 // in comparison with UI display that it's OK to call it on every
26 // UI invocation regardless of whether the browser window has already
27 // been displayed or not.
28 void SetNonBrowserUIDisplayed();
30 // Call this with the creation time of the startup (initial/main) process.
31 void RecordStartupProcessCreationTime(const base::Time
& time
);
33 // Call this with a time recorded as early as possible in the startup process.
34 // On Android, the entry point time is the time at which the Java code starts.
35 // In Mojo, the entry point time is the time at which the shell starts.
36 void RecordMainEntryPointTime(const base::Time
& time
);
38 // Call this with the time when the executable is loaded and main() is entered.
39 // Can be different from |RecordMainEntryPointTime| when the startup process is
40 // contained in a separate dll, such as with chrome.exe / chrome.dll on Windows.
41 void RecordExeMainEntryPointTime(const base::Time
& time
);
43 // Call this with the time recorded just before the message loop is started.
44 // |is_first_run| - is the current launch part of a first run.
45 void RecordBrowserMainMessageLoopStart(const base::Time
& time
,
48 // Call this with the time when the first browser window became visible.
49 void RecordBrowserWindowDisplay(const base::Time
& time
);
51 // Call this with the time delta that the browser spent opening its tabs.
52 void RecordBrowserOpenTabsDelta(const base::TimeDelta
& delta
);
54 // Call this with the time when the first web contents loaded its main frame.
55 void RecordFirstWebContentsMainFrameLoad(const base::Time
& time
);
57 // Call this with the time when the first web contents had a non-empty paint.
58 void RecordFirstWebContentsNonEmptyPaint(const base::Time
& time
);
60 // Returns the time of main entry recorded from RecordMainEntryPointTime.
61 // Returns a null Time if a value has not been recorded yet.
62 // This method is expected to be called from the UI thread.
63 base::Time
MainEntryPointTime();
65 } // namespace startup_metric_utils
67 #endif // COMPONENTS_STARTUP_METRIC_UTILS_STARTUP_METRIC_UTILS_H_