Add ICU message format support
[chromium-blink-merge.git] / content / renderer / manifest / manifest_uma_util.cc
blob513c4d8648b60d025ab77016fe2cfa1a9cf5f1d9
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"
10 namespace content {
12 namespace {
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())
35 return;
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 != Manifest::DISPLAY_MODE_UNSPECIFIED);
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;
63 switch (reason) {
64 case FETCH_EMPTY_URL:
65 fetch_result_type = MANIFEST_FETCH_ERROR_EMPTY_URL;
66 break;
67 case FETCH_UNSPECIFIED_REASON:
68 fetch_result_type = MANIFEST_FETCH_ERROR_UNSPECIFIED;
69 break;
71 DCHECK_NE(fetch_result_type, MANIFEST_FETCH_RESULT_TYPE_COUNT);
73 UMA_HISTOGRAM_ENUMERATION(kUMANameFetchResult,
74 fetch_result_type,
75 MANIFEST_FETCH_RESULT_TYPE_COUNT);
78 } // namespace content