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

Side by Side Diff: chrome/common/startup_metric_utils.cc

Issue 23443009: [Android] Support startup histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [Android] Support startup histogram; remove unnecessary change to AwShellApplication.java Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/startup_metric_utils.h" 5 #include "chrome/common/startup_metric_utils.h"
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
11 #include "base/metrics/statistics_recorder.h" 11 #include "base/metrics/statistics_recorder.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/sys_info.h" 13 #include "base/sys_info.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 15
16 namespace { 16 namespace {
17 17
18 // Mark as volatile to defensively make sure usage is thread-safe. 18 // Mark as volatile to defensively make sure usage is thread-safe.
19 // Note that at the time of this writing, access is only on the UI thread. 19 // Note that at the time of this writing, access is only on the UI thread.
20 volatile bool g_non_browser_ui_displayed = false; 20 volatile bool g_non_browser_ui_displayed = false;
21 21
22 const base::Time* MainEntryPointTimeInternal() { 22 base::Time* MainEntryPointTimeInternal() {
23 static base::Time main_start_time = base::Time::Now(); 23 static base::Time main_start_time = base::Time::Now();
24 return &main_start_time; 24 return &main_start_time;
25 } 25 }
26 26
27 typedef base::hash_map<std::string,base::TimeDelta> SubsystemStartupTimeHash; 27 typedef base::hash_map<std::string,base::TimeDelta> SubsystemStartupTimeHash;
28 28
29 SubsystemStartupTimeHash* GetSubsystemStartupTimeHash() { 29 SubsystemStartupTimeHash* GetSubsystemStartupTimeHash() {
30 static SubsystemStartupTimeHash* slow_startup_time_hash = 30 static SubsystemStartupTimeHash* slow_startup_time_hash =
31 new SubsystemStartupTimeHash; 31 new SubsystemStartupTimeHash;
32 return slow_startup_time_hash; 32 return slow_startup_time_hash;
(...skipping 16 matching lines...) Expand all
49 return g_non_browser_ui_displayed; 49 return g_non_browser_ui_displayed;
50 } 50 }
51 51
52 void SetNonBrowserUIDisplayed() { 52 void SetNonBrowserUIDisplayed() {
53 g_non_browser_ui_displayed = true; 53 g_non_browser_ui_displayed = true;
54 } 54 }
55 55
56 void RecordMainEntryPointTime() { 56 void RecordMainEntryPointTime() {
57 DCHECK(!g_main_entry_time_was_recorded); 57 DCHECK(!g_main_entry_time_was_recorded);
58 g_main_entry_time_was_recorded = true; 58 g_main_entry_time_was_recorded = true;
59 MainEntryPointTimeInternal(); 59 *MainEntryPointTimeInternal() = base::Time::Now();
jeremy 2013/08/27 19:18:51 Sorry, I don't understand this change?
aberent 2013/08/28 15:53:05 Done. You are right, it isn't needed.
60 }
61
62 void RecordSavedMainEntryPointTime(const base::Time& entry_point_time) {
jeremy 2013/08/27 19:18:51 Again #if defined(OS_ANDROID)
aberent 2013/08/28 15:53:05 Done.
63 DCHECK(!g_main_entry_time_was_recorded);
64 g_main_entry_time_was_recorded = true;
65 *MainEntryPointTimeInternal() = entry_point_time;
60 } 66 }
61 67
62 // Return the time recorded by RecordMainEntryPointTime(). 68 // Return the time recorded by RecordMainEntryPointTime().
63 const base::Time MainEntryStartTime() { 69 const base::Time MainEntryStartTime() {
64 DCHECK(g_main_entry_time_was_recorded); 70 DCHECK(g_main_entry_time_was_recorded);
65 return *MainEntryPointTimeInternal(); 71 return *MainEntryPointTimeInternal();
66 } 72 }
67 73
68 void OnBrowserStartupComplete(bool is_first_run) { 74 void OnBrowserStartupComplete(bool is_first_run) {
69 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been 75 // Bail if uptime < 7 minutes, to filter out cases where Chrome may have been
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 SubsystemStartupTimeHash* hash = GetSubsystemStartupTimeHash(); 158 SubsystemStartupTimeHash* hash = GetSubsystemStartupTimeHash();
153 // Only record the initial sample for a given histogram. 159 // Only record the initial sample for a given histogram.
154 if (hash->find(histogram_name_) != hash->end()) 160 if (hash->find(histogram_name_) != hash->end())
155 return; 161 return;
156 162
157 (*hash)[histogram_name_] = 163 (*hash)[histogram_name_] =
158 base::TimeTicks::Now() - start_time_; 164 base::TimeTicks::Now() - start_time_;
159 } 165 }
160 166
161 } // namespace startup_metric_utils 167 } // namespace startup_metric_utils
OLDNEW
« chrome/common/startup_metric_utils.h ('K') | « chrome/common/startup_metric_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698