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

Side by Side Diff: chrome/browser/chromeos/boot_times_loader.h

Issue 9453026: Make BootTimesLoader marker usage thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with trunk Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/boot_times_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(std::vector<TimeMarker>* vector, TimeMarker marker);
169
163 void LoginDone(); 170 void LoginDone();
164 171
165 // Used to hold the stats at main(). 172 // Used to hold the stats at main().
166 Stats chrome_main_stats_; 173 Stats chrome_main_stats_;
167 scoped_refptr<Backend> backend_; 174 scoped_refptr<Backend> backend_;
168 175
169 // Used to track notifications for login. 176 // Used to track notifications for login.
170 content::NotificationRegistrar registrar_; 177 content::NotificationRegistrar registrar_;
171 base::AtomicSequenceNumber num_tabs_; 178 base::AtomicSequenceNumber num_tabs_;
172 bool have_registered_; 179 bool have_registered_;
173 180
174 std::vector<TimeMarker> login_time_markers_; 181 std::vector<TimeMarker> login_time_markers_;
175 std::vector<TimeMarker> logout_time_markers_; 182 std::vector<TimeMarker> logout_time_markers_;
176 std::set<RenderWidgetHost*> render_widget_hosts_loading_; 183 std::set<RenderWidgetHost*> render_widget_hosts_loading_;
177 184
178 DISALLOW_COPY_AND_ASSIGN(BootTimesLoader); 185 DISALLOW_COPY_AND_ASSIGN(BootTimesLoader);
179 }; 186 };
180 187
181 } // namespace chromeos 188 } // namespace chromeos
182 189
183 #endif // CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_ 190 #endif // CHROME_BROWSER_CHROMEOS_BOOT_TIMES_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/boot_times_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698