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
3 // found in the LICENSE file.
5 #include "content/browser/appcache/appcache_histograms.h"
7 #include "base/metrics/histogram.h"
11 static std::string
OriginToCustomHistogramSuffix(const GURL
& origin_url
) {
12 if (origin_url
.host() == "docs.google.com")
17 void AppCacheHistograms::CountInitResult(InitResultType init_result
) {
18 UMA_HISTOGRAM_ENUMERATION(
19 "appcache.InitResult",
20 init_result
, NUM_INIT_RESULT_TYPES
);
23 void AppCacheHistograms::CountReinitAttempt(bool repeated_attempt
) {
24 UMA_HISTOGRAM_BOOLEAN("appcache.ReinitAttempt", repeated_attempt
);
27 void AppCacheHistograms::CountCorruptionDetected() {
28 UMA_HISTOGRAM_BOOLEAN("appcache.CorruptionDetected", true);
31 void AppCacheHistograms::CountUpdateJobResult(
32 AppCacheUpdateJob::ResultType result
,
33 const GURL
& origin_url
) {
34 UMA_HISTOGRAM_ENUMERATION(
35 "appcache.UpdateJobResult",
36 result
, AppCacheUpdateJob::NUM_UPDATE_JOB_RESULT_TYPES
);
38 const std::string suffix
= OriginToCustomHistogramSuffix(origin_url
);
39 if (!suffix
.empty()) {
40 base::LinearHistogram::FactoryGet(
41 "appcache.UpdateJobResult" + suffix
,
43 AppCacheUpdateJob::NUM_UPDATE_JOB_RESULT_TYPES
,
44 AppCacheUpdateJob::NUM_UPDATE_JOB_RESULT_TYPES
+ 1,
45 base::HistogramBase::kUmaTargetedHistogramFlag
)->Add(result
);
49 void AppCacheHistograms::CountCheckResponseResult(
50 CheckResponseResultType result
) {
51 UMA_HISTOGRAM_ENUMERATION(
52 "appcache.CheckResponseResult",
53 result
, NUM_CHECK_RESPONSE_RESULT_TYPES
);
56 void AppCacheHistograms::CountResponseRetrieval(
57 bool success
, bool is_main_resource
, const GURL
& origin_url
) {
59 if (is_main_resource
) {
60 label
= "appcache.MainResourceResponseRetrieval";
61 UMA_HISTOGRAM_BOOLEAN(label
, success
);
63 label
= "appcache.SubResourceResponseRetrieval";
64 UMA_HISTOGRAM_BOOLEAN(label
, success
);
66 const std::string suffix
= OriginToCustomHistogramSuffix(origin_url
);
67 if (!suffix
.empty()) {
68 base::BooleanHistogram::FactoryGet(
70 base::HistogramBase::kUmaTargetedHistogramFlag
)->Add(success
);
74 void AppCacheHistograms::LogUpdateFailureStats(
75 const GURL
& origin_url
,
78 bool was_off_origin_resource_failure
) {
79 const std::string suffix
= OriginToCustomHistogramSuffix(origin_url
);
81 std::string label
= "appcache.UpdateProgressAtPointOfFaliure";
82 UMA_HISTOGRAM_PERCENTAGE(label
, percent_complete
);
83 if (!suffix
.empty()) {
84 base::LinearHistogram::FactoryGet(
87 base::HistogramBase::kUmaTargetedHistogramFlag
)->Add(percent_complete
);
90 label
= "appcache.UpdateWasStalledAtPointOfFailure";
91 UMA_HISTOGRAM_BOOLEAN(label
, was_stalled
);
92 if (!suffix
.empty()) {
93 base::BooleanHistogram::FactoryGet(
95 base::HistogramBase::kUmaTargetedHistogramFlag
)->Add(was_stalled
);
98 label
= "appcache.UpdateWasOffOriginAtPointOfFailure";
99 UMA_HISTOGRAM_BOOLEAN(label
, was_off_origin_resource_failure
);
100 if (!suffix
.empty()) {
101 base::BooleanHistogram::FactoryGet(
103 base::HistogramBase::kUmaTargetedHistogramFlag
)->Add(
104 was_off_origin_resource_failure
);
108 void AppCacheHistograms::AddTaskQueueTimeSample(
109 const base::TimeDelta
& duration
) {
110 UMA_HISTOGRAM_TIMES("appcache.TaskQueueTime", duration
);
113 void AppCacheHistograms::AddTaskRunTimeSample(
114 const base::TimeDelta
& duration
) {
115 UMA_HISTOGRAM_TIMES("appcache.TaskRunTime", duration
);
118 void AppCacheHistograms::AddCompletionQueueTimeSample(
119 const base::TimeDelta
& duration
) {
120 UMA_HISTOGRAM_TIMES("appcache.CompletionQueueTime", duration
);
123 void AppCacheHistograms::AddCompletionRunTimeSample(
124 const base::TimeDelta
& duration
) {
125 UMA_HISTOGRAM_TIMES("appcache.CompletionRunTime", duration
);
128 void AppCacheHistograms::AddNetworkJobStartDelaySample(
129 const base::TimeDelta
& duration
) {
130 UMA_HISTOGRAM_TIMES("appcache.JobStartDelay.Network", duration
);
133 void AppCacheHistograms::AddErrorJobStartDelaySample(
134 const base::TimeDelta
& duration
) {
135 UMA_HISTOGRAM_TIMES("appcache.JobStartDelay.Error", duration
);
138 void AppCacheHistograms::AddAppCacheJobStartDelaySample(
139 const base::TimeDelta
& duration
) {
140 UMA_HISTOGRAM_TIMES("appcache.JobStartDelay.AppCache", duration
);
143 void AppCacheHistograms::AddMissingManifestEntrySample() {
144 UMA_HISTOGRAM_BOOLEAN("appcache.MissingManifestEntry", true);
147 void AppCacheHistograms::AddMissingManifestDetectedAtCallsite(
148 MissingManifestCallsiteType callsite
) {
149 UMA_HISTOGRAM_ENUMERATION(
150 "appcache.MissingManifestDetectedAtCallsite",
151 callsite
, NUM_MISSING_MANIFEST_CALLSITE_TYPES
);
154 } // namespace content