OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 struct ProcessDataSnapshot; | 67 struct ProcessDataSnapshot; |
68 } | 68 } |
69 | 69 |
70 class MetricsService | 70 class MetricsService |
71 : public chrome_browser_metrics::TrackingSynchronizerObserver, | 71 : public chrome_browser_metrics::TrackingSynchronizerObserver, |
72 public content::BrowserChildProcessObserver, | 72 public content::BrowserChildProcessObserver, |
73 public content::NotificationObserver, | 73 public content::NotificationObserver, |
74 public net::URLFetcherDelegate, | 74 public net::URLFetcherDelegate, |
75 public MetricsServiceBase { | 75 public MetricsServiceBase { |
76 public: | 76 public: |
| 77 // The execution phase of the browser. |
| 78 enum ExecutionPhase { |
| 79 CLEAN_SHUTDOWN = 0, |
| 80 START_METRICS_RECORDING = 100, |
| 81 CREATE_PROFILE = 200, |
| 82 STARTUP_TIMEBOMB_ARM = 300, |
| 83 THREAD_WATCHER_START = 400, |
| 84 MAIN_MESSAGE_LOOP_RUN = 500, |
| 85 SHUTDOWN_TIMEBOMB_ARM = 600, |
| 86 }; |
| 87 |
77 MetricsService(); | 88 MetricsService(); |
78 virtual ~MetricsService(); | 89 virtual ~MetricsService(); |
79 | 90 |
80 // Starts the metrics system, turning on recording and uploading of metrics. | 91 // Starts the metrics system, turning on recording and uploading of metrics. |
81 // Should be called when starting up with metrics enabled, or when metrics | 92 // Should be called when starting up with metrics enabled, or when metrics |
82 // are turned on. | 93 // are turned on. |
83 void Start(); | 94 void Start(); |
84 | 95 |
85 // Starts the metrics system in a special test-only mode. Metrics won't ever | 96 // Starts the metrics system in a special test-only mode. Metrics won't ever |
86 // be uploaded or persisted in this mode, but metrics will be recorded in | 97 // be uploaded or persisted in this mode, but metrics will be recorded in |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Called when the application is going into background mode. | 168 // Called when the application is going into background mode. |
158 void OnAppEnterBackground(); | 169 void OnAppEnterBackground(); |
159 | 170 |
160 // Called when the application is coming out of background mode. | 171 // Called when the application is coming out of background mode. |
161 void OnAppEnterForeground(); | 172 void OnAppEnterForeground(); |
162 #else | 173 #else |
163 // Set the dirty flag, which will require a later call to LogCleanShutdown(). | 174 // Set the dirty flag, which will require a later call to LogCleanShutdown(). |
164 static void LogNeedForCleanShutdown(); | 175 static void LogNeedForCleanShutdown(); |
165 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 176 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
166 | 177 |
| 178 static void SetExecutionPhase(ExecutionPhase execution_phase) { |
| 179 execution_phase_ = execution_phase; |
| 180 } |
167 // Saves in the preferences if the crash report registration was successful. | 181 // Saves in the preferences if the crash report registration was successful. |
168 // This count is eventually send via UMA logs. | 182 // This count is eventually send via UMA logs. |
169 void RecordBreakpadRegistration(bool success); | 183 void RecordBreakpadRegistration(bool success); |
170 | 184 |
171 // Saves in the preferences if the browser is running under a debugger. | 185 // Saves in the preferences if the browser is running under a debugger. |
172 // This count is eventually send via UMA logs. | 186 // This count is eventually send via UMA logs. |
173 void RecordBreakpadHasDebugger(bool has_debugger); | 187 void RecordBreakpadHasDebugger(bool has_debugger); |
174 | 188 |
175 #if defined(OS_WIN) | 189 #if defined(OS_WIN) |
176 // Counts (and removes) the browser crash dump attempt signals left behind by | 190 // Counts (and removes) the browser crash dump attempt signals left behind by |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // The external metric service is used to log ChromeOS UMA events. | 499 // The external metric service is used to log ChromeOS UMA events. |
486 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; | 500 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; |
487 #endif | 501 #endif |
488 | 502 |
489 // The last entropy source returned by this service, used for testing. | 503 // The last entropy source returned by this service, used for testing. |
490 EntropySourceReturned entropy_source_returned_; | 504 EntropySourceReturned entropy_source_returned_; |
491 | 505 |
492 // Stores the time of the last call to |GetIncrementalUptime()|. | 506 // Stores the time of the last call to |GetIncrementalUptime()|. |
493 base::TimeTicks last_updated_time_; | 507 base::TimeTicks last_updated_time_; |
494 | 508 |
| 509 // Execution phase the browser is in. |
| 510 static ExecutionPhase execution_phase_; |
| 511 |
495 // Reduntant marker to check that we completed our shutdown, and set the | 512 // Reduntant marker to check that we completed our shutdown, and set the |
496 // exited-cleanly bit in the prefs. | 513 // exited-cleanly bit in the prefs. |
497 static ShutdownCleanliness clean_shutdown_status_; | 514 static ShutdownCleanliness clean_shutdown_status_; |
498 | 515 |
499 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); | 516 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); |
500 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); | 517 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); |
501 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, LowEntropySource0NotReset); | 518 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, LowEntropySource0NotReset); |
502 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, | 519 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, |
503 PermutedEntropyCacheClearedWhenLowEntropyReset); | 520 PermutedEntropyCacheClearedWhenLowEntropyReset); |
504 FRIEND_TEST_ALL_PREFIXES(MetricsServiceBrowserTest, | 521 FRIEND_TEST_ALL_PREFIXES(MetricsServiceBrowserTest, |
(...skipping 13 matching lines...) Expand all Loading... |
518 friend class extensions::ExtensionDownloader; | 535 friend class extensions::ExtensionDownloader; |
519 friend class extensions::ManifestFetchData; | 536 friend class extensions::ManifestFetchData; |
520 | 537 |
521 // Returns true if prefs::kMetricsReportingEnabled is set. | 538 // Returns true if prefs::kMetricsReportingEnabled is set. |
522 static bool IsMetricsReportingEnabled(); | 539 static bool IsMetricsReportingEnabled(); |
523 | 540 |
524 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 541 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
525 }; | 542 }; |
526 | 543 |
527 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 544 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
OLD | NEW |