[go: nahoru, domu]

blob: 9c0adbe8275c24e3c38bff8b91fb2b6e6b556785 [file] [log] [blame]
Avi Drissmandb497b32022-09-15 19:47:281// Copyright 2022 The Chromium Authors
Lei Zhang36a438412022-03-29 20:38:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "pdf/metrics_handler.h"
6
7#include <vector>
8
9#include "base/metrics/histogram_functions.h"
10#include "pdf/document_metadata.h"
11#include "pdf/file_extension.h"
12
13namespace chrome_pdf {
14
15namespace {
16
17// These values are persisted to logs. Entries should not be renumbered and
18// numeric values should never be reused.
19enum class PdfHasAttachment {
20 kNo = 0,
21 kYes = 1,
22 kMaxValue = kYes,
23};
24
Lei Zhang36a438412022-03-29 20:38:2125} // namespace
26
27MetricsHandler::MetricsHandler() = default;
28
29MetricsHandler::~MetricsHandler() = default;
30
31void MetricsHandler::RecordAttachmentTypes(
32 const std::vector<DocumentAttachmentInfo>& attachments) {
33 for (const auto& info : attachments) {
34 base::UmaHistogramEnumeration("PDF.AttachmentType",
35 FileNameToExtensionIndex(info.name));
36 }
37}
38
39void MetricsHandler::RecordDocumentMetrics(const DocumentMetadata& metadata) {
40 base::UmaHistogramEnumeration("PDF.Version", metadata.version);
41 base::UmaHistogramCustomCounts("PDF.PageCount", metadata.page_count, 1,
42 1000000, 50);
43 base::UmaHistogramEnumeration(
44 "PDF.HasAttachment", metadata.has_attachments ? PdfHasAttachment::kYes
45 : PdfHasAttachment::kNo);
Lei Zhang36a438412022-03-29 20:38:2146 base::UmaHistogramEnumeration("PDF.FormType", metadata.form_type);
47}
48
49} // namespace chrome_pdf