Commit d9fb2688 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Copy content::ManifestUmaUtil to blink

This is a part of moving manifest implementation to blink.
content::ManifestUmaUtil would be removed after completing to move
the manifest implementation from content to blink.

Bug: 704441
Change-Id: I5ae55cc02c01c3b3f30268bb0da8dadc83b84f0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1524818Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642371}
parent fc5df617
......@@ -8,5 +8,7 @@ blink_modules_sources("manifest") {
sources = [
"image_resource_type_converters.cc",
"image_resource_type_converters.h",
"manifest_uma_util.cc",
"manifest_uma_util.h",
]
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/manifest/manifest_uma_util.h"
#include "base/metrics/histogram_macros.h"
#include "third_party/blink/public/common/manifest/manifest.h"
namespace blink {
namespace {
static const char kUMANameParseSuccess[] = "Manifest.ParseSuccess";
static const char kUMANameFetchResult[] = "Manifest.FetchResult";
// Enum for UMA purposes, make sure you update histograms.xml if you add new
// result types. Never delete or reorder an entry; only add new entries
// immediately before MANIFEST_FETCH_RESULT_TYPE_COUNT.
enum ManifestFetchResultType {
MANIFEST_FETCH_SUCCESS = 0,
MANIFEST_FETCH_ERROR_EMPTY_URL = 1,
MANIFEST_FETCH_ERROR_UNSPECIFIED = 2,
MANIFEST_FETCH_ERROR_FROM_UNIQUE_ORIGIN = 3,
// Must stay at the end.
MANIFEST_FETCH_RESULT_TYPE_COUNT
};
} // anonymous namespace
void ManifestUmaUtil::ParseSucceeded(const Manifest& manifest) {
UMA_HISTOGRAM_BOOLEAN(kUMANameParseSuccess, true);
UMA_HISTOGRAM_BOOLEAN("Manifest.IsEmpty", manifest.IsEmpty());
if (manifest.IsEmpty())
return;
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.name", !manifest.name.is_null());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.short_name",
!manifest.short_name.is_null());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.start_url",
!manifest.start_url.is_empty());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.display",
manifest.display != kWebDisplayModeUndefined);
UMA_HISTOGRAM_BOOLEAN(
"Manifest.HasProperty.orientation",
manifest.orientation != kWebScreenOrientationLockDefault);
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.icons", !manifest.icons.empty());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.share_target",
manifest.share_target.has_value());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.gcm_sender_id",
!manifest.gcm_sender_id.is_null());
}
void ManifestUmaUtil::ParseFailed() {
UMA_HISTOGRAM_BOOLEAN(kUMANameParseSuccess, false);
}
void ManifestUmaUtil::FetchSucceeded() {
UMA_HISTOGRAM_ENUMERATION(kUMANameFetchResult, MANIFEST_FETCH_SUCCESS,
MANIFEST_FETCH_RESULT_TYPE_COUNT);
}
void ManifestUmaUtil::FetchFailed(FetchFailureReason reason) {
ManifestFetchResultType fetch_result_type = MANIFEST_FETCH_RESULT_TYPE_COUNT;
switch (reason) {
case FETCH_EMPTY_URL:
fetch_result_type = MANIFEST_FETCH_ERROR_EMPTY_URL;
break;
case FETCH_FROM_UNIQUE_ORIGIN:
fetch_result_type = MANIFEST_FETCH_ERROR_FROM_UNIQUE_ORIGIN;
break;
case FETCH_UNSPECIFIED_REASON:
fetch_result_type = MANIFEST_FETCH_ERROR_UNSPECIFIED;
break;
}
DCHECK_NE(fetch_result_type, MANIFEST_FETCH_RESULT_TYPE_COUNT);
UMA_HISTOGRAM_ENUMERATION(kUMANameFetchResult, fetch_result_type,
MANIFEST_FETCH_RESULT_TYPE_COUNT);
}
} // namespace blink
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_MANIFEST_MANIFEST_UMA_UTIL_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MANIFEST_MANIFEST_UMA_UTIL_H_
namespace blink {
struct Manifest;
class ManifestUmaUtil {
public:
enum FetchFailureReason {
FETCH_EMPTY_URL = 0,
FETCH_FROM_UNIQUE_ORIGIN,
FETCH_UNSPECIFIED_REASON
};
// Record that the Manifest was successfully parsed. If it is an empty
// Manifest, it will recorded as so and nothing will happen. Otherwise, the
// presence of each properties will be recorded.
static void ParseSucceeded(const Manifest& manifest);
// Record that the Manifest parsing failed.
static void ParseFailed();
// Record that the Manifest fetching succeeded.
static void FetchSucceeded();
// Record that the Manifest fetching failed and takes the |reason| why it
// failed.
static void FetchFailed(FetchFailureReason reason);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MANIFEST_MANIFEST_UMA_UTIL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment