Commit f8fb5865 authored by vitalybuka's avatar vitalybuka Committed by Commit bot

Added helper function to log CloudPrint.ServiceUtilityProcessHostEvent histogram.

Review URL: https://codereview.chromium.org/576823002

Cr-Commit-Position: refs/heads/master@{#295118}
parent 048201a3
...@@ -68,6 +68,7 @@ class ServiceSandboxedProcessLauncherDelegate ...@@ -68,6 +68,7 @@ class ServiceSandboxedProcessLauncherDelegate
using content::ChildProcessHost; using content::ChildProcessHost;
namespace { namespace {
enum ServiceUtilityProcessHostEvent { enum ServiceUtilityProcessHostEvent {
SERVICE_UTILITY_STARTED, SERVICE_UTILITY_STARTED,
SERVICE_UTILITY_DISCONNECTED, SERVICE_UTILITY_DISCONNECTED,
...@@ -83,6 +84,13 @@ enum ServiceUtilityProcessHostEvent { ...@@ -83,6 +84,13 @@ enum ServiceUtilityProcessHostEvent {
SERVICE_UTILITY_FAILED_TO_START, SERVICE_UTILITY_FAILED_TO_START,
SERVICE_UTILITY_EVENT_MAX, SERVICE_UTILITY_EVENT_MAX,
}; };
void ReportUmaEvent(ServiceUtilityProcessHostEvent id) {
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent",
id,
SERVICE_UTILITY_EVENT_MAX);
}
} // namespace } // namespace
ServiceUtilityProcessHost::ServiceUtilityProcessHost( ServiceUtilityProcessHost::ServiceUtilityProcessHost(
...@@ -103,9 +111,7 @@ bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( ...@@ -103,9 +111,7 @@ bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile(
const base::FilePath& pdf_path, const base::FilePath& pdf_path,
const printing::PdfRenderSettings& render_settings, const printing::PdfRenderSettings& render_settings,
const std::vector<printing::PageRange>& page_ranges) { const std::vector<printing::PageRange>& page_ranges) {
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_METAFILE_REQUEST);
SERVICE_UTILITY_METAFILE_REQUEST,
SERVICE_UTILITY_EVENT_MAX);
start_time_ = base::Time::Now(); start_time_ = base::Time::Now();
#if !defined(OS_WIN) #if !defined(OS_WIN)
// This is only implemented on Windows (because currently it is only needed // This is only implemented on Windows (because currently it is only needed
...@@ -136,9 +142,7 @@ bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( ...@@ -136,9 +142,7 @@ bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile(
bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults( bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults(
const std::string& printer_name) { const std::string& printer_name) {
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_CAPS_REQUEST);
SERVICE_UTILITY_CAPS_REQUEST,
SERVICE_UTILITY_EVENT_MAX);
start_time_ = base::Time::Now(); start_time_ = base::Time::Now();
base::FilePath exposed_path; base::FilePath exposed_path;
if (!StartProcess(true, exposed_path)) if (!StartProcess(true, exposed_path))
...@@ -151,9 +155,7 @@ bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults( ...@@ -151,9 +155,7 @@ bool ServiceUtilityProcessHost::StartGetPrinterCapsAndDefaults(
bool ServiceUtilityProcessHost::StartGetPrinterSemanticCapsAndDefaults( bool ServiceUtilityProcessHost::StartGetPrinterSemanticCapsAndDefaults(
const std::string& printer_name) { const std::string& printer_name) {
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_REQUEST);
SERVICE_UTILITY_SEMANTIC_CAPS_REQUEST,
SERVICE_UTILITY_EVENT_MAX);
start_time_ = base::Time::Now(); start_time_ = base::Time::Now();
base::FilePath exposed_path; base::FilePath exposed_path;
if (!StartProcess(true, exposed_path)) if (!StartProcess(true, exposed_path))
...@@ -183,14 +185,10 @@ bool ServiceUtilityProcessHost::StartProcess( ...@@ -183,14 +185,10 @@ bool ServiceUtilityProcessHost::StartProcess(
cmd_line.AppendSwitch(switches::kLang); cmd_line.AppendSwitch(switches::kLang);
if (Launch(&cmd_line, no_sandbox, exposed_dir)) { if (Launch(&cmd_line, no_sandbox, exposed_dir)) {
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_STARTED);
SERVICE_UTILITY_STARTED,
SERVICE_UTILITY_EVENT_MAX);
return true; return true;
} }
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_FAILED_TO_START);
SERVICE_UTILITY_FAILED_TO_START,
SERVICE_UTILITY_EVENT_MAX);
return false; return false;
} }
...@@ -230,9 +228,7 @@ void ServiceUtilityProcessHost::OnChildDisconnected() { ...@@ -230,9 +228,7 @@ void ServiceUtilityProcessHost::OnChildDisconnected() {
// child died. // child died.
client_message_loop_proxy_->PostTask( client_message_loop_proxy_->PostTask(
FROM_HERE, base::Bind(&Client::OnChildDied, client_.get())); FROM_HERE, base::Bind(&Client::OnChildDied, client_.get()));
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_DISCONNECTED);
SERVICE_UTILITY_DISCONNECTED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityDisconnectTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityDisconnectTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
} }
...@@ -273,9 +269,7 @@ base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const { ...@@ -273,9 +269,7 @@ base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const {
void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded(
const std::vector<printing::PageRange>& page_ranges, const std::vector<printing::PageRange>& page_ranges,
double scale_factor) { double scale_factor) {
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_METAFILE_SUCCEEDED);
SERVICE_UTILITY_METAFILE_SUCCEEDED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
DCHECK(waiting_for_reply_); DCHECK(waiting_for_reply_);
...@@ -303,9 +297,7 @@ void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( ...@@ -303,9 +297,7 @@ void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded(
void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafileFailed() { void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafileFailed() {
DCHECK(waiting_for_reply_); DCHECK(waiting_for_reply_);
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_METAFILE_FAILED);
SERVICE_UTILITY_METAFILE_FAILED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityMetafileFailTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
waiting_for_reply_ = false; waiting_for_reply_ = false;
...@@ -319,9 +311,7 @@ void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( ...@@ -319,9 +311,7 @@ void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded(
const std::string& printer_name, const std::string& printer_name,
const printing::PrinterCapsAndDefaults& caps_and_defaults) { const printing::PrinterCapsAndDefaults& caps_and_defaults) {
DCHECK(waiting_for_reply_); DCHECK(waiting_for_reply_);
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_CAPS_SUCCEEDED);
SERVICE_UTILITY_CAPS_SUCCEEDED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
waiting_for_reply_ = false; waiting_for_reply_ = false;
...@@ -335,9 +325,7 @@ void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded( ...@@ -335,9 +325,7 @@ void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded(
const std::string& printer_name, const std::string& printer_name,
const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults) { const printing::PrinterSemanticCapsAndDefaults& caps_and_defaults) {
DCHECK(waiting_for_reply_); DCHECK(waiting_for_reply_);
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_SUCCEEDED);
SERVICE_UTILITY_SEMANTIC_CAPS_SUCCEEDED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
waiting_for_reply_ = false; waiting_for_reply_ = false;
...@@ -350,9 +338,7 @@ void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded( ...@@ -350,9 +338,7 @@ void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsSucceeded(
void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed( void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed(
const std::string& printer_name) { const std::string& printer_name) {
DCHECK(waiting_for_reply_); DCHECK(waiting_for_reply_);
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_CAPS_FAILED);
SERVICE_UTILITY_CAPS_FAILED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsFailTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilityCapsFailTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
waiting_for_reply_ = false; waiting_for_reply_ = false;
...@@ -365,9 +351,7 @@ void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed( ...@@ -365,9 +351,7 @@ void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsFailed(
void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsFailed( void ServiceUtilityProcessHost::OnGetPrinterSemanticCapsAndDefaultsFailed(
const std::string& printer_name) { const std::string& printer_name) {
DCHECK(waiting_for_reply_); DCHECK(waiting_for_reply_);
UMA_HISTOGRAM_ENUMERATION("CloudPrint.ServiceUtilityProcessHostEvent", ReportUmaEvent(SERVICE_UTILITY_SEMANTIC_CAPS_FAILED);
SERVICE_UTILITY_SEMANTIC_CAPS_FAILED,
SERVICE_UTILITY_EVENT_MAX);
UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsFailTime", UMA_HISTOGRAM_TIMES("CloudPrint.ServiceUtilitySemanticCapsFailTime",
base::Time::Now() - start_time_); base::Time::Now() - start_time_);
waiting_for_reply_ = false; waiting_for_reply_ = false;
......
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