Commit 2c3ee50a authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Add PrinterErrorCode to print job database

- PrinterErrorCode is an enum that details the error that the printer
  reported when a print job either completes successfully or ran into an
  error with printing the print job.
- This enum is also added to PrintingMetrics API.
- Existing stored print jobs will not have this field available as
  we previously were not storing this information to the local database.

Bug: 1053704
Test: unit_tests
Change-Id: I6e851bd1def6ae522fc413d8df1ccbe53d421a98
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207778
Commit-Queue: jimmy gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarNikita Podguzov <nikitapodguzov@chromium.org>
Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776788}
parent dfeb4638
......@@ -2576,12 +2576,6 @@ source_set("chromeos") {
"extensions/printing/print_job_controller.h",
"extensions/printing/printer_capabilities_provider.cc",
"extensions/printing/printer_capabilities_provider.h",
"extensions/printing_metrics/print_job_finished_event_dispatcher.cc",
"extensions/printing_metrics/print_job_finished_event_dispatcher.h",
"extensions/printing_metrics/print_job_info_idl_conversions.cc",
"extensions/printing_metrics/print_job_info_idl_conversions.h",
"extensions/printing_metrics/printing_metrics_api.cc",
"extensions/printing_metrics/printing_metrics_api.h",
"extensions/quick_unlock_private/quick_unlock_private_api.cc",
"extensions/quick_unlock_private/quick_unlock_private_api.h",
"extensions/users_private/users_private_api.cc",
......@@ -2613,6 +2607,12 @@ source_set("chromeos") {
"extensions/printing/printing_api_handler.h",
"extensions/printing/printing_api_utils.cc",
"extensions/printing/printing_api_utils.h",
"extensions/printing_metrics/print_job_finished_event_dispatcher.cc",
"extensions/printing_metrics/print_job_finished_event_dispatcher.h",
"extensions/printing_metrics/print_job_info_idl_conversions.cc",
"extensions/printing_metrics/print_job_info_idl_conversions.h",
"extensions/printing_metrics/printing_metrics_api.cc",
"extensions/printing_metrics/printing_metrics_api.h",
"printing/cups_print_job_manager_impl.cc",
"printing/cups_proxy_service_delegate_impl.cc",
"printing/cups_proxy_service_delegate_impl.h",
......@@ -2969,9 +2969,6 @@ source_set("unit_tests") {
"extensions/printing/fake_print_job_controller.cc",
"extensions/printing/fake_print_job_controller.h",
"extensions/printing/printer_capabilities_provider_unittest.cc",
"extensions/printing_metrics/print_job_finished_event_dispatcher_unittest.cc",
"extensions/printing_metrics/print_job_info_idl_conversions_unittest.cc",
"extensions/printing_metrics/printing_metrics_api_unittest.cc",
"extensions/public_session_permission_helper_unittest.cc",
"extensions/quick_unlock_private/quick_unlock_private_api_unittest.cc",
"extensions/signin_screen_policy_provider_unittest.cc",
......@@ -3352,6 +3349,9 @@ source_set("unit_tests") {
sources += [
"extensions/printing/printing_api_handler_unittest.cc",
"extensions/printing/printing_api_utils_unittest.cc",
"extensions/printing_metrics/print_job_finished_event_dispatcher_unittest.cc",
"extensions/printing_metrics/print_job_info_idl_conversions_unittest.cc",
"extensions/printing_metrics/printing_metrics_api_unittest.cc",
"printing/test_cups_wrapper.cc",
"printing/test_cups_wrapper.h",
]
......
......@@ -57,8 +57,8 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
extensions::MediaPlayerAPI::GetFactoryInstance();
#if defined(USE_CUPS)
extensions::PrintingAPIHandler::GetFactoryInstance();
#endif
extensions::PrintJobFinishedEventDispatcher::GetFactoryInstance();
#endif
extensions::SessionStateChangedEventDispatcher::GetFactoryInstance();
file_manager::EventRouterFactory::GetInstance();
file_manager::VolumeManagerFactory::GetInstance();
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/extensions/printing_metrics/print_job_finished_event_dispatcher.h"
#include "base/no_destructor.h"
#include "chrome/browser/chromeos/extensions/printing/printing_api.h"
#include "chrome/browser/chromeos/extensions/printing_metrics/print_job_info_idl_conversions.h"
#include "chrome/common/extensions/api/printing_metrics.h"
#include "content/public/browser/browser_context.h"
......
......@@ -6,6 +6,8 @@
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "chrome/browser/chromeos/extensions/printing/printing_api.h"
#include "chrome/common/extensions/api/printing.h"
namespace proto = chromeos::printing::proto;
......@@ -112,6 +114,40 @@ idl::Printer PrinterProtoToIdl(const proto::Printer& printer_proto) {
return printer;
}
api::printing::PrinterStatus PrinterErrorCodeToIdl(
proto::PrintJobInfo_PrinterErrorCode error_code_proto) {
switch (error_code_proto) {
case proto::PrintJobInfo_PrinterErrorCode_NO_ERROR:
return api::printing::PRINTER_STATUS_AVAILABLE;
case proto::PrintJobInfo_PrinterErrorCode_PAPER_JAM:
return api::printing::PRINTER_STATUS_PAPER_JAM;
case proto::PrintJobInfo_PrinterErrorCode_OUT_OF_PAPER:
return api::printing::PRINTER_STATUS_OUT_OF_PAPER;
case proto::PrintJobInfo_PrinterErrorCode_OUT_OF_INK:
return api::printing::PRINTER_STATUS_OUT_OF_INK;
case proto::PrintJobInfo_PrinterErrorCode_DOOR_OPEN:
return api::printing::PRINTER_STATUS_DOOR_OPEN;
case proto::PrintJobInfo_PrinterErrorCode_PRINTER_UNREACHABLE:
return api::printing::PRINTER_STATUS_UNREACHABLE;
case proto::PrintJobInfo_PrinterErrorCode_TRAY_MISSING:
return api::printing::PRINTER_STATUS_TRAY_MISSING;
case proto::PrintJobInfo_PrinterErrorCode_OUTPUT_FULL:
return api::printing::PRINTER_STATUS_OUTPUT_FULL;
case proto::PrintJobInfo_PrinterErrorCode_STOPPED:
return api::printing::PRINTER_STATUS_STOPPED;
case proto::PrintJobInfo_PrinterErrorCode_FILTER_FAILED:
case proto::PrintJobInfo_PrinterErrorCode_UNKNOWN_ERROR:
return api::printing::PRINTER_STATUS_GENERIC_ISSUE;
case proto::
PrintJobInfo_PrinterErrorCode_PrintJobInfo_PrinterErrorCode_INT_MIN_SENTINEL_DO_NOT_USE_:
case proto::
PrintJobInfo_PrinterErrorCode_PrintJobInfo_PrinterErrorCode_INT_MAX_SENTINEL_DO_NOT_USE_:
NOTREACHED();
return api::printing::PRINTER_STATUS_GENERIC_ISSUE;
}
return api::printing::PRINTER_STATUS_GENERIC_ISSUE;
}
} // namespace
idl::PrintJobInfo PrintJobInfoProtoToIdl(
......@@ -129,6 +165,8 @@ idl::PrintJobInfo PrintJobInfoProtoToIdl(
print_job_info.completion_time =
base::checked_cast<double>(print_job_info_proto.completion_time());
print_job_info.printer = PrinterProtoToIdl(print_job_info_proto.printer());
print_job_info.printer_status =
PrinterErrorCodeToIdl(print_job_info_proto.printer_error_code());
print_job_info.settings =
PrintSettingsProtoToIdl(print_job_info_proto.settings());
print_job_info.number_of_pages = print_job_info_proto.number_of_pages();
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/extensions/printing_metrics/print_job_info_idl_conversions.h"
#include "chrome/browser/chromeos/extensions/printing/printing_api.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace proto = chromeos::printing::proto;
......@@ -40,6 +41,8 @@ TEST(PrintJobInfoIdlConversionsTest, PrintJobInfoProtoToIdl) {
print_job_info_proto.set_status(proto::PrintJobInfo_PrintJobStatus_FAILED);
print_job_info_proto.set_creation_time(kJobCreationTime);
print_job_info_proto.set_completion_time(kJobCompletionTime);
print_job_info_proto.set_printer_error_code(
proto::PrintJobInfo_PrinterErrorCode_OUT_OF_PAPER);
proto::Printer printer_proto;
printer_proto.set_name(kName);
......@@ -85,6 +88,8 @@ TEST(PrintJobInfoIdlConversionsTest, PrintJobInfoProtoToIdl) {
EXPECT_EQ(kHeight, media_size.height);
EXPECT_EQ(kVendorId, media_size.vendor_id);
EXPECT_EQ(kPagesNumber, print_job_info.number_of_pages);
EXPECT_EQ(api::printing::PRINTER_STATUS_OUT_OF_PAPER,
print_job_info.printer_status);
}
} // namespace extensions
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/extensions/printing_metrics/printing_metrics_api.h"
#include "chrome/browser/chromeos/extensions/printing/printing_api.h"
#include "chrome/browser/chromeos/printing/history/mock_print_job_history_service.h"
#include "chrome/browser/chromeos/printing/history/print_job_history_service_factory.h"
#include "chrome/browser/chromeos/printing/history/print_job_info.pb.h"
......
......@@ -88,6 +88,33 @@ message PrintJobInfo {
PRINTED = 2;
}
// The error code of the printer. These enums are 1:1 with that of
// chrome/browser/chromeos/printing/printer_error_codes.h.
enum PrinterErrorCode {
// Printer has no error.
NO_ERROR = 0;
// The printer has a paper jam.
PAPER_JAM = 1;
// The printer is out of paper.
OUT_OF_PAPER = 2;
// The printer is out of it.
OUT_OF_INK = 3;
// The door of the printer is opened.
DOOR_OPEN = 4;
// The printer is unreachable and does not accept new print jobs.
PRINTER_UNREACHABLE = 5;
// The tray fo the printer is missing.
TRAY_MISSING = 6;
// The output area (e.g. tray) of the printer is full.
OUTPUT_FULL = 7;
// The printer is stopped and doesn't print.
STOPPED = 8;
// The printer pipeline has died.
FILTER_FAILED = 9;
// Generic unknown error.
UNKNOWN_ERROR = 10;
}
// The ID of the job.
string id = 1;
......@@ -117,4 +144,7 @@ message PrintJobInfo {
// The number of pages in the document.
int32 number_of_pages = 10;
// The error code from the printer.
PrinterErrorCode printer_error_code = 11;
}
......@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/printing/history/print_job_info_proto_conversions.h"
#include "base/optional.h"
#include "chrome/browser/chromeos/printing/printer_error_codes.h"
#include "printing/mojom/print.mojom.h"
namespace chromeos {
......@@ -90,6 +91,39 @@ proto::Printer_PrinterSource PrinterSourceToProto(
return proto::Printer_PrinterSource_USER;
}
proto::PrintJobInfo_PrinterErrorCode PrinterErrorCodeToProto(
PrinterErrorCode error_code) {
switch (error_code) {
case PrinterErrorCode::NO_ERROR:
return proto::PrintJobInfo_PrinterErrorCode_NO_ERROR;
case PrinterErrorCode::PAPER_JAM:
return proto::PrintJobInfo_PrinterErrorCode_PAPER_JAM;
case PrinterErrorCode::OUT_OF_PAPER:
return proto::PrintJobInfo_PrinterErrorCode_OUT_OF_PAPER;
case PrinterErrorCode::OUT_OF_INK:
return proto::PrintJobInfo_PrinterErrorCode_OUT_OF_INK;
case PrinterErrorCode::DOOR_OPEN:
return proto::PrintJobInfo_PrinterErrorCode_DOOR_OPEN;
case PrinterErrorCode::PRINTER_UNREACHABLE:
return proto::PrintJobInfo_PrinterErrorCode_PRINTER_UNREACHABLE;
case PrinterErrorCode::TRAY_MISSING:
return proto::PrintJobInfo_PrinterErrorCode_TRAY_MISSING;
case PrinterErrorCode::OUTPUT_FULL:
return proto::PrintJobInfo_PrinterErrorCode_OUTPUT_FULL;
case PrinterErrorCode::STOPPED:
return proto::PrintJobInfo_PrinterErrorCode_STOPPED;
case PrinterErrorCode::FILTER_FAILED:
return proto::PrintJobInfo_PrinterErrorCode_FILTER_FAILED;
case PrinterErrorCode::UNKNOWN_ERROR:
return proto::PrintJobInfo_PrinterErrorCode_UNKNOWN_ERROR;
default:
// Be sure to update the above case statements whenever a new printer
// error is introduced.
NOTREACHED();
}
return proto::PrintJobInfo_PrinterErrorCode_UNKNOWN_ERROR;
}
// Helper method to convert base::Time to the number of milliseconds past the
// Unix epoch. Loses precision beyond milliseconds.
int64_t TimeToMillisecondsPastUnixEpoch(const base::Time& time) {
......@@ -126,6 +160,8 @@ proto::PrintJobInfo CupsPrintJobToProto(const CupsPrintJob& print_job,
print_job_info_proto.set_source(PrintJobSourceToProto(print_job.source()));
print_job_info_proto.set_source_id(print_job.source_id());
print_job_info_proto.set_status(PrintJobStateToProto(print_job.state()));
print_job_info_proto.set_printer_error_code(
PrinterErrorCodeToProto(print_job.error_code()));
print_job_info_proto.set_creation_time(
TimeToMillisecondsPastUnixEpoch(print_job.creation_time()));
print_job_info_proto.set_completion_time(
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/printing/history/print_job_info_proto_conversions.h"
#include "base/time/time_override.h"
#include "chrome/browser/chromeos/printing/printer_error_codes.h"
#include "printing/mojom/print.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -75,6 +76,7 @@ TEST(PrintJobInfoProtoConversionsTest, CupsPrintJobToProto) {
::printing::PrintJob::Source::PRINT_PREVIEW,
kSourceId, settings);
cups_print_job.set_state(CupsPrintJob::State::STATE_FAILED);
cups_print_job.set_error_code(PrinterErrorCode::OUT_OF_PAPER);
base::Time completion_time =
base::Time::Now() + base::TimeDelta::FromSeconds(10);
......@@ -98,6 +100,8 @@ TEST(PrintJobInfoProtoConversionsTest, CupsPrintJobToProto) {
EXPECT_EQ(proto::PrintSettings_ColorMode_COLOR,
print_job_info_proto.settings().color());
EXPECT_EQ(kPagesNumber, print_job_info_proto.number_of_pages());
EXPECT_EQ(proto::PrintJobInfo_PrinterErrorCode_OUT_OF_PAPER,
print_job_info_proto.printer_error_code());
}
} // namespace chromeos
......@@ -33,22 +33,63 @@ mojom::PrintJobCompletionStatus PrintJobStatusProtoToMojom(
return mojom::PrintJobCompletionStatus::kFailed;
}
mojom::PrinterErrorCode PrinterErrorCodeProtoToMojom(
proto::PrintJobInfo_PrinterErrorCode printer_error_code_proto) {
switch (printer_error_code_proto) {
case proto::PrintJobInfo_PrinterErrorCode_NO_ERROR:
return mojom::PrinterErrorCode::kNoError;
case proto::PrintJobInfo_PrinterErrorCode_PAPER_JAM:
return mojom::PrinterErrorCode::kPaperJam;
case proto::PrintJobInfo_PrinterErrorCode_OUT_OF_PAPER:
return mojom::PrinterErrorCode::kOutOfPaper;
case proto::PrintJobInfo_PrinterErrorCode_OUT_OF_INK:
return mojom::PrinterErrorCode::kOutOfInk;
case proto::PrintJobInfo_PrinterErrorCode_DOOR_OPEN:
return mojom::PrinterErrorCode::kDoorOpen;
case proto::PrintJobInfo_PrinterErrorCode_PRINTER_UNREACHABLE:
return mojom::PrinterErrorCode::kPrinterUnreachable;
case proto::PrintJobInfo_PrinterErrorCode_TRAY_MISSING:
return mojom::PrinterErrorCode::kTrayMissing;
case proto::PrintJobInfo_PrinterErrorCode_OUTPUT_FULL:
return mojom::PrinterErrorCode::kOutputFull;
case proto::PrintJobInfo_PrinterErrorCode_STOPPED:
return mojom::PrinterErrorCode::kStopped;
case proto::PrintJobInfo_PrinterErrorCode_FILTER_FAILED:
return mojom::PrinterErrorCode::kFilterFailed;
case proto::PrintJobInfo_PrinterErrorCode_UNKNOWN_ERROR:
return mojom::PrinterErrorCode::kUnknownError;
case proto::
PrintJobInfo_PrinterErrorCode_PrintJobInfo_PrinterErrorCode_INT_MIN_SENTINEL_DO_NOT_USE_:
case proto::
PrintJobInfo_PrinterErrorCode_PrintJobInfo_PrinterErrorCode_INT_MAX_SENTINEL_DO_NOT_USE_:
NOTREACHED();
return mojom::PrinterErrorCode::kUnknownError;
}
return mojom::PrinterErrorCode::kUnknownError;
}
} // namespace
mojom::PrintJobInfoPtr PrintJobProtoToMojom(
const proto::PrintJobInfo& print_job_info_proto) {
mojom::PrintJobInfoPtr print_job_mojom = mojom::PrintJobInfo::New();
mojom::CompletedPrintJobInfoPtr completed_info_mojom =
mojom::CompletedPrintJobInfo::New();
completed_info_mojom->completion_status =
PrintJobStatusProtoToMojom(print_job_info_proto.status());
completed_info_mojom->printer_error_code =
PrinterErrorCodeProtoToMojom(print_job_info_proto.printer_error_code());
mojom::PrintJobInfoPtr print_job_mojom = mojom::PrintJobInfo::New();
print_job_mojom->id = print_job_info_proto.id();
print_job_mojom->title = base::UTF8ToUTF16(print_job_info_proto.title());
print_job_mojom->completion_status =
PrintJobStatusProtoToMojom(print_job_info_proto.status());
print_job_mojom->creation_time =
base::Time::FromJsTime(print_job_info_proto.creation_time());
print_job_mojom->number_of_pages = print_job_info_proto.number_of_pages();
print_job_mojom->printer_name =
base::UTF8ToUTF16(print_job_info_proto.printer().name());
print_job_mojom->printer_uri = GURL(print_job_info_proto.printer().uri());
print_job_mojom->completed_info = std::move(completed_info_mojom);
return print_job_mojom;
}
......
......@@ -37,6 +37,8 @@ proto::PrintJobInfo CreatePrintJobInfoProto() {
print_job_info.set_title(kTitle);
print_job_info.set_status(
printing::proto::PrintJobInfo_PrintJobStatus_PRINTED);
print_job_info.set_printer_error_code(
printing::proto::PrintJobInfo_PrinterErrorCode_NO_ERROR);
print_job_info.set_creation_time(
static_cast<int64_t>(base::Time::UnixEpoch().ToJsTime()));
print_job_info.set_number_of_pages(kPagesNumber);
......@@ -54,13 +56,15 @@ TEST(PrintJobInfoMojomConversionsTest, PrintJobProtoToMojom) {
EXPECT_EQ(kId, print_job_mojo->id);
EXPECT_EQ(base::UTF8ToUTF16(kTitle), print_job_mojo->title);
EXPECT_EQ(mojom::PrintJobCompletionStatus::kPrinted,
print_job_mojo->completion_status);
EXPECT_EQ(base::Time::FromJsTime(kJobCreationTime),
print_job_mojo->creation_time);
EXPECT_EQ(base::UTF8ToUTF16(kName), print_job_mojo->printer_name);
EXPECT_EQ(kUri, print_job_mojo->printer_uri.spec());
EXPECT_EQ(kPagesNumber, print_job_mojo->number_of_pages);
EXPECT_EQ(mojom::PrintJobCompletionStatus::kPrinted,
print_job_mojo->completed_info->completion_status);
EXPECT_EQ(mojom::PrinterErrorCode::kNoError,
print_job_mojo->completed_info->printer_error_code);
}
} // namespace chromeos
......@@ -4,11 +4,55 @@
#include "chrome/browser/chromeos/printing/printer_error_codes.h"
#include "chromeos/components/print_management/mojom/printing_manager.mojom.h"
#include "printing/backend/cups_jobs.h"
#include "printing/printer_status.h"
namespace chromeos {
namespace {
#ifndef STATIC_ASSERT_ENUM
#define STATIC_ASSERT_ENUM(a, b) \
static_assert(static_cast<int>(a) == static_cast<int>(b), \
"mismatching enums: " #a)
#endif
STATIC_ASSERT_ENUM(
PrinterErrorCode::NO_ERROR,
printing::printing_manager::mojom::PrinterErrorCode::kNoError);
STATIC_ASSERT_ENUM(
PrinterErrorCode::PAPER_JAM,
printing::printing_manager::mojom::PrinterErrorCode::kPaperJam);
STATIC_ASSERT_ENUM(
PrinterErrorCode::OUT_OF_PAPER,
printing::printing_manager::mojom::PrinterErrorCode::kOutOfPaper);
STATIC_ASSERT_ENUM(
PrinterErrorCode::OUT_OF_INK,
printing::printing_manager::mojom::PrinterErrorCode::kOutOfInk);
STATIC_ASSERT_ENUM(
PrinterErrorCode::DOOR_OPEN,
printing::printing_manager::mojom::PrinterErrorCode::kDoorOpen);
STATIC_ASSERT_ENUM(
PrinterErrorCode::PRINTER_UNREACHABLE,
printing::printing_manager::mojom::PrinterErrorCode::kPrinterUnreachable);
STATIC_ASSERT_ENUM(
PrinterErrorCode::TRAY_MISSING,
printing::printing_manager::mojom::PrinterErrorCode::kTrayMissing);
STATIC_ASSERT_ENUM(
PrinterErrorCode::OUTPUT_FULL,
printing::printing_manager::mojom::PrinterErrorCode::kOutputFull);
STATIC_ASSERT_ENUM(
PrinterErrorCode::STOPPED,
printing::printing_manager::mojom::PrinterErrorCode::kStopped);
STATIC_ASSERT_ENUM(
PrinterErrorCode::FILTER_FAILED,
printing::printing_manager::mojom::PrinterErrorCode::kFilterFailed);
STATIC_ASSERT_ENUM(
PrinterErrorCode::UNKNOWN_ERROR,
printing::printing_manager::mojom::PrinterErrorCode::kUnknownError);
} // namespace
using PrinterReason = ::printing::PrinterStatus::PrinterReason;
PrinterErrorCode PrinterErrorCodeFromPrinterStatusReasons(
......
......@@ -103,7 +103,6 @@ if (is_chromeos) {
"login_state.idl",
"platform_keys.idl",
"platform_keys_internal.idl",
"printing_metrics.idl",
"quick_unlock_private.idl",
"terminal_private.json",
"users_private.idl",
......@@ -111,7 +110,10 @@ if (is_chromeos) {
"wallpaper_private.json",
]
if (use_cups) {
schema_sources_ += [ "printing.idl" ]
schema_sources_ += [
"printing.idl",
"printing_metrics.idl",
]
}
} else if (is_linux || is_win) {
schema_sources_ += [ "input_ime.json" ]
......
......@@ -133,6 +133,9 @@ namespace printingMetrics {
// The number of pages in the document.
long numberOfPages;
// The status of the printer.
printing.PrinterStatus printer_status;
};
callback GetPrintJobsCallback = void(PrintJobInfo[] jobs);
......
......@@ -2141,8 +2141,6 @@ if (!is_android) {
"../browser/chromeos/extensions/login_screen/login_state/login_state_apitest.cc",
"../browser/chromeos/extensions/login_screen/login_state/session_state_changed_event_dispatcher_apitest.cc",
"../browser/chromeos/extensions/login_screen/storage_apitest.cc",
"../browser/chromeos/extensions/printing_metrics/print_job_finished_event_dispatcher_apitest.cc",
"../browser/chromeos/extensions/printing_metrics/printing_metrics_apitest.cc",
"../browser/chromeos/extensions/users_private/users_private_apitest.cc",
"../browser/chromeos/extensions/wallpaper_apitest.cc",
"../browser/chromeos/extensions/wallpaper_manager_browsertest.cc",
......@@ -2486,6 +2484,8 @@ if (!is_android) {
"../browser/chromeos/extensions/printing/fake_print_job_controller.cc",
"../browser/chromeos/extensions/printing/fake_print_job_controller.h",
"../browser/chromeos/extensions/printing/printing_apitest.cc",
"../browser/chromeos/extensions/printing_metrics/print_job_finished_event_dispatcher_apitest.cc",
"../browser/chromeos/extensions/printing_metrics/printing_metrics_apitest.cc",
]
deps += [ "//printing:test_support" ]
}
......
......@@ -49,10 +49,13 @@ function convertToMojoTime(jsDate) {
* @return {!Object}
*/
function createJobEntry(id, title, completionStatus, jsDate, printerName) {
let completedInfo = [];
completedInfo.completionStatus = completionStatus;
let jobEntry = {};
jobEntry.completedInfo = completedInfo;
jobEntry.id = id;
jobEntry.title = strToMojoString16(title);
jobEntry.completionStatus = completionStatus;
jobEntry.creationTime = {internalValue: convertToMojoTime(jsDate)};
jobEntry.printerName = strToMojoString16(printerName);
jobEntry.printerUri = {url: '192.168.1.1'};
......@@ -389,7 +392,7 @@ suite('PrintJobEntryTest', () => {
* @param {string} expectedStatus
*/
function updateAndVerifyCompletionStatus(element, newStatus, expectedStatus) {
element.set('jobEntry.completionStatus', newStatus);
element.set('jobEntry.completedInfo.completionStatus', newStatus);
assertEquals(
expectedStatus, element.$$('#completionStatus').textContent.trim());
}
......
......@@ -15,6 +15,35 @@ enum PrintJobCompletionStatus {
kPrinted
};
// Enumeration of all the possible printer error codes. The order of these enums
// must match that of chrome/browser/chromeos/printing/printer_error_codes.h
enum PrinterErrorCode {
kNoError,
kPaperJam,
kOutOfPaper,
kOutOfInk,
kDoorOpen,
kPrinterUnreachable,
kTrayMissing,
kOutputFull,
kStopped,
kFilterFailed,
kUnknownError,
};
// Contains information about a completed print job. Completed print jobs are
// stored to the local database. Information of this struct includes the
// completion status and error code associated with the print job. This struct
// is null for active print jobs, i.e. jobs that are currently being printed and
// are not stored in the local database.
struct CompletedPrintJobInfo {
// Corresponds to the status of the print job after it has completed.
PrintJobCompletionStatus completion_status;
// Corresponds to the error code reported by the printer.
PrinterErrorCode printer_error_code;
};
// Contains all the information in regards to a print job. Information is
// provided by the printer. Printer details, i.e. name and uri, can be edited
// via print settings.
......@@ -25,10 +54,6 @@ struct PrintJobInfo {
// Title of the print job. Usually the name of the printed file.
mojo_base.mojom.String16 title;
// Corresponds to the status of the print job after it the print job has
// finished.
PrintJobCompletionStatus completion_status;
// Time of when the print job was requested.
mojo_base.mojom.Time creation_time;
......@@ -40,6 +65,9 @@ struct PrintJobInfo {
// The URI of the printer the print job was requested to.
url.mojom.Url printer_uri;
// Information of a completed print job.
CompletedPrintJobInfo completed_info;
};
// Observer interface that sends remote updates to the print management app UI
......
......@@ -88,7 +88,8 @@ Polymer({
/** @private */
completionStatus_: {
type: String,
computed: 'convertStatusToString_(jobEntry.completionStatus)',
computed:
'convertStatusToString_(jobEntry.completedInfo.completionStatus)',
},
},
......
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