Use base::size rather than arraysize

https://bugs.chromium.org/p/chromium/issues/detail?id=837308
This commit is contained in:
deepak1556 2019-01-21 23:56:33 +05:30 коммит произвёл Samuel Attard
Родитель 3db0a8ef73
Коммит bbd72e5658
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 191FEF027779CC6C
9 изменённых файлов: 23 добавлений и 19 удалений

Просмотреть файл

@ -478,7 +478,7 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
switches::kServiceWorkerSchemes};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames,
arraysize(kCommonSwitchNames));
base::size(kCommonSwitchNames));
#if defined(OS_WIN)
// Append --app-user-model-id.

Просмотреть файл

@ -7,6 +7,7 @@
#include <string>
#include <unordered_map>
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/pref_names.h"
@ -103,7 +104,7 @@ const FontDefault kFontDefaults[] = {
IDS_FIXED_FONT_FAMILY_TRADITIONAL_HAN},
#endif
};
const size_t kFontDefaultsLength = arraysize(kFontDefaults);
const size_t kFontDefaultsLength = base::size(kFontDefaults);
// ^^^^^ DO NOT EDIT ^^^^^

Просмотреть файл

@ -16,6 +16,7 @@
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/pattern.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@ -109,7 +110,7 @@ void SetZoomLevelForWebContents(content::WebContents* web_contents,
double GetNextZoomLevel(double level, bool out) {
double factor = content::ZoomLevelToZoomFactor(level);
size_t size = arraysize(kPresetZoomFactors);
size_t size = base::size(kPresetZoomFactors);
for (size_t i = 0; i < size; ++i) {
if (!content::ZoomValuesEqual(kPresetZoomFactors[i], factor))
continue;

Просмотреть файл

@ -83,7 +83,7 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
item->type = JumpListItem::Type::TASK;
wchar_t path[MAX_PATH];
if (FAILED(shell_link->GetPath(path, arraysize(path), nullptr, 0)))
if (FAILED(shell_link->GetPath(path, MAX_PATH, nullptr, 0)))
return false;
CComQIPtr<IPropertyStore> property_store = shell_link;
@ -100,14 +100,13 @@ bool ConvertShellLinkToJumpListItem(IShellLink* shell_link,
}
int icon_index;
if (SUCCEEDED(
shell_link->GetIconLocation(path, arraysize(path), &icon_index))) {
if (SUCCEEDED(shell_link->GetIconLocation(path, MAX_PATH, &icon_index))) {
item->icon_path = base::FilePath(path);
item->icon_index = icon_index;
}
wchar_t item_desc[INFOTIPSIZE];
if (SUCCEEDED(shell_link->GetDescription(item_desc, arraysize(item_desc))))
if (SUCCEEDED(shell_link->GetDescription(item_desc, INFOTIPSIZE)))
item->description = item_desc;
return true;

Просмотреть файл

@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
@ -414,7 +415,7 @@ DWORD CrashService::AsyncSendDump(void* context) {
const DWORD kSleepSchedule[] = {24 * kOneHour, 8 * kOneHour, 4 * kOneHour,
kOneHour, 15 * kOneMinute, 0};
int retry_round = arraysize(kSleepSchedule) - 1;
int retry_round = base::size(kSleepSchedule) - 1;
do {
::Sleep(kSleepSchedule[retry_round]);

Просмотреть файл

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "atom/common/native_mate_converters/callback.h"
#include "base/stl_util.h"
#include "content/public/browser/browser_thread.h"
#include "native_mate/dictionary.h"
@ -151,7 +152,7 @@ v8::Local<v8::Value> BindFunctionWith(v8::Isolate* isolate,
v8::Local<v8::Function> bind_func =
v8::Local<v8::Function>::Cast(bind.ToLocalChecked());
v8::Local<v8::Value> converted[] = {func, arg1, arg2};
return bind_func->Call(context, func, arraysize(converted), converted)
return bind_func->Call(context, func, base::size(converted), converted)
.ToLocalChecked();
}

Просмотреть файл

@ -29,7 +29,6 @@
#undef DISALLOW_COPY_AND_ASSIGN
#undef NO_RETURN
#undef LIKELY
#undef arraysize
#undef debug_string // This is defined in macOS SDK in AssertMacros.h.
#undef require_string // This is defined in macOS SDK in AssertMacros.h.
#include "env-inl.h"

Просмотреть файл

@ -20,6 +20,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/win/registry.h"
@ -263,7 +264,7 @@ bool ShowItemInFolder(const base::FilePath& full_path) {
const ITEMIDLIST* highlight[] = {file_item};
hr = SHOpenFolderAndSelectItems(dir_item, arraysize(highlight), highlight,
hr = SHOpenFolderAndSelectItems(dir_item, base::size(highlight), highlight,
NULL);
if (!FAILED(hr))
return true;

Просмотреть файл

@ -76,6 +76,7 @@
#include "base/rand_util.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@ -114,7 +115,7 @@ const char kACKToken[] = "ACK";
const char kShutdownToken[] = "SHUTDOWN";
const char kTokenDelimiter = '\0';
const int kMaxMessageLength = 32 * 1024;
const int kMaxACKMessageLength = arraysize(kShutdownToken) - 1;
const int kMaxACKMessageLength = base::size(kShutdownToken) - 1;
const char kLockDelimiter = '-';
@ -225,9 +226,9 @@ ssize_t ReadFromSocket(int fd,
// Set up a sockaddr appropriate for messaging.
void SetupSockAddr(const std::string& path, struct sockaddr_un* addr) {
addr->sun_family = AF_UNIX;
CHECK(path.length() < arraysize(addr->sun_path))
CHECK(path.length() < base::size(addr->sun_path))
<< "Socket path too long: " << path;
base::strlcpy(addr->sun_path, path.c_str(), arraysize(addr->sun_path));
base::strlcpy(addr->sun_path, path.c_str(), base::size(addr->sun_path));
}
// Set up a socket appropriate for messaging.
@ -604,13 +605,13 @@ void ProcessSingleton::LinuxWatcher::HandleMessage(
if (parent_->notification_callback_.Run(argv, base::FilePath(current_dir))) {
// Send back "ACK" message to prevent the client process from starting up.
reader->FinishWithACK(kACKToken, arraysize(kACKToken) - 1);
reader->FinishWithACK(kACKToken, base::size(kACKToken) - 1);
} else {
LOG(WARNING) << "Not handling interprocess notification as browser"
" is shutting down";
// Send back "SHUTDOWN" message, so that the client process can start up
// without killing this process.
reader->FinishWithACK(kShutdownToken, arraysize(kShutdownToken) - 1);
reader->FinishWithACK(kShutdownToken, base::size(kShutdownToken) - 1);
return;
}
}
@ -654,7 +655,7 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
}
// Validate the message. The shortest message is kStartToken\0x\0x
const size_t kMinMessageLength = arraysize(kStartToken) + 4;
const size_t kMinMessageLength = base::size(kStartToken) + 4;
if (bytes_read_ < kMinMessageLength) {
buf_[bytes_read_] = 0;
LOG(ERROR) << "Invalid socket message (wrong length):" << buf_;
@ -857,10 +858,10 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
}
buf[len] = '\0';
if (strncmp(buf, kShutdownToken, arraysize(kShutdownToken) - 1) == 0) {
if (strncmp(buf, kShutdownToken, base::size(kShutdownToken) - 1) == 0) {
// The other process is shutting down, it's safe to start a new process.
return PROCESS_NONE;
} else if (strncmp(buf, kACKToken, arraysize(kACKToken) - 1) == 0) {
} else if (strncmp(buf, kACKToken, base::size(kACKToken) - 1) == 0) {
#if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
// Likely NULL in unit tests.
views::LinuxUI* linux_ui = views::LinuxUI::instance();