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

Side by Side Diff: metrics_daemon.h

Issue 6486021: Collect some disk statistics. (Closed) Base URL: http://git.chromium.org/git/metrics.git@master
Patch Set: remove duplicate log and close file Created 9 years, 10 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 | metrics_daemon.cc » ('j') | metrics_daemon.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 METRICS_DAEMON_H_ 5 #ifndef METRICS_DAEMON_H_
6 #define METRICS_DAEMON_H_ 6 #define METRICS_DAEMON_H_
7 7
8 #include <dbus/dbus.h> 8 #include <dbus/dbus.h>
9 #include <glib.h> 9 #include <glib.h>
10 #include <map> 10 #include <map>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 }; 70 };
71 71
72 // The user session states (see session_states.h). 72 // The user session states (see session_states.h).
73 enum SessionState { 73 enum SessionState {
74 kUnknownSessionState = -1, // Initial/unknown user session state. 74 kUnknownSessionState = -1, // Initial/unknown user session state.
75 #define STATE(name, capname) kSessionState ## capname, 75 #define STATE(name, capname) kSessionState ## capname,
76 #include "session_states.h" 76 #include "session_states.h"
77 kNumberSessionStates 77 kNumberSessionStates
78 }; 78 };
79 79
80 // State for disk stats collector callback.
81 enum DiskStatsState {
82 kDiskStatsShort, // short wait before short interval collection
83 kDiskStatsLong, // final wait before new collection
84 };
85
80 // Data record for aggregating daily usage. 86 // Data record for aggregating daily usage.
81 class UseRecord { 87 class UseRecord {
82 public: 88 public:
83 UseRecord() : day_(0), seconds_(0) {} 89 UseRecord() : day_(0), seconds_(0) {}
84 int day_; 90 int day_;
85 int seconds_; 91 int seconds_;
86 }; 92 };
87 93
88 typedef std::map<std::string, chromeos_metrics::FrequencyCounter*> 94 typedef std::map<std::string, chromeos_metrics::FrequencyCounter*>
89 FrequencyCounters; 95 FrequencyCounters;
(...skipping 14 matching lines...) Expand all
104 static const char kMetricKernelCrashesDailyName[]; 110 static const char kMetricKernelCrashesDailyName[];
105 static const char kMetricKernelCrashesWeeklyName[]; 111 static const char kMetricKernelCrashesWeeklyName[];
106 static const char kMetricKernelCrashIntervalName[]; 112 static const char kMetricKernelCrashIntervalName[];
107 static const char kMetricsPath[]; 113 static const char kMetricsPath[];
108 static const char kMetricUncleanShutdownIntervalName[]; 114 static const char kMetricUncleanShutdownIntervalName[];
109 static const char kMetricUncleanShutdownsDailyName[]; 115 static const char kMetricUncleanShutdownsDailyName[];
110 static const char kMetricUncleanShutdownsWeeklyName[]; 116 static const char kMetricUncleanShutdownsWeeklyName[];
111 static const char kMetricUserCrashesDailyName[]; 117 static const char kMetricUserCrashesDailyName[];
112 static const char kMetricUserCrashesWeeklyName[]; 118 static const char kMetricUserCrashesWeeklyName[];
113 static const char kMetricUserCrashIntervalName[]; 119 static const char kMetricUserCrashIntervalName[];
120 static const char kMetricReadSectorsLongName[];
121 static const char kMetricReadSectorsShortName[];
122 static const char kMetricWriteSectorsLongName[];
123 static const char kMetricWriteSectorsShortName[];
124 static const int kMetricDiskStatsShortInterval;
125 static const int kMetricDiskStatsLongInterval;
126 static const int kMetricSectorsIOMax;
127 static const int kMetricSectorsBuckets;
128 static const char kMetricsDiskStatsPath[];
114 129
115 // D-Bus message match strings. 130 // D-Bus message match strings.
116 static const char* kDBusMatches_[]; 131 static const char* kDBusMatches_[];
117 132
118 // Array of power states. 133 // Array of power states.
119 static const char* kPowerStates_[kNumberPowerStates]; 134 static const char* kPowerStates_[kNumberPowerStates];
120 135
121 // Array of user session states. 136 // Array of user session states.
122 static const char* kSessionStates_[kNumberSessionStates]; 137 static const char* kSessionStates_[kNumberSessionStates];
123 138
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 225
211 // Report daily use through UMA. 226 // Report daily use through UMA.
212 static void ReportDailyUse(void* handle, int tag, int count); 227 static void ReportDailyUse(void* handle, int tag, int count);
213 228
214 // Sends a regular (exponential) histogram sample to Chrome for 229 // Sends a regular (exponential) histogram sample to Chrome for
215 // transport to UMA. See MetricsLibrary::SendToUMA in 230 // transport to UMA. See MetricsLibrary::SendToUMA in
216 // metrics_library.h for a description of the arguments. 231 // metrics_library.h for a description of the arguments.
217 void SendMetric(const std::string& name, int sample, 232 void SendMetric(const std::string& name, int sample,
218 int min, int max, int nbuckets); 233 int min, int max, int nbuckets);
219 234
235 // Initializes disk stats reporting.
236 void DiskStatsReporterInit();
237
238 // Schedules a callback for the next disk stats collection.
239 void ScheduleDiskStatsCallback(int wait);
240
241 // Reads cumulative disk statistics from sysfs.
242 void DiskStatsReadStats(long int* read_sectors, long int* write_sectors);
243
244 // Reports disk statistics (static version for glib). Arguments are a glib
245 // artifact.
246 static gboolean DiskStatsCallbackStatic(void* handle);
247
248 // Reports disk statistics.
249 void DiskStatsCallback();
250
220 // Test mode. 251 // Test mode.
221 bool testing_; 252 bool testing_;
222 253
223 // The metrics library handle. 254 // The metrics library handle.
224 MetricsLibraryInterface* metrics_lib_; 255 MetricsLibraryInterface* metrics_lib_;
225 256
226 // Timestamps last network state update. This timestamp is used to 257 // Timestamps last network state update. This timestamp is used to
227 // sample the time from the network going online to going offline so 258 // sample the time from the network going online to going offline so
228 // TimeTicks ensures a monotonically increasing TimeDelta. 259 // TimeTicks ensures a monotonically increasing TimeDelta.
229 base::TimeTicks network_state_last_; 260 base::TimeTicks network_state_last_;
(...skipping 28 matching lines...) Expand all
258 289
259 // Map of all frequency counters, to simplify flushing them. 290 // Map of all frequency counters, to simplify flushing them.
260 FrequencyCounters frequency_counters_; 291 FrequencyCounters frequency_counters_;
261 292
262 // Sleep period until the next daily usage aggregation performed by 293 // Sleep period until the next daily usage aggregation performed by
263 // the daily use monitor (see ScheduleUseMonitor). 294 // the daily use monitor (see ScheduleUseMonitor).
264 int usemon_interval_; 295 int usemon_interval_;
265 296
266 // Scheduled daily use monitor source (see ScheduleUseMonitor). 297 // Scheduled daily use monitor source (see ScheduleUseMonitor).
267 GSource* usemon_source_; 298 GSource* usemon_source_;
299
300 // Contains the most recent disk stats.
301 long int read_sectors_;
302 long int write_sectors_;
303
304 GSource* diskstats_source_;
305 DiskStatsState diskstats_state_;
306
petkov 2011/02/11 06:42:30 remove blank line
268 }; 307 };
269 308
270 #endif // METRICS_DAEMON_H_ 309 #endif // METRICS_DAEMON_H_
OLDNEW
« no previous file with comments | « no previous file | metrics_daemon.cc » ('j') | metrics_daemon.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698