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.
5 #include "content/renderer/manifest/manifest_uma_util.h"
7 #include "base/metrics/histogram.h"
8 #include "content/public/common/manifest.h"
14 static const char kUMANameParseSuccess
[] = "Manifest.ParseSuccess";
15 static const char kUMANameFetchResult
[] = "Manifest.FetchResult";
17 // Enum for UMA purposes, make sure you update histograms.xml if you add new
18 // result types. Never delete or reorder an entry; only add new entries
19 // immediately before MANIFEST_FETCH_RESULT_TYPE_COUNT.
20 enum ManifestFetchResultType
{
21 MANIFEST_FETCH_SUCCESS
= 0,
22 MANIFEST_FETCH_ERROR_EMPTY_URL
= 1,
23 MANIFEST_FETCH_ERROR_UNSPECIFIED
= 2,
25 // Must stay at the end.
26 MANIFEST_FETCH_RESULT_TYPE_COUNT
29 } // anonymous namespace
31 void ManifestUmaUtil::ParseSucceeded(const Manifest
& manifest
) {
32 UMA_HISTOGRAM_BOOLEAN(kUMANameParseSuccess
, true);
33 UMA_HISTOGRAM_BOOLEAN("Manifest.IsEmpty", manifest
.IsEmpty());
34 if (manifest
.IsEmpty())
37 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.name", !manifest
.name
.is_null());
38 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.short_name",
39 !manifest
.short_name
.is_null());
40 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.start_url",
41 !manifest
.start_url
.is_empty());
42 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.display",
43 manifest
.display
!= blink::WebDisplayModeUndefined
);
44 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.orientation",
45 manifest
.orientation
!= blink::WebScreenOrientationLockDefault
);
46 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.icons", !manifest
.icons
.empty());
47 UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.gcm_sender_id",
48 !manifest
.gcm_sender_id
.is_null());
51 void ManifestUmaUtil::ParseFailed() {
52 UMA_HISTOGRAM_BOOLEAN(kUMANameParseSuccess
, false);
55 void ManifestUmaUtil::FetchSucceeded() {
56 UMA_HISTOGRAM_ENUMERATION(kUMANameFetchResult
,
57 MANIFEST_FETCH_SUCCESS
,
58 MANIFEST_FETCH_RESULT_TYPE_COUNT
);
61 void ManifestUmaUtil::FetchFailed(FetchFailureReason reason
) {
62 ManifestFetchResultType fetch_result_type
= MANIFEST_FETCH_RESULT_TYPE_COUNT
;
65 fetch_result_type
= MANIFEST_FETCH_ERROR_EMPTY_URL
;
67 case FETCH_UNSPECIFIED_REASON
:
68 fetch_result_type
= MANIFEST_FETCH_ERROR_UNSPECIFIED
;
71 DCHECK_NE(fetch_result_type
, MANIFEST_FETCH_RESULT_TYPE_COUNT
);
73 UMA_HISTOGRAM_ENUMERATION(kUMANameFetchResult
,
75 MANIFEST_FETCH_RESULT_TYPE_COUNT
);
78 } // namespace content