Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

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
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 MetricsService(); 114 MetricsService();
115 virtual ~MetricsService(); 115 virtual ~MetricsService();
116 116
117 // Initializes metrics recording state. Updates various bookkeeping values in
118 // prefs and sets up the scheduler. This is a separate function rather than
119 // being done by the constructor so that field trials could be created before
120 // this is run. Takes |reporting_will_be_enabled| parameter which specifies
121 // whether UMA is enabled.
122 void InitializeMetricsRecordingState(bool reporting_will_be_enabled);
Ilya Sherman 2013/12/06 06:21:26 nit: Please define an enum to use in place of the
Ilya Sherman 2013/12/06 06:21:26 Why is this method public? It doesn't look like y
Alexei Svitkine (slow) 2013/12/06 17:59:22 Yes, that was my mistake - I forgot to include the
Alexei Svitkine (slow) 2013/12/06 17:59:22 Done.
123
117 // Starts the metrics system, turning on recording and uploading of metrics. 124 // Starts the metrics system, turning on recording and uploading of metrics.
118 // Should be called when starting up with metrics enabled, or when metrics 125 // Should be called when starting up with metrics enabled, or when metrics
119 // are turned on. 126 // are turned on.
120 void Start(); 127 void Start();
121 128
122 // Starts the metrics system in a special test-only mode. Metrics won't ever 129 // 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 130 // be uploaded or persisted in this mode, but metrics will be recorded in
124 // memory. 131 // memory.
125 void StartRecordingForTests(); 132 void StartRecordingForTests();
126 133
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // registered at a time for a given trial_name. Only the last group name that 253 // 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 254 // 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. 255 // in must not correspond to any real field trial in the code.
249 // To use this method, SyntheticTrialGroup should friend your class. 256 // To use this method, SyntheticTrialGroup should friend your class.
250 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group); 257 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group);
251 258
252 private: 259 private:
253 // The MetricsService has a lifecycle that is stored as a state. 260 // The MetricsService has a lifecycle that is stored as a state.
254 // See metrics_service.cc for description of this lifecycle. 261 // See metrics_service.cc for description of this lifecycle.
255 enum State { 262 enum State {
256 INITIALIZED, // Constructor was called. 263 INITIALIZED, // Constructor was called.
257 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to complete. 264 INIT_TASK_SCHEDULED, // Waiting for deferred init task to finish.
Ilya Sherman 2013/12/06 06:21:26 nit: "tasks" seems more accurate, since this can b
Alexei Svitkine (slow) 2013/12/06 17:59:22 Unfortunately, it goes above the 80 col limit (if
Ilya Sherman 2013/12/07 06:51:53 You can wrap the line like so: INIT_TASK_SCHE
Alexei Svitkine (slow) 2013/12/09 21:17:02 Done.
258 INIT_TASK_DONE, // Waiting for timer to send initial log. 265 INIT_TASK_DONE, // Waiting for timer to send initial log.
259 INITIAL_LOG_READY, // Initial log generated, and waiting for reply. 266 SENDING_INITIAL_STABILITY_LOG, // Initial stability log being sent.
260 SENDING_OLD_LOGS, // Sending unsent logs from previous session. 267 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent.
Ilya Sherman 2013/12/06 06:21:26 Jim made a good point in a previous discussion tha
Alexei Svitkine (slow) 2013/12/06 17:59:22 The code already treats it as an ongoing log (sema
Ilya Sherman 2013/12/07 06:51:53 Ok.
261 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue. 268 SENDING_OLD_LOGS, // Sending unsent logs from last session.
269 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue.
262 }; 270 };
263 271
264 enum ShutdownCleanliness { 272 enum ShutdownCleanliness {
265 CLEANLY_SHUTDOWN = 0xdeadbeef, 273 CLEANLY_SHUTDOWN = 0xdeadbeef,
266 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN 274 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
267 }; 275 };
268 276
269 // Designates which entropy source was returned from this MetricsService. 277 // Designates which entropy source was returned from this MetricsService.
270 // This is used for testing to validate that we return the correct source 278 // This is used for testing to validate that we return the correct source
271 // depending on the state of the service. 279 // depending on the state of the service.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void EnableRecording(); 350 void EnableRecording();
343 void DisableRecording(); 351 void DisableRecording();
344 352
345 // If in_idle is true, sets idle_since_last_transmission to true. 353 // 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 354 // 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 355 // idle_since_last_transmission to false and starts the timer (provided
348 // starting the timer is permitted). 356 // starting the timer is permitted).
349 void HandleIdleSinceLastTransmission(bool in_idle); 357 void HandleIdleSinceLastTransmission(bool in_idle);
350 358
351 // Set up client ID, session ID, etc. 359 // Set up client ID, session ID, etc.
352 void InitializeMetricsState(); 360 void InitializeMetricsState(bool reporting_will_be_enabled);
353 361
354 // Generates a new client ID to use to identify self to metrics server. 362 // Generates a new client ID to use to identify self to metrics server.
355 static std::string GenerateClientID(); 363 static std::string GenerateClientID();
356 364
357 // Schedule the next save of LocalState information. This is called 365 // Schedule the next save of LocalState information. This is called
358 // automatically by the task that performs each save to schedule the next one. 366 // automatically by the task that performs each save to schedule the next one.
359 void ScheduleNextStateSave(); 367 void ScheduleNextStateSave();
360 368
361 // Save the LocalState information immediately. This should not be called by 369 // 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 370 // 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 394 // Callbacks for various stages of final log info collection. Do not call
387 // these directly. 395 // these directly.
388 void OnMemoryDetailCollectionDone(); 396 void OnMemoryDetailCollectionDone();
389 void OnHistogramSynchronizationDone(); 397 void OnHistogramSynchronizationDone();
390 void OnFinalLogInfoCollectionDone(); 398 void OnFinalLogInfoCollectionDone();
391 399
392 // Either closes the current log or creates and closes the initial log 400 // Either closes the current log or creates and closes the initial log
393 // (depending on |state_|), and stages it for upload. 401 // (depending on |state_|), and stages it for upload.
394 void StageNewLog(); 402 void StageNewLog();
395 403
396 // Record stats, client ID, Session ID, etc. in a special "first" log. 404 // Prepares the initial stability log, based on the saved system profile from
397 void PrepareInitialLog(); 405 // a previous session and metrics stability stats and stages it for upload.
Ilya Sherman 2013/12/06 06:21:26 nit: "and metrics stability stats" -> rephrase som
Alexei Svitkine (slow) 2013/12/06 17:59:22 Done.
406 void PrepareInitialStabilityLog();
407
408 // Prepares the initial metrics log, which includes startup histograms and
409 // profiler data, as well as incremental stability-related metrics.
410 void PrepareInitialMetricsLog(MetricsLog::LogType log_type);
398 411
399 // Uploads the currently staged log (which must be non-null). 412 // Uploads the currently staged log (which must be non-null).
400 void SendStagedLog(); 413 void SendStagedLog();
401 414
402 // Prepared the staged log to be passed to the server. Upon return, 415 // 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 416 // current_fetch_ should be reset with its upload data set to a compressed
404 // copy of the staged log. 417 // copy of the staged log.
405 void PrepareFetchWithStagedLog(); 418 void PrepareFetchWithStagedLog();
406 419
407 // Implementation of net::URLFetcherDelegate. Called after transmission 420 // Implementation of net::URLFetcherDelegate. Called after transmission
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 // WiFi adapter, etc. For non Chrome OS hosts, this will be an 493 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
481 // empty string. 494 // empty string.
482 std::string hardware_class_; 495 std::string hardware_class_;
483 496
484 // The list of plugins which was retrieved on the file thread. 497 // The list of plugins which was retrieved on the file thread.
485 std::vector<content::WebPluginInfo> plugins_; 498 std::vector<content::WebPluginInfo> plugins_;
486 499
487 // Google Update statistics, which were retrieved on a blocking pool thread. 500 // Google Update statistics, which were retrieved on a blocking pool thread.
488 GoogleUpdateMetrics google_update_metrics_; 501 GoogleUpdateMetrics google_update_metrics_;
489 502
490 // The initial log, used to record startup metrics. 503 // The initial metrics log, used to record startup metrics (histograms and
491 scoped_ptr<MetricsLog> initial_log_; 504 // profiler data). Note that if a crash occurred in the previous session, an
505 // initial stability log may be sent before this.
506 scoped_ptr<MetricsLog> initial_metrics_log_;
492 507
493 // The outstanding transmission appears as a URL Fetch operation. 508 // The outstanding transmission appears as a URL Fetch operation.
494 scoped_ptr<net::URLFetcher> current_fetch_; 509 scoped_ptr<net::URLFetcher> current_fetch_;
495 510
496 // The TCP/UDP echo server to collect network connectivity stats. 511 // The TCP/UDP echo server to collect network connectivity stats.
497 std::string network_stats_server_; 512 std::string network_stats_server_;
498 513
499 // The HTTP pipelining test server. 514 // The HTTP pipelining test server.
500 std::string http_pipelining_test_server_; 515 std::string http_pipelining_test_server_;
501 516
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 friend class extensions::ExtensionDownloader; 599 friend class extensions::ExtensionDownloader;
585 friend class extensions::ManifestFetchData; 600 friend class extensions::ManifestFetchData;
586 601
587 // Returns true if prefs::kMetricsReportingEnabled is set. 602 // Returns true if prefs::kMetricsReportingEnabled is set.
588 static bool IsMetricsReportingEnabled(); 603 static bool IsMetricsReportingEnabled();
589 604
590 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 605 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
591 }; 606 };
592 607
593 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 608 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_service.cc » ('j') | chrome/browser/metrics/metrics_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698