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

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

Issue 81603002: Send UMA stability stats in a separate UMA log on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years 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 | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/metrics/metrics_service.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 UNINITIALIZED_PHASE = 0, 104 UNINITIALIZED_PHASE = 0,
105 START_METRICS_RECORDING = 100, 105 START_METRICS_RECORDING = 100,
106 CREATE_PROFILE = 200, 106 CREATE_PROFILE = 200,
107 STARTUP_TIMEBOMB_ARM = 300, 107 STARTUP_TIMEBOMB_ARM = 300,
108 THREAD_WATCHER_START = 400, 108 THREAD_WATCHER_START = 400,
109 MAIN_MESSAGE_LOOP_RUN = 500, 109 MAIN_MESSAGE_LOOP_RUN = 500,
110 SHUTDOWN_TIMEBOMB_ARM = 600, 110 SHUTDOWN_TIMEBOMB_ARM = 600,
111 SHUTDOWN_COMPLETE = 700, 111 SHUTDOWN_COMPLETE = 700,
112 }; 112 };
113 113
114 enum ReportingState {
115 REPORTING_ENABLED,
116 REPORTING_DISABLED,
117 };
118
114 MetricsService(); 119 MetricsService();
115 virtual ~MetricsService(); 120 virtual ~MetricsService();
116 121
122 // Initializes metrics recording state. Updates various bookkeeping values in
123 // prefs and sets up the scheduler. This is a separate function rather than
124 // being done by the constructor so that field trials could be created before
125 // this is run. Takes |reporting_state| parameter which specifies whether UMA
126 // is enabled.
127 void InitializeMetricsRecordingState(ReportingState reporting_state);
128
117 // Starts the metrics system, turning on recording and uploading of metrics. 129 // Starts the metrics system, turning on recording and uploading of metrics.
118 // Should be called when starting up with metrics enabled, or when metrics 130 // Should be called when starting up with metrics enabled, or when metrics
119 // are turned on. 131 // are turned on.
120 void Start(); 132 void Start();
121 133
122 // Starts the metrics system in a special test-only mode. Metrics won't ever 134 // Starts the metrics system in a special test-only mode. Metrics won't ever
123 // be uploaded or persisted in this mode, but metrics will be recorded in 135 // be uploaded or persisted in this mode, but metrics will be recorded in
124 // memory. 136 // memory.
125 void StartRecordingForTests(); 137 void StartRecordingForTests();
126 138
(...skipping 19 matching lines...) Expand all
146 // 158 //
147 // If |reporting_will_be_enabled| is true, this method returns an entropy 159 // If |reporting_will_be_enabled| is true, this method returns an entropy
148 // provider that has a high source of entropy, partially based on the client 160 // provider that has a high source of entropy, partially based on the client
149 // ID. Otherwise, an entropy provider that is based on a low entropy source 161 // ID. Otherwise, an entropy provider that is based on a low entropy source
150 // is returned. 162 // is returned.
151 // 163 //
152 // Note that this reporting state can not be checked by reporting_active() 164 // Note that this reporting state can not be checked by reporting_active()
153 // because this method may need to be called before the MetricsService needs 165 // because this method may need to be called before the MetricsService needs
154 // to be started. 166 // to be started.
155 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider( 167 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider(
156 bool reporting_will_be_enabled); 168 ReportingState reporting_state);
157 169
158 // Force the client ID to be generated. This is useful in case it's needed 170 // Force the client ID to be generated. This is useful in case it's needed
159 // before recording. 171 // before recording.
160 void ForceClientIdCreation(); 172 void ForceClientIdCreation();
161 173
162 // At startup, prefs needs to be called with a list of all the pref names and 174 // At startup, prefs needs to be called with a list of all the pref names and
163 // types we'll be using. 175 // types we'll be using.
164 static void RegisterPrefs(PrefRegistrySimple* registry); 176 static void RegisterPrefs(PrefRegistrySimple* registry);
165 177
166 // Set up notifications which indicate that a user is performing work. This is 178 // Set up notifications which indicate that a user is performing work. This is
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Saves in the preferences if the browser is running under a debugger. 222 // Saves in the preferences if the browser is running under a debugger.
211 // This count is eventually send via UMA logs. 223 // This count is eventually send via UMA logs.
212 void RecordBreakpadHasDebugger(bool has_debugger); 224 void RecordBreakpadHasDebugger(bool has_debugger);
213 225
214 #if defined(OS_WIN) 226 #if defined(OS_WIN)
215 // Counts (and removes) the browser crash dump attempt signals left behind by 227 // Counts (and removes) the browser crash dump attempt signals left behind by
216 // any previous browser processes which generated a crash dump. 228 // any previous browser processes which generated a crash dump.
217 void CountBrowserCrashDumpAttempts(); 229 void CountBrowserCrashDumpAttempts();
218 #endif // OS_WIN 230 #endif // OS_WIN
219 231
220 // Save any unsent logs into a persistent store in a pref. We always do this
221 // at shutdown, but we can do it as we reduce the list as well.
222 void StoreUnsentLogs();
223
224 #if defined(OS_CHROMEOS) 232 #if defined(OS_CHROMEOS)
225 // Start the external metrics service, which collects metrics from Chrome OS 233 // Start the external metrics service, which collects metrics from Chrome OS
226 // and passes them to UMA. 234 // and passes them to UMA.
227 void StartExternalMetrics(); 235 void StartExternalMetrics();
228 236
229 // Records a Chrome OS crash. 237 // Records a Chrome OS crash.
230 void LogChromeOSCrash(const std::string &crash_type); 238 void LogChromeOSCrash(const std::string &crash_type);
231 #endif 239 #endif
232 240
233 bool recording_active() const; 241 bool recording_active() const;
(...skipping 12 matching lines...) Expand all
246 // registered at a time for a given trial_name. Only the last group name that 254 // registered at a time for a given trial_name. Only the last group name that
247 // is registered for a given trial name will be recorded. The values passed 255 // is registered for a given trial name will be recorded. The values passed
248 // in must not correspond to any real field trial in the code. 256 // in must not correspond to any real field trial in the code.
249 // To use this method, SyntheticTrialGroup should friend your class. 257 // To use this method, SyntheticTrialGroup should friend your class.
250 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group); 258 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group);
251 259
252 private: 260 private:
253 // The MetricsService has a lifecycle that is stored as a state. 261 // The MetricsService has a lifecycle that is stored as a state.
254 // See metrics_service.cc for description of this lifecycle. 262 // See metrics_service.cc for description of this lifecycle.
255 enum State { 263 enum State {
256 INITIALIZED, // Constructor was called. 264 INITIALIZED, // Constructor was called.
257 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to complete. 265 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to
258 INIT_TASK_DONE, // Waiting for timer to send initial log. 266 // complete.
259 INITIAL_LOG_READY, // Initial log generated, and waiting for reply. 267 INIT_TASK_DONE, // Waiting for timer to send initial log.
260 SENDING_OLD_LOGS, // Sending unsent logs from previous session. 268 SENDING_INITIAL_STABILITY_LOG, // Initial stability log being sent.
261 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue. 269 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent.
270 SENDING_OLD_LOGS, // Sending unsent logs from last session.
271 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue.
262 }; 272 };
263 273
264 enum ShutdownCleanliness { 274 enum ShutdownCleanliness {
265 CLEANLY_SHUTDOWN = 0xdeadbeef, 275 CLEANLY_SHUTDOWN = 0xdeadbeef,
266 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN 276 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
267 }; 277 };
268 278
269 // Designates which entropy source was returned from this MetricsService. 279 // Designates which entropy source was returned from this MetricsService.
270 // This is used for testing to validate that we return the correct source 280 // This is used for testing to validate that we return the correct source
271 // depending on the state of the service. 281 // depending on the state of the service.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void EnableRecording(); 352 void EnableRecording();
343 void DisableRecording(); 353 void DisableRecording();
344 354
345 // If in_idle is true, sets idle_since_last_transmission to true. 355 // If in_idle is true, sets idle_since_last_transmission to true.
346 // If in_idle is false and idle_since_last_transmission_ is true, sets 356 // If in_idle is false and idle_since_last_transmission_ is true, sets
347 // idle_since_last_transmission to false and starts the timer (provided 357 // idle_since_last_transmission to false and starts the timer (provided
348 // starting the timer is permitted). 358 // starting the timer is permitted).
349 void HandleIdleSinceLastTransmission(bool in_idle); 359 void HandleIdleSinceLastTransmission(bool in_idle);
350 360
351 // Set up client ID, session ID, etc. 361 // Set up client ID, session ID, etc.
352 void InitializeMetricsState(); 362 void InitializeMetricsState(ReportingState reporting_state);
353 363
354 // Generates a new client ID to use to identify self to metrics server. 364 // Generates a new client ID to use to identify self to metrics server.
355 static std::string GenerateClientID(); 365 static std::string GenerateClientID();
356 366
357 // Schedule the next save of LocalState information. This is called 367 // Schedule the next save of LocalState information. This is called
358 // automatically by the task that performs each save to schedule the next one. 368 // automatically by the task that performs each save to schedule the next one.
359 void ScheduleNextStateSave(); 369 void ScheduleNextStateSave();
360 370
361 // Save the LocalState information immediately. This should not be called by 371 // Save the LocalState information immediately. This should not be called by
362 // anybody other than the scheduler to avoid doing too many writes. When you 372 // anybody other than the scheduler to avoid doing too many writes. When you
(...skipping 23 matching lines...) Expand all
386 // Callbacks for various stages of final log info collection. Do not call 396 // Callbacks for various stages of final log info collection. Do not call
387 // these directly. 397 // these directly.
388 void OnMemoryDetailCollectionDone(); 398 void OnMemoryDetailCollectionDone();
389 void OnHistogramSynchronizationDone(); 399 void OnHistogramSynchronizationDone();
390 void OnFinalLogInfoCollectionDone(); 400 void OnFinalLogInfoCollectionDone();
391 401
392 // Either closes the current log or creates and closes the initial log 402 // Either closes the current log or creates and closes the initial log
393 // (depending on |state_|), and stages it for upload. 403 // (depending on |state_|), and stages it for upload.
394 void StageNewLog(); 404 void StageNewLog();
395 405
396 // Record stats, client ID, Session ID, etc. in a special "first" log. 406 // Prepares the initial stability log, which is only logged when the previous
397 void PrepareInitialLog(); 407 // run of Chrome crashed. This log contains any stability metrics left over
408 // from that previous run, and only these stability metrics. It uses the
409 // system profile from the previous session.
410 void PrepareInitialStabilityLog();
411
412 // Prepares the initial metrics log, which includes startup histograms and
413 // profiler data, as well as incremental stability-related metrics.
414 void PrepareInitialMetricsLog(MetricsLog::LogType log_type);
398 415
399 // Uploads the currently staged log (which must be non-null). 416 // Uploads the currently staged log (which must be non-null).
400 void SendStagedLog(); 417 void SendStagedLog();
401 418
402 // Prepared the staged log to be passed to the server. Upon return, 419 // Prepared the staged log to be passed to the server. Upon return,
403 // current_fetch_ should be reset with its upload data set to a compressed 420 // current_fetch_ should be reset with its upload data set to a compressed
404 // copy of the staged log. 421 // copy of the staged log.
405 void PrepareFetchWithStagedLog(); 422 void PrepareFetchWithStagedLog();
406 423
407 // Implementation of net::URLFetcherDelegate. Called after transmission 424 // Implementation of net::URLFetcherDelegate. Called after transmission
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 // Indicate whether recording and reporting are currently happening. 481 // Indicate whether recording and reporting are currently happening.
465 // These should not be set directly, but by calling SetRecording and 482 // These should not be set directly, but by calling SetRecording and
466 // SetReporting. 483 // SetReporting.
467 bool recording_active_; 484 bool recording_active_;
468 bool reporting_active_; 485 bool reporting_active_;
469 486
470 // Indicate whether test mode is enabled, where the initial log should never 487 // Indicate whether test mode is enabled, where the initial log should never
471 // be cut, and logs are neither persisted nor uploaded. 488 // be cut, and logs are neither persisted nor uploaded.
472 bool test_mode_active_; 489 bool test_mode_active_;
473 490
474 // The progession of states made by the browser are recorded in the following 491 // The progression of states made by the browser are recorded in the following
475 // state. 492 // state.
476 State state_; 493 State state_;
477 494
495 // Whether the initial stability log has been recorded during startup.
496 bool has_initial_stability_log_;
497
478 // Chrome OS hardware class (e.g., hardware qualification ID). This 498 // Chrome OS hardware class (e.g., hardware qualification ID). This
479 // class identifies the configured system components such as CPU, 499 // class identifies the configured system components such as CPU,
480 // WiFi adapter, etc. For non Chrome OS hosts, this will be an 500 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
481 // empty string. 501 // empty string.
482 std::string hardware_class_; 502 std::string hardware_class_;
483 503
484 // The list of plugins which was retrieved on the file thread. 504 // The list of plugins which was retrieved on the file thread.
485 std::vector<content::WebPluginInfo> plugins_; 505 std::vector<content::WebPluginInfo> plugins_;
486 506
487 // Google Update statistics, which were retrieved on a blocking pool thread. 507 // Google Update statistics, which were retrieved on a blocking pool thread.
488 GoogleUpdateMetrics google_update_metrics_; 508 GoogleUpdateMetrics google_update_metrics_;
489 509
490 // The initial log, used to record startup metrics. 510 // The initial metrics log, used to record startup metrics (histograms and
491 scoped_ptr<MetricsLog> initial_log_; 511 // profiler data). Note that if a crash occurred in the previous session, an
512 // initial stability log may be sent before this.
513 scoped_ptr<MetricsLog> initial_metrics_log_;
492 514
493 // The outstanding transmission appears as a URL Fetch operation. 515 // The outstanding transmission appears as a URL Fetch operation.
494 scoped_ptr<net::URLFetcher> current_fetch_; 516 scoped_ptr<net::URLFetcher> current_fetch_;
495 517
496 // The TCP/UDP echo server to collect network connectivity stats. 518 // The TCP/UDP echo server to collect network connectivity stats.
497 std::string network_stats_server_; 519 std::string network_stats_server_;
498 520
499 // The HTTP pipelining test server. 521 // The HTTP pipelining test server.
500 std::string http_pipelining_test_server_; 522 std::string http_pipelining_test_server_;
501 523
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 friend class extensions::ExtensionDownloader; 606 friend class extensions::ExtensionDownloader;
585 friend class extensions::ManifestFetchData; 607 friend class extensions::ManifestFetchData;
586 608
587 // Returns true if prefs::kMetricsReportingEnabled is set. 609 // Returns true if prefs::kMetricsReportingEnabled is set.
588 static bool IsMetricsReportingEnabled(); 610 static bool IsMetricsReportingEnabled();
589 611
590 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 612 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
591 }; 613 };
592 614
593 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 615 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698