spellcheck_renderer_metrics.cc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2019 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. #ifndef COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_RENDERER_METRICS_H_
  5. #define COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_RENDERER_METRICS_H_
  6. #include "components/spellcheck/renderer/spellcheck_renderer_metrics.h"
  7. #include "base/metrics/histogram_macros.h"
  8. #include "base/time/time.h"
  9. #include "build/build_config.h"
  10. #include "components/spellcheck/spellcheck_buildflags.h"
  11. #if BUILDFLAG(IS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  12. namespace {
  13. // Records the duration of a spell check request. This variation is for when
  14. // spell check is performed only by Hunspell.
  15. void RecordHunspellSpellcheckDuration(base::TimeDelta duration) {
  16. UMA_HISTOGRAM_TIMES(
  17. "Spellcheck.Windows.SpellcheckRequestDuration.HunspellOnly", duration);
  18. }
  19. // Records the duration of a spell check request. This variation is for when
  20. // spell check is performed by both Hunspell and the OS spell checker.
  21. void RecordHybridSpellcheckDuration(base::TimeDelta duration) {
  22. UMA_HISTOGRAM_TIMES("Spellcheck.Windows.SpellcheckRequestDuration.Hybrid",
  23. duration);
  24. }
  25. // Records the duration of a spell check request. This variation is for when
  26. // spell check is performed only by the OS spell checker.
  27. void RecordNativeSpellcheckDuration(base::TimeDelta duration) {
  28. UMA_HISTOGRAM_TIMES("Spellcheck.Windows.SpellcheckRequestDuration.NativeOnly",
  29. duration);
  30. }
  31. } // anonymous namespace
  32. #endif // BUILDFLAG(IS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  33. namespace spellcheck_renderer_metrics {
  34. void RecordAsyncCheckedTextLength(int length) {
  35. UMA_HISTOGRAM_COUNTS_1M("SpellCheck.api.async", length);
  36. }
  37. void RecordCheckedTextLengthNoSuggestions(int length) {
  38. UMA_HISTOGRAM_COUNTS_1M("SpellCheck.api.check", length);
  39. }
  40. void RecordCheckedTextLengthWithSuggestions(int length) {
  41. UMA_HISTOGRAM_COUNTS_1M("SpellCheck.api.check.suggestions", length);
  42. }
  43. #if BUILDFLAG(IS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  44. void RecordHunspellSuggestionDuration(base::TimeDelta duration) {
  45. UMA_HISTOGRAM_TIMES(
  46. "Spellcheck.Windows.SuggestionGatheringDuration.HunspellOnly", duration);
  47. }
  48. void RecordHybridSuggestionDuration(base::TimeDelta duration) {
  49. UMA_HISTOGRAM_TIMES("Spellcheck.Windows.SuggestionGatheringDuration.Hybrid",
  50. duration);
  51. }
  52. void RecordSpellcheckDuration(base::TimeDelta duration,
  53. bool used_hunspell,
  54. bool used_native) {
  55. if (used_hunspell && !used_native) {
  56. RecordHunspellSpellcheckDuration(duration);
  57. } else if (used_hunspell && used_native) {
  58. RecordHybridSpellcheckDuration(duration);
  59. } else if (!used_hunspell && used_native) {
  60. RecordNativeSpellcheckDuration(duration);
  61. }
  62. }
  63. #endif // BUILDFLAG(IS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
  64. } // namespace spellcheck_renderer_metrics
  65. #endif // COMPONENTS_SPELLCHECK_RENDERER_SPELLCHECK_RENDERER_METRICS_H_