0

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

Bug: 1299695
Change-Id: Ia2ef2239d649b2a50569cad9b3f293ca23510b68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3491962
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Owners-Override: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#975484}
This commit is contained in:
Daniel Cheng
2022-02-26 17:57:25 +00:00
committed by Chromium LUCI CQ
parent 91273092b0
commit 7b7aaecca4
266 changed files with 1011 additions and 1222 deletions
components
autofill
autofill_assistant
base32
blocklist
bookmarks
captive_portal
cbor
cdm
certificate_transparency
client_update_protocol
cloud_devices
commerce
component_updater
content_settings
crash
cronet
crx_file
dbus
discardable_memory
domain_reliability
download
drive
embedder_support
error_page
exo
favicon
favicon_base
feature_engagement
feedback
filename_generation
flags_ui
gcm_driver
google
core
history
history_clusters
image_fetcher
metrics
mirroring
nacl
navigation_metrics
network_session_configurator
network_time
no_state_prefetch
ntp_snippets
omnibox
open_from_clipboard
optimization_guide
os_crypt
page_info
password_manager
payments
pdf
permissions
policy
prefs
printing
proxy_config
query_parser
rlz
safe_browsing
safe_search_api
search_engines
services
sessions
signin
site_engagement
spellcheck
ssl_errors
storage_monitor
subresource_filter
sync
sync_device_info
tab_count_metrics
test
translate
update_client
upload_list
url_formatter
url_matcher
url_pattern_index
variations
visitedlink
viz
webcrypto
webrtc
zoom
zucchini

@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/strings/stringprintf.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
#include "base/cxx17_backports.h"
#include "base/metrics/field_trial.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/autofill/content/renderer/test_utils.h"
@ -457,7 +456,7 @@ TEST_F(FormAutofillUtilsTest, IsEnabled) {
{u"name3", true},
{u"name4", false},
};
const size_t number_of_cases = base::size(kExpectedFields);
const size_t number_of_cases = std::size(kExpectedFields);
ASSERT_EQ(number_of_cases, target.fields.size());
for (size_t i = 0; i < number_of_cases; ++i) {
EXPECT_EQ(kExpectedFields[i].name, target.fields[i].name);
@ -499,7 +498,7 @@ TEST_F(FormAutofillUtilsTest, IsReadonly) {
{u"name3", false},
{u"name4", true},
};
const size_t number_of_cases = base::size(kExpectedFields);
const size_t number_of_cases = std::size(kExpectedFields);
ASSERT_EQ(number_of_cases, target.fields.size());
for (size_t i = 0; i < number_of_cases; ++i) {
EXPECT_EQ(kExpectedFields[i].name, target.fields[i].name);

@ -181,7 +181,7 @@ TEST_F(HtmlBasedUsernameDetectorTest, DeveloperGroupAttributes) {
// Occurrence doesn't count.
{{"identity_name", "idn", "johnsmith"}, {"id", "xid", "123"}, "xid"}};
for (size_t i = 0; i < base::size(test_cases); ++i) {
for (size_t i = 0; i < std::size(test_cases); ++i) {
SCOPED_TRACE(testing::Message() << "Iteration " << i);
const std::string& form_html =
@ -253,7 +253,7 @@ TEST_F(HtmlBasedUsernameDetectorTest, UserGroupAttributes) {
"noword",
}};
for (size_t i = 0; i < base::size(test_cases); ++i) {
for (size_t i = 0; i < std::size(test_cases); ++i) {
SCOPED_TRACE(testing::Message() << "Iteration " << i);
const std::string& form_html =

@ -4,7 +4,7 @@
#include "components/autofill/content/renderer/html_based_username_detector_vocabulary.h"
#include "base/cxx17_backports.h"
#include <iterator>
namespace autofill {
@ -23,7 +23,7 @@ const char* const kNegativeLatin[] = {
"second", "passwort", "middlename", "paroladordine",
"codice", "pasvorto", "familyname", "inomboloyokuvula",
"modpas", "salasana", "motdepasse", "numeraeleiloaesesi"};
const size_t kNegativeLatinSize = base::size(kNegativeLatin);
const size_t kNegativeLatinSize = std::size(kNegativeLatin);
const char* const kNegativeNonLatin[] = {"fjalëkalim",
"የይለፍቃል",
@ -74,7 +74,7 @@ const char* const kNegativeNonLatin[] = {"fjalëkalim",
"mậtkhẩu",
"פּאַראָל",
"ọrọigbaniwọle"};
const size_t kNegativeNonLatinSize = base::size(kNegativeNonLatin);
const size_t kNegativeNonLatinSize = std::size(kNegativeNonLatin);
const char* const kUsernameLatin[] = {
"gatti", "uzantonomo", "solonanarana", "nombredeusuario",
@ -86,7 +86,7 @@ const char* const kUsernameLatin[] = {
"mosebedisi", "kasutajanimi", "ainmcleachdaidh", "igamalomsebenzisi",
"nomdusuari", "lomsebenzisi", "jenengpanganggo", "ingoakaiwhakamahi",
"nomeutente", "namapengguna"};
const size_t kUsernameLatinSize = base::size(kUsernameLatin);
const size_t kUsernameLatinSize = std::size(kUsernameLatin);
const char* const kUsernameNonLatin[] = {"用户名",
"کاتيجونالو",
@ -146,7 +146,7 @@ const char* const kUsernameNonLatin[] = {"用户名",
"ব্যবহারকারীরনাম",
"užívateľskémeno",
"ឈ្មោះអ្នកប្រើប្រាស់"};
const size_t kUsernameNonLatinSize = base::size(kUsernameNonLatin);
const size_t kUsernameNonLatinSize = std::size(kUsernameNonLatin);
const char* const kUserLatin[] = {
"user", "wosuta", "gebruiker", "utilizator",
@ -159,7 +159,7 @@ const char* const kUserLatin[] = {
"usuari", "kasutaja", "defnyddiwr", "kaiwhakamahi",
"utente", "korisnik", "mosebedisi", "foydalanuvchi",
"uzanto", "pengguna", "mushandisi"};
const size_t kUserLatinSize = base::size(kUserLatin);
const size_t kUserLatinSize = std::size(kUserLatin);
const char* const kUserNonLatin[] = {"用户",
"użytkownik",
@ -218,7 +218,7 @@ const char* const kUserNonLatin[] = {"用户",
"пайдаланушы",
"အသုံးပြုသူကို",
"käyttäjä"};
const size_t kUserNonLatinSize = base::size(kUserNonLatin);
const size_t kUserNonLatinSize = std::size(kUserNonLatin);
const char* const kTechnicalWords[] = {
"uid", "newtel", "uaccount", "regaccount", "ureg",
@ -226,9 +226,9 @@ const char* const kTechnicalWords[] = {
"loginname", "membername", "uname", "ucreate", "loginmail",
"accountname", "umail", "loginreg", "accountid", "loginaccount",
"ulogin", "regemail", "newmobile", "accountlogin"};
const size_t kTechnicalWordsSize = base::size(kTechnicalWords);
const size_t kTechnicalWordsSize = std::size(kTechnicalWords);
const char* const kWeakWords[] = {"id", "login", "mail"};
const size_t kWeakWordsSize = base::size(kWeakWords);
const size_t kWeakWordsSize = std::size(kWeakWords);
} // namespace autofill

@ -193,7 +193,7 @@ std::u16string GetProfileDescription(const AutofillProfile& profile,
}
return profile.ConstructInferredLabel(
kDetailsFields, base::size(kDetailsFields),
kDetailsFields, std::size(kDetailsFields),
/*num_fields_to_include=*/2, ui_language_code);
}

@ -8,7 +8,6 @@
#include <iterator>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/i18n/char_iterator.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
@ -121,7 +120,7 @@ bool ContainsString(const char* const set[],
void StripPrefixes(std::vector<base::StringPiece16>* name_tokens) {
auto iter = name_tokens->begin();
while (iter != name_tokens->end()) {
if (!ContainsString(name_prefixes, base::size(name_prefixes), *iter))
if (!ContainsString(name_prefixes, std::size(name_prefixes), *iter))
break;
++iter;
}
@ -134,7 +133,7 @@ void StripPrefixes(std::vector<base::StringPiece16>* name_tokens) {
// Removes common name suffixes from |name_tokens|.
void StripSuffixes(std::vector<base::StringPiece16>* name_tokens) {
while (!name_tokens->empty()) {
if (!ContainsString(name_suffixes, base::size(name_suffixes),
if (!ContainsString(name_suffixes, std::size(name_suffixes),
name_tokens->back())) {
break;
}
@ -223,13 +222,13 @@ bool SplitCJKName(const std::vector<base::StringPiece16>& name_tokens,
// ones)
surname_length = std::max<size_t>(
1, StartsWithAny(name, korean_multi_char_surnames,
base::size(korean_multi_char_surnames)));
std::size(korean_multi_char_surnames)));
} else {
// Default to 1 character if the surname is not in
// |common_cjk_multi_char_surnames|.
surname_length = std::max<size_t>(
1, StartsWithAny(name, common_cjk_multi_char_surnames,
base::size(common_cjk_multi_char_surnames)));
std::size(common_cjk_multi_char_surnames)));
}
parts->family = std::u16string(name.substr(0, surname_length));
parts->given = std::u16string(name.substr(surname_length));
@ -427,7 +426,7 @@ NameParts SplitName(base::StringPiece16 name) {
reverse_family_tokens.push_back(name_tokens.back());
name_tokens.pop_back();
while (name_tokens.size() >= 1 &&
ContainsString(family_name_prefixes, base::size(family_name_prefixes),
ContainsString(family_name_prefixes, std::size(family_name_prefixes),
name_tokens.back())) {
reverse_family_tokens.push_back(name_tokens.back());
name_tokens.pop_back();

@ -5,10 +5,10 @@
#include "components/autofill/core/browser/autofill_ie_toolbar_import_win.h"
#include <stddef.h>
#include <windows.h>
#include <string>
#include "base/cxx17_backports.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
@ -18,8 +18,6 @@
#include "components/os_crypt/os_crypt_mocker.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <windows.h>
using base::win::RegKey;
namespace autofill {
@ -159,13 +157,13 @@ TEST_F(AutofillIeToolbarImportTest, TestAutofillImport) {
profile_key.Create(HKEY_CURRENT_USER, kProfileKey, KEY_ALL_ACCESS);
EXPECT_TRUE(profile_key.Valid());
CreateSubkey(&profile_key, L"0", profile1, base::size(profile1));
CreateSubkey(&profile_key, L"1", profile2, base::size(profile2));
CreateSubkey(&profile_key, L"0", profile1, std::size(profile1));
CreateSubkey(&profile_key, L"1", profile2, std::size(profile2));
RegKey cc_key;
cc_key.Create(HKEY_CURRENT_USER, kCreditCardKey, KEY_ALL_ACCESS);
EXPECT_TRUE(cc_key.Valid());
CreateSubkey(&cc_key, L"0", credit_card, base::size(credit_card));
CreateSubkey(&cc_key, L"0", credit_card, std::size(credit_card));
EncryptAndWrite(&cc_key, &empty_password);
EncryptAndWrite(&cc_key, &empty_salt);

@ -15,7 +15,6 @@
#include "base/base64.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/hash/hash.h"
#include "base/memory/raw_ptr.h"
@ -7542,8 +7541,8 @@ TEST_P(BrowserAutofillManagerStructuredProfileTest,
FormSubmitted(form);
EXPECT_EQ(form.fields.size(), form_seen_by_ahm.fields.size());
ASSERT_EQ(base::size(test_fields), form_seen_by_ahm.fields.size());
for (size_t i = 0; i < base::size(test_fields); ++i) {
ASSERT_EQ(std::size(test_fields), form_seen_by_ahm.fields.size());
for (size_t i = 0; i < std::size(test_fields); ++i) {
EXPECT_EQ(
form_seen_by_ahm.fields[i].should_autocomplete,
test_fields[i].expected_field_type != CREDIT_CARD_VERIFICATION_CODE);

@ -11,7 +11,6 @@
#include <ostream>
#include <set>
#include "base/cxx17_backports.h"
#include "base/guid.h"
#include "base/hash/sha1.h"
#include "base/i18n/case_conversion.h"
@ -166,9 +165,9 @@ void GetFieldsForDistinguishingProfiles(
std::vector<ServerFieldType> default_fields;
if (!suggested_fields) {
default_fields.assign(kDefaultDistinguishingFields,
kDefaultDistinguishingFields +
base::size(kDefaultDistinguishingFields));
default_fields.assign(
kDefaultDistinguishingFields,
kDefaultDistinguishingFields + std::size(kDefaultDistinguishingFields));
if (excluded_field == UNKNOWN_TYPE) {
distinguishing_fields->swap(default_fields);
return;

@ -10,7 +10,6 @@
#include <string>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/format_macros.h"
#include "base/guid.h"
#include "base/strings/utf_string_conversions.h"
@ -307,7 +306,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_CH) {
};
std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
for (size_t i = 0; i < std::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
ASSERT_FALSE(labels.empty());
@ -341,7 +340,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_FR) {
};
std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
for (size_t i = 0; i < std::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
ASSERT_FALSE(labels.empty());
@ -385,7 +384,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_KR) {
};
std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
for (size_t i = 0; i < std::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
ASSERT_FALSE(labels.empty());
@ -422,7 +421,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_JP_Latn) {
};
std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
for (size_t i = 0; i < std::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
ASSERT_FALSE(labels.empty());
@ -455,7 +454,7 @@ TEST_P(AutofillProfileTest, CreateInferredLabelsI18n_JP_ja) {
};
std::vector<std::u16string> labels;
for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
for (size_t i = 0; i < std::size(kExpectedLabels); ++i) {
AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
UNKNOWN_TYPE, i, "en-US", &labels);
ASSERT_FALSE(labels.empty());

@ -11,7 +11,6 @@
#include <utility>
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
@ -220,12 +219,12 @@ std::unique_ptr<FormField> PhoneField::Parse(AutofillScanner* scanner,
// The form owns the following variables, so they should not be deleted.
AutofillField* parsed_fields[FIELD_MAX];
for (size_t i = 0; i < base::size(kPhoneFieldGrammars); ++i) {
for (size_t i = 0; i < std::size(kPhoneFieldGrammars); ++i) {
memset(parsed_fields, 0, sizeof(parsed_fields));
size_t saved_cursor = scanner->SaveCursor();
// Attempt to parse according to the next grammar.
for (; i < base::size(kPhoneFieldGrammars) &&
for (; i < std::size(kPhoneFieldGrammars) &&
kPhoneFieldGrammars[i].regex != REGEX_SEPARATOR;
++i) {
const bool is_country_code_field =
@ -254,7 +253,7 @@ std::unique_ptr<FormField> PhoneField::Parse(AutofillScanner* scanner,
}
}
if (i >= base::size(kPhoneFieldGrammars)) {
if (i >= std::size(kPhoneFieldGrammars)) {
scanner->RewindTo(saved_cursor);
return nullptr; // Parsing failed.
}
@ -264,11 +263,11 @@ std::unique_ptr<FormField> PhoneField::Parse(AutofillScanner* scanner,
// Proceed to the next grammar.
do {
++i;
} while (i < base::size(kPhoneFieldGrammars) &&
} while (i < std::size(kPhoneFieldGrammars) &&
kPhoneFieldGrammars[i].regex != REGEX_SEPARATOR);
scanner->RewindTo(saved_cursor);
if (i + 1 == base::size(kPhoneFieldGrammars)) {
if (i + 1 == std::size(kPhoneFieldGrammars)) {
return nullptr; // Tried through all the possibilities - did not match.
}
}

@ -4720,7 +4720,7 @@ TEST_F(FormStructureTestImpl, EncodeUploadRequest_RichMetadata) {
encoder.Encode(form_signature, FieldSignature(),
RandomizedEncoder::FORM_URL, full_url));
ASSERT_EQ(static_cast<size_t>(upload.field_size()),
base::size(kFieldMetadata));
std::size(kFieldMetadata));
ASSERT_EQ(1, upload.randomized_form_metadata().button_title().size());
EXPECT_EQ(upload.randomized_form_metadata()

@ -6,7 +6,6 @@
#include <utility>
#include "base/cxx17_backports.h"
#include "base/memory/singleton.h"
#include "components/strings/grit/components_strings.h"
#include "third_party/icu/source/common/unicode/locid.h"
@ -293,7 +292,7 @@ const StaticCountryAddressImportRequirementsData
// based on |kCountryAddressImportRequirementsData|.
std::vector<std::string> GetCountryCodes() {
std::vector<std::string> country_codes;
country_codes.reserve(base::size(kCountryAddressImportRequirementsData));
country_codes.reserve(std::size(kCountryAddressImportRequirementsData));
for (const auto& static_data : kCountryAddressImportRequirementsData) {
country_codes.push_back(static_data.country_code);
}

@ -11,7 +11,6 @@
#include <utility>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/guid.h"
@ -248,8 +247,8 @@ TEST_F(AutofillTableTest, Autofill) {
AutofillChange(AutofillChange::REMOVE,
AutofillKey(u"Favorite Color", u"Green")),
};
EXPECT_EQ(base::size(kExpectedChanges), changes.size());
for (size_t i = 0; i < base::size(kExpectedChanges); ++i) {
EXPECT_EQ(std::size(kExpectedChanges), changes.size());
for (size_t i = 0; i < std::size(kExpectedChanges); ++i) {
EXPECT_EQ(kExpectedChanges[i], changes[i]);
}
@ -492,7 +491,7 @@ TEST_F(AutofillTableTest, Autofill_UpdateNullTerminated) {
const char16_t kName[] = u"foo";
const char16_t kValue[] = u"bar";
// A value which contains terminating character.
std::u16string value(kValue, base::size(kValue));
std::u16string value(kValue, std::size(kValue));
AutofillEntry entry0(MakeAutofillEntry(kName, kValue, 1, -1));
AutofillEntry entry1(MakeAutofillEntry(kName, value, 2, 3));

@ -5,7 +5,6 @@
#import <Foundation/Foundation.h>
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/strings/sys_string_conversions.h"
#import "components/autofill/ios/form_util/form_util_java_script_feature.h"
#import "ios/web/public/test/web_test_with_web_state.h"
@ -51,7 +50,7 @@ TEST_F(FillJsTest, GetCanonicalActionForForm) {
{@"javascript:login()", @"javascript:login()"},
};
for (size_t i = 0; i < base::size(test_data); i++) {
for (size_t i = 0; i < std::size(test_data); i++) {
TestData& data = test_data[i];
NSString* html_action =
data.html_action == nil

@ -4,7 +4,6 @@
#include "components/autofill_assistant/browser/string_conversions_util.h"
#include "base/cxx17_backports.h"
#include "base/i18n/char_iterator.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
@ -39,7 +38,7 @@ bool AppendUnicodeToUTF8(const UChar32 source, std::string* target) {
char bytes[4];
UBool error = false;
size_t offset = 0;
U8_APPEND(bytes, offset, base::size(bytes), source, error);
U8_APPEND(bytes, offset, std::size(bytes), source, error);
if (error == false) {
target->append(bytes, offset);
}

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/base32/base32.h"
#include <string>
#include "base/cxx17_backports.h"
#include "components/base32/base32.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace base32 {
@ -19,7 +19,7 @@ TEST(Base32Test, EncodesRfcTestVectorsCorrectlyWithoutPadding) {
"", "MY", "MZXQ", "MZXW6", "MZXW6YQ", "MZXW6YTB", "MZXW6YTBOI"};
// Run the tests, with one more letter in the input every pass.
for (size_t i = 0; i < base::size(expected); ++i) {
for (size_t i = 0; i < std::size(expected); ++i) {
base::StringPiece test_substr(test_str, i);
std::string encoded_output =
Base32Encode(test_substr, Base32EncodePolicy::OMIT_PADDING);
@ -38,7 +38,7 @@ TEST(Base32Test, EncodesRfcTestVectorsCorrectlyWithPadding) {
"MZXW6YQ=", "MZXW6YTB", "MZXW6YTBOI======"};
// Run the tests, with one more letter in the input every pass.
for (size_t i = 0; i < base::size(expected); ++i) {
for (size_t i = 0; i < std::size(expected); ++i) {
base::StringPiece test_substr(test_str, i);
std::string encoded_output = Base32Encode(test_substr);
EXPECT_EQ(expected[i], encoded_output);

@ -14,7 +14,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/cxx17_backports.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
@ -1113,7 +1112,7 @@ TEST_F(OptOutBlocklistTest, PassedReasonsWhenUserBlocklisted) {
BlocklistReason::kBlocklistNotLoaded,
BlocklistReason::kUserOptedOutInSession,
};
EXPECT_EQ(base::size(expected_reasons), passed_reasons_.size());
EXPECT_EQ(std::size(expected_reasons), passed_reasons_.size());
for (size_t i = 0; i < passed_reasons_.size(); i++) {
EXPECT_EQ(expected_reasons[i], passed_reasons_[i]);
}
@ -1150,7 +1149,7 @@ TEST_F(OptOutBlocklistTest, PassedReasonsWhenHostBlocklisted) {
BlocklistReason::kUserOptedOutInSession,
BlocklistReason::kUserOptedOutInGeneral,
};
EXPECT_EQ(base::size(expected_reasons), passed_reasons_.size());
EXPECT_EQ(std::size(expected_reasons), passed_reasons_.size());
for (size_t i = 0; i < passed_reasons_.size(); i++) {
EXPECT_EQ(expected_reasons[i], passed_reasons_[i]);
}
@ -1189,7 +1188,7 @@ TEST_F(OptOutBlocklistTest, PassedReasonsWhenAllowed) {
BlocklistReason::kUserOptedOutOfHost,
BlocklistReason::kUserOptedOutOfType,
};
EXPECT_EQ(base::size(expected_reasons), passed_reasons_.size());
EXPECT_EQ(std::size(expected_reasons), passed_reasons_.size());
for (size_t i = 0; i < passed_reasons_.size(); i++) {
EXPECT_EQ(expected_reasons[i], passed_reasons_[i]);
}

@ -573,7 +573,7 @@ TEST_F(BookmarkModelTest, AddURLWithUnicodeTitle) {
}
TEST_F(BookmarkModelTest, AddURLWithWhitespaceTitle) {
for (size_t i = 0; i < base::size(url_whitespace_test_cases); ++i) {
for (size_t i = 0; i < std::size(url_whitespace_test_cases); ++i) {
const BookmarkNode* root = model_->bookmark_bar_node();
const std::u16string title(
ASCIIToUTF16(url_whitespace_test_cases[i].input_title));
@ -700,7 +700,7 @@ TEST_F(BookmarkModelTest, AddFolderWithGUID) {
}
TEST_F(BookmarkModelTest, AddFolderWithWhitespaceTitle) {
for (size_t i = 0; i < base::size(title_whitespace_test_cases); ++i) {
for (size_t i = 0; i < std::size(title_whitespace_test_cases); ++i) {
const BookmarkNode* root = model_->bookmark_bar_node();
const std::u16string title(
ASCIIToUTF16(title_whitespace_test_cases[i].input_title));
@ -822,7 +822,7 @@ TEST_F(BookmarkModelTest, SetTitle) {
}
TEST_F(BookmarkModelTest, SetTitleWithWhitespace) {
for (size_t i = 0; i < base::size(title_whitespace_test_cases); ++i) {
for (size_t i = 0; i < std::size(title_whitespace_test_cases); ++i) {
const BookmarkNode* root = model_->bookmark_bar_node();
std::u16string title(u"dummy");
const GURL url("http://foo.com");
@ -1612,7 +1612,7 @@ TEST(BookmarkModelTest2, CreateAndRestore) {
{ "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"},
};
std::unique_ptr<BookmarkModel> model;
for (size_t i = 0; i < base::size(data); ++i) {
for (size_t i = 0; i < std::size(data); ++i) {
model = TestBookmarkClient::CreateModel();
TestNode bbn;

@ -10,7 +10,6 @@
#include <utility>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
@ -225,7 +224,7 @@ TEST_F(BookmarkUtilsTest, GetBookmarksMatchingPropertiesConjunction) {
&query.url, &query.title};
// Test two fields matching.
for (size_t i = 0; i < base::size(fields); i++) {
for (size_t i = 0; i < std::size(fields); i++) {
std::unique_ptr<std::u16string> original_value(fields[i]->release());
GetBookmarksMatchingProperties(model.get(), query, 100, &nodes);
ASSERT_EQ(1U, nodes.size());
@ -235,7 +234,7 @@ TEST_F(BookmarkUtilsTest, GetBookmarksMatchingPropertiesConjunction) {
}
// Test two fields matching with one non-matching field.
for (size_t i = 0; i < base::size(fields); i++) {
for (size_t i = 0; i < std::size(fields); i++) {
std::unique_ptr<std::u16string> original_value(fields[i]->release());
*fields[i] = std::make_unique<std::u16string>(u"fjdkslafjkldsa");
GetBookmarksMatchingProperties(model.get(), query, 100, &nodes);

@ -5,7 +5,6 @@
#include "components/captive_portal/core/captive_portal_types.h"
#include "base/check_op.h"
#include "base/cxx17_backports.h"
namespace captive_portal {
@ -17,7 +16,7 @@ const char* const kCaptivePortalResultNames[] = {
"BehindCaptivePortal",
"NumCaptivePortalResults",
};
static_assert(base::size(kCaptivePortalResultNames) == RESULT_COUNT + 1,
static_assert(std::size(kCaptivePortalResultNames) == RESULT_COUNT + 1,
"kCaptivePortalResultNames should have "
"RESULT_COUNT + 1 elements");
@ -26,7 +25,7 @@ static_assert(base::size(kCaptivePortalResultNames) == RESULT_COUNT + 1,
std::string CaptivePortalResultToString(CaptivePortalResult result) {
DCHECK_GE(result, 0);
DCHECK_LT(static_cast<unsigned int>(result),
base::size(kCaptivePortalResultNames));
std::size(kCaptivePortalResultNames));
return kCaptivePortalResultNames[result];
}

@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cbor/reader.h"
#include <limits>
#include <utility>
#include "components/cbor/reader.h"
#include "base/containers/span.h"
#include "base/cxx17_backports.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -743,7 +742,7 @@ TEST(CBORReaderTest, TestReadMapWithMixedKeys) {
ASSERT_EQ(cbor->type(), Value::Type::MAP);
ASSERT_EQ(cbor->GetMap().size(), 6u);
EXPECT_EQ(error_code, Reader::DecoderError::CBOR_NO_ERROR);
EXPECT_EQ(num_bytes_consumed, base::size(kMapTestCase));
EXPECT_EQ(num_bytes_consumed, std::size(kMapTestCase));
}
TEST(CBORReaderTest, TestReadNestedMap) {

@ -7,7 +7,6 @@
#include <limits>
#include <string>
#include "base/cxx17_backports.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -135,7 +134,7 @@ TEST(CBORWriterTest, TestWriteArray) {
ASSERT_TRUE(cbor.has_value());
EXPECT_THAT(cbor.value(),
testing::ElementsAreArray(kArrayTestCaseCbor,
base::size(kArrayTestCaseCbor)));
std::size(kArrayTestCaseCbor)));
}
TEST(CBORWriterTest, TestWriteMap) {
@ -258,9 +257,8 @@ TEST(CBORWriterTest, TestWriteMap) {
map[Value(std::numeric_limits<int64_t>::max())] = Value("j");
auto cbor = Writer::Write(Value(map));
ASSERT_TRUE(cbor.has_value());
EXPECT_THAT(cbor.value(),
testing::ElementsAreArray(kMapTestCaseCbor,
base::size(kMapTestCaseCbor)));
EXPECT_THAT(cbor.value(), testing::ElementsAreArray(
kMapTestCaseCbor, std::size(kMapTestCaseCbor)));
}
TEST(CBORWriterTest, TestWriteMapWithArray) {
@ -286,7 +284,7 @@ TEST(CBORWriterTest, TestWriteMapWithArray) {
ASSERT_TRUE(cbor.has_value());
EXPECT_THAT(cbor.value(),
testing::ElementsAreArray(kMapArrayTestCaseCbor,
base::size(kMapArrayTestCaseCbor)));
std::size(kMapArrayTestCaseCbor)));
}
TEST(CBORWriterTest, TestWriteNestedMap) {
@ -315,7 +313,7 @@ TEST(CBORWriterTest, TestWriteNestedMap) {
ASSERT_TRUE(cbor.has_value());
EXPECT_THAT(cbor.value(),
testing::ElementsAreArray(kNestedMapTestCase,
base::size(kNestedMapTestCase)));
std::size(kNestedMapTestCase)));
}
TEST(CBORWriterTest, TestSignedExchangeExample) {
@ -362,7 +360,7 @@ TEST(CBORWriterTest, TestSignedExchangeExample) {
ASSERT_TRUE(cbor.has_value());
EXPECT_THAT(cbor.value(),
testing::ElementsAreArray(kSignedExchangeExample,
base::size(kSignedExchangeExample)));
std::size(kSignedExchangeExample)));
}
TEST(CBORWriterTest, TestWriteSimpleValue) {

@ -4,7 +4,6 @@
#include "components/cdm/common/widevine_drm_delegate_android.h"
#include "base/cxx17_backports.h"
#include "media/cdm/cenc_utils.h"
namespace cdm {
@ -23,7 +22,7 @@ WidevineDrmDelegateAndroid::~WidevineDrmDelegateAndroid() {}
const std::vector<uint8_t> WidevineDrmDelegateAndroid::GetUUID() const {
return std::vector<uint8_t>(kWidevineUuid,
kWidevineUuid + base::size(kWidevineUuid));
kWidevineUuid + std::size(kWidevineUuid));
}
bool WidevineDrmDelegateAndroid::OnCreateSession(

@ -9,7 +9,6 @@
#include <utility>
#include "base/build_time.h"
#include "base/cxx17_backports.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
@ -42,7 +41,7 @@ namespace {
const char kGoogleAviatorLogID[] =
"\x68\xf6\x98\xf8\x1f\x64\x82\xbe\x3a\x8c\xee\xb9\x28\x1d\x4c\xfc\x71\x51"
"\x5d\x67\x93\xd4\x44\xd1\x0a\x67\xac\xbb\x4f\x4f\xfb\xc4";
static_assert(base::size(kGoogleAviatorLogID) - 1 == crypto::kSHA256Length,
static_assert(std::size(kGoogleAviatorLogID) - 1 == crypto::kSHA256Length,
"Incorrect log ID length.");
} // namespace
@ -98,7 +97,7 @@ class ChromeCTPolicyEnforcerTest : public ::testing::Test {
static const char kCertlyLogID[] =
"\xcd\xb5\x17\x9b\x7f\xc1\xc0\x46\xfe\xea\x31\x13\x6a\x3f\x8f\x00\x2e"
"\x61\x82\xfa\xf8\x89\x6f\xec\xc8\xb2\xf5\xb5\xab\x60\x49\x00";
static_assert(base::size(kCertlyLogID) - 1 == crypto::kSHA256Length,
static_assert(std::size(kCertlyLogID) - 1 == crypto::kSHA256Length,
"Incorrect log ID length.");
scoped_refptr<SignedCertificateTimestamp> sct(
@ -261,7 +260,7 @@ TEST_F(ChromeCTPolicyEnforcerTestPre2022Policy,
{// Cert valid for over 39 months, needs 5 SCTs.
time_2015_3_0_25_11_25_0_0, time_2018_6_0_27_11_25_0_0, 5}};
for (size_t i = 0; i < base::size(kTestData); ++i) {
for (size_t i = 0; i < std::size(kTestData); ++i) {
SCOPED_TRACE(i);
const base::Time& start = kTestData[i].validity_start;
const base::Time& end = kTestData[i].validity_end;
@ -869,7 +868,7 @@ TEST_F(ChromeCTPolicyEnforcerTest2022PolicyAllCerts, UpdatedSCTRequirements) {
{// Cert valid for over 180 days, needs 3 SCTs.
time_2015_3_0_25_11_25_0_0, time_2016_3_0_25_11_25_0_0, 3}};
for (size_t i = 0; i < base::size(kTestData); ++i) {
for (size_t i = 0; i < std::size(kTestData); ++i) {
SCOPED_TRACE(i);
const base::Time& validity_start = kTestData[i].validity_start;
const base::Time& validity_end = kTestData[i].validity_end;

@ -7,7 +7,6 @@
#include <stdint.h>
#include "base/base64url.h"
#include "base/cxx17_backports.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
@ -52,7 +51,7 @@ bool ParseETagHeader(const base::StringPiece& etag_header_value_in,
// Remove the weak prefix, then remove the begin and the end quotes.
const char kWeakETagPrefix[] = "W/";
if (base::StartsWith(etag_header_value, kWeakETagPrefix))
etag_header_value.remove_prefix(base::size(kWeakETagPrefix) - 1);
etag_header_value.remove_prefix(std::size(kWeakETagPrefix) - 1);
if (etag_header_value.size() >= 2 &&
base::StartsWith(etag_header_value, "\"") &&
base::EndsWith(etag_header_value, "\"")) {

@ -13,7 +13,6 @@
#include <vector>
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/notreached.h"
@ -236,7 +235,7 @@ constexpr int32_t kInchToUm = 25400;
constexpr int32_t kMmToUm = 1000;
constexpr int32_t kSizeThresholdUm = 1000;
constexpr size_t kEnumClassPrefixLen = base::size("MediaType::") - 1;
constexpr size_t kEnumClassPrefixLen = std::size("MediaType::") - 1;
// Json name of media type is constructed by removing "MediaType::" enum class
// prefix from it.
@ -439,7 +438,7 @@ constexpr struct MediaDefinition {
#undef MAP_CLOUD_PRINT_MEDIA_TYPE
const MediaDefinition& FindMediaByType(MediaType type) {
for (size_t i = 0; i < base::size(kMediaDefinitions); ++i) {
for (size_t i = 0; i < std::size(kMediaDefinitions); ++i) {
if (kMediaDefinitions[i].id == type)
return kMediaDefinitions[i];
}
@ -449,7 +448,7 @@ const MediaDefinition& FindMediaByType(MediaType type) {
const MediaDefinition* FindMediaBySize(int32_t width_um, int32_t height_um) {
const MediaDefinition* result = nullptr;
for (size_t i = 0; i < base::size(kMediaDefinitions); ++i) {
for (size_t i = 0; i < std::size(kMediaDefinitions); ++i) {
int32_t diff =
std::max(std::abs(width_um - kMediaDefinitions[i].width_um),
std::abs(height_um - kMediaDefinitions[i].height_um));
@ -461,7 +460,7 @@ const MediaDefinition* FindMediaBySize(int32_t width_um, int32_t height_um) {
template <class T, class IdType>
std::string TypeToString(const T& names, IdType id) {
for (size_t i = 0; i < base::size(names); ++i) {
for (size_t i = 0; i < std::size(names); ++i) {
if (id == names[i].id)
return names[i].json_name;
}
@ -471,7 +470,7 @@ std::string TypeToString(const T& names, IdType id) {
template <class T, class IdType>
bool TypeFromString(const T& names, const std::string& type, IdType* id) {
for (size_t i = 0; i < base::size(names); ++i) {
for (size_t i = 0; i < std::size(names); ++i) {
if (type == names[i].json_name) {
*id = names[i].id;
return true;

@ -5,7 +5,6 @@
#ifndef COMPONENTS_COMMERCE_CORE_COMMERCE_FEATURE_LIST_H_
#define COMPONENTS_COMMERCE_CORE_COMMERCE_FEATURE_LIST_H_
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "components/flags_ui/feature_entry.h"
@ -34,13 +33,13 @@ constexpr flags_ui::FeatureEntry::FeatureParam
constexpr flags_ui::FeatureEntry::FeatureVariation
kCommercePriceTrackingAndroidVariations[] = {
{"Price alerts", kCommercePriceTracking_PriceAlerts,
base::size(kCommercePriceTracking_PriceAlerts), nullptr},
std::size(kCommercePriceTracking_PriceAlerts), nullptr},
{"Price alerts with OptimizationGuide",
kCommercePriceTracking_PriceAlerts_WithOptimizationGuide,
base::size(kCommercePriceTracking_PriceAlerts_WithOptimizationGuide),
std::size(kCommercePriceTracking_PriceAlerts_WithOptimizationGuide),
nullptr},
{"Price notifications", kCommercePriceTracking_PriceNotifications,
base::size(kCommercePriceTracking_PriceNotifications), nullptr},
std::size(kCommercePriceTracking_PriceNotifications), nullptr},
};
// Price tracking variations for iOS.
@ -58,10 +57,10 @@ constexpr flags_ui::FeatureEntry::FeatureVariation
kCommercePriceTrackingVariations[] = {
{"Price Tracking with Optimization Guide",
kCommercePriceTrackingWithOptimizationGuide,
base::size(kCommercePriceTrackingWithOptimizationGuide), nullptr},
std::size(kCommercePriceTrackingWithOptimizationGuide), nullptr},
{"Price Tracking with Optimization Guide and Opt Out",
kCommercePriceTrackingWithOptimizationGuideAndOptOut,
base::size(kCommercePriceTrackingWithOptimizationGuideAndOptOut),
std::size(kCommercePriceTrackingWithOptimizationGuideAndOptOut),
nullptr}};
extern const base::Feature kCommerceMerchantViewer;

@ -64,7 +64,7 @@ void ClientSidePhishingComponentInstallerPolicy::GetPublicHash(
std::vector<uint8_t>* hash) {
hash->assign(kClientSidePhishingPublicKeySHA256,
kClientSidePhishingPublicKeySHA256 +
base::size(kClientSidePhishingPublicKeySHA256));
std::size(kClientSidePhishingPublicKeySHA256));
}
bool ClientSidePhishingComponentInstallerPolicy::

@ -8,7 +8,6 @@
#include <utility>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
@ -119,7 +118,7 @@ void SafetyTipsComponentInstallerPolicy::GetHash(
std::vector<uint8_t>* hash) const {
hash->assign(
kSafetyTipsPublicKeySHA256,
kSafetyTipsPublicKeySHA256 + base::size(kSafetyTipsPublicKeySHA256));
kSafetyTipsPublicKeySHA256 + std::size(kSafetyTipsPublicKeySHA256));
}
std::string SafetyTipsComponentInstallerPolicy::GetName() const {

@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
@ -152,7 +151,7 @@ void TrustTokenKeyCommitmentsComponentInstallerPolicy::GetPublicKeyHash(
DCHECK(hash);
hash->assign(kTrustTokenKeyCommitmentsPublicKeySHA256,
kTrustTokenKeyCommitmentsPublicKeySHA256 +
base::size(kTrustTokenKeyCommitmentsPublicKeySHA256));
std::size(kTrustTokenKeyCommitmentsPublicKeySHA256));
}
// static

@ -36,20 +36,20 @@ std::vector<std::string> AllowlistedSchemes() {
std::vector<std::string> AllowlistedSchemes(const char* scheme1) {
const char* schemes[] = {scheme1};
return std::vector<std::string>(schemes, schemes + base::size(schemes));
return std::vector<std::string>(schemes, schemes + std::size(schemes));
}
std::vector<std::string> AllowlistedSchemes(const char* scheme1,
const char* scheme2) {
const char* schemes[] = {scheme1, scheme2};
return std::vector<std::string>(schemes, schemes + base::size(schemes));
return std::vector<std::string>(schemes, schemes + std::size(schemes));
}
std::vector<std::string> AllowlistedSchemes(const char* scheme1,
const char* scheme2,
const char* scheme3) {
const char* schemes[] = {scheme1, scheme2, scheme3};
return std::vector<std::string>(schemes, schemes + base::size(schemes));
return std::vector<std::string>(schemes, schemes + std::size(schemes));
}
std::set<ContentSetting> ValidSettings() {
@ -59,14 +59,14 @@ std::set<ContentSetting> ValidSettings() {
std::set<ContentSetting> ValidSettings(ContentSetting setting1,
ContentSetting setting2) {
ContentSetting settings[] = {setting1, setting2};
return std::set<ContentSetting>(settings, settings + base::size(settings));
return std::set<ContentSetting>(settings, settings + std::size(settings));
}
std::set<ContentSetting> ValidSettings(ContentSetting setting1,
ContentSetting setting2,
ContentSetting setting3) {
ContentSetting settings[] = {setting1, setting2, setting3};
return std::set<ContentSetting>(settings, settings + base::size(settings));
return std::set<ContentSetting>(settings, settings + std::size(settings));
}
std::set<ContentSetting> ValidSettings(ContentSetting setting1,
@ -74,7 +74,7 @@ std::set<ContentSetting> ValidSettings(ContentSetting setting1,
ContentSetting setting3,
ContentSetting setting4) {
ContentSetting settings[] = {setting1, setting2, setting3, setting4};
return std::set<ContentSetting>(settings, settings + base::size(settings));
return std::set<ContentSetting>(settings, settings + std::size(settings));
}
} // namespace

@ -8,7 +8,6 @@
#include <vector>
#include "base/cxx17_backports.h"
#include "base/notreached.h"
#include "base/strings/string_split.h"
#include "base/values.h"
@ -32,7 +31,7 @@ const ContentSettingsStringMapping kContentSettingsStringMapping[] = {
{CONTENT_SETTING_SESSION_ONLY, "session_only"},
{CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, "detect_important_content"},
};
static_assert(base::size(kContentSettingsStringMapping) ==
static_assert(std::size(kContentSettingsStringMapping) ==
CONTENT_SETTING_NUM_SETTINGS,
"kContentSettingsToFromString should have "
"CONTENT_SETTING_NUM_SETTINGS elements");
@ -51,7 +50,7 @@ const ContentSetting kContentSettingOrder[] = {
CONTENT_SETTING_BLOCK
};
static_assert(base::size(kContentSettingOrder) ==
static_assert(std::size(kContentSettingOrder) ==
CONTENT_SETTING_NUM_SETTINGS - 1,
"kContentSettingOrder should have CONTENT_SETTING_NUM_SETTINGS-1"
"entries");

@ -8,7 +8,6 @@
#include <string>
#include "base/cxx17_backports.h"
#include "components/content_settings/core/test/content_settings_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -24,7 +23,7 @@ const char* const kContentSettingNames[] = {
"session_only",
"detect_important_content",
};
static_assert(base::size(kContentSettingNames) == CONTENT_SETTING_NUM_SETTINGS,
static_assert(std::size(kContentSettingNames) == CONTENT_SETTING_NUM_SETTINGS,
"kContentSettingNames has an unexpected number of elements");
} // namespace
@ -68,7 +67,7 @@ TEST(ContentSettingsUtilsTest, ContentSettingsStringMap) {
ContentSettingToString(CONTENT_SETTING_NUM_SETTINGS);
EXPECT_TRUE(setting_string.empty());
for (size_t i = 0; i < base::size(kContentSettingNames); ++i) {
for (size_t i = 0; i < std::size(kContentSettingNames); ++i) {
ContentSetting setting = static_cast<ContentSetting>(i);
setting_string = ContentSettingToString(setting);
EXPECT_EQ(kContentSettingNames[i], setting_string);

@ -13,7 +13,6 @@
#include "base/check.h"
#include "base/command_line.h"
#include "base/containers/flat_map.h"
#include "base/cxx17_backports.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
@ -83,7 +82,7 @@ constexpr ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = {
};
static_assert(
base::size(kProviderNamesSourceMap) ==
std::size(kProviderNamesSourceMap) ==
HostContentSettingsMap::NUM_PROVIDER_TYPES,
"kProviderNamesSourceMap should have NUM_PROVIDER_TYPES elements");
@ -862,7 +861,7 @@ base::Value HostContentSettingsMap::GetWebsiteSetting(
// static
HostContentSettingsMap::ProviderType
HostContentSettingsMap::GetProviderTypeFromSource(const std::string& source) {
for (size_t i = 0; i < base::size(kProviderNamesSourceMap); ++i) {
for (size_t i = 0; i < std::size(kProviderNamesSourceMap); ++i) {
if (source == kProviderNamesSourceMap[i].provider_name)
return static_cast<ProviderType>(i);
}

@ -9,7 +9,6 @@
#include <utility>
#include "base/check_op.h"
#include "base/cxx17_backports.h"
#include "base/notreached.h"
#include "build/build_config.h"
#include "components/content_settings/core/common/content_settings_utils.h"
@ -116,7 +115,7 @@ ContentSetting IntToContentSetting(int content_setting) {
int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting,
size_t* num_values) {
*num_values = base::size(kHistogramValue);
*num_values = std::size(kHistogramValue);
// Verify the array is sorted by enum type and contains all values.
DCHECK(std::is_sorted(std::begin(kHistogramValue), std::end(kHistogramValue),
@ -124,7 +123,7 @@ int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting,
return a.type < b.type;
}));
static_assert(
kHistogramValue[base::size(kHistogramValue) - 1].type ==
kHistogramValue[std::size(kHistogramValue) - 1].type ==
ContentSettingsType(
static_cast<int32_t>(ContentSettingsType::NUM_TYPES) - 1),
"Update content settings histogram lookup");

@ -11,7 +11,6 @@
#include <utility>
#include "base/check_op.h"
#include "base/cxx17_backports.h"
#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/string_piece.h"
@ -38,7 +37,7 @@ const char* const kSchemeNames[] = {"wildcard", "other",
"chrome-search", "chrome",
"chrome-untrusted", "devtools"};
static_assert(base::size(kSchemeNames) == ContentSettingsPattern::SCHEME_MAX,
static_assert(std::size(kSchemeNames) == ContentSettingsPattern::SCHEME_MAX,
"kSchemeNames should have SCHEME_MAX elements");
// Note: it is safe to return a base::StringPiece here as long as they are
@ -555,7 +554,7 @@ ContentSettingsPattern::SchemeType ContentSettingsPattern::GetScheme() const {
if (parts_.is_scheme_wildcard)
return SCHEME_WILDCARD;
for (size_t i = 2; i < base::size(kSchemeNames); ++i) {
for (size_t i = 2; i < std::size(kSchemeNames); ++i) {
if (parts_.scheme == kSchemeNames[i])
return static_cast<SchemeType>(i);
}

@ -6,7 +6,6 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/cxx17_backports.h"
#include "components/crash/android/jni_headers/CrashKeys_jni.h"
#include "components/crash/core/common/crash_key.h"
@ -26,7 +25,7 @@ JavaCrashKey& GetCrashKey(int index) {
{"partner_customization_config", JavaCrashKey::Tag::kArray},
};
static_assert(
base::size(crash_keys) == static_cast<size_t>(CrashKeyIndex::NUM_ENTRIES),
std::size(crash_keys) == static_cast<size_t>(CrashKeyIndex::NUM_ENTRIES),
"crash_keys out of sync with index enum");
return crash_keys[index];

@ -4,13 +4,14 @@
#include "components/crash/content/app/breakpad_win.h"
#include <tchar.h>
#include <windows.h>
#include <crtdbg.h>
#include <intrin.h>
#include <shellapi.h>
#include <stddef.h>
#include <tchar.h>
#include <userenv.h>
#include <windows.h>
#include <winnt.h>
#include <algorithm>
@ -21,7 +22,6 @@
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/environment.h"
@ -197,7 +197,7 @@ std::wstring GetProfileType() {
{ PT_ROAMING, L"roaming" },
{ PT_TEMPORARY, L"temporary" },
};
for (size_t i = 0; i < base::size(kBitNames); ++i) {
for (size_t i = 0; i < std::size(kBitNames); ++i) {
const DWORD this_bit = kBitNames[i].bit;
if ((profile_bits & this_bit) != 0) {
profile_type.append(kBitNames[i].name);

@ -17,7 +17,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
@ -580,7 +579,7 @@ bool CrashHandlerHost::ReceiveClientMessage(int client_fd,
msg.msg_name = nullptr;
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = base::size(iov);
msg.msg_iovlen = std::size(iov);
char cmsg_buf[CMSG_SPACE(sizeof(int)) + CMSG_SPACE(sizeof(ucred))];
msg.msg_control = cmsg_buf;

@ -18,7 +18,6 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/path_utils.h"
#include "base/cxx17_backports.h"
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
@ -211,7 +210,7 @@ class SandboxedHandler {
msg.msg_name = nullptr;
msg.msg_namelen = 0;
msg.msg_iov = iov;
msg.msg_iovlen = base::size(iov);
msg.msg_iovlen = std::size(iov);
char cmsg_buf[CMSG_SPACE(sizeof(int))];
msg.msg_control = cmsg_buf;

@ -7,7 +7,6 @@
#include <memory>
#include <string>
#include "base/cxx17_backports.h"
#include "base/debug/crash_logging.h"
#include "base/environment.h"
#include "base/files/file_util.h"
@ -32,7 +31,7 @@ void GetPlatformCrashpadAnnotations(
std::map<std::string, std::string>* annotations) {
CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
wchar_t exe_file[MAX_PATH] = {};
CHECK(::GetModuleFileName(nullptr, exe_file, base::size(exe_file)));
CHECK(::GetModuleFileName(nullptr, exe_file, std::size(exe_file)));
std::wstring product_name, version, special_build, channel_name;
crash_reporter_client->GetProductNameAndVersion(
exe_file, &product_name, &version, &special_build, &channel_name);
@ -100,7 +99,7 @@ bool PlatformCrashpadInitialization(
if (exe_file.empty()) {
wchar_t exe_file_path[MAX_PATH] = {};
CHECK(::GetModuleFileName(nullptr, exe_file_path,
base::size(exe_file_path)));
std::size(exe_file_path)));
exe_file = base::FilePath(exe_file_path);
}

@ -8,7 +8,6 @@
#include <utility>
#include <vector>
#include "base/cxx17_backports.h"
#include "base/i18n/time_formatting.h"
#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
@ -43,7 +42,7 @@ const CrashesUILocalizedString kCrashesUILocalizedStrings[] = {
};
const size_t kCrashesUILocalizedStringsCount =
base::size(kCrashesUILocalizedStrings);
std::size(kCrashesUILocalizedStrings);
const char kCrashesUICrashesJS[] = "crashes.js";
const char kCrashesUICrashesCSS[] = "crashes.css";

@ -4,7 +4,6 @@
#include "components/crash/core/common/crash_key.h"
#include "base/cxx17_backports.h"
#include "base/debug/crash_logging.h"
#include "base/debug/stack_trace.h"
#include "build/build_config.h"
@ -38,7 +37,7 @@ TEST_F(CrashKeyStringTest, FormatStackTrace) {
0x0badbeef, 0x77778888, 0xabc, 0x000ddeeff, 0x12345678,
};
base::debug::StackTrace trace(reinterpret_cast<const void* const*>(addresses),
base::size(addresses));
std::size(addresses));
std::string too_small = internal::FormatStackTrace(trace, 3);
EXPECT_EQ(0u, too_small.size());
@ -59,7 +58,7 @@ TEST_F(CrashKeyStringTest, FormatStackTrace64) {
0xbaaaabaaaaba, 0x1000000000000000,
};
base::debug::StackTrace trace(reinterpret_cast<const void* const*>(addresses),
base::size(addresses));
std::size(addresses));
std::string too_small = internal::FormatStackTrace(trace, 8);
EXPECT_EQ(0u, too_small.size());

@ -8,7 +8,6 @@
#include <vector>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/format_macros.h"
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
@ -119,7 +118,7 @@ static PrinterInfoKey printer_info_keys[] = {
ScopedPrinterInfo::ScopedPrinterInfo(base::StringPiece data) {
std::vector<base::StringPiece> info = base::SplitStringPiece(
data, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
for (size_t i = 0; i < base::size(printer_info_keys); ++i) {
for (size_t i = 0; i < std::size(printer_info_keys); ++i) {
if (i < info.size())
printer_info_keys[i].Set(info[i]);
else

@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
@ -611,7 +610,7 @@ TEST_F(StaleHostResolverTest, MAYBE_StaleUsability) {
SetStaleDelay(kNoStaleDelaySec);
for (size_t i = 0; i < base::size(kUsabilityTestCases); ++i) {
for (size_t i = 0; i < std::size(kUsabilityTestCases); ++i) {
const auto& test_case = kUsabilityTestCases[i];
SetStaleUsability(test_case.max_expired_time_sec, test_case.max_stale_uses,

@ -4,7 +4,6 @@
#include "components/crx_file/crx_creator.h"
#include "base/cxx17_backports.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "components/crx_file/crx3.pb.h"
@ -32,7 +31,7 @@ CreatorResult ReadAndSignArchive(base::File* file,
int read = 0;
static_assert(sizeof(char) == sizeof(uint8_t), "Unsupported char size.");
while ((read = file->ReadAtCurrentPos(reinterpret_cast<char*>(buffer),
base::size(buffer))) > 0) {
std::size(buffer))) > 0) {
if (!signer->Update(buffer, read))
return CreatorResult::ERROR_SIGNING_FAILURE;
}
@ -50,7 +49,7 @@ bool WriteArchive(base::File* out, base::File* in) {
char buffer[1 << 12] = {};
int read = 0;
in->Seek(base::File::Whence::FROM_BEGIN, 0);
while ((read = in->ReadAtCurrentPos(buffer, base::size(buffer))) > 0) {
while ((read = in->ReadAtCurrentPos(buffer, std::size(buffer))) > 0) {
if (out->WriteAtCurrentPos(buffer, read) != read)
return false;
}
@ -82,9 +81,9 @@ CreatorResult SignArchiveAndCreateHeader(const base::FilePath& output_path,
// through, run ZIP through.
auto signer = crypto::SignatureCreator::Create(
signing_key, crypto::SignatureCreator::HashAlgorithm::SHA256);
signer->Update(kSignatureContext, base::size(kSignatureContext));
signer->Update(kSignatureContext, std::size(kSignatureContext));
signer->Update(signed_header_size_octets,
base::size(signed_header_size_octets));
std::size(signed_header_size_octets));
signer->Update(
reinterpret_cast<const uint8_t*>(signed_header_data_str.data()),
signed_header_data_str.size());
@ -121,9 +120,9 @@ CreatorResult WriteCRX(const CrxFileHeader& header,
static_assert(sizeof(char) == sizeof(uint8_t), "Unsupported char size.");
if (!WriteBuffer(&crx, kCrxFileHeaderMagic, kCrxFileHeaderMagicSize) ||
!WriteBuffer(&crx, reinterpret_cast<const char*>(format_version_octets),
base::size(format_version_octets)) ||
std::size(format_version_octets)) ||
!WriteBuffer(&crx, reinterpret_cast<const char*>(header_size_octets),
base::size(header_size_octets)) ||
std::size(header_size_octets)) ||
!WriteBuffer(&crx, header_str.c_str(), header_str.length()) ||
!WriteArchive(&crx, file)) {
return CreatorResult::ERROR_FILE_WRITE_FAILURE;

@ -14,7 +14,6 @@
#include "base/base64.h"
#include "base/bind.h"
#include "base/callback.h"
#include "base/cxx17_backports.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/numerics/safe_conversions.h"
@ -75,8 +74,7 @@ bool ReadHashAndVerifyArchive(base::File* file,
const VerifierCollection& verifiers) {
uint8_t buffer[1 << 12] = {};
size_t len = 0;
while ((len = ReadAndHashBuffer(buffer, base::size(buffer), file, hash)) >
0) {
while ((len = ReadAndHashBuffer(buffer, std::size(buffer), file, hash)) > 0) {
for (auto& verifier : verifiers)
verifier->VerifyUpdate(base::make_span(buffer, len));
}

@ -6,7 +6,6 @@
#include <stdint.h>
#include "base/cxx17_backports.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace crx_file {
@ -30,7 +29,7 @@ TEST(IDUtilTest, GenerateID) {
0x0f, 0x02, 0x03, 0x01, 0x00, 0x01};
std::string extension_id =
GenerateId(std::string(reinterpret_cast<const char*>(&public_key_info[0]),
base::size(public_key_info)));
std::size(public_key_info)));
EXPECT_EQ("melddjfinppjdikinhbgehiennejpfhp", extension_id);
EXPECT_EQ("daibjpdaanagajckigeiigphanababab",

@ -151,10 +151,10 @@ DbusMenu::DbusMenu(dbus::ExportedObject* exported_object,
{kMethodGetProperty, &DbusMenu::OnGetProperty},
};
// base::size(methods) calls for method export, 1 call for properties
// std::size(methods) calls for method export, 1 call for properties
// initialization.
barrier_ =
SuccessBarrierCallback(base::size(methods) + 1, std::move(callback));
SuccessBarrierCallback(std::size(methods) + 1, std::move(callback));
for (const auto& method : methods) {
menu_->ExportMethod(
kInterfaceDbusMenu, method.name,

@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/containers/contains.h"
#include "base/cxx17_backports.h"
#include "components/dbus/properties/success_barrier_callback.h"
#include "dbus/exported_object.h"
#include "dbus/message.h"
@ -38,7 +37,7 @@ DbusProperties::DbusProperties(dbus::ExportedObject* exported_object,
{kMethodPropertiesSet, &DbusProperties::OnSetProperty},
};
barrier_ = SuccessBarrierCallback(base::size(methods), std::move(callback));
barrier_ = SuccessBarrierCallback(std::size(methods), std::move(callback));
for (const auto& method : methods) {
exported_object_->ExportMethod(
DBUS_INTERFACE_PROPERTIES, method.name,

@ -10,7 +10,6 @@
#include <utility>
#include "base/bits.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/memory/aligned_memory.h"
@ -152,7 +151,7 @@ DiscardableSharedMemoryHeap::~DiscardableSharedMemoryHeap() {
memory_segments_.clear();
DCHECK_EQ(num_blocks_, 0u);
DCHECK_EQ(num_free_blocks_, 0u);
DCHECK_EQ(std::count_if(free_spans_, free_spans_ + base::size(free_spans_),
DCHECK_EQ(std::count_if(free_spans_, free_spans_ + std::size(free_spans_),
[](const base::LinkedList<Span>& free_spans) {
return !free_spans.empty();
}),
@ -274,7 +273,7 @@ DiscardableSharedMemoryHeap::SearchFreeLists(size_t blocks, size_t slack) {
size_t max_length = blocks + slack;
// Search array of free lists for a suitable span.
while (length - 1 < base::size(free_spans_) - 1) {
while (length - 1 < std::size(free_spans_) - 1) {
const base::LinkedList<Span>& free_spans = free_spans_[length - 1];
if (!free_spans.empty()) {
// Return the most recently used span located in tail.
@ -287,7 +286,7 @@ DiscardableSharedMemoryHeap::SearchFreeLists(size_t blocks, size_t slack) {
}
const base::LinkedList<Span>& overflow_free_spans =
free_spans_[base::size(free_spans_) - 1];
free_spans_[std::size(free_spans_) - 1];
// Search overflow free list for a suitable span. Starting with the most
// recently used span located in tail and moving towards head.
@ -404,7 +403,7 @@ bool DiscardableSharedMemoryHeap::OnMemoryDump(
void DiscardableSharedMemoryHeap::InsertIntoFreeList(
std::unique_ptr<DiscardableSharedMemoryHeap::Span> span) {
DCHECK(!IsInFreeList(span.get()));
size_t index = std::min(span->length_, base::size(free_spans_)) - 1;
size_t index = std::min(span->length_, std::size(free_spans_)) - 1;
free_spans_[index].Append(span.release());
}

@ -4,8 +4,6 @@
#include "components/domain_reliability/quic_error_mapping.h"
#include "base/cxx17_backports.h"
namespace domain_reliability {
namespace {
@ -475,7 +473,7 @@ const int kDeprecatedQuicErrorCount = 5;
const int kActiveQuicErrorCount =
quic::QUIC_LAST_ERROR - kDeprecatedQuicErrorCount;
static_assert(base::size(kQuicErrorMap) == kActiveQuicErrorCount,
static_assert(std::size(kQuicErrorMap) == kActiveQuicErrorCount,
"quic_error_map is not in sync with quic protocol!");
} // namespace
@ -486,7 +484,7 @@ bool GetDomainReliabilityBeaconQuicError(quic::QuicErrorCode quic_error,
if (quic_error != quic::QUIC_NO_ERROR) {
// Convert a QUIC error.
// TODO(juliatuttle): Consider sorting and using binary search?
for (size_t i = 0; i < base::size(kQuicErrorMap); i++) {
for (size_t i = 0; i < std::size(kQuicErrorMap); i++) {
if (kQuicErrorMap[i].quic_error == quic_error) {
*beacon_quic_error_out = kQuicErrorMap[i].beacon_quic_error;
return true;

@ -7,7 +7,6 @@
#include <stddef.h>
#include "base/callback.h"
#include "base/cxx17_backports.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/time/default_tick_clock.h"
@ -92,7 +91,7 @@ bool GetDomainReliabilityBeaconStatus(
}
// TODO(juliatuttle): Consider sorting and using binary search?
for (size_t i = 0; i < base::size(net_error_map); i++) {
for (size_t i = 0; i < std::size(net_error_map); i++) {
if (net_error_map[i].net_error == net_error) {
*beacon_status_out = net_error_map[i].beacon_status;
return true;

@ -226,7 +226,7 @@ TEST_F(InMemoryDownloadTest, RedirectResponseHeaders) {
// The size must match for download as stream from SimpleUrlLoader.
network::URLLoaderCompletionStatus status;
status.decoded_body_length = base::size(kTestDownloadData) - 1;
status.decoded_body_length = std::size(kTestDownloadData) - 1;
url_loader_factory()->AddResponse(request_params.url, response_head.Clone(),
kTestDownloadData, status,

@ -10,7 +10,6 @@
#include <memory>
#include <utility>
#include "base/cxx17_backports.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
@ -34,10 +33,10 @@ const char kTestData1[] = "Let's write some data to the file!\n";
const char kTestData2[] = "Writing more data.\n";
const char kTestData3[] = "Final line.";
const char kTestData4[] = "supercalifragilisticexpialidocious";
const int kTestDataLength1 = base::size(kTestData1) - 1;
const int kTestDataLength2 = base::size(kTestData2) - 1;
const int kTestDataLength3 = base::size(kTestData3) - 1;
const int kTestDataLength4 = base::size(kTestData4) - 1;
const int kTestDataLength1 = std::size(kTestData1) - 1;
const int kTestDataLength2 = std::size(kTestData2) - 1;
const int kTestDataLength3 = std::size(kTestData3) - 1;
const int kTestDataLength4 = std::size(kTestData4) - 1;
int64_t kTestDataBytesWasted = 0;
// SHA-256 hash of kTestData1 (excluding terminating NUL).
@ -749,7 +748,7 @@ TEST_F(BaseFileTest, NoDoubleDeleteAfterCancel) {
ASSERT_FALSE(base::PathExists(full_path));
const char kData[] = "hello";
const int kDataLength = static_cast<int>(base::size(kData) - 1);
const int kDataLength = static_cast<int>(std::size(kData) - 1);
ASSERT_EQ(kDataLength, base::WriteFile(full_path, kData, kDataLength));
// The file that we created here should stick around when the BaseFile is
// destroyed during TearDown.

@ -6,7 +6,6 @@
#include <string>
#include "base/cxx17_backports.h"
#include "base/files/file.h"
#include "base/hash/md5.h"
#include "base/strings/strcat.h"
@ -166,7 +165,7 @@ std::string GetMd5Digest(const base::FilePath& file_path,
}
bool IsKnownHostedDocumentMimeType(const std::string& mime_type) {
for (size_t i = 0; i < base::size(kHostedDocumentKinds); ++i) {
for (size_t i = 0; i < std::size(kHostedDocumentKinds); ++i) {
if (mime_type == kHostedDocumentKinds[i].mime_type)
return true;
}
@ -175,7 +174,7 @@ bool IsKnownHostedDocumentMimeType(const std::string& mime_type) {
bool HasHostedDocumentExtension(const base::FilePath& path) {
const std::string extension = base::FilePath(path.Extension()).AsUTF8Unsafe();
for (size_t i = 0; i < base::size(kHostedDocumentKinds); ++i) {
for (size_t i = 0; i < std::size(kHostedDocumentKinds); ++i) {
if (extension == kHostedDocumentKinds[i].extension)
return true;
}

@ -12,7 +12,6 @@
#include <utility>
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
@ -100,7 +99,7 @@ bool IsChildEntryKey(const leveldb::Slice& key) {
bool IsCacheEntryKey(const leveldb::Slice& key) {
// A cache entry key should end with |kDBKeyDelimeter + kCacheEntryKeySuffix|.
const leveldb::Slice expected_suffix(kCacheEntryKeySuffix,
base::size(kCacheEntryKeySuffix) - 1);
std::size(kCacheEntryKeySuffix) - 1);
if (key.size() < 1 + expected_suffix.size() ||
key[key.size() - expected_suffix.size() - 1] != kDBKeyDelimeter)
return false;
@ -114,7 +113,7 @@ bool IsCacheEntryKey(const leveldb::Slice& key) {
std::string GetIdFromCacheEntryKey(const leveldb::Slice& key) {
DCHECK(IsCacheEntryKey(key));
// Drop the suffix |kDBKeyDelimeter + kCacheEntryKeySuffix| from the key.
const size_t kSuffixLength = base::size(kCacheEntryKeySuffix) - 1;
const size_t kSuffixLength = std::size(kCacheEntryKeySuffix) - 1;
const int id_length = key.size() - 1 - kSuffixLength;
return std::string(key.data(), id_length);
}
@ -134,7 +133,7 @@ bool IsIdEntryKey(const leveldb::Slice& key) {
// A resource-ID-to-local-ID entry key should start with
// |kDBKeyDelimeter + kIdEntryKeyPrefix + kDBKeyDelimeter|.
const leveldb::Slice expected_prefix(kIdEntryKeyPrefix,
base::size(kIdEntryKeyPrefix) - 1);
std::size(kIdEntryKeyPrefix) - 1);
if (key.size() < 2 + expected_prefix.size())
return false;
const leveldb::Slice key_substring(key.data() + 1, expected_prefix.size());
@ -148,7 +147,7 @@ std::string GetResourceIdFromIdEntryKey(const leveldb::Slice& key) {
DCHECK(IsIdEntryKey(key));
// Drop the prefix |kDBKeyDelimeter + kIdEntryKeyPrefix + kDBKeyDelimeter|
// from the key.
const size_t kPrefixLength = base::size(kIdEntryKeyPrefix) - 1;
const size_t kPrefixLength = std::size(kIdEntryKeyPrefix) - 1;
const int offset = kPrefixLength + 2;
return std::string(key.data() + offset, key.size() - offset);
}

@ -244,7 +244,7 @@ TEST_F(ResourceMetadataStorageTest, GetIdByResourceId) {
TEST_F(ResourceMetadataStorageTest, GetChildren) {
const std::string parents_id[] = { "mercury", "venus", "mars", "jupiter",
"saturn" };
std::vector<base::StringPairs> children_name_id(base::size(parents_id));
std::vector<base::StringPairs> children_name_id(std::size(parents_id));
// Skip children_name_id[0/1] here because Mercury and Venus have no moon.
children_name_id[2].push_back(std::make_pair("phobos", "mars_i"));
children_name_id[2].push_back(std::make_pair("deimos", "mars_ii"));

@ -7,7 +7,6 @@
#include <memory>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
@ -102,13 +101,13 @@ class OriginTrialPolicyImplTest : public testing::Test {
OriginTrialPolicyImplTest()
: token1_signature_(
std::string(reinterpret_cast<const char*>(kToken1Signature),
base::size(kToken1Signature))),
std::size(kToken1Signature))),
token2_signature_(
std::string(reinterpret_cast<const char*>(kToken2Signature),
base::size(kToken2Signature))),
std::size(kToken2Signature))),
token3_signature_(
std::string(reinterpret_cast<const char*>(kToken3Signature),
base::size(kToken3Signature))),
std::size(kToken3Signature))),
two_disabled_tokens_(
base::JoinString({kToken1SignatureEncoded, kToken2SignatureEncoded},
kTokenSeparator)),
@ -117,8 +116,7 @@ class OriginTrialPolicyImplTest : public testing::Test {
kToken3SignatureEncoded},
kTokenSeparator)),
manager_(base::WrapUnique(new OriginTrialPolicyImpl())),
default_keys_(manager_->GetPublicKeys()) {
}
default_keys_(manager_->GetPublicKeys()) {}
OriginTrialPolicyImpl* manager() { return manager_.get(); }
const std::vector<blink::OriginTrialPublicKey>& default_keys() {

@ -12,7 +12,6 @@
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/i18n/rtl.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/field_trial.h"
@ -492,11 +491,11 @@ const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
net::IsHostnameResolutionError(error_code)) {
return &secure_dns_network_error;
}
return FindErrorMapInArray(net_error_options, base::size(net_error_options),
return FindErrorMapInArray(net_error_options, std::size(net_error_options),
error_code);
} else if (error_domain == Error::kHttpErrorDomain) {
const LocalizedErrorMap* map = FindErrorMapInArray(
http_error_options, base::size(http_error_options), error_code);
http_error_options, std::size(http_error_options), error_code);
// Handle miscellaneous 400/500 errors.
return !map && error_code >= 400 && error_code < 600
? &generic_4xx_5xx_error
@ -504,7 +503,7 @@ const LocalizedErrorMap* LookupErrorMap(const std::string& error_domain,
} else if (error_domain == Error::kDnsProbeErrorDomain) {
const LocalizedErrorMap* map =
FindErrorMapInArray(dns_probe_error_options,
base::size(dns_probe_error_options), error_code);
std::size(dns_probe_error_options), error_code);
DCHECK(map);
return map;
} else {

@ -61,7 +61,7 @@ base::TimeDelta GetNextReloadDelay(size_t reload_count) {
static constexpr base::TimeDelta kDelays[] = {
base::Seconds(1), base::Seconds(5), base::Seconds(30), base::Minutes(1),
base::Minutes(5), base::Minutes(10), base::Minutes(30)};
return kDelays[std::min(reload_count, base::size(kDelays) - 1)];
return kDelays[std::min(reload_count, std::size(kDelays) - 1)];
}
// Helper to block a navigation that would result in re-committing the same

@ -840,11 +840,11 @@ TEST_P(SurfaceTest, SubpixelCoordinate) {
gfx::RectF(10.5, 20, 30, 40.5), gfx::RectF(10.5, 20.5, 30, 40)};
bool kExpectedAligned[] = {true, true, false, false,
false, false, false, false};
static_assert(base::size(kTestRects) == base::size(kExpectedAligned),
static_assert(std::size(kTestRects) == std::size(kExpectedAligned),
"Number of elements in each list should be the identical.");
for (int j = 0; j < 2; j++) {
const bool kTestCaseRotation = (j == 1);
for (size_t i = 0; i < base::size(kTestRects); i++) {
for (size_t i = 0; i < std::size(kTestRects); i++) {
auto rect_in_dip = kTestRects[i];
device_scale_transform.TransformRect(&rect_in_dip);
sub_surface->SetPosition(rect_in_dip.origin());
@ -1264,7 +1264,7 @@ TEST_P(SurfaceTest, ColorBufferAlpha) {
constexpr SkColor4f kBuffColorExpected[] = {{1.f, 0.5f, 0.f, 1.f},
{0.f, 0.5f, 1.f, 0.f}};
constexpr bool kExpectedOpaque[] = {true, false};
for (size_t i = 0; i < base::size(kBuffColorExpected); i++) {
for (size_t i = 0; i < std::size(kBuffColorExpected); i++) {
auto buffer =
std::make_unique<SolidColorBuffer>(kBuffColorExpected[i], buffer_size);
auto surface = std::make_unique<Surface>();

@ -8,7 +8,6 @@
#include <vector>
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "components/exo/wayland/clients/client_helper.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkImage.h"
@ -89,7 +88,7 @@ void DrawContents(SkImage* background_grid_image,
SK_ColorRED, SK_ColorYELLOW,
SK_ColorCYAN, SK_ColorMAGENTA};
SkPaint paint;
paint.setColor(kColors[(y * kGridSize + x) % base::size(kColors)]);
paint.setColor(kColors[(y * kGridSize + x) % std::size(kColors)]);
canvas->save();
canvas->translate(
x * cell_size.width() + SkScalarHalf(cell_size.width()),

@ -20,7 +20,6 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/containers/circular_deque.h"
#include "base/cxx17_backports.h"
#include "base/logging.h"
#include "base/message_loop/message_pump_type.h"
#include "base/scoped_generic.h"
@ -423,7 +422,7 @@ int RectsClient::Run(const ClientBase::InitParams& params,
SK_ColorRED, SK_ColorYELLOW,
SK_ColorCYAN, SK_ColorMAGENTA};
SkPaint paint;
paint.setColor(SkColorSetA(kColors[i % base::size(kColors)], 0xA0));
paint.setColor(SkColorSetA(kColors[i % std::size(kColors)], 0xA0));
canvas->rotate(rotation / num_rects);
canvas->drawIRect(rect, paint);
}

@ -5,11 +5,11 @@
#include "components/exo/wayland/clients/simple.h"
#include <presentation-time-client-protocol.h>
#include <iostream>
#include "base/command_line.h"
#include "base/containers/circular_deque.h"
#include "base/cxx17_backports.h"
#include "base/time/time.h"
#include "components/exo/wayland/clients/client_helper.h"
#include "third_party/skia/include/core/SkCanvas.h"
@ -141,7 +141,7 @@ void Simple::Run(int frames,
SkCanvas* canvas = buffer->sk_surface->getCanvas();
static const SkColor kColors[] = {SK_ColorRED, SK_ColorBLACK};
canvas->clear(kColors[++frame_count % base::size(kColors)]);
canvas->clear(kColors[++frame_count % std::size(kColors)]);
if (gr_context_) {
gr_context_->flushAndSubmit();

@ -4,7 +4,6 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/message_loop/message_pump_type.h"
#include "base/task/single_thread_task_executor.h"
#include "components/exo/wayland/clients/client_base.h"
@ -115,7 +114,7 @@ void SubSurfaceClient::Run(const ClientBase::InitParams& params) {
Buffer* buffer = buffers_.front().get();
SkCanvas* canvas = buffer->sk_surface->getCanvas();
static const SkColor kColors[] = {SK_ColorRED, SK_ColorBLACK};
canvas->clear(kColors[frame_count % base::size(kColors)]);
canvas->clear(kColors[frame_count % std::size(kColors)]);
if (gr_context_) {
gr_context_->flushAndSubmit();
glFinish();

@ -4,7 +4,6 @@
#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/cxx17_backports.h"
#include "base/message_loop/message_pump_type.h"
#include "base/task/single_thread_task_executor.h"
#include "components/exo/wayland/clients/client_base.h"
@ -146,7 +145,7 @@ void VulkanClient::Run(const ClientBase::InitParams& params) {
ScopedVulkanRenderFrame vulkan_frame(
this, buffer->vk_framebuffer->get(),
kColors[++frame_count % base::size(kColors)]);
kColors[++frame_count % std::size(kColors)]);
// This is where the drawing code would go.
// This client is not drawing anything. Just clearing the fb.

@ -46,12 +46,12 @@ void shm_pool_create_buffer(wl_client* client,
uint32_t format) {
const auto* supported_format =
std::find_if(shm_supported_formats,
shm_supported_formats + base::size(shm_supported_formats),
shm_supported_formats + std::size(shm_supported_formats),
[format](const shm_supported_format& supported_format) {
return supported_format.shm_format == format;
});
if (supported_format ==
(shm_supported_formats + base::size(shm_supported_formats))) {
(shm_supported_formats + std::size(shm_supported_formats))) {
wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FORMAT,
"invalid format 0x%x", format);
return;

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@ -44,7 +43,7 @@ TEST(FallbackURLUtilTest, GetFallbackIconText) {
{"http://xn--oogle-60a/", "X"},
{"http://xn-oogle-60a/", "X"},
};
for (size_t i = 0; i < base::size(test_cases); ++i) {
for (size_t i = 0; i < std::size(test_cases); ++i) {
std::u16string expected = base::ASCIIToUTF16(test_cases[i].expected);
GURL url(test_cases[i].url_str);
EXPECT_EQ(expected, GetFallbackIconText(url)) << " for test_cases[" << i

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
@ -31,7 +30,7 @@ const ui::ResourceScaleFactor FaviconScaleFactor1xAnd2x[] = {
#define SCOPED_FAVICON_SCALE_FACTOR(list) \
ui::test::ScopedSetSupportedResourceScaleFactors scoped( \
std::vector<ui::ResourceScaleFactor>(list, list + base::size(list)))
std::vector<ui::ResourceScaleFactor>(list, list + std::size(list)))
#define SCOPED_FAVICON_SCALE_FACTOR_1X \
SCOPED_FAVICON_SCALE_FACTOR(FaviconScaleFactor1x)

@ -4,7 +4,6 @@
#include "components/feature_engagement/public/feature_list.h"
#include "base/cxx17_backports.h"
#include "build/build_config.h"
#include "components/feature_engagement/public/feature_constants.h"
@ -155,7 +154,7 @@ const char kIPHDemoModeFeatureChoiceParam[] = "chosen_feature";
std::vector<const base::Feature*> GetAllFeatures() {
return std::vector<const base::Feature*>(
kAllFeatures, kAllFeatures + base::size(kAllFeatures));
kAllFeatures, kAllFeatures + std::size(kAllFeatures));
}
} // namespace feature_engagement

@ -7,7 +7,6 @@
#include <vector>
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "build/build_config.h"
#include "components/feature_engagement/public/feature_constants.h"
@ -40,7 +39,7 @@ namespace {
#define VARIATION_ENTRY(base_feature) \
{ \
base_feature##Variation[0].param_value, base_feature##Variation, \
base::size(base_feature##Variation), nullptr \
std::size(base_feature##Variation), nullptr \
}
// Defines a flags_ui::FeatureEntry::FeatureParam for each feature.

@ -433,7 +433,7 @@ bool FindAndConsumeAndGetSkipped(re2::StringPiece* input,
Arg*... match_groups) {
re2::StringPiece* args[] = {match_groups...};
return FindAndConsumeAndGetSkippedN(input, pattern, skipped_input, args,
base::size(args));
std::size(args));
}
// The following MAC addresses will not be redacted as they are not specific
@ -442,7 +442,7 @@ const char* const kUnredactedMacAddresses[] = {
"00:00:00:00:00:00", // ARP failure result MAC.
"ff:ff:ff:ff:ff:ff", // Broadcast MAC.
};
constexpr size_t kNumUnredactedMacs = base::size(kUnredactedMacAddresses);
constexpr size_t kNumUnredactedMacs = std::size(kUnredactedMacAddresses);
} // namespace

@ -452,7 +452,7 @@ TEST_F(RedactionToolTest, RedactCustomPatterns) {
"file:///var/log/messages",
"file:///usr/local/home/iby/web%20page%20test.html",
};
for (size_t i = 0; i < base::size(kURLs); ++i) {
for (size_t i = 0; i < std::size(kURLs); ++i) {
SCOPED_TRACE(kURLs[i]);
std::string got = RedactCustomPatterns(kURLs[i]);
EXPECT_TRUE(

@ -4,7 +4,6 @@
#include "components/filename_generation/filename_generation.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"
@ -64,7 +63,7 @@ static const struct {
#define MAYBE_TestEnsureHtmlExtension TestEnsureHtmlExtension
#endif
TEST(FilenameGenerationTest, MAYBE_TestEnsureHtmlExtension) {
for (size_t i = 0; i < base::size(kExtensionTestCases); ++i) {
for (size_t i = 0; i < std::size(kExtensionTestCases); ++i) {
base::FilePath original = base::FilePath(kExtensionTestCases[i].page_title);
base::FilePath expected =
base::FilePath(kExtensionTestCases[i].expected_name);
@ -111,7 +110,7 @@ TEST(FilenameGenerationTest, MAYBE_TestEnsureMimeExtension) {
{FPL("filename.abc"), FPL("filename.abc"), "unknown/unknown"},
{FPL("filename"), FPL("filename"), "unknown/unknown"},
};
for (uint32_t i = 0; i < base::size(kExtensionTests); ++i) {
for (uint32_t i = 0; i < std::size(kExtensionTests); ++i) {
base::FilePath original = base::FilePath(kExtensionTests[i].page_title);
base::FilePath expected = base::FilePath(kExtensionTests[i].expected_name);
std::string mime_type(kExtensionTests[i].contents_mime_type);
@ -166,7 +165,7 @@ static const struct GenerateFilenameTestCase {
#define MAYBE_TestGenerateFilename TestGenerateFilename
#endif
TEST(FilenameGenerationTest, MAYBE_TestGenerateFilename) {
for (size_t i = 0; i < base::size(kGenerateFilenameCases); ++i) {
for (size_t i = 0; i < std::size(kGenerateFilenameCases); ++i) {
base::FilePath save_name = GenerateFilename(
kGenerateFilenameCases[i].page_title,
GURL(kGenerateFilenameCases[i].page_url),

@ -174,7 +174,7 @@ class FlagsStateTest : public ::testing::Test,
prefs_.registry()->RegisterListPref(prefs::kAboutFlagsEntries);
prefs_.registry()->RegisterDictionaryPref(prefs::kAboutFlagsOriginLists);
for (size_t i = 0; i < base::size(kEntries); ++i)
for (size_t i = 0; i < std::size(kEntries); ++i)
kEntries[i].supported_platforms = FlagsState::GetCurrentPlatform();
int os_other_than_current = 1;
@ -496,7 +496,7 @@ TEST_F(FlagsStateTest, RemoveFlagSwitches_Features) {
{2, "A,B", "C", "A,B", "C,FeatureName1"},
};
for (size_t i = 0; i < base::size(cases); ++i) {
for (size_t i = 0; i < std::size(cases); ++i) {
SCOPED_TRACE(base::StringPrintf(
"Test[%" PRIuS "]: %d [%s] [%s]", i, cases[i].enabled_choice,
cases[i].existing_enable_features ? cases[i].existing_enable_features
@ -799,7 +799,7 @@ TEST_F(FlagsStateTest, FeatureValues) {
{2, nullptr, "Foo,Bar", "", "Foo,Bar,FeatureName1"},
};
for (size_t i = 0; i < base::size(cases); ++i) {
for (size_t i = 0; i < std::size(cases); ++i) {
SCOPED_TRACE(base::StringPrintf(
"Test[%" PRIuS "]: %d [%s] [%s]", i, cases[i].enabled_choice,
cases[i].existing_enable_features ? cases[i].existing_enable_features
@ -843,7 +843,7 @@ TEST_F(FlagsStateTest, GetFlagFeatureEntries) {
auto unsupported_count = unsupported_entries.size();
EXPECT_EQ(11u, supported_count);
EXPECT_EQ(1u, unsupported_count);
EXPECT_EQ(base::size(kEntries), supported_count + unsupported_count);
EXPECT_EQ(std::size(kEntries), supported_count + unsupported_count);
}
} // namespace flags_ui

@ -7,8 +7,6 @@
#include <stddef.h>
#include <stdint.h>
#include "base/cxx17_backports.h"
#include "base/strings/string_number_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -42,7 +40,7 @@ TEST(EncryptionHeaderParsersTest, ParseValidEncryptionHeaders) {
{ "keyid=foo;someothervalue=1;rs=42", "foo", "", 42 },
};
for (size_t i = 0; i < base::size(expected_results); i++) {
for (size_t i = 0; i < std::size(expected_results); i++) {
SCOPED_TRACE(i);
std::string header(expected_results[i].header);
@ -84,7 +82,7 @@ TEST(EncryptionHeaderParsersTest, ParseValidMultiValueEncryptionHeaders) {
{ "", "sixteencoolbytes", kDefaultRecordSize } } },
};
for (size_t i = 0; i < base::size(expected_results); i++) {
for (size_t i = 0; i < std::size(expected_results); i++) {
SCOPED_TRACE(i);
std::string header(expected_results[i].header);
@ -145,7 +143,7 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionHeaders) {
"rs=2,rs=0",
};
for (size_t i = 0; i < base::size(expected_failures); i++) {
for (size_t i = 0; i < std::size(expected_failures); i++) {
SCOPED_TRACE(i);
std::string header(expected_failures[i]);
@ -154,7 +152,7 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionHeaders) {
EXPECT_FALSE(iterator.GetNext());
}
for (size_t i = 0; i < base::size(expected_failures_second_iter); i++) {
for (size_t i = 0; i < std::size(expected_failures_second_iter); i++) {
SCOPED_TRACE(i);
std::string header(expected_failures_second_iter[i]);
@ -189,7 +187,7 @@ TEST(EncryptionHeaderParsersTest, ParseValidCryptoKeyHeaders) {
"foo", "twelvecoolbytes", "" },
};
for (size_t i = 0; i < base::size(expected_results); i++) {
for (size_t i = 0; i < std::size(expected_results); i++) {
SCOPED_TRACE(i);
std::string header(expected_results[i].header);
@ -231,7 +229,7 @@ TEST(EncryptionHeaderParsersTest, ParseValidMultiValueCryptoKeyHeaders) {
{ "", "sixteencoolbytes", "" } } },
};
for (size_t i = 0; i < base::size(expected_results); i++) {
for (size_t i = 0; i < std::size(expected_results); i++) {
SCOPED_TRACE(i);
std::string header(expected_results[i].header);
@ -283,7 +281,7 @@ TEST(EncryptionHeaderParsersTest, DISABLED_ParseInvalidCryptoKeyHeaders) {
"dh=dHdlbHZlY29vbGJ5dGVz,aesgcm128=123$xyz",
};
for (size_t i = 0; i < base::size(expected_failures); i++) {
for (size_t i = 0; i < std::size(expected_failures); i++) {
SCOPED_TRACE(i);
std::string header(expected_failures[i]);
@ -292,7 +290,7 @@ TEST(EncryptionHeaderParsersTest, DISABLED_ParseInvalidCryptoKeyHeaders) {
EXPECT_FALSE(iterator.GetNext());
}
for (size_t i = 0; i < base::size(expected_failures_second_iter); i++) {
for (size_t i = 0; i < std::size(expected_failures_second_iter); i++) {
SCOPED_TRACE(i);
std::string header(expected_failures_second_iter[i]);

@ -8,7 +8,6 @@
#include "base/base64url.h"
#include "base/big_endian.h"
#include "base/cxx17_backports.h"
#include "base/logging.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
@ -39,7 +38,7 @@ const unsigned char kCommonSenderPublicKey[] = {
0x9A, 0xA1, 0x1A, 0x04, 0xF1, 0x98, 0x25, 0xF2, 0xC2, 0x13, 0x5D,
0xD9, 0x72, 0x35, 0x75, 0x24, 0xF9, 0xFF, 0x25, 0xD1, 0xBC, 0x84,
0x46, 0x4E, 0x88, 0x08, 0x55, 0x70, 0x9F, 0xA7, 0x07, 0xD9};
static_assert(base::size(kCommonSenderPublicKey) == 65,
static_assert(std::size(kCommonSenderPublicKey) == 65,
"Raw P-256 public keys must be 65 bytes in size.");
const unsigned char kCommonRecipientPublicKey[] = {
@ -49,7 +48,7 @@ const unsigned char kCommonRecipientPublicKey[] = {
0x9A, 0x9F, 0xB8, 0x19, 0xD8, 0x21, 0x6F, 0x66, 0xE3, 0xF6, 0x0B,
0x74, 0xB2, 0x28, 0x38, 0xDC, 0xA7, 0x8A, 0x58, 0x0D, 0x56, 0x47,
0x3E, 0xD0, 0x5B, 0x5C, 0x93, 0x4E, 0xB3, 0x89, 0x87, 0x64};
static_assert(base::size(kCommonRecipientPublicKey) == 65,
static_assert(std::size(kCommonRecipientPublicKey) == 65,
"Raw P-256 public keys must be 65 bytes in size.");
const unsigned char kCommonRecipientPrivateKey[] = {
@ -69,7 +68,7 @@ const unsigned char kCommonRecipientPrivateKey[] = {
const unsigned char kCommonAuthSecret[] = {0x25, 0xF2, 0xC2, 0xB8, 0x19, 0xD8,
0xFD, 0x35, 0x97, 0xDF, 0xFB, 0x5E,
0xF6, 0x0B, 0xD7, 0xA4};
static_assert(base::size(kCommonAuthSecret) == 16,
static_assert(std::size(kCommonAuthSecret) == 16,
"Auth secrets must be 16 bytes in size.");
// Test vectors containing reference input for draft-ietf-webpush-encryption
@ -278,14 +277,14 @@ class GCMMessageCryptographerTestBase : public ::testing::Test {
void SetUp() override {
recipient_public_key_.assign(
kCommonRecipientPublicKey,
kCommonRecipientPublicKey + base::size(kCommonRecipientPublicKey));
kCommonRecipientPublicKey + std::size(kCommonRecipientPublicKey));
sender_public_key_.assign(
kCommonSenderPublicKey,
kCommonSenderPublicKey + base::size(kCommonSenderPublicKey));
kCommonSenderPublicKey + std::size(kCommonSenderPublicKey));
std::string recipient_private_key(
kCommonRecipientPrivateKey,
kCommonRecipientPrivateKey + base::size(kCommonRecipientPrivateKey));
kCommonRecipientPrivateKey + std::size(kCommonRecipientPrivateKey));
std::vector<uint8_t> recipient_private_key_vec(
recipient_private_key.begin(), recipient_private_key.end());
std::unique_ptr<crypto::ECPrivateKey> recipient_key =
@ -295,7 +294,7 @@ class GCMMessageCryptographerTestBase : public ::testing::Test {
*recipient_key, sender_public_key_, &ecdh_shared_secret_));
auth_secret_.assign(kCommonAuthSecret,
kCommonAuthSecret + base::size(kCommonAuthSecret));
kCommonAuthSecret + std::size(kCommonAuthSecret));
}
protected:
@ -583,7 +582,7 @@ TEST_F(GCMMessageCryptographerTestVectorTest, EncryptionVectorsDraft03) {
std::string ecdh_shared_secret, auth_secret, salt, ciphertext, output;
size_t record_size = 0;
for (size_t i = 0; i < base::size(kEncryptionTestVectorsDraft03); ++i) {
for (size_t i = 0; i < std::size(kEncryptionTestVectorsDraft03); ++i) {
SCOPED_TRACE(i);
ecdh_shared_secret.assign(
@ -616,7 +615,7 @@ TEST_F(GCMMessageCryptographerTestVectorTest, DecryptionVectorsDraft03) {
GCMMessageCryptographer::Version::DRAFT_03);
std::string input, ecdh_shared_secret, auth_secret, salt, plaintext;
for (size_t i = 0; i < base::size(kDecryptionTestVectorsDraft03); ++i) {
for (size_t i = 0; i < std::size(kDecryptionTestVectorsDraft03); ++i) {
SCOPED_TRACE(i);
ASSERT_TRUE(base::Base64UrlDecode(
@ -658,7 +657,7 @@ TEST_F(GCMMessageCryptographerTestVectorTest, EncryptionVectorsDraft08) {
std::string ecdh_shared_secret, auth_secret, salt, ciphertext, output;
size_t record_size = 0;
for (size_t i = 0; i < base::size(kEncryptionTestVectorsDraft08); ++i) {
for (size_t i = 0; i < std::size(kEncryptionTestVectorsDraft08); ++i) {
SCOPED_TRACE(i);
ecdh_shared_secret.assign(
@ -692,7 +691,7 @@ TEST_F(GCMMessageCryptographerTestVectorTest, DecryptionVectorsDraft08) {
std::string input, ecdh_shared_secret, auth_secret, salt, plaintext;
for (size_t i = 0; i < base::size(kDecryptionTestVectorsDraft08); ++i) {
for (size_t i = 0; i < std::size(kDecryptionTestVectorsDraft08); ++i) {
SCOPED_TRACE(i);
ASSERT_TRUE(base::Base64UrlDecode(

@ -5,7 +5,6 @@
#include "components/gcm_driver/crypto/message_payload_parser.h"
#include "base/big_endian.h"
#include "base/cxx17_backports.h"
#include "components/gcm_driver/crypto/gcm_decryption_result.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -36,13 +35,13 @@ const uint8_t kValidMessage[] = {
0x3F, 0xD8, 0x95, 0x2C, 0xA2, 0x11, 0xBD, 0x7B, 0x57, 0xB2, 0x00, 0xBD,
0x57, 0x68, 0x3F, 0xF0, 0x14, 0x57};
static_assert(base::size(kValidMessage) == 104,
static_assert(std::size(kValidMessage) == 104,
"The smallest valid message is 104 bytes in size.");
// Creates an std::string for the |kValidMessage| constant.
std::string CreateMessageString() {
return std::string(reinterpret_cast<const char*>(kValidMessage),
base::size(kValidMessage));
std::size(kValidMessage));
}
TEST(MessagePayloadParserTest, ValidMessage) {
@ -73,7 +72,7 @@ TEST(MessagePayloadParserTest, ValidMessage) {
TEST(MessagePayloadParserTest, MinimumMessageSize) {
std::string message = CreateMessageString();
message.resize(base::size(kValidMessage) / 2);
message.resize(std::size(kValidMessage) / 2);
MessagePayloadParser parser(message);
EXPECT_FALSE(parser.IsValid());

@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/containers/fixed_flat_set.h"
#include "base/cxx17_backports.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
@ -300,7 +299,7 @@ bool IsGoogleAssociatedDomainUrl(const GURL& url) {
".ytimg.com",
};
const std::string host = url.host();
for (size_t i = 0; i < base::size(kSuffixesToSetHeadersFor); ++i) {
for (size_t i = 0; i < std::size(kSuffixesToSetHeadersFor); ++i) {
if (base::EndsWith(host, kSuffixesToSetHeadersFor[i],
base::CompareCase::INSENSITIVE_ASCII)) {
return true;
@ -311,7 +310,7 @@ bool IsGoogleAssociatedDomainUrl(const GURL& url) {
static const char* kHostsToSetHeadersFor[] = {
"googleweblight.com",
};
for (size_t i = 0; i < base::size(kHostsToSetHeadersFor); ++i) {
for (size_t i = 0; i < std::size(kHostsToSetHeadersFor); ++i) {
if (base::LowerCaseEqualsASCII(host, kHostsToSetHeadersFor[i]))
return true;
}

@ -17,11 +17,9 @@
// has no logic in the getter except threading stuff, which we don't want
// to run.
#include "components/history/core/browser/history_backend.h"
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/test/history_backend_db_base_test.h"
namespace history {
@ -89,11 +87,11 @@ TEST_F(ContentHistoryBackendDBTest,
ConfirmDownloadInterruptReasonBackwardsCompatible) {
// Are there any cases in which a historical number has been repurposed
// for an error other than it's original?
for (size_t i = 0; i < base::size(current_reasons); i++) {
for (size_t i = 0; i < std::size(current_reasons); i++) {
const InterruptReasonAssociation& cur_reason(current_reasons[i]);
bool found = false;
for (size_t j = 0; j < base::size(historical_reasons); ++j) {
for (size_t j = 0; j < std::size(historical_reasons); ++j) {
const InterruptReasonAssociation& hist_reason(historical_reasons[j]);
if (hist_reason.value == cur_reason.value) {

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "sql/statement.h"
namespace history {
@ -37,9 +36,9 @@ class BookmarkIDMapping
public:
BookmarkIDMapping() {
static_assert(
base::size(kAndroidBookmarkColumn) <= HistoryAndBookmarkRow::COLUMN_END,
std::size(kAndroidBookmarkColumn) <= HistoryAndBookmarkRow::COLUMN_END,
"kAndroidBookmarkColumn should not have more than COLUMN_END elements");
for (size_t i = 0; i < base::size(kAndroidBookmarkColumn); ++i) {
for (size_t i = 0; i < std::size(kAndroidBookmarkColumn); ++i) {
(*this)[kAndroidBookmarkColumn[i]] =
static_cast<HistoryAndBookmarkRow::ColumnID>(i);
}
@ -53,10 +52,10 @@ BookmarkIDMapping* g_bookmark_id_mapping = NULL;
class SearchIDMapping : public std::map<std::string, SearchRow::ColumnID> {
public:
SearchIDMapping() {
static_assert(base::size(kAndroidSearchColumn) <= SearchRow::COLUMN_END,
static_assert(std::size(kAndroidSearchColumn) <= SearchRow::COLUMN_END,
"kAndroidSearchColumn should not have more than "
"COLUMN_END elements");
for (size_t i = 0; i < base::size(kAndroidSearchColumn); ++i) {
for (size_t i = 0; i < std::size(kAndroidSearchColumn); ++i) {
(*this)[kAndroidSearchColumn[i]] = static_cast<SearchRow::ColumnID>(i);
}
}

@ -5,7 +5,6 @@
#include "components/history/core/browser/android/android_urls_sql_handler.h"
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "components/history/core/browser/android/android_urls_database.h"
namespace history {
@ -20,7 +19,7 @@ const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = {
AndroidURLsSQLHandler::AndroidURLsSQLHandler(
AndroidURLsDatabase* android_urls_db)
: SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
: SQLHandler(kInterestingColumns, std::size(kInterestingColumns)),
android_urls_db_(android_urls_db) {}
AndroidURLsSQLHandler::~AndroidURLsSQLHandler() {

@ -5,7 +5,6 @@
#include "components/history/core/browser/android/favicon_sql_handler.h"
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "components/favicon/core/favicon_database.h"
@ -23,7 +22,7 @@ const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = {
} // namespace
FaviconSQLHandler::FaviconSQLHandler(favicon::FaviconDatabase* favicon_db)
: SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
: SQLHandler(kInterestingColumns, std::size(kInterestingColumns)),
favicon_db_(favicon_db) {}
FaviconSQLHandler::~FaviconSQLHandler() {

@ -4,7 +4,6 @@
#include "components/history/core/browser/android/urls_sql_handler.h"
#include "base/cxx17_backports.h"
#include "base/logging.h"
#include "components/history/core/browser/url_database.h"
@ -21,7 +20,7 @@ const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = {
} // namespace
UrlsSQLHandler::UrlsSQLHandler(URLDatabase* url_db)
: SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
: SQLHandler(kInterestingColumns, std::size(kInterestingColumns)),
url_db_(url_db) {}
UrlsSQLHandler:: ~UrlsSQLHandler() {

@ -7,7 +7,6 @@
#include <stdint.h>
#include "base/check.h"
#include "base/cxx17_backports.h"
#include "components/history/core/browser/url_database.h"
#include "components/history/core/browser/visit_database.h"
@ -25,7 +24,7 @@ const HistoryAndBookmarkRow::ColumnID kInterestingColumns[] = {
} // namespace
VisitSQLHandler::VisitSQLHandler(URLDatabase* url_db, VisitDatabase* visit_db)
: SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
: SQLHandler(kInterestingColumns, std::size(kInterestingColumns)),
url_db_(url_db),
visit_db_(visit_db) {}

@ -13,7 +13,6 @@
#include "base/bind.h"
#include "base/compiler_specific.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"
@ -607,7 +606,7 @@ TEST_F(ExpireHistoryTest, DeleteURLs) {
std::vector<GURL> urls;
// Push back a bogus URL (which shouldn't change anything).
urls.push_back(GURL());
for (size_t i = 0; i < base::size(rows); ++i) {
for (size_t i = 0; i < std::size(rows); ++i) {
ASSERT_TRUE(main_db_->GetURLRow(url_ids[i], &rows[i]));
favicon_ids[i] =
GetFavicon(rows[i].url(), favicon_base::IconType::kFavicon);

@ -17,7 +17,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/command_line.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"
@ -2840,7 +2839,7 @@ TEST_F(HistoryBackendTest, ExpireHistoryForTimes) {
ASSERT_TRUE(backend_.get());
HistoryAddPageArgs args[10];
for (size_t i = 0; i < base::size(args); ++i) {
for (size_t i = 0; i < std::size(args); ++i) {
args[i].url =
GURL("http://example" + std::string((i % 2 == 0 ? ".com" : ".net")));
args[i].time = base::Time::FromInternalValue(i);
@ -2896,14 +2895,14 @@ TEST_F(HistoryBackendTest, ExpireHistory) {
// Insert 4 entries into the database.
HistoryAddPageArgs args[4];
for (size_t i = 0; i < base::size(args); ++i) {
for (size_t i = 0; i < std::size(args); ++i) {
args[i].url = GURL("http://example" + base::NumberToString(i) + ".com");
args[i].time = reference_time + base::Days(i);
backend_->AddPage(args[i]);
}
URLRow url_rows[4];
for (unsigned int i = 0; i < base::size(args); ++i)
for (unsigned int i = 0; i < std::size(args); ++i)
ASSERT_TRUE(backend_->GetURL(args[i].url, &url_rows[i]));
std::vector<ExpireHistoryArgs> expire_list;
@ -2937,7 +2936,7 @@ TEST_F(HistoryBackendTest, ExpireHistory) {
EXPECT_EQ(backend_->GetFirstRecordedTimeForTest(), args[1].time);
// Now delete the rest of the visits in one call.
for (unsigned int i = 1; i < base::size(args); ++i) {
for (unsigned int i = 1; i < std::size(args); ++i) {
expire_list.resize(expire_list.size() + 1);
expire_list[i].SetTimeRangeForOneDay(args[i].time);
expire_list[i].urls.insert(args[i].url);

@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/callback_helpers.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"
@ -197,7 +196,7 @@ class HistoryQueryTest : public testing::Test {
// Fill the test data.
base_ = base::Time::Now().LocalMidnight();
for (size_t i = 0; i < base::size(test_entries); i++) {
for (size_t i = 0; i < std::size(test_entries); i++) {
test_entries[i].time = GetTimeFromDaysAgo(test_entries[i].days_ago);
AddEntryToHistory(test_entries[i]);
}
@ -458,7 +457,7 @@ TEST_F(HistoryQueryTest, TextSearchIDN) {
L"\u0438\u0434\u0435\u043d\u0442.\u0440\u0444"), 1, },
};
for (size_t i = 0; i < base::size(queries); ++i) {
for (size_t i = 0; i < std::size(queries); ++i) {
QueryHistory(queries[i].query, options, &results);
EXPECT_EQ(queries[i].results_size, results.size());
}
@ -469,7 +468,7 @@ TEST_F(HistoryQueryTest, Paging) {
// Since results are fetched 1 and 2 at a time, entry #0 and #6 will not
// be de-duplicated.
int expected_results[] = {4, 2, 3, 1, 7, 6, 5, 8, 9, 10, 11, 12, 13, 14, 0};
TestPaging(std::string(), expected_results, base::size(expected_results));
TestPaging(std::string(), expected_results, std::size(expected_results));
}
TEST_F(HistoryQueryTest, TextSearchPaging) {
@ -477,7 +476,7 @@ TEST_F(HistoryQueryTest, TextSearchPaging) {
// be de-duplicated. Entry #4 does not contain the text "title", so it
// shouldn't appear.
int expected_results[] = { 2, 3, 1, 7, 6, 5 };
TestPaging("title", expected_results, base::size(expected_results));
TestPaging("title", expected_results, std::size(expected_results));
}
} // namespace history

@ -9,7 +9,6 @@
#include "base/big_endian.h"
#include "base/bind.h"
#include "base/cxx17_backports.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
@ -1542,8 +1541,8 @@ TEST_F(TypedURLSyncBridgeTest, DiffVisitsRemove) {
DiffVisits(old_visits, new_url, &new_visits, &removed_visits);
EXPECT_TRUE(new_visits.empty());
ASSERT_EQ(removed_visits.size(), base::size(visits_removed));
for (size_t i = 0; i < base::size(visits_removed); ++i) {
ASSERT_EQ(removed_visits.size(), std::size(visits_removed));
for (size_t i = 0; i < std::size(visits_removed); ++i) {
EXPECT_EQ(removed_visits[i].visit_time.ToInternalValue(),
visits_removed[i]);
}
@ -1576,8 +1575,8 @@ TEST_F(TypedURLSyncBridgeTest, DiffVisitsAdd) {
DiffVisits(old_visits, new_url, &new_visits, &removed_visits);
EXPECT_TRUE(removed_visits.empty());
ASSERT_TRUE(new_visits.size() == base::size(visits_added));
for (size_t i = 0; i < base::size(visits_added); ++i) {
ASSERT_TRUE(new_visits.size() == std::size(visits_added));
for (size_t i = 0; i < std::size(visits_added); ++i) {
EXPECT_EQ(new_visits[i].first.ToInternalValue(), visits_added[i]);
EXPECT_TRUE(ui::PageTransitionTypeIncludingQualifiersIs(
new_visits[i].second, ui::PAGE_TRANSITION_TYPED));

@ -6,7 +6,6 @@
#include <stddef.h>
#include "base/cxx17_backports.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@ -36,11 +35,11 @@ TEST(HistoryUrlUtilsTest, CanonicalURLStringCompare) {
"http://www.google.com:80/",
"https://www.google.com",
};
for (size_t i = 0; i < base::size(sorted_list); ++i) {
for (size_t i = 0; i < std::size(sorted_list); ++i) {
EXPECT_FALSE(CanonicalURLStringCompare(sorted_list[i], sorted_list[i]))
<< " for \"" << sorted_list[i] << "\" < \"" << sorted_list[i] << "\"";
// Every disjoint pair-wise comparison.
for (size_t j = i + 1; j < base::size(sorted_list); ++j) {
for (size_t j = i + 1; j < std::size(sorted_list); ++j) {
EXPECT_TRUE(CanonicalURLStringCompare(sorted_list[i], sorted_list[j]))
<< " for \"" << sorted_list[i] << "\" < \"" << sorted_list[j] << "\"";
EXPECT_FALSE(CanonicalURLStringCompare(sorted_list[j], sorted_list[i]))
@ -64,7 +63,7 @@ TEST(HistoryUrlUtilsTest, HaveSameSchemeHostAndPort) {
{"http://www.google.com/test", "http://www.google.com/test/with/dir/"},
{"http://www.google.com/test?", "http://www.google.com/test/with/dir/"},
};
for (size_t i = 0; i < base::size(true_cases); ++i) {
for (size_t i = 0; i < std::size(true_cases); ++i) {
EXPECT_TRUE(HaveSameSchemeHostAndPort(GURL(true_cases[i].s1),
GURL(true_cases[i].s2)))
<< " for true_cases[" << i << "]";
@ -79,7 +78,7 @@ TEST(HistoryUrlUtilsTest, HaveSameSchemeHostAndPort) {
{"http://www.google.com/path", "http://www.google.com:137/path"},
{"http://www.google.com/same/dir", "http://www.youtube.com/same/dir"},
};
for (size_t i = 0; i < base::size(false_cases); ++i) {
for (size_t i = 0; i < std::size(false_cases); ++i) {
EXPECT_FALSE(HaveSameSchemeHostAndPort(GURL(false_cases[i].s1),
GURL(false_cases[i].s2)))
<< " for false_cases[" << i << "]";
@ -99,7 +98,7 @@ TEST(HistoryUrlUtilsTest, IsPathPrefix) {
{"/test", "/test/with/dir/"},
{"/test/", "/test/with/dir"},
};
for (size_t i = 0; i < base::size(true_cases); ++i) {
for (size_t i = 0; i < std::size(true_cases); ++i) {
EXPECT_TRUE(IsPathPrefix(true_cases[i].p1, true_cases[i].p2))
<< " for true_cases[" << i << "]";
}
@ -114,7 +113,7 @@ TEST(HistoryUrlUtilsTest, IsPathPrefix) {
{"/test", "/test-bed"},
{"/test-", "/test"},
};
for (size_t i = 0; i < base::size(false_cases); ++i) {
for (size_t i = 0; i < std::size(false_cases); ++i) {
EXPECT_FALSE(IsPathPrefix(false_cases[i].p1, false_cases[i].p2))
<< " for false_cases[" << i << "]";
}

@ -4,7 +4,6 @@
#include "components/history/core/browser/visit_annotations_database.h"
#include "base/cxx17_backports.h"
#include "base/test/gtest_util.h"
#include "base/time/time.h"
#include "components/history/core/browser/history_types.h"
@ -147,7 +146,7 @@ TEST_F(VisitAnnotationsDatabaseTest,
AddContextAnnotationsForVisit(2, visit_context_annotations_list[1]);
AddContextAnnotationsForVisit(3, visit_context_annotations_list[2]);
for (size_t i = 0; i < base::size(visit_context_annotations_list); ++i) {
for (size_t i = 0; i < std::size(visit_context_annotations_list); ++i) {
SCOPED_TRACE(testing::Message() << "i: " << i);
VisitContextAnnotations actual;
VisitID visit_id = i + 1; // VisitIDs are start at 1.

@ -4,7 +4,6 @@
#include "components/history/core/browser/visit_tracker.h"
#include "base/cxx17_backports.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace history {
@ -61,7 +60,7 @@ TEST(VisitTracker, SimpleTransitions) {
};
VisitTracker tracker;
RunTest(&tracker, test_simple, base::size(test_simple));
RunTest(&tracker, test_simple, std::size(test_simple));
}
// Test that referrer is properly computed when there are different frame
@ -83,7 +82,7 @@ TEST(VisitTracker, Frames) {
};
VisitTracker tracker;
RunTest(&tracker, test_frames, base::size(test_frames));
RunTest(&tracker, test_frames, std::size(test_frames));
}
// Test frame navigation to make sure that the referrer is properly computed
@ -105,7 +104,7 @@ TEST(VisitTracker, MultiProcess) {
};
VisitTracker tracker;
RunTest(&tracker, test_processes, base::size(test_processes));
RunTest(&tracker, test_processes, std::size(test_processes));
}
// Test that processes get removed properly.
@ -117,7 +116,7 @@ TEST(VisitTracker, ProcessRemove) {
};
VisitTracker tracker;
RunTest(&tracker, part1, base::size(part1));
RunTest(&tracker, part1, std::size(part1));
// Say that context has been invalidated.
tracker.ClearCachedDataForContextID(reinterpret_cast<ContextID>(1));
@ -127,7 +126,7 @@ TEST(VisitTracker, ProcessRemove) {
VisitToTest part2[] = {
{1, 1, "http://images.google.com/", 2, "http://www.google.com/", 0},
};
RunTest(&tracker, part2, base::size(part2));
RunTest(&tracker, part2, std::size(part2));
}
TEST(VisitTracker, RemoveVisitById) {
@ -138,7 +137,7 @@ TEST(VisitTracker, RemoveVisitById) {
};
VisitTracker tracker;
RunTest(&tracker, test_simple, base::size(test_simple));
RunTest(&tracker, test_simple, std::size(test_simple));
// Remove the first visit.
const VisitToTest& removed = test_simple[0];
@ -188,7 +187,7 @@ TEST(VisitTracker, Clear) {
};
VisitTracker tracker;
RunTest(&tracker, test_simple, base::size(test_simple));
RunTest(&tracker, test_simple, std::size(test_simple));
EXPECT_FALSE(tracker.IsEmpty());
tracker.Clear();
EXPECT_TRUE(tracker.IsEmpty());

@ -39,7 +39,7 @@ TEST(HistoryClustersDBTasksTest, BeginTimeCalculation) {
},
};
for (size_t i = 0; i < base::size(test_data); ++i) {
for (size_t i = 0; i < std::size(test_data); ++i) {
SCOPED_TRACE(base::StringPrintf("Testing case i=%d", int(i)));
auto& test_case = test_data[i];

@ -86,7 +86,7 @@ TEST(HistoryClustersUtilTest, FilterClustersMatchingQuery) {
{"goog red", false, false},
};
for (size_t i = 0; i < base::size(test_data); ++i) {
for (size_t i = 0; i < std::size(test_data); ++i) {
SCOPED_TRACE(base::StringPrintf("Testing case i=%d, query=%s",
static_cast<int>(i),
test_data[i].query.c_str()));

@ -524,7 +524,7 @@ class OnDeviceClusteringWithAllTheBackendsTest
void SetUp() override {
// Set up a simple template URL service with a default search engine.
template_url_service_ = std::make_unique<TemplateURLService>(
kTemplateURLData, base::size(kTemplateURLData));
kTemplateURLData, std::size(kTemplateURLData));
TemplateURL* template_url = template_url_service_->GetTemplateURLForKeyword(
kDefaultTemplateURLKeyword);
template_url_service_->SetUserSelectedDefaultSearchProvider(template_url);

@ -8,7 +8,6 @@
#include <memory>
#include "base/cxx17_backports.h"
#import "base/ios/ios_util.h"
#include "base/memory/ref_counted.h"
#include "base/test/task_environment.h"
@ -179,7 +178,7 @@ TEST_F(IOSImageDataFetcherWrapperTest, TestGoodWebP) {
network::mojom::URLResponseHeadPtr head =
network::mojom::URLResponseHead::New();
head->headers = new net::HttpResponseHeaders(
std::string(kWEBPHeaderResponse, base::size(kWEBPHeaderResponse)));
std::string(kWEBPHeaderResponse, std::size(kWEBPHeaderResponse)));
head->mime_type = "image/webp";
network::URLLoaderCompletionStatus status;
status.decoded_body_length = content.size();
@ -215,7 +214,7 @@ TEST_F(IOSImageDataFetcherWrapperTest, TestBadWebP) {
network::mojom::URLResponseHeadPtr head =
network::mojom::URLResponseHead::New();
head->headers = new net::HttpResponseHeaders(
std::string(kWEBPHeaderResponse, base::size(kWEBPHeaderResponse)));
std::string(kWEBPHeaderResponse, std::size(kWEBPHeaderResponse)));
head->mime_type = "image/webp";
network::URLLoaderCompletionStatus status;
status.decoded_body_length = content.size();

@ -6,14 +6,12 @@
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/base_paths.h"
#include "base/cxx17_backports.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
@ -249,7 +247,7 @@ TEST_F(WebpDecoderTest, InvalidFormat) {
EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1);
const char dummy_image[] = "(>'-')> <('-'<) ^('-')^ <('-'<) (>'-')>";
NSData* data = [[NSData alloc] initWithBytes:dummy_image
length:base::size(dummy_image)];
length:std::size(dummy_image)];
decoder_->OnDataReceived(data);
EXPECT_EQ(0u, [delegate_->GetImage() length]);
}

@ -4,7 +4,6 @@
#include "components/metrics/field_trials_provider.h"
#include "base/cxx17_backports.h"
#include "base/threading/platform_thread.h"
#include "components/variations/active_field_trials.h"
#include "components/variations/synthetic_trial_registry.h"
@ -103,7 +102,7 @@ TEST_F(FieldTrialsProviderTest, ProvideSyntheticTrials) {
provider.ProvideSystemProfileMetricsWithLogCreationTime(log_creation_time,
&proto);
EXPECT_EQ(base::size(kAllTrialIds),
EXPECT_EQ(std::size(kAllTrialIds),
static_cast<size_t>(proto.field_trial_size()));
CheckFieldTrialsInSystemProfile(proto, kAllTrialIds);
}
@ -115,7 +114,7 @@ TEST_F(FieldTrialsProviderTest, NoSyntheticTrials) {
provider.ProvideSystemProfileMetricsWithLogCreationTime(base::TimeTicks(),
&proto);
EXPECT_EQ(base::size(kFieldTrialIds),
EXPECT_EQ(std::size(kFieldTrialIds),
static_cast<size_t>(proto.field_trial_size()));
CheckFieldTrialsInSystemProfile(proto, kFieldTrialIds);
}
@ -139,7 +138,7 @@ TEST_F(FieldTrialsProviderTest, ProvideCurrentSessionData) {
provider.ProvideCurrentSessionData(&uma_log);
EXPECT_EQ(base::size(kAllTrialIds),
EXPECT_EQ(std::size(kAllTrialIds),
static_cast<size_t>(uma_log.system_profile().field_trial_size()));
CheckFieldTrialsInSystemProfile(uma_log.system_profile(), kAllTrialIds);
}

@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/containers/flat_map.h"
#include "base/cxx17_backports.h"
#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
@ -212,7 +211,7 @@ void FileMetricsProvider::RegisterSource(const Params& params) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// Ensure that kSourceOptions has been filled for this type.
DCHECK_GT(base::size(kSourceOptions), static_cast<size_t>(params.type));
DCHECK_GT(std::size(kSourceOptions), static_cast<size_t>(params.type));
std::unique_ptr<SourceInfo> source(new SourceInfo(params));

Some files were not shown because too many files have changed in this diff Show More