0

Remove usage of base::make_span(): printing/

Replace with span() CTAD use, or more targeted helpers.

Bug: 341907909
Change-Id: Ibab5dcf8b14a856b080f9f6600e2fd13f8ea69d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6058229
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1390699}
This commit is contained in:
Peter Kasting
2024-12-03 00:24:18 +00:00
committed by Chromium LUCI CQ
parent 1b9987f607
commit bc5c842764
6 changed files with 15 additions and 15 deletions

@ -71,8 +71,8 @@ TEST(EmfTest, DC) {
// Playback the data.
Emf emf;
// TODO(thestig): Make `data` uint8_t and avoid the base::as_bytes() call.
EXPECT_TRUE(emf.InitFromData(base::as_bytes(base::make_span(data))));
// TODO(thestig): Make `data` uint8_t and avoid the base::as_byte_span() call.
EXPECT_TRUE(emf.InitFromData(base::as_byte_span(data)));
HDC hdc = CreateCompatibleDC(nullptr);
EXPECT_TRUE(hdc);
RECT output_rect = {0, 0, 10, 10};
@ -110,7 +110,7 @@ TEST_F(EmfPrintingTest, Enumerate) {
ASSERT_TRUE(emf_data.size());
Emf emf;
EXPECT_TRUE(emf.InitFromData(base::as_bytes(base::make_span(emf_data))));
EXPECT_TRUE(emf.InitFromData(base::as_byte_span(emf_data)));
// This will print to file. The reason is that when running inside a
// unit_test, PrintingContext automatically dumps its files to the
@ -165,8 +165,8 @@ TEST_F(EmfPrintingTest, PageBreak) {
di.lpszDocName = L"Test Job";
int job_id = ::StartDoc(dc.Get(), &di);
Emf emf;
// TODO(thestig): Make `data` uint8_t and avoid the base::as_bytes() call.
EXPECT_TRUE(emf.InitFromData(base::as_bytes(base::make_span(data))));
// TODO(thestig): Make `data` uint8_t and avoid the base::as_byte_span() call.
EXPECT_TRUE(emf.InitFromData(base::as_byte_span(data)));
EXPECT_TRUE(emf.SafePlayback(dc.Get()));
::EndDoc(dc.Get());
// Since presumably the printer is not real, let us just delete the job from

@ -64,8 +64,7 @@ bool Metafile::SaveTo(base::File* file) const {
if (!GetDataAsVector(&buffer))
return false;
if (!file->WriteAtCurrentPosAndCheck(
base::as_bytes(base::make_span(buffer)))) {
if (!file->WriteAtCurrentPosAndCheck(base::as_byte_span(buffer))) {
DLOG(ERROR) << "Failed to save file.";
return false;
}

@ -379,8 +379,7 @@ bool MetafileSkia::SaveTo(base::File* file) const {
break;
}
DCHECK_GE(buffer.size(), read_size);
if (!file->WriteAtCurrentPosAndCheck(
base::make_span(&buffer[0], read_size))) {
if (!file->WriteAtCurrentPosAndCheck(base::span(&buffer[0], read_size))) {
return false;
} else if (is_at_end) {
break;

@ -56,8 +56,9 @@ std::unique_ptr<PdfMetafileCg> GetPdfMetafile(
// Initialize and check metafile.
auto pdf_cg = std::make_unique<PdfMetafileCg>();
if (!pdf_cg->InitFromData(base::as_bytes(base::make_span(pdf_data))))
if (!pdf_cg->InitFromData(base::as_byte_span(pdf_data))) {
return nullptr;
}
return pdf_cg;
}
@ -172,8 +173,9 @@ TEST(PdfMetafileCgTest, Pdf) {
// Test browser-side constructor.
PdfMetafileCg pdf2;
// TODO(thestig): Make `buffer` uint8_t and avoid the base::as_bytes() call.
EXPECT_TRUE(pdf2.InitFromData(base::as_bytes(base::make_span(buffer))));
// TODO(thestig): Make `buffer` uint8_t and avoid the base::as_byte_span()
// call.
EXPECT_TRUE(pdf2.InitFromData(base::as_byte_span(buffer)));
// Get the first 4 characters from pdf2.
std::vector<char> buffer2(4, 0);
@ -202,7 +204,7 @@ TEST(PdfMetafileCgTest, GetPageBounds) {
// Initialize and check metafile.
PdfMetafileCg pdf_cg;
ASSERT_TRUE(pdf_cg.InitFromData(base::as_bytes(base::make_span(pdf_data))));
ASSERT_TRUE(pdf_cg.InitFromData(base::as_byte_span(pdf_data)));
ASSERT_EQ(5u, pdf_cg.GetPageCount());
// Since the input into GetPageBounds() is a 1-indexed page number, 0 and 6

@ -87,7 +87,7 @@ base::span<const PpdColorSetting> GetKnownPpdColorSettings() {
{kCUPSXeroxXROutputColor, kPrintAsGrayscale, kPrintAsColor}, // Xerox
{kCUPSXeroxXRXColor, kXeroxBW, kXeroxAutomatic}, // Xerox
};
return base::make_span(kKnownPpdColorSettings);
return base::span(kKnownPpdColorSettings);
}
#endif

@ -238,7 +238,7 @@ TEST_F(PrintingContextTest, SettingsToIPPOptions_Collate) {
TEST_F(PrintingContextTest, SettingsToIPPOptions_Pin) {
EXPECT_FALSE(HasAttribute(kIppPin));
settings_.set_pin_value("1234");
TestOctetStringOptionValue(kIppPin, base::make_span("1234", 4u));
TestOctetStringOptionValue(kIppPin, base::span_from_cstring("1234"));
}
TEST_F(PrintingContextTest, SettingsToIPPOptions_Resolution) {