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

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 79 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 258 // 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 259 // 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. 260 // in must not correspond to any real field trial in the code.
249 // To use this method, SyntheticTrialGroup should friend your class. 261 // To use this method, SyntheticTrialGroup should friend your class.
250 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group); 262 void RegisterSyntheticFieldTrial(const SyntheticTrialGroup& trial_group);
251 263
252 private: 264 private:
253 // The MetricsService has a lifecycle that is stored as a state. 265 // The MetricsService has a lifecycle that is stored as a state.
254 // See metrics_service.cc for description of this lifecycle. 266 // See metrics_service.cc for description of this lifecycle.
255 enum State { 267 enum State {
256 INITIALIZED, // Constructor was called. 268 INITIALIZED, // Constructor was called.
257 INIT_TASK_SCHEDULED, // Waiting for deferred init tasks to complete. 269 INIT_TASK_SCHEDULED, // Waiting for deferred init task to finish.
258 INIT_TASK_DONE, // Waiting for timer to send initial log. 270 INIT_TASK_DONE, // Waiting for timer to send initial log.
259 INITIAL_LOG_READY, // Initial log generated, and waiting for reply. 271 SENDING_INITIAL_STABILITY_LOG, // Initial stability log being sent.
260 SENDING_OLD_LOGS, // Sending unsent logs from previous session. 272 SENDING_INITIAL_METRICS_LOG, // Initial metrics log being sent.
261 SENDING_CURRENT_LOGS, // Sending standard current logs as they acrue. 273 SENDING_OLD_LOGS, // Sending unsent logs from last session.
274 SENDING_CURRENT_LOGS, // Sending ongoing logs as they accrue.
262 }; 275 };
263 276
264 enum ShutdownCleanliness { 277 enum ShutdownCleanliness {
265 CLEANLY_SHUTDOWN = 0xdeadbeef, 278 CLEANLY_SHUTDOWN = 0xdeadbeef,
266 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN 279 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN
267 }; 280 };
268 281
269 // Designates which entropy source was returned from this MetricsService. 282 // Designates which entropy source was returned from this MetricsService.
270 // This is used for testing to validate that we return the correct source 283 // This is used for testing to validate that we return the correct source
271 // depending on the state of the service. 284 // depending on the state of the service.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void EnableRecording(); 355 void EnableRecording();
343 void DisableRecording(); 356 void DisableRecording();
344 357
345 // If in_idle is true, sets idle_since_last_transmission to true. 358 // 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 359 // 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 360 // idle_since_last_transmission to false and starts the timer (provided
348 // starting the timer is permitted). 361 // starting the timer is permitted).
349 void HandleIdleSinceLastTransmission(bool in_idle); 362 void HandleIdleSinceLastTransmission(bool in_idle);
350 363
351 // Set up client ID, session ID, etc. 364 // Set up client ID, session ID, etc.
352 void InitializeMetricsState(); 365 void InitializeMetricsState(ReportingState reporting_state);
353 366
354 // Generates a new client ID to use to identify self to metrics server. 367 // Generates a new client ID to use to identify self to metrics server.
355 static std::string GenerateClientID(); 368 static std::string GenerateClientID();
356 369
357 // Schedule the next save of LocalState information. This is called 370 // Schedule the next save of LocalState information. This is called
358 // automatically by the task that performs each save to schedule the next one. 371 // automatically by the task that performs each save to schedule the next one.
359 void ScheduleNextStateSave(); 372 void ScheduleNextStateSave();
360 373
361 // Save the LocalState information immediately. This should not be called by 374 // 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 375 // 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 399 // Callbacks for various stages of final log info collection. Do not call
387 // these directly. 400 // these directly.
388 void OnMemoryDetailCollectionDone(); 401 void OnMemoryDetailCollectionDone();
389 void OnHistogramSynchronizationDone(); 402 void OnHistogramSynchronizationDone();
390 void OnFinalLogInfoCollectionDone(); 403 void OnFinalLogInfoCollectionDone();
391 404
392 // Either closes the current log or creates and closes the initial log 405 // Either closes the current log or creates and closes the initial log
393 // (depending on |state_|), and stages it for upload. 406 // (depending on |state_|), and stages it for upload.
394 void StageNewLog(); 407 void StageNewLog();
395 408
396 // Record stats, client ID, Session ID, etc. in a special "first" log. 409 // Prepares the initial stability log, based on the saved system profile from
397 void PrepareInitialLog(); 410 // a previous session with updated stability stats (only) and stages it for
411 // upload.
Ilya Sherman 2013/12/07 06:51:54 nit: Sorry to super nitpick, but I still find this
Alexei Svitkine (slow) 2013/12/09 21:17:02 Done.
412 void PrepareInitialStabilityLog();
413
414 // Prepares the initial metrics log, which includes startup histograms and
415 // profiler data, as well as incremental stability-related metrics.
416 void PrepareInitialMetricsLog(MetricsLog::LogType log_type);
398 417
399 // Uploads the currently staged log (which must be non-null). 418 // Uploads the currently staged log (which must be non-null).
400 void SendStagedLog(); 419 void SendStagedLog();
401 420
402 // Prepared the staged log to be passed to the server. Upon return, 421 // 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 422 // current_fetch_ should be reset with its upload data set to a compressed
404 // copy of the staged log. 423 // copy of the staged log.
405 void PrepareFetchWithStagedLog(); 424 void PrepareFetchWithStagedLog();
406 425
407 // Implementation of net::URLFetcherDelegate. Called after transmission 426 // 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 499 // WiFi adapter, etc. For non Chrome OS hosts, this will be an
481 // empty string. 500 // empty string.
482 std::string hardware_class_; 501 std::string hardware_class_;
483 502
484 // The list of plugins which was retrieved on the file thread. 503 // The list of plugins which was retrieved on the file thread.
485 std::vector<content::WebPluginInfo> plugins_; 504 std::vector<content::WebPluginInfo> plugins_;
486 505
487 // Google Update statistics, which were retrieved on a blocking pool thread. 506 // Google Update statistics, which were retrieved on a blocking pool thread.
488 GoogleUpdateMetrics google_update_metrics_; 507 GoogleUpdateMetrics google_update_metrics_;
489 508
490 // The initial log, used to record startup metrics. 509 // The initial metrics log, used to record startup metrics (histograms and
491 scoped_ptr<MetricsLog> initial_log_; 510 // profiler data). Note that if a crash occurred in the previous session, an
511 // initial stability log may be sent before this.
512 scoped_ptr<MetricsLog> initial_metrics_log_;
492 513
493 // The outstanding transmission appears as a URL Fetch operation. 514 // The outstanding transmission appears as a URL Fetch operation.
494 scoped_ptr<net::URLFetcher> current_fetch_; 515 scoped_ptr<net::URLFetcher> current_fetch_;
495 516
496 // The TCP/UDP echo server to collect network connectivity stats. 517 // The TCP/UDP echo server to collect network connectivity stats.
497 std::string network_stats_server_; 518 std::string network_stats_server_;
498 519
499 // The HTTP pipelining test server. 520 // The HTTP pipelining test server.
500 std::string http_pipelining_test_server_; 521 std::string http_pipelining_test_server_;
501 522
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 friend class extensions::ExtensionDownloader; 605 friend class extensions::ExtensionDownloader;
585 friend class extensions::ManifestFetchData; 606 friend class extensions::ManifestFetchData;
586 607
587 // Returns true if prefs::kMetricsReportingEnabled is set. 608 // Returns true if prefs::kMetricsReportingEnabled is set.
588 static bool IsMetricsReportingEnabled(); 609 static bool IsMetricsReportingEnabled();
589 610
590 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); 611 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper);
591 }; 612 };
592 613
593 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ 614 #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