Convert usage of ARRAY_SIZE to arraysize.

ARRAY_SIZE is the old version of arraysize and does not cover
all the cases in C++, arraysize is a copy of Chromium's
version and thus have wider coverage.

BUG=None
R=tommi@webrtc.org

Review URL: https://codereview.webrtc.org/1405023016

Cr-Original-Commit-Position: refs/heads/master@{#10594}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 5237aaf243d29732f59557361b7a993c0a18cf0e
diff --git a/base/bitbuffer_unittest.cc b/base/bitbuffer_unittest.cc
index 99701f7..ce42257 100644
--- a/base/bitbuffer_unittest.cc
+++ b/base/bitbuffer_unittest.cc
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/bitbuffer.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/common.h"
@@ -301,11 +302,11 @@
   char test_string[] = "my precious";
   uint8_t bytes[64] = {0};
   BitBufferWriter buffer(bytes, 64);
-  for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) {
+  for (size_t i = 0; i < arraysize(test_string); ++i) {
     EXPECT_TRUE(buffer.WriteExponentialGolomb(test_string[i]));
   }
   buffer.Seek(0, 0);
-  for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) {
+  for (size_t i = 0; i < arraysize(test_string); ++i) {
     uint32_t val;
     EXPECT_TRUE(buffer.ReadExponentialGolomb(&val));
     EXPECT_LE(val, std::numeric_limits<uint8_t>::max());
diff --git a/base/bytebuffer_unittest.cc b/base/bytebuffer_unittest.cc
index 56b0e05..0287d85 100644
--- a/base/bytebuffer_unittest.cc
+++ b/base/bytebuffer_unittest.cc
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/bytebuffer.h"
 #include "webrtc/base/byteorder.h"
 #include "webrtc/base/common.h"
@@ -114,7 +115,7 @@
 TEST(ByteBufferTest, TestReadWriteBuffer) {
   ByteBuffer::ByteOrder orders[2] = { ByteBuffer::ORDER_HOST,
                                       ByteBuffer::ORDER_NETWORK };
-  for (size_t i = 0; i < ARRAY_SIZE(orders); i++) {
+  for (size_t i = 0; i < arraysize(orders); i++) {
     ByteBuffer buffer(orders[i]);
     EXPECT_EQ(orders[i], buffer.Order());
     uint8_t ru8;
diff --git a/base/common.h b/base/common.h
index 67665f2..2086754 100644
--- a/base/common.h
+++ b/base/common.h
@@ -54,8 +54,6 @@
 
 #endif  // !defined(WEBRTC_WIN)
 
-#define ARRAY_SIZE(x) (static_cast<int>(sizeof(x) / sizeof(x[0])))
-
 /////////////////////////////////////////////////////////////////////////////
 // Assertions
 /////////////////////////////////////////////////////////////////////////////
diff --git a/base/crc32.cc b/base/crc32.cc
index eae338a..f9e4c37 100644
--- a/base/crc32.cc
+++ b/base/crc32.cc
@@ -10,6 +10,7 @@
 
 #include "webrtc/base/crc32.h"
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/basicdefs.h"
 
 namespace rtc {
@@ -22,9 +23,9 @@
 static uint32_t kCrc32Table[256] = {0};
 
 static void EnsureCrc32TableInited() {
-  if (kCrc32Table[ARRAY_SIZE(kCrc32Table) - 1])
+  if (kCrc32Table[arraysize(kCrc32Table) - 1])
     return;  // already inited
-  for (uint32_t i = 0; i < ARRAY_SIZE(kCrc32Table); ++i) {
+  for (uint32_t i = 0; i < arraysize(kCrc32Table); ++i) {
     uint32_t c = i;
     for (size_t j = 0; j < 8; ++j) {
       if (c & 1) {
diff --git a/base/diskcache.cc b/base/diskcache.cc
index 7bf1ba2..a1fba6a 100644
--- a/base/diskcache.cc
+++ b/base/diskcache.cc
@@ -15,6 +15,7 @@
 #endif
 
 #include <algorithm>
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/diskcache.h"
 #include "webrtc/base/fileutils.h"
@@ -263,7 +264,7 @@
 #endif  // !TRANSPARENT_CACHE_NAMES
 
   char extension[32];
-  sprintfn(extension, ARRAY_SIZE(extension), ".%u", index);
+  sprintfn(extension, arraysize(extension), ".%u", index);
 
   Pathname pathname;
   pathname.SetFolder(folder_);
diff --git a/base/fileutils.cc b/base/fileutils.cc
index 6f385d7..cb23153 100644
--- a/base/fileutils.cc
+++ b/base/fileutils.cc
@@ -10,6 +10,7 @@
 
 #include <assert.h>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/pathutils.h"
 #include "webrtc/base/fileutils.h"
 #include "webrtc/base/stringutils.h"
@@ -273,8 +274,8 @@
     }
     version += 1;
     char version_base[MAX_PATH];
-    sprintfn(version_base, ARRAY_SIZE(version_base), "%s-%u",
-             basename.c_str(), version);
+    sprintfn(version_base, arraysize(version_base), "%s-%u", basename.c_str(),
+             version);
     path.SetBasename(version_base);
   }
   return true;
diff --git a/base/httpcommon-inl.h b/base/httpcommon-inl.h
index d1c0bf0..188d9e6 100644
--- a/base/httpcommon-inl.h
+++ b/base/httpcommon-inl.h
@@ -11,6 +11,7 @@
 #ifndef WEBRTC_BASE_HTTPCOMMON_INL_H__
 #define WEBRTC_BASE_HTTPCOMMON_INL_H__
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/httpcommon.h"
 
@@ -80,7 +81,7 @@
 template<class CTYPE>
 void Url<CTYPE>::do_get_url(string* val) const {
   CTYPE protocol[9];
-  asccpyn(protocol, ARRAY_SIZE(protocol), secure_ ? "https://" : "http://");
+  asccpyn(protocol, arraysize(protocol), secure_ ? "https://" : "http://");
   val->append(protocol);
   do_get_address(val);
   do_get_full_path(val);
@@ -91,8 +92,8 @@
   val->append(host_);
   if (port_ != HttpDefaultPort(secure_)) {
     CTYPE format[5], port[32];
-    asccpyn(format, ARRAY_SIZE(format), ":%hu");
-    sprintfn(port, ARRAY_SIZE(port), format, port_);
+    asccpyn(format, arraysize(format), ":%hu");
+    sprintfn(port, arraysize(port), format, port_);
     val->append(port);
   }
 }
diff --git a/base/httpcommon.cc b/base/httpcommon.cc
index 0c3547e..c90bea5 100644
--- a/base/httpcommon.cc
+++ b/base/httpcommon.cc
@@ -21,6 +21,7 @@
 
 #include <algorithm>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/base64.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/cryptstring.h"
@@ -377,7 +378,7 @@
     gmt = non_gmt + ((zone[0] == '+') ? offset : -offset);
   } else {
     size_t zindex;
-    if (!find_string(zindex, zone, kTimeZones, ARRAY_SIZE(kTimeZones))) {
+    if (!find_string(zindex, zone, kTimeZones, arraysize(kTimeZones))) {
       return false;
     }
     gmt = non_gmt + kTimeZoneOffsets[zindex] * 60 * 60;
diff --git a/base/natsocketfactory.cc b/base/natsocketfactory.cc
index 548a80c..0abd2a1 100644
--- a/base/natsocketfactory.cc
+++ b/base/natsocketfactory.cc
@@ -10,6 +10,7 @@
 
 #include "webrtc/base/natsocketfactory.h"
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/natserver.h"
 #include "webrtc/base/virtualsocketserver.h"
@@ -270,7 +271,7 @@
   // Sends the destination address to the server to tell it to connect.
   void SendConnectRequest() {
     char buf[kNATEncodedIPv6AddressSize];
-    size_t length = PackAddressForNAT(buf, ARRAY_SIZE(buf), remote_addr_);
+    size_t length = PackAddressForNAT(buf, arraysize(buf), remote_addr_);
     socket_->Send(buf, length);
   }
 
diff --git a/base/openssladapter.cc b/base/openssladapter.cc
index 892b5cc..1f5fbbc 100644
--- a/base/openssladapter.cc
+++ b/base/openssladapter.cc
@@ -31,6 +31,7 @@
 #include "config.h"
 #endif  // HAVE_CONFIG_H
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/openssl.h"
@@ -915,7 +916,7 @@
 bool OpenSSLAdapter::ConfigureTrustedRootCertificates(SSL_CTX* ctx) {
   // Add the root cert that we care about to the SSL context
   int count_of_added_certs = 0;
-  for (int i = 0; i < ARRAY_SIZE(kSSLCertCertificateList); i++) {
+  for (size_t i = 0; i < arraysize(kSSLCertCertificateList); i++) {
     const unsigned char* cert_buffer = kSSLCertCertificateList[i];
     size_t cert_buffer_len = kSSLCertCertificateSizeList[i];
     X509* cert = d2i_X509(NULL, &cert_buffer,
diff --git a/base/physicalsocketserver.cc b/base/physicalsocketserver.cc
index e0fe8a0..4a4c0a3 100644
--- a/base/physicalsocketserver.cc
+++ b/base/physicalsocketserver.cc
@@ -39,6 +39,7 @@
 #include <algorithm>
 #include <map>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/byteorder.h"
 #include "webrtc/base/common.h"
@@ -628,8 +629,8 @@
 
   // Returns true if the given signal number is set.
   bool IsSignalSet(int signum) const {
-    ASSERT(signum < ARRAY_SIZE(received_signal_));
-    if (signum < ARRAY_SIZE(received_signal_)) {
+    ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
+    if (signum < static_cast<int>(arraysize(received_signal_))) {
       return received_signal_[signum];
     } else {
       return false;
@@ -638,8 +639,8 @@
 
   // Clears the given signal number.
   void ClearSignal(int signum) {
-    ASSERT(signum < ARRAY_SIZE(received_signal_));
-    if (signum < ARRAY_SIZE(received_signal_)) {
+    ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
+    if (signum < static_cast<int>(arraysize(received_signal_))) {
       received_signal_[signum] = false;
     }
   }
@@ -654,7 +655,7 @@
   // user-level state of the process, since the handler could be executed at any
   // time on any thread.
   void OnPosixSignalReceived(int signum) {
-    if (signum >= ARRAY_SIZE(received_signal_)) {
+    if (signum >= static_cast<int>(arraysize(received_signal_))) {
       // We don't have space in our array for this.
       return;
     }
diff --git a/base/proxydetect.cc b/base/proxydetect.cc
index c0cfab9..30959ca 100644
--- a/base/proxydetect.cc
+++ b/base/proxydetect.cc
@@ -34,6 +34,7 @@
 
 #include <map>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/fileutils.h"
 #include "webrtc/base/httpcommon.h"
 #include "webrtc/base/httpcommon-inl.h"
@@ -398,7 +399,7 @@
   }
   char buffer[NAME_MAX + 1];
   if (0 != FSRefMakePath(&fr, reinterpret_cast<uint8_t*>(buffer),
-                         ARRAY_SIZE(buffer))) {
+                         arraysize(buffer))) {
     LOG(LS_ERROR) << "FSRefMakePath failed";
     return false;
   }
diff --git a/base/socket_unittest.cc b/base/socket_unittest.cc
index d078d7c..8143823 100644
--- a/base/socket_unittest.cc
+++ b/base/socket_unittest.cc
@@ -10,6 +10,7 @@
 
 #include "webrtc/base/socket_unittest.h"
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/asyncudpsocket.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/nethelpers.h"
@@ -827,7 +828,7 @@
   // Fill the socket buffer.
   char buf[1024 * 16] = {0};
   int sends = 0;
-  while (++sends && accepted->Send(&buf, ARRAY_SIZE(buf)) != -1) {}
+  while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) {}
   EXPECT_TRUE(accepted->IsBlocking());
 
   // Wait until data is available.
@@ -835,7 +836,7 @@
 
   // Pull data.
   for (int i = 0; i < sends; ++i) {
-    client->Recv(buf, ARRAY_SIZE(buf));
+    client->Recv(buf, arraysize(buf));
   }
 
   // Expect at least one additional writable callback.
@@ -845,7 +846,7 @@
   // callbacks.
   int extras = 0;
   for (int i = 0; i < 100; ++i) {
-    accepted->Send(&buf, ARRAY_SIZE(buf));
+    accepted->Send(&buf, arraysize(buf));
     rtc::Thread::Current()->ProcessMessages(1);
     if (sink.Check(accepted.get(), testing::SSE_WRITE)) {
       extras++;
diff --git a/base/stringencode_unittest.cc b/base/stringencode_unittest.cc
index 406d9c7..588e9d8 100644
--- a/base/stringencode_unittest.cc
+++ b/base/stringencode_unittest.cc
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/stringencode.h"
@@ -48,7 +49,7 @@
     }
 
     char buffer[5];
-    memset(buffer, 0x01, ARRAY_SIZE(buffer));
+    memset(buffer, 0x01, arraysize(buffer));
     ASSERT_EQ(kTests[i].enclen, utf8_encode(buffer,
                                             kTests[i].encsize,
                                             kTests[i].decoded));
@@ -56,7 +57,7 @@
     // Make sure remainder of buffer is unchanged
     ASSERT_TRUE(memory_check(buffer + kTests[i].enclen,
                              0x1,
-                             ARRAY_SIZE(buffer) - kTests[i].enclen));
+                             arraysize(buffer) - kTests[i].enclen));
   }
 }
 
diff --git a/base/task_unittest.cc b/base/task_unittest.cc
index 7f67841..3508219 100644
--- a/base/task_unittest.cc
+++ b/base/task_unittest.cc
@@ -20,6 +20,7 @@
 #include "webrtc/base/win32.h"
 #endif  // WEBRTC_WIN
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/logging.h"
@@ -408,7 +409,7 @@
 class TimeoutChangeTest : public sigslot::has_slots<> {
  public:
   TimeoutChangeTest()
-    : task_count_(ARRAY_SIZE(stuck_tasks_)) {}
+    : task_count_(arraysize(stuck_tasks_)) {}
 
   // no need to delete any tasks; the task runner owns them
   ~TimeoutChangeTest() {}
@@ -463,7 +464,7 @@
 
  private:
   void OnTimeoutId(const int id) {
-    for (int i = 0; i < ARRAY_SIZE(stuck_tasks_); ++i) {
+    for (size_t i = 0; i < arraysize(stuck_tasks_); ++i) {
       if (stuck_tasks_[i] && stuck_tasks_[i]->unique_id() == id) {
         task_count_--;
         stuck_tasks_[i] = NULL;
diff --git a/base/testutils.h b/base/testutils.h
index e56895d..6e7e22a 100644
--- a/base/testutils.h
+++ b/base/testutils.h
@@ -25,6 +25,7 @@
 #include <algorithm>
 #include <map>
 #include <vector>
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/asyncsocket.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
@@ -357,7 +358,7 @@
   }
   void OnReadEvent(AsyncSocket* socket) {
     char data[64 * 1024];
-    int result = socket_->Recv(data, ARRAY_SIZE(data));
+    int result = socket_->Recv(data, arraysize(data));
     if (result > 0) {
       recv_buffer_.insert(recv_buffer_.end(), data, data + result);
     }
diff --git a/base/unixfilesystem.cc b/base/unixfilesystem.cc
index 30d6e78..734e880 100644
--- a/base/unixfilesystem.cc
+++ b/base/unixfilesystem.cc
@@ -44,6 +44,7 @@
 #include <sys/syslimits.h>
 #endif
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/fileutils.h"
 #include "webrtc/base/pathutils.h"
 #include "webrtc/base/stream.h"
@@ -176,7 +177,7 @@
                         kCreateFolder, &fr))
     return false;
   unsigned char buffer[NAME_MAX+1];
-  if (0 != FSRefMakePath(&fr, buffer, ARRAY_SIZE(buffer)))
+  if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
     return false;
   pathname.SetPathname(reinterpret_cast<char*>(buffer), "");
 #elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
@@ -303,7 +304,7 @@
 #endif  // WEBRTC_MAC && !defined(WEBRTC_IOS)
 #endif  // WEBRTC_ANDROID || WEBRTC_IOS
   };
-  for (size_t i = 0; i < ARRAY_SIZE(kTempPrefixes); ++i) {
+  for (size_t i = 0; i < arraysize(kTempPrefixes); ++i) {
     if (0 == strncmp(pathname.pathname().c_str(), kTempPrefixes[i],
                      strlen(kTempPrefixes[i])))
       return true;
@@ -377,7 +378,7 @@
   return true;
 #else  // WEBRTC_MAC && !defined(WEBRTC_IOS)
   char buffer[PATH_MAX + 2];
-  ssize_t len = readlink("/proc/self/exe", buffer, ARRAY_SIZE(buffer) - 1);
+  ssize_t len = readlink("/proc/self/exe", buffer, arraysize(buffer) - 1);
   if ((len <= 0) || (len == PATH_MAX + 1))
     return false;
   buffer[len] = '\0';
@@ -399,7 +400,7 @@
                           kCreateFolder, &fr))
       return false;
     unsigned char buffer[NAME_MAX+1];
-    if (0 != FSRefMakePath(&fr, buffer, ARRAY_SIZE(buffer)))
+    if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
       return false;
     path->SetPathname(reinterpret_cast<char*>(buffer), "");
   } else {
@@ -487,7 +488,7 @@
 
   // Create a random directory as /tmp/<appname>-<pid>-<timestamp>
   char buffer[128];
-  sprintfn(buffer, ARRAY_SIZE(buffer), "-%d-%d",
+  sprintfn(buffer, arraysize(buffer), "-%d-%d",
            static_cast<int>(getpid()),
            static_cast<int>(time(0)));
   std::string folder(application_name_);
diff --git a/base/urlencode_unittest.cc b/base/urlencode_unittest.cc
index 5216913..6a61db3 100644
--- a/base/urlencode_unittest.cc
+++ b/base/urlencode_unittest.cc
@@ -8,6 +8,7 @@
  *  be found in the AUTHORS file in the root of the source tree.
  */
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/thread.h"
@@ -19,7 +20,7 @@
   char source[] = "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
       "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
   char dest[1];
-  ASSERT_EQ(0, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+  ASSERT_EQ(0, UrlEncode(source, dest, arraysize(dest)));
   ASSERT_EQ('\0', dest[0]);
 
   dest[0] = 'a';
@@ -30,7 +31,7 @@
 TEST(Urlencode, OneCharacterConversion) {
   char source[] = "^";
   char dest[4];
-  ASSERT_EQ(3, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+  ASSERT_EQ(3, UrlEncode(source, dest, arraysize(dest)));
   ASSERT_STREQ("%5E", dest);
 }
 
@@ -40,7 +41,7 @@
   // hold the text given.
   char source[] = "aa";
   char dest[3];
-  ASSERT_EQ(2, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+  ASSERT_EQ(2, UrlEncode(source, dest, arraysize(dest)));
   ASSERT_STREQ("aa", dest);
 }
 
@@ -49,14 +50,14 @@
   // big enough to hold the encoding.
   char source[] = "&";
   char dest[3];
-  ASSERT_EQ(0, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+  ASSERT_EQ(0, UrlEncode(source, dest, arraysize(dest)));
   ASSERT_EQ('\0', dest[0]);
 }
 
 TEST(Urlencode, Encoding1) {
   char source[] = "A^ ";
   char dest[8];
-  ASSERT_EQ(5, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+  ASSERT_EQ(5, UrlEncode(source, dest, arraysize(dest)));
   ASSERT_STREQ("A%5E+", dest);
 }
 
@@ -64,7 +65,7 @@
   char source[] = "A^ ";
   char dest[8];
   ASSERT_EQ(7, rtc::UrlEncodeWithoutEncodingSpaceAsPlus(source, dest,
-                                                        ARRAY_SIZE(dest)));
+                                                        arraysize(dest)));
   ASSERT_STREQ("A%5E%20", dest);
 }
 
diff --git a/base/virtualsocket_unittest.cc b/base/virtualsocket_unittest.cc
index 694b154..68ad23b 100644
--- a/base/virtualsocket_unittest.cc
+++ b/base/virtualsocket_unittest.cc
@@ -14,6 +14,7 @@
 #include <netinet/in.h>
 #endif
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/logging.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/testclient.h"
@@ -1022,9 +1023,9 @@
   const double kTestDev[] = { 0.25, 0.1, 0.01 };
   // TODO: The current code only works for 1000 data points or more.
   const uint32_t kTestSamples[] = {/*10, 100,*/ 1000};
-  for (size_t midx = 0; midx < ARRAY_SIZE(kTestMean); ++midx) {
-    for (size_t didx = 0; didx < ARRAY_SIZE(kTestDev); ++didx) {
-      for (size_t sidx = 0; sidx < ARRAY_SIZE(kTestSamples); ++sidx) {
+  for (size_t midx = 0; midx < arraysize(kTestMean); ++midx) {
+    for (size_t didx = 0; didx < arraysize(kTestDev); ++didx) {
+      for (size_t sidx = 0; sidx < arraysize(kTestSamples); ++sidx) {
         ASSERT_LT(0u, kTestSamples[sidx]);
         const uint32_t kStdDev =
             static_cast<uint32_t>(kTestDev[didx] * kTestMean[midx]);
diff --git a/base/win32.cc b/base/win32.cc
index 6e09829..182b84f 100644
--- a/base/win32.cc
+++ b/base/win32.cc
@@ -14,6 +14,7 @@
 #include <ws2tcpip.h>
 #include <algorithm>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/basictypes.h"
 #include "webrtc/base/byteorder.h"
 #include "webrtc/base/common.h"
@@ -87,7 +88,7 @@
   int current = 1;
   int max = 0;
   int maxpos = -1;
-  int run_array_size = ARRAY_SIZE(runpos);
+  int run_array_size = arraysize(runpos);
   // Run over the address marking runs of 0s.
   for (int i = 0; i < run_array_size; ++i) {
     if (as_shorts[i] == 0) {
diff --git a/base/win32filesystem.cc b/base/win32filesystem.cc
index 8ac918f..b731974 100644
--- a/base/win32filesystem.cc
+++ b/base/win32filesystem.cc
@@ -15,6 +15,7 @@
 #include <shlobj.h>
 #include <tchar.h>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/fileutils.h"
 #include "webrtc/base/pathutils.h"
 #include "webrtc/base/scoped_ptr.h"
@@ -197,16 +198,16 @@
 bool Win32Filesystem::GetTemporaryFolder(Pathname &pathname, bool create,
                                          const std::string *append) {
   wchar_t buffer[MAX_PATH + 1];
-  if (!::GetTempPath(ARRAY_SIZE(buffer), buffer))
+  if (!::GetTempPath(arraysize(buffer), buffer))
     return false;
   if (!IsCurrentProcessLowIntegrity() &&
-      !::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
+      !::GetLongPathName(buffer, buffer, arraysize(buffer)))
     return false;
   size_t len = strlen(buffer);
   if ((len > 0) && (buffer[len-1] != '\\')) {
-    len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, L"\\");
+    len += strcpyn(buffer + len, arraysize(buffer) - len, L"\\");
   }
-  if (len >= ARRAY_SIZE(buffer) - 1)
+  if (len >= arraysize(buffer) - 1)
     return false;
   pathname.clear();
   pathname.SetFolder(ToUtf8(buffer));
@@ -295,10 +296,10 @@
 
 bool Win32Filesystem::IsTemporaryPath(const Pathname& pathname) {
   TCHAR buffer[MAX_PATH + 1];
-  if (!::GetTempPath(ARRAY_SIZE(buffer), buffer))
+  if (!::GetTempPath(arraysize(buffer), buffer))
     return false;
   if (!IsCurrentProcessLowIntegrity() &&
-      !::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
+      !::GetLongPathName(buffer, buffer, arraysize(buffer)))
     return false;
   return (::strnicmp(ToUtf16(pathname.pathname()).c_str(),
                      buffer, strlen(buffer)) == 0);
@@ -337,7 +338,7 @@
 
 bool Win32Filesystem::GetAppPathname(Pathname* path) {
   TCHAR buffer[MAX_PATH + 1];
-  if (0 == ::GetModuleFileName(NULL, buffer, ARRAY_SIZE(buffer)))
+  if (0 == ::GetModuleFileName(NULL, buffer, arraysize(buffer)))
     return false;
   path->SetPathname(ToUtf8(buffer));
   return true;
@@ -351,20 +352,20 @@
   if (!::SHGetSpecialFolderPath(NULL, buffer, csidl, TRUE))
     return false;
   if (!IsCurrentProcessLowIntegrity() &&
-      !::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
+      !::GetLongPathName(buffer, buffer, arraysize(buffer)))
     return false;
-  size_t len = strcatn(buffer, ARRAY_SIZE(buffer), __T("\\"));
-  len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len,
+  size_t len = strcatn(buffer, arraysize(buffer), __T("\\"));
+  len += strcpyn(buffer + len, arraysize(buffer) - len,
                  ToUtf16(organization_name_).c_str());
   if ((len > 0) && (buffer[len-1] != __T('\\'))) {
-    len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, __T("\\"));
+    len += strcpyn(buffer + len, arraysize(buffer) - len, __T("\\"));
   }
-  len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len,
+  len += strcpyn(buffer + len, arraysize(buffer) - len,
                  ToUtf16(application_name_).c_str());
   if ((len > 0) && (buffer[len-1] != __T('\\'))) {
-    len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, __T("\\"));
+    len += strcpyn(buffer + len, arraysize(buffer) - len, __T("\\"));
   }
-  if (len >= ARRAY_SIZE(buffer) - 1)
+  if (len >= arraysize(buffer) - 1)
     return false;
   path->clear();
   path->SetFolder(ToUtf8(buffer));
diff --git a/base/win32regkey_unittest.cc b/base/win32regkey_unittest.cc
index 389c3a2..1702ef7 100644
--- a/base/win32regkey_unittest.cc
+++ b/base/win32regkey_unittest.cc
@@ -10,6 +10,7 @@
 
 // Unittest for registry access API
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/win32regkey.h"
@@ -564,8 +565,8 @@
 #ifdef IS_PRIVATE_BUILD
   // get a temp file name
   wchar_t temp_path[MAX_PATH] = {0};
-  EXPECT_LT(::GetTempPath(ARRAY_SIZE(temp_path), temp_path),
-            static_cast<DWORD>(ARRAY_SIZE(temp_path)));
+  EXPECT_LT(::GetTempPath(arraysize(temp_path), temp_path),
+            static_cast<DWORD>(arraysize(temp_path)));
   wchar_t temp_file[MAX_PATH] = {0};
   EXPECT_NE(::GetTempFileName(temp_path, L"rkut_",
                               ::GetTickCount(), temp_file), 0);
diff --git a/base/win32windowpicker.cc b/base/win32windowpicker.cc
index b4550ae..da05a5c 100644
--- a/base/win32windowpicker.cc
+++ b/base/win32windowpicker.cc
@@ -12,6 +12,7 @@
 #include <string>
 #include <vector>
 
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
 
@@ -58,7 +59,7 @@
   }
 
   TCHAR window_title[500];
-  GetWindowText(hwnd, window_title, ARRAY_SIZE(window_title));
+  GetWindowText(hwnd, window_title, arraysize(window_title));
   std::string title = ToUtf8(window_title);
 
   WindowId id(hwnd);
diff --git a/base/win32windowpicker_unittest.cc b/base/win32windowpicker_unittest.cc
index 71e8af6..701bb27 100644
--- a/base/win32windowpicker_unittest.cc
+++ b/base/win32windowpicker_unittest.cc
@@ -7,6 +7,7 @@
  *  in the file PATENTS.  All contributing project authors may
  *  be found in the AUTHORS file in the root of the source tree.
  */
+#include "webrtc/base/arraysize.h"
 #include "webrtc/base/gunit.h"
 #include "webrtc/base/common.h"
 #include "webrtc/base/logging.h"
@@ -71,7 +72,7 @@
   EXPECT_EQ(window_picker.visible_window()->handle(), desc.id().id());
   TCHAR window_title[500];
   GetWindowText(window_picker.visible_window()->handle(), window_title,
-                ARRAY_SIZE(window_title));
+                arraysize(window_title));
   EXPECT_EQ(0, wcscmp(window_title, kVisibleWindowTitle));
 }