| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 class TimeMarker { | 133 class TimeMarker { |
| 134 public: | 134 public: |
| 135 TimeMarker(const std::string& name, bool send_to_uma) | 135 TimeMarker(const std::string& name, bool send_to_uma) |
| 136 : name_(name), | 136 : name_(name), |
| 137 time_(base::Time::NowFromSystemTime()), | 137 time_(base::Time::NowFromSystemTime()), |
| 138 send_to_uma_(send_to_uma) {} | 138 send_to_uma_(send_to_uma) {} |
| 139 std::string name() const { return name_; } | 139 std::string name() const { return name_; } |
| 140 base::Time time() const { return time_; } | 140 base::Time time() const { return time_; } |
| 141 bool send_to_uma() const { return send_to_uma_; } | 141 bool send_to_uma() const { return send_to_uma_; } |
| 142 | 142 |
| 143 // comparitor for sorting |
| 144 bool operator<(const TimeMarker& other) const { |
| 145 return time_ < other.time_; |
| 146 } |
| 147 |
| 143 private: | 148 private: |
| 144 friend class std::vector<TimeMarker>; | 149 friend class std::vector<TimeMarker>; |
| 145 std::string name_; | 150 std::string name_; |
| 146 base::Time time_; | 151 base::Time time_; |
| 147 bool send_to_uma_; | 152 bool send_to_uma_; |
| 148 }; | 153 }; |
| 149 | 154 |
| 150 struct Stats { | 155 struct Stats { |
| 151 public: | 156 public: |
| 152 std::string uptime; | 157 std::string uptime; |
| 153 std::string disk; | 158 std::string disk; |
| 154 }; | 159 }; |
| 155 | 160 |
| 156 static void RecordStats( | 161 static void RecordStats( |
| 157 const std::string& name, const Stats& stats); | 162 const std::string& name, const Stats& stats); |
| 158 static Stats GetCurrentStats(); | 163 static Stats GetCurrentStats(); |
| 159 static void WriteTimes(const std::string base_name, | 164 static void WriteTimes(const std::string base_name, |
| 160 const std::string uma_name, | 165 const std::string uma_name, |
| 161 const std::string uma_prefix, | 166 const std::string uma_prefix, |
| 162 const std::vector<TimeMarker> login_times); | 167 std::vector<TimeMarker> login_times); |
| 168 static void AddMarker( |
| 169 std::vector<TimeMarker>* vector, const TimeMarker& marker); |
| 170 static void AddMarkerImpl(std::vector<TimeMarker>* vector, TimeMarker marker); |
| 171 |
| 163 void LoginDone(); | 172 void LoginDone(); |
| 164 | 173 |
| 165 // Used to hold the stats at main(). | 174 // Used to hold the stats at main(). |
| 166 Stats chrome_main_stats_; | 175 Stats chrome_main_stats_; |
| 167 scoped_refptr<Backend> backend_; | 176 scoped_refptr<Backend> backend_; |
| 168 | 177 |
| 169 // Used to track notifications for login. | 178 // Used to track notifications for login. |
| 170 content::NotificationRegistrar registrar_; | 179 content::NotificationRegistrar registrar_; |
| 171 base::AtomicSequenceNumber num_tabs_; | 180 base::AtomicSequenceNumber num_tabs_; |
| 172 bool have_registered_; | 181 bool have_registered_; |
| 173 | 182 |
| 174 std::vector<TimeMarker> login_time_markers_; | 183 std::vector<TimeMarker> login_time_markers_; |
| 175 std::vector<TimeMarker> logout_time_markers_; | 184 std::vector<TimeMarker> logout_time_markers_; |
| 176 std::set<RenderWidgetHost*> render_widget_hosts_loading_; | 185 std::set<RenderWidgetHost*> render_widget_hosts_loading_; |
| 177 | 186 |
| 178 DISALLOW_COPY_AND_ASSIGN(BootTimesLoader); | 187 DISALLOW_COPY_AND_ASSIGN(BootTimesLoader); |
| 179 }; | 188 }; |
| 180 | 189 |
| 181 } // namespace chromeos | 190 } // namespace chromeos |
| 182 | 191 |
| 183 #endif // CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ | 192 #endif // CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ |
| OLD | NEW |