forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics_handler.cc
49 lines (37 loc) · 1.47 KB
/
metrics_handler.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2022 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 "pdf/metrics_handler.h"
#include <vector>
#include "base/metrics/histogram_functions.h"
#include "pdf/document_metadata.h"
#include "pdf/file_extension.h"
namespace chrome_pdf {
namespace {
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class PdfHasAttachment {
kNo = 0,
kYes = 1,
kMaxValue = kYes,
};
} // namespace
MetricsHandler::MetricsHandler() = default;
MetricsHandler::~MetricsHandler() = default;
void MetricsHandler::RecordAttachmentTypes(
const std::vector<DocumentAttachmentInfo>& attachments) {
for (const auto& info : attachments) {
base::UmaHistogramEnumeration("PDF.AttachmentType",
FileNameToExtensionIndex(info.name));
}
}
void MetricsHandler::RecordDocumentMetrics(const DocumentMetadata& metadata) {
base::UmaHistogramEnumeration("PDF.Version", metadata.version);
base::UmaHistogramCustomCounts("PDF.PageCount", metadata.page_count, 1,
1000000, 50);
base::UmaHistogramEnumeration(
"PDF.HasAttachment", metadata.has_attachments ? PdfHasAttachment::kYes
: PdfHasAttachment::kNo);
base::UmaHistogramEnumeration("PDF.FormType", metadata.form_type);
}
} // namespace chrome_pdf