| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #include "components/translate/core/common/translate_metrics.h" | 5 #include "components/translate/core/common/translate_metrics.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
| 8 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 9 #include "url/url_constants.h" | 12 #include "url/url_constants.h" |
| 10 | 13 |
| 11 namespace translate { | 14 namespace translate { |
| 12 | 15 |
| 13 namespace { | 16 namespace { |
| 14 | 17 |
| 15 // Constant string values to indicate UMA names. All entries should have | 18 // Constant string values to indicate UMA names. All entries should have |
| 16 // a corresponding index in MetricsNameIndex and an entry in |kMetricsEntries|. | 19 // a corresponding index in MetricsNameIndex and an entry in |kMetricsEntries|. |
| 17 const char kRenderer4LanguageDetection[] = "Renderer4.LanguageDetection"; | 20 const char kRenderer4LanguageDetection[] = "Renderer4.LanguageDetection"; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 LANGUAGE_MAX); | 74 LANGUAGE_MAX); |
| 72 } | 75 } |
| 73 | 76 |
| 74 void ReportLanguageVerification(LanguageVerificationType type) { | 77 void ReportLanguageVerification(LanguageVerificationType type) { |
| 75 UMA_HISTOGRAM_ENUMERATION(kTranslateLanguageVerification, | 78 UMA_HISTOGRAM_ENUMERATION(kTranslateLanguageVerification, |
| 76 type, | 79 type, |
| 77 LANGUAGE_VERIFICATION_MAX); | 80 LANGUAGE_VERIFICATION_MAX); |
| 78 } | 81 } |
| 79 | 82 |
| 80 void ReportTimeToBeReady(double time_in_msec) { | 83 void ReportTimeToBeReady(double time_in_msec) { |
| 81 UMA_HISTOGRAM_MEDIUM_TIMES( | 84 UMA_HISTOGRAM_MEDIUM_TIMES(kTranslateTimeToBeReady, |
| 82 kTranslateTimeToBeReady, | 85 base::TimeDelta::FromMicroseconds( |
| 83 base::TimeDelta::FromMicroseconds( | 86 static_cast<int64_t>(time_in_msec * 1000.0))); |
| 84 static_cast<int64>(time_in_msec * 1000.0))); | |
| 85 } | 87 } |
| 86 | 88 |
| 87 void ReportTimeToLoad(double time_in_msec) { | 89 void ReportTimeToLoad(double time_in_msec) { |
| 88 UMA_HISTOGRAM_MEDIUM_TIMES( | 90 UMA_HISTOGRAM_MEDIUM_TIMES(kTranslateTimeToLoad, |
| 89 kTranslateTimeToLoad, | 91 base::TimeDelta::FromMicroseconds( |
| 90 base::TimeDelta::FromMicroseconds( | 92 static_cast<int64_t>(time_in_msec * 1000.0))); |
| 91 static_cast<int64>(time_in_msec * 1000.0))); | |
| 92 } | 93 } |
| 93 | 94 |
| 94 void ReportTimeToTranslate(double time_in_msec) { | 95 void ReportTimeToTranslate(double time_in_msec) { |
| 95 UMA_HISTOGRAM_MEDIUM_TIMES( | 96 UMA_HISTOGRAM_MEDIUM_TIMES(kTranslateTimeToTranslate, |
| 96 kTranslateTimeToTranslate, | 97 base::TimeDelta::FromMicroseconds( |
| 97 base::TimeDelta::FromMicroseconds( | 98 static_cast<int64_t>(time_in_msec * 1000.0))); |
| 98 static_cast<int64>(time_in_msec * 1000.0))); | |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ReportUserActionDuration(base::TimeTicks begin, base::TimeTicks end) { | 101 void ReportUserActionDuration(base::TimeTicks begin, base::TimeTicks end) { |
| 102 UMA_HISTOGRAM_LONG_TIMES(kTranslateUserActionDuration, end - begin); | 102 UMA_HISTOGRAM_LONG_TIMES(kTranslateUserActionDuration, end - begin); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void ReportPageScheme(const std::string& scheme) { | 105 void ReportPageScheme(const std::string& scheme) { |
| 106 SchemeType type = SCHEME_OTHERS; | 106 SchemeType type = SCHEME_OTHERS; |
| 107 if (scheme == url::kHttpScheme) | 107 if (scheme == url::kHttpScheme) |
| 108 type = SCHEME_HTTP; | 108 type = SCHEME_HTTP; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 122 const char* GetMetricsName(MetricsNameIndex index) { | 122 const char* GetMetricsName(MetricsNameIndex index) { |
| 123 for (size_t i = 0; i < arraysize(kMetricsEntries); ++i) { | 123 for (size_t i = 0; i < arraysize(kMetricsEntries); ++i) { |
| 124 if (kMetricsEntries[i].index == index) | 124 if (kMetricsEntries[i].index == index) |
| 125 return kMetricsEntries[i].name; | 125 return kMetricsEntries[i].name; |
| 126 } | 126 } |
| 127 NOTREACHED(); | 127 NOTREACHED(); |
| 128 return NULL; | 128 return NULL; |
| 129 } | 129 } |
| 130 | 130 |
| 131 } // namespace translate | 131 } // namespace translate |
| OLD | NEW |