metrics_switches.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/metrics/metrics_switches.h"
  5. #include "base/check.h"
  6. namespace metrics {
  7. namespace switches {
  8. // Forces metrics reporting to be enabled. Should not be used for tests as it
  9. // will send data to servers.
  10. const char kForceEnableMetricsReporting[] = "force-enable-metrics-reporting";
  11. // Enables the recording of metrics reports but disables reporting. In contrast
  12. // to kForceEnableMetricsReporting, this executes all the code that a normal
  13. // client would use for reporting, except the report is dropped rather than sent
  14. // to the server. This is useful for finding issues in the metrics code during
  15. // UI and performance tests.
  16. const char kMetricsRecordingOnly[] = "metrics-recording-only";
  17. // Override the standard time interval between each metrics report upload for
  18. // UMA and UKM. It is useful to set to a short interval for debugging. Unit in
  19. // seconds. (The default is 1800 seconds on desktop).
  20. const char kMetricsUploadIntervalSec[] = "metrics-upload-interval";
  21. // Forces a reset of the one-time-randomized FieldTrials on this client, also
  22. // known as the Chrome Variations state.
  23. const char kResetVariationState[] = "reset-variation-state";
  24. // Overrides the URL of the server that UKM reports are uploaded to. This can
  25. // only be used in debug builds.
  26. const char kUkmServerUrl[] = "ukm-server-url";
  27. // Overrides the URL of the server that UMA reports are uploaded to. This can
  28. // only be used in debug builds.
  29. const char kUmaServerUrl[] = "uma-server-url";
  30. // Overrides the URL of the server that UMA reports are uploaded to when the
  31. // connection to the default secure URL fails (see |kUmaServerUrl|). This can
  32. // only be used in debug builds.
  33. const char kUmaInsecureServerUrl[] = "uma-insecure-server-url";
  34. } // namespace switches
  35. bool IsMetricsRecordingOnlyEnabled() {
  36. return base::CommandLine::ForCurrentProcess()->HasSwitch(
  37. switches::kMetricsRecordingOnly);
  38. }
  39. bool IsMetricsReportingForceEnabled() {
  40. return base::CommandLine::ForCurrentProcess()->HasSwitch(
  41. switches::kForceEnableMetricsReporting);
  42. }
  43. void EnableMetricsRecordingOnlyForTesting(base::CommandLine* command_line) {
  44. DCHECK(command_line != nullptr);
  45. if (!command_line->HasSwitch(switches::kMetricsRecordingOnly))
  46. command_line->AppendSwitch(switches::kMetricsRecordingOnly);
  47. }
  48. void ForceEnableMetricsReportingForTesting(base::CommandLine* command_line) {
  49. DCHECK(command_line != nullptr);
  50. if (!command_line->HasSwitch(switches::kForceEnableMetricsReporting))
  51. command_line->AppendSwitch(switches::kForceEnableMetricsReporting);
  52. }
  53. } // namespace metrics