Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2678)

Unified Diff: chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc

Issue 2903883003: Log printer additions and removals by protocol. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cd129cb619421eab66c8e77250b6b2785ebf2ca8..e5d02eb73159277dfd2577ac4e537c42f6b53fad 100644
--- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -53,7 +53,10 @@ void RecordPpdSource(const PpdSourceForHistogram& source) {
UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PpdSource", source, kPpdSourceMax);
}
-void OnRemovedPrinter(bool success) {}
+void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) {
+ UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterRemoved", protocol,
+ Printer::PrinterProtocol::kProtocolMax);
+}
std::unique_ptr<base::DictionaryValue> GetPrinterInfo(const Printer& printer) {
std::unique_ptr<base::DictionaryValue> printer_info =
@@ -184,12 +187,19 @@ void CupsPrintersHandler::HandleRemoveCupsPrinter(const base::ListValue* args) {
std::string printer_name;
CHECK(args->GetString(0, &printer_id));
CHECK(args->GetString(1, &printer_name));
- PrintersManagerFactory::GetForBrowserContext(profile_)->RemovePrinter(
- printer_id);
+ PrintersManager* prefs =
+ PrintersManagerFactory::GetForBrowserContext(profile_);
+ auto printer = prefs->GetPrinter(printer_id);
+ if (!printer)
+ return;
+
+ Printer::PrinterProtocol protocol = printer->GetProtocol();
+ prefs->RemovePrinter(printer_id);
chromeos::DebugDaemonClient* client =
chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
- client->CupsRemovePrinter(printer_name, base::Bind(&OnRemovedPrinter),
+ client->CupsRemovePrinter(printer_name,
+ base::Bind(&OnRemovedPrinter, protocol),
base::Bind(&base::DoNothing));
}
@@ -270,6 +280,8 @@ void CupsPrintersHandler::OnAddedPrinter(
chromeos::PrinterSetupResult::kMaxValue);
switch (result_code) {
case chromeos::PrinterSetupResult::kSuccess: {
+ UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
+ printer->GetProtocol(), Printer::kProtocolMax);
auto* manager = PrintersManagerFactory::GetForBrowserContext(profile_);
manager->PrinterInstalled(*printer);
manager->RegisterPrinter(std::move(printer));
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698