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

Unified Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 7016039: PrintPreview: Added new histograms for print preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the CL and fixed a style. Created 9 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 | « chrome/browser/ui/webui/print_preview_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc
index 1e496515093586732ba2f4bed6d0f59db01b5f58..d3cf30e505b257c48dbcb432e64e6d0b6904e9b7 100644
--- a/chrome/browser/ui/webui/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview_handler.cc
@@ -8,6 +8,7 @@
#include "base/i18n/file_util_icu.h"
#include "base/json/json_reader.h"
+#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
@@ -53,6 +54,29 @@ const char kColorDevice[] = "ColorDevice";
const char kPskColor[] = "psk:Color";
#endif
+// Histogram buckets
+enum UserActionBuckets {
+ PRINT_TO_PRINTER,
+ PRINT_TO_PDF,
+ CANCEL,
+ FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
+ USERACTION_BUCKET_BOUNDARY
+};
+
+
+// Print preview user action histogram names.
+const char kUserAction[] = "PrintPreview.UserAction";
+const char kManagePrinters[] = "PrintPreview.ManagePrinters";
+const char kNumberOfPrinters[] = "PrintPreview.NumberOfPrinters";
+const char kPreviewFailedInitiatorTabDoesNotExist[] =
+ "PrintPreview.Failed.InitiatorTabDoesNotExist";
+
+const char kRegeneratePreviewRequestsRcvdBeforeCancel[] =
+ "PrintPreview.RegeneratePreviewRequest.BeforeCancel";
+
+const char kRegeneratePreviewRequestsRcvdBeforePrint[] =
+ "PrintPreview.RegeneratePreviewRequest.BeforePrint";
+
// Get the print job settings dictionary from |args|. The caller takes
// ownership of the returned DictionaryValue. Returns NULL on failure.
DictionaryValue* GetSettingsDictionary(const ListValue* args) {
@@ -87,9 +111,11 @@ class PrintSystemTaskProxy
BrowserThread::DeleteOnUIThread> {
public:
PrintSystemTaskProxy(const base::WeakPtr<PrintPreviewHandler>& handler,
- printing::PrintBackend* print_backend)
+ printing::PrintBackend* print_backend,
+ bool has_logged_printers_count)
: handler_(handler),
- print_backend_(print_backend) {
+ print_backend_(print_backend),
+ has_logged_printers_count_(has_logged_printers_count) {
}
void EnumeratePrinters() {
@@ -98,6 +124,12 @@ class PrintSystemTaskProxy
printing::PrinterList printer_list;
print_backend_->EnumeratePrinters(&printer_list);
+
+ if (!has_logged_printers_count_) {
+ // Record the total number of printers.
+ UMA_HISTOGRAM_COUNTS(kNumberOfPrinters, printer_list.size());
+ }
+
int i = 0;
for (printing::PrinterList::iterator index = printer_list.begin();
index != printer_list.end(); ++index, ++i) {
@@ -201,6 +233,8 @@ class PrintSystemTaskProxy
scoped_refptr<printing::PrintBackend> print_backend_;
+ bool has_logged_printers_count_;
+
DISALLOW_COPY_AND_ASSIGN(PrintSystemTaskProxy);
};
@@ -236,7 +270,11 @@ class PrintToPdfTask : public Task {
FilePath* PrintPreviewHandler::last_saved_path_ = NULL;
PrintPreviewHandler::PrintPreviewHandler()
- : print_backend_(printing::PrintBackend::CreateInstance(NULL)) {
+ : print_backend_(printing::PrintBackend::CreateInstance(NULL)),
+ regenerate_preview_request_count_(0),
+ manage_printers_dialog_request_count_(0),
+ print_preview_failed_count_(0),
+ has_logged_printers_count_(false) {
}
PrintPreviewHandler::~PrintPreviewHandler() {
@@ -267,7 +305,11 @@ TabContents* PrintPreviewHandler::preview_tab() {
void PrintPreviewHandler::HandleGetPrinters(const ListValue*) {
scoped_refptr<PrintSystemTaskProxy> task =
- new PrintSystemTaskProxy(AsWeakPtr(), print_backend_.get());
+ new PrintSystemTaskProxy(AsWeakPtr(),
+ print_backend_.get(),
+ has_logged_printers_count_);
+ has_logged_printers_count_ = true;
+
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(task.get(),
@@ -275,8 +317,12 @@ void PrintPreviewHandler::HandleGetPrinters(const ListValue*) {
}
void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
+ // Increment request count.
+ ++regenerate_preview_request_count_;
+
TabContents* initiator_tab = GetInitiatorTab();
if (!initiator_tab) {
+ ++print_preview_failed_count_;
web_ui_->CallJavascriptFunction("printPreviewFailed");
return;
}
@@ -289,6 +335,13 @@ void PrintPreviewHandler::HandleGetPreview(const ListValue* args) {
}
void PrintPreviewHandler::HandlePrint(const ListValue* args) {
+ ReportStats();
+
+ // Record the number of times the user requests to regenerate preview data
+ // before printing.
+ UMA_HISTOGRAM_COUNTS(kRegeneratePreviewRequestsRcvdBeforePrint,
+ regenerate_preview_request_count_);
+
TabContents* initiator_tab = GetInitiatorTab();
if (initiator_tab) {
RenderViewHost* rvh = initiator_tab->render_view_host();
@@ -306,6 +359,10 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
if (print_to_pdf) {
+ UMA_HISTOGRAM_ENUMERATION(kUserAction,
+ PRINT_TO_PDF,
+ USERACTION_BUCKET_BOUNDARY);
+
// Pre-populating select file dialog with print job title.
string16 print_job_title_utf16 =
preview_tab_wrapper->print_view_manager()->RenderSourceName();
@@ -323,6 +380,9 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
SelectFile(default_filename);
} else {
+ UMA_HISTOGRAM_ENUMERATION(kUserAction,
+ PRINT_TO_PRINTER,
+ USERACTION_BUCKET_BOUNDARY);
g_browser_process->background_printing_manager()->OwnTabContents(
preview_tab_wrapper);
@@ -342,7 +402,9 @@ void PrintPreviewHandler::HandleGetPrinterCapabilities(
return;
scoped_refptr<PrintSystemTaskProxy> task =
- new PrintSystemTaskProxy(AsWeakPtr(), print_backend_.get());
+ new PrintSystemTaskProxy(AsWeakPtr(),
+ print_backend_.get(),
+ has_logged_printers_count_);
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
@@ -352,6 +414,11 @@ void PrintPreviewHandler::HandleGetPrinterCapabilities(
}
void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* args) {
+ ReportStats();
+ UMA_HISTOGRAM_ENUMERATION(kUserAction,
+ FALLBACK_TO_ADVANCED_SETTINGS_DIALOG,
+ USERACTION_BUCKET_BOUNDARY);
+
TabContents* initiator_tab = GetInitiatorTab();
if (!initiator_tab)
return;
@@ -365,13 +432,34 @@ void PrintPreviewHandler::HandleShowSystemDialog(const ListValue* args) {
}
void PrintPreviewHandler::HandleManagePrinters(const ListValue* args) {
+ ++manage_printers_dialog_request_count_;
printing::PrinterManagerDialog::ShowPrinterManagerDialog();
}
void PrintPreviewHandler::HandleClosePreviewTab(const ListValue* args) {
+ ReportStats();
+ UMA_HISTOGRAM_ENUMERATION(kUserAction,
+ CANCEL,
+ USERACTION_BUCKET_BOUNDARY);
+
+ // Record the number of times the user requests to regenerate preview data
+ // before cancelling.
+ UMA_HISTOGRAM_COUNTS(kRegeneratePreviewRequestsRcvdBeforeCancel,
+ regenerate_preview_request_count_);
+
ActivateInitiatorTabAndClosePreviewTab();
}
+void PrintPreviewHandler::ReportStats() {
+ if (print_preview_failed_count_ > 0) {
+ UMA_HISTOGRAM_COUNTS(kPreviewFailedInitiatorTabDoesNotExist,
+ print_preview_failed_count_);
+ }
+
+ UMA_HISTOGRAM_COUNTS(kManagePrinters,
+ manage_printers_dialog_request_count_);
+}
+
void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() {
TabContents* initiator_tab = GetInitiatorTab();
if (initiator_tab)
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698