Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 struct WebPluginInfo; | 62 struct WebPluginInfo; |
| 63 } | 63 } |
| 64 | 64 |
| 65 namespace extensions { | 65 namespace extensions { |
| 66 class ExtensionDownloader; | 66 class ExtensionDownloader; |
| 67 class ManifestFetchData; | 67 class ManifestFetchData; |
| 68 class MetricsPrivateGetIsCrashReportingEnabledFunction; | 68 class MetricsPrivateGetIsCrashReportingEnabledFunction; |
| 69 } | 69 } |
| 70 | 70 |
| 71 namespace metrics { | 71 namespace metrics { |
| 72 class ClonedInstallDetector; | 72 class ClonedInstallDetector; |
|
Ilya Sherman
2014/05/02 05:12:38
nit: Still needed?
Alexei Svitkine (slow)
2014/05/02 15:21:46
Nope. Removed.
| |
| 73 class MetricsStateManager; | |
| 73 } | 74 } |
| 74 | 75 |
| 75 namespace net { | 76 namespace net { |
| 76 class URLFetcher; | 77 class URLFetcher; |
| 77 } | 78 } |
| 78 | 79 |
| 79 namespace prerender { | 80 namespace prerender { |
| 80 bool IsOmniboxEnabled(Profile* profile); | 81 bool IsOmniboxEnabled(Profile* profile); |
| 81 } | 82 } |
| 82 | 83 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 STARTUP_TIMEBOMB_ARM = 300, | 124 STARTUP_TIMEBOMB_ARM = 300, |
| 124 THREAD_WATCHER_START = 400, | 125 THREAD_WATCHER_START = 400, |
| 125 MAIN_MESSAGE_LOOP_RUN = 500, | 126 MAIN_MESSAGE_LOOP_RUN = 500, |
| 126 SHUTDOWN_TIMEBOMB_ARM = 600, | 127 SHUTDOWN_TIMEBOMB_ARM = 600, |
| 127 SHUTDOWN_COMPLETE = 700, | 128 SHUTDOWN_COMPLETE = 700, |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 enum ReportingState { | 131 enum ReportingState { |
| 131 REPORTING_ENABLED, | 132 REPORTING_ENABLED, |
| 132 REPORTING_DISABLED, | 133 REPORTING_DISABLED, |
| 133 }; | 134 }; |
|
Ilya Sherman
2014/05/02 05:12:38
nit: Still needed?
Alexei Svitkine (slow)
2014/05/02 15:21:46
Nope. Removed.
| |
| 134 | 135 |
| 135 MetricsService(); | 136 MetricsService(); |
| 136 virtual ~MetricsService(); | 137 virtual ~MetricsService(); |
| 137 | 138 |
| 138 // Initializes metrics recording state. Updates various bookkeeping values in | 139 // Initializes metrics recording state. Updates various bookkeeping values in |
| 139 // prefs and sets up the scheduler. This is a separate function rather than | 140 // prefs and sets up the scheduler. This is a separate function rather than |
| 140 // being done by the constructor so that field trials could be created before | 141 // being done by the constructor so that field trials could be created before |
| 141 // this is run. Takes |reporting_state| parameter which specifies whether UMA | 142 // this is run. Takes |reporting_state| parameter which specifies whether UMA |
| 142 // is enabled. | 143 // is enabled. |
|
Ilya Sherman
2014/05/02 05:12:38
nit: Please update the docs.
Alexei Svitkine (slow)
2014/05/02 15:21:46
Done.
| |
| 143 void InitializeMetricsRecordingState(ReportingState reporting_state); | 144 void InitializeMetricsRecordingState(); |
| 144 | 145 |
| 145 // Starts the metrics system, turning on recording and uploading of metrics. | 146 // Starts the metrics system, turning on recording and uploading of metrics. |
| 146 // Should be called when starting up with metrics enabled, or when metrics | 147 // Should be called when starting up with metrics enabled, or when metrics |
| 147 // are turned on. | 148 // are turned on. |
| 148 void Start(); | 149 void Start(); |
|
Ilya Sherman
2014/05/02 05:12:38
When is it appropriate to call Start(), without re
Alexei Svitkine (slow)
2014/05/02 15:21:46
It's still used by private Android code that uses
Ilya Sherman
2014/05/02 19:35:06
Ok. If this is used only by Android:
(1) Can we r
Alexei Svitkine (slow)
2014/05/02 20:21:31
We can't rename it in this CL since the Android co
Ilya Sherman
2014/05/02 20:30:06
I'd prefer to include the documentation as part of
| |
| 149 | 150 |
| 151 // If metrics reporting is enabled, starts the metrics service. Returns | |
| 152 // whether the metrics service was started. | |
| 153 bool StartIfMetricsReportingEnabled(); | |
|
Ilya Sherman
2014/05/02 05:12:38
nit: Perhaps drop "Metrics" from this method name?
Alexei Svitkine (slow)
2014/05/02 15:21:46
I prefer not to change the name, as otherwise it w
| |
| 154 | |
| 150 // Starts the metrics system in a special test-only mode. Metrics won't ever | 155 // Starts the metrics system in a special test-only mode. Metrics won't ever |
| 151 // be uploaded or persisted in this mode, but metrics will be recorded in | 156 // be uploaded or persisted in this mode, but metrics will be recorded in |
| 152 // memory. | 157 // memory. |
| 153 void StartRecordingForTests(); | 158 void StartRecordingForTests(); |
| 154 | 159 |
| 155 // Shuts down the metrics system. Should be called at shutdown, or if metrics | 160 // Shuts down the metrics system. Should be called at shutdown, or if metrics |
| 156 // are turned off. | 161 // are turned off. |
| 157 void Stop(); | 162 void Stop(); |
| 158 | 163 |
| 159 // Enable/disable transmission of accumulated logs and crash reports (dumps). | 164 // Enable/disable transmission of accumulated logs and crash reports (dumps). |
| 160 // Calling Start() automatically enables reporting, but sending is | 165 // Calling Start() automatically enables reporting, but sending is |
| 161 // asyncronous so this can be called immediately after Start() to prevent | 166 // asyncronous so this can be called immediately after Start() to prevent |
| 162 // any uploading. | 167 // any uploading. |
| 163 void EnableReporting(); | 168 void EnableReporting(); |
| 164 void DisableReporting(); | 169 void DisableReporting(); |
| 165 | 170 |
| 166 // Returns the client ID for this client, or the empty string if metrics | 171 // Returns the client ID for this client, or the empty string if metrics |
| 167 // recording is not currently running. | 172 // recording is not currently running. |
| 168 std::string GetClientId(); | 173 std::string GetClientId(); |
| 169 | 174 |
| 170 // Returns the preferred entropy provider used to seed persistent activities | 175 // Returns the preferred entropy provider used to seed persistent activities |
| 171 // based on whether or not metrics reporting will be permitted on this client. | 176 // based on whether or not metrics reporting will be permitted on this client. |
| 172 // The caller must determine if metrics reporting will be enabled for this | |
| 173 // client and pass that state in as |reporting_will_be_enabled|. | |
| 174 // | 177 // |
| 175 // If |reporting_will_be_enabled| is true, this method returns an entropy | 178 // If metrics reporting is enabled, this method returns an entropy provider |
| 176 // provider that has a high source of entropy, partially based on the client | 179 // that has a high source of entropy, partially based on the client ID. |
| 177 // ID. Otherwise, an entropy provider that is based on a low entropy source | 180 // Otherwise, an entropy provider that is based on a low entropy source is |
| 178 // is returned. | 181 // returned. |
| 179 // | 182 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider(); |
| 180 // Note that this reporting state can not be checked by reporting_active() | |
| 181 // because this method may need to be called before the MetricsService needs | |
| 182 // to be started. | |
| 183 scoped_ptr<const base::FieldTrial::EntropyProvider> CreateEntropyProvider( | |
| 184 ReportingState reporting_state); | |
| 185 | |
| 186 // Force the client ID to be generated. This is useful in case it's needed | |
| 187 // before recording. | |
| 188 void ForceClientIdCreation(); | |
| 189 | 183 |
| 190 // At startup, prefs needs to be called with a list of all the pref names and | 184 // At startup, prefs needs to be called with a list of all the pref names and |
| 191 // types we'll be using. | 185 // types we'll be using. |
| 192 static void RegisterPrefs(PrefRegistrySimple* registry); | 186 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 193 #if defined(OS_ANDROID) | 187 #if defined(OS_ANDROID) |
| 194 static void RegisterPrefsAndroid(PrefRegistrySimple* registry); | 188 static void RegisterPrefsAndroid(PrefRegistrySimple* registry); |
| 195 #endif // defined(OS_ANDROID) | 189 #endif // defined(OS_ANDROID) |
| 196 | 190 |
| 197 // Set up notifications which indicate that a user is performing work. This is | 191 // Set up notifications which indicate that a user is performing work. This is |
| 198 // useful to allow some features to sleep, until the machine becomes active, | 192 // useful to allow some features to sleep, until the machine becomes active, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN | 306 NEED_TO_SHUTDOWN = ~CLEANLY_SHUTDOWN |
| 313 }; | 307 }; |
| 314 | 308 |
| 315 // Designates which entropy source was returned from this MetricsService. | 309 // Designates which entropy source was returned from this MetricsService. |
| 316 // This is used for testing to validate that we return the correct source | 310 // This is used for testing to validate that we return the correct source |
| 317 // depending on the state of the service. | 311 // depending on the state of the service. |
| 318 enum EntropySourceReturned { | 312 enum EntropySourceReturned { |
| 319 LAST_ENTROPY_NONE, | 313 LAST_ENTROPY_NONE, |
| 320 LAST_ENTROPY_LOW, | 314 LAST_ENTROPY_LOW, |
| 321 LAST_ENTROPY_HIGH, | 315 LAST_ENTROPY_HIGH, |
| 322 }; | 316 }; |
|
Ilya Sherman
2014/05/02 05:12:38
nit: Still needed?
Alexei Svitkine (slow)
2014/05/02 15:21:46
Nope! Removed.
| |
| 323 | 317 |
| 324 struct ChildProcessStats; | 318 struct ChildProcessStats; |
| 325 | 319 |
| 326 typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups; | 320 typedef std::vector<SyntheticTrialGroup> SyntheticTrialGroups; |
| 327 | 321 |
| 328 // First part of the init task. Called on the FILE thread to load hardware | 322 // First part of the init task. Called on the FILE thread to load hardware |
| 329 // class information. | 323 // class information. |
| 330 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self, | 324 static void InitTaskGetHardwareClass(base::WeakPtr<MetricsService> self, |
| 331 base::MessageLoopProxy* target_loop); | 325 base::MessageLoopProxy* target_loop); |
| 332 | 326 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 361 // Get the amount of uptime since this process started and since the last | 355 // Get the amount of uptime since this process started and since the last |
| 362 // call to this function. Also updates the cumulative uptime metric (stored | 356 // call to this function. Also updates the cumulative uptime metric (stored |
| 363 // as a pref) for uninstall. Uptimes are measured using TimeTicks, which | 357 // as a pref) for uninstall. Uptimes are measured using TimeTicks, which |
| 364 // guarantees that it is monotonic and does not jump if the user changes | 358 // guarantees that it is monotonic and does not jump if the user changes |
| 365 // his/her clock. The TimeTicks implementation also makes the clock not | 359 // his/her clock. The TimeTicks implementation also makes the clock not |
| 366 // count time the computer is suspended. | 360 // count time the computer is suspended. |
| 367 void GetUptimes(PrefService* pref, | 361 void GetUptimes(PrefService* pref, |
| 368 base::TimeDelta* incremental_uptime, | 362 base::TimeDelta* incremental_uptime, |
| 369 base::TimeDelta* uptime); | 363 base::TimeDelta* uptime); |
| 370 | 364 |
| 371 // Reset the client id and low entropy source if the kMetricsResetMetricIDs | |
| 372 // pref is true. | |
| 373 void ResetMetricsIDsIfNecessary(); | |
| 374 | |
| 375 // Returns the low entropy source for this client. This is a random value | |
| 376 // that is non-identifying amongst browser clients. This method will | |
| 377 // generate the entropy source value if it has not been called before. | |
| 378 int GetLowEntropySource(); | |
| 379 | |
| 380 // Returns the first entropy source that was returned by this service since | |
| 381 // start up, or NONE if neither was returned yet. This is exposed for testing | |
| 382 // only. | |
| 383 EntropySourceReturned entropy_source_returned() const { | |
| 384 return entropy_source_returned_; | |
| 385 } | |
| 386 | |
| 387 // Turns recording on or off. | 365 // Turns recording on or off. |
| 388 // DisableRecording() also forces a persistent save of logging state (if | 366 // DisableRecording() also forces a persistent save of logging state (if |
| 389 // anything has been recorded, or transmitted). | 367 // anything has been recorded, or transmitted). |
| 390 void EnableRecording(); | 368 void EnableRecording(); |
| 391 void DisableRecording(); | 369 void DisableRecording(); |
| 392 | 370 |
| 393 // If in_idle is true, sets idle_since_last_transmission to true. | 371 // If in_idle is true, sets idle_since_last_transmission to true. |
| 394 // If in_idle is false and idle_since_last_transmission_ is true, sets | 372 // If in_idle is false and idle_since_last_transmission_ is true, sets |
| 395 // idle_since_last_transmission to false and starts the timer (provided | 373 // idle_since_last_transmission to false and starts the timer (provided |
| 396 // starting the timer is permitted). | 374 // starting the timer is permitted). |
| 397 void HandleIdleSinceLastTransmission(bool in_idle); | 375 void HandleIdleSinceLastTransmission(bool in_idle); |
| 398 | 376 |
| 399 // Set up client ID, session ID, etc. | 377 // Set up client ID, session ID, etc. |
| 400 void InitializeMetricsState(ReportingState reporting_state); | 378 void InitializeMetricsState(); |
| 401 | |
| 402 // Generates a new client ID to use to identify self to metrics server. | |
| 403 static std::string GenerateClientID(); | |
| 404 | 379 |
| 405 // Schedule the next save of LocalState information. This is called | 380 // Schedule the next save of LocalState information. This is called |
| 406 // automatically by the task that performs each save to schedule the next one. | 381 // automatically by the task that performs each save to schedule the next one. |
| 407 void ScheduleNextStateSave(); | 382 void ScheduleNextStateSave(); |
| 408 | 383 |
| 409 // Save the LocalState information immediately. This should not be called by | 384 // Save the LocalState information immediately. This should not be called by |
| 410 // anybody other than the scheduler to avoid doing too many writes. When you | 385 // anybody other than the scheduler to avoid doing too many writes. When you |
| 411 // make a change, call ScheduleNextStateSave() instead. | 386 // make a change, call ScheduleNextStateSave() instead. |
| 412 void SaveLocalState(); | 387 void SaveLocalState(); |
| 413 | 388 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 | 480 |
| 506 // Returns true if process of type |type| should be counted as a plugin | 481 // Returns true if process of type |type| should be counted as a plugin |
| 507 // process, and false otherwise. | 482 // process, and false otherwise. |
| 508 static bool IsPluginProcess(int process_type); | 483 static bool IsPluginProcess(int process_type); |
| 509 | 484 |
| 510 // Returns a list of synthetic field trials that were active for the entire | 485 // Returns a list of synthetic field trials that were active for the entire |
| 511 // duration of the current log. | 486 // duration of the current log. |
| 512 void GetCurrentSyntheticFieldTrials( | 487 void GetCurrentSyntheticFieldTrials( |
| 513 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials); | 488 std::vector<chrome_variations::ActiveGroupId>* synthetic_trials); |
| 514 | 489 |
| 490 scoped_ptr<metrics::MetricsStateManager> state_manager_; | |
|
Ilya Sherman
2014/05/02 05:12:38
nit: Docs, please.
Alexei Svitkine (slow)
2014/05/02 15:21:46
Done.
| |
| 491 | |
| 515 base::ActionCallback action_callback_; | 492 base::ActionCallback action_callback_; |
| 516 | 493 |
| 517 content::NotificationRegistrar registrar_; | 494 content::NotificationRegistrar registrar_; |
| 518 | 495 |
| 519 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. | 496 // Set to true when |ResetMetricsIDsIfNecessary| is called for the first time. |
| 520 // This prevents multiple resets within the same Chrome session. | 497 // This prevents multiple resets within the same Chrome session. |
| 521 bool metrics_ids_reset_check_performed_; | 498 bool metrics_ids_reset_check_performed_; |
| 522 | 499 |
| 523 // Indicate whether recording and reporting are currently happening. | 500 // Indicate whether recording and reporting are currently happening. |
| 524 // These should not be set directly, but by calling SetRecording and | 501 // These should not be set directly, but by calling SetRecording and |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 | 533 |
| 557 // The outstanding transmission appears as a URL Fetch operation. | 534 // The outstanding transmission appears as a URL Fetch operation. |
| 558 scoped_ptr<net::URLFetcher> current_fetch_; | 535 scoped_ptr<net::URLFetcher> current_fetch_; |
| 559 | 536 |
| 560 // The TCP/UDP echo server to collect network connectivity stats. | 537 // The TCP/UDP echo server to collect network connectivity stats. |
| 561 std::string network_stats_server_; | 538 std::string network_stats_server_; |
| 562 | 539 |
| 563 // The HTTP pipelining test server. | 540 // The HTTP pipelining test server. |
| 564 std::string http_pipelining_test_server_; | 541 std::string http_pipelining_test_server_; |
| 565 | 542 |
| 566 // The identifier that's sent to the server with the log reports. | |
| 567 std::string client_id_; | |
| 568 | |
| 569 // The non-identifying low entropy source value. | |
| 570 int low_entropy_source_; | |
| 571 | |
| 572 // Whether the MetricsService object has received any notifications since | 543 // Whether the MetricsService object has received any notifications since |
| 573 // the last time a transmission was sent. | 544 // the last time a transmission was sent. |
| 574 bool idle_since_last_transmission_; | 545 bool idle_since_last_transmission_; |
| 575 | 546 |
| 576 // A number that identifies the how many times the app has been launched. | 547 // A number that identifies the how many times the app has been launched. |
| 577 int session_id_; | 548 int session_id_; |
| 578 | 549 |
| 579 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to | 550 // Maps WebContentses (corresponding to tabs) or Browsers (corresponding to |
| 580 // Windows) to a unique integer that we will use to identify them. | 551 // Windows) to a unique integer that we will use to identify them. |
| 581 // |next_window_id_| is used to track which IDs we have used so far. | 552 // |next_window_id_| is used to track which IDs we have used so far. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 602 bool waiting_for_asynchronous_reporting_step_; | 573 bool waiting_for_asynchronous_reporting_step_; |
| 603 | 574 |
| 604 // Number of async histogram fetch requests in progress. | 575 // Number of async histogram fetch requests in progress. |
| 605 int num_async_histogram_fetches_in_progress_; | 576 int num_async_histogram_fetches_in_progress_; |
| 606 | 577 |
| 607 #if defined(OS_CHROMEOS) | 578 #if defined(OS_CHROMEOS) |
| 608 // The external metric service is used to log ChromeOS UMA events. | 579 // The external metric service is used to log ChromeOS UMA events. |
| 609 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; | 580 scoped_refptr<chromeos::ExternalMetrics> external_metrics_; |
| 610 #endif | 581 #endif |
| 611 | 582 |
| 612 // The last entropy source returned by this service, used for testing. | |
| 613 EntropySourceReturned entropy_source_returned_; | |
| 614 | |
| 615 // Stores the time of the first call to |GetUptimes()|. | 583 // Stores the time of the first call to |GetUptimes()|. |
| 616 base::TimeTicks first_updated_time_; | 584 base::TimeTicks first_updated_time_; |
| 617 | 585 |
| 618 // Stores the time of the last call to |GetUptimes()|. | 586 // Stores the time of the last call to |GetUptimes()|. |
| 619 base::TimeTicks last_updated_time_; | 587 base::TimeTicks last_updated_time_; |
| 620 | 588 |
| 621 // Execution phase the browser is in. | 589 // Execution phase the browser is in. |
| 622 static ExecutionPhase execution_phase_; | 590 static ExecutionPhase execution_phase_; |
| 623 | 591 |
| 624 // Reduntant marker to check that we completed our shutdown, and set the | 592 // Reduntant marker to check that we completed our shutdown, and set the |
| 625 // exited-cleanly bit in the prefs. | 593 // exited-cleanly bit in the prefs. |
| 626 static ShutdownCleanliness clean_shutdown_status_; | 594 static ShutdownCleanliness clean_shutdown_status_; |
| 627 | 595 |
| 628 // Field trial groups that map to Chrome configuration states. | 596 // Field trial groups that map to Chrome configuration states. |
| 629 SyntheticTrialGroups synthetic_trial_groups_; | 597 SyntheticTrialGroups synthetic_trial_groups_; |
| 630 | 598 |
| 631 scoped_ptr<metrics::ClonedInstallDetector> cloned_install_detector_; | |
| 632 | |
| 633 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ClientIdCorrectlyFormatted); | |
| 634 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); | 599 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); |
| 635 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, LowEntropySource0NotReset); | |
| 636 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, | 600 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, |
| 637 PermutedEntropyCacheClearedWhenLowEntropyReset); | 601 PermutedEntropyCacheClearedWhenLowEntropyReset); |
| 638 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); | 602 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); |
| 639 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, ResetMetricsIDs); | |
| 640 FRIEND_TEST_ALL_PREFIXES(MetricsServiceBrowserTest, | |
| 641 CheckLowEntropySourceUsed); | |
| 642 FRIEND_TEST_ALL_PREFIXES(MetricsServiceReportingTest, | |
| 643 CheckHighEntropySourceUsed); | |
| 644 | 603 |
| 645 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 604 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
| 646 }; | 605 }; |
| 647 | 606 |
| 648 // This class limits and documents access to the IsMetricsReportingEnabled() and | 607 // This class limits and documents access to the IsMetricsReportingEnabled() and |
| 649 // IsCrashReportingEnabled() methods. Since these methods are private, each user | 608 // IsCrashReportingEnabled() methods. Since these methods are private, each user |
| 650 // has to be explicitly declared as a 'friend' below. | 609 // has to be explicitly declared as a 'friend' below. |
| 651 class MetricsServiceHelper { | 610 class MetricsServiceHelper { |
| 652 private: | 611 private: |
| 653 friend bool prerender::IsOmniboxEnabled(Profile* profile); | 612 friend bool prerender::IsOmniboxEnabled(Profile* profile); |
| 654 friend class ChromeRenderMessageFilter; | 613 friend class ChromeRenderMessageFilter; |
| 655 friend class ::CrashesDOMHandler; | 614 friend class ::CrashesDOMHandler; |
| 656 friend class extensions::ExtensionDownloader; | 615 friend class extensions::ExtensionDownloader; |
| 657 friend class extensions::ManifestFetchData; | 616 friend class extensions::ManifestFetchData; |
| 658 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction; | 617 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction; |
| 659 friend class ::FlashDOMHandler; | 618 friend class ::FlashDOMHandler; |
| 660 friend class system_logs::ChromeInternalLogSource; | 619 friend class system_logs::ChromeInternalLogSource; |
| 661 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsReportingEnabled); | 620 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsReportingEnabled); |
| 662 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CrashReportingEnabled); | 621 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CrashReportingEnabled); |
| 663 | 622 |
| 664 // Returns true if prefs::kMetricsReportingEnabled is set. | 623 // Returns true if prefs::kMetricsReportingEnabled is set. |
| 665 static bool IsMetricsReportingEnabled(); | 624 static bool IsMetricsReportingEnabled(); |
|
Ilya Sherman
2014/05/02 05:12:38
How does this compare to MetricsStateManager::IsMe
Alexei Svitkine (slow)
2014/05/02 15:21:46
It's different and sometimes incorrect (e.g. see h
| |
| 666 | 625 |
| 667 // Returns true if crash reporting is enabled. This is set at the platform | 626 // Returns true if crash reporting is enabled. This is set at the platform |
| 668 // level for Android and ChromeOS, and otherwise is the same as | 627 // level for Android and ChromeOS, and otherwise is the same as |
| 669 // IsMetricsReportingEnabled for desktop Chrome. | 628 // IsMetricsReportingEnabled for desktop Chrome. |
| 670 static bool IsCrashReportingEnabled(); | 629 static bool IsCrashReportingEnabled(); |
| 671 | 630 |
| 672 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | 631 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); |
| 673 }; | 632 }; |
| 674 | 633 |
| 675 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 634 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
| OLD | NEW |