Skip to content

Commit

Permalink
Cleanup: obsolete multiple PrintPreview histograms
Browse files Browse the repository at this point in the history
- PrintPreview.PrinterStatus.AttemptedPrintWithErrorStatus
- PrintPreview.PrinterStatus.AttemptedPrintWithGoodStatus
- PrintPreview.PrinterStatus.AttemptedPrintWithUnknownStatus

Also removed codes related to these three histograms since they won't be
used. Tested in DUT and the preview and print function works well.

Screenshot: http://screen/6UUjFxoMVYY5VD9.png

Fixed: 1321661
Change-Id: I66a976faf5869daa3c50e481526e6b8bc444c8b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3629961
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Gavin Williams <gavinwill@chromium.org>
Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Wenyu Zhang <zhangwenyu@google.com>
Cr-Commit-Position: refs/heads/main@{#1001605}
  • Loading branch information
wenyu zhang authored and Chromium LUCI CQ committed May 10, 2022
1 parent abc6f61 commit dd12506
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 71 deletions.
36 changes: 1 addition & 35 deletions chrome/browser/resources/print_preview/native_layer_cros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {sendWithPromise} from 'chrome://resources/js/cr.m.js';

import {Cdd} from './data/cdd.js';
import {ExtensionDestinationInfo} from './data/local_parsers.js';
import {PrinterStatus, PrinterStatusReason} from './data/printer_status_cros.js';
import {PrinterStatus} from './data/printer_status_cros.js';

export type PrinterSetupResponse = {
printerId: string,
Expand Down Expand Up @@ -54,16 +54,6 @@ export interface NativeLayerCros {
*/
requestPrinterStatusUpdate(printerId: string): Promise<PrinterStatus>;

/**
* Records the histogram to capture the printer status of the current
* destination and whether the user chose to print or cancel.
* @param statusReason Current destination printer status
* @param didUserAttemptPrint True if user printed, false if user canceled.
*/
recordPrinterStatusHistogram(
statusReason: PrinterStatusReason|null,
didUserAttemptPrint: boolean): void;

/**
* Records the histogram to capture if the retried printer status was
* able to get a valid response from the local printer.
Expand Down Expand Up @@ -101,30 +91,6 @@ export class NativeLayerCrosImpl implements NativeLayerCros {
return sendWithPromise('requestPrinterStatus', printerId);
}

recordPrinterStatusHistogram(
statusReason: PrinterStatusReason|null, didUserAttemptPrint: boolean) {
if (statusReason === null) {
return;
}

let histogram;
switch (statusReason) {
case (PrinterStatusReason.UNKNOWN_REASON):
histogram =
'PrintPreview.PrinterStatus.AttemptedPrintWithUnknownStatus';
break;
case (PrinterStatusReason.NO_ERROR):
histogram = 'PrintPreview.PrinterStatus.AttemptedPrintWithGoodStatus';
break;
default:
histogram = 'PrintPreview.PrinterStatus.AttemptedPrintWithErrorStatus';
break;
}
chrome.send(
'metricsHandler:recordBooleanHistogram',
[histogram, didUserAttemptPrint]);
}

recordPrinterStatusRetrySuccessHistogram(retrySuccessful: boolean) {
chrome.send(
'metricsHandler:recordBooleanHistogram',
Expand Down
34 changes: 1 addition & 33 deletions chrome/browser/resources/print_preview/ui/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import {WebUIListenerMixin} from 'chrome://resources/js/web_ui_listener_mixin.js
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {Destination, PrinterType} from '../data/destination.js';
// <if expr="chromeos_ash or chromeos_lacros">
import {DestinationOrigin} from '../data/destination.js';
// </if>
import {DocumentSettings, PrintPreviewDocumentInfoElement} from '../data/document_info.js';
import {Margins} from '../data/margins.js';
import {MeasurementSystem} from '../data/measurement_system.js';
Expand All @@ -29,9 +26,6 @@ import {Size} from '../data/size.js';
import {Error, PrintPreviewStateElement, State} from '../data/state.js';
import {MetricsContext, PrintPreviewInitializationEvents} from '../metrics.js';
import {NativeInitialSettings, NativeLayer, NativeLayerImpl} from '../native_layer.js';
// <if expr="chromeos_ash or chromeos_lacros">
import {NativeLayerCros, NativeLayerCrosImpl} from '../native_layer_cros.js';
// </if>

import {getTemplate} from './app.html.js';
import {DestinationState} from './destination_settings.js';
Expand Down Expand Up @@ -131,9 +125,6 @@ export class PrintPreviewAppElement extends PrintPreviewAppElementBase {
private maxSheets_: number;

private nativeLayer_: NativeLayer|null = null;
// <if expr="chromeos_ash or chromeos_lacros">
private nativeLayerCros_: NativeLayerCros|null = null;
// </if>
private tracker_: EventTracker = new EventTracker();
private cancelled_: boolean = false;
private printRequested_: boolean = false;
Expand Down Expand Up @@ -167,9 +158,6 @@ export class PrintPreviewAppElement extends PrintPreviewAppElementBase {

document.documentElement.classList.remove('loading');
this.nativeLayer_ = NativeLayerImpl.getInstance();
// <if expr="chromeos_ash or chromeos_lacros">
this.nativeLayerCros_ = NativeLayerCrosImpl.getInstance();
// </if>
this.addWebUIListener('cr-dialog-open', this.onCrDialogOpen_.bind(this));
this.addWebUIListener('close', this.onCrDialogClose_.bind(this));
this.addWebUIListener('print-failed', this.onPrintFailed_.bind(this));
Expand Down Expand Up @@ -221,13 +209,6 @@ export class PrintPreviewAppElement extends PrintPreviewAppElementBase {
e.preventDefault();
}

// <if expr="chromeos_ash or chromeos_lacros">
if (this.destination_ &&
this.destination_.origin === DestinationOrigin.CROS) {
this.nativeLayerCros_!.recordPrinterStatusHistogram(
this.destination_.printerStatusReason, false);
}
// </if>
return;
}

Expand Down Expand Up @@ -424,25 +405,12 @@ export class PrintPreviewAppElement extends PrintPreviewAppElementBase {
this.printRequested_ = true;
return;
}
// <if expr="chromeos_ash or chromeos_lacros">
if (this.destination_ &&
this.destination_.origin === DestinationOrigin.CROS) {
this.nativeLayerCros_!.recordPrinterStatusHistogram(
this.destination_.printerStatusReason, true);
}
// </if>

this.$.state.transitTo(
this.$.previewArea.previewLoaded() ? State.PRINTING : State.HIDDEN);
}

private onCancelRequested_() {
// <if expr="chromeos_ash or chromeos_lacros">
if (this.destination_ &&
this.destination_.origin === DestinationOrigin.CROS) {
this.nativeLayerCros_!.recordPrinterStatusHistogram(
this.destination_.printerStatusReason, false);
}
// </if>
this.cancelled_ = true;
this.$.state.transitTo(State.CLOSING);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@ export class NativeLayerCrosStub extends TestBrowserProxy implements
return this.multiplePrinterStatusRequestsPromise_.promise;
}

recordPrinterStatusHistogram(
_statusReason: PrinterStatusReason, _didUserAttemptPrint: boolean) {}

choosePrintServers(printServerIds: string[]) {
this.methodCalled('choosePrintServers', printServerIds);
}
Expand Down
9 changes: 9 additions & 0 deletions tools/metrics/histograms/metadata/print/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ chromium-metrics-reviews@google.com.

<histogram name="PrintPreview.PrinterStatus.AttemptedPrintWithErrorStatus"
enum="Boolean" expires_after="2022-10-04">
<obsolete>
Data no longer needed 2022-05.
</obsolete>
<owner>gavinwill@chromium.org</owner>
<owner>cros-peripherals@google.com</owner>
<summary>
Expand All @@ -182,6 +185,9 @@ chromium-metrics-reviews@google.com.

<histogram name="PrintPreview.PrinterStatus.AttemptedPrintWithGoodStatus"
enum="Boolean" expires_after="2022-10-04">
<obsolete>
Data no longer needed 2022-05.
</obsolete>
<owner>gavinwill@chromium.org</owner>
<owner>cros-peripherals@google.com</owner>
<summary>
Expand All @@ -192,6 +198,9 @@ chromium-metrics-reviews@google.com.

<histogram name="PrintPreview.PrinterStatus.AttemptedPrintWithUnknownStatus"
enum="Boolean" expires_after="2022-06-15">
<obsolete>
Data no longer needed 2022-05.
</obsolete>
<owner>gavinwill@chromium.org</owner>
<owner>cros-peripherals@google.com</owner>
<summary>
Expand Down

0 comments on commit dd12506

Please sign in to comment.