OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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-glib.h> | 8 #include <dbus/dbus-glib.h> |
9 #include <sys/time.h> | 9 #include <sys/time.h> |
10 #include <time.h> | 10 #include <time.h> |
11 | 11 |
12 class MetricsDaemon { | 12 class MetricsDaemon { |
13 | 13 |
14 public: | 14 public: |
15 MetricsDaemon() | 15 MetricsDaemon() |
16 : network_state_id_(kUnknownNetworkStateId), metrics_fd_(-1) { | 16 : network_state_id_(kUnknownNetworkStateId), metrics_fd_(-1) { |
17 } | 17 } |
18 ~MetricsDaemon() {} | 18 ~MetricsDaemon() {} |
19 | 19 |
20 // Does all the work. If |testing| is true, log the stats instead of sending | 20 // Does all the work. If |run_as_daemon| is true, daemonize by forking. If |
21 // them to Chrome. | 21 // |testing| is true, log the stats instead of sending them to Chrome. |
22 void Run(bool testing); | 22 void Run(bool run_as_daemon, bool testing); |
23 | 23 |
24 private: | 24 private: |
25 // Shared with Chrome for transport. | 25 // Shared with Chrome for transport. |
26 static const char* kMetricsFilePath; | 26 static const char* kMetricsFilePath; |
27 static const int kMetricsMessageMaxLength = 4096; | 27 static const int kMetricsMessageMaxLength = 4096; |
28 | 28 |
29 // The network states. See network_states.h. | 29 // The network states. See network_states.h. |
30 typedef enum { | 30 typedef enum { |
31 // Initial/unknown network state id. | 31 // Initial/unknown network state id. |
32 kUnknownNetworkStateId = -1, | 32 kUnknownNetworkStateId = -1, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Array of network states of interest. | 80 // Array of network states of interest. |
81 static NetworkState network_states_[kNumberNetworkStates]; | 81 static NetworkState network_states_[kNumberNetworkStates]; |
82 | 82 |
83 bool testing_; // just testing | 83 bool testing_; // just testing |
84 NetworkStateId network_state_id_; // id of current state | 84 NetworkStateId network_state_id_; // id of current state |
85 struct timeval network_state_start_; // when current state was entered | 85 struct timeval network_state_start_; // when current state was entered |
86 int metrics_fd_; // for Chrome transport | 86 int metrics_fd_; // for Chrome transport |
87 }; | 87 }; |
88 | 88 |
89 #endif // METRICS_DAEMON_H_ | 89 #endif // METRICS_DAEMON_H_ |
OLD | NEW |