0

Migrate base::{size,empty,data} to STL equivalents in //content.

Bug: 1299695
Change-Id: Iefec40ecc9327c04732785eaed5a3214d17e552f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3491685
Reviewed-by: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975485}
This commit is contained in:
Daniel Cheng
2022-02-26 18:07:54 +00:00
committed by Chromium LUCI CQ
parent 7b7aaecca4
commit ad44af2f53
82 changed files with 214 additions and 276 deletions
content
app
app_shim_remote_cocoa
browser
accessibility
android
attribution_reporting
blob_storage
browser_child_process_host_impl.ccbrowser_main_loop.ccbrowser_url_handler_impl.cc
browsing_data
code_cache
devtools
download
file_system
file_system_access
font_unique_name_lookup
gpu
host_zoom_map_impl_unittest.cc
indexed_db
interest_group
launch_as_mojo_client_browsertest.cc
media
notifications
ppapi_plugin_process_host.cc
renderer_host
sandbox_ipc_linux.ccservice_process_host_browsertest.cc
service_worker
storage_partition_impl_unittest.ccutility_process_host.cc
web_package
webauth
webui
common
renderer
services
shell
test
web_test

@ -292,7 +292,7 @@ pid_t LaunchZygoteHelper(base::CommandLine* cmd_line,
switches::kVModule,
};
cmd_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kForwardSwitches, base::size(kForwardSwitches));
kForwardSwitches, std::size(kForwardSwitches));
GetContentClient()->browser()->AppendExtraCommandLineSwitches(cmd_line, -1);
@ -606,7 +606,7 @@ int NO_STACK_PROTECTOR RunZygote(ContentMainDelegate* delegate) {
mojo::core::InitFeatures();
for (size_t i = 0; i < base::size(kMainFunctions); ++i) {
for (size_t i = 0; i < std::size(kMainFunctions); ++i) {
if (process_type == kMainFunctions[i].name)
return kMainFunctions[i].function(std::move(main_params));
}
@ -673,7 +673,7 @@ RunOtherNamedProcessTypeMain(const std::string& process_type,
base::HangWatcher::GetInstance()->Start();
}
for (size_t i = 0; i < base::size(kMainFunctions); ++i) {
for (size_t i = 0; i < std::size(kMainFunctions); ++i) {
if (process_type == kMainFunctions[i].name) {
auto exit_code =
delegate->RunProcess(process_type, std::move(main_function_params));

@ -317,7 +317,7 @@ IN_PROC_BROWSER_TEST_F(
const NSSize window_offsets[] = {
{1.0, 0.0}, {-1.0, 0.0}, {0.0, 1.0}, {0.0, -1.0}};
NSRect window_b_frame = [window_b frame];
for (size_t i = 0; i < base::size(window_offsets); i++) {
for (size_t i = 0; i < std::size(window_offsets); i++) {
// Move window b so that it no longer completely covers
// window_a's webcontents.
NSRect offset_window_frame = NSOffsetRect(

@ -8,7 +8,6 @@
#include <atk/atkutil.h>
#include <atspi/atspi.h>
#include "base/cxx17_backports.h"
#include "base/no_destructor.h"
#include "base/process/process_handle.h"
#include "base/strings/stringprintf.h"
@ -294,7 +293,7 @@ void AccessibilityEventRecorderAuraLinux::AddATSPIEventListeners() {
atspi_event_listener_new(OnATSPIEventReceived, this, nullptr);
GError* error = nullptr;
for (size_t i = 0; i < base::size(kEventNames); i++) {
for (size_t i = 0; i < std::size(kEventNames); i++) {
atspi_event_listener_register(atspi_event_listener_, kEventNames[i],
&error);
if (error) {
@ -309,7 +308,7 @@ void AccessibilityEventRecorderAuraLinux::RemoveATSPIEventListeners() {
return;
GError* error = nullptr;
for (size_t i = 0; i < base::size(kEventNames); i++) {
for (size_t i = 0; i < std::size(kEventNames); i++) {
atspi_event_listener_deregister(atspi_event_listener_, kEventNames[i],
nullptr);
if (error) {

@ -8,7 +8,6 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
#include "base/strings/string_number_conversions.h"
@ -256,14 +255,14 @@ std::string AccessibilityTreeFormatterAndroid::ProcessTreeForOutput(
&line);
}
for (unsigned i = 0; i < base::size(BOOL_ATTRIBUTES); i++) {
for (unsigned i = 0; i < std::size(BOOL_ATTRIBUTES); i++) {
const char* attribute_name = BOOL_ATTRIBUTES[i];
absl::optional<bool> value = dict.FindBoolPath(attribute_name);
if (value && *value)
WriteAttribute(true, attribute_name, &line);
}
for (unsigned i = 0; i < base::size(STRING_ATTRIBUTES); i++) {
for (unsigned i = 0; i < std::size(STRING_ATTRIBUTES); i++) {
const char* attribute_name = STRING_ATTRIBUTES[i];
std::string value;
if (!dict.GetString(attribute_name, &value) || value.empty())
@ -272,7 +271,7 @@ std::string AccessibilityTreeFormatterAndroid::ProcessTreeForOutput(
&line);
}
for (unsigned i = 0; i < base::size(INT_ATTRIBUTES); i++) {
for (unsigned i = 0; i < std::size(INT_ATTRIBUTES); i++) {
const char* attribute_name = INT_ATTRIBUTES[i];
int value = dict.FindIntKey(attribute_name).value_or(0);
if (value == 0)
@ -280,7 +279,7 @@ std::string AccessibilityTreeFormatterAndroid::ProcessTreeForOutput(
WriteAttribute(true, StringPrintf("%s=%d", attribute_name, value), &line);
}
for (unsigned i = 0; i < base::size(ACTION_ATTRIBUTES); i++) {
for (unsigned i = 0; i < std::size(ACTION_ATTRIBUTES); i++) {
const char* attribute_name = ACTION_ATTRIBUTES[i];
absl::optional<bool> value = dict.FindBoolPath(attribute_name);
if (value && *value) {

@ -398,14 +398,14 @@ std::string AccessibilityTreeFormatterFuchsia::ProcessTreeForOutput(
node.GetString("role", &role_value);
WriteAttribute(true, role_value, &line);
for (unsigned i = 0; i < base::size(kBoolAttributes); i++) {
for (unsigned i = 0; i < std::size(kBoolAttributes); i++) {
const char* bool_attribute = kBoolAttributes[i];
absl::optional<bool> value = node.FindBoolPath(bool_attribute);
if (value && *value)
WriteAttribute(/*include_by_default=*/true, bool_attribute, &line);
}
for (unsigned i = 0; i < base::size(kStringAttributes); i++) {
for (unsigned i = 0; i < std::size(kStringAttributes); i++) {
const char* string_attribute = kStringAttributes[i];
std::string value;
if (!node.GetString(string_attribute, &value) || value.empty())
@ -416,7 +416,7 @@ std::string AccessibilityTreeFormatterFuchsia::ProcessTreeForOutput(
base::StringPrintf("%s='%s'", string_attribute, value.c_str()), &line);
}
for (unsigned i = 0; i < base::size(kIntAttributes); i++) {
for (unsigned i = 0; i < std::size(kIntAttributes); i++) {
const char* attribute_name = kIntAttributes[i];
int value = node.FindIntKey(attribute_name).value_or(0);
if (value == 0)
@ -425,7 +425,7 @@ std::string AccessibilityTreeFormatterFuchsia::ProcessTreeForOutput(
&line);
}
for (unsigned i = 0; i < base::size(kDoubleAttributes); i++) {
for (unsigned i = 0; i < std::size(kDoubleAttributes); i++) {
const char* attribute_name = kDoubleAttributes[i];
int value = node.FindIntKey(attribute_name).value_or(0);
if (value == 0)

@ -11,7 +11,6 @@
#include <memory>
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
@ -204,7 +203,7 @@ void BrowserAccessibilityStateImplWin::UpdateHistogramsOnOtherThread() {
bool satogo = false; // Very few users -- do not need uniques
for (size_t i = 0; i < module_count; i++) {
TCHAR filename[MAX_PATH];
GetModuleFileName(modules[i], filename, base::size(filename));
GetModuleFileName(modules[i], filename, std::size(filename));
std::string module_name(base::FilePath(filename).BaseName().AsUTF8Unsafe());
if (base::LowerCaseEqualsASCII(module_name, "fsdomsrv.dll"))
g_jaws = true;

@ -8,7 +8,6 @@
#include <memory>
#include "base/cxx17_backports.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
@ -38,7 +37,7 @@ TEST_F(JavaTypeTest, ScalarTypes) {
"Ljava/lang/Object;"},
{"my.nested.Type$Foo", JavaType::TypeObject, "my/nested/Type$Foo",
"Lmy/nested/Type$Foo;"}};
for (size_t i = 0; i < base::size(scalar_types); ++i) {
for (size_t i = 0; i < std::size(scalar_types); ++i) {
JavaType jt = JavaType::CreateFromBinaryName(scalar_types[i].binary_type);
EXPECT_EQ(scalar_types[i].java_type, jt.type);
EXPECT_FALSE(jt.inner_type);

@ -7,11 +7,9 @@
// /third_party/blink/public/common/messaging/message_port_descriptor.h.
#include "third_party/blink/public/common/messaging/message_port_descriptor.h"
#include "base/android/jni_android.h"
#include "base/android/jni_array.h"
#include "base/android/scoped_java_ref.h"
#include "base/cxx17_backports.h"
#include "base/unguessable_token.h"
#include "content/public/android/content_jni_headers/AppWebMessagePortDescriptor_jni.h"
#include "mojo/public/cpp/system/message_pipe.h"
@ -43,7 +41,7 @@ JNI_AppWebMessagePortDescriptor_CreatePair(JNIEnv* env) {
uint64_t pointers[2] = {reinterpret_cast<uint64_t>(port0),
reinterpret_cast<uint64_t>(port1)};
return base::android::ToJavaLongArray(
env, reinterpret_cast<const int64_t*>(pointers), base::size(pointers));
env, reinterpret_cast<const int64_t*>(pointers), std::size(pointers));
}
JNI_EXPORT jlong JNI_AppWebMessagePortDescriptor_Create(JNIEnv* env,
@ -134,8 +132,7 @@ JNI_AppWebMessagePortDescriptor_PassSerialized(
id.GetLowForSerialization(),
id.GetHighForSerialization(), sequence_number};
return base::android::ToJavaLongArray(
env, reinterpret_cast<const int64_t*>(serialized),
base::size(serialized));
env, reinterpret_cast<const int64_t*>(serialized), std::size(serialized));
}
JNI_EXPORT void JNI_AppWebMessagePortDescriptor_CloseAndDestroy(
@ -171,4 +168,4 @@ JNI_EXPORT void JNI_AppWebMessagePortDescriptor_DisentangleCloseAndDestroy(
// Reset it and finally delete the object.
message_port_descriptor->Reset();
delete message_port_descriptor;
}
}

@ -10,7 +10,6 @@
#include "base/check.h"
#include "base/check_op.h"
#include "base/cxx17_backports.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
@ -242,7 +241,7 @@ std::string AttributionReport::PrivacyBudgetKey() const {
ctx->Update(kVersion, sizeof(kVersion));
std::string output(crypto::kSHA256Length, 0);
ctx->Finish(base::data(output), output.size());
ctx->Finish(std::data(output), output.size());
return output;
}

@ -8,7 +8,6 @@
#include <memory>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@ -136,12 +135,12 @@ class BlobURLTest : public testing::Test {
const char kFilename1[] = "FileSystemFile1.dat";
temp_file_system_file1_ = GetFileSystemURL(kFilename1);
WriteFileSystemFile(kFilename1, kTestFileSystemFileData1,
base::size(kTestFileSystemFileData1) - 1,
std::size(kTestFileSystemFileData1) - 1,
&temp_file_system_file_modification_time1_);
const char kFilename2[] = "FileSystemFile2.dat";
temp_file_system_file2_ = GetFileSystemURL(kFilename2);
WriteFileSystemFile(kFilename2, kTestFileSystemFileData2,
base::size(kTestFileSystemFileData2) - 1,
std::size(kTestFileSystemFileData2) - 1,
&temp_file_system_file_modification_time2_);
}
@ -355,13 +354,13 @@ class BlobURLTest : public testing::Test {
TEST_F(BlobURLTest, TestGetSimpleDataRequest) {
blob_data_->AppendData(kTestData1);
TestSuccessNonrangeRequest(kTestData1, base::size(kTestData1) - 1);
TestSuccessNonrangeRequest(kTestData1, std::size(kTestData1) - 1);
}
TEST_F(BlobURLTest, TestGetSimpleFileRequest) {
blob_data_->AppendFile(temp_file1_, 0, std::numeric_limits<uint64_t>::max(),
base::Time());
TestSuccessNonrangeRequest(kTestFileData1, base::size(kTestFileData1) - 1);
TestSuccessNonrangeRequest(kTestFileData1, std::size(kTestFileData1) - 1);
}
TEST_F(BlobURLTest, TestGetLargeFileRequest) {
@ -405,7 +404,7 @@ TEST_F(BlobURLTest, TestGetSimpleFileSystemFileRequest) {
0, std::numeric_limits<uint64_t>::max(), base::Time(),
file_system_context_);
TestSuccessNonrangeRequest(kTestFileSystemFileData1,
base::size(kTestFileSystemFileData1) - 1);
std::size(kTestFileSystemFileData1) - 1);
}
TEST_F(BlobURLTest, TestGetLargeFileSystemFileRequest) {
@ -470,7 +469,7 @@ TEST_F(BlobURLTest, TestGetSimpleDataHandleRequest) {
base::MakeRefCounted<storage::FakeBlobDataHandle>(kTestDataHandleData1,
""));
TestSuccessNonrangeRequest(kTestDataHandleData1,
base::size(kTestDataHandleData1) - 1);
std::size(kTestDataHandleData1) - 1);
}
TEST_F(BlobURLTest, TestGetComplicatedDataFileAndDiskCacheRequest) {
@ -570,7 +569,7 @@ TEST_F(BlobURLTest, TestSideData) {
expected_status_code_ = 200;
expected_response_ = kTestDataHandleData2;
TestRequest("GET", net::HttpRequestHeaders());
EXPECT_EQ(static_cast<int>(base::size(kTestDataHandleData2) - 1),
EXPECT_EQ(static_cast<int>(std::size(kTestDataHandleData2) - 1),
response_headers_->GetContentLength());
EXPECT_EQ(std::string(kTestDiskCacheSideData), response_metadata_);
@ -583,7 +582,7 @@ TEST_F(BlobURLTest, TestZeroSizeSideData) {
expected_status_code_ = 200;
expected_response_ = kTestDataHandleData2;
TestRequest("GET", net::HttpRequestHeaders());
EXPECT_EQ(static_cast<int>(base::size(kTestDataHandleData2) - 1),
EXPECT_EQ(static_cast<int>(std::size(kTestDataHandleData2) - 1),
response_headers_->GetContentLength());
EXPECT_TRUE(response_metadata_.empty());

@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/clang_profiling_buildflags.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/debug/dump_without_crashing.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
@ -303,7 +302,7 @@ void BrowserChildProcessHostImpl::LaunchWithoutExtraCommandLineSwitches(
switches::kVModule,
};
cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
base::size(kForwardSwitches));
std::size(kForwardSwitches));
// All processes should have a non-empty metrics name.
if (data_.metrics_name.empty())

@ -16,7 +16,6 @@
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/location.h"
#include "base/logging.h"
@ -284,7 +283,7 @@ static void SetUpGLibLogHandler() {
// Register GLib-handled assertions to go through our logging system.
const char* const kLogDomains[] = {nullptr, "Gtk", "Gdk", "GLib",
"GLib-GObject"};
for (size_t i = 0; i < base::size(kLogDomains); i++) {
for (size_t i = 0; i < std::size(kLogDomains); i++) {
g_log_set_handler(
kLogDomains[i],
static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL |

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "content/browser/renderer_host/debug_urls.h"
@ -39,7 +38,7 @@ static bool HandleViewSource(GURL* url, BrowserContext* browser_context) {
// Merge all the schemes for which view-source is allowed by default, with
// the view-source schemes defined by the ContentBrowserClient.
std::vector<std::string> all_allowed_sub_schemes;
for (size_t i = 0; i < base::size(default_allowed_sub_schemes); ++i)
for (size_t i = 0; i < std::size(default_allowed_sub_schemes); ++i)
all_allowed_sub_schemes.push_back(default_allowed_sub_schemes[i]);
GetContentClient()->browser()->GetAdditionalViewSourceSchemes(
&all_allowed_sub_schemes);

@ -479,7 +479,7 @@ TEST_F(ClearSiteDataHandlerTest, FormattedConsoleOutput) {
// |NetworkServiceClient| creates a new |ClearSiteDataHandler| for each
// navigation, redirect, or subresource header responses.
for (size_t i = 0; i < base::size(kTestCases); i++) {
for (size_t i = 0; i < std::size(kTestCases); i++) {
TestHandler handler(
base::BindRepeating(&FakeBrowserContextGetter),
base::BindRepeating(&FakeWebContentsGetter), GURL(kTestCases[i].url),

@ -195,7 +195,7 @@ bool GeneratedCodeCache::IsValidHeader(
}
std::string GeneratedCodeCache::GetResourceURLFromKey(const std::string& key) {
constexpr size_t kPrefixStringLen = base::size(kPrefix) - 1;
constexpr size_t kPrefixStringLen = std::size(kPrefix) - 1;
// |key| may not have a prefix and separator (e.g. for deduplicated entries).
// In that case, return an empty string.
const size_t separator_index = key.find(kSeparator);
@ -404,8 +404,8 @@ void GeneratedCodeCache::WriteEntry(const GURL& url,
uint8_t result[crypto::kSHA256Length];
crypto::SHA256HashString(
base::StringPiece(reinterpret_cast<char*>(copy.data()), copy.size()),
result, base::size(result));
std::string checksum_key = base::HexEncode(result, base::size(result));
result, std::size(result));
std::string checksum_key = base::HexEncode(result, std::size(result));
small_buffer = base::MakeRefCounted<net::IOBufferWithSize>(
kHeaderSizeInBytes + kSHAKeySizeInBytes);
// Copy |checksum_key| into the small buffer.

@ -5,7 +5,6 @@
#include "content/browser/devtools/devtools_io_context.h"
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
@ -67,7 +66,7 @@ bool DevToolsIOContext::IsTextMimeType(const std::string& mime_type) {
static const char* kTextMIMETypePrefixes[] = {
"text/", "application/x-javascript", "application/json",
"application/xml"};
for (size_t i = 0; i < base::size(kTextMIMETypePrefixes); ++i) {
for (size_t i = 0; i < std::size(kTextMIMETypePrefixes); ++i) {
if (base::StartsWith(mime_type, kTextMIMETypePrefixes[i],
base::CompareCase::INSENSITIVE_ASCII))
return true;

@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/download/save_package.h"
#include <stddef.h>
#include <stdint.h>
#include <string>
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
@ -15,7 +16,6 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/browser/download/save_file_manager.h"
#include "content/browser/download/save_package.h"
#include "content/public/browser/browser_context.h"
#include "content/public/common/url_constants.h"
#include "content/test/test_render_view_host.h"
@ -187,7 +187,7 @@ static const struct {
};
TEST_F(SavePackageTest, TestSuccessfullyGenerateSavePackageFilename) {
for (size_t i = 0; i < base::size(kGeneratedFiles); ++i) {
for (size_t i = 0; i < std::size(kGeneratedFiles); ++i) {
base::FilePath::StringType file_name;
bool ok = GetGeneratedFilename(true,
kGeneratedFiles[i].disposition,
@ -200,7 +200,7 @@ TEST_F(SavePackageTest, TestSuccessfullyGenerateSavePackageFilename) {
}
TEST_F(SavePackageTest, TestUnSuccessfullyGenerateSavePackageFilename) {
for (size_t i = 0; i < base::size(kGeneratedFiles); ++i) {
for (size_t i = 0; i < std::size(kGeneratedFiles); ++i) {
base::FilePath::StringType file_name;
bool ok = GetGeneratedFilename(false,
kGeneratedFiles[i].disposition,

@ -685,7 +685,7 @@ IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, AutoMountNoHandler) {
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileTest) {
base::ScopedAllowBlockingForTesting allow_blocking;
WriteFile("file1.dat", kTestFileData, base::size(kTestFileData) - 1);
WriteFile("file1.dat", kTestFileData, std::size(kTestFileData) - 1);
auto client = TestLoad(CreateFileSystemURL("file1.dat"));
EXPECT_TRUE(client->has_received_response());
@ -707,7 +707,7 @@ IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, CrossOriginFileBlocked) {
IsolateAllSitesForTesting(base::CommandLine::ForCurrentProcess());
base::ScopedAllowBlockingForTesting allow_blocking;
WriteFile("file1.dat", kTestFileData, base::size(kTestFileData) - 1);
WriteFile("file1.dat", kTestFileData, std::size(kTestFileData) - 1);
// Navigate main frame to foo.com.
ASSERT_TRUE(embedded_test_server()->Start());
@ -781,7 +781,7 @@ IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
FileTestMultipleRangesNotSupported) {
base::ScopedAllowBlockingForTesting allow_blocking;
WriteFile("file1.dat", kTestFileData, base::size(kTestFileData) - 1);
WriteFile("file1.dat", kTestFileData, std::size(kTestFileData) - 1);
net::HttpRequestHeaders headers;
headers.SetHeader(net::HttpRequestHeaders::kRange,
"bytes=0-5,10-200,200-300");
@ -794,7 +794,7 @@ IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest,
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileRangeOutOfBounds) {
base::ScopedAllowBlockingForTesting allow_blocking;
WriteFile("file1.dat", kTestFileData, base::size(kTestFileData) - 1);
WriteFile("file1.dat", kTestFileData, std::size(kTestFileData) - 1);
net::HttpRequestHeaders headers;
headers.SetHeader(net::HttpRequestHeaders::kRange,
net::HttpByteRange::Bounded(500, 1000).GetHeaderValue());
@ -838,7 +838,7 @@ IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, NoSuchFile) {
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileCancel) {
base::ScopedAllowBlockingForTesting allow_blocking;
WriteFile("file1.dat", kTestFileData, base::size(kTestFileData) - 1);
WriteFile("file1.dat", kTestFileData, std::size(kTestFileData) - 1);
auto client = TestLoadNoRun(CreateFileSystemURL("file1.dat"));
// client.reset();
@ -872,7 +872,7 @@ IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileGetMimeType) {
IN_PROC_BROWSER_TEST_P(FileSystemURLLoaderFactoryTest, FileIncognito) {
base::ScopedAllowBlockingForTesting allow_blocking;
WriteFile("file", kTestFileData, base::size(kTestFileData) - 1);
WriteFile("file", kTestFileData, std::size(kTestFileData) - 1);
// Creates a new filesystem context for incognito mode.
scoped_refptr<FileSystemContext> file_system_context =

@ -99,7 +99,7 @@ class HashCalculator : public base::RefCounted<HashCalculator> {
}
if (bytes_read == 0) {
std::string hash_str(hash_->GetHashLength(), 0);
hash_->Finish(base::data(hash_str), hash_str.size());
hash_->Finish(std::data(hash_str), hash_str.size());
std::move(callback_).Run(base::File::FILE_OK, hash_str, file_size_);
return;
}

@ -4,7 +4,6 @@
#include <memory>
#include "base/cxx17_backports.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
@ -157,7 +156,7 @@ IN_PROC_BROWSER_TEST_F(FontUniqueNameBrowserTest,
unsigned num_added_nodes = static_cast<unsigned>(
content::EvalJs(shell(), "addTestNodes()").ExtractInt());
ASSERT_EQ(num_added_nodes, base::size(kExpectedFontFamilyNames));
ASSERT_EQ(num_added_nodes, std::size(kExpectedFontFamilyNames));
std::unique_ptr<base::DictionaryValue> params =
std::make_unique<base::DictionaryValue>();
@ -177,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(FontUniqueNameBrowserTest,
result->FindKeyOfType("nodeIds", base::Value::Type::LIST)->Clone();
base::Value::ConstListView nodes_view = node_list.GetListDeprecated();
ASSERT_EQ(nodes_view.size(), num_added_nodes);
ASSERT_EQ(nodes_view.size(), base::size(kExpectedFontFamilyNames));
ASSERT_EQ(nodes_view.size(), std::size(kExpectedFontFamilyNames));
for (size_t i = 0; i < nodes_view.size(); ++i) {
const base::Value& nodeId = nodes_view[i];
params = std::make_unique<base::DictionaryValue>();

@ -2,21 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/gtest/include/gtest/gtest.h"
#include "content/browser/font_unique_name_lookup/font_unique_name_lookup.h"
#include <functional>
#include <memory>
#include "base/android/build_info.h"
#include "base/cxx17_backports.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/strings/string_util.h"
#include "content/browser/font_unique_name_lookup/font_unique_name_lookup.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/font_unique_name_lookup/font_table_matcher.h"
#include <functional>
#include <memory>
namespace {
static const char* const kAndroidFontPaths[] = {"/system/fonts",
@ -231,7 +230,7 @@ size_t GetNumTables(base::File& font_file) {
font_file.Seek(base::File::FROM_BEGIN, 5);
uint8_t num_tables_bytes[2] = {};
font_file.ReadAtCurrentPos(reinterpret_cast<char*>(num_tables_bytes),
base::size(num_tables_bytes));
std::size(num_tables_bytes));
uint16_t num_tables =
static_cast<uint16_t>(num_tables_bytes[0] + (num_tables_bytes[1] << 8));
return num_tables;
@ -265,7 +264,7 @@ class FontFileCorruptor {
for (size_t i = 0; i < num_tables; ++i) {
CHECK_EQ(static_cast<int>(kSizeOneTableRecord),
font_file.Write(kOffsetTableRecords + i * kSizeOneTableRecord,
garbage, base::size(garbage)));
garbage, std::size(garbage)));
}
});
}

@ -221,8 +221,8 @@ const GpuFeatureData GetGpuFeatureData(
{"direct_rendering_display_compositor", gpu::kGpuFeatureStatusEnabled,
!features::IsDrDcEnabled(), DisableInfo::NotProblem(), false},
};
DCHECK(index < base::size(kGpuFeatureData));
*eof = (index == base::size(kGpuFeatureData) - 1);
DCHECK(index < std::size(kGpuFeatureData));
*eof = (index == std::size(kGpuFeatureData) - 1);
return kGpuFeatureData[index];
}

@ -19,8 +19,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
{
1, // id
"GpuDataManagerImplPrivateTest.GpuSideBlocklisting.0",
base::size(kFeatureListForGpuManagerTestingEntry1), // features size
kFeatureListForGpuManagerTestingEntry1, // features
std::size(kFeatureListForGpuManagerTestingEntry1), // features size
kFeatureListForGpuManagerTestingEntry1, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size
@ -53,8 +53,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
{
2, // id
"GpuDataManagerImplPrivateTest.GpuSideBlocklisting.1",
base::size(kFeatureListForGpuManagerTestingEntry2), // features size
kFeatureListForGpuManagerTestingEntry2, // features
std::size(kFeatureListForGpuManagerTestingEntry2), // features size
kFeatureListForGpuManagerTestingEntry2, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size
@ -87,8 +87,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
{
3, // id
"GpuDataManagerImplPrivateTest.GpuSideBlocklistingWebGL.0",
base::size(kFeatureListForGpuManagerTestingEntry3), // features size
kFeatureListForGpuManagerTestingEntry3, // features
std::size(kFeatureListForGpuManagerTestingEntry3), // features size
kFeatureListForGpuManagerTestingEntry3, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size
@ -121,8 +121,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
{
4, // id
"GpuDataManagerImplPrivateTest.GpuSideBlocklistingWebGL.1",
base::size(kFeatureListForGpuManagerTestingEntry4), // features size
kFeatureListForGpuManagerTestingEntry4, // features
std::size(kFeatureListForGpuManagerTestingEntry4), // features size
kFeatureListForGpuManagerTestingEntry4, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size
@ -155,8 +155,8 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
{
5, // id
"GpuDataManagerImplPrivateTest.GpuSideException",
base::size(kFeatureListForGpuManagerTestingEntry5), // features size
kFeatureListForGpuManagerTestingEntry5, // features
std::size(kFeatureListForGpuManagerTestingEntry5), // features size
kFeatureListForGpuManagerTestingEntry5, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size
@ -183,14 +183,14 @@ const GpuControlList::Entry kGpuDataManagerTestingEntries[] = {
nullptr}, // intel_gpu_generation
&kMoreForEntry5_572251052, // more data
},
base::size(kExceptionsForEntry5), // exceptions count
kExceptionsForEntry5, // exceptions
std::size(kExceptionsForEntry5), // exceptions count
kExceptionsForEntry5, // exceptions
},
{
6, // id
"GpuDataManagerImplPrivateTest.BlocklistAllFeatures",
base::size(kFeatureListForGpuManagerTestingEntry6), // features size
kFeatureListForGpuManagerTestingEntry6, // features
std::size(kFeatureListForGpuManagerTestingEntry6), // features size
kFeatureListForGpuManagerTestingEntry6, // features
0, // DisabledExtensions size
nullptr, // DisabledExtensions
0, // DisabledWebGLExtensions size

@ -619,7 +619,7 @@ void GpuProcessHost::GetHasGpuProcess(base::OnceCallback<void(bool)> callback) {
return;
}
bool has_gpu = false;
for (size_t i = 0; i < base::size(g_gpu_process_hosts); ++i) {
for (size_t i = 0; i < std::size(g_gpu_process_hosts); ++i) {
GpuProcessHost* host = g_gpu_process_hosts[i];
if (host && ValidateHost(host)) {
has_gpu = true;
@ -1198,7 +1198,7 @@ bool GpuProcessHost::LaunchGpuProcess() {
// If you want a browser command-line switch passed to the GPU process
// you need to add it to |kSwitchNames| at the beginning of this file.
cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
base::size(kSwitchNames));
std::size(kSwitchNames));
cmd_line->CopySwitchesFrom(
browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost,
switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches);

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/memory/ref_counted.h"
#include "base/test/simple_test_clock.h"
#include "content/public/test/browser_task_environment.h"
@ -72,8 +71,8 @@ TEST_F(HostZoomMapTest, GetAllZoomLevels) {
zoomed},
{HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST, "zoomed.com", "https",
zoomed}, };
ASSERT_EQ(base::size(expected), levels.size());
for (size_t i = 0; i < base::size(expected); ++i) {
ASSERT_EQ(std::size(expected), levels.size());
for (size_t i = 0; i < std::size(expected); ++i) {
SCOPED_TRACE(testing::Message() << "levels[" << i << "]");
EXPECT_EQ(expected[i].mode, levels[i].mode);
EXPECT_EQ(expected[i].scheme, levels[i].scheme);
@ -108,8 +107,8 @@ TEST_F(HostZoomMapTest, LastModifiedTimestamp) {
{HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST, "login", "chrome", 3.0,
base::Time()},
};
ASSERT_EQ(base::size(expected), levels.size());
for (size_t i = 0; i < base::size(expected); ++i) {
ASSERT_EQ(std::size(expected), levels.size());
for (size_t i = 0; i < std::size(expected); ++i) {
SCOPED_TRACE(testing::Message() << "levels[" << i << "]");
EXPECT_EQ(expected[i].mode, levels[i].mode);
EXPECT_EQ(expected[i].scheme, levels[i].scheme);

@ -16,7 +16,6 @@
#include "base/callback.h"
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/cxx17_backports.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/guid.h"
@ -1009,7 +1008,7 @@ TEST_P(IndexedDBBackingStoreTestWithExternalObjects, DeleteRange) {
IndexedDBKeyRange(keys[1], keys[3], false, true),
IndexedDBKeyRange(keys[0], keys[3], true, true)};
for (size_t i = 0; i < base::size(ranges); ++i) {
for (size_t i = 0; i < std::size(ranges); ++i) {
const int64_t database_id = 1;
const int64_t object_store_id = i + 1;
const IndexedDBKeyRange& range = ranges[i];
@ -1104,7 +1103,7 @@ TEST_P(IndexedDBBackingStoreTestWithExternalObjects, DeleteRangeEmptyRange) {
IndexedDBKeyRange(keys[2], keys[1], false, false),
IndexedDBKeyRange(keys[2], keys[1], true, true)};
for (size_t i = 0; i < base::size(ranges); ++i) {
for (size_t i = 0; i < std::size(ranges); ++i) {
const int64_t database_id = 1;
const int64_t object_store_id = i + 1;
const IndexedDBKeyRange& range = ranges[i];

@ -12,7 +12,6 @@
#include <utility>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/strings/string_piece.h"
#include "components/services/storage/indexed_db/scopes/varint_coding.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -557,7 +556,7 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKeyPath) {
0 // Type is null
};
encoded_paths.push_back(
std::string(expected, expected + base::size(expected)));
std::string(expected, expected + std::size(expected)));
}
{
@ -567,7 +566,7 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKeyPath) {
0 // Length is 0
};
encoded_paths.push_back(
std::string(expected, expected + base::size(expected)));
std::string(expected, expected + std::size(expected)));
}
{
@ -577,7 +576,7 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKeyPath) {
3, 0, 'f', 0, 'o', 0, 'o' // String length 3, UTF-16BE
};
encoded_paths.push_back(
std::string(expected, expected + base::size(expected)));
std::string(expected, expected + std::size(expected)));
}
{
@ -588,7 +587,7 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKeyPath) {
'r' // String length 7, UTF-16BE
};
encoded_paths.push_back(
std::string(expected, expected + base::size(expected)));
std::string(expected, expected + std::size(expected)));
}
{
@ -603,7 +602,7 @@ TEST(IndexedDBLevelDBCodingTest, EncodeDecodeIDBKeyPath) {
'r' // Member 3 (String length 7)
};
encoded_paths.push_back(
std::string(expected, expected + base::size(expected)));
std::string(expected, expected + std::size(expected)));
}
ASSERT_EQ(key_paths.size(), encoded_paths.size());
@ -685,12 +684,12 @@ TEST(IndexedDBLevelDBCodingTest, DecodeLegacyIDBKeyPath) {
{
key_paths.emplace_back(u"foo");
char expected[] = {0, 'f', 0, 'o', 0, 'o'};
encoded_paths.push_back(std::string(expected, base::size(expected)));
encoded_paths.push_back(std::string(expected, std::size(expected)));
}
{
key_paths.emplace_back(u"foo.bar");
char expected[] = {0, 'f', 0, 'o', 0, 'o', 0, '.', 0, 'b', 0, 'a', 0, 'r'};
encoded_paths.push_back(std::string(expected, base::size(expected)));
encoded_paths.push_back(std::string(expected, std::size(expected)));
}
ASSERT_EQ(key_paths.size(), encoded_paths.size());

@ -137,7 +137,7 @@ std::string ReadCorruptionInfo(storage::FilesystemProxy* filesystem_proxy,
if (file.IsValid()) {
std::string input_js(file_info->size, '\0');
if (file_info->size ==
file.Read(0, base::data(input_js), file_info->size)) {
file.Read(0, std::data(input_js), file_info->size)) {
absl::optional<base::Value> val = base::JSONReader::Read(input_js);
if (val && val->is_dict()) {
std::string* s = val->FindStringKey("message");

@ -12,7 +12,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
@ -1301,7 +1300,7 @@ TEST_F(AuctionWorkletManagerTest, BidderWorkletUrlRequestProtection) {
"application/json"},
};
for (size_t i = 0; i < base::size(kAllowedUrls); ++i) {
for (size_t i = 0; i < std::size(kAllowedUrls); ++i) {
network::ResourceRequest request;
request.url = kAllowedUrls[i].url;
request.headers.SetHeader(net::HttpRequestHeaders::kAccept,
@ -1332,7 +1331,7 @@ TEST_F(AuctionWorkletManagerTest, BidderWorkletUrlRequestProtection) {
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
bidder_worklet->url_loader_factory().FlushForTesting();
EXPECT_FALSE(bidder_worklet->url_loader_factory().is_connected());
EXPECT_EQ(base::size(kAllowedUrls),
EXPECT_EQ(std::size(kAllowedUrls),
url_loader_factory_.pending_requests()->size());
EXPECT_EQ("Unexpected request", TakeBadMessage());
}
@ -1361,7 +1360,7 @@ TEST_F(AuctionWorkletManagerTest, SellerWorkletUrlRequestProtection) {
"application/json"},
};
for (size_t i = 0; i < base::size(kAllowedUrls); ++i) {
for (size_t i = 0; i < std::size(kAllowedUrls); ++i) {
network::ResourceRequest request;
request.url = kAllowedUrls[i].url;
request.headers.SetHeader(net::HttpRequestHeaders::kAccept,
@ -1392,7 +1391,7 @@ TEST_F(AuctionWorkletManagerTest, SellerWorkletUrlRequestProtection) {
net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
seller_worklet->url_loader_factory().FlushForTesting();
EXPECT_FALSE(seller_worklet->url_loader_factory().is_connected());
EXPECT_EQ(base::size(kAllowedUrls),
EXPECT_EQ(std::size(kAllowedUrls),
url_loader_factory_.pending_requests()->size());
EXPECT_EQ("Unexpected request", TakeBadMessage());
}

@ -72,7 +72,7 @@ class LaunchAsMojoClientBrowserTest : public ContentBrowserTest {
switches::kOzonePlatform,
};
command_line.CopySwitchesFrom(cmdline, kSwitchesToCopy,
base::size(kSwitchesToCopy));
std::size(kSwitchesToCopy));
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)

@ -6,7 +6,6 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/location.h"
#include "base/no_destructor.h"
#include "base/time/time.h"
@ -22,9 +21,9 @@ const int kApprovedStreamTimeToLiveSeconds = 10;
std::string GenerateRandomStreamId() {
char buffer[kStreamIdLengthBytes];
crypto::RandBytes(buffer, base::size(buffer));
crypto::RandBytes(buffer, std::size(buffer));
std::string result;
base::Base64Encode(base::StringPiece(buffer, base::size(buffer)), &result);
base::Base64Encode(base::StringPiece(buffer, std::size(buffer)), &result);
return result;
}

@ -13,7 +13,6 @@
#include "base/bind.h"
#include "base/containers/adapters.h"
#include "base/containers/cxx20_erase.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial_params.h"
@ -74,7 +73,7 @@ std::string EffectsToString(int effects) {
};
std::string ret;
for (size_t i = 0; i < base::size(flags); ++i) {
for (size_t i = 0; i < std::size(flags); ++i) {
if (effects & flags[i].flag) {
if (!ret.empty())
ret += " | ";

@ -130,7 +130,7 @@ class MidiSessionClientForTesting : public midi::mojom::MidiSessionClient {
class MidiHostTest : public testing::Test {
public:
MidiHostTest() : data_(kNoteOn, kNoteOn + base::size(kNoteOn)), port_id_(0) {
MidiHostTest() : data_(kNoteOn, kNoteOn + std::size(kNoteOn)), port_id_(0) {
browser_context_ = std::make_unique<TestBrowserContext>();
rph_ = std::make_unique<MockRenderProcessHost>(browser_context_.get());
std::unique_ptr<FakeMidiManagerFactory> factory =

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/notifications/notification_database_conversions.h"
#include <stddef.h>
#include <stdint.h>
#include "base/cxx17_backports.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "content/browser/notifications/notification_database_conversions.h"
#include "content/browser/notifications/notification_database_data.pb.h"
#include "content/browser/notifications/notification_database_resources.pb.h"
#include "content/public/browser/notification_database_data.h"
@ -64,11 +64,10 @@ const bool kHasTriggered = true;
TEST(NotificationDatabaseConversionsTest, SerializeAndDeserializeData) {
std::vector<int> vibration_pattern(
kNotificationVibrationPattern,
kNotificationVibrationPattern +
base::size(kNotificationVibrationPattern));
kNotificationVibrationPattern + std::size(kNotificationVibrationPattern));
std::vector<char> developer_data(
kNotificationData, kNotificationData + base::size(kNotificationData));
kNotificationData, kNotificationData + std::size(kNotificationData));
blink::PlatformNotificationData notification_data;
notification_data.title = kNotificationTitle;
@ -256,7 +255,7 @@ TEST(NotificationDatabaseConversionsTest, SerializeAndDeserializeDirections) {
blink::mojom::NotificationDirection::RIGHT_TO_LEFT,
blink::mojom::NotificationDirection::AUTO};
for (size_t i = 0; i < base::size(directions); ++i) {
for (size_t i = 0; i < std::size(directions); ++i) {
blink::PlatformNotificationData notification_data;
notification_data.direction = directions[i];
@ -282,7 +281,7 @@ TEST(NotificationDatabaseConversionsTest,
NotificationDatabaseData::ClosedReason::DEVELOPER,
NotificationDatabaseData::ClosedReason::UNKNOWN};
for (size_t i = 0; i < base::size(closed_reasons); ++i) {
for (size_t i = 0; i < std::size(closed_reasons); ++i) {
NotificationDatabaseData database_data;
database_data.closed_reason = closed_reasons[i];

@ -12,7 +12,6 @@
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
@ -244,7 +243,7 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
switches::kVModule
};
cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches,
base::size(kCommonForwardSwitches));
std::size(kCommonForwardSwitches));
static const char* const kPluginForwardSwitches[] = {
sandbox::policy::switches::kDisableSeccompFilterSandbox,
@ -256,7 +255,7 @@ bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) {
switches::kTimeZoneForTesting,
};
cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches,
base::size(kPluginForwardSwitches));
std::size(kPluginForwardSwitches));
std::string locale = GetContentClient()->browser()->GetApplicationLocale();
if (!locale.empty()) {

@ -16,7 +16,6 @@
#include "base/callback_helpers.h"
#include "base/check_op.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/i18n/case_conversion.h"
#include "base/metrics/histogram_functions.h"
@ -596,7 +595,7 @@ void DWriteFontProxyImpl::InitializeDirectWrite() {
}
// Temp code to help track down crbug.com/561873
for (size_t font = 0; font < base::size(kLastResortFontNames); font++) {
for (size_t font = 0; font < std::size(kLastResortFontNames); font++) {
uint32_t font_index = 0;
BOOL exists = FALSE;
if (SUCCEEDED(collection_->FindFamilyName(kLastResortFontNames[font],

@ -13,7 +13,6 @@
#include <vector>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
@ -1007,7 +1006,7 @@ TEST_F(InputRouterImplTest, MAYBE_GestureTypesIgnoringAck) {
WebInputEvent::Type::kGesturePinchUpdate,
WebInputEvent::Type::kGesturePinchEnd,
WebInputEvent::Type::kGestureScrollEnd};
for (size_t i = 0; i < base::size(eventTypes); ++i) {
for (size_t i = 0; i < std::size(eventTypes); ++i) {
WebInputEvent::Type type = eventTypes[i];
if (type == WebInputEvent::Type::kGestureFlingStart ||
type == WebInputEvent::Type::kGestureFlingCancel) {
@ -1105,7 +1104,7 @@ TEST_F(InputRouterImplTest, RequiredEventAckTypes) {
WebInputEvent::Type::kGestureScrollUpdate,
WebInputEvent::Type::kTouchStart,
WebInputEvent::Type::kTouchMove};
for (size_t i = 0; i < base::size(kRequiredEventAckTypes); ++i) {
for (size_t i = 0; i < std::size(kRequiredEventAckTypes); ++i) {
const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i];
ASSERT_TRUE(ShouldBlockEventStream(GetEventWithType(required_ack_type)))
<< WebInputEvent::GetName(required_ack_type);

@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/renderer_host/input/motion_event_web.h"
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/numerics/math_constants.h"
#include "content/browser/renderer_host/input/motion_event_web.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/gesture_detection/motion_event_generic.h"
@ -33,7 +33,7 @@ TEST(MotionEventWebTest, Constructor) {
PointerProperties pp;
MotionEventGeneric generic_event(MotionEvent::Action::MOVE, event_time, pp);
for (MotionEvent::ToolType tool_type : tool_types) {
for (size_t i = 0; i < base::size(tilts_x); ++i) {
for (size_t i = 0; i < std::size(tilts_x); ++i) {
const float tilt_x = tilts_x[i];
const float tilt_y = tilts_y[i];
const float orientation = orientations[i];

@ -8,7 +8,6 @@
#import <Cocoa/Cocoa.h>
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/mac/mac_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "ui/events/cocoa/cocoa_event_utils.h"
@ -187,7 +186,7 @@ TEST(WebInputEventBuilderMacTest, NumPadMapping) {
ui::DomKey::FromCharacter('9')},
};
for (size_t i = 0; i < base::size(table); ++i) {
for (size_t i = 0; i < std::size(table); ++i) {
NSEvent* mac_event = BuildFakeKeyEvent(table[i].mac_key_code,
table[i].character, 0, NSKeyDown);
WebKeyboardEvent web_event = WebKeyboardEventBuilder::Build(mac_event);
@ -200,7 +199,7 @@ TEST(WebInputEventBuilderMacTest, NumPadMapping) {
// Test that left- and right-hand modifier keys are interpreted correctly when
// pressed simultaneously.
TEST(WebInputEventFactoryTestMac, SimultaneousModifierKeys) {
for (size_t i = 0; i < base::size(kModifierKeys) / 2; ++i) {
for (size_t i = 0; i < std::size(kModifierKeys) / 2; ++i) {
const ModifierKey& left = kModifierKeys[2 * i];
const ModifierKey& right = kModifierKeys[2 * i + 1];
// Press the left key.
@ -231,7 +230,7 @@ TEST(WebInputEventFactoryTestMac, SimultaneousModifierKeys) {
// Test that individual modifier keys are still reported correctly, even if the
// undocumented left- or right-hand flags are not set.
TEST(WebInputEventBuilderMacTest, MissingUndocumentedModifierFlags) {
for (size_t i = 0; i < base::size(kModifierKeys); ++i) {
for (size_t i = 0; i < std::size(kModifierKeys); ++i) {
const ModifierKey& key = kModifierKeys[i];
NSEvent* mac_event = BuildFakeKeyEvent(
key.mac_key_code, 0, key.non_specific_mask, NSFlagsChanged);

@ -16,7 +16,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/cxx17_backports.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
@ -129,8 +128,8 @@ std::string RandomLabel() {
static const size_t kRfc4122LengthLabel = 36u;
std::string label(kRfc4122LengthLabel, ' ');
for (char& c : label) {
// Use |base::size(kAlphabet) - 1| to avoid |kAlphabet|s terminating '\0';
c = kAlphabet[base::RandGenerator(base::size(kAlphabet) - 1)];
// Use |std::size(kAlphabet) - 1| to avoid |kAlphabet|s terminating '\0';
c = kAlphabet[base::RandGenerator(std::size(kAlphabet) - 1)];
DCHECK(std::isalnum(c)) << c;
}
return label;
@ -2338,7 +2337,7 @@ void MediaStreamManager::DevicesEnumerated(
bool requested[] = {requested_audio_input, requested_video_input};
MediaStreamType stream_types[] = {MediaStreamType::DEVICE_AUDIO_CAPTURE,
MediaStreamType::DEVICE_VIDEO_CAPTURE};
for (size_t i = 0; i < base::size(requested); ++i) {
for (size_t i = 0; i < std::size(requested); ++i) {
if (!requested[i])
continue;

@ -6,7 +6,6 @@
#include <stdint.h>
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/time.h"
@ -572,7 +571,7 @@ TEST_F(NavigatorTest, NoContent) {
auto response = network::mojom::URLResponseHead::New();
const char kNoContentHeaders[] = "HTTP/1.1 204 No Content\0\0";
response->headers = new net::HttpResponseHeaders(
std::string(kNoContentHeaders, base::size(kNoContentHeaders)));
std::string(kNoContentHeaders, std::size(kNoContentHeaders)));
GetLoaderForNavigationRequest(main_request)
->CallOnResponseStarted(std::move(response),
mojo::ScopedDataPipeConsumerHandle());
@ -597,7 +596,7 @@ TEST_F(NavigatorTest, NoContent) {
response = network::mojom::URLResponseHead::New();
const char kResetContentHeaders[] = "HTTP/1.1 205 Reset Content\0\0";
response->headers = new net::HttpResponseHeaders(
std::string(kResetContentHeaders, base::size(kResetContentHeaders)));
std::string(kResetContentHeaders, std::size(kResetContentHeaders)));
GetLoaderForNavigationRequest(main_request)
->CallOnResponseStarted(std::move(response),
mojo::ScopedDataPipeConsumerHandle());

@ -6,7 +6,6 @@
#import <Cocoa/Cocoa.h>
#include "base/cxx17_backports.h"
#include "base/strings/sys_string_conversions.h"
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
#include "ppapi/proxy/serialized_structs.h"
@ -30,7 +29,7 @@ const PP_TrueTypeFontWeight_Dev kPepperFontWeights[] = {
PP_TRUETYPEFONTWEIGHT_ULTRABOLD,
PP_TRUETYPEFONTWEIGHT_HEAVY,
};
const NSInteger kPepperFontWeightsLength = base::size(kPepperFontWeights);
const NSInteger kPepperFontWeightsLength = std::size(kPepperFontWeights);
} // namespace

@ -3501,7 +3501,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
#endif
};
renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames,
base::size(kSwitchNames));
std::size(kSwitchNames));
// |switches::kGaiaConfig| can be set via browser command-line arguments,
// usually by developers working on signin code. The switch, however, cannot

@ -7,7 +7,6 @@
#import <objc/runtime.h>
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#import "content/browser/renderer_host/render_widget_host_view_mac.h"
@ -180,7 +179,7 @@ NSString* RenderWidgetHostViewMacEditCommandHelper::CommandNameForSelector(
RenderWidgetHostViewMacEditCommandHelper::
RenderWidgetHostViewMacEditCommandHelper() {
for (size_t i = 0; i < base::size(kEditCommands); ++i) {
for (size_t i = 0; i < std::size(kEditCommands); ++i) {
edit_command_set_.insert(kEditCommands[i]);
}
}
@ -213,7 +212,7 @@ bool RenderWidgetHostViewMacEditCommandHelper::IsMenuItemEnabled(
// static
void RenderWidgetHostViewMacEditCommandHelper::AddEditingSelectorsToClass(
Class klass) {
for (size_t i = 0; i < base::size(kEditCommands); ++i) {
for (size_t i = 0; i < std::size(kEditCommands); ++i) {
// Append trailing ':' to command name to get selector name.
NSString* sel_str = [NSString stringWithFormat:@"%s:", kEditCommands[i]];
@ -230,7 +229,7 @@ void RenderWidgetHostViewMacEditCommandHelper::AddEditingSelectorsToClass(
// static
NSArray*
RenderWidgetHostViewMacEditCommandHelper::GetEditSelectorNamesForTesting() {
size_t num_edit_commands = base::size(kEditCommands);
size_t num_edit_commands = std::size(kEditCommands);
NSMutableArray* ret = [NSMutableArray arrayWithCapacity:num_edit_commands];
for (size_t i = 0; i < num_edit_commands; ++i) {

@ -13,7 +13,6 @@
#include <sys/stat.h>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/files/scoped_file.h"
#include "base/linux_util.h"
#include "base/logging.h"
@ -44,7 +43,7 @@ void SandboxIPCHandler::Run() {
int failed_polls = 0;
for (;;) {
const int r =
HANDLE_EINTR(poll(pfds, base::size(pfds), -1 /* no timeout */));
HANDLE_EINTR(poll(pfds, std::size(pfds), -1 /* no timeout */));
// '0' is not a possible return value with no timeout.
DCHECK_NE(0, r);
if (r < 0) {

@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/browser/service_process_host.h"
#include <string.h>
#include "base/cxx17_backports.h"
#include "base/memory/shared_memory_mapping.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/time/time.h"
#include "base/timer/elapsed_timer.h"
#include "content/public/browser/service_process_host.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "services/test/echo/public/mojom/echo.mojom.h"
@ -121,7 +121,7 @@ IN_PROC_BROWSER_TEST_F(ServiceProcessHostBrowserTest, AllMessagesReceived) {
echo_service.reset();
observer.WaitForDeath();
const std::string& kLastMessage = kMessages[base::size(kMessages) - 1];
const std::string& kLastMessage = kMessages[std::size(kMessages) - 1];
EXPECT_EQ(0,
memcmp(mapping.memory(), kLastMessage.data(), kLastMessage.size()));
}

@ -183,7 +183,7 @@ EmbeddedWorkerTestHelper::CreateMainScriptResponse() {
"Content-Type: application/javascript\0"
"\0";
response_head.headers = base::MakeRefCounted<net::HttpResponseHeaders>(
std::string(data, base::size(data)));
std::string(data, std::size(data)));
return std::make_unique<ServiceWorkerVersion::MainScriptResponse>(
response_head);
}

@ -13,7 +13,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/containers/queue.h"
#include "base/cxx17_backports.h"
#include "base/memory/ptr_util.h"
#include "base/test/task_environment.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
@ -169,7 +168,7 @@ class ServiceWorkerCacheWriterTest : public ::testing::Test {
auto response_head = network::mojom::URLResponseHead::New();
const char data[] = "HTTP/1.1 200 OK\0\0";
response_head->headers = base::MakeRefCounted<net::HttpResponseHeaders>(
std::string(data, base::size(data)));
std::string(data, std::size(data)));
response_head->content_length = len;
net::Error error = cache_writer_->MaybeWriteHeaders(
std::move(response_head), CreateWriteCallback());

@ -59,7 +59,7 @@ void ExpectEqual(const base::DictionaryValue& expected,
}
const char kFileContent[] = "uploaded file content";
const size_t kFileSize = base::size(kFileContent) - 1;
const size_t kFileSize = std::size(kFileContent) - 1;
} // namespace
// Tests POST requests that include a file and are intercepted by a service

@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
@ -1285,7 +1284,7 @@ void WriteStringResponse(
const std::string& body) {
mojo_base::BigBuffer body_buffer(base::as_bytes(base::make_span(body)));
const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0\0";
std::string headers(kHttpHeaders, base::size(kHttpHeaders));
std::string headers(kHttpHeaders, std::size(kHttpHeaders));
WriteResponse(writer, headers, std::move(body_buffer));
}
@ -1426,13 +1425,13 @@ class UpdateJobTestHelper : public EmbeddedWorkerTestHelper,
// Spoof caching the script for the initial version.
WriteStringResponse(writer, kBody);
version->script_cache_map()->NotifyFinishedCaching(
script, base::size(kBody), net::OK, std::string());
script, std::size(kBody), net::OK, std::string());
} else {
EXPECT_NE(GURL(kNoChangeOrigin), script.DeprecatedGetOriginAsURL());
// The script must be changed.
WriteStringResponse(writer, kNewBody);
version->script_cache_map()->NotifyFinishedCaching(
script, base::size(kNewBody), net::OK, std::string());
script, std::size(kNewBody), net::OK, std::string());
}
version->SetMainScriptResponse(CreateMainScriptResponse());
@ -1850,7 +1849,7 @@ TEST_F(ServiceWorkerUpdateJobTest, Update_ScriptUrlChanged) {
version->script_cache_map()->NotifyStartedCaching(new_script, resource_id);
WriteStringResponse(writer, kBody);
version->script_cache_map()->NotifyFinishedCaching(
new_script, base::size(kBody), net::OK, std::string());
new_script, std::size(kBody), net::OK, std::string());
// Run the update job.
base::RunLoop().RunUntilIdle();

@ -129,7 +129,7 @@ int WriteBasicResponse(
int64_t id) {
const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0Content-Length: 5\0\0";
const char kHttpBody[] = "Hello";
std::string headers(kHttpHeaders, base::size(kHttpHeaders));
std::string headers(kHttpHeaders, std::size(kHttpHeaders));
return WriteStringResponse(storage, id, headers, std::string(kHttpBody));
}

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/service_worker/service_worker_version.h"
#include <stddef.h>
#include <stdint.h>
@ -13,7 +15,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/cxx17_backports.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/statistics_recorder.h"
@ -36,7 +37,6 @@
#include "content/browser/service_worker/service_worker_host.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
@ -216,7 +216,7 @@ CreateMainScriptResponse() {
"Content-Type: application/javascript\0"
"\0";
response_head.headers =
new net::HttpResponseHeaders(std::string(data, base::size(data)));
new net::HttpResponseHeaders(std::string(data, std::size(data)));
return std::make_unique<ServiceWorkerVersion::MainScriptResponse>(
response_head);
}

@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/storage_partition_impl.h"
#include <stddef.h>
#include <stdint.h>
@ -16,7 +18,6 @@
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/containers/contains.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h"
@ -50,7 +51,6 @@
#include "content/browser/code_cache/generated_code_cache_context.h"
#include "content/browser/gpu/shader_cache_factory.h"
#include "content/browser/interest_group/interest_group_manager_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/generated_code_cache_settings.h"
@ -392,8 +392,8 @@ class RemoveLocalStorageTester {
std::vector<uint8_t> serialized_origin(origin_str.begin(),
origin_str.end());
std::vector<uint8_t> key;
key.reserve(base::size(kMetaPrefix) + serialized_origin.size());
key.insert(key.end(), kMetaPrefix, kMetaPrefix + base::size(kMetaPrefix));
key.reserve(std::size(kMetaPrefix) + serialized_origin.size());
key.insert(key.end(), kMetaPrefix, kMetaPrefix + std::size(kMetaPrefix));
key.insert(key.end(), serialized_origin.begin(), serialized_origin.end());
return key;
}

@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/i18n/base_i18n_switches.h"
#include "base/strings/utf_string_conversions.h"
@ -299,7 +298,7 @@ bool UtilityProcessHost::StartProcess() {
#endif
};
cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
base::size(kSwitchNames));
std::size(kSwitchNames));
network_session_configurator::CopyNetworkSwitches(browser_command_line,
cmd_line.get());

@ -5,7 +5,6 @@
#include <string>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
@ -1997,7 +1996,7 @@ IN_PROC_BROWSER_TEST_F(SignedExchangeSubresourcePrefetchBrowserTest, CORS) {
std::string requests_list_string;
std::vector<MockSignedExchangeHandlerParams> mock_params;
for (size_t i = 0; i < base::size(kTestCases); ++i) {
for (size_t i = 0; i < std::size(kTestCases); ++i) {
if (i) {
target_sxg_outer_link_header += ",";
target_sxg_inner_link_header += ",";
@ -2083,7 +2082,7 @@ let results = [];
NavigateToURL(shell(), embedded_test_server()->GetURL(prefetch_path)));
// Wait until all (main- and sub-resource) SXGs are prefetched.
while (GetCachedExchanges(shell()).size() < base::size(kTestCases) + 1) {
while (GetCachedExchanges(shell()).size() < std::size(kTestCases) + 1) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
@ -2092,7 +2091,7 @@ let results = [];
NavigateToURLAndWaitTitle(target_sxg_url, "done");
for (size_t i = 0; i < base::size(kTestCases); ++i) {
for (size_t i = 0; i < std::size(kTestCases); ++i) {
SCOPED_TRACE(base::StringPrintf("TestCase %zu", i));
EXPECT_EQ(
EvalJs(shell(), base::StringPrintf("results[%zu]", i)).ExtractString(),

@ -15,7 +15,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/compiler_specific.h"
#include "base/cxx17_backports.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/memory/raw_ptr.h"
@ -794,10 +793,10 @@ TEST_F(AuthenticatorImplTest, ClientDataJSONSerialization) {
TEST_F(AuthenticatorImplTest, MakeCredentialOriginAndRpIds) {
std::vector<OriginClaimedAuthorityPair> tests(
&kValidRelyingPartyTestCases[0],
&kValidRelyingPartyTestCases[base::size(kValidRelyingPartyTestCases)]);
tests.insert(tests.end(), &kInvalidRelyingPartyTestCases[0],
&kInvalidRelyingPartyTestCases[base::size(
kInvalidRelyingPartyTestCases)]);
&kValidRelyingPartyTestCases[std::size(kValidRelyingPartyTestCases)]);
tests.insert(
tests.end(), &kInvalidRelyingPartyTestCases[0],
&kInvalidRelyingPartyTestCases[std::size(kInvalidRelyingPartyTestCases)]);
for (const auto& test_case : tests) {
SCOPED_TRACE(std::string(test_case.claimed_authority) + " " +

@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/webui/web_ui_data_source_impl.h"
@ -39,13 +38,13 @@ class TestClient : public TestContentClient {
base::RefCountedStaticMemory* bytes = nullptr;
if (resource_id == kDummyDefaultResourceId) {
bytes = new base::RefCountedStaticMemory(
kDummyDefaultResource, base::size(kDummyDefaultResource));
kDummyDefaultResource, std::size(kDummyDefaultResource));
} else if (resource_id == kDummyResourceId) {
bytes = new base::RefCountedStaticMemory(kDummyResource,
base::size(kDummyResource));
std::size(kDummyResource));
} else if (resource_id == kDummyJSResourceId) {
bytes = new base::RefCountedStaticMemory(kDummyJSResource,
base::size(kDummyJSResource));
std::size(kDummyJSResource));
}
return bytes;
}

@ -2,17 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/common/font_list.h"
#include <fontconfig/fontconfig.h>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <fontconfig/fontconfig.h>
#include "base/cxx17_backports.h"
#include "base/values.h"
#include "content/common/font_list.h"
namespace content {
@ -39,7 +37,7 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
// See https://www.freetype.org/freetype2/docs/reference/ft2-font_formats.html
// for the list of possible formats.
const char* allowed_formats[] = { "TrueType", "CFF" };
for (size_t i = 0; i < base::size(allowed_formats); ++i) {
for (size_t i = 0; i < std::size(allowed_formats); ++i) {
auto format_pattern = CreateFormatPattern(allowed_formats[i]);
std::unique_ptr<FcFontSet, decltype(&FcFontSetDestroy)> fontset(
FcFontList(nullptr, format_pattern.get(), object_set.get()),

@ -165,7 +165,7 @@ class FontFamilyResolver {
CFStringRef set_values[] = {kCTFontFamilyNameAttribute};
return base::ScopedCFTypeRef<CFSetRef>(CFSetCreate(
kCFAllocatorDefault, reinterpret_cast<const void**>(set_values),
base::size(set_values), &kCFTypeSetCallBacks));
std::size(set_values), &kCFTypeSetCallBacks));
}
// Creates the mutable dictionary stored in |font_descriptor_attributes_|.

@ -10,7 +10,6 @@
#include <string>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/strings/utf_string_conversions.h"
#include "base/version.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -33,7 +32,7 @@ TEST(PluginUtilsTest, VersionExtraction) {
{ "1..0", "1.0.0" } // Empty version component
};
for (size_t i = 0; i < base::size(versions); i++) {
for (size_t i = 0; i < std::size(versions); i++) {
base::Version version;
WebPluginInfo::CreateVersionFromString(
base::ASCIIToUTF16(versions[i][0]), &version);

@ -9,7 +9,6 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/i18n/unicodestring.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
@ -245,7 +244,7 @@ void ZygoteCommunication::Init(
sandbox::policy::switches::kNoSandbox,
};
cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches,
base::size(kForwardSwitches));
std::size(kForwardSwitches));
pid_ = std::move(launcher).Run(&cmd_line, &control_fd_);

@ -9,7 +9,6 @@
#include <cmath>
#include <memory>
#include "base/cxx17_backports.h"
#include "base/strings/stringprintf.h"
#include "content/common/android/gin_java_bridge_value.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -130,7 +129,7 @@ TEST_F(GinJavaBridgeValueConverterTest, TypedArrays) {
"4", "Int32Array", "4", "Uint32Array",
"4", "Float32Array", "8", "Float64Array"
};
for (size_t i = 0; i < base::size(array_types); i += 2) {
for (size_t i = 0; i < std::size(array_types); i += 2) {
const char* typed_array_type = array_types[i + 1];
v8::Local<v8::Script> script(
v8::Script::Compile(

@ -5,10 +5,10 @@
#include "content/renderer/pepper/pepper_audio_encoder_host.h"
#include <stddef.h>
#include <utility>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "content/renderer/pepper/host_globals.h"
@ -95,7 +95,7 @@ PepperAudioEncoderHost::AudioEncoderImpl::GetSupportedProfiles() {
std::vector<PP_AudioProfileDescription> profiles;
static const uint32_t sampling_rates[] = {8000, 12000, 16000, 24000, 48000};
for (uint32_t i = 0; i < base::size(sampling_rates); ++i) {
for (uint32_t i = 0; i < std::size(sampling_rates); ++i) {
PP_AudioProfileDescription profile;
profile.profile = PP_AUDIOPROFILE_OPUS;
profile.max_channels = 2;

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/test/task_environment.h"
#include "content/public/renderer/ppapi_gfx_conversion.h"
#include "content/renderer/pepper/mock_renderer_ppapi_host.h"
@ -136,7 +135,7 @@ TEST_F(PepperGraphics2DHostTest, ConvertToLogicalPixels) {
// Check negative scroll deltas
{10, 10, 20, 20, 5, 5, 10, 10, -6, -4, -3, -2, 0.5, true},
{10, 10, 20, 20, 5, 5, 10, 10, -6, -3, -3, -1, 0.5, false}, };
for (size_t i = 0; i < base::size(tests); ++i) {
for (size_t i = 0; i < std::size(tests); ++i) {
gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
gfx::Rect orig = r1;

@ -12,7 +12,6 @@
#include "base/callback.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/location.h"
@ -162,7 +161,7 @@ int ConvertMockKeyboardModifier(MockKeyboard::Modifiers modifiers) {
{MockKeyboard::RIGHT_ALT, ui::EF_ALT_DOWN},
};
int flags = 0;
for (size_t i = 0; i < base::size(kModifierMap); ++i) {
for (size_t i = 0; i < std::size(kModifierMap); ++i) {
if (kModifierMap[i].src & modifiers) {
flags |= kModifierMap[i].dst;
}
@ -712,7 +711,7 @@ TEST_F(RenderViewImplTest, OnNavigationHttpPost) {
// Set up post data.
const char raw_data[] = "post \0\ndata";
const size_t length = base::size(raw_data);
const size_t length = std::size(raw_data);
scoped_refptr<network::ResourceRequestBody> post_data(
new network::ResourceRequestBody);
post_data->AppendBytes(raw_data, length);
@ -894,7 +893,7 @@ TEST_F(RenderViewImplTest, BeginNavigationHandlesAllTopLevel) {
blink::kWebNavigationTypeOther,
};
for (size_t i = 0; i < base::size(kNavTypes); ++i) {
for (size_t i = 0; i < std::size(kNavTypes); ++i) {
auto navigation_info = std::make_unique<blink::WebNavigationInfo>();
navigation_info->url_request = blink::WebURLRequest(GURL("http://foo.com"));
navigation_info->url_request.SetRequestorOrigin(
@ -1368,7 +1367,7 @@ TEST_F(RenderViewImplTextInputStateChanged, OnImeTypeChanged) {
input_mode = updated_states()[0]->mode;
EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type);
for (size_t test = 0; test < base::size(kInputModeTestCases); test++) {
for (size_t test = 0; test < std::size(kInputModeTestCases); test++) {
const InputModeTestCase* test_case = &kInputModeTestCases[test];
std::u16string javascript = base::ASCIIToUTF16(base::StringPrintf(
"document.getElementById('%s').focus();", test_case->input_id));
@ -1943,7 +1942,7 @@ TEST_F(RenderViewImplTest, ImeComposition) {
{IME_FINISHCOMPOSINGTEXT, false, -1, -1, L"", L"\xC548\xB155"},
};
for (size_t i = 0; i < base::size(kImeMessages); i++) {
for (size_t i = 0; i < std::size(kImeMessages); i++) {
const ImeMessage* ime_message = &kImeMessages[i];
switch (ime_message->command) {
case IME_INITIALIZE:

@ -8,7 +8,6 @@
#include <string>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
#include "base/test/bind.h"
@ -1266,13 +1265,12 @@ TEST_F(AuctionV8HelperTest, CompileWasm) {
v8::Local<v8::WasmModuleObject> wasm_module;
absl::optional<std::string> compile_error;
ASSERT_TRUE(
helper_
->CompileWasm(std::string(kMinimalWasmModuleBytes,
base::size(kMinimalWasmModuleBytes)),
GURL("https://foo.test/"),
/*debug_id=*/nullptr, compile_error)
.ToLocal(&wasm_module));
ASSERT_TRUE(helper_
->CompileWasm(std::string(kMinimalWasmModuleBytes,
std::size(kMinimalWasmModuleBytes)),
GURL("https://foo.test/"),
/*debug_id=*/nullptr, compile_error)
.ToLocal(&wasm_module));
EXPECT_FALSE(compile_error.has_value());
}
@ -1317,7 +1315,7 @@ TEST_F(AuctionV8HelperTest, CompileWasmDebug) {
absl::optional<std::string> error_out;
EXPECT_TRUE(CompileWasmOnV8ThreadAndWait(
id, GURL("https://example.com"),
std::string(kMinimalWasmModuleBytes, base::size(kMinimalWasmModuleBytes)),
std::string(kMinimalWasmModuleBytes, std::size(kMinimalWasmModuleBytes)),
&error_out));
TestDevToolsAgentClient::Event script_parsed =
debug_client.WaitForMethodNotification("Debugger.scriptParsed");
@ -1348,13 +1346,12 @@ TEST_F(AuctionV8HelperTest, CloneWasmModule) {
// Compile the WASM module...
v8::Local<v8::WasmModuleObject> wasm_module;
absl::optional<std::string> error_msg;
ASSERT_TRUE(
helper_
->CompileWasm(std::string(kMinimalWasmModuleBytes,
base::size(kMinimalWasmModuleBytes)),
GURL("https://foo.test/"),
/*debug_id=*/nullptr, error_msg)
.ToLocal(&wasm_module));
ASSERT_TRUE(helper_
->CompileWasm(std::string(kMinimalWasmModuleBytes,
std::size(kMinimalWasmModuleBytes)),
GURL("https://foo.test/"),
/*debug_id=*/nullptr, error_msg)
.ToLocal(&wasm_module));
EXPECT_FALSE(error_msg.has_value());
// And the test script.

@ -9,7 +9,6 @@
#include <string>
#include <vector>
#include "base/cxx17_backports.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8-inspector.h"
@ -21,7 +20,7 @@ namespace auction_worklet {
TEST(AuctionV8InspectorUtilTest, GetStringBytes8) {
const uint8_t chars[] = {'a', 'b', 'c', 0xD0, 0xB0, 0xD0, 0xB1, 0xD0, 0xB2};
auto string_buf = v8_inspector::StringBuffer::create(
v8_inspector::StringView(chars, base::size(chars)));
v8_inspector::StringView(chars, std::size(chars)));
EXPECT_THAT(GetStringBytes(string_buf.get()),
ElementsAre('a', 'b', 'c', 0xD0, 0xB0, 0xD0, 0xB1, 0xD0, 0xB2));
}
@ -36,7 +35,7 @@ TEST(AuctionV8InspectorUtilTest, GetStringBytes16) {
// U+1F600, GRINNING FACE, as surrogate pairs.
0xD83D, 0xDE00};
auto string_buf = v8_inspector::StringBuffer::create(
v8_inspector::StringView(chars16, base::size(chars16)));
v8_inspector::StringView(chars16, std::size(chars16)));
EXPECT_THAT(GetStringBytes(string_buf.get()),
ElementsAre(0xD0, 0x94, 0xD1, 0x8F, 0xD0, 0xBA, 0xD1, 0x83, 0xD1,
0x8E, '!', 0xF0, 0x9F, 0x98, 0x80));

@ -13,7 +13,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/cxx17_backports.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/strcat.h"
@ -92,7 +91,7 @@ v8::MaybeLocal<v8::Value> CreatePrevWinsArray(
return v8::MaybeLocal<v8::Value>();
}
prev_wins_v8.push_back(
v8::Array::New(isolate, win_values, base::size(win_values)));
v8::Array::New(isolate, win_values, std::size(win_values)));
}
return v8::Array::New(isolate, prev_wins_v8.data(), prev_wins_v8.size());
}

@ -9,7 +9,6 @@
#include <vector>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
@ -58,7 +57,7 @@ const char kWasmUrl[] = "https://foo.test/helper.wasm";
// Packs kToyWasm into a std::string.
std::string ToyWasm() {
return std::string(reinterpret_cast<const char*>(kToyWasm),
base::size(kToyWasm));
std::size(kToyWasm));
}
// Creates generateBid() scripts with the specified result value, in raw

@ -8,7 +8,6 @@
#include <utility>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/bind.h"
@ -233,10 +232,10 @@ TEST_F(WorkletLoaderTest, DeleteBeforeCallback) {
}
TEST_F(WorkletLoaderTest, LoadWasmSuccess) {
AddResponse(&url_loader_factory_, url_, "application/wasm",
/*charset=*/absl::nullopt,
std::string(kMinimalWasmModuleBytes,
base::size(kMinimalWasmModuleBytes)));
AddResponse(
&url_loader_factory_, url_, "application/wasm",
/*charset=*/absl::nullopt,
std::string(kMinimalWasmModuleBytes, std::size(kMinimalWasmModuleBytes)));
WorkletWasmLoader worklet_loader(
&url_loader_factory_, url_, v8_helper_,
scoped_refptr<AuctionV8Helper::DebugId>(),

@ -5,11 +5,11 @@
#include "content/shell/browser/shell_content_browser_client.h"
#include <stddef.h>
#include <utility>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
@ -302,8 +302,7 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kForwardSwitches,
base::size(kForwardSwitches));
kForwardSwitches, std::size(kForwardSwitches));
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
if (base::CommandLine::ForCurrentProcess()->HasSwitch(

@ -167,7 +167,7 @@ void ShellDownloadManagerDelegate::ChooseDownloadPath(
#if BUILDFLAG(IS_WIN)
std::wstring file_part = base::FilePath(suggested_path).BaseName().value();
wchar_t file_name[MAX_PATH];
base::wcslcpy(file_name, file_part.c_str(), base::size(file_name));
base::wcslcpy(file_name, file_part.c_str(), std::size(file_name));
OPENFILENAME save_as;
ZeroMemory(&save_as, sizeof(save_as));
save_as.lStructSize = sizeof(OPENFILENAME);
@ -178,7 +178,7 @@ void ShellDownloadManagerDelegate::ChooseDownloadPath(
save_as.hwndOwner =
web_contents->GetNativeView()->GetHost()->GetAcceleratedWidget();
save_as.lpstrFile = file_name;
save_as.nMaxFile = base::size(file_name);
save_as.nMaxFile = std::size(file_name);
std::wstring directory;
if (!suggested_path.empty())

@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/raw_ptr.h"
#include "content/shell/browser/shell_platform_delegate.h"
#include <stddef.h>
#include <algorithm>
@ -13,7 +10,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/cxx17_backports.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
@ -21,6 +18,7 @@
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_platform_delegate.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
@ -241,7 +239,7 @@ class ShellView : public views::BoxLayoutView,
DCHECK(GetWidget());
static const ui::KeyboardCode keys[] = {ui::VKEY_F5, ui::VKEY_BROWSER_BACK,
ui::VKEY_BROWSER_FORWARD};
for (size_t i = 0; i < base::size(keys); ++i) {
for (size_t i = 0; i < std::size(keys); ++i) {
GetFocusManager()->RegisterAccelerator(
ui::Accelerator(keys[i], ui::EF_NONE),
ui::AcceleratorManager::kNormalPriority, this);

@ -66,7 +66,7 @@ base::CommandLine CreateCommandLine() {
switches::kOzonePlatform,
};
command_line.CopySwitchesFrom(cmdline, kSwitchesToCopy,
base::size(kSwitchesToCopy));
std::size(kSwitchesToCopy));
#endif
return command_line;
}

@ -8,7 +8,6 @@
#include <string.h>
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "content/test/mock_keyboard.h"
namespace content {
@ -103,7 +102,7 @@ bool MockKeyboardDriverWin::SetLayout(int layout) {
{L"00001009", MockKeyboard::LAYOUT_CANADIAN_FRENCH},
};
for (size_t i = 0; i < base::size(kLanguageIDs); ++i) {
for (size_t i = 0; i < std::size(kLanguageIDs); ++i) {
if (layout == kLanguageIDs[i].keyboard_layout) {
HKL new_keyboard_layout = LoadKeyboardLayout(kLanguageIDs[i].language,
KLF_ACTIVATE);
@ -143,7 +142,7 @@ bool MockKeyboardDriverWin::SetModifiers(int modifiers) {
{VK_RCONTROL, MockKeyboard::RIGHT_CONTROL},
{VK_RMENU, MockKeyboard::RIGHT_ALT},
};
for (size_t i = 0; i < base::size(kModifierMasks); ++i) {
for (size_t i = 0; i < std::size(kModifierMasks); ++i) {
const int kKeyDownMask = 0x80;
if (modifiers & kModifierMasks[i].mask)
keyboard_states_[kModifierMasks[i].key_code] = kKeyDownMask;
@ -161,7 +160,7 @@ int MockKeyboardDriverWin::GetCharacters(int key_code,
wchar_t code[16];
int length =
ToUnicodeEx(key_code, MapVirtualKey(key_code, 0), &keyboard_states_[0],
&code[0], base::size(code), 0, active_keyboard_layout_);
&code[0], std::size(code), 0, active_keyboard_layout_);
if (length > 0)
output->assign(code);
return length;

@ -6,12 +6,12 @@
#include <stddef.h>
#include <windows.h>
#include <iostream>
#include <list>
#include <string>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
@ -64,7 +64,7 @@ bool WebTestBrowserCheckLayoutSystemDeps() {
&metrics.lfSmCaptionFont};
const wchar_t required_font[] = L"Segoe UI";
int required_font_size = -12;
for (size_t i = 0; i < base::size(system_fonts); ++i) {
for (size_t i = 0; i < std::size(system_fonts); ++i) {
if (system_fonts[i]->lfHeight != required_font_size ||
wcscmp(required_font, system_fonts[i]->lfFaceName)) {
errors.push_back(

@ -12,7 +12,6 @@
#include <vector>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/strings/pattern.h"
@ -351,8 +350,7 @@ void WebTestContentBrowserClient::AppendExtraCommandLineSwitches(
};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kForwardSwitches,
base::size(kForwardSwitches));
kForwardSwitches, std::size(kForwardSwitches));
}
std::unique_ptr<BrowserMainParts>
@ -411,8 +409,8 @@ WebTestContentBrowserClient::GetOriginsRequiringDedicatedProcess() {
};
origins_to_isolate.reserve(origins_to_isolate.size() +
base::size(kWptHostnames) *
base::size(kOriginTemplates));
std::size(kWptHostnames) *
std::size(kOriginTemplates));
for (const char* kWptHostname : kWptHostnames) {
for (const char* kOriginTemplate : kOriginTemplates) {
std::string origin = base::StringPrintf(kOriginTemplate, kWptHostname);

@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/cxx17_backports.h"
#include "base/time/time.h"
#include "content/public/browser/permission_type.h"
#include "content/web_test/browser/web_test_browser_context.h"
@ -84,9 +83,9 @@ void WebTestPushMessagingService::SubscribeFromWorker(
if (permission_status == blink::mojom::PermissionStatus::GRANTED) {
std::vector<uint8_t> p256dh(kTestP256Key,
kTestP256Key + base::size(kTestP256Key));
kTestP256Key + std::size(kTestP256Key));
std::vector<uint8_t> auth(kAuthentication,
kAuthentication + base::size(kAuthentication));
kAuthentication + std::size(kAuthentication));
const std::string subscription_id = "layoutTestRegistrationId";
const GURL endpoint = CreateEndpoint(subscription_id);
@ -110,9 +109,9 @@ void WebTestPushMessagingService::GetSubscriptionInfo(
const std::string& subscription_id,
SubscriptionInfoCallback callback) {
std::vector<uint8_t> p256dh(kTestP256Key,
kTestP256Key + base::size(kTestP256Key));
kTestP256Key + std::size(kTestP256Key));
std::vector<uint8_t> auth(kAuthentication,
kAuthentication + base::size(kAuthentication));
kAuthentication + std::size(kAuthentication));
const GURL endpoint = CreateEndpoint(subscription_id);
std::move(callback).Run(true /* is_valid */, endpoint, GetFutureTime(),
p256dh, auth);

@ -4,7 +4,6 @@
#include "content/web_test/renderer/accessibility_controller.h"
#include "base/cxx17_backports.h"
#include "content/web_test/renderer/web_frame_test_proxy.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
@ -235,7 +234,7 @@ void AccessibilityController::PostNotification(
};
local_frame->CallFunctionEvenIfScriptDisabled(
v8::Local<v8::Function>::New(isolate, notification_callback_),
context->Global(), base::size(argv), argv);
context->Global(), std::size(argv), argv);
}
void AccessibilityController::LogAccessibilityEvents() {

@ -10,7 +10,6 @@
#include <map>
#include <utility>
#include "base/cxx17_backports.h"
#include "base/strings/stringprintf.h"
#include "gin/handle.h"
#include "third_party/blink/public/platform/web_string.h"
@ -505,7 +504,7 @@ void WebAXObjectProxy::NotificationReceived(
// dirtying layout during post-layout hooks?
frame->CallFunctionEvenIfScriptDisabled(
v8::Local<v8::Function>::New(isolate, notification_callback_),
context->Global(), base::size(argv), argv);
context->Global(), std::size(argv), argv);
}
void WebAXObjectProxy::Reset() {

@ -9,7 +9,6 @@
#include <algorithm>
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/strings/string_util.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_text_checking_result.h"
@ -54,7 +53,7 @@ bool WebTestGrammarChecker::CheckGrammarOfString(
{"the the adlj adaasj sdklj. there there", 33, 5},
{"zz apple orange.", 0, 16},
};
for (size_t i = 0; i < base::size(kGrammarErrors); ++i) {
for (size_t i = 0; i < std::size(kGrammarErrors); ++i) {
size_t offset = 0;
std::u16string error(
kGrammarErrors[i].text,

@ -9,7 +9,6 @@
#include <algorithm>
#include "base/check_op.h"
#include "base/cxx17_backports.h"
#include "base/strings/string_util.h"
namespace content {
@ -165,7 +164,7 @@ bool WebTestSpellChecker::InitializeIfNeeded() {
"ifmmp", "qwertyuiopasd", "qwertyuiopasdf", "upper case", "wellcome"};
misspelled_words_.clear();
for (size_t i = 0; i < base::size(misspelled_words); ++i)
for (size_t i = 0; i < std::size(misspelled_words); ++i)
misspelled_words_.push_back(
std::u16string(misspelled_words[i],
misspelled_words[i] + strlen(misspelled_words[i])));