Commit 6d46ea6e authored by skau's avatar skau Committed by Commit Bot

Log printer additions and removals by protocol.

In order to track printer churn, we record an event when a printer is
succesfully added and when a printer is removed in the settings dialogs.
This data is tracked by protocol.

BUG=726103

Review-Url: https://codereview.chromium.org/2903883003
Cr-Commit-Position: refs/heads/master@{#476146}
parent 8cb17745
......@@ -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));
......
......@@ -57194,6 +57194,22 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="Printing.CUPS.PrinterAdded" enum="PrinterProtocol">
<owner>skau@chromium.org</owner>
<summary>
The protocol for a printer that was added. Used to track printer churn by
protocol. Only on Chrome OS.
</summary>
</histogram>
<histogram name="Printing.CUPS.PrinterRemoved" enum="PrinterProtocol">
<owner>skau@chromium.org</owner>
<summary>
The protocol for a printer that was removed. Used to track printer churn by
protocol. Only on Chrome OS.
</summary>
</histogram>
<histogram name="Printing.CUPS.PrintersDiscovered" units="printers">
<owner>skau@chromium.org</owner>
<summary>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment