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

Unified Diff: chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc

Issue 2903923003: Record print job success and print queue size. (Closed)
Patch Set: fix histograms 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/enums.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
index 82ab680f6bda39085e64bcb19a1c1fca0673aa77..01b2b0d22ef125fbc83ada09f5a535fd3e16be54 100644
--- a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
+++ b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/sequenced_task_runner_handle.h"
@@ -46,6 +47,31 @@ using ErrorCode = chromeos::CupsPrintJob::ErrorCode;
using PrinterReason = printing::PrinterStatus::PrinterReason;
+// Enumeration of print job results for histograms. Do not modify!
+enum JobResult {
Carlson 2017/05/25 16:27:17 If this is specific to histograms, can the enum na
skau 2017/05/25 18:45:40 Done.
+ UNKNOWN = 0, // unidentified result
+ FINISHED = 1, // successful completion of job
+ TIMEOUT_CANCEL = 2, // cancelled due to timeout
+ PRINTER_CANCEL = 3, // cancelled by printer
+ LOST = 4, // final state never received
+ RESULT_MAX
+};
+
+// Returns the appropriate JobResult for a given |state|. Only FINISHED and
+// PRINTER_CANCEL are derived from CupsPrintJob::State.
+JobResult ResultForHistogram(State state) {
+ switch (state) {
+ case State::STATE_DOCUMENT_DONE:
+ return FINISHED;
+ case State::STATE_CANCELLED:
+ return PRINTER_CANCEL;
+ default:
+ break;
+ }
+
+ return UNKNOWN;
+}
+
// Returns the equivalient CupsPrintJob#State from a CupsJob#JobState.
chromeos::CupsPrintJob::State ConvertState(printing::CupsJob::JobState state) {
switch (state) {
@@ -223,6 +249,11 @@ bool CupsPrintJobManagerImpl::CreatePrintJob(const std::string& printer_name,
return false;
}
+ // Records the number of jobs we're currently tracking when a new job is
+ // started. This is equivalent to print queue size in the current
+ // implementation.
+ UMA_HISTOGRAM_EXACT_LINEAR("CUPS.PrintJobsQueued", jobs_.size(), 20);
+
// Create a new print job.
auto cpj = base::MakeUnique<CupsPrintJob>(*printer, job_id, title,
total_page_number);
@@ -354,10 +385,14 @@ void CupsPrintJobManagerImpl::UpdateJobs(const QueryResult& result) {
if (print_job->expired()) {
// Job needs to be forcibly cancelled.
+ UMA_HISTOGRAM_ENUMERATION("CUPS.JobResult", TIMEOUT_CANCEL, RESULT_MAX);
CancelPrintJob(print_job);
// Beware, print_job was removed from jobs_ and deleted.
} else if (print_job->IsJobFinished()) {
// Cleanup completed jobs.
+ UMA_HISTOGRAM_ENUMERATION("CUPS.JobResult",
+ ResultForHistogram(print_job->state()),
+ RESULT_MAX);
jobs_.erase(entry);
} else {
active_jobs.push_back(key);
@@ -380,6 +415,7 @@ void CupsPrintJobManagerImpl::UpdateJobs(const QueryResult& result) {
void CupsPrintJobManagerImpl::PurgeJobs() {
for (const auto& entry : jobs_) {
// Declare all lost jobs errors.
+ UMA_HISTOGRAM_ENUMERATION("CUPS.JobResult", LOST, RESULT_MAX);
Alexei Svitkine (slow) 2017/05/25 15:13:56 Please make a helper function for logging this his
skau 2017/05/25 18:45:40 Done.
CupsPrintJob* job = entry.second.get();
job->set_state(CupsPrintJob::State::STATE_ERROR);
NotifyJobStateUpdate(job);
« no previous file with comments | « no previous file | tools/metrics/histograms/enums.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698