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

Side by Side Diff: chrome/browser/metrics/metrics_service.h

Issue 2735005: Merge 49197 - Submitting CL http://codereview.chromium.org/2324001 on behalf ... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/418/src/
Patch Set: Created 10 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file defines a service that collects information about the user 5 // This file defines a service that collects information about the user
6 // experience in order to help improve future versions of the app. 6 // experience in order to help improve future versions of the app.
7 7
8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void RecordCompletedSessionEnd(); 109 void RecordCompletedSessionEnd();
110 110
111 // Saves in the preferences if the crash report registration was successful. 111 // Saves in the preferences if the crash report registration was successful.
112 // This count is eventually send via UMA logs. 112 // This count is eventually send via UMA logs.
113 void RecordBreakpadRegistration(bool success); 113 void RecordBreakpadRegistration(bool success);
114 114
115 // Saves in the preferences if the browser is running under a debugger. 115 // Saves in the preferences if the browser is running under a debugger.
116 // This count is eventually send via UMA logs. 116 // This count is eventually send via UMA logs.
117 void RecordBreakpadHasDebugger(bool has_debugger); 117 void RecordBreakpadHasDebugger(bool has_debugger);
118 118
119 // Callback to let us knew that the plugin list is warmed up.
120 void OnGetPluginListTaskComplete(const std::vector<WebPluginInfo>& plugins);
121
122 // Save any unsent logs into a persistent store in a pref. We always do this 119 // Save any unsent logs into a persistent store in a pref. We always do this
123 // at shutdown, but we can do it as we reduce the list as well. 120 // at shutdown, but we can do it as we reduce the list as well.
124 void StoreUnsentLogs(); 121 void StoreUnsentLogs();
125 122
126 #if defined(OS_CHROMEOS) 123 #if defined(OS_CHROMEOS)
124 // Returns the hardware class of the Chrome OS device (e.g.,
125 // hardware qualification ID), or "unknown" if the hardware class is
126 // not available. The hardware class identifies the configured
127 // system components such us CPU, WiFi adapter, etc. Note that this
128 // routine invokes an external utility to determine the hardware
129 // class.
130 static std::string GetHardwareClass();
131
127 // Start the external metrics service, which collects metrics from Chrome OS 132 // Start the external metrics service, which collects metrics from Chrome OS
128 // and passes them to UMA. 133 // and passes them to UMA.
129 void StartExternalMetrics(); 134 void StartExternalMetrics();
130 #endif 135 #endif
131 136
132 bool recording_active() const; 137 bool recording_active() const;
133 bool reporting_active() const; 138 bool reporting_active() const;
134 139
135 private: 140 private:
136 // The MetricsService has a lifecycle that is stored as a state. 141 // The MetricsService has a lifecycle that is stored as a state.
137 // See metrics_service.cc for description of this lifecycle. 142 // See metrics_service.cc for description of this lifecycle.
138 enum State { 143 enum State {
139 INITIALIZED, // Constructor was called. 144 INITIALIZED, // Constructor was called.
140 PLUGIN_LIST_REQUESTED, // Waiting for plugin list to be loaded. 145 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to complete.
141 PLUGIN_LIST_ARRIVED, // Waiting for timer to send initial log. 146 INIT_TASK_DONE, // Waiting for timer to send initial log.
142 INITIAL_LOG_READY, // Initial log generated, and waiting for reply. 147 INITIAL_LOG_READY, // Initial log generated, and waiting for reply.
143 SEND_OLD_INITIAL_LOGS, // Sending unsent logs from previous session. 148 SEND_OLD_INITIAL_LOGS, // Sending unsent logs from previous session.
144 SENDING_OLD_LOGS, // Sending unsent logs from previous session. 149 SENDING_OLD_LOGS, // Sending unsent logs from previous session.
145 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue. 150 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue.
146 }; 151 };
147 152
148 // Maintain a map of histogram names to the sample stats we've sent. 153 // Maintain a map of histogram names to the sample stats we've sent.
149 typedef std::map<std::string, Histogram::SampleSet> LoggedSampleMap; 154 typedef std::map<std::string, Histogram::SampleSet> LoggedSampleMap;
150 155
151 class GetPluginListTask; 156 class InitTask;
152 class GetPluginListTaskComplete; 157 class InitTaskComplete;
158
159 // Callback to let us know that the init task is done.
160 void OnInitTaskComplete(
161 const std::string& hardware_class,
162 const std::vector<WebPluginInfo>& plugins);
153 163
154 // When we start a new version of Chromium (different from our last run), we 164 // When we start a new version of Chromium (different from our last run), we
155 // need to discard the old crash stats so that we don't attribute crashes etc. 165 // need to discard the old crash stats so that we don't attribute crashes etc.
156 // in the old version to the current version (via current logs). 166 // in the old version to the current version (via current logs).
157 // Without this, a common reason to finally start a new version is to crash 167 // Without this, a common reason to finally start a new version is to crash
158 // the old version (after an autoupdate has arrived), and so we'd bias 168 // the old version (after an autoupdate has arrived), and so we'd bias
159 // initial results towards showing crashes :-(. 169 // initial results towards showing crashes :-(.
160 static void DiscardOldStabilityStats(PrefService* local_state); 170 static void DiscardOldStabilityStats(PrefService* local_state);
161 171
162 // Sets and gets whether metrics recording is active. 172 // Sets and gets whether metrics recording is active.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // The variable server_permits_upload_ is set true when the response 425 // The variable server_permits_upload_ is set true when the response
416 // data forbids uploading. This should coinside with the "die roll" 426 // data forbids uploading. This should coinside with the "die roll"
417 // with probability in the upload tag of the response data came out 427 // with probability in the upload tag of the response data came out
418 // affirmative. 428 // affirmative.
419 bool server_permits_upload_; 429 bool server_permits_upload_;
420 430
421 // The progession of states made by the browser are recorded in the following 431 // The progession of states made by the browser are recorded in the following
422 // state. 432 // state.
423 State state_; 433 State state_;
424 434
435 // Chrome OS hardware class (e.g., hardware qualification ID). This
436 // class identifies the configured system components such as CPU,
437 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
438 // empty string.
439 std::string hardware_class_;
440
425 // The list of plugins which was retrieved on the file thread. 441 // The list of plugins which was retrieved on the file thread.
426 std::vector<WebPluginInfo> plugins_; 442 std::vector<WebPluginInfo> plugins_;
427 443
428 // A log that we are currently transmiting, or about to try to transmit. 444 // A log that we are currently transmiting, or about to try to transmit.
429 MetricsLog* pending_log_; 445 MetricsLog* pending_log_;
430 446
431 // An alternate form of pending_log_. We persistently save this text version 447 // An alternate form of pending_log_. We persistently save this text version
432 // into prefs if we can't transmit it. As a result, sometimes all we have is 448 // into prefs if we can't transmit it. As a result, sometimes all we have is
433 // the text version (recalled from a previous session). 449 // the text version (recalled from a previous session).
434 std::string pending_log_text_; 450 std::string pending_log_text_;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; 526 scoped_refptr<chromeos::ExternalMetrics> external_metrics_;
511 #endif 527 #endif
512 528
513 FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesAllZeroes); 529 FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesAllZeroes);
514 FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesCorrectly); 530 FRIEND_TEST(MetricsServiceTest, ClientIdGeneratesCorrectly);
515 FRIEND_TEST(MetricsServiceTest, ClientIdCorrectlyFormatted); 531 FRIEND_TEST(MetricsServiceTest, ClientIdCorrectlyFormatted);
516 DISALLOW_COPY_AND_ASSIGN(MetricsService); 532 DISALLOW_COPY_AND_ASSIGN(MetricsService);
517 }; 533 };
518 534
519 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 535 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_log_unittest.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698