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

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') | tools/metrics/histograms/histograms.xml » ('J')
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 28a1781f5cad216bd1123cd274008f7d44ca2c0e..c6e28eca3d8fbdf1ce327cfa726d3ae2d032758d 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,7 +45,12 @@ namespace settings {
namespace {
-void OnRemovedPrinter(bool success) {}
+void OnRemovedPrinter(const Printer::PrinterProtocol& protocol, bool success) {
+ if (success) {
+ UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterRemoved", protocol,
+ Printer::PrinterProtocol::PROTOCOL_MAX);
+ }
+}
std::unique_ptr<base::DictionaryValue> GetPrinterInfo(const Printer& printer) {
std::unique_ptr<base::DictionaryValue> printer_info =
@@ -175,12 +181,22 @@ 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) {
+ LOG(WARNING) << "Tried to remove non-existant 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));
}
@@ -257,6 +273,8 @@ void CupsPrintersHandler::OnAddedPrinter(
std::string printer_name = printer->display_name();
switch (result_code) {
case chromeos::PrinterSetupResult::SUCCESS: {
+ UMA_HISTOGRAM_ENUMERATION("Printing.CUPS.PrinterAdded",
+ printer->GetProtocol(), Printer::PROTOCOL_MAX);
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') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698