Chromium Code Reviews| Index: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc |
| diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc |
| index fbf676442a9a98b6841a8d26419119ab3155f849..af1b541f28e3d84a4eb1fd6c874b1c9e42ddcd88 100644 |
| --- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc |
| +++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/files/file_util.h" |
| #include "base/json/json_string_value_serializer.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "base/path_service.h" |
| #include "base/strings/string_util.h" |
| #include "base/threading/sequenced_task_runner_handle.h" |
| @@ -44,6 +45,14 @@ namespace settings { |
| namespace { |
| +// These values are written to logs. New enum values can be added, but existing |
| +// enums must never be renumbered or deleted and reused. |
| +enum PpdSourceForHistogram { kUser = 0, kScs = 1, kPpdSourceMax }; |
| + |
| +void RecordPpdSource(const PpdSourceForHistogram& source) { |
| + UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PpdSource", kUser, kPpdSourceMax); |
| +} |
| + |
| void OnRemovedPrinter(bool success) {} |
| std::unique_ptr<base::DictionaryValue> GetPrinterInfo(const Printer& printer) { |
| @@ -225,6 +234,7 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) { |
| // Verify a valid ppd path is present. |
| if (!printer_ppd_path.empty()) { |
| + RecordPpdSource(kUser); |
| GURL tmp = net::FilePathToFileURL(base::FilePath(printer_ppd_path)); |
| if (!tmp.is_valid()) { |
| LOG(ERROR) << "Invalid ppd path: " << printer_ppd_path; |
| @@ -233,6 +243,7 @@ void CupsPrintersHandler::HandleAddCupsPrinter(const base::ListValue* args) { |
| } |
| printer->mutable_ppd_reference()->user_supplied_ppd_url = tmp.spec(); |
| } else if (!printer_manufacturer.empty() && !printer_model.empty()) { |
| + RecordPpdSource(kScs); |
| // Using the manufacturer and model, get a ppd reference. |
| if (!ppd_provider_->GetPpdReference(printer_manufacturer, printer_model, |
| printer->mutable_ppd_reference())) { |
| @@ -255,6 +266,8 @@ void CupsPrintersHandler::OnAddedPrinter( |
| std::unique_ptr<Printer> printer, |
| chromeos::PrinterSetupResult result_code) { |
| std::string printer_name = printer->display_name(); |
| + UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterSetupResult", result_code, |
| + chromeos::PrinterSetupResult::kMaxValue); |
| switch (result_code) { |
| case chromeos::PrinterSetupResult::kSuccess: { |
| auto* manager = PrintersManagerFactory::GetForBrowserContext(profile_); |
| @@ -407,6 +420,9 @@ void CupsPrintersHandler::OnPrintersFound( |
| printers_list->Append(GetPrinterInfo(printer)); |
| } |
| + UMA_HISTOGRAM_COUNTS_100("Printing.CUPS.PrintersDiscovered", |
|
Carlson
2017/05/26 16:58:38
Since this is potentially incremental, Would it b
skau
2017/05/26 17:18:02
I forgot this is incremental. You're right that r
Carlson
2017/05/26 17:29:19
It's incremental, but not in the way you're thinki
|
| + printers_list->GetSize()); |
| + |
| FireWebUIListener("on-printer-discovered", *printers_list); |
| } |