OLD | NEW |
---|---|
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/browser/performance_monitor/startup_timer.h" | 5 #include "chrome/browser/performance_monitor/startup_timer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 void StartupTimer::SetElapsedSessionRestoreTime( | 103 void StartupTimer::SetElapsedSessionRestoreTime( |
104 const base::TimeDelta& elapsed_session_restore_time) { | 104 const base::TimeDelta& elapsed_session_restore_time) { |
105 g_startup_timer_->elapsed_session_restore_times_.push_back( | 105 g_startup_timer_->elapsed_session_restore_times_.push_back( |
106 elapsed_session_restore_time); | 106 elapsed_session_restore_time); |
107 | 107 |
108 if (g_startup_timer_->performance_monitor_initialized_) | 108 if (g_startup_timer_->performance_monitor_initialized_) |
109 g_startup_timer_->InsertElapsedSessionRestoreTime(); | 109 g_startup_timer_->InsertElapsedSessionRestoreTime(); |
110 } | 110 } |
111 | 111 |
112 void StartupTimer::InsertElapsedStartupTime() { | 112 void StartupTimer::InsertElapsedStartupTime() { |
113 performance_monitor::Database* database = | |
Yoyo Zhou
2013/10/03 22:08:50
You should be able to remove this now.
Finnur
2013/10/04 17:57:02
Indeed.
| |
114 PerformanceMonitor::GetInstance()->database(); | |
115 // TODO(finnur): This is temporary to work around bug 303719 where the | |
116 // startup timer is taking requests to log without the performance monitor | |
117 // having created a database to store it. | |
118 if (!database) | |
119 return; | |
113 content::BrowserThread::PostBlockingPoolSequencedTask( | 120 content::BrowserThread::PostBlockingPoolSequencedTask( |
114 Database::kDatabaseSequenceToken, | 121 Database::kDatabaseSequenceToken, |
115 FROM_HERE, | 122 FROM_HERE, |
116 base::Bind( | 123 base::Bind( |
117 &AddMetricToDatabaseOnBackgroundThread, | 124 &AddMetricToDatabaseOnBackgroundThread, |
118 base::Unretained(PerformanceMonitor::GetInstance()->database()), | 125 base::Unretained(database), |
119 Metric(startup_type_ == STARTUP_NORMAL ? METRIC_STARTUP_TIME | 126 Metric(startup_type_ == STARTUP_NORMAL ? METRIC_STARTUP_TIME |
120 : METRIC_TEST_STARTUP_TIME, | 127 : METRIC_TEST_STARTUP_TIME, |
121 base::Time::Now(), | 128 base::Time::Now(), |
122 static_cast<double>( | 129 static_cast<double>( |
123 elapsed_startup_time_.ToInternalValue())))); | 130 elapsed_startup_time_.ToInternalValue())))); |
124 } | 131 } |
125 | 132 |
126 void StartupTimer::InsertElapsedSessionRestoreTime() { | 133 void StartupTimer::InsertElapsedSessionRestoreTime() { |
127 for (std::vector<base::TimeDelta>::const_iterator iter = | 134 for (std::vector<base::TimeDelta>::const_iterator iter = |
128 elapsed_session_restore_times_.begin(); | 135 elapsed_session_restore_times_.begin(); |
129 iter != elapsed_session_restore_times_.end(); ++iter) { | 136 iter != elapsed_session_restore_times_.end(); ++iter) { |
137 performance_monitor::Database* database = | |
138 PerformanceMonitor::GetInstance()->database(); | |
139 // TODO(finnur): This is temporary to work around bug 303719 where the | |
140 // startup timer is taking requests to log without the performance monitor | |
141 // having created a database to store it. | |
142 if (!database) | |
143 return; | |
130 content::BrowserThread::PostBlockingPoolSequencedTask( | 144 content::BrowserThread::PostBlockingPoolSequencedTask( |
131 Database::kDatabaseSequenceToken, | 145 Database::kDatabaseSequenceToken, |
132 FROM_HERE, | 146 FROM_HERE, |
133 base::Bind( | 147 base::Bind( |
134 &AddMetricToDatabaseOnBackgroundThread, | 148 &AddMetricToDatabaseOnBackgroundThread, |
135 base::Unretained(PerformanceMonitor::GetInstance()->database()), | 149 base::Unretained(database), |
136 Metric(METRIC_SESSION_RESTORE_TIME, | 150 Metric(METRIC_SESSION_RESTORE_TIME, |
137 base::Time::Now(), | 151 base::Time::Now(), |
138 static_cast<double>(iter->ToInternalValue())))); | 152 static_cast<double>(iter->ToInternalValue())))); |
139 } | 153 } |
140 } | 154 } |
141 | 155 |
142 } // namespace performance_monitor | 156 } // namespace performance_monitor |
OLD | NEW |