| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoCurrent); | 42 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoCurrent); |
| 43 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoLast); | 43 FRIEND_TEST(MetricsDaemonTest, ComputeEpochNoLast); |
| 44 FRIEND_TEST(MetricsDaemonTest, GetHistogramPath); | 44 FRIEND_TEST(MetricsDaemonTest, GetHistogramPath); |
| 45 FRIEND_TEST(MetricsDaemonTest, IsNewEpoch); | 45 FRIEND_TEST(MetricsDaemonTest, IsNewEpoch); |
| 46 FRIEND_TEST(MetricsDaemonTest, LookupPowerState); | 46 FRIEND_TEST(MetricsDaemonTest, LookupPowerState); |
| 47 FRIEND_TEST(MetricsDaemonTest, LookupScreenSaverState); | 47 FRIEND_TEST(MetricsDaemonTest, LookupScreenSaverState); |
| 48 FRIEND_TEST(MetricsDaemonTest, LookupSessionState); | 48 FRIEND_TEST(MetricsDaemonTest, LookupSessionState); |
| 49 FRIEND_TEST(MetricsDaemonTest, MessageFilter); | 49 FRIEND_TEST(MetricsDaemonTest, MessageFilter); |
| 50 FRIEND_TEST(MetricsDaemonTest, PowerStateChanged); | 50 FRIEND_TEST(MetricsDaemonTest, PowerStateChanged); |
| 51 FRIEND_TEST(MetricsDaemonTest, ProcessKernelCrash); | 51 FRIEND_TEST(MetricsDaemonTest, ProcessKernelCrash); |
| 52 FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo); |
| 53 FRIEND_TEST(MetricsDaemonTest, ProcessMeminfo2); |
| 52 FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown); | 54 FRIEND_TEST(MetricsDaemonTest, ProcessUncleanShutdown); |
| 53 FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash); | 55 FRIEND_TEST(MetricsDaemonTest, ProcessUserCrash); |
| 54 FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency); | 56 FRIEND_TEST(MetricsDaemonTest, ReportCrashesDailyFrequency); |
| 55 FRIEND_TEST(MetricsDaemonTest, ReportDailyUse); | 57 FRIEND_TEST(MetricsDaemonTest, ReportDailyUse); |
| 56 FRIEND_TEST(MetricsDaemonTest, ReportDiskStats); | 58 FRIEND_TEST(MetricsDaemonTest, ReportDiskStats); |
| 57 FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval); | 59 FRIEND_TEST(MetricsDaemonTest, ReportKernelCrashInterval); |
| 58 FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval); | 60 FRIEND_TEST(MetricsDaemonTest, ReportUncleanShutdownInterval); |
| 59 FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval); | 61 FRIEND_TEST(MetricsDaemonTest, ReportUserCrashInterval); |
| 60 FRIEND_TEST(MetricsDaemonTest, ScreenSaverStateChanged); | 62 FRIEND_TEST(MetricsDaemonTest, ScreenSaverStateChanged); |
| 61 FRIEND_TEST(MetricsDaemonTest, SendMetric); | 63 FRIEND_TEST(MetricsDaemonTest, SendMetric); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 static const char kMetricUncleanShutdownsWeeklyName[]; | 120 static const char kMetricUncleanShutdownsWeeklyName[]; |
| 119 static const char kMetricUserCrashesDailyName[]; | 121 static const char kMetricUserCrashesDailyName[]; |
| 120 static const char kMetricUserCrashesWeeklyName[]; | 122 static const char kMetricUserCrashesWeeklyName[]; |
| 121 static const char kMetricUserCrashIntervalName[]; | 123 static const char kMetricUserCrashIntervalName[]; |
| 122 static const char kMetricReadSectorsLongName[]; | 124 static const char kMetricReadSectorsLongName[]; |
| 123 static const char kMetricReadSectorsShortName[]; | 125 static const char kMetricReadSectorsShortName[]; |
| 124 static const char kMetricWriteSectorsLongName[]; | 126 static const char kMetricWriteSectorsLongName[]; |
| 125 static const char kMetricWriteSectorsShortName[]; | 127 static const char kMetricWriteSectorsShortName[]; |
| 126 static const int kMetricDiskStatsShortInterval; | 128 static const int kMetricDiskStatsShortInterval; |
| 127 static const int kMetricDiskStatsLongInterval; | 129 static const int kMetricDiskStatsLongInterval; |
| 130 static const int kMetricMeminfoInterval; |
| 128 static const int kMetricSectorsIOMax; | 131 static const int kMetricSectorsIOMax; |
| 129 static const int kMetricSectorsBuckets; | 132 static const int kMetricSectorsBuckets; |
| 130 static const char kMetricsDiskStatsPath[]; | 133 static const char kMetricsDiskStatsPath[]; |
| 131 | 134 |
| 132 // D-Bus message match strings. | 135 // D-Bus message match strings. |
| 133 static const char* kDBusMatches_[]; | 136 static const char* kDBusMatches_[]; |
| 134 | 137 |
| 135 // Array of power states. | 138 // Array of power states. |
| 136 static const char* kPowerStates_[kNumberPowerStates]; | 139 static const char* kPowerStates_[kNumberPowerStates]; |
| 137 | 140 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 230 |
| 228 // Report daily use through UMA. | 231 // Report daily use through UMA. |
| 229 static void ReportDailyUse(void* handle, int tag, int count); | 232 static void ReportDailyUse(void* handle, int tag, int count); |
| 230 | 233 |
| 231 // Sends a regular (exponential) histogram sample to Chrome for | 234 // Sends a regular (exponential) histogram sample to Chrome for |
| 232 // transport to UMA. See MetricsLibrary::SendToUMA in | 235 // transport to UMA. See MetricsLibrary::SendToUMA in |
| 233 // metrics_library.h for a description of the arguments. | 236 // metrics_library.h for a description of the arguments. |
| 234 void SendMetric(const std::string& name, int sample, | 237 void SendMetric(const std::string& name, int sample, |
| 235 int min, int max, int nbuckets); | 238 int min, int max, int nbuckets); |
| 236 | 239 |
| 240 // Sends a linear histogram sample to Chrome for transport to UMA. See |
| 241 // MetricsLibrary::SendToUMA in metrics_library.h for a description of the |
| 242 // arguments. |
| 243 void SendLinearMetric(const std::string& name, int sample, |
| 244 int max, int nbuckets); |
| 245 |
| 237 // Initializes disk stats reporting. | 246 // Initializes disk stats reporting. |
| 238 void DiskStatsReporterInit(); | 247 void DiskStatsReporterInit(); |
| 239 | 248 |
| 240 // Schedules a callback for the next disk stats collection. | 249 // Schedules a callback for the next disk stats collection. |
| 241 void ScheduleDiskStatsCallback(int wait); | 250 void ScheduleDiskStatsCallback(int wait); |
| 242 | 251 |
| 243 // Reads cumulative disk statistics from sysfs. | 252 // Reads cumulative disk statistics from sysfs. |
| 244 void DiskStatsReadStats(long int* read_sectors, long int* write_sectors); | 253 void DiskStatsReadStats(long int* read_sectors, long int* write_sectors); |
| 245 | 254 |
| 246 // Reports disk statistics (static version for glib). Arguments are a glib | 255 // Reports disk statistics (static version for glib). Arguments are a glib |
| 247 // artifact. | 256 // artifact. |
| 248 static gboolean DiskStatsCallbackStatic(void* handle); | 257 static gboolean DiskStatsCallbackStatic(void* handle); |
| 249 | 258 |
| 250 // Reports disk statistics. | 259 // Reports disk statistics. |
| 251 void DiskStatsCallback(); | 260 void DiskStatsCallback(); |
| 252 | 261 |
| 262 // Schedules meminfo collection callback. |
| 263 void ScheduleMeminfoCallback(int wait); |
| 264 |
| 265 // Reports memory statistics (static version for glib). Argument is a glib |
| 266 // artifact. |
| 267 static gboolean MeminfoCallbackStatic(void* handle); |
| 268 |
| 269 // Reports memory statistics. Returns false on failure. |
| 270 gboolean MeminfoCallback(); |
| 271 |
| 272 // Parses content of /proc/meminfo and sends fields of interest to UMA. |
| 273 // Returns false on errors. |
| 274 gboolean ProcessMeminfo(std::string meminfo); |
| 275 |
| 253 // Test mode. | 276 // Test mode. |
| 254 bool testing_; | 277 bool testing_; |
| 255 | 278 |
| 256 // The metrics library handle. | 279 // The metrics library handle. |
| 257 MetricsLibraryInterface* metrics_lib_; | 280 MetricsLibraryInterface* metrics_lib_; |
| 258 | 281 |
| 259 // Timestamps last network state update. This timestamp is used to | 282 // Timestamps last network state update. This timestamp is used to |
| 260 // sample the time from the network going online to going offline so | 283 // sample the time from the network going online to going offline so |
| 261 // TimeTicks ensures a monotonically increasing TimeDelta. | 284 // TimeTicks ensures a monotonically increasing TimeDelta. |
| 262 base::TimeTicks network_state_last_; | 285 base::TimeTicks network_state_last_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 324 |
| 302 // Contains the most recent disk stats. | 325 // Contains the most recent disk stats. |
| 303 long int read_sectors_; | 326 long int read_sectors_; |
| 304 long int write_sectors_; | 327 long int write_sectors_; |
| 305 | 328 |
| 306 DiskStatsState diskstats_state_; | 329 DiskStatsState diskstats_state_; |
| 307 std::string diskstats_path_; | 330 std::string diskstats_path_; |
| 308 }; | 331 }; |
| 309 | 332 |
| 310 #endif // METRICS_DAEMON_H_ | 333 #endif // METRICS_DAEMON_H_ |
| OLD | NEW |