diff --git a/BUILD.gn b/BUILD.gn
index edeb047..61b8940 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -653,6 +653,8 @@
       "//mash:all",
       "//media/mojo/services:media_service_unittests",
       "//mojo",
+      "//ui/views/mus:views_mus_interactive_ui_tests",
+      "//ui/views/mus:views_mus_unittests",
     ]
 
     # crbug.com/676055: media_service_unittests fails to link under Windows
@@ -1184,7 +1186,10 @@
       ]
     }
     if (enable_ipc_fuzzer && !is_component_build) {
-      deps += [ "//tools/ipc_fuzzer:ipc_fuzzer_all" ]
+      deps += [
+        "//chrome/app:service_manifests",
+        "//tools/ipc_fuzzer:ipc_fuzzer_all",
+      ]
     }
     if (!is_chromeos) {
       deps += [
diff --git a/DEPS b/DEPS
index 455c8e7b..4335a8e 100644
--- a/DEPS
+++ b/DEPS
@@ -121,11 +121,11 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling Skia
   # and whatever else without interference from each other.
-  'skia_revision': 'f16825ed3c715131489ed574ddd40533e7f0277f',
+  'skia_revision': '212e9060ed298e8aa89e52080f8e80b033c95714',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling V8
   # and whatever else without interference from each other.
-  'v8_revision': 'f6f84c97a6497408eedc6e4fa6877c9239d5c473',
+  'v8_revision': 'cdef3415a2805f926e6da2d5da25da678867c821',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling swarming_client
   # and whatever else without interference from each other.
@@ -133,7 +133,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling ANGLE
   # and whatever else without interference from each other.
-  'angle_revision': '8441286093152097eda821869d2743a85759ff7b',
+  'angle_revision': '7f6b3674978d1852e06263821c99403e3259d397',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling build tools
   # and whatever else without interference from each other.
@@ -181,7 +181,7 @@
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling catapult
   # and whatever else without interference from each other.
-  'catapult_revision': '7c1d51b169edfb62a3e2f88730f1182240cfe981',
+  'catapult_revision': 'a923c2a6de79f0f209157ab09849d695a98f4470',
   # Three lines of non-changing comments so that
   # the commit queue can handle CLs rolling libFuzzer
   # and whatever else without interference from each other.
@@ -679,7 +679,7 @@
 
   # Build tools for Chrome OS. Note: This depends on third_party/pyelftools.
   'src/third_party/chromite': {
-      'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '2c70338572204ba8c265f015b3097d1e60a699c1',
+      'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '3d335bee0f8d8fa3c56c89d38270afbe012a7b68',
       'condition': 'checkout_linux',
   },
 
@@ -892,7 +892,7 @@
     Var('chromium_git') + '/external/libaddressinput.git' + '@' + 'd7ed8e2f3f35ce9a3aafdfdc48745ceab66e7229',
 
   'src/third_party/libaom/source/libaom':
-    Var('aomedia_git') + '/aom.git' + '@' +  'f90004a14ea8c2990e6cdb0961517760a6a2ffa9',
+    Var('aomedia_git') + '/aom.git' + '@' +  '20a747b9ce5ec99ad2f78dd206a3fc1b8abf6850',
 
   # Userspace interface to kernel DRM services.
   'src/third_party/libdrm/src': {
@@ -1036,7 +1036,7 @@
   },
 
   'src/third_party/perfetto':
-    Var('android_git') + '/platform/external/perfetto.git' + '@' +  'b6175dc5dc3af85707b8a5d6def5bd206430453a',
+    Var('android_git') + '/platform/external/perfetto.git' + '@' +  '5a17545b5ab9cf380fc06c00e5080e2179c96762',
 
   'src/third_party/perl': {
       'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + 'ac0d98b5cee6c024b0cffeb4f8f45b6fc5ccdb78',
@@ -1230,7 +1230,7 @@
     Var('chromium_git') + '/v8/v8.git' + '@' +  Var('v8_revision'),
 
   'src-internal': {
-    'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@ff16c5b02fa501739c85ae01e5b8a931b08def76',
+    'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@85aaf9aabaf35ab7b2530d9c7ddb4cfacf481eee',
     'condition': 'checkout_src_internal',
   },
 
diff --git a/apps/load_and_launch_browsertest.cc b/apps/load_and_launch_browsertest.cc
index 8aca4a0..491dfac 100644
--- a/apps/load_and_launch_browsertest.cc
+++ b/apps/load_and_launch_browsertest.cc
@@ -8,6 +8,7 @@
 
 #include "apps/switches.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/test_timeouts.h"
 #include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
@@ -53,7 +54,7 @@
   const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess();
   base::CommandLine new_cmdline(cmdline.GetProgram());
   new_cmdline.CopySwitchesFrom(cmdline, kSwitchesToCopy,
-                               arraysize(kSwitchesToCopy));
+                               base::size(kSwitchesToCopy));
 
   base::FilePath app_path = test_data_dir_
       .AppendASCII("platform_apps")
@@ -89,7 +90,7 @@
   const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess();
   base::CommandLine new_cmdline(cmdline.GetProgram());
   new_cmdline.CopySwitchesFrom(cmdline, kSwitchesToCopy,
-                               arraysize(kSwitchesToCopy));
+                               base::size(kSwitchesToCopy));
 
   base::FilePath app_path = test_data_dir_
       .AppendASCII("platform_apps")
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index 9e3c6e9..9248c0d 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -39,6 +39,7 @@
 #include "ash/wm/wm_event.h"
 #include "base/command_line.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/metrics/user_action_tester.h"
 #include "base/test/scoped_feature_list.h"
 #include "services/media_session/public/cpp/test/test_media_controller.h"
@@ -615,7 +616,7 @@
       {true, ui::VKEY_J, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN},
       {true, ui::VKEY_K, ui::EF_ALT_DOWN, TOGGLE_FULLSCREEN},
   };
-  GetController()->RegisterAccelerators(accelerators, arraysize(accelerators));
+  GetController()->RegisterAccelerators(accelerators, base::size(accelerators));
 
   views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
   params.bounds = gfx::Rect(5, 5, 20, 20);
diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc
index 3bd0f13..26180e4c 100644
--- a/ash/accelerators/accelerator_table.cc
+++ b/ash/accelerators/accelerator_table.cc
@@ -5,7 +5,7 @@
 #include "ash/accelerators/accelerator_table.h"
 
 #include "ash/strings/grit/ash_strings.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ash {
 
@@ -43,7 +43,8 @@
     {true, ui::VKEY_H, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN,
      TOGGLE_HIGH_CONTRAST}};
 
-const size_t kDeprecatedAcceleratorsLength = arraysize(kDeprecatedAccelerators);
+const size_t kDeprecatedAcceleratorsLength =
+    base::size(kDeprecatedAccelerators);
 
 const DeprecatedAcceleratorData kDeprecatedAcceleratorsData[] = {
     {
@@ -67,7 +68,7 @@
     }};
 
 const size_t kDeprecatedAcceleratorsDataLength =
-    arraysize(kDeprecatedAcceleratorsData);
+    base::size(kDeprecatedAcceleratorsData);
 
 const AcceleratorData kDebugAcceleratorData[] = {
     {true, ui::VKEY_N, kDebugModifier, TOGGLE_WIFI},
@@ -90,7 +91,7 @@
     {true, ui::VKEY_K, kDebugModifier, DEBUG_TRIGGER_CRASH},
 };
 
-const size_t kDebugAcceleratorDataLength = arraysize(kDebugAcceleratorData);
+const size_t kDebugAcceleratorDataLength = base::size(kDebugAcceleratorData);
 
 const AcceleratorData kDeveloperAcceleratorData[] = {
     // Extra shortcut for debug build to control magnifier on Linux desktop.
@@ -122,7 +123,7 @@
 };
 
 const size_t kDeveloperAcceleratorDataLength =
-    arraysize(kDeveloperAcceleratorData);
+    base::size(kDeveloperAcceleratorData);
 
 const AcceleratorAction kPreferredActions[] = {
     // Window cycling accelerators.
@@ -130,13 +131,13 @@
     CYCLE_FORWARD_MRU,   // Alt+Tab
 };
 
-const size_t kPreferredActionsLength = arraysize(kPreferredActions);
+const size_t kPreferredActionsLength = base::size(kPreferredActions);
 
 const AcceleratorAction kReservedActions[] = {
     POWER_PRESSED, POWER_RELEASED, SUSPEND,
 };
 
-const size_t kReservedActionsLength = arraysize(kReservedActions);
+const size_t kReservedActionsLength = base::size(kReservedActions);
 
 const AcceleratorAction kActionsAllowedAtLoginOrLockScreen[] = {
     BRIGHTNESS_DOWN,
@@ -184,21 +185,21 @@
 };
 
 const size_t kActionsAllowedAtLoginOrLockScreenLength =
-    arraysize(kActionsAllowedAtLoginOrLockScreen);
+    base::size(kActionsAllowedAtLoginOrLockScreen);
 
 const AcceleratorAction kActionsAllowedAtLockScreen[] = {
     EXIT, SUSPEND,
 };
 
 const size_t kActionsAllowedAtLockScreenLength =
-    arraysize(kActionsAllowedAtLockScreen);
+    base::size(kActionsAllowedAtLockScreen);
 
 const AcceleratorAction kActionsAllowedAtPowerMenu[] = {
     BRIGHTNESS_DOWN, BRIGHTNESS_UP, VOLUME_DOWN, VOLUME_UP, VOLUME_MUTE,
 };
 
 const size_t kActionsAllowedAtPowerMenuLength =
-    arraysize(kActionsAllowedAtPowerMenu);
+    base::size(kActionsAllowedAtPowerMenu);
 
 const AcceleratorAction kActionsAllowedAtModalWindow[] = {
     BRIGHTNESS_DOWN,
@@ -247,7 +248,7 @@
 };
 
 const size_t kActionsAllowedAtModalWindowLength =
-    arraysize(kActionsAllowedAtModalWindow);
+    base::size(kActionsAllowedAtModalWindow);
 
 const AcceleratorAction kRepeatableActions[] = {
     BRIGHTNESS_DOWN,
@@ -265,7 +266,7 @@
     VOLUME_UP,
 };
 
-const size_t kRepeatableActionsLength = arraysize(kRepeatableActions);
+const size_t kRepeatableActionsLength = base::size(kRepeatableActions);
 
 const AcceleratorAction kActionsAllowedInAppModeOrPinnedMode[] = {
     BRIGHTNESS_DOWN,
@@ -309,7 +310,7 @@
 };
 
 const size_t kActionsAllowedInAppModeOrPinnedModeLength =
-    arraysize(kActionsAllowedInAppModeOrPinnedMode);
+    base::size(kActionsAllowedInAppModeOrPinnedMode);
 
 const AcceleratorAction kActionsAllowedInPinnedMode[] = {
     LOCK_SCREEN,
@@ -321,7 +322,7 @@
 };
 
 const size_t kActionsAllowedInPinnedModeLength =
-    arraysize(kActionsAllowedInPinnedMode);
+    base::size(kActionsAllowedInPinnedMode);
 
 const AcceleratorAction kActionsNeedingWindow[] = {
     CYCLE_BACKWARD_MRU,
@@ -336,7 +337,7 @@
     WINDOW_POSITION_CENTER,
 };
 
-const size_t kActionsNeedingWindowLength = arraysize(kActionsNeedingWindow);
+const size_t kActionsNeedingWindowLength = base::size(kActionsNeedingWindow);
 
 const AcceleratorAction kActionsKeepingMenuOpen[] = {
     BRIGHTNESS_DOWN,
@@ -368,6 +369,7 @@
     VOLUME_UP,
 };
 
-const size_t kActionsKeepingMenuOpenLength = arraysize(kActionsKeepingMenuOpen);
+const size_t kActionsKeepingMenuOpenLength =
+    base::size(kActionsKeepingMenuOpen);
 
 }  // namespace ash
diff --git a/ash/accessibility/touch_exploration_controller_unittest.cc b/ash/accessibility/touch_exploration_controller_unittest.cc
index c6c97ff..ed0094f 100644
--- a/ash/accessibility/touch_exploration_controller_unittest.cc
+++ b/ash/accessibility/touch_exploration_controller_unittest.cc
@@ -10,8 +10,8 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "base/time/time.h"
 #include "ui/aura/client/cursor_client.h"
@@ -1262,7 +1262,7 @@
   // detector test, since it seems to be about the right amount to get a swipe.
   const int kSteps = 15;
 
-  for (size_t i = 0; i < arraysize(gestures_to_test); ++i) {
+  for (size_t i = 0; i < base::size(gestures_to_test); ++i) {
     const float distance = 2 * gesture_detector_config_.touch_slop + 1;
     int move_x = gestures_to_test[i].move_x * distance;
     int move_y = gestures_to_test[i].move_y * distance;
diff --git a/ash/app_list/views/pulsing_block_view.cc b/ash/app_list/views/pulsing_block_view.cc
index c1ed1ea..65f838d 100644
--- a/ash/app_list/views/pulsing_block_view.cc
+++ b/ash/app_list/views/pulsing_block_view.cc
@@ -9,8 +9,8 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/compositor/layer.h"
 #include "ui/compositor/layer_animation_element.h"
@@ -30,7 +30,7 @@
 
 void SchedulePulsingAnimation(ui::Layer* layer) {
   DCHECK(layer);
-  DCHECK_EQ(arraysize(kAnimationOpacity), arraysize(kAnimationScale));
+  DCHECK_EQ(base::size(kAnimationOpacity), base::size(kAnimationScale));
 
   std::unique_ptr<ui::LayerAnimationSequence> opacity_sequence =
       std::make_unique<ui::LayerAnimationSequence>();
@@ -42,7 +42,7 @@
   transform_sequence->set_is_cyclic(true);
 
   const gfx::Rect local_bounds(layer->bounds().size());
-  for (size_t i = 0; i < arraysize(kAnimationOpacity); ++i) {
+  for (size_t i = 0; i < base::size(kAnimationOpacity); ++i) {
     opacity_sequence->AddElement(
         ui::LayerAnimationElement::CreateOpacityElement(
             kAnimationOpacity[i],
@@ -76,7 +76,7 @@
   SetPaintToLayer();
   layer()->SetFillsBoundsOpaquely(false);
 
-  const int max_delay = kAnimationDurationInMs * arraysize(kAnimationOpacity);
+  const int max_delay = kAnimationDurationInMs * base::size(kAnimationOpacity);
   const int delay = start_delay ? base::RandInt(0, max_delay) : 0;
   start_delay_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(delay),
                            this, &PulsingBlockView::OnStartDelayTimer);
diff --git a/ash/components/tap_visualizer/tap_renderer.cc b/ash/components/tap_visualizer/tap_renderer.cc
index 218fccc..a7e78c4 100644
--- a/ash/components/tap_visualizer/tap_renderer.cc
+++ b/ash/components/tap_visualizer/tap_renderer.cc
@@ -5,6 +5,7 @@
 #include "ash/components/tap_visualizer/tap_renderer.h"
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "cc/paint/paint_flags.h"
 #include "third_party/skia/include/effects/SkGradientShader.h"
@@ -80,7 +81,7 @@
     stroke_flags_.setAlpha(alpha);
     fill_flags_.setShader(cc::PaintShader::MakeRadialGradient(
         gradient_center_, SkIntToScalar(kPointRadius), gradient_colors_,
-        gradient_pos_, arraysize(gradient_colors_),
+        gradient_pos_, base::size(gradient_colors_),
         SkShader::kMirror_TileMode));
     canvas->DrawCircle(circle_center_, SkIntToScalar(kPointRadius),
                        fill_flags_);
diff --git a/ash/events/keyboard_driven_event_rewriter_unittest.cc b/ash/events/keyboard_driven_event_rewriter_unittest.cc
index 4bac382..e1ec422e 100644
--- a/ash/events/keyboard_driven_event_rewriter_unittest.cc
+++ b/ash/events/keyboard_driven_event_rewriter_unittest.cc
@@ -8,7 +8,7 @@
 
 #include "ash/events/keyboard_driven_event_rewriter.h"
 #include "base/compiler_specific.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/event.h"
@@ -79,7 +79,7 @@
     { ui::VKEY_RETURN, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN },
   };
 
-  for (size_t i = 0; i < arraysize(kTests); ++i) {
+  for (size_t i = 0; i < base::size(kTests); ++i) {
     EXPECT_EQ(GetExpectedResultAsString(kTests[i].ui_flags,
                                         ui::EVENT_REWRITE_CONTINUE),
               GetRewrittenEventAsString(kTests[i].ui_keycode,
@@ -104,7 +104,7 @@
     { ui::VKEY_F6, kModifierMask },
   };
 
-  for (size_t i = 0; i < arraysize(kTests); ++i) {
+  for (size_t i = 0; i < base::size(kTests); ++i) {
     EXPECT_EQ(GetExpectedResultAsString(ui::EF_NONE,
                                         ui::EVENT_REWRITE_REWRITTEN),
               GetRewrittenEventAsString(kTests[i].ui_keycode,
diff --git a/ash/first_run/desktop_cleaner.cc b/ash/first_run/desktop_cleaner.cc
index 0a88c863..0d54d33 100644
--- a/ash/first_run/desktop_cleaner.cc
+++ b/ash/first_run/desktop_cleaner.cc
@@ -8,6 +8,7 @@
 
 #include "ash/public/cpp/shell_window_ids.h"
 #include "ash/shell.h"
+#include "base/stl_util.h"
 #include "ui/aura/window_event_dispatcher.h"
 #include "ui/aura/window_observer.h"
 #include "ui/compositor/layer_animation_observer.h"
@@ -93,7 +94,7 @@
 DesktopCleaner::DesktopCleaner() {
   // TODO(dzhioev): Add support for secondary displays.
   aura::Window* root_window = Shell::Get()->GetPrimaryRootWindow();
-  for (size_t i = 0; i < arraysize(kContainerIdsToHide); ++i) {
+  for (size_t i = 0; i < base::size(kContainerIdsToHide); ++i) {
     aura::Window* container =
         Shell::GetContainer(root_window, kContainerIdsToHide[i]);
     container_hiders_.push_back(std::make_unique<ContainerHider>(container));
@@ -105,8 +106,9 @@
 
 // static
 std::vector<int> DesktopCleaner::GetContainersToHideForTest() {
-  return std::vector<int>(kContainerIdsToHide,
-                          kContainerIdsToHide + arraysize(kContainerIdsToHide));
+  return std::vector<int>(
+      kContainerIdsToHide,
+      kContainerIdsToHide + base::size(kContainerIdsToHide));
 }
 
 }  // namespace ash
diff --git a/ash/login/ui/lock_debug_view.cc b/ash/login/ui/lock_debug_view.cc
index 65465b8f..4693986 100644
--- a/ash/login/ui/lock_debug_view.cc
+++ b/ash/login/ui/lock_debug_view.cc
@@ -25,6 +25,7 @@
 #include "ash/shell.h"
 #include "ash/wallpaper/wallpaper_controller.h"
 #include "base/optional.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/base/ime/chromeos/ime_keyboard.h"
 #include "ui/views/controls/button/md_text_button.h"
@@ -531,7 +532,7 @@
   // Calculates the debugging detachable base ID that should become the paired
   // base in the model when the button for cycling paired bases is clicked.
   int NextBaseId() const {
-    return (base_id_ + 1) % arraysize(kDebugDetachableBases);
+    return (base_id_ + 1) % base::size(kDebugDetachableBases);
   }
 
   // Gets the descripting text for currently paired base, if any.
@@ -550,7 +551,7 @@
     pairing_status_ = pairing_status;
     if (pairing_status == DetachableBasePairingStatus::kAuthenticated) {
       CHECK_GE(base_id, 0);
-      CHECK_LT(base_id, static_cast<int>(arraysize(kDebugDetachableBases)));
+      CHECK_LT(base_id, static_cast<int>(base::size(kDebugDetachableBases)));
       base_id_ = base_id;
     } else {
       base_id_ = kNullBaseId;
diff --git a/ash/login/ui/login_pin_view.cc b/ash/login/ui/login_pin_view.cc
index 9f4d37d..f63ccfe 100644
--- a/ash/login/ui/login_pin_view.cc
+++ b/ash/login/ui/login_pin_view.cc
@@ -12,6 +12,7 @@
 #include "ash/resources/vector_icons/vector_icons.h"
 #include "ash/strings/grit/ash_strings.h"
 #include "base/callback.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/timer/timer.h"
 #include "ui/accessibility/ax_node_data.h"
@@ -58,12 +59,12 @@
 constexpr int kRippleSizeDp = 54;
 
 base::string16 GetButtonLabelForNumber(int value) {
-  DCHECK(value >= 0 && value < int{arraysize(kPinLabels)});
+  DCHECK(value >= 0 && value < int{base::size(kPinLabels)});
   return base::ASCIIToUTF16(std::to_string(value));
 }
 
 base::string16 GetButtonSubLabelForNumber(int value) {
-  DCHECK(value >= 0 && value < int{arraysize(kPinLabels)});
+  DCHECK(value >= 0 && value < int{base::size(kPinLabels)});
   return base::ASCIIToUTF16(kPinLabels[value]);
 }
 
diff --git a/ash/public/cpp/accelerators.cc b/ash/public/cpp/accelerators.cc
index 3b82a84..25fd18f3 100644
--- a/ash/public/cpp/accelerators.cc
+++ b/ash/public/cpp/accelerators.cc
@@ -4,7 +4,7 @@
 
 #include "ash/public/cpp/accelerators.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ash {
 
@@ -175,6 +175,6 @@
     // VKEY_MEDIA_LAUNCH_MAIL.
 };
 
-const size_t kAcceleratorDataLength = arraysize(kAcceleratorData);
+const size_t kAcceleratorDataLength = base::size(kAcceleratorData);
 
 }  // namespace ash
diff --git a/ash/public/cpp/shell_window_ids.cc b/ash/public/cpp/shell_window_ids.cc
index facea8e..fe1da849 100644
--- a/ash/public/cpp/shell_window_ids.cc
+++ b/ash/public/cpp/shell_window_ids.cc
@@ -4,7 +4,7 @@
 
 #include "ash/public/cpp/shell_window_ids.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ash {
 
@@ -28,7 +28,7 @@
 };
 
 const size_t kNumActivatableShellWindowIds =
-    arraysize(kActivatableShellWindowIds);
+    base::size(kActivatableShellWindowIds);
 
 bool IsActivatableShellWindowId(int32_t id) {
   for (size_t i = 0; i < kNumActivatableShellWindowIds; i++) {
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 46ecafb..496cbd72 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -58,8 +58,8 @@
 #include "ash/wm/workspace/workspace_layout_manager.h"
 #include "ash/wm/workspace_controller.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "chromeos/chromeos_switches.h"
 #include "ui/aura/client/aura_constants.h"
@@ -209,7 +209,7 @@
   };
   std::vector<int> container_ids(
       kContainerIdsToMove,
-      kContainerIdsToMove + arraysize(kContainerIdsToMove));
+      kContainerIdsToMove + base::size(kContainerIdsToMove));
   // Check the display mode as this is also necessary when trasitioning between
   // mirror and unified mode.
   if (Shell::Get()->display_manager()->current_default_multi_display_mode() ==
diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc
index 402a9a7..74a88ff 100644
--- a/ash/shelf/shelf_button.cc
+++ b/ash/shelf/shelf_button.cc
@@ -14,6 +14,7 @@
 #include "ash/shelf/shelf_view.h"
 #include "ash/system/tray/tray_popup_utils.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "chromeos/chromeos_switches.h"
 #include "skia/ext/image_operations.h"
@@ -314,7 +315,7 @@
       gfx::ShadowValue(gfx::Vector2d(0, 3), 1, SkColorSetARGB(0x1A, 0, 0, 0)),
       gfx::ShadowValue(gfx::Vector2d(0, 0), 1, SkColorSetARGB(0x54, 0, 0, 0)),
   };
-  icon_shadows_.assign(kShadows, kShadows + arraysize(kShadows));
+  icon_shadows_.assign(kShadows, kShadows + base::size(kShadows));
 
   // TODO: refactor the layers so each button doesn't require 3.
   // |icon_view_| needs its own layer so it can be scaled up independently of
diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc
index 831adfb9..18a0918b5 100644
--- a/ash/shell/app_list.cc
+++ b/ash/shell/app_list.cc
@@ -24,6 +24,7 @@
 #include "base/files/file_path.h"
 #include "base/i18n/case_conversion.h"
 #include "base/i18n/string_search.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -63,7 +64,7 @@
     const int kIconSize = 128;
     SkBitmap icon;
     icon.allocN32Pixels(kIconSize, kIconSize);
-    icon.eraseColor(kColors[static_cast<int>(type) % arraysize(kColors)]);
+    icon.eraseColor(kColors[static_cast<int>(type) % base::size(kColors)]);
     return gfx::ImageSkia::CreateFrom1xBitmap(icon);
   }
 
diff --git a/ash/shell/window_type_launcher.cc b/ash/shell/window_type_launcher.cc
index 14e7d0b2..6c87b31 100644
--- a/ash/shell/window_type_launcher.cc
+++ b/ash/shell/window_type_launcher.cc
@@ -13,6 +13,7 @@
 #include "ash/shell/example_factory.h"
 #include "ash/shell/toplevel_window.h"
 #include "ash/wm/test_child_modal_parent.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_event_dispatcher.h"
@@ -50,7 +51,7 @@
       : modal_type_(modal_type),
         color_(kColors[g_color_index]),
         open_button_(MdTextButton::Create(this, base::ASCIIToUTF16("Moar!"))) {
-    ++g_color_index %= arraysize(kColors);
+    ++g_color_index %= base::size(kColors);
     AddChildView(open_button_);
   }
   ~ModalWindow() override = default;
@@ -100,7 +101,7 @@
 class NonModalTransient : public views::WidgetDelegateView {
  public:
   NonModalTransient() : color_(kColors[g_color_index]) {
-    ++g_color_index %= arraysize(kColors);
+    ++g_color_index %= base::size(kColors);
   }
   ~NonModalTransient() override = default;
 
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index 19b9828..e1e7e0d 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -27,7 +27,7 @@
 #include "ash/window_factory.h"
 #include "ash/wm/window_util.h"
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "components/account_id/account_id.h"
@@ -72,7 +72,7 @@
 // Expect ALL the containers!
 void ExpectAllContainers() {
   // Validate no duplicate container IDs.
-  const size_t all_shell_container_ids_size = arraysize(kAllShellContainerIds);
+  const size_t all_shell_container_ids_size = base::size(kAllShellContainerIds);
   std::set<int32_t> container_ids;
   for (size_t i = 0; i < all_shell_container_ids_size; ++i)
     EXPECT_TRUE(container_ids.insert(kAllShellContainerIds[i]).second);
diff --git a/ash/system/audio/unified_volume_view.cc b/ash/system/audio/unified_volume_view.cc
index 686cffa..c280c64 100644
--- a/ash/system/audio/unified_volume_view.cc
+++ b/ash/system/audio/unified_volume_view.cc
@@ -9,6 +9,7 @@
 #include "ash/system/audio/unified_volume_slider_controller.h"
 #include "ash/system/tray/tray_constants.h"
 #include "ash/system/tray/tray_popup_utils.h"
+#include "base/stl_util.h"
 #include "components/vector_icons/vector_icons.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/gfx/canvas.h"
@@ -39,7 +40,7 @@
 };
 
 // The maximum index of kVolumeLevelIcons.
-constexpr int kVolumeLevels = arraysize(kVolumeLevelIcons) - 1;
+constexpr int kVolumeLevels = base::size(kVolumeLevelIcons) - 1;
 
 // Get vector icon reference that corresponds to the given volume level. |level|
 // is between 0.0 to 1.0.
diff --git a/ash/wallpaper/wallpaper_utils/wallpaper_resizer_unittest.cc b/ash/wallpaper/wallpaper_utils/wallpaper_resizer_unittest.cc
index da6689b..f2153f5b 100644
--- a/ash/wallpaper/wallpaper_utils/wallpaper_resizer_unittest.cc
+++ b/ash/wallpaper/wallpaper_utils/wallpaper_resizer_unittest.cc
@@ -10,9 +10,9 @@
 
 #include "ash/public/cpp/wallpaper_types.h"
 #include "ash/wallpaper/wallpaper_utils/wallpaper_resizer_observer.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/threading/thread.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/image/image_skia_rep.h"
@@ -107,7 +107,7 @@
       WALLPAPER_LAYOUT_CENTER, WALLPAPER_LAYOUT_CENTER_CROPPED,
       WALLPAPER_LAYOUT_STRETCH, WALLPAPER_LAYOUT_TILE,
   };
-  const int length = arraysize(layouts);
+  const int length = base::size(layouts);
 
   for (int i = 0; i < length; i++) {
     WallpaperLayout layout = layouts[i];
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index 933d22a3..c5aa8d9 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -1440,7 +1440,7 @@
       {9, 8, 7, 6, 5, 4, 3, 2, 1, 9}   // Up (same as Left)
   };
 
-  for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) {
+  for (size_t key_index = 0; key_index < base::size(arrow_keys); key_index++) {
     ToggleOverview();
     const std::vector<std::unique_ptr<WindowSelectorItem>>& overview_windows =
         GetWindowItemsForRoot(0);
diff --git a/ash/wm/switchable_windows.cc b/ash/wm/switchable_windows.cc
index ef39a557..cf481d9 100644
--- a/ash/wm/switchable_windows.cc
+++ b/ash/wm/switchable_windows.cc
@@ -5,6 +5,7 @@
 #include "ash/wm/switchable_windows.h"
 
 #include "ash/public/cpp/shell_window_ids.h"
+#include "base/stl_util.h"
 #include "ui/aura/window.h"
 
 namespace ash {
@@ -15,7 +16,7 @@
     kShellWindowId_AppListContainer};
 
 const size_t kSwitchableWindowContainerIdsLength =
-    arraysize(kSwitchableWindowContainerIds);
+    base::size(kSwitchableWindowContainerIds);
 
 bool IsSwitchableContainer(const aura::Window* window) {
   if (!window)
diff --git a/ash/wm/tablet_mode/accelerometer_test_data_literals.cc b/ash/wm/tablet_mode/accelerometer_test_data_literals.cc
index 09cf518d..3246948 100644
--- a/ash/wm/tablet_mode/accelerometer_test_data_literals.cc
+++ b/ash/wm/tablet_mode/accelerometer_test_data_literals.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ash {
 
@@ -556,7 +556,7 @@
     0.0703125f,   -0.0986328f,   0.948242f,     -0.928711f,    -0.162109f,
     -0.333008f};
 extern const size_t kAccelerometerLaptopModeTestDataLength =
-    arraysize(kAccelerometerLaptopModeTestData);
+    base::size(kAccelerometerLaptopModeTestData);
 
 extern const float kAccelerometerFullyOpenTestData[] = {
     0.892578f,    -0.0810547f,  0.0146484f,    0.929688f,     -0.0644531f,
@@ -994,7 +994,7 @@
     0.887695f,    0.0146484f,   0.360352f,     0.927734f,     -0.03125f,
     0.272461f};
 extern const size_t kAccelerometerFullyOpenTestDataLength =
-    arraysize(kAccelerometerFullyOpenTestData);
+    base::size(kAccelerometerFullyOpenTestData);
 
 extern const float kAccelerometerVerticalHingeTestData[] = {
     -0.0766145f,  6.02381f,     7.85298f,     -0.268151f,   -8.84897f,
@@ -1996,7 +1996,7 @@
 };
 
 extern const size_t kAccelerometerVerticalHingeTestDataLength =
-    arraysize(kAccelerometerVerticalHingeTestData);
+    base::size(kAccelerometerVerticalHingeTestData);
 
 extern const float kAccelerometerVerticalHingeUnstableAnglesTestData[] = {
     8.5904f,   -1.36948f,  -3.74453f,   8.72447f,  1.1971f,    4.00311f,
@@ -2023,6 +2023,6 @@
 };
 
 extern const size_t kAccelerometerVerticalHingeUnstableAnglesTestDataLength =
-    arraysize(kAccelerometerVerticalHingeUnstableAnglesTestData);
+    base::size(kAccelerometerVerticalHingeUnstableAnglesTestData);
 
 }  // namespace ash
diff --git a/ash/wm/test_session_state_animator.cc b/ash/wm/test_session_state_animator.cc
index 77bbbc2..20edf41 100644
--- a/ash/wm/test_session_state_animator.cc
+++ b/ash/wm/test_session_state_animator.cc
@@ -9,6 +9,7 @@
 
 #include "base/barrier_closure.h"
 #include "base/bind.h"
+#include "base/stl_util.h"
 
 namespace ash {
 
@@ -175,7 +176,7 @@
 bool TestSessionStateAnimator::AreContainersAnimated(
     int container_mask,
     SessionStateAnimator::AnimationType type) const {
-  for (size_t i = 0; i < arraysize(kAllContainers); ++i) {
+  for (size_t i = 0; i < base::size(kAllContainers); ++i) {
     if (container_mask & kAllContainers[i] &&
         !IsContainerAnimated(kAllContainers[i], type)) {
       return false;
@@ -198,7 +199,7 @@
                                               AnimationType type,
                                               AnimationSpeed speed) {
   ++last_animation_epoch_;
-  for (size_t i = 0; i < arraysize(kAllContainers); ++i) {
+  for (size_t i = 0; i < base::size(kAllContainers); ++i) {
     if (container_mask & kAllContainers[i]) {
       // Use a dummy no-op callback because one isn't required by the client
       // but one is required when completing or aborting animations.
@@ -216,14 +217,14 @@
   ++last_animation_epoch_;
 
   int container_count = 0;
-  for (size_t i = 0; i < arraysize(kAllContainers); ++i) {
+  for (size_t i = 0; i < base::size(kAllContainers); ++i) {
     if (container_mask & kAllContainers[i])
       ++container_count;
   }
 
   base::RepeatingClosure completion_callback =
       base::BarrierClosure(container_count, std::move(callback));
-  for (size_t i = 0; i < arraysize(kAllContainers); ++i) {
+  for (size_t i = 0; i < base::size(kAllContainers); ++i) {
     if (container_mask & kAllContainers[i]) {
       // ash::SessionStateAnimatorImpl invokes the callback whether or not the
       // animation was completed successfully or not.
@@ -256,7 +257,7 @@
     AnimationSpeed speed,
     AnimationSequence* animation_sequence) {
   ++last_animation_epoch_;
-  for (size_t i = 0; i < arraysize(kAllContainers); ++i) {
+  for (size_t i = 0; i < base::size(kAllContainers); ++i) {
     if (container_mask & kAllContainers[i]) {
       base::Closure success_callback =
           base::Bind(&AnimationSequence::SequenceFinished,
diff --git a/ash/wm/window_modality_controller_unittest.cc b/ash/wm/window_modality_controller_unittest.cc
index ced6df83..b4a2abc 100644
--- a/ash/wm/window_modality_controller_unittest.cc
+++ b/ash/wm/window_modality_controller_unittest.cc
@@ -8,6 +8,7 @@
 #include "ash/test/ash_test_base.h"
 #include "ash/wm/test_child_modal_parent.h"
 #include "ash/wm/window_util.h"
+#include "base/stl_util.h"
 #include "services/ws/public/mojom/window_manager.mojom.h"
 #include "ui/aura/client/aura_constants.h"
 #include "ui/aura/client/capture_client.h"
@@ -67,14 +68,14 @@
   EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
 
   int check1[] = {-1, -12, -11};
-  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, arraysize(check1)));
+  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, base::size(check1)));
 
   wm::ActivateWindow(w1.get());
   EXPECT_TRUE(wm::IsActiveWindow(w12.get()));
   // Transient children are always stacked above their transient parent, which
   // is why this order is not -11, -1, -12.
   int check2[] = {-1, -11, -12};
-  EXPECT_TRUE(ValidateStacking(w1->parent(), check2, arraysize(check2)));
+  EXPECT_TRUE(ValidateStacking(w1->parent(), check2, base::size(check2)));
 
   w12.reset();
   EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
@@ -114,20 +115,20 @@
   wm::ActivateWindow(w1.get());
   EXPECT_TRUE(wm::IsActiveWindow(w111.get()));
   int check1[] = {-2, -1, -11, -111};
-  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, arraysize(check1)));
+  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, base::size(check1)));
 
   wm::ActivateWindow(w11.get());
   EXPECT_TRUE(wm::IsActiveWindow(w111.get()));
-  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, arraysize(check1)));
+  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, base::size(check1)));
 
   wm::ActivateWindow(w111.get());
   EXPECT_TRUE(wm::IsActiveWindow(w111.get()));
-  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, arraysize(check1)));
+  EXPECT_TRUE(ValidateStacking(w1->parent(), check1, base::size(check1)));
 
   wm::ActivateWindow(w2.get());
   EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
   int check2[] = {-1, -11, -111, -2};
-  EXPECT_TRUE(ValidateStacking(w1->parent(), check2, arraysize(check2)));
+  EXPECT_TRUE(ValidateStacking(w1->parent(), check2, base::size(check2)));
 
   w2.reset();
   EXPECT_TRUE(wm::IsActiveWindow(w111.get()));
diff --git a/cc/animation/keyframe_model.cc b/cc/animation/keyframe_model.cc
index 2e3c8d9..51449a9 100644
--- a/cc/animation/keyframe_model.cc
+++ b/cc/animation/keyframe_model.cc
@@ -7,6 +7,7 @@
 #include <cmath>
 
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/trace_event.h"
@@ -25,7 +26,7 @@
                                               "ABORTED_BUT_NEEDS_COMPLETION"};
 
 static_assert(static_cast<int>(cc::KeyframeModel::LAST_RUN_STATE) + 1 ==
-                  arraysize(s_runStateNames),
+                  base::size(s_runStateNames),
               "RunStateEnumSize should equal the number of elements in "
               "s_runStateNames");
 
@@ -33,7 +34,7 @@
     "COLOR", "FLOAT", "TRANSFORM", "FILTER", "SCROLL_OFFSET", "SIZE"};
 
 static_assert(static_cast<int>(cc::AnimationCurve::LAST_CURVE_TYPE) + 1 ==
-                  arraysize(s_curveTypeNames),
+                  base::size(s_curveTypeNames),
               "CurveType enum should equal the number of elements in "
               "s_runStateNames");
 
diff --git a/cc/animation/transform_operations_unittest.cc b/cc/animation/transform_operations_unittest.cc
index ac7e528..8f24cda 100644
--- a/cc/animation/transform_operations_unittest.cc
+++ b/cc/animation/transform_operations_unittest.cc
@@ -9,6 +9,7 @@
 #include <limits>
 #include <vector>
 
+#include "base/stl_util.h"
 #include "cc/test/geometry_test_utils.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/animation/tween.h"
@@ -1028,7 +1029,7 @@
   // Since we're rotating 360 degrees, any box with dimensions between 0 and
   // 2 * sqrt(2) should give the same result.
   float sizes[] = { 0.f, 0.1f, sqrt_2, 2.f * sqrt_2 };
-  for (size_t i = 0; i < arraysize(sizes); ++i) {
+  for (size_t i = 0; i < base::size(sizes); ++i) {
     box.set_size(sizes[i], sizes[i], 0.f);
     SkMScalar min_progress = 0.f;
     SkMScalar max_progress = 1.f;
@@ -1123,7 +1124,7 @@
                {0.f, 1.f, 1.f, gfx::BoxF(-1.f, dim1, dim1, 2.f, dim2, dim2)},
                {1.f, 0.f, 1.f, gfx::BoxF(dim1, -1.f, dim1, dim2, 2.f, dim2)}};
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     float x = tests[i].x;
     float y = tests[i].y;
     float z = tests[i].z;
@@ -1262,9 +1263,9 @@
         {0.f, 1.f}, {-.25f, 1.25f},
     };
 
-  for (size_t i = 0; i < arraysize(axes); ++i) {
-    for (size_t j = 0; j < arraysize(angles); ++j) {
-      for (size_t k = 0; k < arraysize(progress); ++k) {
+  for (size_t i = 0; i < base::size(axes); ++i) {
+    for (size_t j = 0; j < base::size(angles); ++j) {
+      for (size_t k = 0; k < base::size(progress); ++k) {
         float x = axes[i].x;
         float y = axes[i].y;
         float z = axes[i].z;
@@ -1325,8 +1326,8 @@
         {0.f, 1.f}, {-0.1f, 1.1f},
     };
 
-  for (size_t i = 0; i < arraysize(perspective_depths); ++i) {
-    for (size_t j = 0; j < arraysize(progress); ++j) {
+  for (size_t i = 0; i < base::size(perspective_depths); ++i) {
+    for (size_t j = 0; j < base::size(progress); ++j) {
       TransformOperations operations_from;
       operations_from.AppendPerspective(perspective_depths[i].from_depth);
       TransformOperations operations_to;
@@ -1356,8 +1357,8 @@
         {0.f, 1.f}, {-0.1f, 1.1f},
     };
 
-  for (size_t i = 0; i < arraysize(skews); ++i) {
-    for (size_t j = 0; j < arraysize(progress); ++j) {
+  for (size_t i = 0; i < base::size(skews); ++i) {
+    for (size_t j = 0; j < base::size(progress); ++j) {
       TransformOperations operations_from;
       operations_from.AppendSkew(skews[i].from_x, skews[i].from_y);
       TransformOperations operations_to;
diff --git a/cc/base/index_rect_unittest.cc b/cc/base/index_rect_unittest.cc
index aff41ee9..1580a39 100644
--- a/cc/base/index_rect_unittest.cc
+++ b/cc/base/index_rect_unittest.cc
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
 #include "cc/base/index_rect.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace cc {
@@ -22,7 +22,7 @@
                            {0, 0, 0, 0, 1, 1},
                            {10, 10, 10, 10, 1, 1}};
 
-  for (size_t i = 0; i < arraysize(num_indices_cases); ++i) {
+  for (size_t i = 0; i < base::size(num_indices_cases); ++i) {
     const NumIndicesCase& value = num_indices_cases[i];
     IndexRect rect(value.left, value.right, value.top, value.bottom);
     EXPECT_EQ(value.num_indices_x, rect.num_indices_x());
@@ -49,7 +49,7 @@
                         {{-10, 5, -10, 5}, {0, 10, 0, 10}, {0, 5, 0, 5}, true},
                         {{0, 5, 0, 5}, {10, 20, 10, 20}, {0, 0, 0, 0}, false}};
 
-  for (size_t i = 0; i < arraysize(clamp_to_cases); ++i) {
+  for (size_t i = 0; i < base::size(clamp_to_cases); ++i) {
     const ClampToCase& value = clamp_to_cases[i];
     IndexRect first(value.first.left, value.first.right, value.first.top,
                     value.first.bottom);
@@ -82,7 +82,7 @@
       {-10, 10, -10, 10, 20, 20, false},  {-10, 10, -10, 10, 20, 5, false},
       {-10, 10, -10, 10, 5, 20, false}};
 
-  for (size_t i = 0; i < arraysize(contains_cases); ++i) {
+  for (size_t i = 0; i < base::size(contains_cases); ++i) {
     const ContainsCase& value = contains_cases[i];
     IndexRect rect(value.left, value.right, value.top, value.bottom);
     EXPECT_EQ(value.contained, rect.Contains(value.index_x, value.index_y));
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 14736412..0bf913bf 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -13,6 +13,7 @@
 
 #include "base/location.h"
 #include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "cc/animation/animation_host.h"
 #include "cc/base/math_util.h"
@@ -3242,7 +3243,7 @@
     while (std::abs(tile->contents_scale_key() - expected_scales[scale_index]) >
            std::numeric_limits<float>::epsilon()) {
       ++scale_index;
-      ASSERT_LT(scale_index, arraysize(expected_scales));
+      ASSERT_LT(scale_index, base::size(expected_scales));
     }
 
     EXPECT_FLOAT_EQ(tile->contents_scale_key(), expected_scales[scale_index]);
@@ -3290,7 +3291,7 @@
     while (std::abs(tile->contents_scale_key() - expected_scales[scale_index]) >
            std::numeric_limits<float>::epsilon()) {
       ++scale_index;
-      ASSERT_LT(scale_index, arraysize(expected_scales));
+      ASSERT_LT(scale_index, base::size(expected_scales));
     }
 
     EXPECT_FLOAT_EQ(tile->contents_scale_key(), expected_scales[scale_index]);
diff --git a/cc/layers/surface_layer_impl.cc b/cc/layers/surface_layer_impl.cc
index 4a05173a..02da1fd 100644
--- a/cc/layers/surface_layer_impl.cc
+++ b/cc/layers/surface_layer_impl.cc
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "base/trace_event/traced_value.h"
 #include "cc/debug/debug_colors.h"
 #include "cc/layers/append_quads_data.h"
@@ -211,7 +212,7 @@
       0x800000ff,  // Blue.
       0x80ee82ee,  // Violet.
   };
-  const int kNumColors = arraysize(colors);
+  const int kNumColors = base::size(colors);
 
   const int kStripeWidth = 300;
   const int kStripeHeight = 300;
diff --git a/cc/paint/filter_operation.cc b/cc/paint/filter_operation.cc
index 6dda21fbf..267381b 100644
--- a/cc/paint/filter_operation.cc
+++ b/cc/paint/filter_operation.cc
@@ -9,6 +9,7 @@
 #include "cc/paint/filter_operation.h"
 
 #include "base/numerics/ranges.h"
+#include "base/stl_util.h"
 #include "base/trace_event/traced_value.h"
 #include "base/values.h"
 #include "cc/base/math_util.h"
@@ -300,7 +301,7 @@
       break;
     case FilterOperation::COLOR_MATRIX: {
       value->BeginArray("matrix");
-      for (size_t i = 0; i < arraysize(matrix_); ++i)
+      for (size_t i = 0; i < base::size(matrix_); ++i)
         value->AppendDouble(matrix_[i]);
       value->EndArray();
       break;
diff --git a/cc/paint/paint_op_buffer_unittest.cc b/cc/paint/paint_op_buffer_unittest.cc
index 7ea6952..cd214e5 100644
--- a/cc/paint/paint_op_buffer_unittest.cc
+++ b/cc/paint/paint_op_buffer_unittest.cc
@@ -3,6 +3,8 @@
 // found in the LICENSE file.
 
 #include "cc/paint/paint_op_buffer.h"
+
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "cc/paint/decoded_draw_image.h"
 #include "cc/paint/display_item_list.h"
@@ -2468,11 +2470,11 @@
       static_cast<SkBlendMode>(static_cast<uint32_t>(~0)),
   };
 
-  for (size_t i = 0; i < arraysize(bad_modes_for_draw_color); ++i) {
+  for (size_t i = 0; i < base::size(bad_modes_for_draw_color); ++i) {
     buffer.push<DrawColorOp>(SK_ColorMAGENTA, bad_modes_for_draw_color[i]);
   }
 
-  for (size_t i = 0; i < arraysize(bad_modes_for_flags); ++i) {
+  for (size_t i = 0; i < base::size(bad_modes_for_flags); ++i) {
     PaintFlags flags = test_flags[i % test_flags.size()];
     flags.setBlendMode(bad_modes_for_flags[i]);
     buffer.push<DrawRectOp>(test_rects[i % test_rects.size()], flags);
diff --git a/cc/paint/solid_color_analyzer_unittest.cc b/cc/paint/solid_color_analyzer_unittest.cc
index 939e517..c90e38d 100644
--- a/cc/paint/solid_color_analyzer_unittest.cc
+++ b/cc/paint/solid_color_analyzer_unittest.cc
@@ -6,6 +6,7 @@
 
 #include "base/memory/ref_counted.h"
 #include "base/optional.h"
+#include "base/stl_util.h"
 #include "cc/paint/display_item_list.h"
 #include "cc/paint/paint_filter.h"
 #include "cc/paint/record_paint_canvas.h"
@@ -351,7 +352,7 @@
 
   for (int case_scale = 0; case_scale < 2; ++case_scale) {
     bool scaled = case_scale > 0;
-    for (size_t i = 0; i < arraysize(cases); ++i) {
+    for (size_t i = 0; i < base::size(cases); ++i) {
       Reset();
       Initialize(canvas_rect);
 
diff --git a/cc/scheduler/compositor_timing_history.cc b/cc/scheduler/compositor_timing_history.cc
index e648071..affa7ac 100644
--- a/cc/scheduler/compositor_timing_history.cc
+++ b/cc/scheduler/compositor_timing_history.cc
@@ -9,6 +9,7 @@
 
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "cc/debug/rendering_stats_instrumentation.h"
 
@@ -121,12 +122,12 @@
     2000000, 4000000, 8000000, 16000000, 32000000,
 };
 
-#define UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(name, sample)             \
-  do {                                                                     \
-    UMA_HISTOGRAM_CUSTOM_ENUMERATION(                                      \
-        name "2", sample.InMicroseconds(),                                 \
-        std::vector<int>(kUMAVSyncBuckets,                                 \
-                         kUMAVSyncBuckets + arraysize(kUMAVSyncBuckets))); \
+#define UMA_HISTOGRAM_CUSTOM_TIMES_VSYNC_ALIGNED(name, sample)              \
+  do {                                                                      \
+    UMA_HISTOGRAM_CUSTOM_ENUMERATION(                                       \
+        name "2", sample.InMicroseconds(),                                  \
+        std::vector<int>(kUMAVSyncBuckets,                                  \
+                         kUMAVSyncBuckets + base::size(kUMAVSyncBuckets))); \
   } while (false)
 
 #define UMA_HISTOGRAM_CUSTOM_TIMES_DURATION_SUFFIX(name, suffix, sample) \
@@ -135,7 +136,7 @@
         name "2" suffix, sample.InMicroseconds(),                        \
         std::vector<int>(                                                \
             kUMADurationBuckets,                                         \
-            kUMADurationBuckets + arraysize(kUMADurationBuckets)));      \
+            kUMADurationBuckets + base::size(kUMADurationBuckets)));     \
   } while (false)
 
 #define UMA_HISTOGRAM_CUSTOM_TIMES_DURATION(name, sample) \
diff --git a/cc/test/task_graph_runner_test_template.h b/cc/test/task_graph_runner_test_template.h
index 3cfe46c1..7c2f387f8f 100644
--- a/cc/test/task_graph_runner_test_template.h
+++ b/cc/test/task_graph_runner_test_template.h
@@ -10,7 +10,7 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/synchronization/lock.h"
 #include "base/threading/simple_thread.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -274,8 +274,8 @@
         TaskInfo(i, 0u, 2u, 1u, 0u, 1u),  // Priority 1
         TaskInfo(i, 1u, 3u, 1u, 0u, 0u)   // Priority 0
     };
-    this->ScheduleTasks(i,
-                        std::vector<TaskInfo>(tasks, tasks + arraysize(tasks)));
+    this->ScheduleTasks(
+        i, std::vector<TaskInfo>(tasks, tasks + base::size(tasks)));
   }
 
   for (int i = 0; i < kNamespaceCount; ++i) {
diff --git a/cc/tiles/picture_layer_tiling.cc b/cc/tiles/picture_layer_tiling.cc
index c16c0bb2..d8347eb 100644
--- a/cc/tiles/picture_layer_tiling.cc
+++ b/cc/tiles/picture_layer_tiling.cc
@@ -14,6 +14,7 @@
 #include "base/containers/flat_map.h"
 #include "base/logging.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "base/trace_event/traced_value.h"
 #include "cc/base/math_util.h"
@@ -587,7 +588,7 @@
       &visible_rect_in_layer_space, &skewport_in_layer_space,
       &soon_border_rect_in_layer_space, &eventually_rect_in_layer_space};
   gfx::Rect output_rects[4];
-  for (size_t i = 0; i < arraysize(input_rects); ++i)
+  for (size_t i = 0; i < base::size(input_rects); ++i)
     output_rects[i] = EnclosingContentsRectFromLayerRect(*input_rects[i]);
   // Make sure the eventually rect is aligned to tile bounds.
   output_rects[3] =
diff --git a/cc/tiles/tile_manager_perftest.cc b/cc/tiles/tile_manager_perftest.cc
index 8842bc3..8a875845 100644
--- a/cc/tiles/tile_manager_perftest.cc
+++ b/cc/tiles/tile_manager_perftest.cc
@@ -7,6 +7,7 @@
 
 #include "base/lazy_instance.h"
 #include "base/location.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "cc/base/lap_timer.h"
@@ -80,7 +81,7 @@
       std::unique_ptr<RasterTilePriorityQueue> queue(
           host_impl()->BuildRasterQueue(priorities[priority_count],
                                         RasterTilePriorityQueue::Type::ALL));
-      priority_count = (priority_count + 1) % arraysize(priorities);
+      priority_count = (priority_count + 1) % base::size(priorities);
       timer_.NextLap();
     } while (!timer_.HasTimeLimitExpired());
 
@@ -115,7 +116,7 @@
         ASSERT_TRUE(queue->Top().tile());
         queue->Pop();
       }
-      priority_count = (priority_count + 1) % arraysize(priorities);
+      priority_count = (priority_count + 1) % base::size(priorities);
       timer_.NextLap();
     } while (!timer_.HasTimeLimitExpired());
 
@@ -148,7 +149,7 @@
     do {
       std::unique_ptr<EvictionTilePriorityQueue> queue(
           host_impl()->BuildEvictionQueue(priorities[priority_count]));
-      priority_count = (priority_count + 1) % arraysize(priorities);
+      priority_count = (priority_count + 1) % base::size(priorities);
       timer_.NextLap();
     } while (!timer_.HasTimeLimitExpired());
 
@@ -188,7 +189,7 @@
         ASSERT_TRUE(queue->Top().tile());
         queue->Pop();
       }
-      priority_count = (priority_count + 1) % arraysize(priorities);
+      priority_count = (priority_count + 1) % base::size(priorities);
       timer_.NextLap();
     } while (!timer_.HasTimeLimitExpired());
 
diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc
index 7fbe4f3..f797450 100644
--- a/cc/tiles/tile_manager_unittest.cc
+++ b/cc/tiles/tile_manager_unittest.cc
@@ -1746,7 +1746,7 @@
   gfx::Size size(10, 12);
   TileResolution resolutions[] = {HIGH_RESOLUTION, LOW_RESOLUTION};
 
-  for (size_t i = 0; i < arraysize(resolutions); ++i) {
+  for (size_t i = 0; i < base::size(resolutions); ++i) {
     SCOPED_TRACE(resolutions[i]);
 
     // Make a RasterSource that will draw a blue bitmap image.
diff --git a/cc/trees/layer_tree_host_pixeltest_blending.cc b/cc/trees/layer_tree_host_pixeltest_blending.cc
index 12d47be4..ae1fb765 100644
--- a/cc/trees/layer_tree_host_pixeltest_blending.cc
+++ b/cc/trees/layer_tree_host_pixeltest_blending.cc
@@ -4,6 +4,7 @@
 
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "cc/layers/picture_image_layer.h"
 #include "cc/layers/solid_color_layer.h"
@@ -55,7 +56,7 @@
     0x00000000   // transparent
 };
 
-const int kCSSTestColorsCount = arraysize(kCSSTestColors);
+const int kCSSTestColorsCount = base::size(kCSSTestColors);
 
 using RenderPassOptions = uint32_t;
 const uint32_t kUseMasks = 1 << 0;
diff --git a/cc/trees/layer_tree_host_pixeltest_masks.cc b/cc/trees/layer_tree_host_pixeltest_masks.cc
index 47d0be0..36726cc8 100644
--- a/cc/trees/layer_tree_host_pixeltest_masks.cc
+++ b/cc/trees/layer_tree_host_pixeltest_masks.cc
@@ -4,6 +4,7 @@
 
 #include <stddef.h>
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "cc/layers/content_layer_client.h"
 #include "cc/layers/picture_image_layer.h"
@@ -495,7 +496,7 @@
     for (int j = 0; j < (bounds.height() + grid_size - 1) / grid_size; j++) {
       for (int i = 0; i < (bounds.width() + grid_size - 1) / grid_size; i++) {
         PaintFlags flags;
-        flags.setColor(test_colors[(i + j * 3) % arraysize(test_colors)]);
+        flags.setColor(test_colors[(i + j * 3) % base::size(test_colors)]);
         display_list->push<DrawRectOp>(
             SkRect::MakeXYWH(i * grid_size, j * grid_size, grid_size,
                              grid_size),
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index bc8bbcf..5f6068be 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -5,6 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "cc/layers/heads_up_display_layer.h"
 #include "cc/layers/layer_impl.h"
@@ -328,7 +329,7 @@
         },
     };
 
-    if (test_case_ >= arraysize(kTests))
+    if (test_case_ >= base::size(kTests))
       return false;
     // Make sure that we lost our context at least once in the last test run so
     // the test did something.
diff --git a/cc/trees/occlusion_unittest.cc b/cc/trees/occlusion_unittest.cc
index da2f6fd..e5b31e41 100644
--- a/cc/trees/occlusion_unittest.cc
+++ b/cc/trees/occlusion_unittest.cc
@@ -6,6 +6,7 @@
 
 #include <stddef.h>
 
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace cc {
@@ -36,8 +37,8 @@
 #define EXPECT_OCCLUSION(occlusion, rects, ...)              \
   {                                                          \
     bool expected[] = {__VA_ARGS__};                         \
-    ASSERT_EQ(arraysize(rects), arraysize(expected));        \
-    for (size_t i = 0; i < arraysize(rects); ++i)            \
+    ASSERT_EQ(base::size(rects), base::size(expected));      \
+    for (size_t i = 0; i < base::size(rects); ++i)           \
       EXPECT_EQ(expected[i], occlusion.IsOccluded(rects[i])) \
           << "Test failed for index " << i << ".";           \
   }
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index dcbe126..2ff0f55 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -123,6 +123,9 @@
       public_deps += [ ":reorder_imports" ]
       data_deps += [ ":reorder_imports" ]
     }
+    if (use_aura && (is_win || is_linux)) {
+      data_deps += [ "//chrome/app:service_manifests" ]
+    }
     if (is_chromeos) {
       data_deps += [ "//sandbox/linux:chrome_sandbox" ]
     }
@@ -1225,9 +1228,13 @@
     ]
 
     if (is_chrome_branded) {
-      framework_contents += [ "Default Apps" ]
+      framework_contents += [
+        "Default Apps",
+      ]
       if (enable_keystone_registration_framework) {
-        framework_contents += [ "Frameworks" ]  # For KeystoneRegistration.framework.
+        framework_contents += [
+          "Frameworks",  # For KeystoneRegistration.framework.
+        ]
       }
     }
 
diff --git a/chrome/VERSION b/chrome/VERSION
index 85d7f51..ee836740 100644
--- a/chrome/VERSION
+++ b/chrome/VERSION
@@ -1,4 +1,4 @@
 MAJOR=73
 MINOR=0
-BUILD=3650
+BUILD=3652
 PATCH=0
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java
index 5a4deba4..60bfe0b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClient.java
@@ -106,11 +106,11 @@
 
         Bitmap bitmap = service.getSmallIconBitmap();
         if (!builder.hasStatusBarIconBitmap()) {
-            builder.setStatusBarIconForUntrustedRemoteApp(id, bitmap,
-                    service.getComponentName().getPackageName());
+            builder.setStatusBarIconForRemoteApp(
+                    id, bitmap, service.getComponentName().getPackageName());
         }
         if (!builder.hasSmallIconForContent()) {
-            builder.setContentSmallIconForUntrustedRemoteApp(bitmap);
+            builder.setContentSmallIconForRemoteApp(bitmap);
         }
     }
 
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
index 294a39ee..6f24787 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationBuilderBase.java
@@ -10,10 +10,8 @@
 import android.app.PendingIntent;
 import android.app.RemoteInput;
 import android.content.Context;
-import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Paint;
@@ -24,7 +22,6 @@
 import android.support.annotation.IntDef;
 import android.support.annotation.Nullable;
 
-import org.chromium.base.ContextUtils;
 import org.chromium.base.VisibleForTesting;
 import org.chromium.chrome.browser.ChromeFeatureList;
 import org.chromium.chrome.browser.widget.RoundedIconGenerator;
@@ -248,32 +245,13 @@
 
     /**
      * Sets the status bar icon for a notification that will be displayed by a different app.
-     * The icon must come from a trusted app because this involves decoding a Bitmap from its
-     * resources.
-     * @param iconId An iconId for a resource in the package that will display the notification.
-     * @param packageName The package name of the package that will display the notification.
-     */
-    public NotificationBuilderBase setStatusBarIconForTrustedRemoteApp(
-            int iconId, String packageName) {
-        setStatusBarIconForRemoteApp(iconId, decodeImageResource(packageName, iconId), packageName);
-        return this;
-    }
-
-    /**
-     * Sets the status bar icon for a notification that will be displayed by a different app.
-     * Unlike {@link #setStatusBarIconForTrustedRemoteApp} this is safe to use for any app.
+     * This is safe to use for any app.
      * @param iconId An iconId for a resource in the package that will display the notification.
      * @param iconBitmap The decoded bitmap. Depending on the device we need either id or bitmap.
      * @param packageName The package name of the package that will display the notification.
      */
-    public NotificationBuilderBase setStatusBarIconForUntrustedRemoteApp(
+    public NotificationBuilderBase setStatusBarIconForRemoteApp(
             int iconId, @Nullable Bitmap iconBitmap, String packageName) {
-        setStatusBarIconForRemoteApp(iconId, iconBitmap, packageName);
-        return this;
-    }
-
-    private void setStatusBarIconForRemoteApp(int iconId, @Nullable Bitmap iconBitmap,
-            String packageName) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             // On Android M+, the small icon has to be from the resources of the app whose context
             // is passed to the Notification.Builder constructor. Thus we can't use iconId directly,
@@ -292,6 +270,7 @@
             // NotificationManager is used in NotificationManager#notify.
             setSmallIconId(iconId);
         }
+        return this;
     }
 
     private static boolean usingRemoteAppContextAllowed() {
@@ -301,20 +280,9 @@
 
     /**
      * Sets the small icon to be shown inside a notification that will be displayed by a different
-     * app. The icon must come from a trusted app.
+     * app. This is safe to use for any app.
      */
-    public NotificationBuilderBase setContentSmallIconForTrustedRemoteApp(
-            int iconId, String packageName) {
-        setSmallIconForContent(decodeImageResource(packageName, iconId));
-        return this;
-    }
-
-    /**
-     * Sets the small icon to be shown inside a notification that will be displayed by a different
-     * app. Unlike {@link #setContentSmallIconForTrustedRemoteApp} this is safe to use for any app.
-     */
-    public NotificationBuilderBase setContentSmallIconForUntrustedRemoteApp(
-            @Nullable Bitmap bitmap) {
+    public NotificationBuilderBase setContentSmallIconForRemoteApp(@Nullable Bitmap bitmap) {
         setSmallIconForContent(bitmap);
         return this;
     }
@@ -646,16 +614,4 @@
         return new RoundedIconGenerator(largeIconWidthPx, largeIconHeightPx, cornerRadiusPx,
                 NOTIFICATION_ICON_BG_COLOR, NOTIFICATION_ICON_TEXT_SIZE_DP * density);
     }
-
-    /** Decodes into a Bitmap an Image resource stored in another package. */
-    @Nullable
-    private static Bitmap decodeImageResource(String otherPackage, int resourceId) {
-        PackageManager packageManager = ContextUtils.getApplicationContext().getPackageManager();
-        try {
-            Resources resources = packageManager.getResourcesForApplication(otherPackage);
-            return BitmapFactory.decodeResource(resources, resourceId);
-        } catch (PackageManager.NameNotFoundException e) {
-            return null;
-        }
-    }
 }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkServiceClient.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkServiceClient.java
index 78aa2376..0c961654 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkServiceClient.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkServiceClient.java
@@ -6,9 +6,13 @@
 
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.os.Build;
 import android.os.IBinder;
 import android.os.RemoteException;
+import android.support.annotation.Nullable;
 
 import org.chromium.base.ContextUtils;
 import org.chromium.base.Log;
@@ -104,11 +108,12 @@
 
     private void fallbackToWebApkIconIfNecessary(NotificationBuilderBase builder,
             String webApkPackage, int iconId) {
+        Bitmap icon = decodeImageResourceFromPackage(webApkPackage, iconId);
         if (!builder.hasSmallIconForContent()) {
-            builder.setContentSmallIconForTrustedRemoteApp(iconId, webApkPackage);
+            builder.setContentSmallIconForRemoteApp(icon);
         }
         if (!builder.hasStatusBarIconBitmap()) {
-            builder.setStatusBarIconForTrustedRemoteApp(iconId, webApkPackage);
+            builder.setStatusBarIconForRemoteApp(iconId, icon, webApkPackage);
         }
     }
 
@@ -145,4 +150,16 @@
 
         return false;
     }
+
+    /** Decodes into a Bitmap an Image resource stored in an APK with the given package name. */
+    @Nullable
+    private static Bitmap decodeImageResourceFromPackage(String packageName, int resourceId) {
+        PackageManager packageManager = ContextUtils.getApplicationContext().getPackageManager();
+        try {
+            Resources resources = packageManager.getResourcesForApplication(packageName);
+            return BitmapFactory.decodeResource(resources, resourceId);
+        } catch (PackageManager.NameNotFoundException e) {
+            return null;
+        }
+    }
 }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java
index 22f7ec0..3629dc25 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/browserservices/TrustedWebActivityClientTest.java
@@ -79,8 +79,9 @@
     public void usesIconFromService_IfStatusBarIconNotSet() {
         setHasStatusBarBitmap(false);
         postNotification();
-        verify(mNotificationBuilder).setStatusBarIconForUntrustedRemoteApp(
-                SERVICE_SMALL_ICON_ID, mServiceSmallIconBitmap, CLIENT_PACKAGE_NAME);
+        verify(mNotificationBuilder)
+                .setStatusBarIconForRemoteApp(
+                        SERVICE_SMALL_ICON_ID, mServiceSmallIconBitmap, CLIENT_PACKAGE_NAME);
     }
 
 
@@ -89,22 +90,21 @@
         setHasStatusBarBitmap(true);
         postNotification();
         verify(mNotificationBuilder, never())
-                .setStatusBarIconForUntrustedRemoteApp(anyInt(), any(), anyString());
+                .setStatusBarIconForRemoteApp(anyInt(), any(), anyString());
     }
 
     @Test
     public void usesIconFromService_IfContentSmallIconNotSet() {
         setHasContentBitmap(false);
         postNotification();
-        verify(mNotificationBuilder)
-                .setContentSmallIconForUntrustedRemoteApp(mServiceSmallIconBitmap);
+        verify(mNotificationBuilder).setContentSmallIconForRemoteApp(mServiceSmallIconBitmap);
     }
 
     @Test
     public void doesntUseIconFromService_IfContentSmallIconSet() {
         setHasContentBitmap(true);
         postNotification();
-        verify(mNotificationBuilder, never()).setContentSmallIconForUntrustedRemoteApp(any());
+        verify(mNotificationBuilder, never()).setContentSmallIconForRemoteApp(any());
     }
 
 
diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt
index 8e1b7a2..38552a0 100644
--- a/chrome/android/profiles/newest.txt
+++ b/chrome/android/profiles/newest.txt
@@ -1 +1 @@
-chromeos-chrome-amd64-73.0.3649.0_rc-r1.afdo.bz2
\ No newline at end of file
+chromeos-chrome-amd64-73.0.3651.0_rc-r1.afdo.bz2
\ No newline at end of file
diff --git a/chrome/app/BUILD.gn b/chrome/app/BUILD.gn
index 39bd9e5c..016b0ba2 100644
--- a/chrome/app/BUILD.gn
+++ b/chrome/app/BUILD.gn
@@ -519,3 +519,70 @@
     ":chrome_content_utility_manifest_overlay",
   ]
 }
+
+if (use_aura || enable_ipc_fuzzer) {
+  # NOTE: These rules generate compiled versions of the content service
+  # manifests with Chrome's overlays applied. These are only used at run-time,
+  # and only when running Chrome inside the Mash environment. In production
+  # Chrome, the content manifests and Chrome's overlays are baked into browser
+  # resources and merged at runtime.
+
+  service_manifest("chrome_content_packaged_services_manifest") {
+    source_manifest = "//content/public/app:packaged_services_manifest"
+    overlays = [ ":chrome_content_packaged_services_manifest_overlay" ]
+  }
+
+  service_manifest("chrome_content_browser_manifest") {
+    source_manifest = "//content/public/app:browser_manifest"
+    overlays = [ ":chrome_content_browser_manifest_overlay" ]
+  }
+
+  service_manifest("chrome_test_browser_manifest") {
+    source_manifest = ":chrome_content_browser_manifest"
+    overlays = [ ":chrome_test_browser_overlay" ]
+  }
+
+  service_manifest("chrome_content_gpu_manifest") {
+    source_manifest = "//content/public/app:gpu_manifest"
+    overlays = [ ":chrome_content_gpu_manifest_overlay" ]
+  }
+
+  service_manifest("chrome_content_plugin_manifest") {
+    source_manifest = "//content/public/app:plugin_manifest"
+    overlays = [ ":chrome_content_plugin_manifest_overlay" ]
+  }
+
+  service_manifest("chrome_content_renderer_manifest") {
+    source_manifest = "//content/public/app:renderer_manifest"
+    overlays = [ ":chrome_content_renderer_manifest_overlay" ]
+  }
+
+  service_manifest("chrome_content_utility_manifest") {
+    source_manifest = "//content/public/app:utility_manifest"
+    overlays = [ ":chrome_content_utility_manifest_overlay" ]
+  }
+
+  group("service_manifests") {
+    deps = [
+      ":chrome_content_browser_manifest",
+      ":chrome_content_gpu_manifest",
+      ":chrome_content_plugin_manifest",
+      ":chrome_content_renderer_manifest",
+      ":chrome_content_utility_manifest",
+    ]
+  }
+
+  chrome_embedded_services = [
+    ":chrome_content_browser_manifest",
+    ":chrome_content_gpu_manifest",
+    ":chrome_content_plugin_manifest",
+    ":chrome_content_renderer_manifest",
+    ":chrome_content_utility_manifest",
+    ":chrome_renderer_manifest",
+  ]
+
+  catalog("catalog") {
+    embedded_services = chrome_embedded_services +
+                        [ ":chrome_content_packaged_services_manifest" ]
+  }
+}
diff --git a/chrome/browser/background_fetch/background_fetch_browsertest.cc b/chrome/browser/background_fetch/background_fetch_browsertest.cc
index a12688d..635d792 100644
--- a/chrome/browser/background_fetch/background_fetch_browsertest.cc
+++ b/chrome/browser/background_fetch/background_fetch_browsertest.cc
@@ -198,6 +198,8 @@
       resume_ = false;
     }
 
+    // Check that the progress is always increasing and never resets.
+    DCHECK_GE(item.progress.value, latest_item_.progress.value);
     latest_item_ = item;
   }
 
diff --git a/chrome/browser/background_fetch/background_fetch_delegate_impl.cc b/chrome/browser/background_fetch/background_fetch_delegate_impl.cc
index d8bff93..6bc6ece 100644
--- a/chrome/browser/background_fetch/background_fetch_delegate_impl.cc
+++ b/chrome/browser/background_fetch/background_fetch_delegate_impl.cc
@@ -112,7 +112,7 @@
   DCHECK_GT(fetch_description->total_parts, 0);
 
   if (ShouldReportProgressBySize()) {
-    offline_item.progress.value = fetch_description->completed_parts_size;
+    offline_item.progress.value = GetProcessedDataSize();
     // If we have completed all downloads, update progress max to
     // completed_parts_size in case total_parts_size was set too high. This
     // avoid unnecessary jumping in the progress bar.
@@ -150,6 +150,10 @@
   }
 }
 
+uint64_t BackgroundFetchDelegateImpl::JobDetails::GetProcessedDataSize() const {
+  return fetch_description->completed_parts_size + in_progress_parts_size;
+}
+
 bool BackgroundFetchDelegateImpl::JobDetails::ShouldReportProgressBySize() {
   if (!fetch_description->total_parts_size) {
     // total_parts_size was not set. Cannot report by size.
@@ -157,8 +161,7 @@
   }
 
   if (fetch_description->completed_parts < fetch_description->total_parts &&
-      fetch_description->completed_parts_size >
-          fetch_description->total_parts_size) {
+      GetProcessedDataSize() > fetch_description->total_parts_size) {
     // total_parts_size was set too low.
     return false;
   }
@@ -402,10 +405,10 @@
   // This will update the progress bar.
   DCHECK(job_details_map_.count(job_unique_id));
   JobDetails& job_details = job_details_map_.find(job_unique_id)->second;
-  job_details.fetch_description->completed_parts_size = bytes_downloaded;
+  job_details.in_progress_parts_size = bytes_downloaded;
   if (job_details.fetch_description->total_parts_size &&
       job_details.fetch_description->total_parts_size <
-          job_details.fetch_description->completed_parts_size) {
+          job_details.GetProcessedDataSize()) {
     // Fail the fetch if total download size was set too low.
     // We only do this if total download size is specified. If not specified,
     // this check is skipped. This is to allow for situations when the
@@ -436,6 +439,8 @@
   const std::string& job_unique_id = download_job_unique_id_iter->second;
   JobDetails& job_details = job_details_map_.find(job_unique_id)->second;
   ++job_details.fetch_description->completed_parts;
+  job_details.in_progress_parts_size = 0u;
+
   UpdateOfflineItemAndUpdateObservers(&job_details);
 
   // The client cancelled or aborted the download so no need to notify it.
@@ -468,10 +473,12 @@
   const std::string& job_unique_id = download_job_unique_id_iter->second;
   JobDetails& job_details = job_details_map_.find(job_unique_id)->second;
   ++job_details.fetch_description->completed_parts;
+  job_details.in_progress_parts_size = 0u;
 
-  job_details.fetch_description->completed_parts_size =
+  job_details.fetch_description->completed_parts_size +=
       profile_->IsOffTheRecord() ? result->blob_handle->size()
                                  : result->file_size;
+
   UpdateOfflineItemAndUpdateObservers(&job_details);
 
   if (job_details.client) {
diff --git a/chrome/browser/background_fetch/background_fetch_delegate_impl.h b/chrome/browser/background_fetch/background_fetch_delegate_impl.h
index 7147a37..e541d80 100644
--- a/chrome/browser/background_fetch/background_fetch_delegate_impl.h
+++ b/chrome/browser/background_fetch/background_fetch_delegate_impl.h
@@ -156,6 +156,10 @@
     void UpdateOfflineItem();
     void MarkJobAsStarted();
 
+    // Returns how many bytes have been processed by the Download Service so
+    // far.
+    uint64_t GetProcessedDataSize() const;
+
     struct UploadData {
       enum class Status {
         kAbsent,
@@ -184,6 +188,7 @@
     offline_items_collection::OfflineItem offline_item;
     State job_state;
     std::unique_ptr<content::BackgroundFetchDescription> fetch_description;
+    uint64_t in_progress_parts_size = 0u;
 
     base::OnceClosure on_resume;
 
diff --git a/chrome/browser/chromeos/extensions/input_method_api.cc b/chrome/browser/chromeos/extensions/input_method_api.cc
index d17ef2ef..9741820 100644
--- a/chrome/browser/chromeos/extensions/input_method_api.cc
+++ b/chrome/browser/chromeos/extensions/input_method_api.cc
@@ -326,11 +326,17 @@
 
   auto ret = std::make_unique<base::DictionaryValue>();
   ui::SurroundingTextInfo info = input_context->GetSurroundingTextInfo();
-  uint32_t text_before_end = info.selection_range.start();
+  uint32_t selection_start = info.selection_range.start();
+  uint32_t selection_end = info.selection_range.end();
+  // Makes sure |selection_start| is less or equals to |selection_end|.
+  if (selection_start > selection_end)
+    std::swap(selection_start, selection_end);
+
+  uint32_t text_before_end = selection_start;
   uint32_t text_before_start = text_before_end > param_before_length
                                    ? text_before_end - param_before_length
                                    : 0;
-  uint32_t text_after_start = info.selection_range.end();
+  uint32_t text_after_start = selection_end;
   uint32_t text_after_end =
       text_after_start + param_after_length < info.surrounding_text.length()
           ? text_after_start + param_after_length
diff --git a/chrome/browser/extensions/activity_log/activity_database_unittest.cc b/chrome/browser/extensions/activity_log/activity_database_unittest.cc
index 8dc7d907..b6e25bb2 100644
--- a/chrome/browser/extensions/activity_log/activity_database_unittest.cc
+++ b/chrome/browser/extensions/activity_log/activity_database_unittest.cc
@@ -10,8 +10,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_clock.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -64,11 +64,9 @@
     "LONGVARCHAR NOT NULL", "INTEGER", "INTEGER", "LONGVARCHAR"};
 
 bool ActivityDatabaseTestPolicy::InitDatabase(sql::Database* db) {
-  return ActivityDatabase::InitializeTable(db,
-                                           kTableName,
-                                           kTableContentFields,
+  return ActivityDatabase::InitializeTable(db, kTableName, kTableContentFields,
                                            kTableFieldTypes,
-                                           arraysize(kTableContentFields));
+                                           base::size(kTableContentFields));
 }
 
 bool ActivityDatabaseTestPolicy::FlushDatabase(sql::Database* db) {
diff --git a/chrome/browser/extensions/activity_log/activity_log.cc b/chrome/browser/extensions/activity_log/activity_log.cc
index 1b545c0..691a907 100644
--- a/chrome/browser/extensions/activity_log/activity_log.cc
+++ b/chrome/browser/extensions/activity_log/activity_log.cc
@@ -14,7 +14,7 @@
 #include "base/json/json_string_value_serializer.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/synchronization/lock.h"
@@ -187,7 +187,7 @@
 
  private:
   ApiInfoDatabase() {
-    for (size_t i = 0; i < arraysize(kApiInfoTable); i++) {
+    for (size_t i = 0; i < base::size(kApiInfoTable); i++) {
       const ApiInfo* info = &kApiInfoTable[i];
       api_database_[info->api_name] = info;
     }
diff --git a/chrome/browser/extensions/activity_log/activity_log_unittest.cc b/chrome/browser/extensions/activity_log/activity_log_unittest.cc
index 6e1eeac..cd27c75 100644
--- a/chrome/browser/extensions/activity_log/activity_log_unittest.cc
+++ b/chrome/browser/extensions/activity_log/activity_log_unittest.cc
@@ -9,8 +9,8 @@
 #include <memory>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/synchronization/waitable_event.h"
 #include "build/build_config.h"
 #include "chrome/browser/extensions/activity_log/activity_action_constants.h"
@@ -168,7 +168,7 @@
 
   static void RetrieveActions_ArgUrlApiCalls(
       std::unique_ptr<std::vector<scoped_refptr<Action>>> actions) {
-    size_t api_calls_size = arraysize(kUrlApiCalls);
+    size_t api_calls_size = base::size(kUrlApiCalls);
     const base::DictionaryValue* other = NULL;
     int dom_verb = -1;
 
@@ -364,7 +364,7 @@
   ActivityLog* activity_log = ActivityLog::GetInstance(profile());
   std::unique_ptr<base::ListValue> args(new base::ListValue());
   base::Time now = base::Time::Now();
-  int api_calls_size = arraysize(kUrlApiCalls);
+  int api_calls_size = base::size(kUrlApiCalls);
   scoped_refptr<Action> action;
 
   for (int i = 0; i < api_calls_size; i++) {
diff --git a/chrome/browser/extensions/activity_log/counting_policy.cc b/chrome/browser/extensions/activity_log/counting_policy.cc
index 397104e..2dbe068 100644
--- a/chrome/browser/extensions/activity_log/counting_policy.cc
+++ b/chrome/browser/extensions/activity_log/counting_policy.cc
@@ -40,8 +40,8 @@
 #include "base/files/file_path.h"
 #include "base/json/json_reader.h"
 #include "base/json/json_string_value_serializer.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/task_runner_util.h"
@@ -170,7 +170,7 @@
       string_table_("string_ids"),
       url_table_("url_ids"),
       retention_time_(base::TimeDelta::FromHours(60)) {
-  for (size_t i = 0; i < arraysize(kAlwaysLog); i++) {
+  for (size_t i = 0; i < base::size(kAlwaysLog); i++) {
     api_arg_whitelist_.insert(
         std::make_pair(kAlwaysLog[i].type, kAlwaysLog[i].name));
   }
@@ -185,11 +185,9 @@
     return false;
 
   // Create the unified activity log entry table.
-  if (!ActivityDatabase::InitializeTable(db,
-                                         kTableName,
-                                         kTableContentFields,
+  if (!ActivityDatabase::InitializeTable(db, kTableName, kTableContentFields,
                                          kTableFieldTypes,
-                                         arraysize(kTableContentFields)))
+                                         base::size(kTableContentFields)))
     return false;
 
   // Create a view for easily accessing the uncompressed form of the data, and
@@ -271,14 +269,14 @@
       " SET count = count + ?, time = max(?, time)"
       " WHERE rowid = ?";
 
-  for (size_t i = 0; i < arraysize(matched_columns); i++) {
+  for (size_t i = 0; i < base::size(matched_columns); i++) {
     locate_str = base::StringPrintf(
         "%s AND %s IS ?", locate_str.c_str(), matched_columns[i]);
     insert_str =
         base::StringPrintf("%s, %s", insert_str.c_str(), matched_columns[i]);
   }
   insert_str += ") VALUES (?, ?";
-  for (size_t i = 0; i < arraysize(matched_columns); i++) {
+  for (size_t i = 0; i < base::size(matched_columns); i++) {
     insert_str += ", ?";
   }
   locate_str += " ORDER BY time DESC LIMIT 1";
diff --git a/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc b/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
index 9604dd4..13b7939 100644
--- a/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
+++ b/chrome/browser/extensions/activity_log/fullstream_ui_policy.cc
@@ -12,8 +12,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_string_value_serializer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/task_runner_util.h"
@@ -47,7 +47,7 @@
   "LONGVARCHAR", "LONGVARCHAR", "LONGVARCHAR", "LONGVARCHAR"
 };
 const int FullStreamUIPolicy::kTableFieldCount =
-    arraysize(FullStreamUIPolicy::kTableContentFields);
+    base::size(FullStreamUIPolicy::kTableContentFields);
 
 FullStreamUIPolicy::FullStreamUIPolicy(Profile* profile)
     : ActivityLogDatabasePolicy(
@@ -58,11 +58,9 @@
 
 bool FullStreamUIPolicy::InitDatabase(sql::Database* db) {
   // Create the unified activity log entry table.
-  return ActivityDatabase::InitializeTable(db,
-                                           kTableName,
-                                           kTableContentFields,
+  return ActivityDatabase::InitializeTable(db, kTableName, kTableContentFields,
                                            kTableFieldTypes,
-                                           arraysize(kTableContentFields));
+                                           base::size(kTableContentFields));
 }
 
 bool FullStreamUIPolicy::FlushDatabase(sql::Database* db) {
diff --git a/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc b/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc
index 3e5b240..1edfa81 100644
--- a/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc
+++ b/chrome/browser/extensions/api/braille_display_private/braille_controller_brlapi.cc
@@ -14,7 +14,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/threading/scoped_blocking_call.h"
 #include "base/time/time.h"
@@ -81,7 +81,7 @@
     "libbrlapi.so.0.5",
     "libbrlapi.so.0.6"
   };
-  for (size_t i = 0; i < arraysize(kSupportedVersions); ++i) {
+  for (size_t i = 0; i < base::size(kSupportedVersions); ++i) {
     if (libbrlapi_loader_.Load(kSupportedVersions[i]))
       return;
   }
diff --git a/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc b/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
index f09e416..4995fa3 100644
--- a/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
+++ b/chrome/browser/extensions/api/braille_display_private/brlapi_connection.cc
@@ -7,8 +7,8 @@
 #include <errno.h>
 
 #include "base/files/file_descriptor_watcher_posix.h"
-#include "base/macros.h"
 #include "base/memory/free_deleter.h"
+#include "base/stl_util.h"
 #include "base/system/sys_info.h"
 #include "build/build_config.h"
 
@@ -117,9 +117,9 @@
       // explicitly accept this command.
       BRLAPI_KEY_TYPE_CMD | BRLAPI_KEY_CMD_PASSDOTS,
   };
-  if (libbrlapi_loader_->brlapi__acceptKeys(
-          handle_.get(), brlapi_rangeType_command, extraKeys,
-          arraysize(extraKeys)) < 0) {
+  if (libbrlapi_loader_->brlapi__acceptKeys(handle_.get(),
+                                            brlapi_rangeType_command, extraKeys,
+                                            base::size(extraKeys)) < 0) {
     LOG(ERROR) << "Couldn't acceptKeys: " << BrlapiStrError();
     Disconnect();
     return CONNECT_ERROR_RETRY;
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_unittest.cc b/chrome/browser/extensions/api/content_settings/content_settings_unittest.cc
index 692e75f6..395fe37 100644
--- a/chrome/browser/extensions/api/content_settings/content_settings_unittest.cc
+++ b/chrome/browser/extensions/api/content_settings/content_settings_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/browser/extensions/api/content_settings/content_settings_helpers.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -24,7 +24,7 @@
     { "https://*/*", "https://*" },
     { "file:///foo/bar/baz", "file:///foo/bar/baz" },
   };
-  for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kTestPatterns); ++i) {
     std::string error;
     std::string pattern_str = helpers::ParseExtensionPattern(
         kTestPatterns[i].extension_pattern, &error).ToString();
@@ -41,7 +41,7 @@
     { "file:///foo/bar/*",
       "Path wildcards in file URL patterns are not allowed." },
   };
-  for (size_t i = 0; i < arraysize(kInvalidTestPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kInvalidTestPatterns); ++i) {
     std::string error;
     ContentSettingsPattern pattern = helpers::ParseExtensionPattern(
         kInvalidTestPatterns[i].extension_pattern, &error);
diff --git a/chrome/browser/extensions/api/cookies/cookies_unittest.cc b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
index ce043bf..c6952d4 100644
--- a/chrome/browser/extensions/api/cookies/cookies_unittest.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_unittest.cc
@@ -10,7 +10,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/browser/extensions/api/cookies/cookies_api_constants.h"
 #include "chrome/browser/extensions/api/cookies/cookies_helpers.h"
@@ -165,7 +165,7 @@
       {".bar.com", ".foo.bar.com", true}, {".bar.com", "baz.foo.bar.com", true},
       {"foo.bar.com", ".bar.com", false}};
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     // Build up the Params struct.
     base::ListValue args;
     auto dict = std::make_unique<base::DictionaryValue>();
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
index 3afaee4..7cd7aba 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
@@ -10,8 +10,8 @@
 
 #include "base/files/file_path.h"
 #include "base/json/json_file_value_serializer.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/test/values_test_util.h"
 #include "base/time/time.h"
 #include "base/values.h"
@@ -588,7 +588,7 @@
     "declarativeWebRequest.IgnoreRules",
   };
   std::unique_ptr<WebRequestActionSet> action_set(CreateSetOfActions(kActions));
-  ASSERT_EQ(arraysize(kExpectedNames), action_set->actions().size());
+  ASSERT_EQ(base::size(kExpectedNames), action_set->actions().size());
   size_t index = 0;
   for (auto it = action_set->actions().cbegin();
        it != action_set->actions().cend(); ++it) {
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
index b829ee7..245bb2e 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc
@@ -12,7 +12,6 @@
 #include <vector>
 
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
 #include "base/test/values_test_util.h"
@@ -664,14 +663,14 @@
   };
   // Which rules should match in subsequent test iterations.
   const char* const matchingRuleIds[] = { kRuleId1, kRuleId2 };
-  static_assert(arraysize(urls) == arraysize(firstPartyUrls),
+  static_assert(base::size(urls) == base::size(firstPartyUrls),
                 "urls and firstPartyUrls must have the same number "
                 "of elements");
-  static_assert(arraysize(urls) == arraysize(matchingRuleIds),
+  static_assert(base::size(urls) == base::size(matchingRuleIds),
                 "urls and matchingRuleIds must have the same number "
                 "of elements");
 
-  for (size_t i = 0; i < arraysize(matchingRuleIds); ++i) {
+  for (size_t i = 0; i < base::size(matchingRuleIds); ++i) {
     // Construct the inputs.
     WebRequestInfo http_request_info = CreateRequest(urls[i]);
     http_request_info.site_for_cookies = firstPartyUrls[i];
diff --git a/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc b/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc
index 43454096..adc282b 100644
--- a/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc
+++ b/chrome/browser/extensions/api/desktop_capture/desktop_capture_apitest.cc
@@ -5,8 +5,8 @@
 #include <array>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "build/build_config.h"
 #include "chrome/browser/extensions/api/desktop_capture/desktop_capture_api.h"
@@ -133,7 +133,7 @@
     {true, false, false, true,
      DesktopMediaID(DesktopMediaID::TYPE_SCREEN, webrtc::kFullDesktopScreenId)},
   };
-  picker_factory_.SetTestFlags(test_flags, arraysize(test_flags));
+  picker_factory_.SetTestFlags(test_flags, base::size(test_flags));
   ASSERT_TRUE(RunExtensionTest("desktop_capture")) << message_;
 }
 
@@ -165,7 +165,7 @@
        DesktopMediaID(DesktopMediaID::TYPE_SCREEN, DesktopMediaID::kNullId),
        true},
   };
-  picker_factory_.SetTestFlags(test_flags, arraysize(test_flags));
+  picker_factory_.SetTestFlags(test_flags, base::size(test_flags));
 
   bool result;
 
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index 3584296..abbfe3b9 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -21,7 +21,6 @@
 #include "base/lazy_instance.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_loop_current.h"
@@ -188,7 +187,7 @@
     kDangerSafe,     kDangerUncommon,
     kDangerAccepted, kDangerHost,
     kDangerUnwanted, kDangerWhitelistedByPolicy};
-static_assert(arraysize(kDangerStrings) == download::DOWNLOAD_DANGER_TYPE_MAX,
+static_assert(base::size(kDangerStrings) == download::DOWNLOAD_DANGER_TYPE_MAX,
               "kDangerStrings should have DOWNLOAD_DANGER_TYPE_MAX elements");
 
 // Note: Any change to the state strings, should be accompanied by a
@@ -199,22 +198,22 @@
   kStateInterrupted,
   kStateInterrupted,
 };
-static_assert(arraysize(kStateStrings) ==
+static_assert(base::size(kStateStrings) ==
                   download::DownloadItem::MAX_DOWNLOAD_STATE,
               "kStateStrings should have MAX_DOWNLOAD_STATE elements");
 
 const char* DangerString(download::DownloadDangerType danger) {
   DCHECK(danger >= 0);
   DCHECK(danger <
-         static_cast<download::DownloadDangerType>(arraysize(kDangerStrings)));
+         static_cast<download::DownloadDangerType>(base::size(kDangerStrings)));
   if (danger < 0 || danger >= static_cast<download::DownloadDangerType>(
-                                  arraysize(kDangerStrings)))
+                                  base::size(kDangerStrings)))
     return "";
   return kDangerStrings[danger];
 }
 
 download::DownloadDangerType DangerEnumFromString(const std::string& danger) {
-  for (size_t i = 0; i < arraysize(kDangerStrings); ++i) {
+  for (size_t i = 0; i < base::size(kDangerStrings); ++i) {
     if (danger == kDangerStrings[i])
       return static_cast<download::DownloadDangerType>(i);
   }
@@ -224,16 +223,16 @@
 const char* StateString(download::DownloadItem::DownloadState state) {
   DCHECK(state >= 0);
   DCHECK(state < static_cast<download::DownloadItem::DownloadState>(
-                     arraysize(kStateStrings)));
+                     base::size(kStateStrings)));
   if (state < 0 || state >= static_cast<download::DownloadItem::DownloadState>(
-                                arraysize(kStateStrings)))
+                                base::size(kStateStrings)))
     return "";
   return kStateStrings[state];
 }
 
 download::DownloadItem::DownloadState StateEnumFromString(
     const std::string& state) {
-  for (size_t i = 0; i < arraysize(kStateStrings); ++i) {
+  for (size_t i = 0; i < base::size(kStateStrings); ++i) {
     if ((kStateStrings[i] != NULL) && (state == kStateStrings[i]))
       return static_cast<DownloadItem::DownloadState>(i);
   }
diff --git a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
index 0e303565..949cb01 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc
@@ -12,10 +12,10 @@
 #include "base/files/file_util.h"
 #include "base/guid.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/task/post_task.h"
 #include "base/test/bind_test_util.h"
@@ -1150,7 +1150,7 @@
       {FILE_PATH_LITERAL("fake.txt"), DownloadItem::COMPLETE,
        download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS}};
   DownloadManager::DownloadVector all_downloads;
-  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
+  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, base::size(kHistoryInfo),
                                      &all_downloads));
 
   base::FilePath real_path = all_downloads[0]->GetTargetFilePath();
@@ -1252,7 +1252,7 @@
       {FILE_PATH_LITERAL("baz"), DownloadItem::COMPLETE,
        download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS}};
   DownloadManager::DownloadVector all_downloads;
-  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
+  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, base::size(kHistoryInfo),
                                      &all_downloads));
 
   std::unique_ptr<base::Value> result(RunFunctionAndReturnResult(
@@ -1328,8 +1328,8 @@
       {FILE_PATH_LITERAL("baz"), DownloadItem::COMPLETE,
        download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS}};
   DownloadManager::DownloadVector items;
-  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
-                                     &items));
+  ASSERT_TRUE(
+      CreateHistoryDownloads(kHistoryInfo, base::size(kHistoryInfo), &items));
 
   std::unique_ptr<base::Value> result(RunFunctionAndReturnResult(
       new DownloadsSearchFunction(), "[{\"orderBy\": [\"filename\"]}]"));
@@ -1358,8 +1358,8 @@
       {FILE_PATH_LITERAL("baz"), DownloadItem::COMPLETE,
        download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS}};
   DownloadManager::DownloadVector items;
-  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
-                                     &items));
+  ASSERT_TRUE(
+      CreateHistoryDownloads(kHistoryInfo, base::size(kHistoryInfo), &items));
 
   std::unique_ptr<base::Value> result(RunFunctionAndReturnResult(
       new DownloadsSearchFunction(), "[{\"orderBy\": []}]"));
@@ -1392,8 +1392,8 @@
       {FILE_PATH_LITERAL("baz"), DownloadItem::COMPLETE,
        download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS}};
   DownloadManager::DownloadVector items;
-  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
-                                     &items));
+  ASSERT_TRUE(
+      CreateHistoryDownloads(kHistoryInfo, base::size(kHistoryInfo), &items));
 
   std::unique_ptr<base::Value> result(RunFunctionAndReturnResult(
       new DownloadsSearchFunction(), "[{\"danger\": \"content\"}]"));
@@ -1478,8 +1478,8 @@
        download::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT},
   };
   DownloadManager::DownloadVector items;
-  ASSERT_TRUE(CreateHistoryDownloads(kHistoryInfo, arraysize(kHistoryInfo),
-                                     &items));
+  ASSERT_TRUE(
+      CreateHistoryDownloads(kHistoryInfo, base::size(kHistoryInfo), &items));
 
   std::unique_ptr<base::Value> result(
       RunFunctionAndReturnResult(new DownloadsSearchFunction(),
@@ -1935,7 +1935,7 @@
     "Access-Control-Request-Method",
   };
 
-  for (size_t index = 0; index < arraysize(kUnsafeHeaders); ++index) {
+  for (size_t index = 0; index < base::size(kUnsafeHeaders); ++index) {
     std::string download_url = embedded_test_server()->GetURL("/slow?0").spec();
     EXPECT_STREQ(errors::kInvalidHeaderUnsafe,
                   RunFunctionAndReturnError(new DownloadsDownloadFunction(),
@@ -2072,7 +2072,7 @@
     "google.com/",
   };
 
-  for (size_t index = 0; index < arraysize(kInvalidURLs); ++index) {
+  for (size_t index = 0; index < base::size(kInvalidURLs); ++index) {
     EXPECT_STREQ(errors::kInvalidURL,
                   RunFunctionAndReturnError(new DownloadsDownloadFunction(),
                                             base::StringPrintf(
diff --git a/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc b/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
index 2febb6e0..e11b93a6 100644
--- a/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
+++ b/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
@@ -7,9 +7,9 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h"
@@ -178,7 +178,7 @@
     // In order to use a prepared certificate, import a private key to the
     // user's token for which the Javscript test will import the certificate.
     ImportPrivateKeyPKCS8ToSlot(privateKeyPkcs8User,
-                                arraysize(privateKeyPkcs8User),
+                                base::size(privateKeyPkcs8User),
                                 cert_db->GetPrivateSlot().get());
     done_callback.Run();
   }
@@ -239,7 +239,7 @@
     // Import a private key to the system slot.  The Javascript part of this
     // test has a prepared certificate for this key.
     ImportPrivateKeyPKCS8ToSlot(privateKeyPkcs8System,
-                                arraysize(privateKeyPkcs8System),
+                                base::size(privateKeyPkcs8System),
                                 system_slot->slot());
   }
 
diff --git a/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 8a1d288..d27bdd4 100644
--- a/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -10,9 +10,9 @@
 
 #include "base/lazy_instance.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
@@ -521,7 +521,7 @@
     EXTENSION_FUNCTION_VALIDATE(list->GetSize() == 4);
 
     int color_array[4] = {0};
-    for (size_t i = 0; i < arraysize(color_array); ++i) {
+    for (size_t i = 0; i < base::size(color_array); ++i) {
       EXTENSION_FUNCTION_VALIDATE(list->GetInteger(i, &color_array[i]));
     }
 
diff --git a/chrome/browser/extensions/api/gcm/gcm_api.cc b/chrome/browser/extensions/api/gcm/gcm_api.cc
index d003884..d652931 100644
--- a/chrome/browser/extensions/api/gcm/gcm_api.cc
+++ b/chrome/browser/extensions/api/gcm/gcm_api.cc
@@ -11,13 +11,12 @@
 #include <utility>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "chrome/browser/gcm/gcm_profile_service_factory.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile.h"
 #include "chrome/common/extensions/api/gcm.h"
 #include "components/gcm_driver/common/gcm_messages.h"
 #include "components/gcm_driver/gcm_driver.h"
@@ -73,12 +72,10 @@
 bool IsMessageKeyValid(const std::string& key) {
   std::string lower = base::ToLowerASCII(key);
   return !key.empty() &&
-         key.compare(0, arraysize(kCollapseKey) - 1, kCollapseKey) != 0 &&
-         lower.compare(0,
-                       arraysize(kGoogleRestrictedPrefix) - 1,
+         key.compare(0, base::size(kCollapseKey) - 1, kCollapseKey) != 0 &&
+         lower.compare(0, base::size(kGoogleRestrictedPrefix) - 1,
                        kGoogleRestrictedPrefix) != 0 &&
-         lower.compare(0,
-                       arraysize(kGoogDotRestrictedPrefix),
+         lower.compare(0, base::size(kGoogDotRestrictedPrefix),
                        kGoogDotRestrictedPrefix) != 0;
 }
 
diff --git a/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc b/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc
index 252f109..e535deb 100644
--- a/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc
+++ b/chrome/browser/extensions/api/identity/identity_get_auth_token_function.cc
@@ -9,6 +9,7 @@
 #include <string>
 #include <vector>
 
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "build/build_config.h"
 #include "chrome/browser/browser_process.h"
@@ -654,7 +655,7 @@
 bool IdentityGetAuthTokenFunction::IsOriginWhitelistedInPublicSession() {
   DCHECK(extension());
   GURL extension_url = extension()->url();
-  for (size_t i = 0; i < arraysize(kPublicSessionAllowedOrigins); i++) {
+  for (size_t i = 0; i < base::size(kPublicSessionAllowedOrigins); i++) {
     URLPattern allowed_origin(URLPattern::SCHEME_ALL,
                               kPublicSessionAllowedOrigins[i]);
     if (allowed_origin.MatchesSecurityOrigin(extension_url)) {
diff --git a/chrome/browser/extensions/api/management/management_browsertest.cc b/chrome/browser/extensions/api/management/management_browsertest.cc
index 24da4131..7676a54d 100644
--- a/chrome/browser/extensions/api/management/management_browsertest.cc
+++ b/chrome/browser/extensions/api/management/management_browsertest.cc
@@ -6,7 +6,6 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
@@ -258,7 +257,7 @@
   NotificationListener() : started_(false), finished_(false) {
     int types[] = {extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED,
                    extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND};
-    for (size_t i = 0; i < arraysize(types); i++) {
+    for (size_t i = 0; i < base::size(types); i++) {
       registrar_.Add(
           this, types[i], content::NotificationService::AllSources());
     }
diff --git a/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc b/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc
index 723bad5..52c2d49b 100644
--- a/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc
+++ b/chrome/browser/extensions/api/messaging/native_message_host_chromeos.cc
@@ -13,8 +13,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
@@ -122,9 +122,9 @@
 
 static const BuiltInHost kBuiltInHost[] = {
     {"com.google.chrome.test.echo",  // ScopedTestNativeMessagingHost::kHostName
-     kEchoHostOrigins, arraysize(kEchoHostOrigins), &EchoHost::Create},
+     kEchoHostOrigins, base::size(kEchoHostOrigins), &EchoHost::Create},
     {"com.google.chrome.remote_assistance", kRemotingIt2MeOrigins,
-     arraysize(kRemotingIt2MeOrigins), &CreateIt2MeHost},
+     base::size(kRemotingIt2MeOrigins), &CreateIt2MeHost},
     {arc::ArcSupportMessageHost::kHostName,
      arc::ArcSupportMessageHost::kHostOrigin, 1,
      &arc::ArcSupportMessageHost::Create},
@@ -150,7 +150,7 @@
     const std::string& native_host_name,
     bool allow_user_level,
     std::string* error) {
-  for (unsigned int i = 0; i < arraysize(kBuiltInHost); i++) {
+  for (unsigned int i = 0; i < base::size(kBuiltInHost); i++) {
     const BuiltInHost& host = kBuiltInHost[i];
     std::string name(host.name);
     if (name == native_host_name) {
diff --git a/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc b/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc
index f7c64e1..8847f05 100644
--- a/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc
+++ b/chrome/browser/extensions/api/metrics_private/metrics_apitest.cc
@@ -6,10 +6,10 @@
 
 #include <map>
 
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/statistics_recorder.h"
+#include "base/stl_util.h"
 #include "base/test/metrics/user_action_tester.h"
 #include "chrome/browser/extensions/extension_apitest.h"
 #include "components/variations/variations_associated_data.h"
@@ -83,7 +83,7 @@
 void ValidateSparseHistogramSamples(
     const std::string& name,
     const base::HistogramSamples& samples) {
-  for (unsigned int i = 0; i < arraysize(g_sparse_histograms); ++i) {
+  for (unsigned int i = 0; i < base::size(g_sparse_histograms); ++i) {
     const SparseHistogram& sparse_histogram = g_sparse_histograms[i];
     if (std::string(name) == sparse_histogram.name) {
       for (int j = 0; j < sparse_histogram.bucket_count; ++j) {
@@ -144,8 +144,8 @@
   ASSERT_TRUE(RunComponentExtensionTest("metrics")) << message_;
 
   ValidateUserActions(user_action_tester, g_user_actions,
-                      arraysize(g_user_actions));
-  ValidateHistograms(g_histograms, arraysize(g_histograms));
+                      base::size(g_user_actions));
+  ValidateHistograms(g_histograms, base::size(g_histograms));
 }
 
 }  // namespace extensions
diff --git a/chrome/browser/extensions/api/platform_keys/platform_keys_api.cc b/chrome/browser/extensions/api/platform_keys/platform_keys_api.cc
index 2983149..08b30719 100644
--- a/chrome/browser/extensions/api/platform_keys/platform_keys_api.cc
+++ b/chrome/browser/extensions/api/platform_keys/platform_keys_api.cc
@@ -10,7 +10,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/browser/chromeos/platform_keys/platform_keys.h"
 #include "chrome/browser/chromeos/platform_keys/platform_keys_service.h"
@@ -68,7 +68,7 @@
       "publicExponent",
       base::Value::CreateWithCopiedBuffer(
           reinterpret_cast<const char*>(defaultPublicExponent),
-          arraysize(defaultPublicExponent)));
+          base::size(defaultPublicExponent)));
 }
 
 const struct NameValuePair {
@@ -389,7 +389,7 @@
   if (net::IsCertificateError(verify_result)) {
     // Only report errors, not internal informational statuses.
     const int masked_cert_status = cert_status & net::CERT_STATUS_ALL_ERRORS;
-    for (size_t i = 0; i < arraysize(kCertStatusErrors); ++i) {
+    for (size_t i = 0; i < base::size(kCertStatusErrors); ++i) {
       if ((masked_cert_status & kCertStatusErrors[i].value) ==
           kCertStatusErrors[i].value) {
         result.debug_errors.push_back(kCertStatusErrors[i].name);
diff --git a/chrome/browser/extensions/api/preference/preference_api.cc b/chrome/browser/extensions/api/preference/preference_api.cc
index 15748c8..2885e6f 100644
--- a/chrome/browser/extensions/api/preference/preference_api.cc
+++ b/chrome/browser/extensions/api/preference/preference_api.cc
@@ -11,8 +11,8 @@
 #include <utility>
 
 #include "base/lazy_instance.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "build/build_config.h"
@@ -289,8 +289,8 @@
       event_mapping_[pref.browser_pref] =
           PrefMapData(event_name, pref.read_permission, pref.write_permission);
     }
-    DCHECK_EQ(arraysize(kPrefMapping), mapping_.size());
-    DCHECK_EQ(arraysize(kPrefMapping), event_mapping_.size());
+    DCHECK_EQ(base::size(kPrefMapping), mapping_.size());
+    DCHECK_EQ(base::size(kPrefMapping), event_mapping_.size());
     RegisterPrefTransformer(proxy_config::prefs::kProxy,
                             std::make_unique<ProxyPrefTransformer>());
     RegisterPrefTransformer(prefs::kBlockThirdPartyCookies,
diff --git a/chrome/browser/extensions/api/proxy/proxy_api_constants.cc b/chrome/browser/extensions/api/proxy/proxy_api_constants.cc
index 88a43df..253efed 100644
--- a/chrome/browser/extensions/api/proxy/proxy_api_constants.cc
+++ b/chrome/browser/extensions/api/proxy/proxy_api_constants.cc
@@ -4,9 +4,8 @@
 
 // Constants for the Chrome Extensions Proxy Settings API.
 
-#include "base/macros.h"
 #include "chrome/browser/extensions/api/proxy/proxy_api_constants.h"
-
+#include "base/stl_util.h"
 
 namespace extensions {
 namespace proxy_api_constants {
@@ -44,9 +43,9 @@
 
 static_assert(SCHEME_MAX == SCHEME_FALLBACK,
               "SCHEME_MAX is incorrect");
-static_assert(arraysize(field_name) == SCHEME_MAX + 1,
+static_assert(base::size(field_name) == SCHEME_MAX + 1,
               "field_name array size is incorrect");
-static_assert(arraysize(scheme_name) == SCHEME_MAX + 1,
+static_assert(base::size(scheme_name) == SCHEME_MAX + 1,
               "scheme_name array size is incorrect");
 static_assert(SCHEME_ALL == 0, "SCHEME_ALL must be the first value");
 
diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
index cb340247..4a19012 100644
--- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -9,9 +9,9 @@
 
 #include "base/bind.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/pattern.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/bind_test_util.h"
@@ -116,7 +116,7 @@
     // Only the tabs are interesting.
     const base::ListValue* tabs = NULL;
     EXPECT_TRUE(window->GetList("tabs", &tabs));
-    EXPECT_EQ(arraysize(kTabIDs), tabs->GetSize());
+    EXPECT_EQ(base::size(kTabIDs), tabs->GetSize());
     for (size_t j = 0; j < tabs->GetSize(); ++j) {
       const base::DictionaryValue* tab = NULL;
       EXPECT_TRUE(tabs->GetDictionary(j, &tab));
@@ -217,12 +217,12 @@
                                      activation_response->type_processor.get());
 
   syncer::SyncDataList initial_data;
-  for (size_t index = 0; index < arraysize(kSessionTags); ++index) {
+  for (size_t index = 0; index < base::size(kSessionTags); ++index) {
     // Fill an instance of session specifics with a foreign session's data.
     sync_pb::EntitySpecifics header_entity;
     BuildSessionSpecifics(kSessionTags[index], header_entity.mutable_session());
     std::vector<SessionID::id_type> tab_list(kTabIDs,
-                                             kTabIDs + arraysize(kTabIDs));
+                                             kTabIDs + base::size(kTabIDs));
     BuildWindowSpecifics(index, tab_list, header_entity.mutable_session());
     std::vector<sync_pb::SessionSpecifics> tabs(tab_list.size());
     for (size_t i = 0; i < tab_list.size(); ++i) {
diff --git a/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc b/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc
index a4dc765..c69063e 100644
--- a/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc
+++ b/chrome/browser/extensions/api/settings_overrides/settings_overrides_browsertest.cc
@@ -4,8 +4,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "chrome/browser/extensions/extension_browsertest.h"
@@ -97,7 +97,7 @@
   ASSERT_TRUE(prefs);
   const GURL urls[] = {GURL("http://foo"), GURL("http://bar")};
   SessionStartupPref startup_pref(SessionStartupPref::LAST);
-  startup_pref.urls.assign(urls, urls + arraysize(urls));
+  startup_pref.urls.assign(urls, urls + base::size(urls));
   SessionStartupPref::SetStartupPref(prefs, startup_pref);
 
   const extensions::Extension* extension = LoadExtensionWithInstallParam(
@@ -112,7 +112,8 @@
   UnloadExtension(extension->id());
   startup_pref = SessionStartupPref::GetStartupPref(prefs);
   EXPECT_EQ(SessionStartupPref::LAST, startup_pref.type);
-  EXPECT_EQ(std::vector<GURL>(urls, urls + arraysize(urls)), startup_pref.urls);
+  EXPECT_EQ(std::vector<GURL>(urls, urls + base::size(urls)),
+            startup_pref.urls);
 }
 
 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, OverrideDSE) {
diff --git a/chrome/browser/extensions/api/socket/udp_socket_unittest.cc b/chrome/browser/extensions/api/socket/udp_socket_unittest.cc
index 8357f4e5..01d48a5 100644
--- a/chrome/browser/extensions/api/socket/udp_socket_unittest.cc
+++ b/chrome/browser/extensions/api/socket/udp_socket_unittest.cc
@@ -9,9 +9,9 @@
 #include <string>
 
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/test_timeouts.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chrome/browser/extensions/extension_service_test_base.h"
@@ -60,7 +60,7 @@
 }
 
 static const char kTestMessage[] = "$$TESTMESSAGETESTMESSAGETESTMESSAGETEST$$";
-static const int kTestMessageLength = arraysize(kTestMessage);
+static const int kTestMessageLength = base::size(kTestMessage);
 
 net::AddressList CreateAddressList(const char* address_string, int port) {
   net::IPAddress ip;
diff --git a/chrome/browser/extensions/api/system_private/system_private_api.cc b/chrome/browser/extensions/api/system_private/system_private_api.cc
index bc91204..99b8663 100644
--- a/chrome/browser/extensions/api/system_private/system_private_api.cc
+++ b/chrome/browser/extensions/api/system_private/system_private_api.cc
@@ -7,7 +7,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "build/build_config.h"
 #include "chrome/browser/browser_process.h"
@@ -60,7 +60,7 @@
   int value = prefs->GetInteger(prefs::kIncognitoModeAvailability);
   EXTENSION_FUNCTION_VALIDATE(
       value >= 0 &&
-      value < static_cast<int>(arraysize(kIncognitoModeAvailabilityStrings)));
+      value < static_cast<int>(base::size(kIncognitoModeAvailabilityStrings)));
   return RespondNow(OneArgument(
       std::make_unique<base::Value>(kIncognitoModeAvailabilityStrings[value])));
 }
diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
index df456f2..cbeaa34 100644
--- a/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
+++ b/chrome/browser/extensions/api/tab_capture/tab_capture_api.cc
@@ -14,7 +14,7 @@
 #include <vector>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
@@ -310,7 +310,7 @@
       base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
           switches::kWhitelistedExtensionID) == extension()->id() ||
       SimpleFeature::IsIdInArray(extension()->id(), kMediaRouterExtensionIds,
-                                 arraysize(kMediaRouterExtensionIds));
+                                 base::size(kMediaRouterExtensionIds));
   if (!is_whitelisted_extension)
     return RespondNow(Error(kNotWhitelistedForOffscreenTabApi));
 
diff --git a/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc b/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc
index 7a428607..70d1069b 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api_unittest.cc
@@ -5,6 +5,7 @@
 #include "chrome/browser/extensions/api/tabs/tabs_api.h"
 
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/browser_process.h"
@@ -129,8 +130,8 @@
   std::string tab_titles[] = {"", "Sample title", "Sample title"};
 
   // Add 3 web contentses to the browser.
-  content::WebContents* web_contentses[arraysize(tab_urls)];
-  for (size_t i = 0; i < arraysize(tab_urls); ++i) {
+  content::WebContents* web_contentses[base::size(tab_urls)];
+  for (size_t i = 0; i < base::size(tab_urls); ++i) {
     std::unique_ptr<content::WebContents> web_contents =
         content::WebContentsTester::CreateTestWebContents(profile(), nullptr);
     content::WebContents* raw_web_contents = web_contents.get();
@@ -190,8 +191,8 @@
   std::string tab_titles[] = {"", "Sample title", "Sample title"};
 
   // Add 3 web contentses to the browser.
-  content::WebContents* web_contentses[arraysize(tab_urls)];
-  for (size_t i = 0; i < arraysize(tab_urls); ++i) {
+  content::WebContents* web_contentses[base::size(tab_urls)];
+  for (size_t i = 0; i < base::size(tab_urls); ++i) {
     std::unique_ptr<content::WebContents> web_contents =
         content::WebContentsTester::CreateTestWebContents(profile(), nullptr);
     content::WebContents* raw_web_contents = web_contents.get();
diff --git a/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc b/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc
index 56d9b5d4..9ae363c 100644
--- a/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc
+++ b/chrome/browser/extensions/api/terminal/terminal_extension_helper.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/common/extensions/extension_constants.h"
 #include "extensions/browser/extension_registry.h"
@@ -32,7 +32,7 @@
 
   const ExtensionSet& extensions =
       ExtensionRegistry::Get(profile)->enabled_extensions();
-  for (size_t i = 0; i < arraysize(kPossibleAppIds); ++i) {
+  for (size_t i = 0; i < base::size(kPossibleAppIds); ++i) {
     const extensions::Extension* extension =
         extensions.GetByID(kPossibleAppIds[i]);
     if (extension)
diff --git a/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc b/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc
index 43c0efb8..428d265 100644
--- a/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc
+++ b/chrome/browser/extensions/api/vpn_provider/vpn_provider_apitest.cc
@@ -5,8 +5,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "chrome/browser/chromeos/profiles/profile_helper.h"
 #include "chrome/browser/extensions/extension_apitest.h"
@@ -304,7 +304,7 @@
   EXPECT_EQ(1, test_client_->send_packet_counter_);
   EXPECT_EQ(api_vpn::VPN_CONNECTION_STATE_CONNECTED,
             test_client_->update_connection_state_counter_);
-  for (size_t i = 0; i < arraysize(kParameterValues); ++i) {
+  for (size_t i = 0; i < base::size(kParameterValues); ++i) {
     std::string value;
     EXPECT_TRUE(
         test_client_->parameters_->GetString(kParameterKeys[i], &value));
diff --git a/chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc b/chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc
index 2b54370..372a012 100644
--- a/chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc
+++ b/chrome/browser/extensions/api/web_navigation/frame_navigation_state.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/extensions/api/web_navigation/frame_navigation_state.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/url_constants.h"
 #include "content/public/browser/render_frame_host.h"
 #include "extensions/common/constants.h"
@@ -44,7 +44,7 @@
 
 // static
 bool FrameNavigationState::IsValidUrl(const GURL& url) {
-  for (unsigned i = 0; i < arraysize(kValidSchemes); ++i) {
+  for (unsigned i = 0; i < base::size(kValidSchemes); ++i) {
     if (url.scheme() == kValidSchemes[i])
       return true;
   }
diff --git a/chrome/browser/extensions/api/web_request/web_request_event_details_unittest.cc b/chrome/browser/extensions/api/web_request/web_request_event_details_unittest.cc
index 63bbb3c..ad63a757 100644
--- a/chrome/browser/extensions/api/web_request/web_request_event_details_unittest.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_event_details_unittest.cc
@@ -5,6 +5,7 @@
 #include "extensions/browser/api/web_request/web_request_event_details.h"
 
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "extensions/browser/api/web_request/web_request_api_constants.h"
 #include "extensions/browser/api/web_request/web_request_api_helpers.h"
@@ -69,7 +70,7 @@
   EXPECT_EQ("http://www.foo.bar/", url);
 
   // Extras are filtered out (+1 for url).
-  EXPECT_EQ(arraysize(safe_attributes) + 1, copy->dict_.size());
+  EXPECT_EQ(base::size(safe_attributes) + 1, copy->dict_.size());
 }
 
 TEST(WebRequestEventDetailsTest, SetResponseHeaders) {
diff --git a/chrome/browser/extensions/chrome_app_sorting.cc b/chrome/browser/extensions/chrome_app_sorting.cc
index 92fde72..c480f444 100644
--- a/chrome/browser/extensions/chrome_app_sorting.cc
+++ b/chrome/browser/extensions/chrome_app_sorting.cc
@@ -9,7 +9,7 @@
 #include <utility>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/extensions/extension_sync_service.h"
@@ -569,7 +569,7 @@
     extensions::kWebStoreAppId,
   };
   const std::vector<const char*> app_ids(
-      kDefaultAppOrder, kDefaultAppOrder + arraysize(kDefaultAppOrder));
+      kDefaultAppOrder, kDefaultAppOrder + base::size(kDefaultAppOrder));
 #endif
 
   syncer::StringOrdinal page_ordinal = CreateFirstAppPageOrdinal();
diff --git a/chrome/browser/extensions/chrome_component_extension_resource_manager.cc b/chrome/browser/extensions/chrome_component_extension_resource_manager.cc
index 0b9ebd8..170f13e 100644
--- a/chrome/browser/extensions/chrome_component_extension_resource_manager.cc
+++ b/chrome/browser/extensions/chrome_component_extension_resource_manager.cc
@@ -5,8 +5,8 @@
 #include "chrome/browser/extensions/chrome_component_extension_resource_manager.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/grit/chrome_unscaled_resources.h"
@@ -41,9 +41,8 @@
   AddComponentResourceEntries(
       kComponentExtensionResources,
       kComponentExtensionResourcesSize);
-  AddComponentResourceEntries(
-      kExtraComponentExtensionResources,
-      arraysize(kExtraComponentExtensionResources));
+  AddComponentResourceEntries(kExtraComponentExtensionResources,
+                              base::size(kExtraComponentExtensionResources));
 #if defined(OS_CHROMEOS)
   size_t file_manager_resource_size;
   const GritResourceMap* file_manager_resources =
diff --git a/chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc b/chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc
index 329ecd5e..6eca1a7 100644
--- a/chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc
+++ b/chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc
@@ -15,6 +15,7 @@
 #include "base/debug/alias.h"
 #include "base/debug/dump_without_crashing.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/browser_process.h"
@@ -897,7 +898,7 @@
       "last",
   };
 
-  static_assert(arraysize(kSchemeNames) == SCHEME_LAST + 1,
+  static_assert(base::size(kSchemeNames) == SCHEME_LAST + 1,
                 "kSchemeNames should have SCHEME_LAST + 1 elements");
 
   ShouldAllowOpenURLFailureScheme scheme = SCHEME_UNKNOWN;
diff --git a/chrome/browser/extensions/component_extensions_whitelist/whitelist.cc b/chrome/browser/extensions/component_extensions_whitelist/whitelist.cc
index 64be043..3a5e695 100644
--- a/chrome/browser/extensions/component_extensions_whitelist/whitelist.cc
+++ b/chrome/browser/extensions/component_extensions_whitelist/whitelist.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/common/buildflags.h"
 #include "chrome/common/extensions/extension_constants.h"
@@ -39,7 +39,7 @@
 #endif
   };
 
-  for (size_t i = 0; i < arraysize(kAllowed); ++i) {
+  for (size_t i = 0; i < base::size(kAllowed); ++i) {
     if (extension_id == kAllowed[i])
       return true;
   }
diff --git a/chrome/browser/extensions/convert_web_app_unittest.cc b/chrome/browser/extensions/convert_web_app_unittest.cc
index 84dbd9c..6ff1e4e 100644
--- a/chrome/browser/extensions/convert_web_app_unittest.cc
+++ b/chrome/browser/extensions/convert_web_app_unittest.cc
@@ -13,8 +13,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
@@ -251,7 +251,7 @@
   web_app.scope = GURL("http://aaronboodman.com/gearpad/");
 
   const int sizes[] = {16, 48, 128};
-  for (size_t i = 0; i < arraysize(sizes); ++i) {
+  for (size_t i = 0; i < base::size(sizes); ++i) {
     GURL icon_url(
         web_app.app_url.Resolve(base::StringPrintf("%i.png", sizes[i])));
     web_app.icons.push_back(GetIconInfo(icon_url, sizes[i]));
diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc
index 113ab8b..a0b898c4 100644
--- a/chrome/browser/extensions/crx_installer_browsertest.cc
+++ b/chrome/browser/extensions/crx_installer_browsertest.cc
@@ -11,11 +11,11 @@
 #include "base/at_exit.h"
 #include "base/files/file_path.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/optional.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
 #include "build/build_config.h"
@@ -575,7 +575,7 @@
 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, AllowOffStore) {
   const bool kTestData[] = {false, true};
 
-  for (size_t i = 0; i < arraysize(kTestData); ++i) {
+  for (size_t i = 0; i < base::size(kTestData); ++i) {
     std::unique_ptr<MockPromptProxy> mock_prompt =
         CreateMockPromptProxyForBrowser(browser());
 
diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc
index 0c3a25a..b5fe700 100644
--- a/chrome/browser/extensions/default_apps.cc
+++ b/chrome/browser/extensions/default_apps.cc
@@ -11,7 +11,7 @@
 #include <string>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/first_run/first_run.h"
@@ -40,7 +40,7 @@
   // an API. See http://crbug.com/101357
   const std::string& locale = g_browser_process->GetApplicationLocale();
   static const char* const unsupported_locales[] = {"CN", "TR", "IR"};
-  for (size_t i = 0; i < arraysize(unsupported_locales); ++i) {
+  for (size_t i = 0; i < base::size(unsupported_locales); ++i) {
     if (base::EndsWith(locale, unsupported_locales[i],
                        base::CompareCase::INSENSITIVE_ASCII)) {
       return false;
diff --git a/chrome/browser/extensions/extension_management_constants.cc b/chrome/browser/extensions/extension_management_constants.cc
index 46638ff..9cb2f25 100644
--- a/chrome/browser/extensions/extension_management_constants.cc
+++ b/chrome/browser/extensions/extension_management_constants.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/extensions/extension_management_constants.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace extensions {
 namespace schema_constants {
@@ -45,7 +45,7 @@
   // policy.
 };
 
-const size_t kAllowedTypesMapSize = arraysize(kAllowedTypesMap);
+const size_t kAllowedTypesMapSize = base::size(kAllowedTypesMap);
 
 Manifest::Type GetManifestType(const std::string& name) {
   for (size_t index = 0; index < kAllowedTypesMapSize; ++index) {
diff --git a/chrome/browser/extensions/extension_messages_apitest.cc b/chrome/browser/extensions/extension_messages_apitest.cc
index fca6f98..58ffc47 100644
--- a/chrome/browser/extensions/extension_messages_apitest.cc
+++ b/chrome/browser/extensions/extension_messages_apitest.cc
@@ -13,9 +13,9 @@
 #include "base/files/file_path.h"
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/stringprintf.h"
@@ -336,7 +336,7 @@
 
     // Turn the array into a JS array, which effectively gets eval()ed.
     std::string as_js_array;
-    for (size_t i = 0; i < arraysize(non_messaging_apis); ++i) {
+    for (size_t i = 0; i < base::size(non_messaging_apis); ++i) {
       as_js_array += as_js_array.empty() ? "[" : ",";
       as_js_array += base::StringPrintf("'%s'", non_messaging_apis[i]);
     }
diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc
index 96fac7c..80d8ccb 100644
--- a/chrome/browser/extensions/extension_protocols_unittest.cc
+++ b/chrome/browser/extensions/extension_protocols_unittest.cc
@@ -10,8 +10,8 @@
 
 #include "base/command_line.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/test/power_monitor_test_base.h"
@@ -406,7 +406,7 @@
     {"split enabled", true, true, true, false},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     scoped_refptr<Extension> extension =
         CreateTestExtension(cases[i].name, cases[i].incognito_split_mode);
     AddExtension(extension, cases[i].incognito_enabled, false);
diff --git a/chrome/browser/extensions/extension_service_sync_unittest.cc b/chrome/browser/extensions/extension_service_sync_unittest.cc
index 3aee86c..c03afb43 100644
--- a/chrome/browser/extensions/extension_service_sync_unittest.cc
+++ b/chrome/browser/extensions/extension_service_sync_unittest.cc
@@ -12,10 +12,10 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/weak_ptr.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/test/mock_entropy_provider.h"
 #include "base/test/scoped_feature_list.h"
 #include "chrome/browser/chrome_notification_types.h"
@@ -2494,7 +2494,7 @@
 
   // Create a sync deletion for each extension.
   SyncChangeList list;
-  for (size_t i = 0; i < arraysize(extensions); i++) {
+  for (size_t i = 0; i < base::size(extensions); i++) {
     const std::string& id = extensions[i]->id();
     sync_pb::EntitySpecifics specifics;
     sync_pb::ExtensionSpecifics* ext_specifics = specifics.mutable_extension();
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index ffff05f..5b2722a 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -24,7 +24,6 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_string_value_serializer.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
@@ -2036,7 +2035,7 @@
     base::FilePath(FILE_PATH_LITERAL("thisextensionhasaslashinitsname.pem")),
   };
 
-  for (size_t i = 0; i < arraysize(punctuated_names); ++i) {
+  for (size_t i = 0; i < base::size(punctuated_names); ++i) {
     SCOPED_TRACE(punctuated_names[i].value().c_str());
     base::FilePath output_dir = temp_dir.GetPath().Append(punctuated_names[i]);
 
@@ -6636,7 +6635,7 @@
       {page_action, "1.0.0.0", "page_action.crx"},
       {minimal_platform_app_crx, "0.1", "minimal_platform_app.crx"}};
 
-  for (size_t i = 0; i < arraysize(extension_info); ++i) {
+  for (size_t i = 0; i < base::size(extension_info); ++i) {
     reg_provider->UpdateOrAddExtension(
         extension_info[i][0], extension_info[i][1],
         data_dir().AppendASCII(extension_info[i][2]));
diff --git a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
index b55fbd4d..44d3fe55 100644
--- a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
@@ -6,8 +6,8 @@
 
 #include <utility>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "build/build_config.h"
 #include "chrome/browser/content_settings/cookie_settings_factory.h"
@@ -362,8 +362,8 @@
     SpecialStoragePolicy::STORAGE_UNLIMITED,
   };
 
-  ASSERT_EQ(arraysize(apps), arraysize(change_flags));
-  for (size_t i = 0; i < arraysize(apps); ++i) {
+  ASSERT_EQ(base::size(apps), base::size(change_flags));
+  for (size_t i = 0; i < base::size(apps); ++i) {
     SCOPED_TRACE(testing::Message() << "i: " << i);
     observer.ExpectGrant(apps[i]->id(), change_flags[i]);
     policy_->GrantRightsForExtension(apps[i].get(), NULL);
@@ -371,14 +371,14 @@
     EXPECT_TRUE(observer.IsCompleted());
   }
 
-  for (size_t i = 0; i < arraysize(apps); ++i) {
+  for (size_t i = 0; i < base::size(apps); ++i) {
     SCOPED_TRACE(testing::Message() << "i: " << i);
     policy_->GrantRightsForExtension(apps[i].get(), NULL);
     base::RunLoop().RunUntilIdle();
     EXPECT_TRUE(observer.IsCompleted());
   }
 
-  for (size_t i = 0; i < arraysize(apps); ++i) {
+  for (size_t i = 0; i < base::size(apps); ++i) {
     SCOPED_TRACE(testing::Message() << "i: " << i);
     observer.ExpectRevoke(apps[i]->id(), change_flags[i]);
     policy_->RevokeRightsForExtension(apps[i].get());
@@ -386,7 +386,7 @@
     EXPECT_TRUE(observer.IsCompleted());
   }
 
-  for (size_t i = 0; i < arraysize(apps); ++i) {
+  for (size_t i = 0; i < base::size(apps); ++i) {
     SCOPED_TRACE(testing::Message() << "i: " << i);
     policy_->RevokeRightsForExtension(apps[i].get());
     base::RunLoop().RunUntilIdle();
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index 4a307f1..306050ea 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -8,8 +8,8 @@
 #include <algorithm>
 #include <utility>
 
-#include "base/macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -634,7 +634,7 @@
     return false;
 
   base::StringPiece fixed_host = fixed_url.host_piece();
-  for (size_t i = 0; i < arraysize(kill_hosts); ++i) {
+  for (size_t i = 0; i < base::size(kill_hosts); ++i) {
     if (fixed_host == kill_hosts[i])
       return true;
   }
diff --git a/chrome/browser/extensions/global_shortcut_listener_x11.cc b/chrome/browser/extensions/global_shortcut_listener_x11.cc
index 3628110..392cf3d5 100644
--- a/chrome/browser/extensions/global_shortcut_listener_x11.cc
+++ b/chrome/browser/extensions/global_shortcut_listener_x11.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/public/browser/browser_thread.h"
 #include "ui/base/accelerators/accelerator.h"
 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
@@ -111,14 +111,14 @@
   // Because XGrabKey only works on the exact modifiers mask, we should register
   // our hot keys with modifiers that we want to ignore, including Num lock,
   // Caps lock, Scroll lock. See comment about |kModifiersMasks|.
-  for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
+  for (size_t i = 0; i < base::size(kModifiersMasks); ++i) {
     XGrabKey(x_display_, keycode, modifiers | kModifiersMasks[i],
              x_root_window_, x11::False, GrabModeAsync, GrabModeAsync);
   }
 
   if (err_tracker.FoundNewError()) {
     // We may have part of the hotkeys registered, clean up.
-    for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
+    for (size_t i = 0; i < base::size(kModifiersMasks); ++i) {
       XUngrabKey(x_display_, keycode, modifiers | kModifiersMasks[i],
                  x_root_window_);
     }
@@ -138,7 +138,7 @@
   KeyCode keycode = XKeysymToKeycode(x_display_,
       XKeysymForWindowsKeyCode(accelerator.key_code(), false));
 
-  for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
+  for (size_t i = 0; i < base::size(kModifiersMasks); ++i) {
     XUngrabKey(x_display_, keycode, modifiers | kModifiersMasks[i],
                x_root_window_);
   }
diff --git a/chrome/browser/extensions/permission_messages_unittest.cc b/chrome/browser/extensions/permission_messages_unittest.cc
index f07ecde6..11cad06 100644
--- a/chrome/browser/extensions/permission_messages_unittest.cc
+++ b/chrome/browser/extensions/permission_messages_unittest.cc
@@ -7,7 +7,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/extensions/permissions_test_util.h"
@@ -339,7 +339,7 @@
   EXPECT_EQ(base::ASCIIToUTF16(kMessage), messages.front().message());
   const std::vector<base::string16>& submessages =
       messages.front().submessages();
-  ASSERT_EQ(arraysize(kDetails), submessages.size());
+  ASSERT_EQ(base::size(kDetails), submessages.size());
   for (size_t i = 0; i < submessages.size(); i++)
     EXPECT_EQ(base::ASCIIToUTF16(kDetails[i]), submessages[i]);
 }
diff --git a/chrome/browser/extensions/process_manager_browsertest.cc b/chrome/browser/extensions/process_manager_browsertest.cc
index 4788594d..246a016 100644
--- a/chrome/browser/extensions/process_manager_browsertest.cc
+++ b/chrome/browser/extensions/process_manager_browsertest.cc
@@ -8,9 +8,9 @@
 #include <utility>
 
 #include "base/callback.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/strcat.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/metrics/histogram_tester.h"
@@ -864,7 +864,7 @@
 
   // Navigate the popup to each nested URL with extension origin.
   GURL nested_urls[] = {blob_url, filesystem_url};
-  for (size_t i = 0; i < arraysize(nested_urls); i++) {
+  for (size_t i = 0; i < base::size(nested_urls); i++) {
     EXPECT_TRUE(ExecuteScript(
         popup, "location.href = '" + nested_urls[i].spec() + "';"));
 
@@ -897,7 +897,7 @@
 
   // Navigate second subframe to each nested URL from the main frame (i.e.,
   // from non-extension process).  These should be canceled.
-  for (size_t i = 0; i < arraysize(nested_urls); i++) {
+  for (size_t i = 0; i < base::size(nested_urls); i++) {
     EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", nested_urls[i]));
     content::RenderFrameHost* second_frame = ChildFrameAt(main_frame, 1);
 
@@ -1048,7 +1048,7 @@
   // Navigate second subframe to each nested URL from the main frame (i.e.,
   // from non-extension process).  These should be canceled.
   GURL nested_urls[] = {blob_url, filesystem_url};
-  for (size_t i = 0; i < arraysize(nested_urls); i++) {
+  for (size_t i = 0; i < base::size(nested_urls); i++) {
     EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame2", nested_urls[i]));
     content::RenderFrameHost* second_frame = ChildFrameAt(main_frame, 1);
 
@@ -1095,7 +1095,7 @@
   // From the main frame, navigate its subframe to each nested URL.  This
   // should be allowed and should stay in the extension process.
   GURL nested_urls[] = {blob_url, filesystem_url};
-  for (size_t i = 0; i < arraysize(nested_urls); i++) {
+  for (size_t i = 0; i < base::size(nested_urls); i++) {
     EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", nested_urls[i]));
     content::RenderFrameHost* child = ChildFrameAt(main_frame, 0);
     EXPECT_EQ(nested_urls[i], child->GetLastCommittedURL());
@@ -1239,7 +1239,7 @@
   // Try navigating the web tab to each nested URL with the app's origin.  This
   // should be blocked.
   GURL nested_urls[] = {blob_url, filesystem_url};
-  for (size_t i = 0; i < arraysize(nested_urls); i++) {
+  for (size_t i = 0; i < base::size(nested_urls); i++) {
     content::TestNavigationObserver observer(web_tab);
     EXPECT_TRUE(ExecuteScript(
         web_tab, "location.href = '" + nested_urls[i].spec() + "';"));
@@ -1363,7 +1363,7 @@
   // Attempt opening the nested urls using window.open(url, '', 'noopener').
   // This should not be allowed.
   GURL nested_urls[] = {blob_url, filesystem_url};
-  for (size_t i = 0; i < arraysize(nested_urls); i++) {
+  for (size_t i = 0; i < base::size(nested_urls); i++) {
     content::WebContents* new_popup =
         OpenPopupNoOpener(tab->GetMainFrame(), nested_urls[i]);
 
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc
index f318867..eca3458 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -18,7 +18,6 @@
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
 #include "base/compiler_specific.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/run_loop.h"
 #include "base/sequenced_task_runner.h"
@@ -225,7 +224,7 @@
 class NotificationsObserver : public content::NotificationObserver {
  public:
   NotificationsObserver() {
-    for (size_t i = 0; i < arraysize(kNotificationsObserved); ++i) {
+    for (size_t i = 0; i < base::size(kNotificationsObserved); ++i) {
       count_[i] = 0;
       registrar_.Add(this,
                      kNotificationsObserved[i],
@@ -234,7 +233,7 @@
   }
 
   ~NotificationsObserver() override {
-    for (size_t i = 0; i < arraysize(kNotificationsObserved); ++i) {
+    for (size_t i = 0; i < base::size(kNotificationsObserved); ++i) {
       registrar_.Remove(this,
                         kNotificationsObserved[i],
                         content::NotificationService::AllSources());
@@ -262,7 +261,7 @@
                const content::NotificationDetails& details) override {
     if (!quit_closure_.is_null())
       quit_closure_.Run();
-    for (size_t i = 0; i < arraysize(kNotificationsObserved); ++i) {
+    for (size_t i = 0; i < base::size(kNotificationsObserved); ++i) {
       if (kNotificationsObserved[i] == type) {
         count_[i]++;
         if (type == extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND) {
@@ -276,7 +275,7 @@
   }
 
   content::NotificationRegistrar registrar_;
-  size_t count_[arraysize(kNotificationsObserved)];
+  size_t count_[base::size(kNotificationsObserved)];
   std::set<std::string> updated_;
   base::Closure quit_closure_;
 
@@ -1889,8 +1888,8 @@
     // rollcall and active pings.
     int ping_cases[] = { ManifestFetchData::kNeverPinged, 0, 1, 5 };
 
-    for (size_t i = 0; i < arraysize(ping_cases); i++) {
-      for (size_t j = 0; j < arraysize(ping_cases); j++) {
+    for (size_t i = 0; i < base::size(ping_cases); i++) {
+      for (size_t j = 0; j < base::size(ping_cases); j++) {
         for (size_t k = 0; k < 2; k++) {
           int rollcall_ping_days = ping_cases[i];
           int active_ping_days = ping_cases[j];
diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc
index fbb1df01..8b4e1e1 100644
--- a/chrome/browser/extensions/window_open_apitest.cc
+++ b/chrome/browser/extensions/window_open_apitest.cc
@@ -5,6 +5,7 @@
 #include <stddef.h>
 
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "build/build_config.h"
@@ -372,7 +373,7 @@
   ASSERT_TRUE(history_url.SchemeIs(content::kChromeUIScheme));
   ASSERT_TRUE(ntp_url.SchemeIs(chrome::kChromeSearchScheme));
   GURL start_urls[] = {history_url, ntp_url};
-  for (size_t i = 0; i < arraysize(start_urls); i++) {
+  for (size_t i = 0; i < base::size(start_urls); i++) {
     ui_test_utils::NavigateToURL(browser(), start_urls[i]);
     EXPECT_EQ(start_urls[i], tab->GetMainFrame()->GetLastCommittedURL());
 
diff --git a/chrome/browser/external_protocol/external_protocol_handler.cc b/chrome/browser/external_protocol/external_protocol_handler.cc
index e33f45d..fab33800 100644
--- a/chrome/browser/external_protocol/external_protocol_handler.cc
+++ b/chrome/browser/external_protocol/external_protocol_handler.cc
@@ -8,8 +8,8 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "chrome/browser/platform_util.h"
 #include "chrome/browser/profiles/profile.h"
@@ -175,13 +175,13 @@
   }
 
   // Always block the hard-coded denied schemes.
-  for (size_t i = 0; i < arraysize(kDeniedSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kDeniedSchemes); ++i) {
     if (kDeniedSchemes[i] == scheme)
       return BLOCK;
   }
 
   // Always allow the hard-coded allowed schemes.
-  for (size_t i = 0; i < arraysize(kAllowedSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kAllowedSchemes); ++i) {
     if (kAllowedSchemes[i] == scheme)
       return DONT_BLOCK;
   }
diff --git a/chrome/browser/file_select_helper_unittest.cc b/chrome/browser/file_select_helper_unittest.cc
index 1f586f8b..275e4d4 100644
--- a/chrome/browser/file_select_helper_unittest.cc
+++ b/chrome/browser/file_select_helper_unittest.cc
@@ -10,9 +10,9 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/file_select_helper.h"
 #include "chrome/common/chrome_paths.h"
@@ -77,7 +77,7 @@
   const char* files_to_verify[] = {"Contents/Info.plist",
                                    "Contents/MacOS/Calculator",
                                    "Contents/_CodeSignature/CodeResources"};
-  size_t file_count = arraysize(files_to_verify);
+  size_t file_count = base::size(files_to_verify);
   for (size_t i = 0; i < file_count; i++) {
     const char* relative_path = files_to_verify[i];
     base::FilePath orig_file = src.Append(relative_path);
diff --git a/chrome/browser/first_run/upgrade_util_win.cc b/chrome/browser/first_run/upgrade_util_win.cc
index dc77424f..9c30b37 100644
--- a/chrome/browser/first_run/upgrade_util_win.cc
+++ b/chrome/browser/first_run/upgrade_util_win.cc
@@ -18,10 +18,10 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/process/launch.h"
 #include "base/process/process_handle.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/win/registry.h"
@@ -148,8 +148,7 @@
 
   if (!::GetMappedFileName(::GetCurrentProcess(),
                            reinterpret_cast<void*>(::GetModuleHandle(NULL)),
-                           mapped_file_name,
-                           arraysize(mapped_file_name))) {
+                           mapped_file_name, base::size(mapped_file_name))) {
     return false;
   }
 
diff --git a/chrome/browser/google/google_brand.cc b/chrome/browser/google/google_brand.cc
index 611ab30..6e9b9dd 100644
--- a/chrome/browser/google/google_brand.cc
+++ b/chrome/browser/google/google_brand.cc
@@ -7,7 +7,6 @@
 #include <algorithm>
 #include <string>
 
-#include "base/macros.h"
 #include "base/no_destructor.h"
 #include "base/optional.h"
 #include "base/stl_util.h"
@@ -119,7 +118,7 @@
       "CHOU", "CHOX", "CHOY", "CHOZ", "CHPD", "CHPE", "CHPF", "CHPG", "ECBA",
       "ECBB", "ECDA", "ECDB", "ECSA", "ECSB", "ECVA", "ECVB", "ECWA", "ECWB",
       "ECWC", "ECWD", "ECWE", "ECWF", "EUBB", "EUBC", "GGLA", "GGLS"};
-  const char* const* end = &kOrganicBrands[arraysize(kOrganicBrands)];
+  const char* const* end = &kOrganicBrands[base::size(kOrganicBrands)];
   if (std::binary_search(&kOrganicBrands[0], end, brand))
     return true;
 
diff --git a/chrome/browser/google/google_update_win.cc b/chrome/browser/google/google_update_win.cc
index 6e2b928..6611ed9 100644
--- a/chrome/browser/google/google_update_win.cc
+++ b/chrome/browser/google/google_update_win.cc
@@ -16,13 +16,13 @@
 #include "base/callback.h"
 #include "base/files/file_path.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
 #include "base/sequenced_task_runner.h"
 #include "base/sequenced_task_runner_helpers.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -138,7 +138,7 @@
   // For Vista+, need to instantiate the class factory via the elevation
   // moniker. This ensures that the UAC dialog shows up.
   wchar_t class_id_as_string[MAX_PATH] = {};
-  StringFromGUID2(class_id, class_id_as_string, arraysize(class_id_as_string));
+  StringFromGUID2(class_id, class_id_as_string, base::size(class_id_as_string));
 
   base::string16 elevation_moniker_name = base::StringPrintf(
       L"Elevation:Administrator!clsid:%ls", class_id_as_string);
diff --git a/chrome/browser/history/android/bookmark_model_sql_handler.cc b/chrome/browser/history/android/bookmark_model_sql_handler.cc
index 047e356..7b93eae5 100644
--- a/chrome/browser/history/android/bookmark_model_sql_handler.cc
+++ b/chrome/browser/history/android/bookmark_model_sql_handler.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/history/android/bookmark_model_sql_handler.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
 #include "chrome/browser/profiles/profile_manager.h"
@@ -93,11 +93,9 @@
   return BookmarkModelFactory::GetForBrowserContext(profile);
 }
 
-BookmarkModelSQLHandler::BookmarkModelSQLHandler(
-    URLDatabase* url_database)
-    : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
-      url_database_(url_database) {
-}
+BookmarkModelSQLHandler::BookmarkModelSQLHandler(URLDatabase* url_database)
+    : SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
+      url_database_(url_database) {}
 
 BookmarkModelSQLHandler::~BookmarkModelSQLHandler() {
 }
diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc
index f35ece5a..dc5d5f2f 100644
--- a/chrome/browser/history/top_sites_factory.cc
+++ b/chrome/browser/history/top_sites_factory.cc
@@ -11,8 +11,8 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/engagement/site_engagement_service.h"
 #include "chrome/browser/engagement/site_engagement_service_factory.h"
@@ -74,8 +74,8 @@
 #if !defined(OS_ANDROID)
   DCHECK(prepopulated_pages);
   bool hide_web_store_icon = prefs->GetBoolean(prefs::kHideWebStoreIcon);
-  prepopulated_pages->reserve(arraysize(kRawPrepopulatedPages));
-  for (size_t i = 0; i < arraysize(kRawPrepopulatedPages); ++i) {
+  prepopulated_pages->reserve(base::size(kRawPrepopulatedPages));
+  for (size_t i = 0; i < base::size(kRawPrepopulatedPages); ++i) {
     const RawPrepopulatedPage& page = kRawPrepopulatedPages[i];
     if (hide_web_store_icon && page.url_id == IDS_WEBSTORE_URL)
       continue;
diff --git a/chrome/browser/icon_loader_chromeos.cc b/chrome/browser/icon_loader_chromeos.cc
index e8177fe..e86c62d 100644
--- a/chrome/browser/icon_loader_chromeos.cc
+++ b/chrome/browser/icon_loader_chromeos.cc
@@ -13,8 +13,8 @@
 #include "base/bind.h"
 #include "base/files/file_path.h"
 #include "base/lazy_instance.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/task/post_task.h"
 #include "chrome/grit/theme_resources.h"
@@ -129,7 +129,7 @@
     std::make_pair(".webm", kVideoIdrs),
   };
 
-  const size_t kESize = arraysize(kExtensionIdrBySizeData);
+  const size_t kESize = base::size(kExtensionIdrBySizeData);
   ExtensionIconMap source(&kExtensionIdrBySizeData[0],
                           &kExtensionIdrBySizeData[kESize]);
   extension_icon_map_.swap(source);
diff --git a/chrome/browser/importer/edge_importer_browsertest_win.cc b/chrome/browser/importer/edge_importer_browsertest_win.cc
index 13fd30a..2d5e3e3 100644
--- a/chrome/browser/importer/edge_importer_browsertest_win.cc
+++ b/chrome/browser/importer/edge_importer_browsertest_win.cc
@@ -8,9 +8,9 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -177,7 +177,7 @@
       {false, 0, {}, L"InvalidFavicon", "http://www.invalid-favicon.com/"},
   };
   std::vector<BookmarkInfo> bookmark_entries(
-      kEdgeBookmarks, kEdgeBookmarks + arraysize(kEdgeBookmarks));
+      kEdgeBookmarks, kEdgeBookmarks + base::size(kEdgeBookmarks));
 
   const FaviconGroup kEdgeFaviconGroup[] = {
       {L"http://www.links-sublink.com/favicon.ico",
@@ -195,7 +195,7 @@
   };
 
   std::vector<FaviconGroup> favicon_groups(
-      kEdgeFaviconGroup, kEdgeFaviconGroup + arraysize(kEdgeFaviconGroup));
+      kEdgeFaviconGroup, kEdgeFaviconGroup + base::size(kEdgeFaviconGroup));
 
   base::FilePath data_path;
   ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &data_path));
@@ -239,11 +239,11 @@
   const BookmarkInfo kEdgeBookmarks[] = {
       {false, 0, {}, L"Google", "http://www.google.com/"}};
   std::vector<BookmarkInfo> bookmark_entries(
-      kEdgeBookmarks, kEdgeBookmarks + arraysize(kEdgeBookmarks));
+      kEdgeBookmarks, kEdgeBookmarks + base::size(kEdgeBookmarks));
   const FaviconGroup kEdgeFaviconGroup[] = {
       {L"http://www.google.com/favicon.ico", L"http://www.google.com/"}};
   std::vector<FaviconGroup> favicon_groups(
-      kEdgeFaviconGroup, kEdgeFaviconGroup + arraysize(kEdgeFaviconGroup));
+      kEdgeFaviconGroup, kEdgeFaviconGroup + base::size(kEdgeFaviconGroup));
 
   base::FilePath data_path;
   ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &data_path));
diff --git a/chrome/browser/importer/firefox_importer_browsertest.cc b/chrome/browser/importer/firefox_importer_browsertest.cc
index 3ab2558..6a73092d 100644
--- a/chrome/browser/importer/firefox_importer_browsertest.cc
+++ b/chrome/browser/importer/firefox_importer_browsertest.cc
@@ -7,7 +7,6 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
@@ -153,14 +152,14 @@
   void ImportItemEnded(importer::ImportItem item) override {}
   void ImportEnded() override {
     base::RunLoop::QuitCurrentWhenIdleDeprecated();
-    EXPECT_EQ(arraysize(kFirefoxBookmarks), bookmark_count_);
+    EXPECT_EQ(base::size(kFirefoxBookmarks), bookmark_count_);
     EXPECT_EQ(1U, history_count_);
-    EXPECT_EQ(arraysize(kFirefoxPasswords), password_count_);
+    EXPECT_EQ(base::size(kFirefoxPasswords), password_count_);
     // The following test case from |kFirefoxKeywords| won't be imported:
     //   "http://%x.example.{searchTerms}.com/"}.
     // Hence, value of |keyword_count_| should be lower than size of
     // |kFirefoxKeywords| by 1.
-    EXPECT_EQ(arraysize(kFirefoxKeywords) - 1, keyword_count_);
+    EXPECT_EQ(base::size(kFirefoxKeywords) - 1, keyword_count_);
   }
 
   bool BookmarkModelIsLoaded() const override {
@@ -199,7 +198,8 @@
 
   void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks,
                     const base::string16& top_level_folder_name) override {
-    ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kFirefoxBookmarks));
+    ASSERT_LE(bookmark_count_ + bookmarks.size(),
+              base::size(kFirefoxBookmarks));
     // Importer should import the FF favorites the same as the list, in the same
     // order.
     for (size_t i = 0; i < bookmarks.size(); ++i) {
@@ -212,8 +212,8 @@
 
   void AddAutofillFormDataEntries(
       const std::vector<autofill::AutofillEntry>& autofill_entries) override {
-    EXPECT_EQ(arraysize(kFirefoxAutofillEntries), autofill_entries.size());
-    for (size_t i = 0; i < arraysize(kFirefoxAutofillEntries); ++i) {
+    EXPECT_EQ(base::size(kFirefoxAutofillEntries), autofill_entries.size());
+    for (size_t i = 0; i < base::size(kFirefoxAutofillEntries); ++i) {
       EXPECT_EQ(kFirefoxAutofillEntries[i].name,
                 base::UTF16ToUTF8(autofill_entries[i].key().name()));
       EXPECT_EQ(kFirefoxAutofillEntries[i].value,
diff --git a/chrome/browser/importer/ie_importer_browsertest_win.cc b/chrome/browser/importer/ie_importer_browsertest_win.cc
index 508e8a33..95b97a0 100644
--- a/chrome/browser/importer/ie_importer_browsertest_win.cc
+++ b/chrome/browser/importer/ie_importer_browsertest_win.cc
@@ -21,8 +21,8 @@
 #include "base/compiler_specific.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -235,8 +235,8 @@
   void ImportEnded() override {
     base::RunLoop::QuitCurrentWhenIdleDeprecated();
     if (importer_items_ & importer::FAVORITES) {
-      EXPECT_EQ(arraysize(kIEBookmarks), bookmark_count_);
-      EXPECT_EQ(arraysize(kIEFaviconGroup), favicon_count_);
+      EXPECT_EQ(base::size(kIEBookmarks), bookmark_count_);
+      EXPECT_EQ(base::size(kIEFaviconGroup), favicon_count_);
     }
     if (importer_items_ & importer::HISTORY)
       EXPECT_EQ(2u, history_count_);
@@ -280,7 +280,7 @@
 
   void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks,
                     const base::string16& top_level_folder_name) override {
-    ASSERT_LE(bookmark_count_ + bookmarks.size(), arraysize(kIEBookmarks));
+    ASSERT_LE(bookmark_count_ + bookmarks.size(), base::size(kIEBookmarks));
     // Importer should import the IE Favorites folder the same as the list,
     // in the same order.
     for (size_t i = 0; i < bookmarks.size(); ++i) {
@@ -293,10 +293,10 @@
 
   void AddFavicons(const favicon_base::FaviconUsageDataList& usage) override {
     // Importer should group the favicon information for each favicon URL.
-    for (size_t i = 0; i < arraysize(kIEFaviconGroup); ++i) {
+    for (size_t i = 0; i < base::size(kIEFaviconGroup); ++i) {
       GURL favicon_url(kIEFaviconGroup[i].favicon_url);
       std::set<GURL> urls;
-      for (size_t j = 0; j < arraysize(kIEFaviconGroup[i].site_url); ++j)
+      for (size_t j = 0; j < base::size(kIEFaviconGroup[i].site_url); ++j)
         urls.insert(GURL(kIEFaviconGroup[i].site_url[j]));
 
       SCOPED_TRACE(testing::Message() << "Expected Favicon: " << favicon_url);
@@ -344,7 +344,7 @@
   void ImportItemEnded(importer::ImportItem item) override {}
   void ImportEnded() override {
     base::RunLoop::QuitCurrentWhenIdleDeprecated();
-    EXPECT_EQ(arraysize(kIESortedBookmarks), bookmark_count_);
+    EXPECT_EQ(base::size(kIESortedBookmarks), bookmark_count_);
   }
 
   // ProfileWriter:
@@ -358,7 +358,7 @@
   void AddBookmarks(const std::vector<ImportedBookmarkEntry>& bookmarks,
                     const base::string16& top_level_folder_name) override {
     ASSERT_LE(bookmark_count_ + bookmarks.size(),
-              arraysize(kIESortedBookmarks));
+              base::size(kIESortedBookmarks));
     for (size_t i = 0; i < bookmarks.size(); ++i) {
       EXPECT_NO_FATAL_FAILURE(
           TestEqualBookmarkEntry(bookmarks[i],
@@ -440,10 +440,10 @@
     L"a",
     L"SubFolder.url",
   };
-  ASSERT_TRUE(CreateOrderBlob(
-      base::FilePath(path), L"",
-      std::vector<base::string16>(root_links,
-                                  root_links + arraysize(root_links))));
+  ASSERT_TRUE(
+      CreateOrderBlob(base::FilePath(path), L"",
+                      std::vector<base::string16>(
+                          root_links, root_links + base::size(root_links))));
 
   // Sets up a special history link.
   Microsoft::WRL::ComPtr<IUrlHistoryStg2> url_history_stg2;
@@ -524,7 +524,7 @@
 
   // Verify malformed registry data are safely ignored and alphabetical
   // sort is performed.
-  for (size_t i = 0; i < arraysize(kBadBinary); ++i) {
+  for (size_t i = 0; i < base::size(kBadBinary); ++i) {
     base::string16 key_path(importer::GetIEFavoritesOrderKey());
     base::win::RegKey key;
     ASSERT_EQ(ERROR_SUCCESS,
diff --git a/chrome/browser/lifetime/switch_utils_unittest.cc b/chrome/browser/lifetime/switch_utils_unittest.cc
index fb63af41..7e3f32b 100644
--- a/chrome/browser/lifetime/switch_utils_unittest.cc
+++ b/chrome/browser/lifetime/switch_utils_unittest.cc
@@ -6,7 +6,7 @@
 
 #include "base/command_line.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -18,7 +18,7 @@
       FILE_PATH_LITERAL("--make-default-browser"),
       FILE_PATH_LITERAL("--foo"),
       FILE_PATH_LITERAL("--bar")};
-  base::CommandLine cmd_line(arraysize(argv), argv);
+  base::CommandLine cmd_line(base::size(argv), argv);
   EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
 
   base::CommandLine::SwitchMap switches = cmd_line.GetSwitches();
@@ -58,7 +58,7 @@
       FILE_PATH_LITERAL("--foo"),
       FILE_PATH_LITERAL("/prefetch:1"),
       FILE_PATH_LITERAL("--bar")};
-  base::CommandLine cmd_line(arraysize(argv), argv);
+  base::CommandLine cmd_line(base::size(argv), argv);
   EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
 
   base::CommandLine::SwitchMap switches = cmd_line.GetSwitches();
@@ -77,7 +77,7 @@
       FILE_PATH_LITERAL("/prefetch:1"),
       FILE_PATH_LITERAL("--force-first-run"),
       FILE_PATH_LITERAL("--bar")};
-  base::CommandLine cmd_line(arraysize(argv), argv);
+  base::CommandLine cmd_line(base::size(argv), argv);
   EXPECT_FALSE(cmd_line.GetCommandLineString().empty());
 
   base::CommandLine::SwitchMap switches = cmd_line.GetSwitches();
diff --git a/chrome/browser/local_discovery/service_discovery_client_mac_unittest.mm b/chrome/browser/local_discovery/service_discovery_client_mac_unittest.mm
index 72d98cb..769fb98 100644
--- a/chrome/browser/local_discovery/service_discovery_client_mac_unittest.mm
+++ b/chrome/browser/local_discovery/service_discovery_client_mac_unittest.mm
@@ -8,7 +8,6 @@
 #include "base/bind.h"
 #include "base/callback.h"
 #include "base/mac/scoped_nsobject.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
 #include "chrome/browser/local_discovery/service_discovery_client.h"
@@ -126,7 +125,7 @@
   const uint8_t record_bytes[] = {2, 'a', 'b', 3, 'd', '=', 'e'};
   base::scoped_nsobject<TestNSNetService> test_service([[TestNSNetService alloc]
       initWithData:[NSData dataWithBytes:record_bytes
-                                  length:arraysize(record_bytes)]]);
+                                  length:base::size(record_bytes)]]);
 
   const std::string kIp = "2001:4860:4860::8844";
   const uint16_t kPort = 4321;
@@ -181,7 +180,7 @@
   };
   base::scoped_nsobject<TestNSNetService> test_service([[TestNSNetService alloc]
       initWithData:[NSData dataWithBytes:record_bytes
-                                  length:arraysize(record_bytes)]]);
+                                  length:base::size(record_bytes)]]);
 
   const std::string kIp = "2001:4860:4860::8844";
   const uint16_t kPort = 4321;
diff --git a/chrome/browser/locale_tests_browsertest.cc b/chrome/browser/locale_tests_browsertest.cc
index 75d814a..3b29a39 100644
--- a/chrome/browser/locale_tests_browsertest.cc
+++ b/chrome/browser/locale_tests_browsertest.cc
@@ -8,7 +8,7 @@
 
 #include "base/command_line.h"
 #include "base/environment.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "ui/base/ui_base_switches.h"
@@ -35,7 +35,7 @@
       { "zh-TW", "zh_TW.UTF-8" }
     };
     bool found_locale = false;
-    for (size_t i = 0; i < arraysize(kLocales); ++i) {
+    for (size_t i = 0; i < base::size(kLocales); ++i) {
       if (kLocales[i].chrome_locale == locale) {
         found_locale = true;
         setenv("LC_ALL", kLocales[i].system_locale, 1);
diff --git a/chrome/browser/mac/exception_processor.mm b/chrome/browser/mac/exception_processor.mm
index 8354415..da7bfae 100644
--- a/chrome/browser/mac/exception_processor.mm
+++ b/chrome/browser/mac/exception_processor.mm
@@ -15,8 +15,8 @@
 #include "base/debug/crash_logging.h"
 #include "base/debug/stack_trace.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "components/crash/core/common/crash_key.h"
 
@@ -58,11 +58,11 @@
   };
 
   // Make sure our array hasn't outgrown our abilities to track it.
-  static_assert(arraysize(kKnownNSExceptionNames) < kKnownNSExceptionCount,
+  static_assert(base::size(kKnownNSExceptionNames) < kKnownNSExceptionCount,
                 "Cannot track more exceptions");
 
   NSString* name = [exception name];
-  for (size_t i = 0; i < arraysize(kKnownNSExceptionNames); ++i) {
+  for (size_t i = 0; i < base::size(kKnownNSExceptionNames); ++i) {
     if (name == kKnownNSExceptionNames[i]) {
       return i;
     }
diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm
index cf28387..758046a 100644
--- a/chrome/browser/mac/install_from_dmg.mm
+++ b/chrome/browser/mac/install_from_dmg.mm
@@ -32,6 +32,7 @@
 #include "base/mac/scoped_nsautorelease_pool.h"
 #include "base/mac/sdk_forward_declarations.h"
 #include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/sys_string_conversions.h"
@@ -185,7 +186,7 @@
   }
 
   const char dev_root[] = "/dev/";
-  const int dev_root_length = arraysize(dev_root) - 1;
+  const int dev_root_length = base::size(dev_root) - 1;
   if (strncmp(statfs_buf.f_mntfromname, dev_root, dev_root_length) != 0) {
     // Not rooted at dev_root, no BSD name to search on.
     return DiskImageStatusFalse;
diff --git a/chrome/browser/media/router/discovery/dial/dial_service_unittest.cc b/chrome/browser/media/router/discovery/dial/dial_service_unittest.cc
index d76a680..750c44f 100644
--- a/chrome/browser/media/router/discovery/dial/dial_service_unittest.cc
+++ b/chrome/browser/media/router/discovery/dial/dial_service_unittest.cc
@@ -8,9 +8,9 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "chrome/browser/media/router/discovery/dial/dial_device_data.h"
 #include "content/public/test/test_browser_thread_bundle.h"
 #include "net/base/ip_address.h"
@@ -138,7 +138,7 @@
 
 TEST_F(DialServiceTest, TestOnDeviceDiscovered) {
   dial_service_.discovery_active_ = true;
-  int response_size = arraysize(kValidResponse) - 1;
+  int response_size = base::size(kValidResponse) - 1;
   dial_socket_->recv_buffer_ =
       base::MakeRefCounted<net::IOBufferWithSize>(response_size);
   strncpy(dial_socket_->recv_buffer_->data(), kValidResponse, response_size);
diff --git a/chrome/browser/media/router/discovery/discovery_network_list_win.cc b/chrome/browser/media/router/discovery/discovery_network_list_win.cc
index f1d4a353..3b5e397 100644
--- a/chrome/browser/media/router/discovery/discovery_network_list_win.cc
+++ b/chrome/browser/media/router/discovery/discovery_network_list_win.cc
@@ -20,6 +20,7 @@
 
 #include "base/containers/small_map.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 
 namespace media_router {
@@ -68,7 +69,7 @@
   static std::unique_ptr<WlanApi> Create() {
     static const wchar_t* kWlanDllPath = L"%WINDIR%\\system32\\wlanapi.dll";
     wchar_t path[MAX_PATH] = {0};
-    ExpandEnvironmentStrings(kWlanDllPath, path, arraysize(path));
+    ExpandEnvironmentStrings(kWlanDllPath, path, base::size(path));
     HINSTANCE library =
         LoadLibraryEx(path, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
     if (!library) {
diff --git a/chrome/browser/media/router/test/media_router_mojo_test.cc b/chrome/browser/media/router/test/media_router_mojo_test.cc
index a8446126..1e1ce40 100644
--- a/chrome/browser/media/router/test/media_router_mojo_test.cc
+++ b/chrome/browser/media/router/test/media_router_mojo_test.cc
@@ -8,6 +8,7 @@
 
 #include "base/bind.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "chrome/browser/media/router/event_page_request_manager_factory.h"
 #include "extensions/common/extension_builder.h"
 
@@ -359,13 +360,13 @@
 void MediaRouterMojoTest::TestSendRouteBinaryMessage() {
   ProvideTestRoute(MediaRouteProviderId::EXTENSION, kRouteId);
   auto expected_binary_data = std::make_unique<std::vector<uint8_t>>(
-      kBinaryMessage, kBinaryMessage + arraysize(kBinaryMessage));
+      kBinaryMessage, kBinaryMessage + base::size(kBinaryMessage));
   EXPECT_CALL(mock_extension_provider_, SendRouteBinaryMessage(kRouteId, _))
-      .WillOnce(
-          [](const MediaRoute::Id& route_id, const std::vector<uint8_t>& data) {
-            EXPECT_EQ(0, memcmp(kBinaryMessage, &(data[0]),
-                                arraysize(kBinaryMessage)));
-          });
+      .WillOnce([](const MediaRoute::Id& route_id,
+                   const std::vector<uint8_t>& data) {
+        EXPECT_EQ(
+            0, memcmp(kBinaryMessage, &(data[0]), base::size(kBinaryMessage)));
+      });
 
   router()->SendRouteBinaryMessage(kRouteId, std::move(expected_binary_data));
   base::RunLoop().RunUntilIdle();
diff --git a/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc b/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc
index 8cbbc51b..65e0f9dd 100644
--- a/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc
+++ b/chrome/browser/media/webrtc/webrtc_event_log_manager_local.cc
@@ -5,6 +5,7 @@
 #include "chrome/browser/media/webrtc/webrtc_event_log_manager_local.h"
 
 #include "base/files/file_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
@@ -244,11 +245,11 @@
   // [user_defined]_[date]_[time]_[render_process_id]_[lid].[extension]
   char stamp[100];
   int written =
-      base::snprintf(stamp, arraysize(stamp), "%04d%02d%02d_%02d%02d_%d_%d",
+      base::snprintf(stamp, base::size(stamp), "%04d%02d%02d_%02d%02d_%d_%d",
                      now.year, now.month, now.day_of_month, now.hour,
                      now.minute, key.render_process_id, key.lid);
   CHECK_GT(written, 0);
-  CHECK_LT(static_cast<size_t>(written), arraysize(stamp));
+  CHECK_LT(static_cast<size_t>(written), base::size(stamp));
 
   return base_path.InsertBeforeExtension(FILE_PATH_LITERAL("_"))
       .AddExtension(log_file_writer_factory_.Extension())
diff --git a/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc b/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc
index f1a28ed4..85da228 100644
--- a/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc
+++ b/chrome/browser/media/webrtc/webrtc_rtp_dump_handler_unittest.cc
@@ -14,10 +14,10 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/task_scheduler/task_scheduler.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chrome/browser/media/webrtc/webrtc_rtp_dump_writer.h"
@@ -97,8 +97,8 @@
     *incoming_dump = dir.AppendASCII("recv");
     *outgoing_dump = dir.AppendASCII("send");
     const char dummy[] = "dummy";
-    EXPECT_GT(base::WriteFile(*incoming_dump, dummy, arraysize(dummy)), 0);
-    EXPECT_GT(base::WriteFile(*outgoing_dump, dummy, arraysize(dummy)), 0);
+    EXPECT_GT(base::WriteFile(*incoming_dump, dummy, base::size(dummy)), 0);
+    EXPECT_GT(base::WriteFile(*outgoing_dump, dummy, base::size(dummy)), 0);
   }
 
   void FlushTaskRunners() {
@@ -124,7 +124,7 @@
   types[1] = RTP_DUMP_OUTGOING;
   types[2] = RTP_DUMP_BOTH;
 
-  for (size_t i = 0; i < arraysize(types); ++i) {
+  for (size_t i = 0; i < base::size(types); ++i) {
     DVLOG(2) << "Verifying state transition: type = " << types[i];
 
     // Only StartDump is allowed in STATE_NONE.
@@ -213,10 +213,10 @@
 
   std::unique_ptr<WebRtcRtpDumpHandler> handlers[6];
 
-  for (size_t i = 0; i < arraysize(handlers); ++i) {
+  for (size_t i = 0; i < base::size(handlers); ++i) {
     handlers[i].reset(new WebRtcRtpDumpHandler(base::FilePath()));
 
-    if (i < arraysize(handlers) - 1) {
+    if (i < base::size(handlers) - 1) {
       EXPECT_TRUE(handlers[i]->StartDump(RTP_DUMP_INCOMING, &error));
     } else {
       EXPECT_FALSE(handlers[i]->StartDump(RTP_DUMP_INCOMING, &error));
diff --git a/chrome/browser/media/webrtc/webrtc_rtp_dump_writer.cc b/chrome/browser/media/webrtc/webrtc_rtp_dump_writer.cc
index 6a21ee87..10e779f1 100644
--- a/chrome/browser/media/webrtc/webrtc_rtp_dump_writer.cc
+++ b/chrome/browser/media/webrtc/webrtc_rtp_dump_writer.cc
@@ -9,7 +9,7 @@
 #include "base/big_endian.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "content/public/browser/browser_thread.h"
 #include "third_party/zlib/zlib.h"
@@ -298,8 +298,7 @@
 
     // Writes the dump file header.
     AppendToBuffer(kRtpDumpFileHeaderFirstLine,
-                   arraysize(kRtpDumpFileHeaderFirstLine) - 1,
-                   dest_buffer);
+                   base::size(kRtpDumpFileHeaderFirstLine) - 1, dest_buffer);
     WriteRtpDumpFileHeaderBigEndian(start_time_, dest_buffer);
   }
 
diff --git a/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc b/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc
index 073cd49..12bc9b49 100644
--- a/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc
+++ b/chrome/browser/media/webrtc/webrtc_rtp_dump_writer_unittest.cc
@@ -14,9 +14,9 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/test/test_browser_thread_bundle.h"
 #include "content/public/test/test_utils.h"
@@ -149,9 +149,9 @@
     size_t dump_pos = 0;
 
     // Verifies the first line.
-    EXPECT_EQ(memcmp(&dump[0], kFirstLine, arraysize(kFirstLine) - 1), 0);
+    EXPECT_EQ(memcmp(&dump[0], kFirstLine, base::size(kFirstLine) - 1), 0);
 
-    dump_pos += arraysize(kFirstLine) - 1;
+    dump_pos += base::size(kFirstLine) - 1;
     EXPECT_GT(dump.size(), dump_pos);
 
     // Skips the file header.
diff --git a/chrome/browser/media_galleries/chromeos/mtp_device_object_enumerator_unittest.cc b/chrome/browser/media_galleries/chromeos/mtp_device_object_enumerator_unittest.cc
index e40efef..2ae4e8d 100644
--- a/chrome/browser/media_galleries/chromeos/mtp_device_object_enumerator_unittest.cc
+++ b/chrome/browser/media_galleries/chromeos/mtp_device_object_enumerator_unittest.cc
@@ -7,7 +7,7 @@
 
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/browser/media_galleries/chromeos/mtp_device_object_enumerator.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -49,7 +49,7 @@
 
 TEST_F(MTPDeviceObjectEnumeratorTest, Traversal) {
   std::vector<device::mojom::MtpFileEntryPtr> entries;
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     auto entry = device::mojom::MtpFileEntry::New();
     entry->file_name = kTestCases[i].name;
     entry->file_size = kTestCases[i].size;
@@ -63,7 +63,7 @@
   MTPDeviceObjectEnumerator enumerator(std::move(entries));
   TestEnumeratorIsEmpty(&enumerator);
   TestEnumeratorIsEmpty(&enumerator);
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     EXPECT_EQ(kTestCases[i].name, enumerator.Next().value());
     EXPECT_EQ(kTestCases[i].size, enumerator.Size());
     EXPECT_EQ(kTestCases[i].is_directory, enumerator.IsDirectory());
diff --git a/chrome/browser/media_galleries/fileapi/media_file_validator_browsertest.cc b/chrome/browser/media_galleries/fileapi/media_file_validator_browsertest.cc
index c0df789..f1e7f00 100644
--- a/chrome/browser/media_galleries/fileapi/media_file_validator_browsertest.cc
+++ b/chrome/browser/media_galleries/fileapi/media_file_validator_browsertest.cc
@@ -11,9 +11,9 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/task/task_traits.h"
 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
@@ -270,21 +270,23 @@
 };
 
 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, UnsupportedExtension) {
-  MoveTest("a.txt", std::string(kValidImage, arraysize(kValidImage)), false);
+  MoveTest("a.txt", std::string(kValidImage, base::size(kValidImage)), false);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidImage) {
-  MoveTest("a.webp", std::string(kValidImage, arraysize(kValidImage)), true);
+  MoveTest("a.webp", std::string(kValidImage, base::size(kValidImage)), true);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, InvalidImage) {
-  MoveTest("a.webp", std::string(kInvalidMediaFile,
-           arraysize(kInvalidMediaFile)), false);
+  MoveTest("a.webp",
+           std::string(kInvalidMediaFile, base::size(kInvalidMediaFile)),
+           false);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, InvalidAudio) {
-  MoveTest("a.ogg", std::string(kInvalidMediaFile,
-           arraysize(kInvalidMediaFile)), false);
+  MoveTest("a.ogg",
+           std::string(kInvalidMediaFile, base::size(kInvalidMediaFile)),
+           false);
 }
 
 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidAudio) {
diff --git a/chrome/browser/media_galleries/fileapi/media_path_filter.cc b/chrome/browser/media_galleries/fileapi/media_path_filter.cc
index 5b92c254..b76e192 100644
--- a/chrome/browser/media_galleries/fileapi/media_path_filter.cc
+++ b/chrome/browser/media_galleries/fileapi/media_path_filter.cc
@@ -172,13 +172,16 @@
   AddExtensionsToMediaFileExtensionMap(GetMediaExtensionList("video/*"),
                                        MEDIA_GALLERY_FILE_TYPE_VIDEO);
   AddAdditionalExtensionsToMediaFileExtensionMap(
-      kExtraSupportedImageExtensions, arraysize(kExtraSupportedImageExtensions),
+      kExtraSupportedImageExtensions,
+      base::size(kExtraSupportedImageExtensions),
       MEDIA_GALLERY_FILE_TYPE_IMAGE);
   AddAdditionalExtensionsToMediaFileExtensionMap(
-      kExtraSupportedAudioExtensions, arraysize(kExtraSupportedAudioExtensions),
+      kExtraSupportedAudioExtensions,
+      base::size(kExtraSupportedAudioExtensions),
       MEDIA_GALLERY_FILE_TYPE_AUDIO);
   AddAdditionalExtensionsToMediaFileExtensionMap(
-      kExtraSupportedVideoExtensions, arraysize(kExtraSupportedVideoExtensions),
+      kExtraSupportedVideoExtensions,
+      base::size(kExtraSupportedVideoExtensions),
       MEDIA_GALLERY_FILE_TYPE_VIDEO);
 
   initialized_ = true;
diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc b/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc
index 1665fde8..751cadb8 100644
--- a/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc
+++ b/chrome/browser/media_galleries/fileapi/native_media_file_util_unittest.cc
@@ -14,7 +14,7 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/format_macros.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/task/post_task.h"
 #include "base/threading/sequenced_task_runner_handle.h"
@@ -203,11 +203,10 @@
 };
 
 TEST_F(NativeMediaFileUtilTest, DirectoryExistsAndFileExistsFiltering) {
-  PopulateDirectoryWithTestCases(root_path(),
-                                 kFilteringTestCases,
-                                 arraysize(kFilteringTestCases));
+  PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                 base::size(kFilteringTestCases));
 
-  for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
     FileSystemURL url = CreateURL(kFilteringTestCases[i].path);
 
     base::File::Error expectation =
@@ -229,9 +228,8 @@
 }
 
 TEST_F(NativeMediaFileUtilTest, ReadDirectoryFiltering) {
-  PopulateDirectoryWithTestCases(root_path(),
-                                 kFilteringTestCases,
-                                 arraysize(kFilteringTestCases));
+  PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                 base::size(kFilteringTestCases));
 
   std::set<base::FilePath::StringType> content;
   FileSystemURL url = CreateURL(FPL(""));
@@ -242,7 +240,7 @@
   EXPECT_TRUE(completed);
   EXPECT_EQ(6u, content.size());
 
-  for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
     base::FilePath::StringType name =
         base::FilePath(kFilteringTestCases[i].path).BaseName().value();
     auto found = content.find(name);
@@ -254,7 +252,7 @@
   // Run the loop twice. The second loop attempts to create directories that are
   // pre-existing. Though the result should be the same.
   for (int loop_count = 0; loop_count < 2; ++loop_count) {
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       if (kFilteringTestCases[i].is_directory) {
         FileSystemURL root_url = CreateURL(FPL(""));
         FileSystemURL url = CreateURL(kFilteringTestCases[i].path);
@@ -282,11 +280,10 @@
   // Run the loop twice. The first run has no source files. The second run does.
   for (int loop_count = 0; loop_count < 2; ++loop_count) {
     if (loop_count == 1) {
-      PopulateDirectoryWithTestCases(root_path(),
-                                     kFilteringTestCases,
-                                     arraysize(kFilteringTestCases));
+      PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                     base::size(kFilteringTestCases));
     }
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       // Always start with an empty destination directory.
       // Copying to a non-empty destination directory is an invalid operation.
       ASSERT_TRUE(base::DeleteFile(dest_path, true));
@@ -324,9 +321,8 @@
       // directories and create new ones that should pre-exist.
       ASSERT_TRUE(base::DeleteFile(root_path(), true));
       ASSERT_TRUE(base::CreateDirectory(root_path()));
-      PopulateDirectoryWithTestCases(root_path(),
-                                     kFilteringTestCases,
-                                     arraysize(kFilteringTestCases));
+      PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                     base::size(kFilteringTestCases));
     }
 
     // Always create a dummy source data file.
@@ -336,7 +332,7 @@
     ASSERT_EQ(static_cast<int>(strlen(kDummyData)),
               base::WriteFile(src_path, kDummyData, strlen(kDummyData)));
 
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       if (loop_count == 0 && kFilteringTestCases[i].is_directory) {
         // These directories do not exist in this case, so Copy() will not
         // treat them as directories. Thus invalidating these test cases.
@@ -388,11 +384,10 @@
   // Run the loop twice. The first run has no source files. The second run does.
   for (int loop_count = 0; loop_count < 2; ++loop_count) {
     if (loop_count == 1) {
-      PopulateDirectoryWithTestCases(root_path(),
-                                     kFilteringTestCases,
-                                     arraysize(kFilteringTestCases));
+      PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                     base::size(kFilteringTestCases));
     }
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       // Always start with an empty destination directory.
       // Moving to a non-empty destination directory is an invalid operation.
       ASSERT_TRUE(base::DeleteFile(dest_path, true));
@@ -430,12 +425,11 @@
       // directories and create new ones that should pre-exist.
       ASSERT_TRUE(base::DeleteFile(root_path(), true));
       ASSERT_TRUE(base::CreateDirectory(root_path()));
-      PopulateDirectoryWithTestCases(root_path(),
-                                     kFilteringTestCases,
-                                     arraysize(kFilteringTestCases));
+      PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                     base::size(kFilteringTestCases));
     }
 
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       if (loop_count == 0 && kFilteringTestCases[i].is_directory) {
         // These directories do not exist in this case, so Copy() will not
         // treat them as directories. Thus invalidating these test cases.
@@ -492,11 +486,10 @@
   // Run the loop twice. The first run has no files. The second run does.
   for (int loop_count = 0; loop_count < 2; ++loop_count) {
     if (loop_count == 1) {
-      PopulateDirectoryWithTestCases(root_path(),
-                                     kFilteringTestCases,
-                                     arraysize(kFilteringTestCases));
+      PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                     base::size(kFilteringTestCases));
     }
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       FileSystemURL root_url = CreateURL(FPL(""));
       FileSystemURL url = CreateURL(kFilteringTestCases[i].path);
 
@@ -520,11 +513,10 @@
   // Run the loop twice. The first run has no files. The second run does.
   for (int loop_count = 0; loop_count < 2; ++loop_count) {
     if (loop_count == 1) {
-      PopulateDirectoryWithTestCases(root_path(),
-                                     kFilteringTestCases,
-                                     arraysize(kFilteringTestCases));
+      PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                     base::size(kFilteringTestCases));
     }
-    for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
       FileSystemURL root_url = CreateURL(FPL(""));
       FileSystemURL url = CreateURL(kFilteringTestCases[i].path);
 
@@ -553,10 +545,9 @@
 }
 
 TEST_F(NativeMediaFileUtilTest, CreateSnapshot) {
-  PopulateDirectoryWithTestCases(root_path(),
-                                 kFilteringTestCases,
-                                 arraysize(kFilteringTestCases));
-  for (size_t i = 0; i < arraysize(kFilteringTestCases); ++i) {
+  PopulateDirectoryWithTestCases(root_path(), kFilteringTestCases,
+                                 base::size(kFilteringTestCases));
+  for (size_t i = 0; i < base::size(kFilteringTestCases); ++i) {
     if (kFilteringTestCases[i].is_directory ||
         !kFilteringTestCases[i].visible) {
       continue;
diff --git a/chrome/browser/media_galleries/media_galleries_permissions_unittest.cc b/chrome/browser/media_galleries/media_galleries_permissions_unittest.cc
index d3c1b88..56985c89 100644
--- a/chrome/browser/media_galleries/media_galleries_permissions_unittest.cc
+++ b/chrome/browser/media_galleries/media_galleries_permissions_unittest.cc
@@ -6,8 +6,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "chrome/browser/extensions/extension_prefs_unittest.h"
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
@@ -118,7 +118,7 @@
                                   {&extension2_id_, &extension2_expectation_},
                                   {&extension3_id_, &extension3_expectation_},
                                   {&extension4_id_, &extension4_expectation_}};
-    for (size_t i = 0; i < arraysize(test_data); i++) {
+    for (size_t i = 0; i < base::size(test_data); i++) {
       std::vector<MediaGalleryPermission> actual =
           gallery_prefs_->GetGalleryPermissionsFromPrefs(*test_data[i].id);
       EXPECT_EQ(test_data[i].expectation->size(), actual.size());
diff --git a/chrome/browser/media_galleries/media_galleries_preferences.cc b/chrome/browser/media_galleries/media_galleries_preferences.cc
index 80f1b9c..f79731e 100644
--- a/chrome/browser/media_galleries/media_galleries_preferences.cc
+++ b/chrome/browser/media_galleries/media_galleries_preferences.cc
@@ -12,7 +12,6 @@
 #include "base/base_paths_posix.h"
 #include "base/callback.h"
 #include "base/i18n/time_formatting.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/stl_util.h"
 #include "base/strings/string16.h"
@@ -507,7 +506,7 @@
     {chrome::DIR_USER_VIDEOS, MediaGalleryPrefInfo::kVideosDefault},
   };
 
-  for (size_t i = 0; i < arraysize(kDirectories); ++i) {
+  for (size_t i = 0; i < base::size(kDirectories); ++i) {
     base::FilePath path;
     if (!base::PathService::Get(kDirectories[i].directory_key, &path))
       continue;
diff --git a/chrome/browser/media_galleries/win/mtp_device_object_enumerator_unittest.cc b/chrome/browser/media_galleries/win/mtp_device_object_enumerator_unittest.cc
index 2caba53..dd2ae61 100644
--- a/chrome/browser/media_galleries/win/mtp_device_object_enumerator_unittest.cc
+++ b/chrome/browser/media_galleries/win/mtp_device_object_enumerator_unittest.cc
@@ -11,7 +11,7 @@
 
 #include <ctime>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/time/time.h"
 #include "chrome/browser/media_galleries/win/mtp_device_object_entry.h"
@@ -66,7 +66,7 @@
 
 TEST_F(MTPDeviceObjectEnumeratorWinTest, Traversal) {
   MTPDeviceObjectEntries entries;
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     entries.push_back(MTPDeviceObjectEntry(
         kTestCases[i].object_id,
         kTestCases[i].name,
@@ -77,7 +77,7 @@
   MTPDeviceObjectEnumerator enumerator(entries);
   TestEnumeratorIsEmpty(&enumerator);
   TestEnumeratorIsEmpty(&enumerator);
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     EXPECT_EQ(kTestCases[i].name, enumerator.Next().value());
     EXPECT_EQ(kTestCases[i].object_id, enumerator.GetObjectId());
     EXPECT_EQ(kTestCases[i].size, enumerator.Size());
diff --git a/chrome/browser/memory/memory_kills_monitor_unittest.cc b/chrome/browser/memory/memory_kills_monitor_unittest.cc
index cba304c..56411037 100644
--- a/chrome/browser/memory/memory_kills_monitor_unittest.cc
+++ b/chrome/browser/memory/memory_kills_monitor_unittest.cc
@@ -4,10 +4,10 @@
 
 #include "chrome/browser/memory/memory_kills_monitor.h"
 
-#include "base/macros.h"
 #include "base/metrics/histogram_base.h"
 #include "base/metrics/histogram_samples.h"
 #include "base/metrics/statistics_recorder.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "chrome/browser/memory/memory_kills_histogram.h"
 #include "content/public/test/test_browser_thread_bundle.h"
@@ -117,7 +117,7 @@
       "score 653 or sacrifice child"
   };
 
-  for (unsigned long i = 0; i < arraysize(sample_lines); ++i) {
+  for (unsigned long i = 0; i < base::size(sample_lines); ++i) {
     MemoryKillsMonitor::TryMatchOomKillLine(sample_lines[i]);
   }
 
diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc
index 6bfa3bc..769bc331 100644
--- a/chrome/browser/metrics/chrome_metrics_service_client.cc
+++ b/chrome/browser/metrics/chrome_metrics_service_client.cc
@@ -24,6 +24,7 @@
 #include "base/metrics/statistics_recorder.h"
 #include "base/path_service.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_piece.h"
 #include "base/task/post_task.h"
@@ -343,7 +344,7 @@
   DCHECK_NE(nullptr, channel_name);
 
   wchar_t exe_file[MAX_PATH] = {};
-  CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file)));
+  CHECK(::GetModuleFileName(nullptr, exe_file, base::size(exe_file)));
 
   base::string16 unused_special_build;
   install_static::GetExecutableVersionDetails(
diff --git a/chrome/browser/metrics/perf/cpu_identity.cc b/chrome/browser/metrics/perf/cpu_identity.cc
index 97b0b1f..d6ae9056 100644
--- a/chrome/browser/metrics/perf/cpu_identity.cc
+++ b/chrome/browser/metrics/perf/cpu_identity.cc
@@ -8,7 +8,7 @@
 #include <string.h>
 
 #include "base/cpu.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/system/sys_info.h"
@@ -65,7 +65,7 @@
 };
 
 const CpuUarchTableEntry* kCpuUarchTableEnd =
-    kCpuUarchTable + arraysize(kCpuUarchTable);
+    kCpuUarchTable + base::size(kCpuUarchTable);
 
 bool CpuUarchTableCmp(const CpuUarchTableEntry& a,
                       const CpuUarchTableEntry& b) {
diff --git a/chrome/browser/metrics/thread_watcher_unittest.cc b/chrome/browser/metrics/thread_watcher_unittest.cc
index 0eb536c..93f70d7 100644
--- a/chrome/browser/metrics/thread_watcher_unittest.cc
+++ b/chrome/browser/metrics/thread_watcher_unittest.cc
@@ -13,10 +13,10 @@
 #include "base/cancelable_callback.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.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_tokenizer.h"
@@ -430,7 +430,7 @@
   // Verify the data.
   base::CStringTokenizer tokens(
       kCrashOnHangThreadNames,
-      kCrashOnHangThreadNames + (arraysize(kCrashOnHangThreadNames) - 1), ",");
+      kCrashOnHangThreadNames + (base::size(kCrashOnHangThreadNames) - 1), ",");
   while (tokens.GetNext()) {
     std::vector<base::StringPiece> values = base::SplitStringPiece(
         tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
@@ -459,7 +459,7 @@
   // Verify the data.
   base::CStringTokenizer tokens(
       kCrashOnHangThreadData,
-      kCrashOnHangThreadData + (arraysize(kCrashOnHangThreadData) - 1), ",");
+      kCrashOnHangThreadData + (base::size(kCrashOnHangThreadData) - 1), ",");
   while (tokens.GetNext()) {
     std::vector<base::StringPiece> values = base::SplitStringPiece(
         tokens.token_piece(), ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
diff --git a/chrome/browser/nacl_host/nacl_browser_delegate_impl.cc b/chrome/browser/nacl_host/nacl_browser_delegate_impl.cc
index 5d09bf1..49c9062 100644
--- a/chrome/browser/nacl_host/nacl_browser_delegate_impl.cc
+++ b/chrome/browser/nacl_host/nacl_browser_delegate_impl.cc
@@ -8,8 +8,8 @@
 
 #include <vector>
 
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/browser_process.h"
@@ -54,7 +54,7 @@
     ProfileManager* profile_manager)
     : profile_manager_(profile_manager), inverse_debug_patterns_(false) {
   DCHECK(profile_manager_);
-  for (size_t i = 0; i < arraysize(kAllowedNonSfiOrigins); ++i) {
+  for (size_t i = 0; i < base::size(kAllowedNonSfiOrigins); ++i) {
     allowed_nonsfi_origins_.insert(kAllowedNonSfiOrigins[i]);
   }
 }
diff --git a/chrome/browser/net/service_providers_win.cc b/chrome/browser/net/service_providers_win.cc
index 66fb715..4eb2e4f1 100644
--- a/chrome/browser/net/service_providers_win.cc
+++ b/chrome/browser/net/service_providers_win.cc
@@ -10,7 +10,7 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 
 WinsockLayeredServiceProvider::WinsockLayeredServiceProvider() {
@@ -93,7 +93,7 @@
     // http://msdn.microsoft.com/en-us/library/ms742239%28v=VS.85%29.aspx
 
     wchar_t path[MAX_PATH];
-    int path_length = arraysize(path);
+    int path_length = base::size(path);
     if (0 == WSCGetProviderPath(&service_providers[i].ProviderId, path,
                                 &path_length, &error)) {
       service_provider.path = path;
diff --git a/chrome/browser/notifications/platform_notification_service_unittest.cc b/chrome/browser/notifications/platform_notification_service_unittest.cc
index 918f836a..65a89be 100644
--- a/chrome/browser/notifications/platform_notification_service_unittest.cc
+++ b/chrome/browser/notifications/platform_notification_service_unittest.cc
@@ -11,7 +11,7 @@
 #include "base/bind_helpers.h"
 #include "base/feature_list.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
@@ -168,7 +168,8 @@
 TEST_F(PlatformNotificationServiceTest, DisplayNonPersistentPropertiesMatch) {
   std::vector<int> vibration_pattern(
       kNotificationVibrationPattern,
-      kNotificationVibrationPattern + arraysize(kNotificationVibrationPattern));
+      kNotificationVibrationPattern +
+          base::size(kNotificationVibrationPattern));
 
   PlatformNotificationData data;
   data.title = base::ASCIIToUTF16("My notification's title");
@@ -200,7 +201,8 @@
 TEST_F(PlatformNotificationServiceTest, DisplayPersistentPropertiesMatch) {
   std::vector<int> vibration_pattern(
       kNotificationVibrationPattern,
-      kNotificationVibrationPattern + arraysize(kNotificationVibrationPattern));
+      kNotificationVibrationPattern +
+          base::size(kNotificationVibrationPattern));
 
   PlatformNotificationData data;
   data.title = base::ASCIIToUTF16("My notification's title");
diff --git a/chrome/browser/password_manager/password_manager_util_mac.mm b/chrome/browser/password_manager/password_manager_util_mac.mm
index 9e0550b5..94ec937 100644
--- a/chrome/browser/password_manager/password_manager_util_mac.mm
+++ b/chrome/browser/password_manager/password_manager_util_mac.mm
@@ -11,7 +11,7 @@
 #include "base/mac/authorization_util.h"
 #include "base/mac/foundation_util.h"
 #include "base/mac/scoped_authorizationref.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/grit/chromium_strings.h"
 #include "ui/base/l10n/l10n_util.h"
 
@@ -26,7 +26,7 @@
   // kAuthorizationRuleAuthenticateAsSessionUser, to ensure that the session
   // user password, as opposed to an admin's password, is required.
   AuthorizationItem right_items[] = {{"system.login.screensaver", 0, NULL, 0}};
-  AuthorizationRights rights = {arraysize(right_items), right_items};
+  AuthorizationRights rights = {base::size(right_items), right_items};
 
   NSString* prompt;
   switch (purpose) {
diff --git a/chrome/browser/password_manager/password_manager_util_win.cc b/chrome/browser/password_manager/password_manager_util_win.cc
index d2792f5..32e3d12 100644
--- a/chrome/browser/password_manager/password_manager_util_win.cc
+++ b/chrome/browser/password_manager/password_manager_util_win.cc
@@ -25,6 +25,7 @@
 #include "base/bind_helpers.h"
 #include "base/feature_list.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
 #include "base/time/time.h"
@@ -150,7 +151,7 @@
   LUID luid;
   HANDLE token;
 
-  strcpy_s(source.SourceName, arraysize(source.SourceName), "Chrome");
+  strcpy_s(source.SourceName, base::size(source.SourceName), "Chrome");
   if (!AllocateLocallyUniqueId(&source.SourceIdentifier))
     return GetLastError();
 
@@ -456,7 +457,7 @@
                          password_manager::ReauthPurpose purpose) {
   bool retval = false;
   WCHAR cur_username[CREDUI_MAX_USERNAME_LENGTH + 1] = {};
-  DWORD cur_username_length = arraysize(cur_username);
+  DWORD cur_username_length = base::size(cur_username);
 
   // If this is a standlone workstation, it's possible the current user has no
   // password, so check here and allow it.
diff --git a/chrome/browser/platform_util_unittest.cc b/chrome/browser/platform_util_unittest.cc
index 528c97db..160e170b 100644
--- a/chrome/browser/platform_util_unittest.cc
+++ b/chrome/browser/platform_util_unittest.cc
@@ -10,8 +10,8 @@
 #include "base/callback.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/platform_util_internal.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -150,7 +150,7 @@
     ASSERT_NO_FATAL_FAILURE(PlatformUtilTestBase::SetUp());
 
     static const char kTestFileData[] = "Cow says moo!";
-    const int kTestFileDataLength = arraysize(kTestFileData) - 1;
+    const int kTestFileDataLength = base::size(kTestFileData) - 1;
 
     // This prevents platfrom_util from invoking any shell or external APIs
     // during tests. Doing so may result in external applications being launched
diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc
index 3a31d39..7315c64 100644
--- a/chrome/browser/platform_util_win.cc
+++ b/chrome/browser/platform_util_win.cc
@@ -17,7 +17,7 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
@@ -64,7 +64,8 @@
 
   const ITEMIDLIST* highlight[] = {file_item};
 
-  hr = SHOpenFolderAndSelectItems(dir_item, arraysize(highlight), highlight, 0);
+  hr =
+      SHOpenFolderAndSelectItems(dir_item, base::size(highlight), highlight, 0);
   if (FAILED(hr)) {
     // On some systems, the above call mysteriously fails with "file not
     // found" even though the file is there.  In these cases, ShellExecute()
diff --git a/chrome/browser/plugins/plugin_policy_handler.cc b/chrome/browser/plugins/plugin_policy_handler.cc
index e790784..bd3c955 100644
--- a/chrome/browser/plugins/plugin_policy_handler.cc
+++ b/chrome/browser/plugins/plugin_policy_handler.cc
@@ -6,6 +6,7 @@
 
 #include <string>
 
+#include "base/stl_util.h"
 #include "base/strings/pattern.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
@@ -76,7 +77,7 @@
       policy::key::kEnabledPlugins, policy::key::kDisabledPlugins,
       policy::key::kDisabledPluginsExceptions};
   bool ok = true;
-  for (size_t i = 0; i < arraysize(checked_policies); ++i) {
+  for (size_t i = 0; i < base::size(checked_policies); ++i) {
     const base::Value* value = policies.GetValue(checked_policies[i]);
     if (value && !value->is_list()) {
       errors->AddError(checked_policies[i], IDS_POLICY_TYPE_ERROR,
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index fff07a79..ea2d5dbc 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -11,8 +11,8 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "build/build_config.h"
 #include "chrome/browser/net/disk_cache_dir_policy_handler.h"
@@ -1003,7 +1003,7 @@
       new ConfigurationPolicyHandlerList(
           base::Bind(&PopulatePolicyHandlerParameters),
           base::Bind(&GetChromePolicyDetails)));
-  for (size_t i = 0; i < arraysize(kSimplePolicyMap); ++i) {
+  for (size_t i = 0; i < base::size(kSimplePolicyMap); ++i) {
     handlers->AddHandler(std::make_unique<SimplePolicyHandler>(
         kSimplePolicyMap[i].policy_name, kSimplePolicyMap[i].preference_path,
         kSimplePolicyMap[i].value_type));
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index c485d1da..d548139 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -23,7 +23,6 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
@@ -33,6 +32,7 @@
 #include "base/metrics/statistics_recorder.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/strcat.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
@@ -3290,7 +3290,7 @@
   FlushBlacklistPolicy();
   // All bbb.com URLs are blocked, and "aaa.com" is still unblocked.
   CheckCanOpenURL(browser(), kURLS[0]);
-  for (size_t i = 1; i < arraysize(kURLS); ++i)
+  for (size_t i = 1; i < base::size(kURLS); ++i)
     CheckURLIsBlocked(browser(), kURLS[i]);
 
   // Whitelist some sites of bbb.com.
@@ -3337,7 +3337,7 @@
   FlushBlacklistPolicy();
   // All bbb.com URLs are blocked, and "aaa.com" is still unblocked.
   CheckCanOpenURL(incognito_browser, kURLS[0]);
-  for (size_t i = 1; i < arraysize(kURLS); ++i)
+  for (size_t i = 1; i < base::size(kURLS); ++i)
     CheckURLIsBlocked(incognito_browser, kURLS[i]);
 
   // Whitelist some sites of bbb.com.
@@ -4026,13 +4026,13 @@
     base::PostTaskWithTraits(
         FROM_HERE, {BrowserThread::IO},
         base::BindOnce(RedirectHostsToTestData, kRestoredURLs,
-                       arraysize(kRestoredURLs)));
+                       base::size(kRestoredURLs)));
   }
 
   void ListOfURLs() {
     // Verifies that policy can set the startup pages to a list of URLs.
     base::ListValue urls;
-    for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
+    for (size_t i = 0; i < base::size(kRestoredURLs); ++i) {
       urls.AppendString(kRestoredURLs[i]);
       expected_urls_.push_back(GURL(kRestoredURLs[i]));
     }
@@ -4070,7 +4070,7 @@
         nullptr);
     provider_.UpdateChromePolicy(policies);
     // This should restore the tabs opened at PRE_RunTest below.
-    for (size_t i = 0; i < arraysize(kRestoredURLs); ++i)
+    for (size_t i = 0; i < base::size(kRestoredURLs); ++i)
       expected_urls_.push_back(GURL(kRestoredURLs[i]));
   }
 
@@ -4091,7 +4091,7 @@
     // This should restore the tabs opened at PRE_RunTest below, yet all should
     // be blocked.
     blocked_ = true;
-    for (size_t i = 0; i < arraysize(kRestoredURLs); ++i)
+    for (size_t i = 0; i < base::size(kRestoredURLs); ++i)
       expected_urls_.emplace_back(kRestoredURLs[i]);
   }
 
@@ -4117,7 +4117,7 @@
   // Most policy settings override this, except kPrefValueLast which enforces
   // a restore.
   ui_test_utils::NavigateToURL(browser(), GURL(kRestoredURLs[0]));
-  for (size_t i = 1; i < arraysize(kRestoredURLs); ++i) {
+  for (size_t i = 1; i < base::size(kRestoredURLs); ++i) {
     content::WindowedNotificationObserver observer(
         content::NOTIFICATION_LOAD_STOP,
         content::NotificationService::AllSources());
@@ -4476,7 +4476,7 @@
       nullptr,
   };
 
-  for (size_t i = 0; i < arraysize(allow_pattern); ++i) {
+  for (size_t i = 0; i < base::size(allow_pattern); ++i) {
     PolicyMap policies;
     ConfigurePolicyMap(&policies, key::kAudioCaptureAllowed,
                        key::kAudioCaptureAllowedUrls, allow_pattern[i]);
@@ -4534,7 +4534,7 @@
       nullptr,
   };
 
-  for (size_t i = 0; i < arraysize(allow_pattern); ++i) {
+  for (size_t i = 0; i < base::size(allow_pattern); ++i) {
     PolicyMap policies;
     ConfigurePolicyMap(&policies, key::kVideoCaptureAllowed,
                        key::kVideoCaptureAllowedUrls, allow_pattern[i]);
diff --git a/chrome/browser/policy/site_isolation_policy_browsertest.cc b/chrome/browser/policy/site_isolation_policy_browsertest.cc
index 05b1e00..1520abd 100644
--- a/chrome/browser/policy/site_isolation_policy_browsertest.cc
+++ b/chrome/browser/policy/site_isolation_policy_browsertest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/chrome_content_browser_client.h"
 #include "chrome/browser/profiles/profile.h"
@@ -160,7 +160,7 @@
       {"http://foo.com/", true},
       {"http://example.org/pumpkins.html", true},
   };
-  CheckExpectations(expectations, arraysize(expectations));
+  CheckExpectations(expectations, base::size(expectations));
 }
 
 IN_PROC_BROWSER_TEST_F(IsolateOriginsPolicyBrowserTest, Simple) {
@@ -174,7 +174,7 @@
       {"https://example.org/pumpkins.html", true},
       {"http://example.com/index.php", true},
   };
-  CheckExpectations(expectations, arraysize(expectations));
+  CheckExpectations(expectations, base::size(expectations));
 }
 
 IN_PROC_BROWSER_TEST_F(WebDriverSitePerProcessPolicyBrowserTest, Simple) {
@@ -182,7 +182,7 @@
       {"https://foo.com/noodles.html", true},
       {"http://example.org/pumpkins.html", true},
   };
-  CheckExpectations(expectations, arraysize(expectations));
+  CheckExpectations(expectations, base::size(expectations));
 }
 
 IN_PROC_BROWSER_TEST_F(NoOverrideSitePerProcessPolicyBrowserTest, Simple) {
@@ -190,7 +190,7 @@
       {"https://foo.com/noodles.html", true},
       {"http://example.org/pumpkins.html", true},
   };
-  CheckExpectations(expectations, arraysize(expectations));
+  CheckExpectations(expectations, base::size(expectations));
 }
 
 class SitePerProcessPolicyBrowserTestFieldTrialTest
@@ -225,7 +225,7 @@
       {"https://foo.com/noodles.html", false},
       {"http://example.org/pumpkins.html", false},
   };
-  CheckExpectations(expectations, arraysize(expectations));
+  CheckExpectations(expectations, base::size(expectations));
 }
 
 IN_PROC_BROWSER_TEST_F(SiteIsolationPolicyBrowserTest, NoPolicyNoTrialsFlags) {
diff --git a/chrome/browser/predictors/autocomplete_action_predictor.cc b/chrome/browser/predictors/autocomplete_action_predictor.cc
index 9493296..aa942f42b 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor.cc
@@ -10,7 +10,6 @@
 #include "base/bind.h"
 #include "base/guid.h"
 #include "base/i18n/case_conversion.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_util.h"
@@ -43,8 +42,8 @@
   0.5f
 };
 
-static_assert(arraysize(kConfidenceCutoff) ==
-              predictors::AutocompleteActionPredictor::LAST_PREDICT_ACTION,
+static_assert(base::size(kConfidenceCutoff) ==
+                  predictors::AutocompleteActionPredictor::LAST_PREDICT_ACTION,
               "kConfidenceCutoff count should match LAST_PREDICT_ACTION");
 
 const int kMinimumNumberOfHits = 3;
diff --git a/chrome/browser/prefs/chrome_command_line_pref_store.cc b/chrome/browser/prefs/chrome_command_line_pref_store.cc
index e3e8ce7..03f4fe3e 100644
--- a/chrome/browser/prefs/chrome_command_line_pref_store.cc
+++ b/chrome/browser/prefs/chrome_command_line_pref_store.cc
@@ -13,6 +13,7 @@
 #include "ash/public/cpp/ash_switches.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/values.h"
@@ -125,10 +126,10 @@
 
 void ChromeCommandLinePrefStore::ApplySimpleSwitches() {
   // Look for each switch we know about and set its preference accordingly.
-  ApplyStringSwitches(string_switch_map_, arraysize(string_switch_map_));
-  ApplyPathSwitches(path_switch_map_, arraysize(path_switch_map_));
-  ApplyIntegerSwitches(integer_switch_map_, arraysize(integer_switch_map_));
-  ApplyBooleanSwitches(boolean_switch_map_, arraysize(boolean_switch_map_));
+  ApplyStringSwitches(string_switch_map_, base::size(string_switch_map_));
+  ApplyPathSwitches(path_switch_map_, base::size(path_switch_map_));
+  ApplyIntegerSwitches(integer_switch_map_, base::size(integer_switch_map_));
+  ApplyBooleanSwitches(boolean_switch_map_, base::size(boolean_switch_map_));
 }
 
 void ChromeCommandLinePrefStore::ApplyProxyMode() {
diff --git a/chrome/browser/prefs/chrome_command_line_pref_store_proxy_unittest.cc b/chrome/browser/prefs/chrome_command_line_pref_store_proxy_unittest.cc
index 9535fcb..be9df49 100644
--- a/chrome/browser/prefs/chrome_command_line_pref_store_proxy_unittest.cc
+++ b/chrome/browser/prefs/chrome_command_line_pref_store_proxy_unittest.cc
@@ -8,8 +8,8 @@
 #include <stddef.h>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "chrome/common/chrome_switches.h"
 #include "components/prefs/pref_registry_simple.h"
 #include "components/prefs/pref_service.h"
@@ -162,7 +162,7 @@
   net::ProxyConfigWithAnnotation* proxy_config() { return &proxy_config_; }
 
   void SetUp() override {
-    for (size_t i = 0; i < arraysize(GetParam().switches); i++) {
+    for (size_t i = 0; i < base::size(GetParam().switches); i++) {
       const char* name = GetParam().switches[i].name;
       const char* value = GetParam().switches[i].value;
       if (name && value)
diff --git a/chrome/browser/prefs/chrome_command_line_pref_store_unittest.cc b/chrome/browser/prefs/chrome_command_line_pref_store_unittest.cc
index e9e922a..8753173 100644
--- a/chrome/browser/prefs/chrome_command_line_pref_store_unittest.cc
+++ b/chrome/browser/prefs/chrome_command_line_pref_store_unittest.cc
@@ -6,8 +6,8 @@
 #include <stddef.h>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
 #include "chrome/browser/prefs/chrome_command_line_pref_store.h"
@@ -194,7 +194,7 @@
     "0x0005",
   };
   store1->VerifySSLCipherSuites(expected_ciphers1,
-                                arraysize(expected_ciphers1));
+                                base::size(expected_ciphers1));
 
   base::CommandLine cl2(base::CommandLine::NO_PROGRAM);
   cl2.AppendSwitchASCII(switches::kCipherSuiteBlacklist,
@@ -207,7 +207,7 @@
     "0x0005",
   };
   store2->VerifySSLCipherSuites(expected_ciphers2,
-                                arraysize(expected_ciphers2));
+                                base::size(expected_ciphers2));
 
   base::CommandLine cl3(base::CommandLine::NO_PROGRAM);
   cl3.AppendSwitchASCII(switches::kCipherSuiteBlacklist,
@@ -218,5 +218,5 @@
     "0x0004;MOAR;0x0005"
   };
   store3->VerifySSLCipherSuites(expected_ciphers3,
-                                arraysize(expected_ciphers3));
+                                base::size(expected_ciphers3));
 }
diff --git a/chrome/browser/prefs/chrome_pref_service_factory.cc b/chrome/browser/prefs/chrome_pref_service_factory.cc
index e99bb397..724c86e 100644
--- a/chrome/browser/prefs/chrome_pref_service_factory.cc
+++ b/chrome/browser/prefs/chrome_pref_service_factory.cc
@@ -13,9 +13,9 @@
 #include "base/bind.h"
 #include "base/compiler_specific.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
@@ -194,7 +194,7 @@
 
 // One more than the last tracked preferences ID above.
 const size_t kTrackedPrefsReportingIDsCount =
-    kTrackedPrefs[arraysize(kTrackedPrefs) - 1].reporting_id + 1;
+    kTrackedPrefs[base::size(kTrackedPrefs) - 1].reporting_id + 1;
 
 // Each group enforces a superset of the protection provided by the previous
 // one.
@@ -258,7 +258,7 @@
           chrome_prefs::internals::kSettingsEnforcementTrialName);
   if (trial) {
     const std::string& group_name = trial->group_name();
-    for (size_t i = 0; i < arraysize(kEnforcementLevelMap); ++i) {
+    for (size_t i = 0; i < base::size(kEnforcementLevelMap); ++i) {
       if (kEnforcementLevelMap[i].group_name == group_name) {
         enforcement_group = kEnforcementLevelMap[i].group;
         group_determined_from_trial = true;
@@ -278,7 +278,7 @@
       GetSettingsEnforcementGroup();
 
   std::vector<prefs::mojom::TrackedPreferenceMetadataPtr> result;
-  for (size_t i = 0; i < arraysize(kTrackedPrefs); ++i) {
+  for (size_t i = 0; i < base::size(kTrackedPrefs); ++i) {
     prefs::mojom::TrackedPreferenceMetadataPtr data =
         prefs::ConstructTrackedMetadata(kTrackedPrefs[i]);
 
diff --git a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc
index c4d925f..6ce431ef7 100644
--- a/chrome/browser/prefs/profile_pref_store_manager_unittest.cc
+++ b/chrome/browser/prefs/profile_pref_store_manager_unittest.cc
@@ -15,10 +15,10 @@
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/test/scoped_feature_list.h"
 #include "base/values.h"
@@ -153,7 +153,7 @@
 
     ProfilePrefStoreManager::RegisterProfilePrefs(profile_pref_registry_.get());
     for (const prefs::TrackedPreferenceMetadata* it = kConfiguration;
-         it != kConfiguration + arraysize(kConfiguration); ++it) {
+         it != kConfiguration + base::size(kConfiguration); ++it) {
       if (it->strategy == PrefTrackingStrategy::ATOMIC) {
         profile_pref_registry_->RegisterStringPref(it->name, std::string());
       } else {
diff --git a/chrome/browser/prerender/prerender_final_status.cc b/chrome/browser/prerender/prerender_final_status.cc
index e337441c..b708eedf 100644
--- a/chrome/browser/prerender/prerender_final_status.cc
+++ b/chrome/browser/prerender/prerender_final_status.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/prerender/prerender_final_status.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/browser/prerender/prerender_manager.h"
 
 namespace prerender {
@@ -73,14 +73,14 @@
     "BrowserSwitcher Switch",
     "Max",
 };
-static_assert(arraysize(kFinalStatusNames) == FINAL_STATUS_MAX + 1,
+static_assert(base::size(kFinalStatusNames) == FINAL_STATUS_MAX + 1,
               "status name count mismatch");
 
 }  // namespace
 
 const char* NameFromFinalStatus(FinalStatus final_status) {
   DCHECK_LT(static_cast<unsigned int>(final_status),
-            arraysize(kFinalStatusNames));
+            base::size(kFinalStatusNames));
   return kFinalStatusNames[final_status];
 }
 
diff --git a/chrome/browser/prerender/prerender_origin.cc b/chrome/browser/prerender/prerender_origin.cc
index 86975af..3f61c44 100644
--- a/chrome/browser/prerender/prerender_origin.cc
+++ b/chrome/browser/prerender/prerender_origin.cc
@@ -4,8 +4,8 @@
 
 #include "chrome/browser/prerender/prerender_origin.h"
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "chrome/browser/prerender/prerender_manager.h"
 
 namespace prerender {
@@ -30,7 +30,7 @@
     "[Deprecated] Offline",
     "Max",
 };
-static_assert(arraysize(kOriginNames) == ORIGIN_MAX + 1,
+static_assert(base::size(kOriginNames) == ORIGIN_MAX + 1,
               "prerender origin name count mismatch");
 
 }  // namespace
diff --git a/chrome/browser/printing/cloud_print/privet_traffic_detector.cc b/chrome/browser/printing/cloud_print/privet_traffic_detector.cc
index 06b9a5e..ce8de85 100644
--- a/chrome/browser/printing/cloud_print/privet_traffic_detector.cc
+++ b/chrome/browser/printing/cloud_print/privet_traffic_detector.cc
@@ -7,6 +7,7 @@
 #include <utility>
 
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/sys_byteorder.h"
 #include "base/task/post_task.h"
 #include "base/threading/scoped_blocking_call.h"
@@ -221,8 +222,8 @@
 
   static const char kPrivetDeviceTypeDnsString[] = "\x07_privet";
   const char* substring_begin = kPrivetDeviceTypeDnsString;
-  const char* substring_end = substring_begin +
-                              arraysize(kPrivetDeviceTypeDnsString) - 1;
+  const char* substring_end =
+      substring_begin + base::size(kPrivetDeviceTypeDnsString) - 1;
   // Check for expected substring, any Privet device must include this.
   return std::search(buffer_begin, buffer_end, substring_begin,
                      substring_end) != buffer_end;
diff --git a/chrome/browser/printing/printing_layout_browsertest.cc b/chrome/browser/printing/printing_layout_browsertest.cc
index 1177a94d..d218821 100644
--- a/chrome/browser/printing/printing_layout_browsertest.cc
+++ b/chrome/browser/printing/printing_layout_browsertest.cc
@@ -7,12 +7,12 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/path_service.h"
 #include "base/process/process_handle.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/test_file_util.h"
@@ -379,11 +379,11 @@
 
   DismissTheWindow dismisser;
 
-  ASSERT_GT(arraysize(kTestPool), 0u);
-  for (int i = 0; i < arraysize(kTestPool); ++i) {
+  ASSERT_GT(base::size(kTestPool), 0u);
+  for (int i = 0; i < base::size(kTestPool); ++i) {
     if (i)
       CleanupDumpDirectory();
-    const TestPool& test = kTestPool[i % arraysize(kTestPool)];
+    const TestPool& test = kTestPool[i % base::size(kTestPool)];
     ui_test_utils::NavigateToURL(browser(),
                                  embedded_test_server()->GetURL(test.source));
     base::DelegateSimpleThread close_printdlg_thread1(&dismisser,
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
index 3b6c0b6..5ae6482 100644
--- a/chrome/browser/process_singleton_posix.cc
+++ b/chrome/browser/process_singleton_posix.cc
@@ -63,7 +63,6 @@
 #include "base/files/file_util.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
@@ -73,6 +72,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"
@@ -116,7 +116,7 @@
 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 = '-';
 
@@ -223,9 +223,9 @@
 // Set up a sockaddr appropriate for messaging.
 bool SetupSockAddr(const std::string& path, struct sockaddr_un* addr) {
   addr->sun_family = AF_UNIX;
-  if (path.length() >= arraysize(addr->sun_path))
+  if (path.length() >= base::size(addr->sun_path))
     return false;
-  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));
   return true;
 }
 
@@ -633,13 +633,13 @@
   if (parent_->notification_callback_.Run(base::CommandLine(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;
   }
 }
@@ -683,7 +683,7 @@
   }
 
   // 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_;
@@ -899,11 +899,11 @@
   }
 
   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.
     SendRemoteProcessInteractionResultHistogram(REMOTE_PROCESS_SHUTTING_DOWN);
     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();
diff --git a/chrome/browser/process_singleton_win_unittest.cc b/chrome/browser/process_singleton_win_unittest.cc
index c3cabe2a..aee9a58b 100644
--- a/chrome/browser/process_singleton_win_unittest.cc
+++ b/chrome/browser/process_singleton_win_unittest.cc
@@ -14,10 +14,10 @@
 #include "base/files/file_path.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/process/launch.h"
 #include "base/process/process.h"
 #include "base/process/process_handle.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/metrics/histogram_tester.h"
@@ -200,7 +200,7 @@
     // The wait should always return because either |ready_event| is signaled or
     // |browser_victim_| died unexpectedly or exited on error.
     DWORD result =
-        ::WaitForMultipleObjects(arraysize(handles), handles, FALSE, INFINITE);
+        ::WaitForMultipleObjects(base::size(handles), handles, FALSE, INFINITE);
     ASSERT_EQ(WAIT_OBJECT_0, result);
   }
 
diff --git a/chrome/browser/profile_resetter/brandcode_config_fetcher.cc b/chrome/browser/profile_resetter/brandcode_config_fetcher.cc
index ee3cc61..cacb746 100644
--- a/chrome/browser/profile_resetter/brandcode_config_fetcher.cc
+++ b/chrome/browser/profile_resetter/brandcode_config_fetcher.cc
@@ -8,7 +8,7 @@
 #include <vector>
 
 #include "base/callback_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
@@ -134,7 +134,7 @@
 
 bool XmlConfigParser::IsParsingData() const {
   const std::string data_path[] = {"response", "app", "data"};
-  return elements_.size() == arraysize(data_path) &&
+  return elements_.size() == base::size(data_path) &&
          std::equal(elements_.begin(), elements_.end(), data_path);
 }
 
diff --git a/chrome/browser/profile_resetter/profile_resetter.cc b/chrome/browser/profile_resetter/profile_resetter.cc
index aabaebf..79f0484 100644
--- a/chrome/browser/profile_resetter/profile_resetter.cc
+++ b/chrome/browser/profile_resetter/profile_resetter.cc
@@ -9,7 +9,7 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/synchronization/cancellation_flag.h"
 #include "base/task/post_task.h"
 #include "base/task/task_traits.h"
@@ -129,7 +129,7 @@
   };
 
   ResettableFlags reset_triggered_for_flags = 0;
-  for (size_t i = 0; i < arraysize(flagToMethod); ++i) {
+  for (size_t i = 0; i < base::size(flagToMethod); ++i) {
     if (resettable_flags & flagToMethod[i].flag) {
       reset_triggered_for_flags |= flagToMethod[i].flag;
       (this->*flagToMethod[i].method)();
diff --git a/chrome/browser/profile_resetter/profile_resetter_unittest.cc b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
index 8cc7319a..a76350ec 100644
--- a/chrome/browser/profile_resetter/profile_resetter_unittest.cc
+++ b/chrome/browser/profile_resetter/profile_resetter_unittest.cc
@@ -12,9 +12,9 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/scoped_refptr.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/bind_test_util.h"
 #include "base/test/scoped_path_override.h"
@@ -659,7 +659,8 @@
   startup_pref = SessionStartupPref::GetStartupPref(prefs);
   EXPECT_EQ(SessionStartupPref::URLS, startup_pref.type);
   const GURL urls[] = {GURL("http://goo.gl"), GURL("http://foo.de")};
-  EXPECT_EQ(std::vector<GURL>(urls, urls + arraysize(urls)), startup_pref.urls);
+  EXPECT_EQ(std::vector<GURL>(urls, urls + base::size(urls)),
+            startup_pref.urls);
 }
 
 
@@ -669,14 +670,15 @@
 
   const GURL urls[] = {GURL("http://foo"), GURL("http://bar")};
   SessionStartupPref startup_pref(SessionStartupPref::URLS);
-  startup_pref.urls.assign(urls, urls + arraysize(urls));
+  startup_pref.urls.assign(urls, urls + base::size(urls));
   SessionStartupPref::SetStartupPref(prefs, startup_pref);
 
   ResetAndWait(ProfileResetter::STARTUP_PAGES, std::string());
 
   startup_pref = SessionStartupPref::GetStartupPref(prefs);
   EXPECT_EQ(SessionStartupPref::GetDefaultStartupType(), startup_pref.type);
-  EXPECT_EQ(std::vector<GURL>(urls, urls + arraysize(urls)), startup_pref.urls);
+  EXPECT_EQ(std::vector<GURL>(urls, urls + base::size(urls)),
+            startup_pref.urls);
 }
 
 TEST_F(PinnedTabsResetTest, ResetPinnedTabs) {
@@ -854,7 +856,7 @@
   EXPECT_EQ(diff_fields, nonorganic_snap.FindDifferentFields(organic_snap));
   nonorganic_snap.Subtract(organic_snap);
   const GURL urls[] = {GURL("http://foo.de"), GURL("http://goo.gl")};
-  EXPECT_EQ(std::vector<GURL>(urls, urls + arraysize(urls)),
+  EXPECT_EQ(std::vector<GURL>(urls, urls + base::size(urls)),
             nonorganic_snap.startup_urls());
   EXPECT_EQ(SessionStartupPref::URLS, nonorganic_snap.startup_type());
   EXPECT_EQ("http://www.foo.com", nonorganic_snap.homepage());
diff --git a/chrome/browser/profiles/profile_attributes_storage.cc b/chrome/browser/profiles/profile_attributes_storage.cc
index 707558e..d22716cb 100644
--- a/chrome/browser/profiles/profile_attributes_storage.cc
+++ b/chrome/browser/profiles/profile_attributes_storage.cc
@@ -12,6 +12,7 @@
 #include "base/i18n/number_formatting.h"
 #include "base/i18n/string_compare.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
@@ -248,7 +249,7 @@
     return true;
 
   // Check if it's one of the old-style profile names.
-  for (size_t i = 0; i < arraysize(kDefaultNames); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultNames); ++i) {
     if (name == l10n_util::GetStringUTF16(kDefaultNames[i]))
       return true;
   }
diff --git a/chrome/browser/profiles/profile_info_cache_unittest.cc b/chrome/browser/profiles/profile_info_cache_unittest.cc
index b71b0626..0298ebe9 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -12,7 +12,7 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
@@ -528,7 +528,7 @@
     { "path_test3", "name_3" },
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     base::FilePath profile_path = GetProfilePath(kTestCases[i].profile_path);
     base::string16 profile_name = ASCIIToUTF16(kTestCases[i].profile_name);
 
@@ -578,7 +578,7 @@
   // ProfileAttributesStorage is checked after each insert and delete operation.
 
   // Add profiles.
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     base::FilePath profile_path = GetProfilePath(kTestCases[i].profile_path);
     base::string16 profile_name = ASCIIToUTF16(kTestCases[i].profile_name);
 
@@ -613,7 +613,7 @@
   }
 
   // Remove profiles.
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     base::FilePath profile_path = GetProfilePath(kTestCases[i].profile_path);
     ASSERT_EQ(1u, GetCache()->profile_attributes_entries_.count(
                       profile_path.value()));
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 7727fda..fe7fe69 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -17,7 +17,6 @@
 #include "base/debug/alias.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
@@ -655,7 +654,7 @@
     url::kFileSystemScheme,
     chrome::kChromeSearchScheme,
   };
-  for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
+  for (size_t i = 0; i < base::size(kProtocolList); ++i) {
     if (scheme == kProtocolList[i])
       return true;
   }
diff --git a/chrome/browser/profiles/profile_shortcut_manager_win.cc b/chrome/browser/profiles/profile_shortcut_manager_win.cc
index 80334a76..152a6f8 100644
--- a/chrome/browser/profiles/profile_shortcut_manager_win.cc
+++ b/chrome/browser/profiles/profile_shortcut_manager_win.cc
@@ -16,8 +16,8 @@
 #include "base/command_line.h"
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -801,7 +801,7 @@
 
 ProfileShortcutManagerWin::ProfileShortcutManagerWin(ProfileManager* manager)
     : profile_manager_(manager) {
-  DCHECK_EQ(arraysize(kProfileAvatarIconResources2x),
+  DCHECK_EQ(base::size(kProfileAvatarIconResources2x),
             profiles::GetDefaultAvatarIconCount());
 
   registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc
index 660b312..28d85cd9 100644
--- a/chrome/browser/push_messaging/push_messaging_browsertest.cc
+++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc
@@ -12,7 +12,6 @@
 #include "base/barrier_closure.h"
 #include "base/bind.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/metrics/histogram_tester.h"
@@ -90,7 +89,7 @@
 
 std::string GetTestApplicationServerKey() {
   return std::string(kApplicationServerKey,
-                     kApplicationServerKey + arraysize(kApplicationServerKey));
+                     kApplicationServerKey + base::size(kApplicationServerKey));
 }
 
 void LegacyRegisterCallback(const base::Closure& done_callback,
diff --git a/chrome/browser/push_messaging/push_messaging_service_unittest.cc b/chrome/browser/push_messaging/push_messaging_service_unittest.cc
index cd79a4d..7b1f142 100644
--- a/chrome/browser/push_messaging/push_messaging_service_unittest.cc
+++ b/chrome/browser/push_messaging/push_messaging_service_unittest.cc
@@ -11,8 +11,8 @@
 
 #include "base/bind.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
 #include "chrome/browser/gcm/gcm_profile_service_factory.h"
@@ -242,7 +242,7 @@
   PushMessagingServiceImpl* push_service = profile()->GetPushMessagingService();
   ASSERT_TRUE(push_service);
 
-  std::string p256dh(kTestP256Key, kTestP256Key + arraysize(kTestP256Key));
+  std::string p256dh(kTestP256Key, kTestP256Key + base::size(kTestP256Key));
   ASSERT_EQ(65u, p256dh.size());
 
   // NIST P-256 public keys in uncompressed format will be encoded using the
diff --git a/chrome/browser/renderer_context_menu/render_view_context_menu.cc b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
index 5b4d4a9..886c5d0 100644
--- a/chrome/browser/renderer_context_menu/render_view_context_menu.cc
+++ b/chrome/browser/renderer_context_menu/render_view_context_menu.cc
@@ -13,7 +13,6 @@
 #include "base/command_line.h"
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/user_metrics.h"
@@ -396,7 +395,7 @@
     return 1;
 
   id = CollapseCommandsForUMA(id);
-  const size_t kMappingSize = arraysize(kUmaEnumToControlId);
+  const size_t kMappingSize = base::size(kUmaEnumToControlId);
   for (size_t i = 0; i < kMappingSize; ++i) {
     if (kUmaEnumToControlId[i].control_id == id) {
       if (enum_lookup_type == GENERAL_ENUM_ID)
@@ -893,7 +892,7 @@
     return;
   }
 
-  const size_t kMappingSize = arraysize(kUmaEnumToControlId);
+  const size_t kMappingSize = base::size(kUmaEnumToControlId);
   UMA_HISTOGRAM_EXACT_LINEAR("RenderViewContextMenu.Used", enum_id,
                              kUmaEnumToControlId[kMappingSize - 1].enum_id);
   // Record to additional context specific histograms.
@@ -925,7 +924,7 @@
 void RenderViewContextMenu::RecordShownItem(int id) {
   int enum_id = FindUMAEnumValueForCommand(id, GENERAL_ENUM_ID);
   if (enum_id != -1) {
-    const size_t kMappingSize = arraysize(kUmaEnumToControlId);
+    const size_t kMappingSize = base::size(kUmaEnumToControlId);
     UMA_HISTOGRAM_EXACT_LINEAR("RenderViewContextMenu.Shown", enum_id,
                                kUmaEnumToControlId[kMappingSize - 1].enum_id);
   } else {
diff --git a/chrome/browser/renderer_host/chrome_extension_message_filter.cc b/chrome/browser/renderer_host/chrome_extension_message_filter.cc
index d96ca959..f8473b4 100644
--- a/chrome/browser/renderer_host/chrome_extension_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_extension_message_filter.cc
@@ -10,8 +10,8 @@
 #include "base/bind_helpers.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/browser_process.h"
@@ -60,7 +60,7 @@
     int render_process_id,
     Profile* profile)
     : BrowserMessageFilter(kExtensionFilteredMessageClasses,
-                           arraysize(kExtensionFilteredMessageClasses)),
+                           base::size(kExtensionFilteredMessageClasses)),
       render_process_id_(render_process_id),
       profile_(profile),
       activity_log_(extensions::ActivityLog::GetInstance(profile)),
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index f6a4553..4df8a9e9 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -11,7 +11,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/chrome_notification_types.h"
@@ -53,7 +53,7 @@
 ChromeRenderMessageFilter::ChromeRenderMessageFilter(int render_process_id,
                                                      Profile* profile)
     : BrowserMessageFilter(kRenderFilteredMessageClasses,
-                           arraysize(kRenderFilteredMessageClasses)),
+                           base::size(kRenderFilteredMessageClasses)),
       render_process_id_(render_process_id),
       preconnect_manager_initialized_(false),
       cookie_settings_(CookieSettingsFactory::GetForProfile(profile)) {
diff --git a/chrome/browser/renderer_host/pepper/device_id_fetcher.cc b/chrome/browser/renderer_host/pepper/device_id_fetcher.cc
index 797369c..c1d0053a 100644
--- a/chrome/browser/renderer_host/pepper/device_id_fetcher.cc
+++ b/chrome/browser/renderer_host/pepper/device_id_fetcher.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
 
 #include "base/files/file_util.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/task/post_task.h"
 #include "build/build_config.h"
@@ -115,9 +115,9 @@
   std::string salt = profile->GetPrefs()->GetString(prefs::kDRMSalt);
   if (salt.empty()) {
     uint8_t salt_bytes[kSaltLength];
-    crypto::RandBytes(salt_bytes, arraysize(salt_bytes));
+    crypto::RandBytes(salt_bytes, base::size(salt_bytes));
     // Since it will be stored in a string pref, convert it to hex.
-    salt = base::HexEncode(salt_bytes, arraysize(salt_bytes));
+    salt = base::HexEncode(salt_bytes, base::size(salt_bytes));
     profile->GetPrefs()->SetString(prefs::kDRMSalt, salt);
   }
 
diff --git a/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc b/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
index d266f412..5e468b2 100644
--- a/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
+++ b/chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/profiles/profile.h"
@@ -69,7 +69,7 @@
       profile_directory_(profile_directory),
       document_url_(document_url),
       ppapi_host_(ppapi_host) {
-  for (size_t i = 0; i < arraysize(kPredefinedAllowedCrxFsOrigins); ++i)
+  for (size_t i = 0; i < base::size(kPredefinedAllowedCrxFsOrigins); ++i)
     allowed_crxfs_origins_.insert(kPredefinedAllowedCrxFsOrigins[i]);
 }
 
diff --git a/chrome/browser/resource_coordinator/tab_manager.cc b/chrome/browser/resource_coordinator/tab_manager.cc
index 7cf3e07..c840b4b09 100644
--- a/chrome/browser/resource_coordinator/tab_manager.cc
+++ b/chrome/browser/resource_coordinator/tab_manager.cc
@@ -17,6 +17,7 @@
 #include "base/metrics/histogram_macros.h"
 #include "base/process/process.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -405,7 +406,7 @@
       chrome::kChromeUINewTabURL, chrome::kChromeUISettingsURL};
   // Prefix-match against the table above. Use strncmp to avoid allocating
   // memory to convert the URL prefix constants into std::strings.
-  for (size_t i = 0; i < arraysize(kInternalPagePrefixes); ++i) {
+  for (size_t i = 0; i < base::size(kInternalPagePrefixes); ++i) {
     if (!strncmp(url.spec().c_str(), kInternalPagePrefixes[i],
                  strlen(kInternalPagePrefixes[i])))
       return true;
diff --git a/chrome/browser/resources_util_unittest.cc b/chrome/browser/resources_util_unittest.cc
index e1ce86b9..2693879a 100644
--- a/chrome/browser/resources_util_unittest.cc
+++ b/chrome/browser/resources_util_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "components/grit/components_scaled_resources.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -34,6 +34,6 @@
     {"backstar", -1},
   };
 
-  for (size_t i = 0; i < arraysize(kCases); ++i)
+  for (size_t i = 0; i < base::size(kCases); ++i)
     EXPECT_EQ(kCases[i].id, ResourcesUtil::GetThemeResourceId(kCases[i].name));
 }
diff --git a/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc b/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
index e54d4a3e..6c8b632 100644
--- a/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
@@ -12,8 +12,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident.h"
 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
 #include "chrome/common/chrome_version.h"
@@ -38,16 +38,16 @@
     NOTREACHED();
 
   std::vector<base::FilePath> critical_binaries;
-  critical_binaries.reserve(arraysize(kUnversionedFiles) +
-                            arraysize(kVersionedFiles));
+  critical_binaries.reserve(base::size(kUnversionedFiles) +
+                            base::size(kVersionedFiles));
 
-  for (size_t i = 0; i < arraysize(kUnversionedFiles); ++i) {
+  for (size_t i = 0; i < base::size(kUnversionedFiles); ++i) {
     critical_binaries.push_back(chrome_exe_dir.Append(kUnversionedFiles[i]));
   }
 
   base::FilePath version_dir(
       chrome_exe_dir.AppendASCII(CHROME_VERSION_STRING));
-  for (size_t i = 0; i < arraysize(kVersionedFiles); ++i) {
+  for (size_t i = 0; i < base::size(kVersionedFiles); ++i) {
     critical_binaries.push_back(version_dir.Append(kVersionedFiles[i]));
   }
 
diff --git a/chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident_unittest.cc
index 95c3cac..6cd05754 100644
--- a/chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident_unittest.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/safe_browsing/proto/csd.pb.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -33,10 +33,10 @@
       {42, 255, 100, 53, 2},
       {64, 33, 51, 91, 210},
   };
-  for (size_t i = 0; i < arraysize(certificates); ++i) {
+  for (size_t i = 0; i < base::size(certificates); ++i) {
     ClientDownloadRequest_CertificateChain_Element* element =
         certificate_chain->add_element();
-    element->set_certificate(certificates[i], arraysize(certificates[i]));
+    element->set_certificate(certificates[i], base::size(certificates[i]));
   }
 
   return std::make_unique<BinaryIntegrityIncident>(std::move(incident));
diff --git a/chrome/browser/safe_browsing/incident_reporting/environment_data_collection_win.cc b/chrome/browser/safe_browsing/incident_reporting/environment_data_collection_win.cc
index e4a21ab..7120b9f 100644
--- a/chrome/browser/safe_browsing/incident_reporting/environment_data_collection_win.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/environment_data_collection_win.cc
@@ -11,9 +11,9 @@
 #include <string>
 
 #include "base/i18n/case_conversion.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -299,12 +299,12 @@
     ClientIncidentReport_EnvironmentData_Process* process) {
   CollectDlls(process);
   RecordLspFeature(process);
-  CollectModuleVerificationData(
-      kModulesToVerify, arraysize(kModulesToVerify), process);
+  CollectModuleVerificationData(kModulesToVerify, base::size(kModulesToVerify),
+                                process);
 }
 
 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) {
-  CollectRegistryData(kRegKeysToCollect, arraysize(kRegKeysToCollect),
+  CollectRegistryData(kRegKeysToCollect, base::size(kRegKeysToCollect),
                       os_data->mutable_registry_key());
   CollectDomainEnrollmentData(os_data);
 }
diff --git a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc
index 33c3fd13..6b7b57ef 100644
--- a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc
@@ -12,11 +12,11 @@
 #include <utility>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/process/process.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/task/post_task.h"
 #include "base/task/task_traits.h"
@@ -99,7 +99,7 @@
       "SBIRS.DiscardedIncident",
       "SBIRS.NoDownloadIncident",
   };
-  static_assert(arraysize(kHistogramNames) == NUM_DISPOSITIONS,
+  static_assert(base::size(kHistogramNames) == NUM_DISPOSITIONS,
                 "Keep kHistogramNames in sync with enum IncidentDisposition.");
   DCHECK_GE(disposition, 0);
   DCHECK_LT(disposition, NUM_DISPOSITIONS);
diff --git a/chrome/browser/safe_browsing/incident_reporting/module_integrity_unittest_util_win.cc b/chrome/browser/safe_browsing/incident_reporting/module_integrity_unittest_util_win.cc
index a616608..791dc3d5 100644
--- a/chrome/browser/safe_browsing/incident_reporting/module_integrity_unittest_util_win.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/module_integrity_unittest_util_win.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_unittest_util_win.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace safe_browsing {
 
@@ -13,7 +13,7 @@
     L"verifier_test_dll_2.dll",
 };
 
-const size_t kTestDllNamesCount = arraysize(kTestDllNames);
+const size_t kTestDllNamesCount = base::size(kTestDllNames);
 
 const char kTestExportName[] = "DummyExport";
 
diff --git a/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win.cc b/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win.cc
index 38949a2..5b4e11c 100644
--- a/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win.cc
@@ -12,9 +12,9 @@
 
 #include "base/files/file_path.h"
 #include "base/files/memory_mapped_file.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/scoped_native_library.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/pe_image.h"
 #include "components/safe_browsing/proto/csd.pb.h"
@@ -320,8 +320,8 @@
 
   WCHAR module_path[MAX_PATH] = {};
   DWORD length =
-      GetModuleFileName(module_handle, module_path, arraysize(module_path));
-  if (!length || length == arraysize(module_path))
+      GetModuleFileName(module_handle, module_path, base::size(module_path));
+  if (!length || length == base::size(module_path))
     return false;
 
   base::MemoryMappedFile mapped_module;
diff --git a/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win_unittest.cc
index 166e12c..3b50a52 100644
--- a/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win_unittest.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/module_integrity_verifier_win_unittest.cc
@@ -15,9 +15,9 @@
 
 #include "base/files/file_path.h"
 #include "base/files/memory_mapped_file.h"
-#include "base/macros.h"
 #include "base/native_library.h"
 #include "base/scoped_native_library.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/pe_image.h"
 #include "build/build_config.h"
@@ -111,8 +111,8 @@
 
     WCHAR module_path[MAX_PATH] = {};
     DWORD length =
-        GetModuleFileName(module_handle, module_path, arraysize(module_path));
-    ASSERT_NE(arraysize(module_path), length);
+        GetModuleFileName(module_handle, module_path, base::size(module_path));
+    ASSERT_NE(base::size(module_path), length);
     ASSERT_TRUE(disk_dll_handle_.Initialize(base::FilePath(module_path)));
   }
 
diff --git a/chrome/browser/search/local_ntp_source.cc b/chrome/browser/search/local_ntp_source.cc
index 4e4b039..d19a1b4 100644
--- a/chrome/browser/search/local_ntp_source.cc
+++ b/chrome/browser/search/local_ntp_source.cc
@@ -15,6 +15,7 @@
 #include "base/metrics/field_trial_params.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -496,7 +497,7 @@
   if (url.SchemeIs(chrome::kChromeSearchScheme)) {
     std::string filename;
     webui::ParsePathAndScale(url, &filename, nullptr);
-    for (size_t i = 0; i < arraysize(kResources); ++i) {
+    for (size_t i = 0; i < base::size(kResources); ++i) {
       if (filename == kResources[i].filename)
         return true;
     }
@@ -981,7 +982,7 @@
       GURL(GetLocalNtpPath() + stripped_path), &filename, &scale);
   ui::ScaleFactor scale_factor = ui::GetSupportedScaleFactor(scale);
 
-  for (size_t i = 0; i < arraysize(kResources); ++i) {
+  for (size_t i = 0; i < base::size(kResources); ++i) {
     if (filename == kResources[i].filename) {
       scoped_refptr<base::RefCountedMemory> response(
           ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale(
@@ -996,7 +997,7 @@
 std::string LocalNtpSource::GetMimeType(
     const std::string& path) const {
   const std::string stripped_path = StripParameters(path);
-  for (size_t i = 0; i < arraysize(kResources); ++i) {
+  for (size_t i = 0; i < base::size(kResources); ++i) {
     if (stripped_path == kResources[i].filename)
       return kResources[i].mime_type;
   }
diff --git a/chrome/browser/search/search_unittest.cc b/chrome/browser/search/search_unittest.cc
index eb6be50..0574177 100644
--- a/chrome/browser/search/search_unittest.cc
+++ b/chrome/browser/search/search_unittest.cc
@@ -11,7 +11,7 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "chrome/browser/search/instant_service.h"
@@ -116,7 +116,7 @@
       {"https://foo.com/", false, "Instant support was removed"},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const SearchTestCase& test = kTestCases[i];
     EXPECT_EQ(test.expected_result,
               ShouldAssignURLToInstantRenderer(GURL(test.url), profile()))
@@ -141,7 +141,7 @@
       {"https://foo.com/", false, "Non-exact path"},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const SearchTestCase& test = kTestCases[i];
     EXPECT_EQ(test.expected_result,
               ShouldUseProcessPerSiteForInstantURL(GURL(test.url), profile()))
@@ -178,7 +178,7 @@
 };
 
 TEST_F(SearchTest, ProcessIsolation) {
-  for (size_t i = 0; i < arraysize(kProcessIsolationTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kProcessIsolationTestCases); ++i) {
     const ProcessIsolationTestCase& test = kProcessIsolationTestCases[i];
     AddTab(browser(), GURL("chrome://blank"));
     content::WebContents* contents =
@@ -215,7 +215,7 @@
 }
 
 TEST_F(SearchTest, ProcessIsolation_RendererInitiated) {
-  for (size_t i = 0; i < arraysize(kProcessIsolationTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kProcessIsolationTestCases); ++i) {
     const ProcessIsolationTestCase& test = kProcessIsolationTestCases[i];
     AddTab(browser(), GURL("chrome://blank"));
     content::WebContents* contents =
diff --git a/chrome/browser/search_engines/template_url_fetcher_unittest.cc b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
index 07564fdeb..7abe311 100644
--- a/chrome/browser/search_engines/template_url_fetcher_unittest.cc
+++ b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
@@ -12,9 +12,9 @@
 
 #include "base/callback_helpers.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/search_engines/template_url_service_test_util.h"
 #include "chrome/test/base/testing_profile.h"
@@ -225,7 +225,7 @@
        keyword},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     StartDownload(test_cases[i].keyword, test_cases[i].osdd_file_name, false);
     EXPECT_EQ(1, template_url_fetcher()->requests_count())
         << test_cases[i].description;
diff --git a/chrome/browser/search_engines/template_url_parser_unittest.cc b/chrome/browser/search_engines/template_url_parser_unittest.cc
index 2d30e24..7cfa0e5 100644
--- a/chrome/browser/search_engines/template_url_parser_unittest.cc
+++ b/chrome/browser/search_engines/template_url_parser_unittest.cc
@@ -2,15 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "components/search_engines/template_url_parser.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/common/chrome_paths.h"
 #include "components/search_engines/search_terms_data.h"
 #include "components/search_engines/template_url.h"
-#include "components/search_engines/template_url_parser.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 using base::ASCIIToUTF16;
@@ -262,6 +262,6 @@
     </Url>
     </OpenSearchDescription>
   )";
-  TemplateURLParser::Parse(SearchTermsData(), char_data, arraysize(char_data),
+  TemplateURLParser::Parse(SearchTermsData(), char_data, base::size(char_data),
                            &filter);
 }
diff --git a/chrome/browser/search_engines/template_url_service_sync_unittest.cc b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
index bf476586..5911f29 100644
--- a/chrome/browser/search_engines/template_url_service_sync_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_sync_unittest.cc
@@ -10,6 +10,7 @@
 #include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
@@ -587,7 +588,7 @@
     {100, 100, false, false, false},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     TemplateURL* local_turl = model()->Add(CreateTestTemplateURL(
         ASCIIToUTF16("localkey"), "www.local.com", "localguid",
         test_cases[i].local_time, true, test_cases[i].local_created_by_policy));
@@ -2183,7 +2184,7 @@
     {NEITHER, SYNC, NEITHER, NEITHER, BOTH, false, {1, 0, 0}},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     // Assert all the valid states of ExpectedTemplateURLs.
     ASSERT_FALSE(test_cases[i].conflict_winner == BOTH);
     ASSERT_FALSE(test_cases[i].synced_at_start == NEITHER);
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index 015cf0d..539c8bb3 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -12,9 +12,9 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/callback.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -1095,7 +1095,7 @@
                      "http://sugg1", "http://x/foo#query={searchTerms}",
                      "http://icon1", false, "UTF-8;UTF-16");
 
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     TemplateURLService::URLVisitedDetails details = {
       GURL(data[i].url), false
     };
@@ -1117,7 +1117,7 @@
   AddKeywordWithDate("name", "x", "http://x/foo", "http://sugg1", std::string(),
                      "http://icon1", false, "UTF-8;UTF-16");
 
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     TemplateURLService::URLVisitedDetails details = {
       GURL(data[i].url), false
     };
diff --git a/chrome/browser/sessions/session_restore_delegate.cc b/chrome/browser/sessions/session_restore_delegate.cc
index a7b3651f..c5ca690 100644
--- a/chrome/browser/sessions/session_restore_delegate.cc
+++ b/chrome/browser/sessions/session_restore_delegate.cc
@@ -7,8 +7,8 @@
 #include <stddef.h>
 #include <utility>
 
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "chrome/browser/sessions/session_restore_stats_collector.h"
 #include "chrome/browser/sessions/tab_loader.h"
 #include "chrome/common/url_constants.h"
@@ -28,7 +28,7 @@
   };
   // Prefix-match against the table above. Use strncmp to avoid allocating
   // memory to convert the URL prefix constants into std::strings.
-  for (size_t i = 0; i < arraysize(kReloadableUrlPrefixes); ++i) {
+  for (size_t i = 0; i < base::size(kReloadableUrlPrefixes); ++i) {
     if (!strncmp(url.spec().c_str(), kReloadableUrlPrefixes[i],
                  strlen(kReloadableUrlPrefixes[i])))
       return true;
diff --git a/chrome/browser/shell_integration_linux_unittest.cc b/chrome/browser/shell_integration_linux_unittest.cc
index 2a258c45..d60897b 100644
--- a/chrome/browser/shell_integration_linux_unittest.cc
+++ b/chrome/browser/shell_integration_linux_unittest.cc
@@ -17,7 +17,6 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -315,7 +314,7 @@
     { "http___foo_.desktop", "http://foo/bar/././../baz/././../" },
     { "http___.._.desktop", "http://../../../../" },
   };
-  for (size_t i = 0; i < arraysize(test_cases); i++) {
+  for (size_t i = 0; i < base::size(test_cases); i++) {
     EXPECT_EQ(std::string(chrome::kBrowserProcessExecutableName) + "-" +
               test_cases[i].path,
               GetWebShortcutFilename(GURL(test_cases[i].url)).value()) <<
@@ -454,7 +453,7 @@
     },
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); i++) {
+  for (size_t i = 0; i < base::size(test_cases); i++) {
     SCOPED_TRACE(i);
     EXPECT_EQ(
         test_cases[i].expected_output,
@@ -529,7 +528,7 @@
     },
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); i++) {
+  for (size_t i = 0; i < base::size(test_cases); i++) {
     SCOPED_TRACE(i);
     EXPECT_EQ(test_cases[i].expected_output,
               GetDirectoryFileContents(base::ASCIIToUTF16(test_cases[i].title),
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index c1998b8..8daaee10 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -21,12 +21,12 @@
 #include "base/command_line.h"
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/user_metrics.h"
 #include "base/metrics/user_metrics_action.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -182,7 +182,7 @@
   // populate the external protocol dialog box the user sees when invoking
   // an unknown external protocol.
   wchar_t out_buffer[1024];
-  DWORD buffer_size = arraysize(out_buffer);
+  DWORD buffer_size = base::size(out_buffer);
   HRESULT hr =
       AssocQueryString(ASSOCF_IS_PROTOCOL, ASSOCSTR_FRIENDLYAPPNAME,
                        url_scheme.c_str(), NULL, out_buffer, &buffer_size);
diff --git a/chrome/browser/signin/signin_error_notifier_ash_unittest.cc b/chrome/browser/signin/signin_error_notifier_ash_unittest.cc
index ec50ee0..28f88fb4 100644
--- a/chrome/browser/signin/signin_error_notifier_ash_unittest.cc
+++ b/chrome/browser/signin/signin_error_notifier_ash_unittest.cc
@@ -9,7 +9,6 @@
 #include <memory>
 #include <string>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/stl_util.h"
 #include "build/build_config.h"
@@ -149,12 +148,12 @@
     { GoogleServiceAuthError::SERVICE_ERROR, true },
     { GoogleServiceAuthError::WEB_LOGIN_REQUIRED, true },
   };
-  static_assert(arraysize(table) == GoogleServiceAuthError::NUM_STATES,
-      "table size should match number of auth error types");
+  static_assert(base::size(table) == GoogleServiceAuthError::NUM_STATES,
+                "table size should match number of auth error types");
   std::string account_id =
       identity_test_env()->MakeAccountAvailable(kTestEmail).account_id;
 
-  for (size_t i = 0; i < arraysize(table); ++i) {
+  for (size_t i = 0; i < base::size(table); ++i) {
     if (GoogleServiceAuthError::IsDeprecated(table[i].error_state))
       continue;
 
diff --git a/chrome/browser/signin/signin_global_error_unittest.cc b/chrome/browser/signin/signin_global_error_unittest.cc
index 2b129b0..d26bc9a6 100644
--- a/chrome/browser/signin/signin_global_error_unittest.cc
+++ b/chrome/browser/signin/signin_global_error_unittest.cc
@@ -10,7 +10,7 @@
 #include <string>
 
 #include "base/bind.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "chrome/browser/profiles/profile_attributes_entry.h"
@@ -135,13 +135,13 @@
     { GoogleServiceAuthError::SERVICE_ERROR, true },
     { GoogleServiceAuthError::WEB_LOGIN_REQUIRED, true },
   };
-  static_assert(arraysize(table) == GoogleServiceAuthError::NUM_STATES,
-      "table size should match number of auth error types");
+  static_assert(base::size(table) == GoogleServiceAuthError::NUM_STATES,
+                "table size should match number of auth error types");
 
   // Mark the profile with an active timestamp so profile_metrics logs it.
   testing_profile_manager()->UpdateLastUser(profile());
 
-  for (size_t i = 0; i < arraysize(table); ++i) {
+  for (size_t i = 0; i < base::size(table); ++i) {
     if (GoogleServiceAuthError::IsDeprecated(table[i].error_state))
       continue;
     SetAuthError(GoogleServiceAuthError::NONE);
diff --git a/chrome/browser/spellchecker/spellcheck_service_browsertest.cc b/chrome/browser/spellchecker/spellcheck_service_browsertest.cc
index 926a3a69f..0dd37f2 100644
--- a/chrome/browser/spellchecker/spellcheck_service_browsertest.cc
+++ b/chrome/browser/spellchecker/spellcheck_service_browsertest.cc
@@ -7,9 +7,9 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -461,8 +461,8 @@
     base::ScopedAllowBlockingForTesting allow_blocking;
     size_t actual = base::WriteFile(
         bdict_path, reinterpret_cast<const char*>(kCorruptedBDICT),
-        arraysize(kCorruptedBDICT));
-    EXPECT_EQ(arraysize(kCorruptedBDICT), actual);
+        base::size(kCorruptedBDICT));
+    EXPECT_EQ(base::size(kCorruptedBDICT), actual);
   }
 
   // Attach an event to the SpellcheckService object so we can receive its
diff --git a/chrome/browser/spellchecker/spelling_service_client_unittest.cc b/chrome/browser/spellchecker/spelling_service_client_unittest.cc
index bf9827d..d432389 100644
--- a/chrome/browser/spellchecker/spelling_service_client_unittest.cc
+++ b/chrome/browser/spellchecker/spelling_service_client_unittest.cc
@@ -12,7 +12,7 @@
 
 #include "base/bind.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/bind_test_util.h"
@@ -104,7 +104,7 @@
     } kCountries[] = {
         {"af", "ZAF"}, {"en", "USA"},
     };
-    for (size_t i = 0; i < arraysize(kCountries); ++i) {
+    for (size_t i = 0; i < base::size(kCountries); ++i) {
       if (!language.compare(kCountries[i].language)) {
         country->assign(kCountries[i].country);
         return true;
@@ -218,7 +218,7 @@
   pref->SetBoolean(spellcheck::prefs::kSpellCheckEnable, true);
   pref->SetBoolean(spellcheck::prefs::kSpellCheckUseSpellingService, true);
 
-  for (size_t i = 0; i < arraysize(kTests); ++i) {
+  for (size_t i = 0; i < base::size(kTests); ++i) {
     client_.test_url_loader_factory()->ClearResponses();
     net::HttpStatusCode http_status = kTests[i].response_status;
     network::ResourceResponseHead head;
@@ -324,7 +324,7 @@
   };
   // If spellcheck is allowed, then suggest is not since spellcheck is a
   // superset of suggest.
-  for (size_t i = 0; i < arraysize(kSupported); ++i) {
+  for (size_t i = 0; i < base::size(kSupported); ++i) {
     base::ListValue dictionary;
     dictionary.AppendString(kSupported[i]);
     pref->Set(spellcheck::prefs::kSpellCheckDictionaries, dictionary);
@@ -341,7 +341,7 @@
       "lv-LV", "nb-NO", "nl-NL", "pl-PL", "pt-BR", "pt-PT", "ro-RO", "ru-RU",
       "sk-SK", "sl-SI", "sh",    "sr",    "sv-SE", "tr-TR", "uk-UA", "vi-VN",
   };
-  for (size_t i = 0; i < arraysize(kUnsupported); ++i) {
+  for (size_t i = 0; i < base::size(kUnsupported); ++i) {
     SCOPED_TRACE(std::string("Expected language ") + kUnsupported[i]);
     base::ListValue dictionary;
     dictionary.AppendString(kUnsupported[i]);
diff --git a/chrome/browser/supervised_user/child_accounts/family_info_fetcher.cc b/chrome/browser/supervised_user/child_accounts/family_info_fetcher.cc
index 4e454455..b22aee5 100644
--- a/chrome/browser/supervised_user/child_accounts/family_info_fetcher.cc
+++ b/chrome/browser/supervised_user/child_accounts/family_info_fetcher.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/json/json_reader.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "chrome/browser/supervised_user/child_accounts/kids_management_api.h"
@@ -105,7 +105,7 @@
 bool FamilyInfoFetcher::StringToRole(
     const std::string& str,
     FamilyInfoFetcher::FamilyMemberRole* role) {
-  for (size_t i = 0; i < arraysize(kFamilyMemberRoleStrings); i++) {
+  for (size_t i = 0; i < base::size(kFamilyMemberRoleStrings); i++) {
     if (str == kFamilyMemberRoleStrings[i]) {
       *role = FamilyMemberRole(i);
       return true;
diff --git a/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc b/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc
index 154cc81..2a2690a 100644
--- a/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/leveldb_wrapper_unittest.cc
@@ -10,7 +10,7 @@
 
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/leveldatabase/env_chromium.h"
@@ -46,7 +46,7 @@
     // Expected contents are
     // {"a": "1", "ab": "0", "bb": "3", "d": "4"}
     const char* keys[] = {"ab", "a", "d", "bb", "d"};
-    for (size_t i = 0; i < arraysize(keys); ++i) {
+    for (size_t i = 0; i < base::size(keys); ++i) {
       leveldb::Status status =
           db->Put(leveldb::WriteOptions(), keys[i], base::NumberToString(i));
       ASSERT_TRUE(status.ok());
@@ -175,7 +175,7 @@
   GetDB()->Put("bb", "new2");  // Overwrite an entry.
 
   SCOPED_TRACE("PutTest_Pending");
-  CheckDBContents(merged_data, arraysize(merged_data));
+  CheckDBContents(merged_data, base::size(merged_data));
 
   EXPECT_EQ(3, GetDB()->num_puts());
   // Remove all pending transactions.
@@ -183,7 +183,7 @@
   EXPECT_EQ(0, GetDB()->num_puts());
 
   SCOPED_TRACE("PutTest_Clear");
-  CheckDBContents(orig_data, arraysize(orig_data));
+  CheckDBContents(orig_data, base::size(orig_data));
 
   // Add pending transactions again, with commiting.
   GetDB()->Put("aa", "new0");
@@ -195,7 +195,7 @@
   GetDB()->Clear();  // Clear just in case.
 
   SCOPED_TRACE("PutTest_Commit");
-  CheckDBContents(merged_data, arraysize(merged_data));
+  CheckDBContents(merged_data, base::size(merged_data));
 }
 
 TEST_F(LevelDBWrapperTest, DeleteTest) {
@@ -216,13 +216,13 @@
   EXPECT_EQ(2, GetDB()->num_deletes());
 
   SCOPED_TRACE("DeleteTest_Pending");
-  CheckDBContents(merged_data, arraysize(merged_data));
+  CheckDBContents(merged_data, base::size(merged_data));
 
   // Remove all pending transactions.
   GetDB()->Clear();
 
   SCOPED_TRACE("DeleteTest_Clear");
-  CheckDBContents(orig_data, arraysize(orig_data));
+  CheckDBContents(orig_data, base::size(orig_data));
 
   // Add pending transactions again, with commiting.
   GetDB()->Put("aa", "new0");
@@ -237,7 +237,7 @@
   EXPECT_EQ(0, GetDB()->num_deletes());
 
   SCOPED_TRACE("DeleteTest_Commit");
-  CheckDBContents(merged_data, arraysize(merged_data));
+  CheckDBContents(merged_data, base::size(merged_data));
 }
 
 }  // namespace drive_backend
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc
index 5dcdcd4..a83bcce 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database.cc
@@ -12,7 +12,6 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
@@ -1638,8 +1637,8 @@
     "active", "dirty", "folder_listing", "demoted",
     "title", "kind", "md5", "etag", "missing", "change_id",
   };
-  std::vector<std::string> key_strings(
-      trackerKeys, trackerKeys + arraysize(trackerKeys));
+  std::vector<std::string> key_strings(trackerKeys,
+                                       trackerKeys + base::size(trackerKeys));
   auto keys = std::make_unique<base::ListValue>();
   keys->AppendStrings(key_strings);
   metadata->SetString("title", "Trackers");
@@ -1700,8 +1699,8 @@
     "file_id", "title", "type", "md5", "etag", "missing",
     "change_id", "parents"
   };
-  std::vector<std::string> key_strings(
-      fileKeys, fileKeys + arraysize(fileKeys));
+  std::vector<std::string> key_strings(fileKeys,
+                                       fileKeys + base::size(fileKeys));
   auto keys = std::make_unique<base::ListValue>();
   keys->AppendStrings(key_strings);
   metadata->SetString("title", "Metadata");
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
index 552d840..d092a60 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
@@ -8,7 +8,6 @@
 
 #include "base/format_macros.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -732,7 +731,7 @@
   };
 
   int64_t num_deletes_before = db_->num_deletes();
-  for (size_t i = 0; i < arraysize(kIndexPrefixes); ++i)
+  for (size_t i = 0; i < base::size(kIndexPrefixes); ++i)
     DeleteKeyStartsWith(kIndexPrefixes[i]);
   num_dirty_trackers_ = 0;
   return db_->num_deletes() - num_deletes_before;
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
index c524111..d3b60d78 100644
--- a/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_unittest.cc
@@ -12,9 +12,9 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
@@ -673,11 +673,11 @@
     &sync_root, &app_root, &file, &folder, &file_in_folder, &orphaned_file
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
 
   orphaned_file.should_be_absent = true;
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
 }
 
 TEST_P(MetadataDatabaseTest, AppManagementTest) {
@@ -693,9 +693,9 @@
   const TrackedFile* tracked_files[] = {
     &sync_root, &app_root, &file, &folder,
   };
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
 
   folder.tracker.set_app_id("foo");
   EXPECT_EQ(SYNC_STATUS_OK, RegisterApp(
@@ -910,7 +910,7 @@
     &new_file,
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
 
   ApplyRenameChangeToMetadata("renamed", &renamed_file.metadata);
@@ -947,7 +947,7 @@
 
   new_file.should_be_absent = false;
 
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 }
 
@@ -969,9 +969,9 @@
     &sync_root, &app_root, &folder_to_populate, &known_file, &new_file
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
 
   FileIDList listed_children;
   listed_children.push_back(known_file.metadata.file_id());
@@ -989,7 +989,7 @@
   new_file.tracker.clear_synced_details();
   new_file.should_be_absent = false;
   new_file.tracker_only = true;
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 }
 
@@ -1009,9 +1009,9 @@
     &sync_root, &app_root, &inactive_folder, &new_file,
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
 
   FileIDList listed_children;
   listed_children.push_back(new_file.metadata.file_id());
@@ -1019,7 +1019,7 @@
   EXPECT_EQ(SYNC_STATUS_OK,
             PopulateFolder(inactive_folder.metadata.file_id(),
                            listed_children));
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 }
 
@@ -1038,9 +1038,9 @@
     &sync_root, &disabled_app_root, &disabled_app_root, &known_file, &file,
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
 
   FileIDList disabled_app_children;
   disabled_app_children.push_back(file.metadata.file_id());
@@ -1055,7 +1055,7 @@
 
   disabled_app_root.tracker.set_dirty(false);
   disabled_app_root.tracker.set_needs_folder_listing(false);
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 }
 
@@ -1081,15 +1081,15 @@
     &sync_root, &app_root, &file, &inactive_file, &new_conflict
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 
   *file.tracker.mutable_synced_details() = file.metadata.details();
   file.tracker.set_dirty(false);
   EXPECT_EQ(SYNC_STATUS_OK, UpdateTracker(file.tracker));
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 
   *inactive_file.tracker.mutable_synced_details() =
@@ -1097,7 +1097,7 @@
   inactive_file.tracker.set_dirty(false);
   inactive_file.tracker.set_active(true);
   EXPECT_EQ(SYNC_STATUS_OK, UpdateTracker(inactive_file.tracker));
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 
   *new_conflict.tracker.mutable_synced_details() =
@@ -1107,7 +1107,7 @@
   file.tracker.set_dirty(true);
   file.tracker.set_active(false);
   EXPECT_EQ(SYNC_STATUS_OK, UpdateTracker(new_conflict.tracker));
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 }
 
@@ -1138,7 +1138,7 @@
   ResetTrackerID(&app_root.tracker);
   app_root.tracker.set_parent_tracker_id(sync_root.tracker.tracker_id());
 
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
   VerifyReloadConsistency();
 }
 
@@ -1154,9 +1154,9 @@
     &sync_root, &app_root, &folder_0, &file_0
   };
 
-  SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files));
+  SetUpDatabaseByTrackedFiles(tracked_files, base::size(tracked_files));
   EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase());
-  VerifyTrackedFiles(tracked_files, arraysize(tracked_files));
+  VerifyTrackedFiles(tracked_files, base::size(tracked_files));
 
   std::unique_ptr<base::ListValue> files =
       metadata_database()->DumpFiles(app_root.tracker.app_id());
diff --git a/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc b/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc
index c0ce6a9..15f317e 100644
--- a/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend/sync_engine_unittest.cc
@@ -8,9 +8,9 @@
 #include <utility>
 
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chrome/browser/sync_file_system/drive_backend/callback_helper.h"
@@ -212,7 +212,7 @@
     {REMOTE_SERVICE_DISABLED, "DISABLED"},
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     PostUpdateServiceState(test_data[i].state, test_data[i].description);
     EXPECT_EQ(test_data[i].state, sync_engine()->GetCurrentState())
         << "Expected state: REMOTE_SERVICE_" << test_data[i].description;
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc b/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc
index 68f47bd..94087e2 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc
@@ -13,7 +13,6 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
@@ -776,7 +775,7 @@
 
   // Create kFile1 and populate it with kTestFileData0.
   EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kFile1));
-  EXPECT_EQ(static_cast<int64_t>(arraysize(kTestFileData0) - 1),
+  EXPECT_EQ(static_cast<int64_t>(base::size(kTestFileData0) - 1),
             file_system.WriteString(kFile1, kTestFileData0));
 
   // kFile2 and kDir are not there yet.
@@ -796,12 +795,12 @@
   const base::FilePath kFilePath1(temp_dir.GetPath().Append(FPL("file1")));
   const base::FilePath kFilePath2(temp_dir.GetPath().Append(FPL("file2")));
 
-  ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
+  ASSERT_EQ(static_cast<int>(base::size(kTestFileData1) - 1),
             base::WriteFile(kFilePath1, kTestFileData1,
-                            arraysize(kTestFileData1) - 1));
-  ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
+                            base::size(kTestFileData1) - 1));
+  ASSERT_EQ(static_cast<int>(base::size(kTestFileData2) - 1),
             base::WriteFile(kFilePath2, kTestFileData2,
-                            arraysize(kTestFileData2) - 1));
+                            base::size(kTestFileData2) - 1));
 
   // Record the usage.
   int64_t usage = -1, new_usage = -1;
@@ -832,7 +831,7 @@
 
   // Check if the usage has been increased by (kTestFileData1 - kTestFileData0).
   const int updated_size =
-      arraysize(kTestFileData1) - arraysize(kTestFileData0);
+      base::size(kTestFileData1) - base::size(kTestFileData0);
   EXPECT_EQ(blink::mojom::QuotaStatusCode::kOk,
             file_system.GetUsageAndQuota(&new_usage, &quota));
   EXPECT_EQ(updated_size, new_usage - usage);
@@ -883,7 +882,7 @@
   EXPECT_EQ(blink::mojom::QuotaStatusCode::kOk,
             file_system.GetUsageAndQuota(&new_usage, &quota));
   EXPECT_GT(new_usage,
-            static_cast<int64_t>(usage + arraysize(kTestFileData2) - 1));
+            static_cast<int64_t>(usage + base::size(kTestFileData2) - 1));
 
   // The changes applied by ApplyRemoteChange should not be recorded in
   // the change tracker.
@@ -927,9 +926,9 @@
 
   // Prepare a temporary file which represents remote file data.
   const base::FilePath kFilePath(temp_dir.GetPath().Append(FPL("file")));
-  ASSERT_EQ(static_cast<int>(arraysize(kTestFileData) - 1),
-            base::WriteFile(kFilePath, kTestFileData,
-                            arraysize(kTestFileData) - 1));
+  ASSERT_EQ(
+      static_cast<int>(base::size(kTestFileData) - 1),
+      base::WriteFile(kFilePath, kTestFileData, base::size(kTestFileData) - 1));
 
   // Calling ApplyChange's with kFilePath should create
   // kFile along with kDir.
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc b/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
index cd795ce..5ed7b6b 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
@@ -9,7 +9,6 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
 #include "base/task/post_task.h"
@@ -215,7 +214,7 @@
   const FileSystemURL kFile(file_system_->URL("file"));
   const FileSystemURL kDir(file_system_->URL("dir"));
   const char kTestFileData[] = "0123456789";
-  const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1);
+  const int kTestFileDataSize = static_cast<int>(base::size(kTestFileData) - 1);
 
   base::FilePath local_path;
   ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.GetPath(), &local_path));
@@ -275,7 +274,7 @@
   const FileSystemURL kFile(file_system_->URL("file"));
   const FileSystemURL kDir(file_system_->URL("dir"));
   const char kTestFileData[] = "0123456789";
-  const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1);
+  const int kTestFileDataSize = static_cast<int>(base::size(kTestFileData) - 1);
 
   EXPECT_EQ(base::File::FILE_OK, file_system_->CreateFile(kFile));
 
@@ -334,7 +333,7 @@
 TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateFile) {
   const FileSystemURL kFile(file_system_->URL("foo"));
   const char kTestFileData[] = "0123456789";
-  const int kTestFileDataSize = static_cast<int>(arraysize(kTestFileData) - 1);
+  const int kTestFileDataSize = static_cast<int>(base::size(kTestFileData) - 1);
 
   base::RunLoop run_loop;
 
@@ -630,7 +629,7 @@
 
   const GURL kOrigins[] = { kOrigin1, kOrigin2, kOrigin3 };
   std::set<GURL> all_origins;
-  all_origins.insert(kOrigins, kOrigins + arraysize(kOrigins));
+  all_origins.insert(kOrigins, kOrigins + base::size(kOrigins));
 
   GURL origin;
   while (!all_origins.empty()) {
@@ -667,7 +666,7 @@
   SetOriginChangeCount(kOrigin2, 8);
   ASSERT_EQ(1 + 4 + 8, GetTotalChangeCount());
 
-  all_origins.insert(kOrigins, kOrigins + arraysize(kOrigins));
+  all_origins.insert(kOrigins, kOrigins + base::size(kOrigins));
   while (!all_origins.empty()) {
     ASSERT_TRUE(NextOriginToProcess(&origin));
     ASSERT_TRUE(base::ContainsKey(all_origins, origin));
@@ -690,7 +689,7 @@
   ASSERT_EQ(1 + 2 + 4, GetTotalChangeCount());
 
   std::set<GURL> all_origins;
-  all_origins.insert(kOrigins, kOrigins + arraysize(kOrigins));
+  all_origins.insert(kOrigins, kOrigins + base::size(kOrigins));
 
   GURL origin;
   while (!all_origins.empty()) {
diff --git a/chrome/browser/task_manager/providers/web_contents/tab_contents_tag_browsertest.cc b/chrome/browser/task_manager/providers/web_contents/tab_contents_tag_browsertest.cc
index 08029a58..094b009 100644
--- a/chrome/browser/task_manager/providers/web_contents/tab_contents_tag_browsertest.cc
+++ b/chrome/browser/task_manager/providers/web_contents/tab_contents_tag_browsertest.cc
@@ -4,9 +4,9 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
 #include "chrome/browser/task_manager/mock_web_contents_task_manager.h"
@@ -68,7 +68,7 @@
     },
 };
 
-const size_t kTestPagesLength = arraysize(kTestPages);
+const size_t kTestPagesLength = base::size(kTestPages);
 
 // Blocks till the current page uses a specific icon URL.
 class FaviconWaiter : public favicon::FaviconDriverObserver {
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index 9d8c013..0c29127 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -13,7 +13,6 @@
 
 #include "base/containers/flat_set.h"
 #include "base/files/file.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/no_destructor.h"
 #include "base/stl_util.h"
@@ -142,7 +141,7 @@
     {PRS_THEME_WINDOW_CONTROL_BACKGROUND, IDR_THEME_WINDOW_CONTROL_BACKGROUND,
      "theme_window_control_background"},
 };
-const size_t kPersistingImagesLength = arraysize(kPersistingImages);
+const size_t kPersistingImagesLength = base::size(kPersistingImages);
 
 int GetPersistentIDByNameHelper(const std::string& key,
                                 const PersistingImagesTable* image_table,
@@ -229,7 +228,7 @@
     {"frame_incognito_inactive", TP::TINT_FRAME_INCOGNITO_INACTIVE},
     {"background_tab", TP::TINT_BACKGROUND_TAB},
 };
-const size_t kTintTableLength = arraysize(kTintTable);
+const size_t kTintTableLength = base::size(kTintTable);
 
 // Strings used by themes to identify colors in the JSON.
 constexpr StringToIntTable kOverwritableColorTable[] = {
@@ -280,7 +279,7 @@
     {"ntp_background_repeat", TP::NTP_BACKGROUND_TILING},
     {"ntp_logo_alternate", TP::NTP_LOGO_ALTERNATE},
 };
-const size_t kDisplayPropertiesSize = arraysize(kDisplayProperties);
+const size_t kDisplayPropertiesSize = base::size(kDisplayProperties);
 
 int GetIntForString(const std::string& key,
                     const StringToIntTable* table,
@@ -677,7 +676,7 @@
 
   // Generate raw images (for new-tab-page attribution and background) for
   // any missing scale from an available scale image.
-  for (size_t i = 0; i < arraysize(kPreloadIDs); ++i) {
+  for (size_t i = 0; i < base::size(kPreloadIDs); ++i) {
     pack->GenerateRawImageForAllSupportedScales(kPreloadIDs[i]);
   }
 
@@ -1194,7 +1193,7 @@
     // Some images need to go directly into |image_memory_|. No modification is
     // necessary or desirable.
     bool is_copyable = false;
-    for (size_t i = 0; i < arraysize(kPreloadIDs); ++i) {
+    for (size_t i = 0; i < base::size(kPreloadIDs); ++i) {
       if (kPreloadIDs[i] == prs_id) {
         is_copyable = true;
         break;
@@ -1248,7 +1247,7 @@
 }
 
 void BrowserThemePack::CropImages(ImageCache* images) const {
-  for (size_t i = 0; i < arraysize(kImagesToCrop); ++i) {
+  for (size_t i = 0; i < base::size(kImagesToCrop); ++i) {
     int prs_id = kImagesToCrop[i].prs_id;
     auto it = images->find(prs_id);
     if (it == images->end())
@@ -1453,7 +1452,7 @@
   };
 
   ImageCache temp_output;
-  for (size_t i = 0; i < arraysize(kTabBackgroundMap); ++i) {
+  for (size_t i = 0; i < base::size(kTabBackgroundMap); ++i) {
     const int tab_id = kTabBackgroundMap[i].tab_id;
     ImageCache::const_iterator tab_it = images->find(tab_id);
 
diff --git a/chrome/browser/translate/translate_manager_render_view_host_unittest.cc b/chrome/browser/translate/translate_manager_render_view_host_unittest.cc
index 8441177e..801c8f8 100644
--- a/chrome/browser/translate/translate_manager_render_view_host_unittest.cc
+++ b/chrome/browser/translate/translate_manager_render_view_host_unittest.cc
@@ -11,7 +11,6 @@
 #include <vector>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/scoped_observer.h"
 #include "base/stl_util.h"
@@ -547,7 +546,7 @@
 // Test the fetching of languages from the translate server
 TEST_F(TranslateManagerRenderViewHostTest, FetchLanguagesFromTranslateServer) {
   std::vector<std::string> server_languages;
-  for (size_t i = 0; i < arraysize(kServerLanguageList); ++i)
+  for (size_t i = 0; i < base::size(kServerLanguageList); ++i)
     server_languages.push_back(kServerLanguageList[i]);
 
   // First, get the default languages list. Note that calling
diff --git a/chrome/browser/ui/app_list/search/tests/mixer_unittest.cc b/chrome/browser/ui/app_list/search/tests/mixer_unittest.cc
index 832bf489..1d480c78 100644
--- a/chrome/browser/ui/app_list/search/tests/mixer_unittest.cc
+++ b/chrome/browser/ui/app_list/search/tests/mixer_unittest.cc
@@ -12,7 +12,7 @@
 
 #include "ash/public/cpp/app_list/app_list_constants.h"
 #include "ash/public/cpp/app_list/app_list_features.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -205,7 +205,7 @@
       {0, 0, 0, ""},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     app_provider()->set_count(kTestCases[i].app_results);
     omnibox_provider()->set_count(kTestCases[i].omnibox_results);
     webstore_provider()->set_count(kTestCases[i].webstore_results);
diff --git a/chrome/browser/ui/app_list/search/tests/tokenized_string_match_unittest.cc b/chrome/browser/ui/app_list/search/tests/tokenized_string_match_unittest.cc
index 1b129d23..ff12cd0f 100644
--- a/chrome/browser/ui/app_list/search/tests/tokenized_string_match_unittest.cc
+++ b/chrome/browser/ui/app_list/search/tests/tokenized_string_match_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -43,7 +43,7 @@
   };
 
   TokenizedStringMatch match;
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const base::string16 text(base::UTF8ToUTF16(kTestCases[i].text));
     EXPECT_FALSE(match.Calculate(base::UTF8ToUTF16(kTestCases[i].query), text))
         << "Test case " << i << " : text=" << kTestCases[i].text
@@ -71,7 +71,7 @@
   };
 
   TokenizedStringMatch match;
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const base::string16 text(base::UTF8ToUTF16(kTestCases[i].text));
     EXPECT_TRUE(match.Calculate(base::UTF8ToUTF16(kTestCases[i].query), text));
     EXPECT_EQ(kTestCases[i].expect, MatchHit(text, match));
@@ -103,7 +103,7 @@
 
   TokenizedStringMatch match_low;
   TokenizedStringMatch match_high;
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const base::string16 text(base::UTF8ToUTF16(kTestCases[i].text));
     EXPECT_TRUE(
         match_low.Calculate(base::UTF8ToUTF16(kTestCases[i].query_low), text));
@@ -137,7 +137,7 @@
   };
 
   TokenizedStringMatch match;
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const base::string16 text(base::UTF8ToUTF16(kTestCases[i].text));
     EXPECT_TRUE(match.Calculate(base::UTF8ToUTF16(kTestCases[i].query), text));
     EXPECT_NEAR(match.relevance(), kTestCases[i].expected_score, kEpsilon)
diff --git a/chrome/browser/ui/ash/chrome_launcher_prefs.cc b/chrome/browser/ui/ash/chrome_launcher_prefs.cc
index 2382bc9..eae6fd8 100644
--- a/chrome/browser/ui/ash/chrome_launcher_prefs.cc
+++ b/chrome/browser/ui/ash/chrome_launcher_prefs.cc
@@ -11,7 +11,7 @@
 #include <utility>
 
 #include "ash/public/cpp/ash_pref_names.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/browser/app_mode/app_mode_utils.h"
 #include "chrome/browser/chromeos/login/demo_mode/demo_session.h"
@@ -46,7 +46,7 @@
 
 std::unique_ptr<base::ListValue> CreateDefaultPinnedAppsList() {
   std::unique_ptr<base::ListValue> apps(new base::ListValue);
-  for (size_t i = 0; i < arraysize(kDefaultPinnedApps); ++i)
+  for (size_t i = 0; i < base::size(kDefaultPinnedApps); ++i)
     apps->Append(CreateAppDict(kDefaultPinnedApps[i]));
 
   return apps;
@@ -329,7 +329,7 @@
   }
 
   // Now process default apps.
-  for (size_t i = 0; i < arraysize(kDefaultPinnedApps); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultPinnedApps); ++i) {
     const std::string& app_id = kDefaultPinnedApps[i];
     // Check if it is already imported.
     if (app_service->GetPinPosition(app_id).IsValid())
diff --git a/chrome/browser/ui/autofill/popup_view_common_unittest.cc b/chrome/browser/ui/autofill/popup_view_common_unittest.cc
index fb4c507..be577fa 100644
--- a/chrome/browser/ui/autofill/popup_view_common_unittest.cc
+++ b/chrome/browser/ui/autofill/popup_view_common_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/browser/ui/autofill/popup_view_test_helpers.h"
 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
 #include "content/public/browser/web_contents.h"
@@ -67,7 +67,7 @@
                  desired_height)},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     gfx::Rect actual_popup_bounds = view_common.CalculatePopupBounds(
         desired_width, desired_height, test_cases[i].element_bounds,
         web_contents()->GetNativeView(), /* is_rtl= */ false);
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index e6ddbc7e..4a9a861 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -15,11 +15,11 @@
 #include "base/compiler_specific.h"
 #include "base/files/file_path.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/system/sys_info.h"
@@ -1421,7 +1421,7 @@
 // set_show_state(ui::SHOW_STATE_MAXIMIZED) has been invoked.
 IN_PROC_BROWSER_TEST_F(BrowserTest, StartMaximized) {
   Browser::Type types[] = { Browser::TYPE_TABBED, Browser::TYPE_POPUP };
-  for (size_t i = 0; i < arraysize(types); ++i) {
+  for (size_t i = 0; i < base::size(types); ++i) {
     Browser::CreateParams params(types[i], browser()->profile(), true);
     params.initial_show_state = ui::SHOW_STATE_MAXIMIZED;
     AddBlankTabAndShow(new Browser(params));
@@ -1432,7 +1432,7 @@
 // set_show_state(ui::SHOW_STATE_MINIMIZED) has been invoked.
 IN_PROC_BROWSER_TEST_F(BrowserTest, StartMinimized) {
   Browser::Type types[] = { Browser::TYPE_TABBED, Browser::TYPE_POPUP };
-  for (size_t i = 0; i < arraysize(types); ++i) {
+  for (size_t i = 0; i < base::size(types); ++i) {
     Browser::CreateParams params(types[i], browser()->profile(), true);
     params.initial_show_state = ui::SHOW_STATE_MINIMIZED;
     AddBlankTabAndShow(new Browser(params));
diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc
index 991b073..db7719bb 100644
--- a/chrome/browser/ui/browser_command_controller_unittest.cc
+++ b/chrome/browser/ui/browser_command_controller_unittest.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/ui/browser_command_controller.h"
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/app/chrome_command_ids.h"
 #include "chrome/browser/browser_process.h"
@@ -375,7 +375,7 @@
       blink::WebInputEvent::kUndefined, 0,
       blink::WebInputEvent::GetStaticTimeStampForTests());
   // Defaults for a tabbed browser.
-  for (size_t i = 0; i < arraysize(commands); i++) {
+  for (size_t i = 0; i < base::size(commands); i++) {
     SCOPED_TRACE(commands[i].command_id);
     EXPECT_EQ(chrome::IsCommandEnabled(browser(), commands[i].command_id),
               commands[i].enabled_in_tab);
@@ -392,7 +392,7 @@
   // By default, in fullscreen mode, the toolbar should be hidden; and all
   // platforms behave similarly.
   EXPECT_FALSE(window()->IsToolbarShowing());
-  for (size_t i = 0; i < arraysize(commands); i++) {
+  for (size_t i = 0; i < base::size(commands); i++) {
     SCOPED_TRACE(commands[i].command_id);
     EXPECT_EQ(chrome::IsCommandEnabled(browser(), commands[i].command_id),
               commands[i].enabled_in_fullscreen);
@@ -408,7 +408,7 @@
       true);
   EXPECT_TRUE(browser()->command_controller()->IsReservedCommandOrKey(
       IDC_FULLSCREEN, key_event));
-  for (size_t i = 0; i < arraysize(commands); i++) {
+  for (size_t i = 0; i < base::size(commands); i++) {
     if (commands[i].command_id != IDC_FULLSCREEN) {
       SCOPED_TRACE(commands[i].command_id);
       EXPECT_EQ(browser()->command_controller()->IsReservedCommandOrKey(
@@ -426,7 +426,7 @@
   ASSERT_FALSE(browser()->window()->IsFullscreen());
   browser()->command_controller()->FullscreenStateChanged();
 
-  for (size_t i = 0; i < arraysize(commands); i++) {
+  for (size_t i = 0; i < base::size(commands); i++) {
     SCOPED_TRACE(commands[i].command_id);
     EXPECT_EQ(chrome::IsCommandEnabled(browser(), commands[i].command_id),
               commands[i].enabled_in_tab);
diff --git a/chrome/browser/ui/browser_focus_uitest.cc b/chrome/browser/ui/browser_focus_uitest.cc
index 16577f9..ab1a141 100644
--- a/chrome/browser/ui/browser_focus_uitest.cc
+++ b/chrome/browser/ui/browser_focus_uitest.cc
@@ -8,11 +8,11 @@
 #include "base/files/file_util.h"
 #include "base/format_macros.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
@@ -127,9 +127,9 @@
             content::NotificationService::AllSources()));
       }
 
-      for (size_t j = 0; j < arraysize(kExpectedIDs); ++j) {
+      for (size_t j = 0; j < base::size(kExpectedIDs); ++j) {
         SCOPED_TRACE(base::StringPrintf("focus inner loop %" PRIuS, j));
-        const size_t index = reverse ? arraysize(kExpectedIDs) - 1 - j : j;
+        const size_t index = reverse ? base::size(kExpectedIDs) - 1 - j : j;
         // The details are the node's editable state, i.e. true for "textEdit".
         bool is_editable_node = index == 0;
 
diff --git a/chrome/browser/ui/browser_instant_controller_unittest.cc b/chrome/browser/ui/browser_instant_controller_unittest.cc
index a17a31ac..c2e5aade 100644
--- a/chrome/browser/ui/browser_instant_controller_unittest.cc
+++ b/chrome/browser/ui/browser_instant_controller_unittest.cc
@@ -7,9 +7,9 @@
 #include <vector>
 
 #include "base/gtest_prod_util.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/search/instant_service.h"
 #include "chrome/browser/search/instant_unittest_base.h"
@@ -101,7 +101,7 @@
 };
 
 TEST_F(BrowserInstantControllerTest, DefaultSearchProviderChanged) {
-  size_t num_tests = arraysize(kTabReloadTestCasesFinalProviderNotGoogle);
+  size_t num_tests = base::size(kTabReloadTestCasesFinalProviderNotGoogle);
   std::vector<std::unique_ptr<FakeWebContentsObserver>> observers;
   for (size_t i = 0; i < num_tests; ++i) {
     const TabReloadTestCase& test =
@@ -149,7 +149,7 @@
 }
 
 TEST_F(BrowserInstantControllerTest, GoogleBaseURLUpdated) {
-  const size_t num_tests = arraysize(kTabReloadTestCasesFinalProviderGoogle);
+  const size_t num_tests = base::size(kTabReloadTestCasesFinalProviderGoogle);
   std::vector<std::unique_ptr<FakeWebContentsObserver>> observers;
   for (size_t i = 0; i < num_tests; ++i) {
     const TabReloadTestCase& test = kTabReloadTestCasesFinalProviderGoogle[i];
diff --git a/chrome/browser/ui/cocoa/applescript/apple_event_util_unittest.mm b/chrome/browser/ui/cocoa/applescript/apple_event_util_unittest.mm
index 25d4b47..c02b8a7b 100644
--- a/chrome/browser/ui/cocoa/applescript/apple_event_util_unittest.mm
+++ b/chrome/browser/ui/cocoa/applescript/apple_event_util_unittest.mm
@@ -12,7 +12,7 @@
 
 #include "base/json/json_reader.h"
 #include "base/mac/scoped_aedesc.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
@@ -234,7 +234,7 @@
       typeAEList },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::unique_ptr<base::Value> value =
         base::JSONReader::Read(cases[i].json_input);
     NSAppleEventDescriptor* descriptor =
diff --git a/chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.mm b/chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.mm
index 71ad1b8a..293e589 100644
--- a/chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.mm
+++ b/chrome/browser/ui/cocoa/fullscreen/fullscreen_menubar_tracker.mm
@@ -8,7 +8,7 @@
 #include <QuartzCore/QuartzCore.h>
 
 #include "base/mac/mac_util.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_controller.h"
 #import "chrome/browser/ui/cocoa/fullscreen/fullscreen_toolbar_visibility_lock_controller.h"
 #include "ui/base/cocoa/appkit_utils.h"
@@ -87,7 +87,7 @@
     eventSpecs[2].eventKind = kEventMenuBarHidden;
 
     InstallApplicationEventHandler(NewEventHandlerUPP(&MenuBarRevealHandler),
-                                   arraysize(eventSpecs), eventSpecs, self,
+                                   base::size(eventSpecs), eventSpecs, self,
                                    &menubarTrackingHandler_);
 
     // Register for Active Space change notifications.
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
index 2d94eed1..e7fb0dc3 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -11,7 +11,6 @@
 
 #include "base/command_line.h"
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/metrics/user_metrics.h"
 #include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -191,11 +190,11 @@
       {CONTENT_SETTINGS_TYPE_SENSORS, IDS_ALLOWED_SENSORS_TITLE},
   };
   const ContentSettingsTypeIdEntry* title_ids = kBlockedTitleIDs;
-  size_t num_title_ids = arraysize(kBlockedTitleIDs);
+  size_t num_title_ids = base::size(kBlockedTitleIDs);
   if (content_settings->IsContentAllowed(content_type()) &&
       !content_settings->IsContentBlocked(content_type())) {
     title_ids = kAccessedTitleIDs;
-    num_title_ids = arraysize(kAccessedTitleIDs);
+    num_title_ids = base::size(kAccessedTitleIDs);
   }
   int title_id = GetIdForContentType(title_ids, num_title_ids, content_type());
   if (title_id)
@@ -225,11 +224,11 @@
       {CONTENT_SETTINGS_TYPE_SENSORS, IDS_ALLOWED_SENSORS_MESSAGE},
   };
   const ContentSettingsTypeIdEntry* message_ids = kBlockedMessageIDs;
-  size_t num_message_ids = arraysize(kBlockedMessageIDs);
+  size_t num_message_ids = base::size(kBlockedMessageIDs);
   if (content_settings->IsContentAllowed(content_type()) &&
       !content_settings->IsContentBlocked(content_type())) {
     message_ids = kAccessedMessageIDs;
-    num_message_ids = arraysize(kAccessedMessageIDs);
+    num_message_ids = base::size(kAccessedMessageIDs);
   }
   int message_id =
       GetIdForContentType(message_ids, num_message_ids, content_type());
@@ -262,7 +261,7 @@
     {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_ALLOW_INSECURE_CONTENT_BUTTON},
   };
   int custom_link_id =
-      GetIdForContentType(kCustomIDs, arraysize(kCustomIDs), content_type());
+      GetIdForContentType(kCustomIDs, base::size(kCustomIDs), content_type());
   if (custom_link_id)
     set_custom_link(l10n_util::GetStringUTF16(custom_link_id));
 }
@@ -790,11 +789,11 @@
   base::string16 radio_allow_label;
   if (allowed) {
     int resource_id = GetIdForContentType(
-        kAllowedAllowIDs, arraysize(kAllowedAllowIDs), content_type());
+        kAllowedAllowIDs, base::size(kAllowedAllowIDs), content_type());
     radio_allow_label = l10n_util::GetStringUTF16(resource_id);
   } else {
     radio_allow_label = l10n_util::GetStringFUTF16(
-        GetIdForContentType(kBlockedAllowIDs, arraysize(kBlockedAllowIDs),
+        GetIdForContentType(kBlockedAllowIDs, base::size(kBlockedAllowIDs),
                             content_type()),
         display_host);
   }
@@ -819,11 +818,11 @@
   base::string16 radio_block_label;
   if (allowed) {
     int resource_id = GetIdForContentType(
-        kAllowedBlockIDs, arraysize(kAllowedBlockIDs), content_type());
+        kAllowedBlockIDs, base::size(kAllowedBlockIDs), content_type());
     radio_block_label = l10n_util::GetStringFUTF16(resource_id, display_host);
   } else {
     radio_block_label = l10n_util::GetStringUTF16(GetIdForContentType(
-        kBlockedBlockIDs, arraysize(kBlockedBlockIDs), content_type()));
+        kBlockedBlockIDs, base::size(kBlockedBlockIDs), content_type()));
   }
 
   radio_group.radio_items = {radio_allow_label, radio_block_label};
diff --git a/chrome/browser/ui/libgtkui/gtk_key_bindings_handler.cc b/chrome/browser/ui/libgtkui/gtk_key_bindings_handler.cc
index 95264b3..0f957d6e 100644
--- a/chrome/browser/ui/libgtkui/gtk_key_bindings_handler.cc
+++ b/chrome/browser/ui/libgtkui/gtk_key_bindings_handler.cc
@@ -10,7 +10,7 @@
 #include <string>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "chrome/browser/ui/libgtkui/gtk_util.h"
 #include "content/public/browser/native_web_keyboard_event.h"
@@ -279,7 +279,7 @@
   if (count < 0)
     count = -count;
   for (; count > 0; --count) {
-    for (size_t i = 0; i < arraysize(commands); ++i)
+    for (size_t i = 0; i < base::size(commands); ++i)
       if (commands[i] != TextEditCommand::INVALID_COMMAND)
         owner->EditCommandMatched(commands[i], std::string());
   }
diff --git a/chrome/browser/ui/libgtkui/gtk_ui.cc b/chrome/browser/ui/libgtkui/gtk_ui.cc
index 13a2ae1..0e3b246 100644
--- a/chrome/browser/ui/libgtkui/gtk_ui.cc
+++ b/chrome/browser/ui/libgtkui/gtk_ui.cc
@@ -20,7 +20,6 @@
 #include "base/environment.h"
 #include "base/i18n/rtl.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/protected_memory.h"
 #include "base/memory/protected_memory_cfi.h"
 #include "base/nix/mime_util_xdg.h"
@@ -565,7 +564,7 @@
 
   std::string content_types[] = {content_type, kUnknownContentType};
 
-  for (size_t i = 0; i < arraysize(content_types); ++i) {
+  for (size_t i = 0; i < base::size(content_types); ++i) {
     ScopedGIcon icon(g_content_type_get_icon(content_types[i].c_str()));
     ScopedGtkIconInfo icon_info(gtk_icon_theme_lookup_by_gicon(
         theme, icon.get(), size,
@@ -629,7 +628,7 @@
       },
   };
 
-  for (unsigned i = 0; i < arraysize(paintstate); i++) {
+  for (unsigned i = 0; i < base::size(paintstate); i++) {
     gtk_border->SetPainter(
         paintstate[i].focus, paintstate[i].state,
         border->PaintsButtonState(paintstate[i].focus, paintstate[i].state)
diff --git a/chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer_unittest.cc b/chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer_unittest.cc
index 23e0f814..cf775da 100644
--- a/chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer_unittest.cc
+++ b/chrome/browser/ui/omnibox/chrome_omnibox_navigation_observer_unittest.cc
@@ -7,8 +7,8 @@
 #include <unordered_map>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/infobars/infobar_service.h"
@@ -283,7 +283,7 @@
         kNoResponse},
        true},
   };
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE("case #" + base::IntToString(i));
     const Case& test_case = cases[i];
     const Response& response = test_case.response;
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index 2957a1e..3779197 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -7,9 +7,9 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/scoped_observer.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -336,7 +336,7 @@
   void SetupHistory() {
     // Add enough history pages containing |kSearchText| to trigger
     // open history page url in autocomplete result.
-    for (size_t i = 0; i < arraysize(kHistoryEntries); i++) {
+    for (size_t i = 0; i < base::size(kHistoryEntries); i++) {
       // Add everything in order of time. We don't want to have a time that
       // is "right now" or it will nondeterministically appear in the results.
       base::Time t = base::Time::Now() - base::TimeDelta::FromHours(i + 1);
@@ -345,7 +345,7 @@
   }
 
   void SetupHostResolver() {
-    for (size_t i = 0; i < arraysize(kBlockedHostnames); ++i)
+    for (size_t i = 0; i < base::size(kBlockedHostnames); ++i)
       host_resolver()->AddSimulatedFailure(kBlockedHostnames[i]);
   }
 
@@ -537,7 +537,7 @@
 
   // Should stay in keyword mode while deleting search text by pressing
   // backspace.
-  for (size_t i = 0; i < arraysize(kSearchText) - 1; ++i) {
+  for (size_t i = 0; i < base::size(kSearchText) - 1; ++i) {
     ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
     ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
     ASSERT_EQ(kSearchKeyword, UTF16ToUTF8(omnibox_view->model()->keyword()));
@@ -725,7 +725,7 @@
   base::string16 old_text = omnibox_view->GetText();
 
   // Make sure inline autocomplete is triggerred.
-  EXPECT_GT(old_text.length(), arraysize(kInlineAutocompleteText) - 1);
+  EXPECT_GT(old_text.length(), base::size(kInlineAutocompleteText) - 1);
 
   size_t old_selected_line = popup_model->selected_line();
   EXPECT_EQ(0U, old_selected_line);
@@ -1442,7 +1442,7 @@
   base::string16 old_text = omnibox_view->GetText();
 
   // Make sure inline autocomplete is triggerred.
-  EXPECT_GT(old_text.length(), arraysize(kInlineAutocompleteText) - 1);
+  EXPECT_GT(old_text.length(), base::size(kInlineAutocompleteText) - 1);
 
   // Press ctrl key.
   omnibox_view->model()->OnControlKeyChanged(true);
diff --git a/chrome/browser/ui/page_info/page_info.cc b/chrome/browser/ui/page_info/page_info.cc
index 3db58ddd..75bb90ad 100644
--- a/chrome/browser/ui/page_info/page_info.cc
+++ b/chrome/browser/ui/page_info/page_info.cc
@@ -14,11 +14,11 @@
 
 #include "base/command_line.h"
 #include "base/i18n/time_formatting.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/user_metrics.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
@@ -831,7 +831,7 @@
   ChosenObjectInfoList chosen_object_info_list;
 
   PageInfoUI::PermissionInfo permission_info;
-  for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
+  for (size_t i = 0; i < base::size(kPermissionType); ++i) {
     permission_info.type = kPermissionType[i];
 
     content_settings::SettingInfo info;
@@ -971,7 +971,7 @@
 
 std::vector<ContentSettingsType> PageInfo::GetAllPermissionsForTesting() {
   std::vector<ContentSettingsType> permission_list;
-  for (size_t i = 0; i < arraysize(kPermissionType); ++i) {
+  for (size_t i = 0; i < base::size(kPermissionType); ++i) {
 #if !defined(OS_ANDROID)
     if (kPermissionType[i] == CONTENT_SETTINGS_TYPE_AUTOPLAY)
       continue;
diff --git a/chrome/browser/ui/page_info/page_info_ui.cc b/chrome/browser/ui/page_info/page_info_ui.cc
index f9348ff4..a55f80ca 100644
--- a/chrome/browser/ui/page_info/page_info_ui.cc
+++ b/chrome/browser/ui/page_info/page_info_ui.cc
@@ -7,7 +7,7 @@
 #include <utility>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
 #include "chrome/browser/permissions/permission_manager.h"
@@ -62,7 +62,7 @@
     IDS_PAGE_INFO_PERMISSION_ASK_BY_POLICY,
     kInvalidResourceID,
     kInvalidResourceID};
-static_assert(arraysize(kPermissionButtonTextIDPolicyManaged) ==
+static_assert(base::size(kPermissionButtonTextIDPolicyManaged) ==
                   CONTENT_SETTING_NUM_SETTINGS,
               "kPermissionButtonTextIDPolicyManaged array size is incorrect");
 
@@ -75,7 +75,7 @@
     IDS_PAGE_INFO_PERMISSION_ASK_BY_EXTENSION,
     kInvalidResourceID,
     kInvalidResourceID};
-static_assert(arraysize(kPermissionButtonTextIDExtensionManaged) ==
+static_assert(base::size(kPermissionButtonTextIDExtensionManaged) ==
                   CONTENT_SETTING_NUM_SETTINGS,
               "kPermissionButtonTextIDExtensionManaged array size is "
               "incorrect");
@@ -89,7 +89,7 @@
     IDS_PAGE_INFO_BUTTON_TEXT_ASK_BY_USER,
     kInvalidResourceID,
     IDS_PAGE_INFO_BUTTON_TEXT_DETECT_IMPORTANT_CONTENT_BY_USER};
-static_assert(arraysize(kPermissionButtonTextIDUserManaged) ==
+static_assert(base::size(kPermissionButtonTextIDUserManaged) ==
                   CONTENT_SETTING_NUM_SETTINGS,
               "kPermissionButtonTextIDUserManaged array size is incorrect");
 
diff --git a/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc b/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc
index 77286ad..0117a4c3 100644
--- a/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_view_utils_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -132,7 +132,7 @@
 
 // Test for GetSavePasswordDialogTitleTextAndLinkRange().
 TEST(ManagePasswordsViewUtilTest, GetSavePasswordDialogTitleTextAndLinkRange) {
-  for (size_t i = 0; i < arraysize(kDomainsTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kDomainsTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "user_visible_url = "
                                     << kDomainsTestCases[i].user_visible_url
                                     << ", form_origin_url = "
@@ -189,7 +189,7 @@
 }
 
 TEST(ManagePasswordsViewUtilTest, GetManagePasswordsDialogTitleText) {
-  for (size_t i = 0; i < arraysize(kDomainsTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kDomainsTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "user_visible_url = "
                                     << kDomainsTestCases[i].user_visible_url
                                     << ", password_origin_url = "
diff --git a/chrome/browser/ui/prefs/prefs_tab_helper.cc b/chrome/browser/ui/prefs/prefs_tab_helper.cc
index 04328ff..5fdc374c 100644
--- a/chrome/browser/ui/prefs/prefs_tab_helper.cc
+++ b/chrome/browser/ui/prefs/prefs_tab_helper.cc
@@ -11,7 +11,7 @@
 #include <string>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -88,7 +88,7 @@
 #undef EXPAND_SCRIPT_FONT
   };
 
-  for (size_t i = 0; i < arraysize(kFontFamilyMap); ++i) {
+  for (size_t i = 0; i < base::size(kFontFamilyMap); ++i) {
     const char* pref_name = kFontFamilyMap[i];
     if (fonts_with_defaults.find(pref_name) == fonts_with_defaults.end()) {
       // We haven't already set a default value for this font preference, so set
@@ -192,7 +192,7 @@
 #endif
 };
 
-const size_t kFontDefaultsLength = arraysize(kFontDefaults);
+const size_t kFontDefaultsLength = base::size(kFontDefaults);
 
 // Returns the script of the font pref |pref_name|.  For example, suppose
 // |pref_name| is "webkit.webprefs.fonts.serif.Hant".  Since the script code for
diff --git a/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc b/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
index dcf4f446..711b737 100644
--- a/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
+++ b/chrome/browser/ui/sync/profile_signin_confirmation_helper_unittest.cc
@@ -11,9 +11,9 @@
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
 #include "base/compiler_specific.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -242,7 +242,7 @@
   // history items.
   char buf[18];
   for (int i = 0; i < 10; i++) {
-    base::snprintf(buf, arraysize(buf), "http://foo.com/%d", i);
+    base::snprintf(buf, base::size(buf), "http://foo.com/%d", i);
     history->AddPage(
         GURL(std::string(buf)), base::Time::Now(), NULL, 1,
         GURL(), history::RedirectList(), ui::PAGE_TRANSITION_LINK,
diff --git a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
index 654b01e7..485b942f 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model_unittest.cc
@@ -11,7 +11,6 @@
 #include <string>
 
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
@@ -2283,7 +2282,7 @@
       {7, 4, "2 3 4", 3, "0p 1p 2p 3p 5 4 6"},
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     TabStripDummyDelegate delegate;
     TabStripModel strip(&delegate, profile());
     ASSERT_NO_FATAL_FAILURE(PrepareTabstripForSelectionTest(
diff --git a/chrome/browser/ui/task_manager/task_manager_columns.cc b/chrome/browser/ui/task_manager/task_manager_columns.cc
index 44dfb939..643fc3f 100644
--- a/chrome/browser/ui/task_manager/task_manager_columns.cc
+++ b/chrome/browser/ui/task_manager/task_manager_columns.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/ui/task_manager/task_manager_columns.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/grit/generated_resources.h"
 #include "components/nacl/common/buildflags.h"
@@ -27,12 +27,12 @@
     {IDS_TASK_MANAGER_PROFILE_NAME_COLUMN, ui::TableColumn::LEFT, -1, 0, 60,
      200, true, true, false},
     {IDS_TASK_MANAGER_MEM_FOOTPRINT_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("800 MiB") * kCharWidth,
-     arraysize("Memory Footprint") * 1.5 * kCharWidth, true, false, true},
+     base::size("800 MiB") * kCharWidth,
+     base::size("Memory Footprint") * 1.5 * kCharWidth, true, false, true},
 
 #if defined(OS_CHROMEOS)
     {IDS_TASK_MANAGER_SWAPPED_MEM_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("800 MiB") * kCharWidth, -1, true, false, false},
+     base::size("800 MiB") * kCharWidth, -1, true, false, false},
 #endif
 
 // Make the CPU column min width a bit wider on macOS. When you click a column
@@ -41,22 +41,22 @@
 // caret in by tail-truncating the label, which looks terrible.
 #if defined(OS_MACOSX)
     {IDS_TASK_MANAGER_CPU_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("0099.9") * kCharWidth, -1, true, false, true},
+     base::size("0099.9") * kCharWidth, -1, true, false, true},
 #else
     {IDS_TASK_MANAGER_CPU_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("99.9") * kCharWidth, -1, true, false, true},
+     base::size("99.9") * kCharWidth, -1, true, false, true},
 #endif  // defined(OS_MACOSX)
 
 #if defined(OS_WIN)
     {IDS_TASK_MANAGER_CPU_TIME_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("1234h 42m 30s") * kCharWidth, -1, true, false, false},
+     base::size("1234h 42m 30s") * kCharWidth, -1, true, false, false},
     {IDS_TASK_MANAGER_START_TIME_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("12/13/14 11:44:30 PM") * kCharWidth, -1, true, true, false},
+     base::size("12/13/14 11:44:30 PM") * kCharWidth, -1, true, true, false},
 #endif
     {IDS_TASK_MANAGER_NET_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("150 kiB/s") * kCharWidth, -1, true, false, true},
+     base::size("150 kiB/s") * kCharWidth, -1, true, false, true},
     {IDS_TASK_MANAGER_PROCESS_ID_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("73099  ") * kCharWidth, -1, true, true, true},
+     base::size("73099  ") * kCharWidth, -1, true, true, true},
 
 #if defined(OS_WIN)
     {IDS_TASK_MANAGER_GDI_HANDLES_COLUMN, ui::TableColumn::RIGHT, -1, 0, 0, 0,
@@ -66,44 +66,44 @@
 #endif
 
     {IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("2000.0K (2000.0 live)") * kCharWidth, -1, true, false, false},
+     base::size("2000.0K (2000.0 live)") * kCharWidth, -1, true, false, false},
     {IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN, ui::TableColumn::RIGHT, -1,
-     0, arraysize("2000.0K (2000.0 live)") * kCharWidth, -1, true, false,
+     0, base::size("2000.0K (2000.0 live)") * kCharWidth, -1, true, false,
      false},
     {IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("2000.0K (2000.0 live)") * kCharWidth, -1, true, false, false},
+     base::size("2000.0K (2000.0 live)") * kCharWidth, -1, true, false, false},
     {IDS_TASK_MANAGER_VIDEO_MEMORY_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("2000.0K") * kCharWidth, -1, true, false, false},
+     base::size("2000.0K") * kCharWidth, -1, true, false, false},
     {IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("800 kB") * kCharWidth, -1, true, false, false},
+     base::size("800 kB") * kCharWidth, -1, true, false, false},
 
 #if BUILDFLAG(ENABLE_NACL)
     {IDS_TASK_MANAGER_NACL_DEBUG_STUB_PORT_COLUMN, ui::TableColumn::RIGHT, -1,
-     0, arraysize("32767") * kCharWidth, -1, true, true, false},
+     0, base::size("32767") * kCharWidth, -1, true, true, false},
 #endif  // BUILDFLAG(ENABLE_NACL)
 
     {IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN,
      ui::TableColumn::RIGHT, -1, 0,
-     arraysize("2000.0K (2000.0 live)") * kCharWidth, -1, true, false, false},
+     base::size("2000.0K (2000.0 live)") * kCharWidth, -1, true, false, false},
     {IDS_TASK_MANAGER_IDLE_WAKEUPS_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("idlewakeups") * kCharWidth, -1, true, false, false},
+     base::size("idlewakeups") * kCharWidth, -1, true, false, false},
 
 #if defined(OS_WIN)
     {IDS_TASK_MANAGER_HARD_FAULTS_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("100000") * kCharWidth, -1, true, false, false},
+     base::size("100000") * kCharWidth, -1, true, false, false},
 #endif
 
 #if defined(OS_LINUX)
     {IDS_TASK_MANAGER_OPEN_FD_COUNT_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("999") * kCharWidth, -1, true, false, false},
+     base::size("999") * kCharWidth, -1, true, false, false},
 #endif  // defined(OS_LINUX)
     {IDS_TASK_MANAGER_PROCESS_PRIORITY_COLUMN, ui::TableColumn::LEFT, -1, 0,
-     arraysize("background") * kCharWidth, -1, true, true, false},
+     base::size("background") * kCharWidth, -1, true, true, false},
     {IDS_TASK_MANAGER_KEEPALIVE_COUNT_COLUMN, ui::TableColumn::RIGHT, -1, 0,
-     arraysize("999") * kCharWidth, -1, false, false, false},
+     base::size("999") * kCharWidth, -1, false, false, false},
 };
 
-const size_t kColumnsSize = arraysize(kColumns);
+const size_t kColumnsSize = base::size(kColumns);
 
 const char kSortColumnIdKey[] = "sort_column_id";
 const char kSortIsAscendingKey[] = "sort_is_ascending";
diff --git a/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc b/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc
index 04eb923..a57bd31 100644
--- a/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc
+++ b/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc
@@ -9,8 +9,8 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_feature_list.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
@@ -132,7 +132,7 @@
       extensions::ExtensionRegistry::Get(profile());
   // Add each, and verify that it is both correctly added to the extension
   // registry and to the browser actions container.
-  for (size_t i = 0; i < arraysize(extensions); ++i) {
+  for (size_t i = 0; i < base::size(extensions); ++i) {
     extension_service()->AddExtension(extensions[i]);
     EXPECT_TRUE(registry->enabled_extensions().GetByID(extensions[i]->id())) <<
         extensions[i]->name();
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc b/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc
index 7c797045..6378930 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_model_unittest.cc
@@ -11,9 +11,9 @@
 #include "base/callback.h"
 #include "base/callback_helpers.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
@@ -1002,7 +1002,7 @@
 
   extensions::TestExtensionDir* dirs[] = {&dir1, &dir2};
   const extensions::Extension* extensions[] = {nullptr, nullptr};
-  for (size_t i = 0; i < arraysize(dirs); ++i) {
+  for (size_t i = 0; i < base::size(dirs); ++i) {
     // The extension id will be calculated from the file path; we need this to
     // wait for the extension to load.
     base::FilePath path_for_id =
diff --git a/chrome/browser/ui/views/accelerator_table.cc b/chrome/browser/ui/views/accelerator_table.cc
index 79309ec..993b052 100644
--- a/chrome/browser/ui/views/accelerator_table.cc
+++ b/chrome/browser/ui/views/accelerator_table.cc
@@ -6,8 +6,8 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/app/chrome_command_ids.h"
 #include "printing/buildflags/buildflags.h"
@@ -216,7 +216,7 @@
   IDC_SELECT_NEXT_TAB,
   IDC_SELECT_PREVIOUS_TAB,
 };
-const size_t kRepeatableCommandIdsLength = arraysize(kRepeatableCommandIds);
+const size_t kRepeatableCommandIdsLength = base::size(kRepeatableCommandIds);
 
 } // namespace
 
diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
index 669bb2d..8626f71 100644
--- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc
@@ -8,7 +8,6 @@
 #include <utility>
 
 #include "apps/ui/views/app_window_frame_view.h"
-#include "base/macros.h"
 #include "base/no_destructor.h"
 #include "base/stl_util.h"
 #include "build/build_config.h"
@@ -163,8 +162,8 @@
   // registered. This CHECK catches the case.
   CHECK(!is_kiosk_app_mode ||
         accelerator_table.size() ==
-            arraysize(kAppWindowAcceleratorMap) +
-                arraysize(kAppWindowKioskAppModeAcceleratorMap));
+            base::size(kAppWindowAcceleratorMap) +
+                base::size(kAppWindowKioskAppModeAcceleratorMap));
 
   // Ensure there is a ZoomController in kiosk mode, otherwise the processing
   // of the accelerators will cause a crash. Note CHECK here because DCHECK
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
index 7d537b1..e713957d 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc
@@ -17,7 +17,6 @@
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/browser/ui/app_list/app_list_util.h"
 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view_test_helper.h"
-#include "chrome/browser/ui/views/native_widget_factory.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/test/base/browser_with_test_window_test.h"
 #include "chrome/test/base/testing_browser_process.h"
@@ -378,13 +377,13 @@
   views::Widget widget;
   views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
   params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
-#if !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
+#if !defined(OS_CHROMEOS)
   // On Chrome OS, this always creates a NativeWidgetAura, but it should create
   // a DesktopNativeWidgetAura for Mash. We can get by without manually creating
   // it because AshTestViewsDelegate and MusClient will do the right thing
   // automatically.
-  params.native_widget = CreateNativeWidget(
-      NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA, &params, &widget);
+  params.native_widget = views::test::CreatePlatformDesktopNativeWidgetImpl(
+      params, &widget, nullptr);
 #endif
   widget.Init(params);
   widget.Show();
diff --git a/chrome/browser/ui/views/color_chooser_dialog.cc b/chrome/browser/ui/views/color_chooser_dialog.cc
index fca217b..c26be85 100644
--- a/chrome/browser/ui/views/color_chooser_dialog.cc
+++ b/chrome/browser/ui/views/color_chooser_dialog.cc
@@ -9,8 +9,8 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/threading/thread.h"
 #include "content/public/browser/browser_task_traits.h"
@@ -85,5 +85,5 @@
 }
 
 void ColorChooserDialog::CopyCustomColors(COLORREF* src, COLORREF* dst) {
-  memcpy(dst, src, sizeof(COLORREF) * arraysize(g_custom_colors));
+  memcpy(dst, src, sizeof(COLORREF) * base::size(g_custom_colors));
 }
diff --git a/chrome/browser/ui/views/device_chooser_content_view.cc b/chrome/browser/ui/views/device_chooser_content_view.cc
index 907d1e13..2362b75 100644
--- a/chrome/browser/ui/views/device_chooser_content_view.cc
+++ b/chrome/browser/ui/views/device_chooser_content_view.cc
@@ -5,6 +5,7 @@
 #include "chrome/browser/ui/views/device_chooser_content_view.h"
 
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "chrome/browser/ui/views/chrome_layout_provider.h"
 #include "chrome/grit/generated_resources.h"
 #include "components/strings/grit/components_strings.h"
@@ -225,7 +226,7 @@
     return gfx::ImageSkia();
 
   DCHECK_GE(level, 0);
-  DCHECK_LT(level, static_cast<int>(arraysize(kSignalStrengthLevelImageIds)));
+  DCHECK_LT(level, static_cast<int>(base::size(kSignalStrengthLevelImageIds)));
 
   return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
       kSignalStrengthLevelImageIds[level]);
diff --git a/chrome/browser/ui/views/extensions/chooser_dialog_view_unittest.cc b/chrome/browser/ui/views/extensions/chooser_dialog_view_unittest.cc
index 3c88dff8..88f14fee 100644
--- a/chrome/browser/ui/views/extensions/chooser_dialog_view_unittest.cc
+++ b/chrome/browser/ui/views/extensions/chooser_dialog_view_unittest.cc
@@ -14,6 +14,7 @@
 #include "ui/events/base_event_utils.h"
 #include "ui/views/controls/button/label_button.h"
 #include "ui/views/controls/table/table_view.h"
+#include "ui/views/test/native_widget_factory.h"
 #include "ui/views/widget/widget.h"
 #include "ui/views/window/dialog_client_view.h"
 
@@ -34,6 +35,8 @@
         CreateParams(views::Widget::InitParams::TYPE_WINDOW);
     params.bounds = gfx::Rect(10, 11, 200, 200);
     params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+    params.native_widget = views::test::CreatePlatformDesktopNativeWidgetImpl(
+        params, &parent_widget_, nullptr);
     parent_widget_.Init(params);
 
     widget_ = views::DialogDelegate::CreateDialogWidget(
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc
index baba07e..3df7db89 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -6,8 +6,8 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
 #include "base/observer_list.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/ui/browser.h"
@@ -206,7 +206,7 @@
         bookmark_bar_size.width(),
         infobar_container_size.width(),
         contents_size.width() };
-  int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]);
+  int min_width = *std::max_element(&widths[0], &widths[base::size(widths)]);
   return gfx::Size(min_width, min_height);
 }
 
diff --git a/chrome/browser/ui/views/hover_button_unittest.cc b/chrome/browser/ui/views/hover_button_unittest.cc
index ad68c73d..93577ffc 100644
--- a/chrome/browser/ui/views/hover_button_unittest.cc
+++ b/chrome/browser/ui/views/hover_button_unittest.cc
@@ -6,6 +6,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/test/views/chrome_views_test_base.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -77,7 +78,7 @@
 
 // Tests whether the HoverButton has the correct tooltip and accessible name.
 TEST_F(HoverButtonTest, TooltipAndAccessibleName) {
-  for (size_t i = 0; i < arraysize(kTitleSubtitlePairs); ++i) {
+  for (size_t i = 0; i < base::size(kTitleSubtitlePairs); ++i) {
     TitleSubtitlePair pair = kTitleSubtitlePairs[i];
     SCOPED_TRACE(testing::Message() << "Index: " << i << ", expected_tooltip="
                                     << (pair.tooltip ? "true" : "false"));
@@ -114,7 +115,7 @@
 TEST_F(HoverButtonTest, CustomTooltip) {
   const base::string16 custom_tooltip = base::ASCIIToUTF16("custom");
 
-  for (size_t i = 0; i < arraysize(kTitleSubtitlePairs); ++i) {
+  for (size_t i = 0; i < base::size(kTitleSubtitlePairs); ++i) {
     SCOPED_TRACE(testing::Message() << "Index: " << i);
     TitleSubtitlePair pair = kTitleSubtitlePairs[i];
     auto button = std::make_unique<HoverButton>(
diff --git a/chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos_unittest.cc b/chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos_unittest.cc
index c6004c78..3c63ad8 100644
--- a/chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos_unittest.cc
+++ b/chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos_unittest.cc
@@ -7,8 +7,8 @@
 #include <memory>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/ui/views/ime_driver/input_method_bridge_chromeos.h"
 #include "content/public/test/test_browser_thread_bundle.h"
@@ -184,7 +184,7 @@
   };
 
   // Send the Ctrl-Shift-U,3,4,0,2 sequence.
-  for (size_t i = 0; i < arraysize(kTestSequence); i++) {
+  for (size_t i = 0; i < base::size(kTestSequence); i++) {
     EXPECT_TRUE(ProcessKeyEvent(
         UnicodeKeyPress(kTestSequence[i].vkey, kTestSequence[i].code,
                         kTestSequence[i].flags, kTestSequence[i].character)));
diff --git a/chrome/browser/ui/views/infobars/infobar_view_unittest.cc b/chrome/browser/ui/views/infobars/infobar_view_unittest.cc
index 15b1b91..5e0fac3 100644
--- a/chrome/browser/ui/views/infobars/infobar_view_unittest.cc
+++ b/chrome/browser/ui/views/infobars/infobar_view_unittest.cc
@@ -6,7 +6,9 @@
 
 #include "chrome/browser/infobars/infobar_service.h"
 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
+#include "chrome/test/base/testing_profile.h"
+#include "chrome/test/views/chrome_views_test_base.h"
+#include "content/public/test/test_web_contents_factory.h"
 
 class TestInfoBarDelegate : public infobars::InfoBarDelegate {
  public:
@@ -20,27 +22,17 @@
   InfoBarIdentifier GetIdentifier() const override { return TEST_INFOBAR; }
 };
 
-class InfoBarViewTest : public BrowserWithTestWindowTest {
+class InfoBarViewTest : public ChromeViewsTestBase {
  public:
-  InfoBarViewTest() : infobar_container_view_(nullptr) {}
-  ~InfoBarViewTest() override = default;
-
-  // ChromeViewsTestBase:
-  void SetUp() override {
-    BrowserWithTestWindowTest::SetUp();
-
-    AddTab(browser(), GURL("about:blank"));
+  InfoBarViewTest()
+      : web_contents_(web_contents_factory_.CreateWebContents(&profile_)),
+        infobar_container_view_(nullptr) {
+    InfoBarService::CreateForWebContents(web_contents_);
     infobar_container_view_.ChangeInfoBarManager(infobar_service());
   }
 
-  void TearDown() override {
-    DetachContainer();
-    BrowserWithTestWindowTest::TearDown();
-  }
-
   InfoBarService* infobar_service() {
-    return InfoBarService::FromWebContents(
-        browser()->tab_strip_model()->GetWebContentsAt(0));
+    return InfoBarService::FromWebContents(web_contents_);
   }
 
   // Detaches |infobar_container_view_| from infobar_service(), so that newly-
@@ -51,9 +43,10 @@
   }
 
  private:
+  TestingProfile profile_;
+  content::TestWebContentsFactory web_contents_factory_;
+  content::WebContents* web_contents_;
   InfoBarContainerView infobar_container_view_;
-
-  DISALLOW_COPY_AND_ASSIGN(InfoBarViewTest);
 };
 
 TEST_F(InfoBarViewTest, ShouldDrawSeparator) {
diff --git a/chrome/browser/ui/views/keyboard_access_browsertest.cc b/chrome/browser/ui/views/keyboard_access_browsertest.cc
index b3573a7b..fd229c5 100644
--- a/chrome/browser/ui/views/keyboard_access_browsertest.cc
+++ b/chrome/browser/ui/views/keyboard_access_browsertest.cc
@@ -7,11 +7,11 @@
 // on the Mac, and it's not yet implemented on Linux.
 
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -262,9 +262,8 @@
   // then select the New Tab option from the menu.
   if (n_code == HCBT_ACTIVATE || n_code == HCBT_CREATEWND) {
     wchar_t class_name[MAX_PATH] = {0};
-    GetClassName(reinterpret_cast<HWND>(w_param),
-                 class_name,
-                 arraysize(class_name));
+    GetClassName(reinterpret_cast<HWND>(w_param), class_name,
+                 base::size(class_name));
     if (base::LowerCaseEqualsASCII(class_name, "#32768")) {
       // Select the New Tab option and then send the enter key to execute it.
       ::PostMessage(reinterpret_cast<HWND>(w_param), WM_CHAR, 'T', 0);
diff --git a/chrome/browser/ui/views/layout_provider_unittest.cc b/chrome/browser/ui/views/layout_provider_unittest.cc
index ba3974ad..a649af7 100644
--- a/chrome/browser/ui/views/layout_provider_unittest.cc
+++ b/chrome/browser/ui/views/layout_provider_unittest.cc
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_feature_list.h"
 #include "build/build_config.h"
@@ -290,7 +291,7 @@
                             {CONTEXT_BODY_TEXT_LARGE, 2, 4},
                             {CONTEXT_BODY_TEXT_SMALL, 4, 5}};
 
-  for (size_t i = 0; i < arraysize(kExpectedIncreases); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedIncreases); ++i) {
     SCOPED_TRACE(testing::Message() << "Testing index: " << i);
     const auto& increase = kExpectedIncreases[i];
     const gfx::FontList& font = views::style::GetFont(increase.context, kStyle);
@@ -331,7 +332,7 @@
                          {CONTEXT_BODY_TEXT_LARGE, kBodyLineHeight},
                          {CONTEXT_BODY_TEXT_SMALL, kBodyLineHeight}};
 
-  for (size_t i = 0; i < arraysize(kHarmonyHeights); ++i) {
+  for (size_t i = 0; i < base::size(kHarmonyHeights); ++i) {
     SCOPED_TRACE(testing::Message() << "Testing index: " << i);
     EXPECT_EQ(kHarmonyHeights[i].line_height,
               views::style::GetLineHeight(kHarmonyHeights[i].context, kStyle));
diff --git a/chrome/browser/ui/views/media_router/cast_toolbar_button_unittest.cc b/chrome/browser/ui/views/media_router/cast_toolbar_button_unittest.cc
index 396181c..5f0ed1b2 100644
--- a/chrome/browser/ui/views/media_router/cast_toolbar_button_unittest.cc
+++ b/chrome/browser/ui/views/media_router/cast_toolbar_button_unittest.cc
@@ -68,20 +68,17 @@
 
   void SetUp() override {
     ChromeViewsTestBase::SetUp();
-
-    profile_ = std::make_unique<TestingProfile>();
-
     MediaRouterFactory::GetInstance()->SetTestingFactory(
-        profile_.get(), base::BindRepeating(&MockMediaRouter::Create));
+        &profile_, base::BindRepeating(&MockMediaRouter::Create));
     MediaRouterUIServiceFactory::GetInstance()->SetTestingFactory(
-        profile_.get(), base::BindRepeating(&BuildUIService));
+        &profile_, base::BindRepeating(&BuildUIService));
 
     window_ = std::make_unique<TestBrowserWindow>();
-    Browser::CreateParams browser_params(profile_.get(), true);
+    Browser::CreateParams browser_params(&profile_, true);
     browser_params.window = window_.get();
     browser_ = std::make_unique<Browser>(browser_params);
     MediaRouter* media_router =
-        MediaRouterFactory::GetApiForBrowserContext(profile_.get());
+        MediaRouterFactory::GetApiForBrowserContext(&profile_);
     auto context_menu = std::make_unique<MediaRouterContextualMenu>(
         browser_.get(), true, false, &context_menu_observer_);
     button_ = std::make_unique<CastToolbarButton>(browser_.get(), media_router,
@@ -92,7 +89,6 @@
     button_.reset();
     browser_.reset();
     window_.reset();
-    profile_.reset();
     ChromeViewsTestBase::TearDown();
   }
 
@@ -105,7 +101,7 @@
   std::unique_ptr<Browser> browser_;
   std::unique_ptr<CastToolbarButton> button_;
   MockContextMenuObserver context_menu_observer_;
-  std::unique_ptr<TestingProfile> profile_;
+  TestingProfile profile_;
 
   const gfx::Image idle_icon_ =
       gfx::Image(gfx::CreateVectorIcon(vector_icons::kMediaRouterIdleIcon,
diff --git a/chrome/browser/ui/views/media_router/cloud_services_dialog_view_unittest.cc b/chrome/browser/ui/views/media_router/cloud_services_dialog_view_unittest.cc
index 3c82977..29255df 100644
--- a/chrome/browser/ui/views/media_router/cloud_services_dialog_view_unittest.cc
+++ b/chrome/browser/ui/views/media_router/cloud_services_dialog_view_unittest.cc
@@ -23,9 +23,8 @@
   void SetUp() override {
     ChromeViewsTestBase::SetUp();
 
-    profile_ = std::make_unique<TestingProfile>();
     window_ = std::make_unique<TestBrowserWindow>();
-    Browser::CreateParams browser_params(profile_.get(), true);
+    Browser::CreateParams browser_params(&profile_, true);
     browser_params.window = window_.get();
     browser_ = std::make_unique<Browser>(browser_params);
 
@@ -42,7 +41,6 @@
     anchor_widget_.reset();
     browser_.reset();
     window_.reset();
-    profile_.reset();
 
     ChromeViewsTestBase::TearDown();
   }
@@ -69,7 +67,7 @@
   std::unique_ptr<BrowserWindow> window_;
   std::unique_ptr<Browser> browser_;
   std::unique_ptr<views::Widget> anchor_widget_;
-  std::unique_ptr<TestingProfile> profile_;
+  TestingProfile profile_;
 };
 
 TEST_F(CloudServicesDialogViewTest, Enable) {
diff --git a/chrome/browser/ui/views/menu_interactive_uitest.cc b/chrome/browser/ui/views/menu_interactive_uitest.cc
index 1ed4e47..ff777d2 100644
--- a/chrome/browser/ui/views/menu_interactive_uitest.cc
+++ b/chrome/browser/ui/views/menu_interactive_uitest.cc
@@ -6,9 +6,7 @@
 #include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/strings/utf_string_conversions.h"
-#include "build/build_config.h"
 #include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/views/native_widget_factory.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chrome/test/base/interactive_test_utils.h"
 #include "chrome/test/base/test_browser_window.h"
@@ -19,6 +17,10 @@
 #include "ui/views/test/platform_test_helper.h"
 #include "ui/views/widget/widget.h"
 
+#if !defined(OS_CHROMEOS)
+#include "ui/views/test/native_widget_factory.h"
+#endif
+
 namespace views {
 namespace test {
 
@@ -76,11 +78,11 @@
   // Create a parent widget.
   Widget* widget = new views::Widget;
   Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
-  params.bounds = {0, 0, 200, 200};
-#if !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
-  params.native_widget = CreateNativeWidget(
-      NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA, &params, widget);
+#if !defined(OS_CHROMEOS)
+  params.native_widget = ::views::test::CreatePlatformDesktopNativeWidgetImpl(
+      params, widget, nullptr);
 #endif
+  params.bounds = {0, 0, 200, 200};
   widget->Init(params);
   widget->Show();
   widget->Activate();
diff --git a/chrome/browser/ui/views/message_center/popups_only_ui_delegate_unittest.cc b/chrome/browser/ui/views/message_center/popups_only_ui_delegate_unittest.cc
index 60393db..95ce00b0 100644
--- a/chrome/browser/ui/views/message_center/popups_only_ui_delegate_unittest.cc
+++ b/chrome/browser/ui/views/message_center/popups_only_ui_delegate_unittest.cc
@@ -33,12 +33,12 @@
 
 class PopupsOnlyUiDelegateTest : public views::test::WidgetTest {
  public:
-  PopupsOnlyUiDelegateTest() = default;
-  ~PopupsOnlyUiDelegateTest() override = default;
+  PopupsOnlyUiDelegateTest() {}
+  ~PopupsOnlyUiDelegateTest() override {}
 
   void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
     views::test::WidgetTest::SetUp();
+    test_views_delegate()->set_use_desktop_native_widgets(true);
     MessageCenter::Initialize();
   }
 
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_unittest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_unittest.cc
index c444adb..0fd2e65 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views_unittest.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_unittest.cc
@@ -247,8 +247,8 @@
   }
 
  private:
-  std::unique_ptr<TestingProfile> profile_;
-  std::unique_ptr<TemplateURLServiceFactoryTestUtil> util_;
+  TestingProfile profile_;
+  TemplateURLServiceFactoryTestUtil util_;
   CommandUpdaterImpl command_updater_;
   TestLocationBarModel location_bar_model_;
   TestingOmniboxEditController omnibox_edit_controller_;
@@ -266,6 +266,7 @@
 OmniboxViewViewsTest::OmniboxViewViewsTest(
     const std::vector<base::Feature>& enabled_features)
     : OmniboxViewViewsTestBase(enabled_features),
+      util_(&profile_),
       command_updater_(nullptr),
       omnibox_edit_controller_(&command_updater_, &location_bar_model_) {}
 
@@ -285,9 +286,6 @@
 void OmniboxViewViewsTest::SetUp() {
   ChromeViewsTestBase::SetUp();
 
-  profile_ = std::make_unique<TestingProfile>();
-  util_ = std::make_unique<TemplateURLServiceFactoryTestUtil>(profile_.get());
-
   // We need a widget so OmniboxView can be correctly focused and unfocused.
   widget_ = std::make_unique<views::Widget>();
   views::Widget::InitParams params =
@@ -302,12 +300,11 @@
       new chromeos::input_method::MockInputMethodManagerImpl);
 #endif
   AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse(
-      profile_.get(),
+      &profile_,
       base::BindRepeating(&AutocompleteClassifierFactory::BuildInstanceFor));
-  omnibox_view_ =
-      new TestingOmniboxView(&omnibox_edit_controller_,
-                             std::make_unique<ChromeOmniboxClient>(
-                                 &omnibox_edit_controller_, profile_.get()));
+  omnibox_view_ = new TestingOmniboxView(
+      &omnibox_edit_controller_, std::make_unique<ChromeOmniboxClient>(
+                                     &omnibox_edit_controller_, &profile_));
   test_api_ = std::make_unique<views::TextfieldTestApi>(omnibox_view_);
   omnibox_view_->Init();
 
@@ -320,8 +317,6 @@
     omnibox_view_->GetInputMethod()->DetachTextInputClient(omnibox_view_);
 
   widget_.reset();
-  util_.reset();
-  profile_.reset();
 
 #if defined(OS_CHROMEOS)
   chromeos::input_method::Shutdown();
diff --git a/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc b/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
index 1daec06..757752b 100644
--- a/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
+++ b/chrome/browser/ui/views/payments/payment_sheet_view_controller.cc
@@ -12,7 +12,7 @@
 #include <vector>
 
 #include "base/i18n/message_formatter.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -844,7 +844,7 @@
     } else if (state()->contact_profiles().size() == 1) {
       base::string16 truncated_content =
           state()->contact_profiles()[0]->ConstructInferredLabel(
-              kLabelFields, arraysize(kLabelFields), arraysize(kLabelFields),
+              kLabelFields, base::size(kLabelFields), base::size(kLabelFields),
               state()->GetApplicationLocale());
       return builder.CreateWithButton(truncated_content,
                                       l10n_util::GetStringUTF16(IDS_CHOOSE),
@@ -852,7 +852,7 @@
     } else {
       base::string16 preview =
           state()->contact_profiles()[0]->ConstructInferredLabel(
-              kLabelFields, arraysize(kLabelFields), arraysize(kLabelFields),
+              kLabelFields, base::size(kLabelFields), base::size(kLabelFields),
               state()->GetApplicationLocale());
       base::string16 format = l10n_util::GetPluralStringFUTF16(
           IDS_PAYMENT_REQUEST_CONTACTS_PREVIEW,
diff --git a/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc b/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc
index 021a196..e6dfab79 100644
--- a/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc
+++ b/chrome/browser/ui/views/settings_reset_prompt_dialog_browsertest.cc
@@ -12,7 +12,7 @@
 #include <vector>
 
 #include "base/callback.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
@@ -68,12 +68,12 @@
             profile,
             std::make_unique<NiceMock<MockSettingsResetPromptConfig>>(),
             std::make_unique<NiceMock<MockProfileResetter>>(profile)) {
-    EXPECT_LE(params.startup_pages, arraysize(kStartupUrls));
+    EXPECT_LE(params.startup_pages, base::size(kStartupUrls));
 
     // Set up startup URLs to be returned by member functions based on the
     // constructor arguments.
     for (size_t i = 0;
-         i < std::min(arraysize(kStartupUrls), params.startup_pages); ++i) {
+         i < std::min(base::size(kStartupUrls), params.startup_pages); ++i) {
       startup_urls_.push_back(GURL(kStartupUrls[i]));
     }
 
diff --git a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc
index 27a92271..4bd125e 100644
--- a/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc
+++ b/chrome/browser/ui/views/tabs/stacked_tab_strip_layout_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <string>
 
-#include "base/macros.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"
@@ -165,7 +165,7 @@
     { 0, 300, 100, 10, 1, 0, 6, "", "0 1 2 3 4 20 110 200" },
     { 0, 300, 100, 10, 1, 0, 4, "", "0 1 2 3 4 94 184 199 200" },
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i]);
     EXPECT_EQ(test_data[i].expected_bounds, BoundsString()) << " at " << i;
   }
@@ -273,7 +273,7 @@
     { { 0, 150, 100, 10, 2, 0, 2, "0 2 10 16 25 50", "0 2 11 17 26 50" }, 1 },
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     layout_->DragActiveTab(test_data[i].delta);
     EXPECT_EQ(test_data[i].common_data.expected_bounds, BoundsString()) <<
@@ -296,7 +296,7 @@
     { 0, 240, 100, 10, 2, 0, 1, "0 49 89 140", "0 49 89 139" },
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i]);
     SetBoundsFromString(test_data[i].expected_bounds);
     layout_->SizeToFit();
@@ -372,7 +372,7 @@
     { { 0, 200, 100, 10, 2, 0, 2, "0 2 10 100", "0 90 96 98 100"},
       0, true, false },
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     int add_types = 0;
     if (test_data[i].add_active)
@@ -429,7 +429,7 @@
     { { 0, 200, 100, 10, 2, 0, 0, "0 90 94 96 98 100", "0 90 94 96 100" },
       5, 0 },
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     int old_x = view_model_.ideal_bounds(test_data[i].remove_index).x();
     view_model_.Remove(test_data[i].remove_index);
@@ -523,7 +523,7 @@
     { { 0, 200, 100, 10, 2, 0, 2, "0 90 92 100", "0 2 78 80"}, 180 },
 
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     layout_->SetWidth(test_data[i].new_width);
     EXPECT_EQ(test_data[i].common_data.expected_bounds, BoundsString()) <<
@@ -544,7 +544,7 @@
     { { 4, 250, 100, 10, 2, 1, 2, "0 4 8 98 148 150", "0 4 94 146 148 150"},
       0 },
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     layout_->SetActiveIndex(test_data[i].new_index);
     EXPECT_EQ(test_data[i].common_data.expected_bounds, BoundsString()) <<
@@ -589,7 +589,7 @@
     { { 0, 200, 100, 10, 2, 0, 4, "0 2 4 6 96 98 100", "0 2 4 6 8 10 100" },
       0, 6, 6, 0, 0 },
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     view_model_.MoveViewOnly(test_data[i].from, test_data[i].to);
     for (int j = 0; j < test_data[i].new_pinned_tab_count; ++j) {
@@ -654,7 +654,7 @@
     // Location can be honored.
     { { 0, 300, 100, 10, 2, 0, 3, "", "0 2 4 40 130 198 200" }, 40 },
   };
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     CreateLayout(test_data[i].common_data);
     layout_->SetActiveTabLocation(test_data[i].location);
     EXPECT_EQ(test_data[i].common_data.expected_bounds, BoundsString()) <<
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
index cbcb0c60..72889559 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -15,11 +15,11 @@
 #include "base/callback_helpers.h"
 #include "base/command_line.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/bind_test_util.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -2356,7 +2356,7 @@
 };
 
 static_assert(
-    arraysize(kDragPoints) == arraysize(kDeviceScaleFactorExpectations),
+    base::size(kDragPoints) == base::size(kDeviceScaleFactorExpectations),
     "kDragPoints and kDeviceScaleFactorExpectations must have the same "
     "number of elements");
 
@@ -2368,7 +2368,7 @@
   ASSERT_FALSE(not_attached_tab_strip->IsDragSessionActive());
   ASSERT_TRUE(TabDragController::IsActive());
 
-  if (index < arraysize(kDragPoints)) {
+  if (index < base::size(kDragPoints)) {
     EXPECT_EQ(kDeviceScaleFactorExpectations[index],
               test->GetCursorDeviceScaleFactor());
     const DragPoint p = kDragPoints[index];
diff --git a/chrome/browser/ui/views/tabs/tab_strip_layout_unittest.cc b/chrome/browser/ui/views/tabs/tab_strip_layout_unittest.cc
index 7bfe839..39405f4 100644
--- a/chrome/browser/ui/views/tabs/tab_strip_layout_unittest.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip_layout_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/rect.h"
@@ -96,7 +96,7 @@
       {1, 3, 0, 0, 10, "0 10, 6 14, 16 14", 20, 14},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     int active_width;
     int inactive_width;
     std::vector<gfx::Rect> tabs_bounds = CalculateBounds(
diff --git a/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog.cc b/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog.cc
index bd0210ce..1f85a02 100644
--- a/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog.cc
+++ b/chrome/browser/ui/views/try_chrome_dialog_win/try_chrome_dialog.cc
@@ -11,6 +11,7 @@
 #include "base/bind.h"
 #include "base/logging.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/time/time.h"
 #include "cc/paint/paint_flags.h"
@@ -745,7 +746,7 @@
   POINT polygon[7];
   properties_->region_creator(window_size, dialog_bounds, arrow_bounds,
                               arrow_border_insets, &polygon[0]);
-  HRGN region = ::CreatePolygonRgn(&polygon[0], arraysize(polygon), WINDING);
+  HRGN region = ::CreatePolygonRgn(&polygon[0], base::size(polygon), WINDING);
   ::SetWindowRgn(hwnd, region, FALSE);
 }
 
@@ -964,7 +965,7 @@
 TryChromeDialog::Result TryChromeDialog::Show(
     size_t group,
     ActiveModalDialogListener listener) {
-  if (group >= arraysize(kExperiments)) {
+  if (group >= base::size(kExperiments)) {
     // Exit immediately given bogus values; see TryChromeDialogBrowserTest test.
     return NOT_NOW;
   }
@@ -990,7 +991,7 @@
     : group_(group),
       delegate_(delegate),
       context_(std::make_unique<Context>()) {
-  DCHECK_LT(group, arraysize(kExperiments));
+  DCHECK_LT(group, base::size(kExperiments));
   DCHECK(delegate);
 }
 
diff --git a/chrome/browser/ui/webui/chromeos/image_source.cc b/chrome/browser/ui/webui/chromeos/image_source.cc
index 7abfddc..5fe26023 100644
--- a/chrome/browser/ui/webui/chromeos/image_source.cc
+++ b/chrome/browser/ui/webui/chromeos/image_source.cc
@@ -11,10 +11,10 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/task/task_scheduler/task_scheduler.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -106,7 +106,7 @@
   if (components.empty())
     return false;
 
-  for (size_t i = 0; i < arraysize(kWhitelistedDirectories); i++) {
+  for (size_t i = 0; i < base::size(kWhitelistedDirectories); i++) {
     if (components[0] == kWhitelistedDirectories[i])
       return true;
   }
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc b/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
index 9940e69..a235ccc 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_userlist_unittest.cc
@@ -5,8 +5,8 @@
 #include <stddef.h>
 
 #include "base/compiler_specific.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "chrome/browser/chromeos/login/screens/user_selection_screen.h"
 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h"
@@ -56,11 +56,11 @@
         this, TestingBrowserProcess::GetGlobal()->local_state()));
     fake_user_manager_->set_multi_profile_user_controller(controller_.get());
 
-    for (size_t i = 0; i < arraysize(kUsersPublic); ++i)
+    for (size_t i = 0; i < base::size(kUsersPublic); ++i)
       fake_user_manager_->AddPublicAccountUser(
           AccountId::FromUserEmail(kUsersPublic[i]));
 
-    for (size_t i = 0; i < arraysize(kUsers); ++i)
+    for (size_t i = 0; i < base::size(kUsers); ++i)
       fake_user_manager_->AddUser(AccountId::FromUserEmail(kUsers[i]));
 
     fake_user_manager_->set_owner_id(AccountId::FromUserEmail(kOwner));
diff --git a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc
index 053b224..c472892 100644
--- a/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/user_image_screen_handler.cc
@@ -10,6 +10,7 @@
 #include "base/command_line.h"
 #include "base/logging.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
 #include "chrome/browser/chromeos/login/existing_user_controller.h"
@@ -142,7 +143,7 @@
   std::string raw_data;
   base::StringPiece url(image_url);
   const char kDataUrlPrefix[] = "data:image/png;base64,";
-  const size_t kDataUrlPrefixLength = arraysize(kDataUrlPrefix) - 1;
+  const size_t kDataUrlPrefixLength = base::size(kDataUrlPrefix) - 1;
   if (!url.starts_with(kDataUrlPrefix) ||
       !base::Base64Decode(url.substr(kDataUrlPrefixLength), &raw_data)) {
     LOG(WARNING) << "Invalid image URL";
diff --git a/chrome/browser/ui/webui/fileicon_source_unittest.cc b/chrome/browser/ui/webui/fileicon_source_unittest.cc
index f88d9940..83d32c97 100644
--- a/chrome/browser/ui/webui/fileicon_source_unittest.cc
+++ b/chrome/browser/ui/webui/fileicon_source_unittest.cc
@@ -3,8 +3,9 @@
 // found in the LICENSE file.
 
 #include "chrome/browser/ui/webui/fileicon_source.h"
-#include "base/macros.h"
+
 #include "base/memory/ref_counted_memory.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/browser/icon_manager.h"
 #include "chrome/browser/profiles/profile.h"
@@ -105,7 +106,7 @@
   ui::test::ScopedSetSupportedScaleFactors scoped_supported(
       supported_scale_factors);
 
-  for (unsigned i = 0; i < arraysize(kBasicExpectations); i++) {
+  for (unsigned i = 0; i < base::size(kBasicExpectations); i++) {
     std::unique_ptr<TestFileIconSource> source(CreateFileIconSource());
     content::URLDataSource::GotDataCallback callback;
     EXPECT_CALL(*source.get(),
diff --git a/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc b/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
index fc2a175..a9e5e26c 100644
--- a/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
+++ b/chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc
@@ -14,6 +14,7 @@
 #include "base/metrics/histogram_macros.h"
 #include "base/no_destructor.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
@@ -184,7 +185,7 @@
   std::string raw_data;
   base::StringPiece url(image_url);
   const char kDataUrlPrefix[] = "data:image/png;base64,";
-  const size_t kDataUrlPrefixLength = arraysize(kDataUrlPrefix) - 1;
+  const size_t kDataUrlPrefixLength = base::size(kDataUrlPrefix) - 1;
   if (!url.starts_with(kDataUrlPrefix) ||
       !base::Base64Decode(url.substr(kDataUrlPrefixLength), &raw_data)) {
     LOG(WARNING) << "Invalid image URL";
diff --git a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
index 9d871da..a85fb76 100644
--- a/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler.cc
@@ -8,9 +8,9 @@
 #include <vector>
 
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/browser/browsing_data/browsing_data_helper.h"
 #include "chrome/browser/browsing_data/browsing_data_important_sites_util.h"
@@ -239,7 +239,7 @@
         BrowsingDataType::FORM_DATA,      BrowsingDataType::HOSTED_APPS_DATA,
         BrowsingDataType::MEDIA_LICENSES,
     };
-    static size_t num_other_types = arraysize(other_types);
+    static size_t num_other_types = base::size(other_types);
     int checked_other_types =
         std::count_if(other_types, other_types + num_other_types,
                       [&data_types](BrowsingDataType type) {
diff --git a/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc b/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
index cf169a42..2af0d2c1 100644
--- a/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_cookies_view_handler.cc
@@ -12,7 +12,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/i18n/number_formatting.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
@@ -104,7 +104,7 @@
   };
   // Before optimizing, consider the data size and the cost of L2 cache misses.
   // A linear search over a couple dozen integers is very fast.
-  for (size_t i = 0; i < arraysize(kCategoryLabels); ++i) {
+  for (size_t i = 0; i < base::size(kCategoryLabels); ++i) {
     if (kCategoryLabels[i].node_type == node_type) {
       return kCategoryLabels[i].id;
     }
diff --git a/chrome/browser/ui/webui/site_settings_helper.cc b/chrome/browser/ui/webui/site_settings_helper.cc
index 88e00f02..c0035d64 100644
--- a/chrome/browser/ui/webui/site_settings_helper.cc
+++ b/chrome/browser/ui/webui/site_settings_helper.cc
@@ -10,6 +10,7 @@
 #include <string>
 
 #include "base/feature_list.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
 #include "chrome/browser/permissions/chooser_context_base.h"
@@ -102,7 +103,7 @@
     {CONTENT_SETTINGS_TYPE_BACKGROUND_FETCH, nullptr},
     {CONTENT_SETTINGS_TYPE_INTENT_PICKER_DISPLAY, nullptr},
 };
-static_assert(arraysize(kContentSettingsTypeGroupNames) ==
+static_assert(base::size(kContentSettingsTypeGroupNames) ==
                   // ContentSettingsType starts at -1, so add 1 here.
                   static_cast<int>(CONTENT_SETTINGS_NUM_TYPES) + 1,
               "kContentSettingsTypeGroupNames should have "
@@ -124,7 +125,7 @@
     {SiteSettingSource::kPolicy, "policy"},
     {SiteSettingSource::kPreference, "preference"},
 };
-static_assert(arraysize(kSiteSettingSourceStringMapping) ==
+static_assert(base::size(kSiteSettingSourceStringMapping) ==
                   static_cast<int>(SiteSettingSource::kNumSources),
               "kSiteSettingSourceStringMapping should have "
               "SiteSettingSource::kNumSources elements");
@@ -214,7 +215,7 @@
 }  // namespace
 
 bool HasRegisteredGroupName(ContentSettingsType type) {
-  for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
+  for (size_t i = 0; i < base::size(kContentSettingsTypeGroupNames); ++i) {
     if (type == kContentSettingsTypeGroupNames[i].type &&
         kContentSettingsTypeGroupNames[i].name != nullptr) {
       return true;
@@ -224,7 +225,7 @@
 }
 
 ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
-  for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
+  for (size_t i = 0; i < base::size(kContentSettingsTypeGroupNames); ++i) {
     if (name == kContentSettingsTypeGroupNames[i].name)
       return kContentSettingsTypeGroupNames[i].type;
   }
@@ -234,7 +235,7 @@
 }
 
 std::string ContentSettingsTypeToGroupName(ContentSettingsType type) {
-  for (size_t i = 0; i < arraysize(kContentSettingsTypeGroupNames); ++i) {
+  for (size_t i = 0; i < base::size(kContentSettingsTypeGroupNames); ++i) {
     if (type == kContentSettingsTypeGroupNames[i].type) {
       const char* name = kContentSettingsTypeGroupNames[i].name;
       if (name != nullptr)
diff --git a/chrome/browser/vr/elements/controller.cc b/chrome/browser/vr/elements/controller.cc
index 6a28a82..f742674 100644
--- a/chrome/browser/vr/elements/controller.cc
+++ b/chrome/browser/vr/elements/controller.cc
@@ -5,6 +5,7 @@
 #include "chrome/browser/vr/elements/controller.h"
 
 #include "base/numerics/math_constants.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "cc/animation/keyframed_animation_curve.h"
 #include "chrome/browser/vr/ui_element_renderer.h"
@@ -278,9 +279,9 @@
   opacity_handle_ = glGetUniformLocation(program_handle_, "u_Opacity");
 
   auto body_alpha_curve =
-      CreateAlphaCurve(kBodyAlphaStops, arraysize(kBodyAlphaStops));
+      CreateAlphaCurve(kBodyAlphaStops, base::size(kBodyAlphaStops));
   auto top_alpha_curve =
-      CreateAlphaCurve(kTopAlphaStops, arraysize(kTopAlphaStops));
+      CreateAlphaCurve(kTopAlphaStops, base::size(kTopAlphaStops));
 
   gfx::Transform transform;
   transform.Translate3d(0.0, 0.0, (kControllerLength - kControllerWidth) / 2);
diff --git a/chrome/browser/vr/elements/draw_phase.cc b/chrome/browser/vr/elements/draw_phase.cc
index ec8ad62..1dbf9a41 100644
--- a/chrome/browser/vr/elements/draw_phase.cc
+++ b/chrome/browser/vr/elements/draw_phase.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/browser/vr/elements/draw_phase.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace vr {
 
@@ -16,7 +16,7 @@
 };
 
 static_assert(
-    kNumDrawPhases + 1 == arraysize(g_draw_phase_strings),
+    kNumDrawPhases + 1 == base::size(g_draw_phase_strings),
     "Mismatch between the DrawPhase enum and the corresponding strings");
 
 }  // namespace
diff --git a/chrome/browser/vr/elements/environment/stars.cc b/chrome/browser/vr/elements/environment/stars.cc
index 4471369..26ef20b 100644
--- a/chrome/browser/vr/elements/environment/stars.cc
+++ b/chrome/browser/vr/elements/environment/stars.cc
@@ -6,6 +6,7 @@
 
 #include "base/numerics/math_constants.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "chrome/browser/vr/ui_element_renderer.h"
 #include "chrome/browser/vr/ui_scene_constants.h"
 #include "chrome/browser/vr/vr_gl_util.h"
@@ -120,7 +121,7 @@
   glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_);
 
-  glDrawElements(GL_TRIANGLES, arraysize(g_indices), GL_UNSIGNED_SHORT, 0);
+  glDrawElements(GL_TRIANGLES, base::size(g_indices), GL_UNSIGNED_SHORT, 0);
 
   glDisableVertexAttribArray(position_handle_);
   glDisableVertexAttribArray(opacity_handle_);
@@ -185,12 +186,13 @@
   index_buffer_ = buffers[1];
 
   glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
-  glBufferData(GL_ARRAY_BUFFER, arraysize(g_vertices) * sizeof(float),
+  glBufferData(GL_ARRAY_BUFFER, base::size(g_vertices) * sizeof(float),
                g_vertices, GL_STATIC_DRAW);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_);
-  glBufferData(GL_ELEMENT_ARRAY_BUFFER, arraysize(g_indices) * sizeof(GLushort),
-               g_indices, GL_STATIC_DRAW);
+  glBufferData(GL_ELEMENT_ARRAY_BUFFER,
+               base::size(g_indices) * sizeof(GLushort), g_indices,
+               GL_STATIC_DRAW);
 }
 
 }  // namespace vr
diff --git a/chrome/browser/vr/elements/ui_element_name.cc b/chrome/browser/vr/elements/ui_element_name.cc
index 187e5cc..c565b56 100644
--- a/chrome/browser/vr/elements/ui_element_name.cc
+++ b/chrome/browser/vr/elements/ui_element_name.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/vr/elements/ui_element_name.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace vr {
 
@@ -150,7 +150,7 @@
 };
 
 static_assert(
-    kNumUiElementNames == arraysize(g_ui_element_name_strings),
+    kNumUiElementNames == base::size(g_ui_element_name_strings),
     "Mismatch between the kUiElementName enum and the corresponding array "
     "of strings.");
 
diff --git a/chrome/browser/vr/elements/ui_element_type.cc b/chrome/browser/vr/elements/ui_element_type.cc
index 322e1d4..b9ab201 100644
--- a/chrome/browser/vr/elements/ui_element_type.cc
+++ b/chrome/browser/vr/elements/ui_element_type.cc
@@ -5,7 +5,7 @@
 #include "chrome/browser/vr/elements/ui_element_type.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace vr {
 
@@ -50,7 +50,7 @@
 };
 
 static_assert(
-    kNumUiElementTypes == arraysize(g_ui_element_type_strings),
+    kNumUiElementTypes == base::size(g_ui_element_type_strings),
     "Mismatch between the kUiElementType enum and the corresponding array "
     "of strings.");
 
diff --git a/chrome/browser/vr/renderers/base_quad_renderer.cc b/chrome/browser/vr/renderers/base_quad_renderer.cc
index 0e98c4c9e..aff8ff26 100644
--- a/chrome/browser/vr/renderers/base_quad_renderer.cc
+++ b/chrome/browser/vr/renderers/base_quad_renderer.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/vr/renderers/base_quad_renderer.h"
 
+#include "base/stl_util.h"
 #include "chrome/browser/vr/vr_gl_util.h"
 #include "ui/gfx/transform.h"
 
@@ -51,17 +52,17 @@
   index_buffer_ = buffers[1];
 
   glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
-  glBufferData(GL_ARRAY_BUFFER, arraysize(kQuadVertices) * sizeof(float),
+  glBufferData(GL_ARRAY_BUFFER, base::size(kQuadVertices) * sizeof(float),
                kQuadVertices, GL_STATIC_DRAW);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_);
   glBufferData(GL_ELEMENT_ARRAY_BUFFER,
-               arraysize(kQuadIndices) * sizeof(GLushort), kQuadIndices,
+               base::size(kQuadIndices) * sizeof(GLushort), kQuadIndices,
                GL_STATIC_DRAW);
 }
 
 int BaseQuadRenderer::NumQuadIndices() {
-  return arraysize(kQuadIndices);
+  return base::size(kQuadIndices);
 }
 
 }  // namespace vr
diff --git a/chrome/browser/vr/renderers/textured_quad_renderer.cc b/chrome/browser/vr/renderers/textured_quad_renderer.cc
index e95ff45..b9af5339 100644
--- a/chrome/browser/vr/renderers/textured_quad_renderer.cc
+++ b/chrome/browser/vr/renderers/textured_quad_renderer.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/vr/renderers/textured_quad_renderer.h"
 
+#include "base/stl_util.h"
 #include "chrome/browser/vr/vr_gl_util.h"
 #include "ui/gfx/transform.h"
 
@@ -320,7 +321,7 @@
       glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
                      VOID_OFFSET(kInnerRectOffset));
     } else {
-      glDrawElements(GL_TRIANGLES, arraysize(kIndices), GL_UNSIGNED_SHORT, 0);
+      glDrawElements(GL_TRIANGLES, base::size(kIndices), GL_UNSIGNED_SHORT, 0);
     }
 
     quad_queue_.pop();
@@ -346,11 +347,11 @@
   index_buffer_ = buffers[1];
 
   glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer_);
-  glBufferData(GL_ARRAY_BUFFER, arraysize(kVertices) * sizeof(float), kVertices,
-               GL_STATIC_DRAW);
+  glBufferData(GL_ARRAY_BUFFER, base::size(kVertices) * sizeof(float),
+               kVertices, GL_STATIC_DRAW);
 
   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer_);
-  glBufferData(GL_ELEMENT_ARRAY_BUFFER, arraysize(kIndices) * sizeof(GLushort),
+  glBufferData(GL_ELEMENT_ARRAY_BUFFER, base::size(kIndices) * sizeof(GLushort),
                kIndices, GL_STATIC_DRAW);
 }
 
@@ -371,7 +372,7 @@
 }
 
 int TexturedQuadRenderer::NumQuadIndices() {
-  return arraysize(kIndices);
+  return base::size(kIndices);
 }
 
 }  // namespace vr
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc
index 83be24e..dd89c5ae 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -14,6 +14,7 @@
 #include "base/path_service.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -99,9 +100,8 @@
   const char* kSwitchNames[] = { switches::kUserDataDir };
   const base::CommandLine& command_line =
       *base::CommandLine::ForCurrentProcess();
-  shell_link->GetCommandLine()->CopySwitchesFrom(command_line,
-                                                 kSwitchNames,
-                                                 arraysize(kSwitchNames));
+  shell_link->GetCommandLine()->CopySwitchesFrom(command_line, kSwitchNames,
+                                                 base::size(kSwitchNames));
 }
 
 // Creates a ShellLinkItem preloaded with common switches.
diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc
index c54f40f..e0a8398 100644
--- a/chrome/common/crash_keys.cc
+++ b/chrome/common/crash_keys.cc
@@ -7,7 +7,7 @@
 #include "base/base_switches.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.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"
@@ -69,7 +69,7 @@
     return false;
   size_t end = flag.find("=");
   size_t len = (end == std::string::npos) ? flag.length() - 2 : end - 2;
-  for (size_t i = 0; i < arraysize(kIgnoreSwitches); ++i) {
+  for (size_t i = 0; i < base::size(kIgnoreSwitches); ++i) {
     if (flag.compare(2, len, kIgnoreSwitches[i]) == 0)
       return true;
   }
@@ -99,7 +99,7 @@
   };
 
   auto it = extensions.begin();
-  for (size_t i = 0; i < arraysize(extension_ids); ++i) {
+  for (size_t i = 0; i < base::size(extension_ids); ++i) {
     if (it == extensions.end()) {
       extension_ids[i].Clear();
     } else {
diff --git a/chrome/common/extensions/api/common_extension_api_unittest.cc b/chrome/common/extensions/api/common_extension_api_unittest.cc
index 5e95e482..c47862a 100644
--- a/chrome/common/extensions/api/common_extension_api_unittest.cc
+++ b/chrome/common/extensions/api/common_extension_api_unittest.cc
@@ -13,9 +13,9 @@
 
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "chrome/common/chrome_paths.h"
@@ -90,7 +90,7 @@
     { &empty_instance, false }
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     EXPECT_EQ(test_data[i].expect_populated,
               test_data[i].api->GetSchema("bookmarks.create") != nullptr);
   }
@@ -108,7 +108,7 @@
                    {"foo:bar", "foo", "bar"},
                    {"foo:bar.baz", "foo", "bar.baz"}};
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     std::string feature_type;
     std::string feature_name;
     ExtensionAPI::SplitDependencyName(
@@ -195,7 +195,7 @@
   FeatureProvider api_feature_provider;
   AddUnittestAPIFeatures(&api_feature_provider);
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     TestExtensionAPI api;
     api.RegisterDependencyProvider("api", &api_feature_provider);
     for (auto* key : kTestFeatures)
@@ -320,7 +320,7 @@
   FeatureProvider api_feature_provider;
   AddUnittestAPIFeatures(&api_feature_provider);
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     TestExtensionAPI api;
     api.RegisterDependencyProvider("api", &api_feature_provider);
     for (auto* key : kTestFeatures)
@@ -739,7 +739,7 @@
 
   std::unique_ptr<ExtensionAPI> api(
       ExtensionAPI::CreateWithDefaultConfiguration());
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     std::string child_name;
     std::string api_name = api->GetAPINameFromFullName(test_data[i].input,
                                                        &child_name);
@@ -763,7 +763,7 @@
     // TODO(aa): More stuff to test over time.
   } test_data[] = {{browser_action}, {browser_action_set_title}};
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     const SimpleFeature* feature = test_data[i].feature;
     ASSERT_TRUE(feature) << i;
 
@@ -916,7 +916,7 @@
       ExtensionAPI::CreateWithDefaultConfiguration());
   scoped_refptr<const Extension> extension = ExtensionBuilder("Test").Build();
 
-  for (size_t i = 0; i < arraysize(kTests); ++i) {
+  for (size_t i = 0; i < base::size(kTests); ++i) {
     EXPECT_EQ(kTests[i].expect_success,
               extension_api
                   ->IsAvailable(kTests[i].permission_name, extension.get(),
diff --git a/chrome/common/extensions/api/file_browser_handlers/file_browser_handler_manifest_unittest.cc b/chrome/common/extensions/api/file_browser_handlers/file_browser_handler_manifest_unittest.cc
index 84385e5..9145bb5 100644
--- a/chrome/common/extensions/api/file_browser_handlers/file_browser_handler_manifest_unittest.cc
+++ b/chrome/common/extensions/api/file_browser_handlers/file_browser_handler_manifest_unittest.cc
@@ -5,7 +5,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handler.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
@@ -96,7 +96,7 @@
       Testcase("filebrowser_invalid_file_filters_url.json",
                extensions::ErrorUtils::FormatErrorMessage(
                    errors::kInvalidURLPatternError, "http:*.html"))};
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
   RunTestcase(Testcase("filebrowser_missing_permission.json",
                        errors::kInvalidFileBrowserHandlerMissingPermission),
               EXPECT_TYPE_WARNING);
diff --git a/chrome/common/extensions/command_unittest.cc b/chrome/common/extensions/command_unittest.cc
index 02d5796..be69b6649 100644
--- a/chrome/common/extensions/command_unittest.cc
+++ b/chrome/common/extensions/command_unittest.cc
@@ -9,7 +9,6 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
 #include "base/optional.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
@@ -226,7 +225,7 @@
   all_platforms.push_back("mac");
   all_platforms.push_back("windows");
 
-  for (size_t i = 0; i < arraysize(kTests); ++i)
+  for (size_t i = 0; i < base::size(kTests); ++i)
     CheckParse(kTests[i], i, false, all_platforms);
 }
 
@@ -330,7 +329,7 @@
 
   std::vector<std::string> chromeos;
   chromeos.push_back("chromeos");
-  for (size_t i = 0; i < arraysize(kChromeOsTests); ++i)
+  for (size_t i = 0; i < base::size(kChromeOsTests); ++i)
     CheckParse(kChromeOsTests[i], i, true, chromeos);
 
   ConstCommandsTestData kNonChromeOsSearchTests[] = {
@@ -342,7 +341,7 @@
   non_chromeos.push_back("mac");
   non_chromeos.push_back("linux");
 
-  for (size_t i = 0; i < arraysize(kNonChromeOsSearchTests); ++i)
+  for (size_t i = 0; i < base::size(kNonChromeOsSearchTests); ++i)
     CheckParse(kNonChromeOsSearchTests[i], i, true, non_chromeos);
 }
 
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 2991f0a..09fe282 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -6,8 +6,8 @@
 
 #include "base/files/file_util.h"
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -271,9 +271,9 @@
   scoped_refptr<Extension> extension = LoadManifestStrict("empty_manifest",
       "empty.json");
   EXPECT_TRUE(extension.get());
-  for (size_t i = 0; i < arraysize(valid_path_test_cases); ++i)
+  for (size_t i = 0; i < base::size(valid_path_test_cases); ++i)
     EXPECT_TRUE(!extension->GetResource(valid_path_test_cases[i]).empty());
-  for (size_t i = 0; i < arraysize(invalid_path_test_cases); ++i)
+  for (size_t i = 0; i < base::size(invalid_path_test_cases); ++i)
     EXPECT_TRUE(extension->GetResource(invalid_path_test_cases[i]).empty());
 }
 
diff --git a/chrome/common/extensions/manifest_handlers/app_theme_color_manifest_unittest.cc b/chrome/common/extensions/manifest_handlers/app_theme_color_manifest_unittest.cc
index f70691c..92e4705 100644
--- a/chrome/common/extensions/manifest_handlers/app_theme_color_manifest_unittest.cc
+++ b/chrome/common/extensions/manifest_handlers/app_theme_color_manifest_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/extension.h"
 #include "extensions/common/manifest_constants.h"
@@ -17,20 +17,20 @@
       Testcase("theme_color.json", std::string(),
                extensions::Manifest::INTERNAL, Extension::FROM_BOOKMARK),
   };
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_SUCCESS);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_SUCCESS);
 
   Testcase failure_testcases[] = {
       Testcase("theme_color_wrong_type.json",
                extensions::manifest_errors::kInvalidAppThemeColor),
   };
-  RunTestcases(failure_testcases, arraysize(failure_testcases),
+  RunTestcases(failure_testcases, base::size(failure_testcases),
                EXPECT_TYPE_ERROR);
 
   Testcase warning_testcases[] = {
       Testcase("theme_color.json",
                extensions::manifest_errors::kInvalidThemeColorAppType),
   };
-  RunTestcases(warning_testcases, arraysize(warning_testcases),
+  RunTestcases(warning_testcases, base::size(warning_testcases),
                EXPECT_TYPE_WARNING);
 }
 
diff --git a/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc b/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc
index 7ad8af9..6293f37 100644
--- a/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc
+++ b/chrome/common/extensions/manifest_handlers/content_scripts_manifest_unittest.cc
@@ -4,8 +4,8 @@
 
 #include "base/command_line.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
@@ -39,8 +39,7 @@
                ErrorUtils::FormatErrorMessage(
                    errors::kInvalidMatch, base::IntToString(0),
                    base::IntToString(0), errors::kExpectString))};
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 
   LoadAndExpectSuccess("ports_in_content_scripts.json");
 }
diff --git a/chrome/common/extensions/manifest_handlers/exclude_matches_manifest_unittest.cc b/chrome/common/extensions/manifest_handlers/exclude_matches_manifest_unittest.cc
index 0e699d4f..f3dbc6d 100644
--- a/chrome/common/extensions/manifest_handlers/exclude_matches_manifest_unittest.cc
+++ b/chrome/common/extensions/manifest_handlers/exclude_matches_manifest_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/extension.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -17,8 +17,7 @@
     Testcase("exclude_matches.json"),
     Testcase("exclude_matches_empty.json")
   };
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_SUCCESS);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_SUCCESS);
 
   Testcase testcases2[] = {
     Testcase("exclude_matches_not_list.json",
@@ -27,8 +26,7 @@
              "Invalid value for 'content_scripts[0].exclude_matches[0]': "
                  "Invalid host wildcard.")
   };
-  RunTestcases(testcases2, arraysize(testcases2),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases2, base::size(testcases2), EXPECT_TYPE_ERROR);
 }
 
 }  // namespace extensions
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_about_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_about_unittest.cc
index 3407e3b..88b89ddf 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_about_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_about_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/manifest_constants.h"
 #include "extensions/common/manifest_url_handlers.h"
@@ -26,5 +26,5 @@
       // Forbid absolute URLs.
       Testcase("shared_module_about_absolute.json",
                errors::kInvalidAboutPageExpectRelativePath)};
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc
index 7acb0af..8828b6d 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_contentsecuritypolicy_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/error_utils.h"
 #include "extensions/common/manifest_constants.h"
@@ -26,5 +26,5 @@
       Testcase("insecure_contentsecuritypolicy_3.json",
                ErrorUtils::FormatErrorMessage(
                    errors::kInvalidCSPMissingSecureSrc, "object-src"))};
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_WARNING);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_WARNING);
 }
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc
index a0dd367..7bc29b6b 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_homepage_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/extension.h"
@@ -27,8 +27,7 @@
     Testcase("homepage_bad_schema.json",
              errors::kInvalidHomepageURL)
   };
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(HomepageURLManifestTest, GetHomepageURL) {
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
index 15ab8ea..d6cd935 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
@@ -4,8 +4,8 @@
 
 #include "base/command_line.h"
 #include "base/i18n/rtl.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
@@ -87,8 +87,7 @@
       Testcase("init_invalid_short_name_type.json", errors::kInvalidShortName),
   };
 
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(InitValueManifestTest, InitFromValueValid) {
@@ -147,8 +146,7 @@
     Testcase("init_valid_permissions_unknown.json")
   };
 
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_SUCCESS);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_SUCCESS);
 }
 
 TEST_F(InitValueManifestTest, InitFromValueValidNameInRTL) {
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
index 96d5546d..e9e7c26 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
@@ -66,8 +66,7 @@
                  errors::kInvalidLaunchValue,
                  keys::kLaunchHeight))
   };
-  RunTestcases(testcases, arraysize(testcases),
-      EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(AppLaunchManifestTest, AppLaunchURL) {
@@ -105,8 +104,7 @@
                  errors::kInvalidLaunchValue,
                  keys::kLaunchWebURL))
   };
-  RunTestcases(testcases, arraysize(testcases),
-      EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 
   scoped_refptr<Extension> extension;
   extension = LoadAndExpectSuccess("launch_local_path.json");
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc
index a0d030ab..d52c2c9 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/error_utils.h"
@@ -90,8 +90,7 @@
     Testcase("packaged_app_absolute_options.json",
              errors::kInvalidOptionsPageExpectUrlInPackage)
   };
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 // Tests for the options_ui.page manifest field.
@@ -112,7 +111,7 @@
 
   Testcase testcases[] = {Testcase("options_ui_page_bad_url.json",
                                    "'page': expected page, got null")};
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_WARNING);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_WARNING);
 }
 
 // Runs TestOptionsUIChromeStyleAndOpenInTab with and without the
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc
index a04d08a..f3df018 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_override_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/chrome_manifest_url_handlers.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/manifest_constants.h"
@@ -18,8 +18,7 @@
     Testcase("override_newtab_and_history.json", errors::kMultipleOverrides),
     Testcase("override_invalid_page.json", errors::kInvalidChromeURLOverrides)
   };
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 
   scoped_refptr<extensions::Extension> extension;
 
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
index 917c3da..d6f2436 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
@@ -6,7 +6,7 @@
 
 #include "base/command_line.h"
 #include "base/json/json_file_value_serializer.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/error_utils.h"
 #include "extensions/common/features/simple_feature.h"
@@ -44,7 +44,7 @@
              ErrorUtils::FormatErrorMessage(
                  errors::kInvalidManifestVersionOld, "2", "apps")),
   };
-  RunTestcases(error_testcases, arraysize(error_testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(error_testcases, base::size(error_testcases), EXPECT_TYPE_ERROR);
 
   Testcase warning_testcases[] = {
       Testcase(
@@ -64,8 +64,8 @@
                "apps, "
                "but this is a packaged app."),
   };
-  RunTestcases(
-      warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING);
+  RunTestcases(warning_testcases, base::size(warning_testcases),
+               EXPECT_TYPE_WARNING);
 }
 
 TEST_F(PlatformAppsManifestTest, PlatformAppContentSecurityPolicy) {
@@ -80,8 +80,8 @@
         "'app.content_security_policy' is not allowed for specified extension "
             "ID.")
   };
-  RunTestcases(
-      warning_testcases, arraysize(warning_testcases), EXPECT_TYPE_WARNING);
+  RunTestcases(warning_testcases, base::size(warning_testcases),
+               EXPECT_TYPE_WARNING);
 
   // Allowlisted ones can (this is the ID corresponding to the base 64 encoded
   // key in the init_platform_app_csp.json manifest.)
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc
index 7b56ef53e..bd7e5aa 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_requirements_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/error_utils.h"
 #include "extensions/common/manifest_constants.h"
@@ -35,7 +35,7 @@
                  errors::kInvalidRequirement, "3D")),
   };
 
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(RequirementsManifestTest, RequirementsValid) {
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc
index 4e07ef3..383b8f4 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_update_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 #include "extensions/common/manifest_constants.h"
 #include "extensions/common/manifest_url_handlers.h"
@@ -27,8 +27,7 @@
     Testcase("update_url_valid_4.json", extensions::Manifest::INTERNAL,
              Extension::NO_FLAGS)
   };
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_SUCCESS);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_SUCCESS);
 
   // Test some invalid update urls
   Testcase testcases2[] = {
@@ -39,6 +38,5 @@
     Testcase("update_url_invalid_3.json", errors::kInvalidUpdateURL,
              extensions::Manifest::INTERNAL, Extension::NO_FLAGS)
   };
-  RunTestcases(testcases2, arraysize(testcases2),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases2, base::size(testcases2), EXPECT_TYPE_ERROR);
 }
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_web_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_web_unittest.cc
index 248caa2..eb9398bb 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_web_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_web_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "extensions/common/error_utils.h"
@@ -40,8 +40,7 @@
                ErrorUtils::FormatErrorMessage(
                    errors::kInvalidWebURL, base::IntToString(1),
                    errors::kCannotClaimAllHostsInExtent))};
-  RunTestcases(testcases, arraysize(testcases),
-               EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 
   LoadAndExpectSuccess("web_urls_has_port.json");
 
diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc
index f81d03f..8dbb2e3 100644
--- a/chrome/common/extensions/permissions/permission_set_unittest.cc
+++ b/chrome/common/extensions/permissions/permission_set_unittest.cc
@@ -10,8 +10,8 @@
 #include "base/command_line.h"
 #include "base/json/json_file_value_serializer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -688,7 +688,7 @@
       {"sockets3", true},           // tcp:a.com:80 -> tcp:*:*
   };
 
-  for (size_t i = 0; i < arraysize(kTests); ++i) {
+  for (size_t i = 0; i < base::size(kTests); ++i) {
     scoped_refptr<Extension> old_extension(
         LoadManifest("allow_silent_upgrade",
                      std::string(kTests[i].base_name) + "_old.json"));
diff --git a/chrome/common/importer/firefox_importer_utils_unittest.cc b/chrome/common/importer/firefox_importer_utils_unittest.cc
index 6ac9159..6fdf99d 100644
--- a/chrome/common/importer/firefox_importer_utils_unittest.cc
+++ b/chrome/common/importer/firefox_importer_utils_unittest.cc
@@ -8,7 +8,7 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/grit/generated_resources.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -96,7 +96,7 @@
 }  // anonymous namespace
 
 TEST(FirefoxImporterUtilsTest, GetPrefsJsValue) {
-  for (size_t i = 0; i < arraysize(GetPrefsJsValueCases); ++i) {
+  for (size_t i = 0; i < base::size(GetPrefsJsValueCases); ++i) {
     EXPECT_EQ(
       GetPrefsJsValueCases[i].pref_value,
       GetPrefsJsValue(GetPrefsJsValueCases[i].prefs_content,
@@ -109,7 +109,7 @@
   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
   const base::FilePath app_ini_file(
       temp_dir.GetPath().AppendASCII("application.ini"));
-  for (size_t i = 0; i < arraysize(GetFirefoxImporterNameCases); ++i) {
+  for (size_t i = 0; i < base::size(GetFirefoxImporterNameCases); ++i) {
     base::WriteFile(app_ini_file,
                     GetFirefoxImporterNameCases[i].app_ini_content.c_str(),
                     GetFirefoxImporterNameCases[i].app_ini_content.size());
diff --git a/chrome/common/mac/cfbundle_blocker.mm b/chrome/common/mac/cfbundle_blocker.mm
index ed2fb47..e9795a05 100644
--- a/chrome/common/mac/cfbundle_blocker.mm
+++ b/chrome/common/mac/cfbundle_blocker.mm
@@ -14,7 +14,7 @@
 #include "base/mac/scoped_cftyperef.h"
 #include "base/mac/scoped_nsautorelease_pool.h"
 #import "base/mac/scoped_nsobject.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "third_party/mach_override/mach_override.h"
 
@@ -59,8 +59,8 @@
       // printer drivers or Internet plugins.
     };
 
-    NSUInteger blocked_paths_count = [blocked_prefixes count] *
-                                     arraysize(blocked_suffixes);
+    NSUInteger blocked_paths_count =
+        [blocked_prefixes count] * base::size(blocked_suffixes);
 
     // Not autoreleased here, because the enclosing pool is scoped too
     // narrowly.
@@ -70,7 +70,7 @@
     // Build a flat list by adding each suffix to each prefix.
     for (NSString* blocked_prefix in blocked_prefixes) {
       for (size_t blocked_suffix_index = 0;
-           blocked_suffix_index < arraysize(blocked_suffixes);
+           blocked_suffix_index < base::size(blocked_suffixes);
            ++blocked_suffix_index) {
         NSString* blocked_suffix = blocked_suffixes[blocked_suffix_index];
         NSString* blocked_path =
@@ -264,7 +264,7 @@
     { @"com.surteesstudios.BartenderHelperBundle", @"1.2.20" },
   };
 
-  for (size_t index = 0; index < arraysize(kAllowedBundles); ++index) {
+  for (size_t index = 0; index < base::size(kAllowedBundles); ++index) {
     const AllowedBundle& allowed_bundle = kAllowedBundles[index];
     NSString* allowed_bundle_id = allowed_bundle.bundle_id;
     NSUInteger allowed_bundle_id_length = [allowed_bundle_id length];
diff --git a/chrome/common/mac/cfbundle_blocker_unittest.mm b/chrome/common/mac/cfbundle_blocker_unittest.mm
index c225aa1..c19138e 100644
--- a/chrome/common/mac/cfbundle_blocker_unittest.mm
+++ b/chrome/common/mac/cfbundle_blocker_unittest.mm
@@ -8,7 +8,7 @@
 #import <Foundation/Foundation.h>
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/mach_override/mach_override.h"
 
@@ -78,7 +78,7 @@
     { @"com.stclairsoft.DefaultFolderX.CocoaPatcher", @"4.4.3", true },
   };
 
-  for (size_t index = 0; index < arraysize(kTestcases); ++index) {
+  for (size_t index = 0; index < base::size(kTestcases); ++index) {
     const IsBundleAllowedTestcase& testcase = kTestcases[index];
     NSString* bundle_id = testcase.bundle_id;
     NSString* version = testcase.version;
diff --git a/chrome/common/media/cdm_host_file_path.cc b/chrome/common/media/cdm_host_file_path.cc
index c6030f4..cd13f95 100644
--- a/chrome/common/media/cdm_host_file_path.cc
+++ b/chrome/common/media/cdm_host_file_path.cc
@@ -7,8 +7,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/common/chrome_version.h"
 
@@ -53,11 +53,11 @@
     NOTREACHED();
   base::FilePath version_dir(chrome_exe_dir.AppendASCII(CHROME_VERSION_STRING));
 
-  cdm_host_file_paths->reserve(arraysize(kUnversionedFiles) +
-                               arraysize(kVersionedFiles));
+  cdm_host_file_paths->reserve(base::size(kUnversionedFiles) +
+                               base::size(kVersionedFiles));
 
   // Signature files are always in the version directory.
-  for (size_t i = 0; i < arraysize(kUnversionedFiles); ++i) {
+  for (size_t i = 0; i < base::size(kUnversionedFiles); ++i) {
     base::FilePath file_path = chrome_exe_dir.Append(kUnversionedFiles[i]);
     base::FilePath sig_path =
         GetSigFilePath(version_dir.Append(kUnversionedFiles[i]));
@@ -66,7 +66,7 @@
     cdm_host_file_paths->emplace_back(file_path, sig_path);
   }
 
-  for (size_t i = 0; i < arraysize(kVersionedFiles); ++i) {
+  for (size_t i = 0; i < base::size(kVersionedFiles); ++i) {
     base::FilePath file_path = version_dir.Append(kVersionedFiles[i]);
     DVLOG(2) << __func__ << ": versioned file " << i << " at "
              << file_path.value();
diff --git a/chrome/common/origin_trials/chrome_origin_trial_policy.cc b/chrome/common/origin_trials/chrome_origin_trial_policy.cc
index 2707d3fe..8db86191 100644
--- a/chrome/common/origin_trials/chrome_origin_trial_policy.cc
+++ b/chrome/common/origin_trials/chrome_origin_trial_policy.cc
@@ -11,6 +11,7 @@
 #include "base/base64.h"
 #include "base/command_line.h"
 #include "base/feature_list.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "chrome/common/chrome_switches.h"
 #include "content/public/common/content_features.h"
@@ -27,7 +28,7 @@
 
 ChromeOriginTrialPolicy::ChromeOriginTrialPolicy()
     : public_key_(std::string(reinterpret_cast<const char*>(kDefaultPublicKey),
-                              arraysize(kDefaultPublicKey))) {
+                              base::size(kDefaultPublicKey))) {
   // Set the public key and disabled feature list for the origin trial key
   // manager, based on the command line flags which were passed to this process.
   // If the flags are not present, or are incorrectly formatted, the defaults
diff --git a/chrome/common/origin_trials/chrome_origin_trial_policy_unittest.cc b/chrome/common/origin_trials/chrome_origin_trial_policy_unittest.cc
index 2d3176d2..831c8b6 100644
--- a/chrome/common/origin_trials/chrome_origin_trial_policy_unittest.cc
+++ b/chrome/common/origin_trials/chrome_origin_trial_policy_unittest.cc
@@ -7,8 +7,8 @@
 #include <memory>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "chrome/common/chrome_switches.h"
@@ -79,13 +79,13 @@
   ChromeOriginTrialPolicyTest()
       : token1_signature_(
             std::string(reinterpret_cast<const char*>(kToken1Signature),
-                        arraysize(kToken1Signature))),
+                        base::size(kToken1Signature))),
         token2_signature_(
             std::string(reinterpret_cast<const char*>(kToken2Signature),
-                        arraysize(kToken2Signature))),
+                        base::size(kToken2Signature))),
         token3_signature_(
             std::string(reinterpret_cast<const char*>(kToken3Signature),
-                        arraysize(kToken3Signature))),
+                        base::size(kToken3Signature))),
         two_disabled_tokens_(
             base::JoinString({kToken1SignatureEncoded, kToken2SignatureEncoded},
                              kTokenSeparator)),
@@ -96,7 +96,7 @@
         manager_(base::WrapUnique(new ChromeOriginTrialPolicy())),
         default_key_(manager_->GetPublicKey().as_string()),
         test_key_(std::string(reinterpret_cast<const char*>(kTestPublicKey),
-                              arraysize(kTestPublicKey))) {}
+                              base::size(kTestPublicKey))) {}
 
   ChromeOriginTrialPolicy* manager() { return manager_.get(); }
   base::StringPiece default_key() { return default_key_; }
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index ab606ed..a062d3b0 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/common/pref_names.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "chrome/common/buildflags.h"
 #include "chrome/common/pref_font_webkit_names.h"
@@ -252,7 +252,7 @@
 };
 
 const size_t kWebKitScriptsForFontFamilyMapsLength =
-    arraysize(kWebKitScriptsForFontFamilyMaps);
+    base::size(kWebKitScriptsForFontFamilyMaps);
 
 // Strings for WebKit font family preferences. If these change, the pref prefix
 // in pref_names_util.cc and the pref format in font_settings_api.cc must also
diff --git a/chrome/common/service_process_util.cc b/chrome/common/service_process_util.cc
index ca7aae17..9de350ed 100644
--- a/chrome/common/service_process_util.cc
+++ b/chrome/common/service_process_util.cc
@@ -13,10 +13,10 @@
 #include "base/base_switches.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
 #include "base/path_service.h"
 #include "base/sha1.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -188,8 +188,7 @@
   };
 
   command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
-                                 kSwitchesToCopy,
-                                 arraysize(kSwitchesToCopy));
+                                 kSwitchesToCopy, base::size(kSwitchesToCopy));
   return command_line;
 }
 
diff --git a/chrome/common/webui_url_constants.cc b/chrome/common/webui_url_constants.cc
index fd1d6fd..0139064 100644
--- a/chrome/common/webui_url_constants.cc
+++ b/chrome/common/webui_url_constants.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/common/webui_url_constants.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/nacl/common/buildflags.h"
 #include "components/safe_browsing/web_ui/constants.h"
 #include "extensions/buildflags/buildflags.h"
@@ -439,7 +439,7 @@
 #endif
     kChromeUIWebRtcLogsHost,
 };
-const size_t kNumberOfChromeHostURLs = arraysize(kChromeHostURLs);
+const size_t kNumberOfChromeHostURLs = base::size(kChromeHostURLs);
 
 const char* const kChromeDebugURLs[] = {
     content::kChromeUIBadCastCrashURL,
@@ -465,6 +465,6 @@
 #endif
     kChromeUIQuitURL,
     kChromeUIRestartURL};
-const size_t kNumberOfChromeDebugURLs = arraysize(kChromeDebugURLs);
+const size_t kNumberOfChromeDebugURLs = base::size(kChromeDebugURLs);
 
 }  // namespace chrome
diff --git a/chrome/gpu/widevine_cdm_proxy_factory.cc b/chrome/gpu/widevine_cdm_proxy_factory.cc
index 37f92b42..9e1fee3a 100644
--- a/chrome/gpu/widevine_cdm_proxy_factory.cc
+++ b/chrome/gpu/widevine_cdm_proxy_factory.cc
@@ -8,6 +8,7 @@
 #include <initguid.h>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "media/cdm/cdm_proxy.h"
 #include "media/gpu/windows/d3d11_cdm_proxy.h"
@@ -34,7 +35,7 @@
   // Create device and pupulate |device|.
   HRESULT hresult = D3D11CreateDevice(
       nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, feature_levels,
-      arraysize(feature_levels), D3D11_SDK_VERSION, device.GetAddressOf(),
+      base::size(feature_levels), D3D11_SDK_VERSION, device.GetAddressOf(),
       nullptr, nullptr);
 
   if (FAILED(hresult)) {
diff --git a/chrome/install_static/install_util_unittest.cc b/chrome/install_static/install_util_unittest.cc
index ae85fe8f..12e1118 100644
--- a/chrome/install_static/install_util_unittest.cc
+++ b/chrome/install_static/install_util_unittest.cc
@@ -8,7 +8,6 @@
 
 #include <tuple>
 
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/test/test_reg_util_win.h"
 #include "chrome/install_static/install_details.h"
@@ -369,7 +368,7 @@
       L"Chromium",
   };
 #endif
-  static_assert(arraysize(kInstallDirs) == NUM_INSTALL_MODES,
+  static_assert(base::size(kInstallDirs) == NUM_INSTALL_MODES,
                 "kInstallDirs out of date.");
   EXPECT_THAT(GetChromeInstallSubDirectory(),
               StrCaseEq(kInstallDirs[std::get<0>(GetParam())]));
@@ -390,7 +389,7 @@
       L"Software\\Chromium",
   };
 #endif
-  static_assert(arraysize(kRegistryPaths) == NUM_INSTALL_MODES,
+  static_assert(base::size(kRegistryPaths) == NUM_INSTALL_MODES,
                 "kRegistryPaths out of date.");
   EXPECT_THAT(GetRegistryPath(),
               StrCaseEq(kRegistryPaths[std::get<0>(GetParam())]));
@@ -416,7 +415,7 @@
       L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium",
   };
 #endif
-  static_assert(arraysize(kUninstallRegistryPaths) == NUM_INSTALL_MODES,
+  static_assert(base::size(kUninstallRegistryPaths) == NUM_INSTALL_MODES,
                 "kUninstallRegistryPaths out of date.");
   EXPECT_THAT(GetUninstallRegistryPath(),
               StrCaseEq(kUninstallRegistryPaths[std::get<0>(GetParam())]));
@@ -438,7 +437,7 @@
       L"{401C381F-E0DE-4B85-8BD8-3F3F14FBDA57}",  // Google Chrome Dev.
       L"{4EA16AC7-FD5A-47C3-875B-DBF4A2008C20}",  // Google Chrome SxS (Canary).
   };
-  static_assert(arraysize(kAppGuids) == NUM_INSTALL_MODES,
+  static_assert(base::size(kAppGuids) == NUM_INSTALL_MODES,
                 "kAppGuids out of date.");
   EXPECT_THAT(GetAppGuid(), StrCaseEq(kAppGuids[std::get<0>(GetParam())]));
 #else
@@ -458,7 +457,7 @@
       L"Chromium",
   };
 #endif
-  static_assert(arraysize(kBaseAppIds) == NUM_INSTALL_MODES,
+  static_assert(base::size(kBaseAppIds) == NUM_INSTALL_MODES,
                 "kBaseAppIds out of date.");
   EXPECT_THAT(GetBaseAppId(), StrCaseEq(kBaseAppIds[std::get<0>(GetParam())]));
 }
@@ -510,7 +509,7 @@
       L"{635EFA6F-08D6-4EC9-BD14-8A0FDE975159}"  // Chromium.
   };
 #endif
-  static_assert(arraysize(kToastActivatorClsids) == NUM_INSTALL_MODES,
+  static_assert(base::size(kToastActivatorClsids) == NUM_INSTALL_MODES,
                 "kToastActivatorClsids out of date.");
 
   EXPECT_EQ(GetToastActivatorClsid(),
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc
index acf3e80..77c15b7f 100644
--- a/chrome/installer/gcapi/gcapi.cc
+++ b/chrome/installer/gcapi/gcapi.cc
@@ -29,8 +29,8 @@
 
 #include "base/command_line.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -345,7 +345,7 @@
   SetWindowPosParams* params = reinterpret_cast<SetWindowPosParams*>(lparam);
 
   if (!params->shunted_hwnds.count(hwnd) &&
-      ::GetClassName(hwnd, window_class, arraysize(window_class)) &&
+      ::GetClassName(hwnd, window_class, base::size(window_class)) &&
       base::StartsWith(window_class, kChromeWindowClassPrefix,
                        base::CompareCase::INSENSITIVE_ASCII) &&
       ::SetWindowPos(hwnd, params->window_insert_after, params->x, params->y,
diff --git a/chrome/installer/setup/install_unittest.cc b/chrome/installer/setup/install_unittest.cc
index f74d9d9..b4c4810 100644
--- a/chrome/installer/setup/install_unittest.cc
+++ b/chrome/installer/setup/install_unittest.cc
@@ -16,8 +16,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -82,8 +82,8 @@
   // Creates a dummy test file at |path|.
   void CreateTestFile(const base::FilePath& path) {
     static constexpr char kBlah[] = "blah";
-    ASSERT_EQ(static_cast<int>(arraysize(kBlah) - 1),
-              base::WriteFile(path, &kBlah[0], arraysize(kBlah) - 1));
+    ASSERT_EQ(static_cast<int>(base::size(kBlah) - 1),
+              base::WriteFile(path, &kBlah[0], base::size(kBlah) - 1));
   }
 
   // Creates the VisualElements directory and a light asset, if testing such.
@@ -288,7 +288,7 @@
     };
 
     std::string master_prefs("{\"distribution\":{");
-    for (size_t i = 0; i < arraysize(desired_prefs); ++i) {
+    for (size_t i = 0; i < base::size(desired_prefs); ++i) {
       master_prefs += (i == 0 ? "\"" : ",\"");
       master_prefs += desired_prefs[i].pref_name;
       master_prefs += "\":";
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index 2530f98a..2a56c613a 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -22,7 +22,6 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/persistent_histogram_storage.h"
 #include "base/numerics/safe_conversions.h"
@@ -30,6 +29,7 @@
 #include "base/process/launch.h"
 #include "base/process/memory.h"
 #include "base/process/process.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -238,7 +238,7 @@
     base::string16 value_name(value_iter.Name());
     if (base::StartsWith(value_name, kMsiProductIdPrefix,
                          base::CompareCase::INSENSITIVE_ASCII)) {
-      return value_name.substr(arraysize(kMsiProductIdPrefix) - 1);
+      return value_name.substr(base::size(kMsiProductIdPrefix) - 1);
     }
   }
   return base::string16();
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc
index b8c7a62e..1cc6bd5 100644
--- a/chrome/installer/setup/setup_util.cc
+++ b/chrome/installer/setup/setup_util.cc
@@ -30,9 +30,9 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/version.h"
@@ -379,7 +379,7 @@
       L"%SystemRoot%\\System32\\rundll32.exe";
   wchar_t rundll32[MAX_PATH];
   DWORD size =
-      ExpandEnvironmentStrings(kRunDll32Path, rundll32, arraysize(rundll32));
+      ExpandEnvironmentStrings(kRunDll32Path, rundll32, base::size(rundll32));
   if (!size || size >= MAX_PATH)
     return false;
 
@@ -473,7 +473,7 @@
     "app-host",
     "app-launcher",
   };
-  for (size_t i = 0; i < arraysize(kLegacySwitches); ++i) {
+  for (size_t i = 0; i < base::size(kLegacySwitches); ++i) {
     if (cmd_line.HasSwitch(kLegacySwitches[i]))
       return true;
   }
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 7324716..f5d5c2f9 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -20,7 +20,6 @@
 #include "base/bind.h"
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/process/kill.h"
 #include "base/stl_util.h"
@@ -547,7 +546,7 @@
   // but doesn't seem to do so when manually deleting the user-level keys it
   // created.
   base::string16 alternate_active_setup_path(active_setup_path);
-  alternate_active_setup_path.insert(arraysize("Software\\") - 1,
+  alternate_active_setup_path.insert(base::size("Software\\") - 1,
                                      L"Wow6432Node\\");
 
   VLOG(1) << "Uninstall per-user Active Setup keys.";
diff --git a/chrome/installer/setup/user_experiment.cc b/chrome/installer/setup/user_experiment.cc
index 4e8a103d..eafc3b16 100644
--- a/chrome/installer/setup/user_experiment.cc
+++ b/chrome/installer/setup/user_experiment.cc
@@ -17,6 +17,7 @@
 #include "base/process/launch.h"
 #include "base/process/process_info.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/win/registry.h"
@@ -272,7 +273,7 @@
       kExperimentRetryDelay,
   };
   setup_command.CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
-                                 kSwitchesToCopy, arraysize(kSwitchesToCopy));
+                                 kSwitchesToCopy, base::size(kSwitchesToCopy));
 
   if (user_context) {
     // This is either a per-user install or a per-machine install run via
diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc
index 35b84786..50503f0 100644
--- a/chrome/installer/test/alternate_version_generator.cc
+++ b/chrome/installer/test/alternate_version_generator.cc
@@ -42,10 +42,10 @@
 #include "base/files/file_util.h"
 #include "base/files/memory_mapped_file.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/process/launch.h"
 #include "base/process/process_handle.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -146,19 +146,19 @@
 base::string16 ChromeVersion::ToString() const {
   base::char16 buffer[24];
   int string_len =
-      swprintf_s(&buffer[0], arraysize(buffer), L"%hu.%hu.%hu.%hu",
-                 major(), minor(), build(), patch());
+      swprintf_s(&buffer[0], base::size(buffer), L"%hu.%hu.%hu.%hu", major(),
+                 minor(), build(), patch());
   DCHECK_NE(-1, string_len);
-  DCHECK_GT(static_cast<int>(arraysize(buffer)), string_len);
+  DCHECK_GT(static_cast<int>(base::size(buffer)), string_len);
   return base::string16(&buffer[0], string_len);
 }
 
 std::string ChromeVersion::ToASCII() const {
   char buffer[24];
-  int string_len = sprintf_s(&buffer[0], arraysize(buffer), "%hu.%hu.%hu.%hu",
+  int string_len = sprintf_s(&buffer[0], base::size(buffer), "%hu.%hu.%hu.%hu",
                              major(), minor(), build(), patch());
   DCHECK_NE(-1, string_len);
-  DCHECK_GT(static_cast<int>(arraysize(buffer)), string_len);
+  DCHECK_GT(static_cast<int>(base::size(buffer)), string_len);
   return std::string(&buffer[0], string_len);
 }
 
diff --git a/chrome/installer/test/alternate_version_generator_main.cc b/chrome/installer/test/alternate_version_generator_main.cc
index 23c7d15f..c19ea3a5 100644
--- a/chrome/installer/test/alternate_version_generator_main.cc
+++ b/chrome/installer/test/alternate_version_generator_main.cc
@@ -15,8 +15,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "chrome/installer/test/alternate_version_generator.h"
 
 namespace {
@@ -52,7 +52,7 @@
 
 const wchar_t* GetErrorMessage(ErrorCode error_code) {
   DCHECK_LE(0, error_code);
-  DCHECK_GT(arraysize(Messages), static_cast<size_t>(error_code));
+  DCHECK_GT(base::size(Messages), static_cast<size_t>(error_code));
   return Messages[error_code];
 }
 
diff --git a/chrome/installer/util/advanced_firewall_manager_win.cc b/chrome/installer/util/advanced_firewall_manager_win.cc
index 7afc772..8ddaffad 100644
--- a/chrome/installer/util/advanced_firewall_manager_win.cc
+++ b/chrome/installer/util/advanced_firewall_manager_win.cc
@@ -9,7 +9,7 @@
 
 #include "base/guid.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/scoped_bstr.h"
@@ -53,7 +53,7 @@
     NET_FW_PROFILE2_PRIVATE,
     NET_FW_PROFILE2_DOMAIN
   };
-  for (size_t i = 0; i < arraysize(kProfileTypes); ++i) {
+  for (size_t i = 0; i < base::size(kProfileTypes); ++i) {
     if ((profile_types & kProfileTypes[i]) != 0) {
       VARIANT_BOOL enabled = VARIANT_TRUE;
       hr = firewall_policy_->get_FirewallEnabled(kProfileTypes[i], &enabled);
diff --git a/chrome/installer/util/app_command.cc b/chrome/installer/util/app_command.cc
index 9b6981d6..3100645c 100644
--- a/chrome/installer/util/app_command.cc
+++ b/chrome/installer/util/app_command.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/win/registry.h"
 #include "chrome/installer/util/google_update_constants.h"
 #include "chrome/installer/util/work_item_list.h"
@@ -60,7 +60,7 @@
 
   command_line_.swap(cmd_line);
 
-  for (size_t i = 0; i < arraysize(kNameBoolVars); ++i) {
+  for (size_t i = 0; i < base::size(kNameBoolVars); ++i) {
     DWORD value = 0;  // Set default to false.
     // Note: ReadValueDW only modifies out param on success.
     key.ReadValueDW(kNameBoolVars[i].name, &value);
@@ -86,7 +86,7 @@
                                     true)
       ->set_log_message("setting AppCommand CommandLine registry value");
 
-  for (size_t i = 0; i < arraysize(kNameBoolVars); ++i) {
+  for (size_t i = 0; i < base::size(kNameBoolVars); ++i) {
     const wchar_t* var_name = kNameBoolVars[i].name;
     bool var_data = this->*(kNameBoolVars[i].data);
 
diff --git a/chrome/installer/util/auto_launch_util.cc b/chrome/installer/util/auto_launch_util.cc
index 3499754..0583ec64 100644
--- a/chrome/installer/util/auto_launch_util.cc
+++ b/chrome/installer/util/auto_launch_util.cc
@@ -11,8 +11,8 @@
 #include "base/command_line.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -42,9 +42,9 @@
 
   std::string input(path.AsUTF8Unsafe());
   uint8_t hash[16];
-  crypto::SHA256HashString(input, hash, arraysize(hash));
+  crypto::SHA256HashString(input, hash, base::size(hash));
   return base::string16(kAutolaunchKeyValue) + base::ASCIIToUTF16("_") +
-         base::ASCIIToUTF16(base::HexEncode(hash, arraysize(hash)));
+         base::ASCIIToUTF16(base::HexEncode(hash, base::size(hash)));
 }
 
 }  // namespace
diff --git a/chrome/installer/util/channel_info.cc b/chrome/installer/util/channel_info.cc
index 39d72b0..f5c9a58 100644
--- a/chrome/installer/util/channel_info.cc
+++ b/chrome/installer/util/channel_info.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/win/registry.h"
 #include "chrome/installer/util/google_update_constants.h"
 #include "chrome/installer/util/util_constants.h"
@@ -57,7 +57,7 @@
   NUM_MODIFIERS
 };
 
-static_assert(NUM_MODIFIERS == arraysize(kModifiers),
+static_assert(NUM_MODIFIERS == base::size(kModifiers),
               "kModifiers disagrees with ModifierIndex; they must match!");
 
 // Returns true if the modifier is found, in which case |position| holds the
diff --git a/chrome/installer/util/delete_after_reboot_helper_unittest.cc b/chrome/installer/util/delete_after_reboot_helper_unittest.cc
index 37d58e97..ab5f57f5 100644
--- a/chrome/installer/util/delete_after_reboot_helper_unittest.cc
+++ b/chrome/installer/util/delete_after_reboot_helper_unittest.cc
@@ -11,7 +11,7 @@
 #include <memory>
 
 #include "base/files/file_util.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/win/registry.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -115,7 +115,7 @@
     { L"deletes", L"foo\0\0bar\0\0bizz\0\0", 16 * sizeof(wchar_t), 3 },
   };
 
-  for (size_t i = 0; i < arraysize(tests); i++) {
+  for (size_t i = 0; i < base::size(tests); i++) {
     std::vector<PendingMove> string_list;
     EXPECT_TRUE(SUCCEEDED(
         MultiSZBytesToStringArray(reinterpret_cast<const char*>(tests[i].str),
@@ -136,7 +136,7 @@
       {L"malformed", reinterpret_cast<const wchar_t*>("oddnumb\0\0"), 9, 1},
   };
 
-  for (size_t i = 0; i < arraysize(failures); i++) {
+  for (size_t i = 0; i < base::size(failures); i++) {
     std::vector<PendingMove> string_list;
     EXPECT_FALSE(SUCCEEDED(MultiSZBytesToStringArray(
         reinterpret_cast<const char*>(failures[i].str),
@@ -175,7 +175,7 @@
   // Check that each of the deletes we expect are there in order.
   base::FilePath expected_paths[] =
       { temp_file_, temp_subdir_file_, temp_subdir_, temp_dir_ };
-  for (size_t i = 0; i < arraysize(expected_paths); ++i) {
+  for (size_t i = 0; i < base::size(expected_paths); ++i) {
     EXPECT_FALSE(iter == pending_moves.end());
     if (iter != pending_moves.end()) {
       base::FilePath short_path_name(GetShortPathName(expected_paths[i]));
@@ -229,7 +229,7 @@
   // Check that each of the deletes we expect are there in order.
   base::FilePath expected_paths[] =
       { temp_file_, temp_subdir_file_, temp_subdir_, temp_dir_ };
-  for (size_t i = 0; i < arraysize(expected_paths); ++i) {
+  for (size_t i = 0; i < base::size(expected_paths); ++i) {
     EXPECT_FALSE(iter == pending_moves.end());
     if (iter != pending_moves.end()) {
       base::FilePath short_path_name(GetShortPathName(expected_paths[i]));
diff --git a/chrome/installer/util/delete_reg_key_work_item_unittest.cc b/chrome/installer/util/delete_reg_key_work_item_unittest.cc
index 65bfdc7..2c67696 100644
--- a/chrome/installer/util/delete_reg_key_work_item_unittest.cc
+++ b/chrome/installer/util/delete_reg_key_work_item_unittest.cc
@@ -11,7 +11,7 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/win/registry.h"
 #include "chrome/installer/util/registry_test_data.h"
 #include "chrome/installer/util/work_item.h"
@@ -40,7 +40,7 @@
     std::wstring(test_data_.base_path() + L"\\NoKeyHere\\OrHere")
   };
   RegKey key;
-  for (size_t i = 0; i < arraysize(key_paths); ++i) {
+  for (size_t i = 0; i < base::size(key_paths); ++i) {
     const std::wstring& key_path = key_paths[i];
     std::unique_ptr<DeleteRegKeyWorkItem> item(
         WorkItem::CreateDeleteRegKeyWorkItem(test_data_.root_key(), key_path,
diff --git a/chrome/installer/util/google_update_settings_unittest.cc b/chrome/installer/util/google_update_settings_unittest.cc
index e5c182e..06330cc 100644
--- a/chrome/installer/util/google_update_settings_unittest.cc
+++ b/chrome/installer/util/google_update_settings_unittest.cc
@@ -10,8 +10,8 @@
 #include <memory>
 
 #include "base/base_paths.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_path_override.h"
 #include "base/test/test_reg_util_win.h"
@@ -244,20 +244,20 @@
     L"1.1-full",
     L"1.1-dev-full"
   };
-  static_assert(arraysize(full) == arraysize(plain), "bad full array size");
+  static_assert(base::size(full) == base::size(plain), "bad full array size");
   const wchar_t* const multifail[] = {
     L"-multifail",
     L"1.1-multifail",
     L"1.1-dev-multifail"
   };
-  static_assert(arraysize(multifail) == arraysize(plain),
+  static_assert(base::size(multifail) == base::size(plain),
                 "bad multifail array size");
   const wchar_t* const multifail_full[] = {
     L"-multifail-full",
     L"1.1-multifail-full",
     L"1.1-dev-multifail-full"
   };
-  static_assert(arraysize(multifail_full) == arraysize(plain),
+  static_assert(base::size(multifail_full) == base::size(plain),
                 "bad multifail_full array size");
   const wchar_t* const* input_arrays[] = {
     plain,
@@ -290,7 +290,7 @@
           else
             outputs = plain;
         }
-        for (size_t input_idx = 0; input_idx < arraysize(plain); ++input_idx) {
+        for (size_t input_idx = 0; input_idx < base::size(plain); ++input_idx) {
           const wchar_t* input = inputs[input_idx];
           const wchar_t* output = outputs[input_idx];
 
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
index 63c99a2..b46c91c 100644
--- a/chrome/installer/util/install_util.cc
+++ b/chrome/installer/util/install_util.cc
@@ -16,10 +16,10 @@
 #include "base/command_line.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/system/sys_info.h"
@@ -513,9 +513,9 @@
 // static
 base::string16 InstallUtil::GetCurrentDate() {
   static const wchar_t kDateFormat[] = L"yyyyMMdd";
-  wchar_t date_str[arraysize(kDateFormat)] = {0};
-  int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat,
-                           date_str, arraysize(date_str));
+  wchar_t date_str[base::size(kDateFormat)] = {0};
+  int len = GetDateFormatW(LOCALE_INVARIANT, 0, NULL, kDateFormat, date_str,
+                           base::size(date_str));
   if (len) {
     --len;  // Subtract terminating \0.
   } else {
diff --git a/chrome/installer/util/install_util_unittest.cc b/chrome/installer/util/install_util_unittest.cc
index 4189416..c55d180 100644
--- a/chrome/installer/util/install_util_unittest.cc
+++ b/chrome/installer/util/install_util_unittest.cc
@@ -15,8 +15,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/test/scoped_path_override.h"
 #include "base/test/test_reg_util_win.h"
@@ -402,7 +402,7 @@
   // Tests where the expected file exists.
   static const char data[] = "data";
   ASSERT_TRUE(base::CreateDirectory(some_long_dir));
-  ASSERT_NE(-1, base::WriteFile(expect, data, arraysize(data) - 1));
+  ASSERT_NE(-1, base::WriteFile(expect, data, base::size(data) - 1));
   // Paths don't match.
   EXPECT_FALSE(InstallUtil::ProgramCompare(expect).Evaluate(
       L"\"" + other.value() + L"\""));
diff --git a/chrome/installer/util/l10n_string_util.cc b/chrome/installer/util/l10n_string_util.cc
index 87e0b07..e768fd7a 100644
--- a/chrome/installer/util/l10n_string_util.cc
+++ b/chrome/installer/util/l10n_string_util.cc
@@ -135,12 +135,12 @@
 
 int GetBaseMessageIdForMode(int base_message_id) {
 // Generate the constants holding the mode-specific resource ID arrays.
-#define HANDLE_MODE_STRING(id, ...)                                   \
-  static constexpr int k##id##Strings[] = {__VA_ARGS__};              \
-  static_assert(                                                      \
-      arraysize(k##id##Strings) == install_static::NUM_INSTALL_MODES, \
-      "resource " #id                                                 \
-      " has the wrong number of mode-specific "                       \
+#define HANDLE_MODE_STRING(id, ...)                                    \
+  static constexpr int k##id##Strings[] = {__VA_ARGS__};               \
+  static_assert(                                                       \
+      base::size(k##id##Strings) == install_static::NUM_INSTALL_MODES, \
+      "resource " #id                                                  \
+      " has the wrong number of mode-specific "                        \
       "strings.");
   DO_MODE_STRINGS
 #undef HANDLE_MODE_STRING
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 5baded7e..df8a6e2 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -11,7 +11,7 @@
 #include "base/json/json_string_value_serializer.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
 #include "chrome/common/env_vars.h"
@@ -133,7 +133,7 @@
   };
 
   std::string name(installer::master_preferences::kDistroDict);
-  for (size_t i = 0; i < arraysize(translate_switches); ++i) {
+  for (size_t i = 0; i < base::size(translate_switches); ++i) {
     if (cmd_line.HasSwitch(translate_switches[i].cmd_line_switch)) {
       name.assign(installer::master_preferences::kDistroDict);
       name.append(".").append(translate_switches[i].distribution_switch);
diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc
index 009cc19..887f143 100644
--- a/chrome/installer/util/master_preferences_unittest.cc
+++ b/chrome/installer/util/master_preferences_unittest.cc
@@ -12,8 +12,8 @@
 
 #include "base/environment.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/pref_names.h"
@@ -112,7 +112,7 @@
       installer::master_preferences::kRequireEula,
   };
 
-  for (size_t i = 0; i < arraysize(expected_true); ++i) {
+  for (size_t i = 0; i < base::size(expected_true); ++i) {
     bool value = false;
     EXPECT_TRUE(prefs.GetBool(expected_true[i], &value));
     EXPECT_TRUE(value) << expected_true[i];
@@ -148,7 +148,7 @@
   };
 
   bool value = false;
-  for (size_t i = 0; i < arraysize(expected_bool); ++i) {
+  for (size_t i = 0; i < base::size(expected_bool); ++i) {
     EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value));
     EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name;
   }
@@ -160,7 +160,7 @@
     installer::master_preferences::kMakeChromeDefaultForUser,
   };
 
-  for (size_t i = 0; i < arraysize(missing_bools); ++i) {
+  for (size_t i = 0; i < base::size(missing_bools); ++i) {
     EXPECT_FALSE(prefs.GetBool(missing_bools[i], &value)) << missing_bools[i];
   }
 
@@ -261,7 +261,7 @@
 
   // Now check that prefs got merged correctly.
   bool value = false;
-  for (size_t i = 0; i < arraysize(expected_bool); ++i) {
+  for (size_t i = 0; i < base::size(expected_bool); ++i) {
     EXPECT_TRUE(prefs.GetBool(expected_bool[i].name, &value));
     EXPECT_EQ(value, expected_bool[i].expected_value) << expected_bool[i].name;
   }
@@ -278,7 +278,7 @@
     { installer::master_preferences::kDoNotLaunchChrome, true },
   };
 
-  for (size_t i = 0; i < arraysize(expected_bool2); ++i) {
+  for (size_t i = 0; i < base::size(expected_bool2); ++i) {
     EXPECT_TRUE(prefs2.GetBool(expected_bool2[i].name, &value));
     EXPECT_EQ(value, expected_bool2[i].expected_value)
         << expected_bool2[i].name;
diff --git a/chrome/installer/util/move_tree_work_item_unittest.cc b/chrome/installer/util/move_tree_work_item_unittest.cc
index 6c6152b..d357287 100644
--- a/chrome/installer/util/move_tree_work_item_unittest.cc
+++ b/chrome/installer/util/move_tree_work_item_unittest.cc
@@ -12,7 +12,7 @@
 #include "base/base_paths.h"
 #include "base/files/file_util.h"
 #include "base/files/memory_mapped_file.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/installer/util/installer_util_test_common.h"
@@ -47,7 +47,7 @@
   std::wifstream file;
   file.open(base::UTF16ToASCII(path.value()).c_str());
   EXPECT_TRUE(file.is_open());
-  file.getline(contents, arraysize(contents));
+  file.getline(contents, base::size(contents));
   file.close();
   return std::wstring(contents);
 }
diff --git a/chrome/installer/util/self_cleaning_temp_dir_unittest.cc b/chrome/installer/util/self_cleaning_temp_dir_unittest.cc
index b807fbff..9a65915 100644
--- a/chrome/installer/util/self_cleaning_temp_dir_unittest.cc
+++ b/chrome/installer/util/self_cleaning_temp_dir_unittest.cc
@@ -8,7 +8,7 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "chrome/installer/util/self_cleaning_temp_dir.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -25,11 +25,11 @@
   // seen the latter trivially repeat.
   EXPECT_NE(FALSE, CryptAcquireContext(&crypt_ctx, NULL, NULL, PROV_RSA_FULL,
                                         CRYPT_VERIFYCONTEXT));
-  EXPECT_NE(FALSE, CryptGenRandom(crypt_ctx, arraysize(data), &data[0]));
+  EXPECT_NE(FALSE, CryptGenRandom(crypt_ctx, base::size(data), &data[0]));
   EXPECT_NE(FALSE, CryptReleaseContext(crypt_ctx, 0));
 
   // Hexify the value.
-  std::string result(base::HexEncode(&data[0], arraysize(data)));
+  std::string result(base::HexEncode(&data[0], base::size(data)));
   EXPECT_EQ(8u, result.size());
 
   // Replace the first digit with the letter 'R' (for "random", get it?).
@@ -165,9 +165,9 @@
     EXPECT_EQ(parent_temp_dir.Append(L"Three"), temp_dir.path());
     EXPECT_TRUE(base::DirectoryExists(temp_dir.path()));
     // Drop a file somewhere.
-    EXPECT_EQ(static_cast<int>(arraysize(kHiHon) - 1),
+    EXPECT_EQ(static_cast<int>(base::size(kHiHon) - 1),
               base::WriteFile(parent_temp_dir.AppendASCII(GetRandomFilename()),
-                              kHiHon, arraysize(kHiHon) - 1));
+                              kHiHon, base::size(kHiHon) - 1));
   }
   EXPECT_FALSE(base::DirectoryExists(parent_temp_dir.Append(L"Three")));
   EXPECT_TRUE(base::DirectoryExists(parent_temp_dir));
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 5d08e8a..14fcde2 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -30,10 +30,10 @@
 #include "base/files/file_util.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/md5.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
@@ -155,7 +155,7 @@
   base::MD5Sum(user_sid_ascii.c_str(), user_sid_ascii.length(), &md5_digest);
   std::string base32_md5 = base32::Base32Encode(
       base::StringPiece(reinterpret_cast<char*>(md5_digest.a),
-                        arraysize(md5_digest.a)),
+                        base::size(md5_digest.a)),
       base32::Base32EncodePolicy::OMIT_PADDING);
   // The value returned by the base32 algorithm above must never change.
   DCHECK_EQ(base32_md5.length(), 26U);
@@ -1396,7 +1396,7 @@
   };
   base::CommandLine desired_args(base::CommandLine::NO_PROGRAM);
   desired_args.CopySwitchesFrom(current_args, kept_switches,
-                                arraysize(kept_switches));
+                                base::size(kept_switches));
   if (desired_args.argv().size() == current_args.argv().size())
     return true;
   if (shortcuts)
@@ -1926,7 +1926,7 @@
   // to show up in Add/Remove programs for us.
   static const wchar_t* const kChromeProtocols[] = { L"http", L"https" };
   DefaultState default_state = ProbeProtocolHandlers(
-      chrome_exe, kChromeProtocols, arraysize(kChromeProtocols));
+      chrome_exe, kChromeProtocols, base::size(kChromeProtocols));
   UpdateDefaultBrowserBeaconWithState(default_state);
   return default_state;
 }
@@ -1943,9 +1943,7 @@
   }
 
   const wchar_t* const protocols[] = { protocol.c_str() };
-  return ProbeProtocolHandlers(chrome_exe,
-                               protocols,
-                               arraysize(protocols));
+  return ProbeProtocolHandlers(chrome_exe, protocols, base::size(protocols));
 }
 
 // static
@@ -2372,7 +2370,7 @@
 
 bool ShellUtil::GetOldUserSpecificRegistrySuffix(base::string16* suffix) {
   wchar_t user_name[256];
-  DWORD size = arraysize(user_name);
+  DWORD size = base::size(user_name);
   if (::GetUserName(user_name, &size) == 0 || size < 1) {
     NOTREACHED();
     return false;
diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc
index a2bc7f3..537a5bc 100644
--- a/chrome/installer/util/shell_util_unittest.cc
+++ b/chrome/installer/util/shell_util_unittest.cc
@@ -17,8 +17,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/md5.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/synchronization/cancellation_flag.h"
@@ -820,7 +820,7 @@
 
   static std::set<base::string16> FileExtensions() {
     std::set<base::string16> file_extensions;
-    for (size_t i = 0; i < arraysize(kTestFileExtensions); ++i)
+    for (size_t i = 0; i < base::size(kTestFileExtensions); ++i)
       file_extensions.insert(kTestFileExtensions[i]);
     return file_extensions;
   }
@@ -977,7 +977,7 @@
   ASSERT_TRUE(base::StartsWith(suffix, L".", base::CompareCase::SENSITIVE));
 
   wchar_t user_name[256];
-  DWORD size = arraysize(user_name);
+  DWORD size = base::size(user_name);
   ASSERT_NE(0, ::GetUserName(user_name, &size));
   ASSERT_GE(size, 1U);
   ASSERT_STREQ(user_name, suffix.substr(1).c_str());
diff --git a/chrome/notification_helper/trace_util.cc b/chrome/notification_helper/trace_util.cc
index d078750..3fc3ad2 100644
--- a/chrome/notification_helper/trace_util.cc
+++ b/chrome/notification_helper/trace_util.cc
@@ -7,7 +7,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 
 #if !defined(NDEBUG)
@@ -22,7 +22,7 @@
   va_list args = {};
 
   va_start(args, format);
-  if (vswprintf(buffer, arraysize(buffer), format, args) > 0) {
+  if (vswprintf(buffer, base::size(buffer), format, args) > 0) {
     OutputDebugString(buffer);
   } else {
     base::string16 error_string(L"Format error for string: ");
diff --git a/chrome/renderer/app_categorizer.cc b/chrome/renderer/app_categorizer.cc
index 3d7a180..08e1d2c6 100644
--- a/chrome/renderer/app_categorizer.cc
+++ b/chrome/renderer/app_categorizer.cc
@@ -4,7 +4,7 @@
 
 #include "chrome/renderer/app_categorizer.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "url/gurl.h"
 
@@ -36,12 +36,10 @@
 bool AppCategorizer::IsHangoutsUrl(const GURL& url) {
   // Whitelisted apps must be served over https.
   return url.SchemeIsCryptographic() &&
-      base::StartsWith(url.path(), "/hangouts/",
-                       base::CompareCase::INSENSITIVE_ASCII) &&
-      IsInWhitelistedDomain(
-          url,
-          kPredefinedHangoutsDomains,
-          arraysize(kPredefinedHangoutsDomains));
+         base::StartsWith(url.path(), "/hangouts/",
+                          base::CompareCase::INSENSITIVE_ASCII) &&
+         IsInWhitelistedDomain(url, kPredefinedHangoutsDomains,
+                               base::size(kPredefinedHangoutsDomains));
 }
 
 bool AppCategorizer::IsWhitelistedApp(
diff --git a/chrome/renderer/app_categorizer_unittest.cc b/chrome/renderer/app_categorizer_unittest.cc
index 69b5f0b..7439061 100644
--- a/chrome/renderer/app_categorizer_unittest.cc
+++ b/chrome/renderer/app_categorizer_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/renderer/app_categorizer.h"
 
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
 
@@ -37,11 +38,11 @@
 }  // namespace
 
 TEST(AppCategorizerTest, IsHangoutsUrl) {
-  for (size_t i = 0; i < arraysize(kChatAppURLs); ++i) {
+  for (size_t i = 0; i < base::size(kChatAppURLs); ++i) {
     EXPECT_TRUE(AppCategorizer::IsHangoutsUrl(GURL(kChatAppURLs[i])));
   }
 
-  for (size_t i = 0; i < arraysize(kBadChatAppURLs); ++i) {
+  for (size_t i = 0; i < base::size(kBadChatAppURLs); ++i) {
     EXPECT_FALSE(AppCategorizer::IsHangoutsUrl(GURL(kBadChatAppURLs[i])));
   }
 }
@@ -49,12 +50,12 @@
 TEST(AppCategorizerTest, IsWhitelistedApp) {
   // Hangouts app
   {
-    EXPECT_EQ(arraysize(kChatAppURLs), arraysize(kChatManifestFSs));
-    for (size_t i = 0; i < arraysize(kChatAppURLs); ++i) {
+    EXPECT_EQ(base::size(kChatAppURLs), base::size(kChatManifestFSs));
+    for (size_t i = 0; i < base::size(kChatAppURLs); ++i) {
       EXPECT_TRUE(AppCategorizer::IsWhitelistedApp(
           GURL(kChatManifestFSs[i]), GURL(kChatAppURLs[i])));
     }
-    for (size_t i = 0; i < arraysize(kBadChatAppURLs); ++i) {
+    for (size_t i = 0; i < base::size(kBadChatAppURLs); ++i) {
       EXPECT_FALSE(AppCategorizer::IsWhitelistedApp(
           GURL("filesystem:https://irrelevant.com/"),
           GURL(kBadChatAppURLs[i])));
diff --git a/chrome/renderer/autofill/form_autofill_browsertest.cc b/chrome/renderer/autofill/form_autofill_browsertest.cc
index debce1f..d8207cd2 100644
--- a/chrome/renderer/autofill/form_autofill_browsertest.cc
+++ b/chrome/renderer/autofill/form_autofill_browsertest.cc
@@ -7,8 +7,8 @@
 #include <vector>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -572,9 +572,8 @@
         "some multi-\nline value",
         "Go\naway!"},
     };
-    TestFormFillFunctions(html, unowned, url_override,
-                          field_cases, arraysize(field_cases),
-                          FillForm, &GetValueWrapper);
+    TestFormFillFunctions(html, unowned, url_override, field_cases,
+                          base::size(field_cases), FillForm, &GetValueWrapper);
     // Verify preview selection.
     WebInputElement firstname = GetInputElementById("firstname");
     EXPECT_EQ(16, firstname.SelectionStart());
@@ -648,9 +647,9 @@
         "suggested multi-\nline value",
         ""},
     };
-    TestFormFillFunctions(html, unowned, url_override,
-                          field_cases, arraysize(field_cases),
-                          &PreviewForm, &GetSuggestedValueWrapper);
+    TestFormFillFunctions(html, unowned, url_override, field_cases,
+                          base::size(field_cases), &PreviewForm,
+                          &GetSuggestedValueWrapper);
 
     // Verify preview selection.
     WebInputElement firstname = GetInputElementById("firstname");
@@ -2783,7 +2782,7 @@
   };
 
   WebDocument document = frame->GetDocument();
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     WebFormControlElement element = GetFormControlElementById(
         WebString::FromASCII(test_cases[i].element_id));
     FormFieldData result;
@@ -3731,10 +3730,9 @@
        "some multi-\nline value",
        "some multi-\nline value"},
   };
-  TestFormFillFunctions(kFormHtml, false, nullptr,
-                        field_cases, arraysize(field_cases),
-                        &FillFormIncludingNonFocusableElementsWrapper,
-                        &GetValueWrapper);
+  TestFormFillFunctions(
+      kFormHtml, false, nullptr, field_cases, base::size(field_cases),
+      &FillFormIncludingNonFocusableElementsWrapper, &GetValueWrapper);
 }
 
 TEST_F(FormAutofillTest, PreviewForm) {
diff --git a/chrome/renderer/extensions/app_bindings.cc b/chrome/renderer/extensions/app_bindings.cc
index e44d35e8..77ffa86 100644
--- a/chrome/renderer/extensions/app_bindings.cc
+++ b/chrome/renderer/extensions/app_bindings.cc
@@ -7,6 +7,7 @@
 #include <memory>
 
 #include "base/bind.h"
+#include "base/stl_util.h"
 #include "extensions/renderer/script_context.h"
 #include "v8/include/v8.h"
 
@@ -76,7 +77,7 @@
           .ToLocalChecked(),
       v8::Integer::New(isolate, callback_id)};
   context()->module_system()->CallModuleMethodSafe(
-      "app", "onInstallStateResponse", arraysize(argv), argv);
+      "app", "onInstallStateResponse", base::size(argv), argv);
 }
 
 }  // namespace extensions
diff --git a/chrome/renderer/extensions/cast_streaming_native_handler.cc b/chrome/renderer/extensions/cast_streaming_native_handler.cc
index 92e08b8..b489179 100644
--- a/chrome/renderer/extensions/cast_streaming_native_handler.cc
+++ b/chrome/renderer/extensions/cast_streaming_native_handler.cc
@@ -17,8 +17,8 @@
 
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/system/sys_info.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -743,7 +743,7 @@
   v8::Local<v8::Value> callback_args[] = {V8ValueConverter::Create()->ToV8Value(
       raw_events.get(), context()->v8_context())};
   context()->SafeCallFunction(v8::Local<v8::Function>::New(isolate, it->second),
-                              arraysize(callback_args), callback_args);
+                              base::size(callback_args), callback_args);
   get_raw_events_callbacks_.erase(it);
 }
 
@@ -761,7 +761,7 @@
   v8::Local<v8::Value> callback_args[] = {V8ValueConverter::Create()->ToV8Value(
       stats.get(), context()->v8_context())};
   context()->SafeCallFunction(v8::Local<v8::Function>::New(isolate, it->second),
-                              arraysize(callback_args), callback_args);
+                              base::size(callback_args), callback_args);
   get_stats_callbacks_.erase(it);
 }
 
diff --git a/chrome/renderer/extensions/custom_types_unittest.cc b/chrome/renderer/extensions/custom_types_unittest.cc
index bef9040..635cc8a 100644
--- a/chrome/renderer/extensions/custom_types_unittest.cc
+++ b/chrome/renderer/extensions/custom_types_unittest.cc
@@ -5,6 +5,7 @@
 #include "extensions/renderer/storage_area.h"
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "components/crx_file/id_util.h"
 #include "extensions/common/extension_builder.h"
 #include "extensions/common/features/simple_feature.h"
@@ -59,12 +60,12 @@
     v8::Local<v8::Function> use_api =
         FunctionFromString(context, use_api_script);
     v8::Local<v8::Value> args[] = {api_object};
-    RunFunction(use_api, context, arraysize(args), args);
+    RunFunction(use_api, context, base::size(args), args);
 
     DisposeContext(context);
 
     EXPECT_FALSE(binding::IsContextValid(context));
-    RunFunctionAndExpectError(use_api, context, arraysize(args), args,
+    RunFunctionAndExpectError(use_api, context, base::size(args), args,
                               "Uncaught Error: Extension context invalidated.");
   }
 
diff --git a/chrome/renderer/net/net_error_helper_core.cc b/chrome/renderer/net/net_error_helper_core.cc
index 487d946..5b81f53d 100644
--- a/chrome/renderer/net/net_error_helper_core.cc
+++ b/chrome/renderer/net/net_error_helper_core.cc
@@ -22,9 +22,9 @@
 #include "base/json/json_writer.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
@@ -123,8 +123,8 @@
 base::TimeDelta GetAutoReloadTime(size_t reload_count) {
   static const int kDelaysMs[] = {0,      5000,   30000,  60000,
                                   300000, 600000, 1800000};
-  if (reload_count >= arraysize(kDelaysMs))
-    reload_count = arraysize(kDelaysMs) - 1;
+  if (reload_count >= base::size(kDelaysMs))
+    reload_count = base::size(kDelaysMs) - 1;
   return base::TimeDelta::FromMilliseconds(kDelaysMs[reload_count]);
 }
 
@@ -339,7 +339,7 @@
 
     size_t correction_index;
     for (correction_index = 0;
-         correction_index < arraysize(kCorrectionResourceTable);
+         correction_index < base::size(kCorrectionResourceTable);
          ++correction_index) {
       if ((*it)->correction_type !=
           kCorrectionResourceTable[correction_index].correction_type) {
@@ -403,7 +403,7 @@
 
   size_t correction_index;
   for (correction_index = 0;
-       correction_index < arraysize(kCorrectionResourceTable);
+       correction_index < base::size(kCorrectionResourceTable);
        ++correction_index) {
     if (kCorrectionResourceTable[correction_index].correction_type == type_id) {
       UMA_HISTOGRAM_ENUMERATION(
diff --git a/chrome/renderer/net/net_error_helper_core_unittest.cc b/chrome/renderer/net/net_error_helper_core_unittest.cc
index 9a81fab..9658363 100644
--- a/chrome/renderer/net/net_error_helper_core_unittest.cc
+++ b/chrome/renderer/net/net_error_helper_core_unittest.cc
@@ -16,8 +16,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/metrics/histogram_tester.h"
@@ -1304,7 +1304,7 @@
 
   // Corrections are retrieved.
   NavigationCorrectionsLoadSuccess(kDefaultCorrections,
-                                   arraysize(kDefaultCorrections));
+                                   base::size(kDefaultCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   ExpectDefaultNavigationCorrections();
@@ -1357,7 +1357,7 @@
   // Corrections are retrieved.
   EXPECT_TRUE(is_url_being_fetched());
   NavigationCorrectionsLoadSuccess(kDefaultCorrections,
-                                   arraysize(kDefaultCorrections));
+                                   base::size(kDefaultCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   ExpectDefaultNavigationCorrections();
@@ -1634,7 +1634,7 @@
 
   // Corrections request succeeds.
   NavigationCorrectionsLoadSuccess(kDefaultCorrections,
-                                   arraysize(kDefaultCorrections));
+                                   base::size(kDefaultCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   ExpectDefaultNavigationCorrections();
@@ -1746,7 +1746,7 @@
 
   // Corrections are retrieved.
   NavigationCorrectionsLoadSuccess(kDefaultCorrections,
-                                   arraysize(kDefaultCorrections));
+                                   base::size(kDefaultCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   EXPECT_FALSE(is_url_being_fetched());
@@ -1789,7 +1789,7 @@
 
   // Corrections are retrieved.
   NavigationCorrectionsLoadSuccess(kDefaultCorrections,
-                                   arraysize(kDefaultCorrections));
+                                   base::size(kDefaultCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   EXPECT_FALSE(is_url_being_fetched());
@@ -1831,7 +1831,7 @@
   EXPECT_FALSE(last_error_page_params());
 
   // Corrections are retrieved.
-  NavigationCorrectionsLoadSuccess(kCorrections, arraysize(kCorrections));
+  NavigationCorrectionsLoadSuccess(kCorrections, base::size(kCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   EXPECT_FALSE(is_url_being_fetched());
@@ -1879,7 +1879,7 @@
   EXPECT_FALSE(last_error_page_params());
 
   // Corrections are retrieved.
-  NavigationCorrectionsLoadSuccess(kCorrections, arraysize(kCorrections));
+  NavigationCorrectionsLoadSuccess(kCorrections, base::size(kCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   EXPECT_FALSE(is_url_being_fetched());
@@ -2004,7 +2004,7 @@
 
   // Corrections are retrieved.
   NavigationCorrectionsLoadSuccess(kDefaultCorrections,
-                                   arraysize(kDefaultCorrections));
+                                   base::size(kDefaultCorrections));
   EXPECT_EQ(1, error_html_update_count());
   EXPECT_EQ(NetErrorString(net::ERR_NAME_NOT_RESOLVED), last_error_html());
   ExpectDefaultNavigationCorrections();
@@ -2020,10 +2020,10 @@
 
   // Invalid clicks should be ignored.
   core()->TrackClick(-1);
-  core()->TrackClick(arraysize(kDefaultCorrections));
+  core()->TrackClick(base::size(kDefaultCorrections));
   EXPECT_EQ(0, tracking_request_count());
 
-  for (size_t i = 0; i < arraysize(kDefaultCorrections); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultCorrections); ++i) {
     // Skip links that do not appear in the page.
     if (kDefaultCorrections[i].is_porn || kDefaultCorrections[i].is_soft_porn)
       continue;
@@ -2047,7 +2047,7 @@
   }
 
   // Make sure duplicate tracking requests are ignored.
-  for (size_t i = 0; i < arraysize(kDefaultCorrections); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultCorrections); ++i) {
     // Skip links that do not appear in the page.
     if (kDefaultCorrections[i].is_porn || kDefaultCorrections[i].is_soft_porn)
       continue;
diff --git a/chrome/renderer/pepper/pepper_flash_renderer_host.cc b/chrome/renderer/pepper/pepper_flash_renderer_host.cc
index d7084ac..caae499c 100644
--- a/chrome/renderer/pepper/pepper_flash_renderer_host.cc
+++ b/chrome/renderer/pepper/pepper_flash_renderer_host.cc
@@ -9,9 +9,9 @@
 #include <map>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "components/pdf/renderer/pepper_pdf_host.h"
 #include "content/public/renderer/pepper_plugin_instance.h"
@@ -307,7 +307,7 @@
   std::map<std::string, FlashNavigateUsage>& rejected_headers =
       GetRejectedHeaders();
   if (rejected_headers.empty()) {
-    for (size_t i = 0; i < arraysize(kRejectedHttpRequestHeaders); ++i)
+    for (size_t i = 0; i < base::size(kRejectedHttpRequestHeaders); ++i)
       rejected_headers[kRejectedHttpRequestHeaders[i]] =
           static_cast<FlashNavigateUsage>(i);
   }
diff --git a/chrome/renderer/pepper/pepper_uma_host.cc b/chrome/renderer/pepper/pepper_uma_host.cc
index b3e4a3a..f26197e 100644
--- a/chrome/renderer/pepper/pepper_uma_host.cc
+++ b/chrome/renderer/pepper/pepper_uma_host.cc
@@ -6,9 +6,9 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/metrics/histogram.h"
 #include "base/sha1.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "chrome/common/chrome_content_client.h"
@@ -75,11 +75,11 @@
         host->GetPluginInstance(instance)->GetModulePath().BaseName();
   }
 
-  for (size_t i = 0; i < arraysize(kPredefinedAllowedUMAOrigins); ++i)
+  for (size_t i = 0; i < base::size(kPredefinedAllowedUMAOrigins); ++i)
     allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]);
-  for (size_t i = 0; i < arraysize(kWhitelistedHistogramPrefixes); ++i)
+  for (size_t i = 0; i < base::size(kWhitelistedHistogramPrefixes); ++i)
     allowed_histogram_prefixes_.insert(kWhitelistedHistogramPrefixes[i]);
-  for (size_t i = 0; i < arraysize(kWhitelistedPluginBaseNames); ++i)
+  for (size_t i = 0; i < base::size(kWhitelistedPluginBaseNames); ++i)
     allowed_plugin_base_names_.insert(kWhitelistedPluginBaseNames[i]);
 }
 
diff --git a/chrome/renderer/plugins/plugin_uma.cc b/chrome/renderer/plugins/plugin_uma.cc
index 467e9ab..201e41e50 100644
--- a/chrome/renderer/plugins/plugin_uma.cc
+++ b/chrome/renderer/plugins/plugin_uma.cc
@@ -7,8 +7,8 @@
 #include <algorithm>
 #include <cstring>
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "content/public/common/content_constants.h"
 
@@ -125,25 +125,25 @@
   std::string file_extension;
   ExtractFileExtension(src, &file_extension);
   if (CStringArrayContainsCString(kWindowsMediaPlayerExtensions,
-                                  arraysize(kWindowsMediaPlayerExtensions),
+                                  base::size(kWindowsMediaPlayerExtensions),
                                   file_extension.c_str())) {
     return WINDOWS_MEDIA_PLAYER;
   }
 
   if (CStringArrayContainsCString(kQuickTimeExtensions,
-                                  arraysize(kQuickTimeExtensions),
+                                  base::size(kQuickTimeExtensions),
                                   file_extension.c_str())) {
     return QUICKTIME;
   }
 
   if (CStringArrayContainsCString(kRealPlayerExtensions,
-                                  arraysize(kRealPlayerExtensions),
+                                  base::size(kRealPlayerExtensions),
                                   file_extension.c_str())) {
     return REALPLAYER;
   }
 
   if (CStringArrayContainsCString(kShockwaveFlashExtensions,
-                                  arraysize(kShockwaveFlashExtensions),
+                                  base::size(kShockwaveFlashExtensions),
                                   file_extension.c_str())) {
     return SHOCKWAVE_FLASH;
   }
diff --git a/chrome/renderer/searchbox/searchbox_unittest.cc b/chrome/renderer/searchbox/searchbox_unittest.cc
index e9e5260..747fe74 100644
--- a/chrome/renderer/searchbox/searchbox_unittest.cc
+++ b/chrome/renderer/searchbox/searchbox_unittest.cc
@@ -9,7 +9,7 @@
 #include <map>
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/search/instant_types.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
@@ -130,7 +130,7 @@
     "blahblah",
     "0xA/0x10",
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     int view_id = -1;
     InstantRestrictedID rid = -1;
     EXPECT_FALSE(ParseViewIdAndRestrictedId(test_cases[i], &view_id, &rid))
@@ -151,7 +151,7 @@
       {"chrome-search://favicon/size/16@2x/3/4", "size/16@2x/", 3, 4},
       {"chrome-search://favicon/iconurl/9/10", "iconurl/", 9, 10},
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::string param_part = "(unwritten)";
     int view_id = -1;
     InstantRestrictedID rid = -1;
@@ -177,7 +177,7 @@
       {"chrome-search://favicon/largest/http://www.google.com"},
       {"chrome-search://favicon/size/16@2x/-1/10"},
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::string param_part = "(unwritten)";
     int view_id = -1;
     InstantRestrictedID rid = -1;
@@ -208,7 +208,7 @@
   };
 
   MockIconURLHelper helper;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     GURL url;
     GURL transient_url(test_cases[i].transient_url_str);
     TranslateIconRestrictedUrl(transient_url, helper, &url);
diff --git a/chrome/renderer/web_apps_unittest.cc b/chrome/renderer/web_apps_unittest.cc
index 0cd91fc..44c3008 100644
--- a/chrome/renderer/web_apps_unittest.cc
+++ b/chrome/renderer/web_apps_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -43,7 +43,7 @@
     { " 10x11 ",    true, false, 1, 10, 11, 0, 0 },
     { " 10x11 1x2", true, false, 2, 10, 11, 1, 2 },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     bool is_any;
     std::vector<gfx::Size> sizes;
     bool result = web_apps::ParseIconSizes(
diff --git a/chrome/service/cloud_print/connector_settings_unittest.cc b/chrome/service/cloud_print/connector_settings_unittest.cc
index 6b6b5963..3b870e6 100644
--- a/chrome/service/cloud_print/connector_settings_unittest.cc
+++ b/chrome/service/cloud_print/connector_settings_unittest.cc
@@ -10,9 +10,9 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
 #include "chrome/common/cloud_print/cloud_print_constants.h"
@@ -83,7 +83,7 @@
     "{'foo': []}",
     "{'foo',,}",
   };
-  for (size_t i = 0; i < arraysize(kEmptyJSons); ++i) {
+  for (size_t i = 0; i < base::size(kEmptyJSons); ++i) {
     std::unique_ptr<ServiceProcessPrefs> prefs(CreateTestFile(kEmptyJSons[i]));
     ConnectorSettings settings;
     settings.InitFrom(prefs.get());
diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc
index 68664618..7ad0232 100644
--- a/chrome/service/service_utility_process_host.cc
+++ b/chrome/service/service_utility_process_host.cc
@@ -17,12 +17,12 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/process/launch.h"
 #include "base/process/process_handle.h"
 #include "base/rand_util.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/task_runner_util.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -361,7 +361,7 @@
   // "content_utility". This is all set up here.
   service_manager_ = std::make_unique<service_manager::ServiceManager>(
       std::make_unique<NullServiceProcessLauncherFactory>(),
-      CreateServiceProcessCatalog());
+      CreateServiceProcessCatalog(), nullptr);
 
   service_manager::mojom::ServicePtr browser_proxy;
   service_manager_connection_ = content::ServiceManagerConnection::Create(
@@ -428,7 +428,7 @@
       switches::kVModule,
   };
   cmd_line->CopySwitchesFrom(service_command_line, kForwardSwitches,
-                             arraysize(kForwardSwitches));
+                             base::size(kForwardSwitches));
 
   if (sandbox) {
     mojo::PlatformChannel channel;
diff --git a/chrome/test/base/always_on_top_window_killer_win.cc b/chrome/test/base/always_on_top_window_killer_win.cc
index 12d227e8..d6eff4c3 100644
--- a/chrome/test/base/always_on_top_window_killer_win.cc
+++ b/chrome/test/base/always_on_top_window_killer_win.cc
@@ -13,8 +13,8 @@
 #include "base/command_line.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/process/process.h"
+#include "base/stl_util.h"
 #include "chrome/test/base/process_inspector_win.h"
 #include "chrome/test/base/save_desktop_snapshot_win.h"
 #include "ui/display/win/screen_win.h"
@@ -141,9 +141,9 @@
 // static
 base::string16 WindowEnumerator::GetWindowClass(HWND hwnd) {
   wchar_t buffer[257];  // Max is 256.
-  buffer[arraysize(buffer) - 1] = L'\0';
-  int name_len = ::GetClassName(hwnd, &buffer[0], arraysize(buffer));
-  if (name_len <= 0 || static_cast<size_t>(name_len) >= arraysize(buffer))
+  buffer[base::size(buffer) - 1] = L'\0';
+  int name_len = ::GetClassName(hwnd, &buffer[0], base::size(buffer));
+  if (name_len <= 0 || static_cast<size_t>(name_len) >= base::size(buffer))
     return base::string16();
   return base::string16(&buffer[0], name_len);
 }
diff --git a/chrome/test/base/in_process_browser_test_browsertest.cc b/chrome/test/base/in_process_browser_test_browsertest.cc
index 61841a8..97433a2 100644
--- a/chrome/test/base/in_process_browser_test_browsertest.cc
+++ b/chrome/test/base/in_process_browser_test_browsertest.cc
@@ -6,8 +6,8 @@
 #include <string.h>
 
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "chrome/browser/after_startup_task_utils.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -77,7 +77,7 @@
     "http://www.google.com/",
     "http://www.cnn.com/"
   };
-  for (size_t i = 0; i < arraysize(kURLs); ++i) {
+  for (size_t i = 0; i < base::size(kURLs); ++i) {
     GURL url(kURLs[i]);
     LoadFailObserver observer(contents);
     ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/test/base/interactive_test_utils_win.cc b/chrome/test/base/interactive_test_utils_win.cc
index 7f0d98a..c5d9975 100644
--- a/chrome/test/base/interactive_test_utils_win.cc
+++ b/chrome/test/base/interactive_test_utils_win.cc
@@ -8,7 +8,7 @@
 
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "chrome/test/base/interactive_test_utils_aura.h"
 #include "ui/aura/window_tree_host.h"
@@ -63,7 +63,7 @@
       CloseHandle(process_handle);
     }
   }
-  GetWindowText(foreground_window, window_title, arraysize(window_title));
+  GetWindowText(foreground_window, window_title, base::size(window_title));
   LOG(ERROR) << "ShowAndFocusNativeWindow failed. foreground window: "
              << foreground_window << ", title: " << window_title << ", path: "
              << path_str;
diff --git a/chrome/test/chromedriver/capabilities.cc b/chrome/test/chromedriver/capabilities.cc
index 882c62a..f3baddb2 100644
--- a/chrome/test/chromedriver/capabilities.cc
+++ b/chrome/test/chromedriver/capabilities.cc
@@ -11,7 +11,7 @@
 #include "base/callback.h"
 #include "base/json/string_escape.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_tokenizer.h"
@@ -300,7 +300,7 @@
     const std::string kSocksProxy = "socksProxy";
     const base::Value* option_value = NULL;
     std::string proxy_servers;
-    for (size_t i = 0; i < arraysize(proxy_servers_options); ++i) {
+    for (size_t i = 0; i < base::size(proxy_servers_options); ++i) {
       if (!proxy_dict->Get(proxy_servers_options[i][0], &option_value) ||
           option_value->is_none()) {
         continue;
diff --git a/chrome/test/chromedriver/chrome/chrome_finder.cc b/chrome/test/chromedriver/chrome/chrome_finder.cc
index 4194f510e..acf43084 100644
--- a/chrome/test/chromedriver/chrome/chrome_finder.cc
+++ b/chrome/test/chromedriver/chrome/chrome_finder.cc
@@ -15,8 +15,8 @@
 #include "base/environment.h"
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -147,7 +147,7 @@
   };
 
   std::vector<base::FilePath> browser_exes(
-      browser_exes_array, browser_exes_array + arraysize(browser_exes_array));
+      browser_exes_array, browser_exes_array + base::size(browser_exes_array));
   base::FilePath module_dir;
   if (base::PathService::Get(base::DIR_MODULE, &module_dir)) {
     for (size_t i = 0; i < browser_exes.size(); ++i) {
diff --git a/chrome/test/chromedriver/chrome/heap_snapshot_taker.cc b/chrome/test/chromedriver/chrome/heap_snapshot_taker.cc
index 38109e4f..2eff863 100644
--- a/chrome/test/chromedriver/chrome/heap_snapshot_taker.cc
+++ b/chrome/test/chromedriver/chrome/heap_snapshot_taker.cc
@@ -9,7 +9,7 @@
 
 #include "base/json/json_reader.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/test/chromedriver/chrome/devtools_client.h"
 #include "chrome/test/chromedriver/chrome/status.h"
@@ -52,7 +52,7 @@
       "HeapProfiler.collectGarbage",
       "HeapProfiler.takeHeapSnapshot"
   };
-  for (size_t i = 0; i < arraysize(kMethods); ++i) {
+  for (size_t i = 0; i < base::size(kMethods); ++i) {
     Status status = client_->SendCommand(kMethods[i], params);
     if (status.IsError())
       return status;
diff --git a/chrome/test/chromedriver/chrome/heap_snapshot_taker_unittest.cc b/chrome/test/chromedriver/chrome/heap_snapshot_taker_unittest.cc
index 9dff36c1..977e3d0 100644
--- a/chrome/test/chromedriver/chrome/heap_snapshot_taker_unittest.cc
+++ b/chrome/test/chromedriver/chrome/heap_snapshot_taker_unittest.cc
@@ -11,7 +11,7 @@
 #include <string>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chrome/test/chromedriver/chrome/status.h"
 #include "chrome/test/chromedriver/chrome/stub_devtools_client.h"
@@ -42,7 +42,7 @@
   Status SendAddHeapSnapshotChunkEvent() {
     base::DictionaryValue event_params;
     event_params.SetInteger("uid", uid_);
-    for (size_t i = 0; i < arraysize(chunks); ++i) {
+    for (size_t i = 0; i < base::size(chunks); ++i) {
       event_params.SetString("chunk", chunks[i]);
       Status status = listeners_.front()->OnEvent(
           this, "HeapProfiler.addHeapSnapshotChunk", event_params);
diff --git a/chrome/test/chromedriver/key_converter.cc b/chrome/test/chromedriver/key_converter.cc
index b23f85e..612c9cc 100644
--- a/chrome/test/chromedriver/key_converter.cc
+++ b/chrome/test/chromedriver/key_converter.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/test/chromedriver/chrome/status.h"
@@ -128,8 +128,8 @@
 bool KeyCodeFromSpecialWebDriverKey(base::char16 key,
                                     ui::KeyboardCode* key_code) {
   int index = static_cast<int>(key) - 0xE000U;
-  bool is_special_key = index >= 0 &&
-      index < static_cast<int>(arraysize(kSpecialWebDriverKeys));
+  bool is_special_key =
+      index >= 0 && index < static_cast<int>(base::size(kSpecialWebDriverKeys));
   if (is_special_key)
     *key_code = kSpecialWebDriverKeys[index];
   return is_special_key;
diff --git a/chrome/test/chromedriver/key_converter_unittest.cc b/chrome/test/chromedriver/key_converter_unittest.cc
index b88a7af..dc83a00 100644
--- a/chrome/test/chromedriver/key_converter_unittest.cc
+++ b/chrome/test/chromedriver/key_converter_unittest.cc
@@ -7,7 +7,7 @@
 #include <list>
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -389,7 +389,7 @@
           << "Index: " << i;
       if (i == 0) {
         EXPECT_EQ(0u, events.size()) << "Index: " << i;
-      } else if (i >= arraysize(kTextForKeys) || kTextForKeys[i] == 0) {
+      } else if (i >= base::size(kTextForKeys) || kTextForKeys[i] == 0) {
         EXPECT_EQ(2u, events.size()) << "Index: " << i;
       } else {
         ASSERT_EQ(3u, events.size()) << "Index: " << i;
diff --git a/chrome/test/chromedriver/keycode_text_conversion_x.cc b/chrome/test/chromedriver/keycode_text_conversion_x.cc
index a7cb15c..f2b59e4 100644
--- a/chrome/test/chromedriver/keycode_text_conversion_x.cc
+++ b/chrome/test/chromedriver/keycode_text_conversion_x.cc
@@ -9,7 +9,7 @@
 #include <string.h>
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/test/chromedriver/chrome/ui_events.h"
 #include "ui/base/x/x11_util.h"
@@ -139,9 +139,9 @@
   KeyCodeAndXKeyCode find;
   find.key_code = key_code;
   const KeyCodeAndXKeyCode* found = std::lower_bound(
-      kKeyCodeToXKeyCode, kKeyCodeToXKeyCode + arraysize(kKeyCodeToXKeyCode),
+      kKeyCodeToXKeyCode, kKeyCodeToXKeyCode + base::size(kKeyCodeToXKeyCode),
       find);
-  if (found >= kKeyCodeToXKeyCode + arraysize(kKeyCodeToXKeyCode) ||
+  if (found >= kKeyCodeToXKeyCode + base::size(kKeyCodeToXKeyCode) ||
       found->key_code != key_code)
     return -1;
   return found->x_key_code;
@@ -244,7 +244,7 @@
   int test_modifiers;
   *error_msg = std::string();
   std::string conv_string;
-  for (size_t i = 0; i < arraysize(kKeyCodeToXKeyCode); ++i) {
+  for (size_t i = 0; i < base::size(kKeyCodeToXKeyCode); ++i) {
     test_code = kKeyCodeToXKeyCode[i].key_code;
     // Skip the numpad keys.
     if (test_code >= ui::VKEY_NUMPAD0 && test_code <= ui::VKEY_DIVIDE)
diff --git a/chrome/test/chromedriver/logging.cc b/chrome/test/chromedriver/logging.cc
index e3712cd..6819978 100644
--- a/chrome/test/chromedriver/logging.cc
+++ b/chrome/test/chromedriver/logging.cc
@@ -14,7 +14,7 @@
 #include "base/command_line.h"
 #include "base/json/json_reader.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
@@ -51,7 +51,7 @@
 const char* LevelToName(Log::Level level) {
   const int index = level - Log::kAll;
   CHECK_GE(index, 0);
-  CHECK_LT(static_cast<size_t>(index), arraysize(kLevelToName));
+  CHECK_LT(static_cast<size_t>(index), base::size(kLevelToName));
   return kLevelToName[index];
 }
 
@@ -134,7 +134,7 @@
 const char WebDriverLog::kDevToolsType[] = "devtools";
 
 bool WebDriverLog::NameToLevel(const std::string& name, Log::Level* out_level) {
-  for (size_t i = 0; i < arraysize(kNameToLevel); ++i) {
+  for (size_t i = 0; i < base::size(kNameToLevel); ++i) {
     if (name == kNameToLevel[i].name) {
       *out_level = kNameToLevel[i].level;
       return true;
diff --git a/chrome/test/chromedriver/logging_unittest.cc b/chrome/test/chromedriver/logging_unittest.cc
index b3b0c90..5abf739 100644
--- a/chrome/test/chromedriver/logging_unittest.cc
+++ b/chrome/test/chromedriver/logging_unittest.cc
@@ -8,7 +8,7 @@
 #include <vector>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "chrome/test/chromedriver/capabilities.h"
@@ -30,7 +30,7 @@
 
 TEST(Logging, NameLevelConversionHappy) {
   // All names map to a valid enum value.
-  for (int i = 0; static_cast<size_t>(i) < arraysize(kAllWdLevels); ++i) {
+  for (int i = 0; static_cast<size_t>(i) < base::size(kAllWdLevels); ++i) {
     Log::Level level = static_cast<Log::Level>(-1);
     EXPECT_TRUE(WebDriverLog::NameToLevel(kAllWdLevels[i], &level));
     EXPECT_LE(Log::kAll, level);
diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc
index ef0ba10..30f0f72 100644
--- a/chrome/test/chromedriver/server/chromedriver_server.cc
+++ b/chrome/test/chromedriver/server/chromedriver_server.cc
@@ -20,7 +20,6 @@
 #include "base/files/file_util.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
@@ -377,7 +376,7 @@
         "comma-separated whitelist of remote IP addresses "
         "which are allowed to connect to ChromeDriver",
     };
-    for (size_t i = 0; i < arraysize(kOptionAndDescriptions) - 1; i += 2) {
+    for (size_t i = 0; i < base::size(kOptionAndDescriptions) - 1; i += 2) {
       options += base::StringPrintf(
           "  --%-30s%s\n",
           kOptionAndDescriptions[i], kOptionAndDescriptions[i + 1]);
diff --git a/chrome/test/chromedriver/server/http_handler.cc b/chrome/test/chromedriver/server/http_handler.cc
index 5d8f8d66..c5804732 100644
--- a/chrome/test/chromedriver/server/http_handler.cc
+++ b/chrome/test/chromedriver/server/http_handler.cc
@@ -14,8 +14,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/logging.h"  // For CHECK macros.
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -786,8 +786,7 @@
           kPost, "session/:sessionId/touch/pinch",
           WrapToCommand("TouchPinch", base::BindRepeating(&ExecuteTouchPinch))),
   };
-  command_map_.reset(
-      new CommandMap(commands, commands + arraysize(commands)));
+  command_map_.reset(new CommandMap(commands, commands + base::size(commands)));
 }
 
 HttpHandler::~HttpHandler() {}
diff --git a/chrome/test/logging/win/file_logger.cc b/chrome/test/logging/win/file_logger.cc
index 13eca7b..48a6c27 100644
--- a/chrome/test/logging/win/file_logger.cc
+++ b/chrome/test/logging/win/file_logger.cc
@@ -15,7 +15,7 @@
 #include "base/files/file_path.h"
 #include "base/logging.h"
 #include "base/logging_win.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/event_trace_consumer.h"
@@ -54,7 +54,7 @@
   { &kChromeTestsProvider, 255, 0 },
 };
 
-static_assert((1 << arraysize(kProviders)) - 1 ==
+static_assert((1 << base::size(kProviders)) - 1 ==
                   FileLogger::kAllEventProviders,
               "size of kProviders is inconsistent with kAllEventProviders");
 
@@ -96,7 +96,7 @@
     logging::LogEventProvider::Initialize(kChromeTestsProvider);
 
   HRESULT hr = S_OK;
-  for (size_t i = 0; i < arraysize(kProviders); ++i) {
+  for (size_t i = 0; i < base::size(kProviders); ++i) {
     if (event_provider_mask_ & (1 << i)) {
       hr = controller_.EnableProvider(*kProviders[i].provider_name,
                                       kProviders[i].level,
@@ -115,7 +115,7 @@
 
 void FileLogger::DisableProviders() {
   HRESULT hr = S_OK;
-  for (size_t i = 0; i < arraysize(kProviders); ++i) {
+  for (size_t i = 0; i < base::size(kProviders); ++i) {
     if (event_provider_mask_ & (1 << i)) {
       hr = controller_.DisableProvider(*kProviders[i].provider_name);
       LOG_IF(ERROR, FAILED(hr)) << "Failed to disable event provider "
diff --git a/chrome/test/logging/win/log_file_printer.cc b/chrome/test/logging/win/log_file_printer.cc
index f4107f4..7842b2c 100644
--- a/chrome/test/logging/win/log_file_printer.cc
+++ b/chrome/test/logging/win/log_file_printer.cc
@@ -15,7 +15,7 @@
 
 #include "base/compiler_specific.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/time/time.h"
@@ -144,7 +144,7 @@
 void EventPrinter::PrintBadEvent(const EVENT_TRACE* event,
                                  const base::StringPiece& error) {
   wchar_t guid[64];
-  StringFromGUID2(event->Header.Guid, &guid[0], arraysize(guid));
+  StringFromGUID2(event->Header.Guid, &guid[0], base::size(guid));
   *out_ << error << " (class=" << guid << ", type="
        << static_cast<int>(event->Header.Class.Type) << ")";
 }
diff --git a/chrome/test/logging/win/mof_data_parser_unittest.cc b/chrome/test/logging/win/mof_data_parser_unittest.cc
index 4d5addf..ed05c76 100644
--- a/chrome/test/logging/win/mof_data_parser_unittest.cc
+++ b/chrome/test/logging/win/mof_data_parser_unittest.cc
@@ -7,7 +7,7 @@
 
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/test/logging/win/mof_data_parser.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -90,7 +90,7 @@
 // writing a DWORD item count followed by the items.
 TEST_F(MofDataParserTest, ReadPointerArray) {
   const void* const pointers[] = { this, &buffer_ };
-  const DWORD array_size = arraysize(pointers);
+  const DWORD array_size = base::size(pointers);
 
   // Read a valid array of two pointers.
   EVENT_TRACE* event = MakeEventWithPointerArray(&pointers[0], array_size);
@@ -160,30 +160,30 @@
 
   // Read a string with a trailing newline.
   EVENT_TRACE* event =
-      MakeEventWithString(a_string_nl, arraysize(a_string_nl));
+      MakeEventWithString(a_string_nl, base::size(a_string_nl));
   {
     base::StringPiece value;
     logging_win::MofDataParser parser(event);
     EXPECT_FALSE(parser.empty());
     EXPECT_TRUE(parser.ReadString(&value));
-    EXPECT_EQ(base::StringPiece(&a_string_nl[0], arraysize(a_string_nl) - 2),
+    EXPECT_EQ(base::StringPiece(&a_string_nl[0], base::size(a_string_nl) - 2),
               value);
     EXPECT_TRUE(parser.empty());
   }
 
   // Read a string without a trailing newline.
-  event = MakeEventWithString(a_string, arraysize(a_string));
+  event = MakeEventWithString(a_string, base::size(a_string));
   {
     base::StringPiece value;
     logging_win::MofDataParser parser(event);
     EXPECT_FALSE(parser.empty());
     EXPECT_TRUE(parser.ReadString(&value));
-    EXPECT_EQ(base::StringPiece(&a_string[0], arraysize(a_string) - 1), value);
+    EXPECT_EQ(base::StringPiece(&a_string[0], base::size(a_string) - 1), value);
     EXPECT_TRUE(parser.empty());
   }
 
   // Try a string that isn't terminated.
-  event = MakeEventWithString(a_string, arraysize(a_string) - 1);
+  event = MakeEventWithString(a_string, base::size(a_string) - 1);
   {
     base::StringPiece value;
     logging_win::MofDataParser parser(event);
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index 0559a40..db1c0776 100644
--- a/chrome/test/ppapi/ppapi_browsertest.cc
+++ b/chrome/test/ppapi/ppapi_browsertest.cc
@@ -7,9 +7,9 @@
 #include <vector>
 
 #include "base/callback.h"
-#include "base/macros.h"
 #include "base/optional.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/test/test_timeouts.h"
 #include "base/threading/thread_restrictions.h"
 #include "build/build_config.h"
@@ -1997,7 +1997,7 @@
                                    "InputEvent_AcceptTouchEvent_4"
                                  };
 
-  for (size_t i = 0; i < arraysize(positive_tests); ++i) {
+  for (size_t i = 0; i < base::size(positive_tests); ++i) {
     RunTest(positive_tests[i]);
     RenderViewHost* host = browser()->tab_strip_model()->
         GetActiveWebContents()->GetRenderViewHost();
diff --git a/chrome/test/remoting/key_code_conv.cc b/chrome/test/remoting/key_code_conv.cc
index 6ed6949..72838d5c 100644
--- a/chrome/test/remoting/key_code_conv.cc
+++ b/chrome/test/remoting/key_code_conv.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/test/remoting/key_code_map.h"
 
 namespace remoting {
@@ -20,7 +20,7 @@
   *code = NULL;
   *vkey_code = InvalidKeyboardCode();
 
-  for (size_t i = 0; i < arraysize(key_code_map); ++i) {
+  for (size_t i = 0; i < base::size(key_code_map); ++i) {
     if (key_code_map[i].lower_char == c) {
       *code = key_code_map[i].code;
       *vkey_code = key_code_map[i].vkey_code;
diff --git a/chrome/test/views/chrome_views_test_base.cc b/chrome/test/views/chrome_views_test_base.cc
index 0460f612..e378e6b 100644
--- a/chrome/test/views/chrome_views_test_base.cc
+++ b/chrome/test/views/chrome_views_test_base.cc
@@ -7,12 +7,13 @@
 #include "chrome/test/views/chrome_test_views_delegate.h"
 #include "content/public/test/test_browser_thread_bundle.h"
 
-ChromeViewsTestBase::ChromeViewsTestBase() = default;
-ChromeViewsTestBase::~ChromeViewsTestBase() = default;
+ChromeViewsTestBase::ChromeViewsTestBase()
+    : views::ViewsTestBase(
+          std::make_unique<content::TestBrowserThreadBundle>()) {}
+
+ChromeViewsTestBase::~ChromeViewsTestBase() {}
 
 void ChromeViewsTestBase::SetUp() {
-  set_scoped_task_environment(
-      std::make_unique<content::TestBrowserThreadBundle>());
   set_views_delegate(std::make_unique<ChromeTestViewsDelegate>());
   views::ViewsTestBase::SetUp();
 }
diff --git a/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp b/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp
index 10f56737..56b2da9 100644
--- a/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp
+++ b/chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp
@@ -48,7 +48,7 @@
 
 #include "base/i18n/number_formatting.h"
 #include "base/lazy_instance.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -841,7 +841,7 @@
     if (point->reasons.len) {
       rv += ' ';
       comma = false;
-      for (size_t i = 0; i < arraysize(reason_string_map); ++i) {
+      for (size_t i = 0; i < base::size(reason_string_map); ++i) {
         if (point->reasons.data[0] & reason_string_map[i].reason) {
           if (comma)
             rv += ',';
@@ -969,7 +969,7 @@
     {NS_CERT_TYPE_OBJECT_SIGNING_CA, IDS_CERT_USAGE_OBJECT_SIGNER},
   };
   return ProcessBitStringExtension(extension_data, usage_string_map,
-                                   arraysize(usage_string_map), '\n');
+                                   base::size(usage_string_map), '\n');
 }
 
 static const MaskIdPair key_usage_string_map[] = {
@@ -987,12 +987,12 @@
 
 std::string ProcessKeyUsageBitString(SECItem* bitstring, char sep) {
   return ProcessBitField(bitstring, key_usage_string_map,
-                         arraysize(key_usage_string_map), sep);
+                         base::size(key_usage_string_map), sep);
 }
 
 std::string ProcessKeyUsageExtension(SECItem* extension_data) {
   return ProcessBitStringExtension(extension_data, key_usage_string_map,
-                                   arraysize(key_usage_string_map), '\n');
+                                   base::size(key_usage_string_map), '\n');
 }
 
 std::string ProcessExtKeyUsage(SECItem* extension_data) {
diff --git a/chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.cpp b/chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.cpp
index 93b5b5d..9e2b58f 100644
--- a/chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.cpp
+++ b/chrome/third_party/mozilla_security_manager/nsUsageArrayHelper.cpp
@@ -39,7 +39,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/grit/generated_resources.h"
 #include "ui/base/l10n/l10n_util.h"
 
@@ -65,7 +65,7 @@
       {certificateUsageSSLCA, IDS_CERT_USAGE_SSL_CA},
       {certificateUsageStatusResponder, IDS_CERT_USAGE_STATUS_RESPONDER},
     };
-    for (size_t i = 0; i < arraysize(usage_string_map); ++i) {
+    for (size_t i = 0; i < base::size(usage_string_map); ++i) {
       if (usages & usage_string_map[i].usage)
         out->push_back(l10n_util::GetStringUTF8(
             usage_string_map[i].string_id));
diff --git a/chrome/tools/convert_dict/convert_dict_unittest.cc b/chrome/tools/convert_dict/convert_dict_unittest.cc
index a12752c..1afd2755 100644
--- a/chrome/tools/convert_dict/convert_dict_unittest.cc
+++ b/chrome/tools/convert_dict/convert_dict_unittest.cc
@@ -11,6 +11,7 @@
 #include "base/format_macros.h"
 #include "base/i18n/icu_string_conversions.h"
 #include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/tools/convert_dict/aff_reader.h"
@@ -146,7 +147,7 @@
   };
 
   std::map<base::string16, bool> word_list;
-  for (size_t i = 0; i < arraysize(kWords); ++i) {
+  for (size_t i = 0; i < base::size(kWords); ++i) {
     word_list.insert(
         std::make_pair<base::string16, bool>(base::WideToUTF16(kWords[i]),
                                              true));
@@ -170,7 +171,7 @@
   };
 
   std::map<base::string16, bool> word_list;
-  for (size_t i = 0; i < arraysize(kWords); ++i) {
+  for (size_t i = 0; i < base::size(kWords); ++i) {
     word_list.insert(
         std::make_pair<base::string16, bool>(base::WideToUTF16(kWords[i]),
                                              true));
@@ -196,7 +197,7 @@
   };
 
   std::map<base::string16, bool> word_list;
-  for (size_t i = 0; i < arraysize(kWords); ++i) {
+  for (size_t i = 0; i < base::size(kWords); ++i) {
     word_list.insert(
         std::make_pair<base::string16, bool>(base::WideToUTF16(kWords[i]),
                                              true));
diff --git a/chrome/utility/importer/bookmark_html_reader.cc b/chrome/utility/importer/bookmark_html_reader.cc
index 192af0c8..c16d369 100644
--- a/chrome/utility/importer/bookmark_html_reader.cc
+++ b/chrome/utility/importer/bookmark_html_reader.cc
@@ -10,7 +10,7 @@
 #include "base/callback.h"
 #include "base/files/file_util.h"
 #include "base/i18n/icu_string_conversions.h"
-#include "base/macros.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"
@@ -99,7 +99,7 @@
   static const char kDtTag[] = "<DT>";
   if (base::StartsWith(line, kDtTag,
                        base::CompareCase::INSENSITIVE_ASCII)) {
-    line.erase(0, arraysize(kDtTag) - 1);
+    line.erase(0, base::size(kDtTag) - 1);
     base::TrimString(line, " ", &line);
   }
   return line;
@@ -140,7 +140,7 @@
     static const char kHrTag[] = "<HR>";
     while (base::StartsWith(line, kHrTag,
                             base::CompareCase::INSENSITIVE_ASCII)) {
-      line.erase(0, arraysize(kHrTag) - 1);
+      line.erase(0, base::size(kHrTag) - 1);
       base::TrimString(line, " ", &line);
     }
 
@@ -340,15 +340,15 @@
   size_t end = line.find(kFolderClose);
   size_t tag_end = line.rfind('>', end) + 1;
   // If no end tag or start tag is broken, we skip to find the folder name.
-  if (end == std::string::npos || tag_end < arraysize(kFolderOpen))
+  if (end == std::string::npos || tag_end < base::size(kFolderOpen))
     return false;
 
   base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
                         base::OnStringConversionError::SKIP, folder_name);
   *folder_name = net::UnescapeForHTML(*folder_name);
 
-  std::string attribute_list = line.substr(arraysize(kFolderOpen),
-      tag_end - arraysize(kFolderOpen) - 1);
+  std::string attribute_list = line.substr(
+      base::size(kFolderOpen), tag_end - base::size(kFolderOpen) - 1);
   std::string value;
 
   // Add date
@@ -399,11 +399,11 @@
 
   size_t end = line.find(kItemClose);
   size_t tag_end = line.rfind('>', end) + 1;
-  if (end == std::string::npos || tag_end < arraysize(kItemOpen))
+  if (end == std::string::npos || tag_end < base::size(kItemOpen))
     return false;  // No end tag or start tag is broken.
 
-  std::string attribute_list = line.substr(arraysize(kItemOpen),
-      tag_end - arraysize(kItemOpen) - 1);
+  std::string attribute_list =
+      line.substr(base::size(kItemOpen), tag_end - base::size(kItemOpen) - 1);
 
   // We don't import Live Bookmark folders, which is Firefox's RSS reading
   // feature, since the user never necessarily bookmarked them and we don't
@@ -477,11 +477,11 @@
   // Find any close tag.
   size_t end = line.find(kItemClose);
   size_t tag_end = line.rfind('>', end) + 1;
-  if (end == std::string::npos || tag_end < arraysize(kItemOpen))
+  if (end == std::string::npos || tag_end < base::size(kItemOpen))
     return false;  // No end tag or start tag is broken.
 
-  std::string attribute_list = line.substr(arraysize(kItemOpen),
-      tag_end - arraysize(kItemOpen) - 1);
+  std::string attribute_list =
+      line.substr(base::size(kItemOpen), tag_end - base::size(kItemOpen) - 1);
 
   // Title
   base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
diff --git a/chrome/utility/importer/bookmark_html_reader_unittest.cc b/chrome/utility/importer/bookmark_html_reader_unittest.cc
index 12d48f0..264993a5 100644
--- a/chrome/utility/importer/bookmark_html_reader_unittest.cc
+++ b/chrome/utility/importer/bookmark_html_reader_unittest.cc
@@ -10,8 +10,8 @@
 #include "base/bind_helpers.h"
 #include "base/callback.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -192,7 +192,7 @@
   };
 
   std::string search_engine_url;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     EXPECT_EQ(test_cases[i].can_be_imported_as_search_engine,
         CanImportURLAsSearchEngine(GURL(test_cases[i].url),
                                    &search_engine_url));
diff --git a/chrome/utility/importer/bookmarks_file_importer.cc b/chrome/utility/importer/bookmarks_file_importer.cc
index 984e4660..82154b0 100644
--- a/chrome/utility/importer/bookmarks_file_importer.cc
+++ b/chrome/utility/importer/bookmarks_file_importer.cc
@@ -8,7 +8,7 @@
 
 #include "base/bind.h"
 #include "base/callback.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chrome/common/importer/imported_bookmark_entry.h"
 #include "chrome/common/importer/importer_bridge.h"
 #include "chrome/common/importer/importer_data_types.h"
@@ -38,7 +38,7 @@
 
   // Filter out the URLs with unsupported schemes.
   const char* const kInvalidSchemes[] = {"wyciwyg", "place"};
-  for (size_t i = 0; i < arraysize(kInvalidSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kInvalidSchemes); ++i) {
     if (url.SchemeIs(kInvalidSchemes[i]))
       return false;
   }
diff --git a/chrome/utility/importer/bookmarks_file_importer_unittest.cc b/chrome/utility/importer/bookmarks_file_importer_unittest.cc
index 07cd7bf..4a27c9c 100644
--- a/chrome/utility/importer/bookmarks_file_importer_unittest.cc
+++ b/chrome/utility/importer/bookmarks_file_importer_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
 
@@ -39,7 +39,7 @@
     { "about:moon", false },
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     EXPECT_EQ(test_cases[i].can_be_imported,
               internal::CanImportURL(GURL(test_cases[i].url)));
   }
diff --git a/chrome/utility/importer/edge_database_reader_unittest_win.cc b/chrome/utility/importer/edge_database_reader_unittest_win.cc
index d9a2d77..e76cab01 100644
--- a/chrome/utility/importer/edge_database_reader_unittest_win.cc
+++ b/chrome/utility/importer/edge_database_reader_unittest_win.cc
@@ -11,8 +11,8 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -279,7 +279,7 @@
   std::unique_ptr<EdgeDatabaseTableEnumerator> table_enum =
       reader.OpenTableEnumerator(L"UnicodeTable");
   EXPECT_NE(nullptr, table_enum);
-  size_t utf8_strings_count = arraysize(utf8_strings);
+  size_t utf8_strings_count = base::size(utf8_strings);
   for (size_t row_count = 0; row_count < utf8_strings_count; ++row_count) {
     std::wstring row_string = base::UTF8ToWide(utf8_strings[row_count]);
     base::string16 str_col_value;
diff --git a/chrome/utility/importer/firefox_importer.cc b/chrome/utility/importer/firefox_importer.cc
index f7ed312..ead3566 100644
--- a/chrome/utility/importer/firefox_importer.cc
+++ b/chrome/utility/importer/firefox_importer.cc
@@ -10,8 +10,8 @@
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
 #include "base/json/json_file_value_serializer.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -70,7 +70,7 @@
 
   // Filter out the URLs with unsupported schemes.
   const char* const kInvalidSchemes[] = {"wyciwyg", "place", "about", "chrome"};
-  for (size_t i = 0; i < arraysize(kInvalidSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kInvalidSchemes); ++i) {
     if (url.SchemeIs(kInvalidSchemes[i]))
       return false;
   }
diff --git a/chrome/utility/importer/safari_importer_unittest.mm b/chrome/utility/importer/safari_importer_unittest.mm
index 96ffe25f2..03c1eff 100644
--- a/chrome/utility/importer/safari_importer_unittest.mm
+++ b/chrome/utility/importer/safari_importer_unittest.mm
@@ -10,8 +10,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -141,7 +141,7 @@
   std::vector<ImportedBookmarkEntry> bookmarks;
   importer->ParseBookmarks(ASCIIToUTF16("Toolbar"), &bookmarks);
   size_t num_bookmarks = bookmarks.size();
-  ASSERT_EQ(arraysize(kImportedBookmarksData), num_bookmarks);
+  ASSERT_EQ(base::size(kImportedBookmarksData), num_bookmarks);
 
   for (size_t i = 0; i < num_bookmarks; ++i) {
     ImportedBookmarkEntry& entry = bookmarks[i];
@@ -206,7 +206,7 @@
   std::vector<ImportedBookmarkEntry> bookmarks;
   importer->ParseBookmarks(ASCIIToUTF16("Toolbar"), &bookmarks);
   size_t num_bookmarks = bookmarks.size();
-  ASSERT_EQ(arraysize(kImportedBookmarksData), num_bookmarks);
+  ASSERT_EQ(base::size(kImportedBookmarksData), num_bookmarks);
 
   for (size_t i = 0; i < num_bookmarks; ++i) {
     ImportedBookmarkEntry& entry = bookmarks[i];
diff --git a/chrome/utility/safe_browsing/mac/hfs.cc b/chrome/utility/safe_browsing/mac/hfs.cc
index 7a3fd89c..6b57ad73 100644
--- a/chrome/utility/safe_browsing/mac/hfs.cc
+++ b/chrome/utility/safe_browsing/mac/hfs.cc
@@ -13,8 +13,8 @@
 #include <vector>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/utility/safe_browsing/mac/convert_big_endian.h"
 #include "chrome/utility/safe_browsing/mac/read_stream.h"
@@ -29,7 +29,7 @@
   ConvertBigEndian(&fork->logicalSize);
   ConvertBigEndian(&fork->clumpSize);
   ConvertBigEndian(&fork->totalBlocks);
-  for (size_t i = 0; i < arraysize(fork->extents); ++i) {
+  for (size_t i = 0; i < base::size(fork->extents); ++i) {
     ConvertBigEndian(&fork->extents[i].startBlock);
     ConvertBigEndian(&fork->extents[i].blockCount);
   }
@@ -352,7 +352,7 @@
   if (fork_logical_offset_ == fork_.logicalSize)
     return true;
 
-  for (; current_extent_ < arraysize(fork_.extents); ++current_extent_) {
+  for (; current_extent_ < base::size(fork_.extents); ++current_extent_) {
     // If the buffer is out of space, do not attempt any reads. Check this
     // here, so that current_extent_ is advanced by the loop if the last
     // extent was fully read.
@@ -425,7 +425,7 @@
   DCHECK(offset == 0 || static_cast<uint64_t>(offset) < fork_.logicalSize);
   size_t target_block = offset / hfs_->block_size();
   size_t block_count = 0;
-  for (size_t i = 0; i < arraysize(fork_.extents); ++i) {
+  for (size_t i = 0; i < base::size(fork_.extents); ++i) {
     const HFSPlusExtentDescriptor* extent = &fork_.extents[i];
 
     // An empty extent indicates end-of-fork.
diff --git a/chrome/utility/safe_browsing/mac/hfs_unittest.cc b/chrome/utility/safe_browsing/mac/hfs_unittest.cc
index 7cb55df4..18a118b 100644
--- a/chrome/utility/safe_browsing/mac/hfs_unittest.cc
+++ b/chrome/utility/safe_browsing/mac/hfs_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "base/files/file.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -47,14 +47,14 @@
 
     const base::string16 dmg_name = base::ASCIIToUTF16("SafeBrowsingDMG/");
 
-    for (size_t i = 0; i < arraysize(kBaseFiles); ++i)
+    for (size_t i = 0; i < base::size(kBaseFiles); ++i)
       files->insert(dmg_name + base::ASCIIToUTF16(kBaseFiles[i]));
 
     files->insert(dmg_name + base::ASCIIToUTF16("first/second/") +
                   base::UTF8ToUTF16("Te\xCC\x86st\xCC\x88 \xF0\x9F\x90\x90 "));
 
     dirs->insert(dmg_name.substr(0, dmg_name.size() - 1));
-    for (size_t i = 0; i < arraysize(kBaseDirs); ++i)
+    for (size_t i = 0; i < base::size(kBaseDirs); ++i)
       dirs->insert(dmg_name + base::ASCIIToUTF16(kBaseDirs[i]));
 
     if (case_sensitive) {
diff --git a/chrome/utility/safe_browsing/mac/udif.cc b/chrome/utility/safe_browsing/mac/udif.cc
index 3bae29fb..5d3f05f0 100644
--- a/chrome/utility/safe_browsing/mac/udif.cc
+++ b/chrome/utility/safe_browsing/mac/udif.cc
@@ -15,8 +15,8 @@
 #include "base/logging.h"
 #include "base/mac/foundation_util.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "chrome/utility/safe_browsing/mac/convert_big_endian.h"
 #include "chrome/utility/safe_browsing/mac/read_stream.h"
@@ -41,7 +41,7 @@
 static void ConvertBigEndian(UDIFChecksum* checksum) {
   ConvertBigEndian(&checksum->type);
   ConvertBigEndian(&checksum->size);
-  for (size_t i = 0; i < arraysize(checksum->data); ++i) {
+  for (size_t i = 0; i < base::size(checksum->data); ++i) {
     ConvertBigEndian(&checksum->data[i]);
   }
 }
diff --git a/chromecast/base/metrics/grouped_histogram.cc b/chromecast/base/metrics/grouped_histogram.cc
index 1bc541c9..b459723 100644
--- a/chromecast/base/metrics/grouped_histogram.cc
+++ b/chromecast/base/metrics/grouped_histogram.cc
@@ -8,10 +8,10 @@
 #include <stdint.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/stringprintf.h"
 #include "base/synchronization/lock.h"
@@ -168,7 +168,7 @@
 } // namespace
 
 void PreregisterAllGroupedHistograms() {
-  for (size_t i = 0; i < arraysize(kHistogramsToGroup); ++i) {
+  for (size_t i = 0; i < base::size(kHistogramsToGroup); ++i) {
     PreregisterHistogram(
         kHistogramsToGroup[i].name,
         kHistogramsToGroup[i].minimum,
diff --git a/chromecast/browser/cast_browser_main_parts.cc b/chromecast/browser/cast_browser_main_parts.cc
index 2a53c8d..add06dc 100644
--- a/chromecast/browser/cast_browser_main_parts.cc
+++ b/chromecast/browser/cast_browser_main_parts.cc
@@ -13,12 +13,12 @@
 #include "base/command_line.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/threading/thread.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -147,7 +147,7 @@
 
 void RegisterClosureOnSignal(const base::Closure& closure) {
   DCHECK(!g_signal_closure);
-  DCHECK_GT(arraysize(kSignalsToRunClosure), 0U);
+  DCHECK_GT(base::size(kSignalsToRunClosure), 0U);
 
   // Memory leak on purpose, since |g_signal_closure| should live until
   // process exit.
diff --git a/chromecast/browser/cast_content_browser_client.cc b/chromecast/browser/cast_content_browser_client.cc
index 6510bff9..2ecb3e5 100644
--- a/chromecast/browser/cast_content_browser_client.cc
+++ b/chromecast/browser/cast_content_browser_client.cc
@@ -15,8 +15,8 @@
 #include "base/files/scoped_file.h"
 #include "base/i18n/rtl.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
@@ -432,7 +432,7 @@
   };
 
   const std::string& scheme = url.scheme();
-  for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
+  for (size_t i = 0; i < base::size(kProtocolList); ++i) {
     if (scheme == kProtocolList[i])
       return true;
   }
@@ -498,7 +498,7 @@
         switches::kForceMediaResolutionHeight,
         switches::kForceMediaResolutionWidth};
     command_line->CopySwitchesFrom(*browser_command_line, kForwardSwitches,
-                                   arraysize(kForwardSwitches));
+                                   base::size(kForwardSwitches));
   } else if (process_type == switches::kUtilityProcess) {
     if (browser_command_line->HasSwitch(switches::kAudioOutputChannels)) {
       command_line->AppendSwitchASCII(switches::kAudioOutputChannels,
@@ -519,7 +519,7 @@
         switches::kVSyncInterval,
     };
     command_line->CopySwitchesFrom(*browser_command_line, kForwardSwitches,
-                                   arraysize(kForwardSwitches));
+                                   base::size(kForwardSwitches));
 
     auto display = display::Screen::GetScreen()->GetPrimaryDisplay();
     gfx::Size res = display.GetSizeInPixel();
diff --git a/chromecast/browser/cast_extension_message_filter.cc b/chromecast/browser/cast_extension_message_filter.cc
index 3b72bea..9899d33 100644
--- a/chromecast/browser/cast_extension_message_filter.cc
+++ b/chromecast/browser/cast_extension_message_filter.cc
@@ -10,8 +10,8 @@
 #include "base/bind_helpers.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
 #include "chromecast/common/extensions_api/cast_extension_messages.h"
@@ -41,7 +41,7 @@
     int render_process_id,
     content::BrowserContext* context)
     : BrowserMessageFilter(kExtensionFilteredMessageClasses,
-                           arraysize(kExtensionFilteredMessageClasses)),
+                           base::size(kExtensionFilteredMessageClasses)),
       render_process_id_(render_process_id),
       context_(context),
       extension_info_map_(
diff --git a/chromecast/media/audio/cast_audio_manager_alsa.cc b/chromecast/media/audio/cast_audio_manager_alsa.cc
index 74c5222..bc4af575 100644
--- a/chromecast/media/audio/cast_audio_manager_alsa.cc
+++ b/chromecast/media/audio/cast_audio_manager_alsa.cc
@@ -8,6 +8,7 @@
 #include <utility>
 
 #include "base/memory/free_deleter.h"
+#include "base/stl_util.h"
 #include "chromecast/media/cma/backend/cma_backend_factory.h"
 #include "media/audio/alsa/alsa_input.h"
 #include "media/audio/alsa/alsa_wrapper.h"
@@ -188,7 +189,7 @@
   // it or not.
   if (type == kStreamCapture) {
     // Check if the device is in the list of invalid devices.
-    for (size_t i = 0; i < arraysize(kInvalidAudioInputDevices); ++i) {
+    for (size_t i = 0; i < base::size(kInvalidAudioInputDevices); ++i) {
       if (strncmp(kInvalidAudioInputDevices[i], device_name,
                   strlen(kInvalidAudioInputDevices[i])) == 0)
         return false;
@@ -202,7 +203,7 @@
     // TODO(joi): Should we prefer "hw" instead?
     static const char kDeviceTypeDesired[] = "plughw";
     return strncmp(kDeviceTypeDesired, device_name,
-                   arraysize(kDeviceTypeDesired) - 1) == 0;
+                   base::size(kDeviceTypeDesired) - 1) == 0;
   }
 }
 
diff --git a/chromecast/media/audio/cast_audio_output_stream_unittest.cc b/chromecast/media/audio/cast_audio_output_stream_unittest.cc
index eaead526..5beb1ab 100644
--- a/chromecast/media/audio/cast_audio_output_stream_unittest.cc
+++ b/chromecast/media/audio/cast_audio_output_stream_unittest.cc
@@ -12,6 +12,7 @@
 #include "base/bind.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/time/time.h"
 #include "chromecast/common/mojom/constants.mojom.h"
@@ -543,7 +544,7 @@
   ::media::AudioParameters::Format format[] = {
       ::media::AudioParameters::AUDIO_PCM_LINEAR,
       ::media::AudioParameters::AUDIO_PCM_LOW_LATENCY};
-  for (size_t i = 0; i < arraysize(format); ++i) {
+  for (size_t i = 0; i < base::size(format); ++i) {
     format_ = format[i];
     ::media::AudioOutputStream* stream = CreateStream();
     ASSERT_TRUE(stream);
@@ -564,7 +565,7 @@
 TEST_F(CastAudioOutputStreamTest, ChannelLayout) {
   ::media::ChannelLayout layout[] = {::media::CHANNEL_LAYOUT_MONO,
                                      ::media::CHANNEL_LAYOUT_STEREO};
-  for (size_t i = 0; i < arraysize(layout); ++i) {
+  for (size_t i = 0; i < base::size(layout); ++i) {
     channel_layout_ = layout[i];
     ::media::AudioOutputStream* stream = CreateStream();
     ASSERT_TRUE(stream);
diff --git a/chromecast/media/cdm/playready_drm_delegate_android.cc b/chromecast/media/cdm/playready_drm_delegate_android.cc
index 1d8b591..88fb704f 100644
--- a/chromecast/media/cdm/playready_drm_delegate_android.cc
+++ b/chromecast/media/cdm/playready_drm_delegate_android.cc
@@ -5,7 +5,7 @@
 #include "chromecast/media/cdm/playready_drm_delegate_android.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chromecast/media/cdm/chromecast_init_data.h"
 
 namespace chromecast {
@@ -23,7 +23,7 @@
 
 const ::media::UUID PlayreadyDrmDelegateAndroid::GetUUID() const {
   return ::media::UUID(kPlayreadyUuid,
-                       kPlayreadyUuid + arraysize(kPlayreadyUuid));
+                       kPlayreadyUuid + base::size(kPlayreadyUuid));
 }
 
 bool PlayreadyDrmDelegateAndroid::OnCreateSession(
diff --git a/chromecast/media/cma/backend/alsa/mixer_output_stream_alsa.cc b/chromecast/media/cma/backend/alsa/mixer_output_stream_alsa.cc
index 232b3312..da953a74 100644
--- a/chromecast/media/cma/backend/alsa/mixer_output_stream_alsa.cc
+++ b/chromecast/media/cma/backend/alsa/mixer_output_stream_alsa.cc
@@ -5,6 +5,7 @@
 #include "chromecast/media/cma/backend/alsa/mixer_output_stream_alsa.h"
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "chromecast/base/chromecast_switches.h"
 #include "chromecast/media/cma/backend/alsa/alsa_wrapper.h"
@@ -439,7 +440,7 @@
   // doesn't always choose a rate that's actually near the given input sample
   // rate when the input sample rate is not supported.
   const int* kSupportedSampleRatesEnd =
-      kSupportedSampleRates + arraysize(kSupportedSampleRates);
+      kSupportedSampleRates + base::size(kSupportedSampleRates);
   auto* nearest_sample_rate =
       std::min_element(kSupportedSampleRates, kSupportedSampleRatesEnd,
                        [requested_sample_rate](int r1, int r2) -> bool {
diff --git a/chromecast/media/cma/base/balanced_media_task_runner_unittest.cc b/chromecast/media/cma/base/balanced_media_task_runner_unittest.cc
index df537d8..51fb542 100644
--- a/chromecast/media/cma/base/balanced_media_task_runner_unittest.cc
+++ b/chromecast/media/cma/base/balanced_media_task_runner_unittest.cc
@@ -10,12 +10,12 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -218,7 +218,7 @@
   int timestamps0_ms[] = {0, 10, 20, 30, 40, 30, 50, 60, 20, 30, 70};
   std::vector<std::vector<int> > timestamps_ms(1);
   timestamps_ms[0] = std::vector<int>(
-      timestamps0_ms, timestamps0_ms + arraysize(timestamps0_ms));
+      timestamps0_ms, timestamps0_ms + base::size(timestamps0_ms));
 
   // Scheduling pattern.
   std::vector<size_t> scheduling_pattern(1);
@@ -226,9 +226,9 @@
 
   // Expected results.
   int expected_timestamps[] = {0, 10, 20, 30, 40, 50, 60, 70};
-  std::vector<int> expected_timestamps_ms(std::vector<int>(
-      expected_timestamps,
-      expected_timestamps + arraysize(expected_timestamps)));
+  std::vector<int> expected_timestamps_ms(
+      std::vector<int>(expected_timestamps,
+                       expected_timestamps + base::size(expected_timestamps)));
 
   SetupTest(base::TimeDelta::FromMilliseconds(30),
             timestamps_ms,
@@ -247,21 +247,21 @@
   int timestamps1_ms[] = {5, 15, 25, 35, 45, 35, 55, 65, 25, 35, 75};
   std::vector<std::vector<int> > timestamps_ms(2);
   timestamps_ms[0] = std::vector<int>(
-      timestamps0_ms, timestamps0_ms + arraysize(timestamps0_ms));
+      timestamps0_ms, timestamps0_ms + base::size(timestamps0_ms));
   timestamps_ms[1] = std::vector<int>(
-      timestamps1_ms, timestamps1_ms + arraysize(timestamps1_ms));
+      timestamps1_ms, timestamps1_ms + base::size(timestamps1_ms));
 
   // Scheduling pattern.
   size_t pattern[] = {1, 0, 0, 0, 0};
-  std::vector<size_t> scheduling_pattern = std::vector<size_t>(
-      pattern, pattern + arraysize(pattern));
+  std::vector<size_t> scheduling_pattern =
+      std::vector<size_t>(pattern, pattern + base::size(pattern));
 
   // Expected results.
   int expected_timestamps[] = {
     5, 0, 10, 20, 30, 15, 40, 25, 50, 35, 60, 45, 70, 55, 65, 75 };
-  std::vector<int> expected_timestamps_ms(std::vector<int>(
-      expected_timestamps,
-      expected_timestamps + arraysize(expected_timestamps)));
+  std::vector<int> expected_timestamps_ms(
+      std::vector<int>(expected_timestamps,
+                       expected_timestamps + base::size(expected_timestamps)));
 
   SetupTest(base::TimeDelta::FromMilliseconds(30),
             timestamps_ms,
diff --git a/chromecast/media/cma/base/buffering_frame_provider_unittest.cc b/chromecast/media/cma/base/buffering_frame_provider_unittest.cc
index 56f67af..42e1d98 100644
--- a/chromecast/media/cma/base/buffering_frame_provider_unittest.cc
+++ b/chromecast/media/cma/base/buffering_frame_provider_unittest.cc
@@ -12,12 +12,12 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread.h"
 #include "base/time/time.h"
 #include "chromecast/media/cma/test/frame_generator_for_test.h"
@@ -121,14 +121,13 @@
   bool consumer_delayed_pattern[] = { true };
 
   const size_t frame_count = 100u;
-  Configure(
-      frame_count,
-      std::vector<bool>(
-          provider_delayed_pattern,
-          provider_delayed_pattern + arraysize(provider_delayed_pattern)),
-      std::vector<bool>(
-          consumer_delayed_pattern,
-          consumer_delayed_pattern + arraysize(consumer_delayed_pattern)));
+  Configure(frame_count,
+            std::vector<bool>(provider_delayed_pattern,
+                              provider_delayed_pattern +
+                                  base::size(provider_delayed_pattern)),
+            std::vector<bool>(consumer_delayed_pattern,
+                              consumer_delayed_pattern +
+                                  base::size(consumer_delayed_pattern)));
 
   std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
   message_loop->task_runner()->PostTask(
@@ -142,14 +141,13 @@
   bool consumer_delayed_pattern[] = { false };
 
   const size_t frame_count = 100u;
-  Configure(
-      frame_count,
-      std::vector<bool>(
-          provider_delayed_pattern,
-          provider_delayed_pattern + arraysize(provider_delayed_pattern)),
-      std::vector<bool>(
-          consumer_delayed_pattern,
-          consumer_delayed_pattern + arraysize(consumer_delayed_pattern)));
+  Configure(frame_count,
+            std::vector<bool>(provider_delayed_pattern,
+                              provider_delayed_pattern +
+                                  base::size(provider_delayed_pattern)),
+            std::vector<bool>(consumer_delayed_pattern,
+                              consumer_delayed_pattern +
+                                  base::size(consumer_delayed_pattern)));
 
   std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
   message_loop->task_runner()->PostTask(
@@ -170,14 +168,13 @@
   };
 
   const size_t frame_count = 100u;
-  Configure(
-      frame_count,
-      std::vector<bool>(
-          provider_delayed_pattern,
-          provider_delayed_pattern + arraysize(provider_delayed_pattern)),
-      std::vector<bool>(
-          consumer_delayed_pattern,
-          consumer_delayed_pattern + arraysize(consumer_delayed_pattern)));
+  Configure(frame_count,
+            std::vector<bool>(provider_delayed_pattern,
+                              provider_delayed_pattern +
+                                  base::size(provider_delayed_pattern)),
+            std::vector<bool>(consumer_delayed_pattern,
+                              consumer_delayed_pattern +
+                                  base::size(consumer_delayed_pattern)));
 
   std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
   message_loop->task_runner()->PostTask(
diff --git a/chromecast/media/cma/base/decoder_buffer_adapter_unittest.cc b/chromecast/media/cma/base/decoder_buffer_adapter_unittest.cc
index cce5b5af..265caa3 100644
--- a/chromecast/media/cma/base/decoder_buffer_adapter_unittest.cc
+++ b/chromecast/media/cma/base/decoder_buffer_adapter_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "chromecast/media/cma/base/decoder_buffer_adapter.h"
 
+#include "base/stl_util.h"
 #include "chromecast/public/media/cast_decrypt_config.h"
 #include "media/base/decoder_buffer.h"
 #include "media/base/decrypt_config.h"
@@ -11,7 +12,7 @@
 
 namespace {
 static const uint8_t kBufferData[] = "hello";
-static const size_t kBufferDataSize = arraysize(kBufferData);
+static const size_t kBufferDataSize = base::size(kBufferData);
 static const int64_t kBufferTimestampUs = 31;
 
 scoped_refptr<media::DecoderBuffer> MakeDecoderBuffer() {
@@ -63,7 +64,7 @@
   EXPECT_EQ(kBufferDataSize, buffer_adapter->data_size());
 
   const uint8_t kTestBufferData[] = "world";
-  const size_t kTestBufferDataSize = arraysize(kTestBufferData);
+  const size_t kTestBufferDataSize = base::size(kTestBufferData);
   memcpy(buffer_adapter->writable_data(), kTestBufferData, kTestBufferDataSize);
   EXPECT_EQ(
       0, memcmp(buffer_adapter->data(), kTestBufferData, kTestBufferDataSize));
diff --git a/chromecast/media/cma/pipeline/audio_video_pipeline_impl_unittest.cc b/chromecast/media/cma/pipeline/audio_video_pipeline_impl_unittest.cc
index 72ea574..ab240ba 100644
--- a/chromecast/media/cma/pipeline/audio_video_pipeline_impl_unittest.cc
+++ b/chromecast/media/cma/pipeline/audio_video_pipeline_impl_unittest.cc
@@ -8,6 +8,7 @@
 
 #include "base/bind.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chromecast/media/base/decrypt_context_impl.h"
@@ -242,7 +243,7 @@
     frame_provider->Configure(
         std::vector<bool>(
             provider_delayed_pattern,
-            provider_delayed_pattern + arraysize(provider_delayed_pattern)),
+            provider_delayed_pattern + base::size(provider_delayed_pattern)),
         std::move(frame_generator));
     frame_provider->SetDelayFlush(true);
     return std::move(frame_provider);
diff --git a/chromecast/media/cma/test/frame_generator_for_test.cc b/chromecast/media/cma/test/frame_generator_for_test.cc
index f7d84aba..a1a6b9b 100644
--- a/chromecast/media/cma/test/frame_generator_for_test.cc
+++ b/chromecast/media/cma/test/frame_generator_for_test.cc
@@ -7,7 +7,7 @@
 #include <stdint.h>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chromecast/media/cma/base/decoder_buffer_adapter.h"
 #include "chromecast/media/cma/base/decoder_buffer_base.h"
 #include "media/base/decoder_buffer.h"
@@ -99,8 +99,8 @@
 
     std::unique_ptr<::media::DecryptConfig> decrypt_config =
         ::media::DecryptConfig::CreateCencConfig(
-            std::string(key_id, arraysize(key_id)),
-            std::string(iv, arraysize(iv)), subsamples);
+            std::string(key_id, base::size(key_id)),
+            std::string(iv, base::size(iv)), subsamples);
     buffer->set_decrypt_config(std::move(decrypt_config));
   }
 
diff --git a/chromecast/tracing/ftrace.cc b/chromecast/tracing/ftrace.cc
index 5f066a0..ae3cd61 100644
--- a/chromecast/tracing/ftrace.cc
+++ b/chromecast/tracing/ftrace.cc
@@ -7,7 +7,9 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+
 #include "base/files/file_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "base/trace_event/common/trace_event_common.h"
@@ -67,32 +69,32 @@
 void AddCategoryEvents(const std::string& category,
                        std::vector<std::string>* events) {
   if (category == "gfx") {
-    std::copy(kGfxEvents, kGfxEvents + arraysize(kGfxEvents),
+    std::copy(kGfxEvents, kGfxEvents + base::size(kGfxEvents),
               std::back_inserter(*events));
     return;
   }
   if (category == "input") {
-    std::copy(kInputEvents, kInputEvents + arraysize(kInputEvents),
+    std::copy(kInputEvents, kInputEvents + base::size(kInputEvents),
               std::back_inserter(*events));
     return;
   }
   if (category == TRACE_DISABLED_BY_DEFAULT("irq")) {
-    std::copy(kIrqEvents, kIrqEvents + arraysize(kIrqEvents),
+    std::copy(kIrqEvents, kIrqEvents + base::size(kIrqEvents),
               std::back_inserter(*events));
     return;
   }
   if (category == "power") {
-    std::copy(kPowerEvents, kPowerEvents + arraysize(kPowerEvents),
+    std::copy(kPowerEvents, kPowerEvents + base::size(kPowerEvents),
               std::back_inserter(*events));
     return;
   }
   if (category == "sched") {
-    std::copy(kSchedEvents, kSchedEvents + arraysize(kSchedEvents),
+    std::copy(kSchedEvents, kSchedEvents + base::size(kSchedEvents),
               std::back_inserter(*events));
     return;
   }
   if (category == "workq") {
-    std::copy(kWorkqEvents, kWorkqEvents + arraysize(kWorkqEvents),
+    std::copy(kWorkqEvents, kWorkqEvents + base::size(kWorkqEvents),
               std::back_inserter(*events));
     return;
   }
diff --git a/chromecast/tracing/system_tracing_common.cc b/chromecast/tracing/system_tracing_common.cc
index c88f721..d2ba80f 100644
--- a/chromecast/tracing/system_tracing_common.cc
+++ b/chromecast/tracing/system_tracing_common.cc
@@ -5,7 +5,8 @@
 #include "chromecast/tracing/system_tracing_common.h"
 
 #include <string.h>
-#include "base/macros.h"
+
+#include "base/stl_util.h"
 #include "base/trace_event/common/trace_event_common.h"
 
 namespace chromecast {
@@ -20,7 +21,7 @@
     "gfx",   "input", TRACE_DISABLED_BY_DEFAULT("irq"),
     "power", "sched", "workq"};
 
-const size_t kCategoryCount = arraysize(kCategories);
+const size_t kCategoryCount = base::size(kCategories);
 
 sockaddr_un GetSystemTracingSocketAddress() {
   struct sockaddr_un addr;
diff --git a/chromeos/accelerometer/accelerometer_reader.cc b/chromeos/accelerometer/accelerometer_reader.cc
index f8ac8bf..529b0678 100644
--- a/chromeos/accelerometer/accelerometer_reader.cc
+++ b/chromeos/accelerometer/accelerometer_reader.cc
@@ -14,10 +14,10 @@
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -363,12 +363,12 @@
     const base::FilePath& name,
     const std::string& location) {
   size_t config_index = 0;
-  for (; config_index < arraysize(kAccelerometerNames); ++config_index) {
+  for (; config_index < base::size(kAccelerometerNames); ++config_index) {
     if (location == kAccelerometerNames[config_index])
       break;
   }
 
-  if (config_index >= arraysize(kAccelerometerNames)) {
+  if (config_index >= base::size(kAccelerometerNames)) {
     LOG(ERROR) << "Unrecognized location: " << location << " for device "
                << name.MaybeAsASCII() << "\n";
     return false;
@@ -378,7 +378,7 @@
   if (!ReadFileToDouble(iio_path.Append(kAccelerometerScaleFileName), &scale))
     return false;
 
-  const int kNumberAxes = arraysize(kAccelerometerAxes);
+  const int kNumberAxes = base::size(kAccelerometerAxes);
   for (size_t i = 0; i < kNumberAxes; ++i) {
     std::string accelerometer_index_path = base::StringPrintf(
         kAccelerometerScanIndexPathFormatString, kAccelerometerAxes[i]);
@@ -412,7 +412,7 @@
       base::FilePath(kAccelerometerDevicePath).Append(name.BaseName());
   // Read configuration of each accelerometer axis from each accelerometer from
   // /sys/bus/iio/devices/iio:deviceX/.
-  for (size_t i = 0; i < arraysize(kAccelerometerNames); ++i) {
+  for (size_t i = 0; i < base::size(kAccelerometerNames); ++i) {
     configuration_.has[i] = false;
     // Read scale of accelerometer.
     std::string accelerometer_scale_path = base::StringPrintf(
@@ -430,7 +430,7 @@
     }
 
     configuration_.has[i] = true;
-    for (size_t j = 0; j < arraysize(kLegacyAccelerometerAxes); ++j) {
+    for (size_t j = 0; j < base::size(kLegacyAccelerometerAxes); ++j) {
       configuration_.scale[i][j] = kMeanGravity / scale_divisor;
       std::string accelerometer_index_path = base::StringPrintf(
           kLegacyAccelerometerScanIndexPathFormatString,
diff --git a/chromeos/components/proximity_auth/metrics.cc b/chromeos/components/proximity_auth/metrics.cc
index 4ec3b2d..0b0d673 100644
--- a/chromeos/components/proximity_auth/metrics.cc
+++ b/chromeos/components/proximity_auth/metrics.cc
@@ -9,10 +9,10 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/md5.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/sys_byteorder.h"
 
 namespace proximity_auth {
@@ -25,7 +25,7 @@
   // First, copy to a uint32_t, since byte swapping and endianness conversions
   // expect unsigned integers.
   uint32_t unsigned_value;
-  DCHECK_GE(arraysize(digest.a), sizeof(unsigned_value));
+  DCHECK_GE(base::size(digest.a), sizeof(unsigned_value));
   memcpy(&unsigned_value, digest.a, sizeof(unsigned_value));
   unsigned_value = base::ByteSwap(base::HostToNet32(unsigned_value));
 
diff --git a/chromeos/dbus/fake_cryptohome_client.cc b/chromeos/dbus/fake_cryptohome_client.cc
index 1478d79..51b39e2 100644
--- a/chromeos/dbus/fake_cryptohome_client.cc
+++ b/chromeos/dbus/fake_cryptohome_client.cc
@@ -748,8 +748,8 @@
 // static
 std::vector<uint8_t> FakeCryptohomeClient::GetStubSystemSalt() {
   const char kStubSystemSalt[] = "stub_system_salt";
-  return std::vector<uint8_t>(kStubSystemSalt,
-                              kStubSystemSalt + arraysize(kStubSystemSalt) - 1);
+  return std::vector<uint8_t>(
+      kStubSystemSalt, kStubSystemSalt + base::size(kStubSystemSalt) - 1);
 }
 
 void FakeCryptohomeClient::ReturnProtobufMethodCallback(
diff --git a/chromeos/dbus/shill_third_party_vpn_driver_client.cc b/chromeos/dbus/shill_third_party_vpn_driver_client.cc
index 4788471..578719a 100644
--- a/chromeos/dbus/shill_third_party_vpn_driver_client.cc
+++ b/chromeos/dbus/shill_third_party_vpn_driver_client.cc
@@ -12,7 +12,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "chromeos/dbus/shill_third_party_vpn_observer.h"
 #include "dbus/bus.h"
 #include "dbus/message.h"
@@ -135,7 +135,7 @@
 
 ShillThirdPartyVpnDriverClientImpl::ShillThirdPartyVpnDriverClientImpl()
     : bus_(nullptr) {
-  for (uint32_t i = 0; i < arraysize(kSetParametersKeyList); ++i) {
+  for (uint32_t i = 0; i < base::size(kSetParametersKeyList); ++i) {
     valid_keys_.insert(kSetParametersKeyList[i]);
   }
 }
diff --git a/chromeos/dbus/update_engine_client.cc b/chromeos/dbus/update_engine_client.cc
index f1b26dc0..9787d52 100644
--- a/chromeos/dbus/update_engine_client.cc
+++ b/chromeos/dbus/update_engine_client.cc
@@ -15,8 +15,8 @@
 #include "base/command_line.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chromeos/dbus/dbus_switches.h"
@@ -722,10 +722,10 @@
     const std::string& target_channel) {
   const char** cix = std::find(
       kReleaseChannelsList,
-      kReleaseChannelsList + arraysize(kReleaseChannelsList), current_channel);
+      kReleaseChannelsList + base::size(kReleaseChannelsList), current_channel);
   const char** tix = std::find(
       kReleaseChannelsList,
-      kReleaseChannelsList + arraysize(kReleaseChannelsList), target_channel);
+      kReleaseChannelsList + base::size(kReleaseChannelsList), target_channel);
   return tix > cix;
 }
 
diff --git a/chromeos/disks/disk_mount_manager_unittest.cc b/chromeos/disks/disk_mount_manager_unittest.cc
index a1c4d0b..a00a12e 100644
--- a/chromeos/disks/disk_mount_manager_unittest.cc
+++ b/chromeos/disks/disk_mount_manager_unittest.cc
@@ -12,6 +12,7 @@
 
 #include "base/bind.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/scoped_task_environment.h"
 #include "chromeos/dbus/dbus_thread_manager.h"
@@ -574,10 +575,10 @@
   void InitDisksAndMountPoints() {
     // Disks should be  added first (when adding device mount points it is
     // expected that the corresponding disk is already added).
-    for (size_t i = 0; i < arraysize(kTestDisks); i++)
+    for (size_t i = 0; i < base::size(kTestDisks); i++)
       AddTestDisk(kTestDisks[i]);
 
-    for (size_t i = 0; i < arraysize(kTestMountPoints); i++)
+    for (size_t i = 0; i < base::size(kTestMountPoints); i++)
       AddTestMountPoint(kTestMountPoints[i]);
   }
 
diff --git a/chromeos/geolocation/geoposition.cc b/chromeos/geolocation/geoposition.cc
index 8909d4a6..a05bb82 100644
--- a/chromeos/geolocation/geoposition.cc
+++ b/chromeos/geolocation/geoposition.cc
@@ -4,6 +4,7 @@
 
 #include "chromeos/geolocation/geoposition.h"
 
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 
 namespace {
@@ -42,13 +43,9 @@
   return base::StringPrintf(
       "latitude=%f, longitude=%f, accuracy=%f, error_code=%u, "
       "error_message='%s', status=%u (%s)",
-      latitude,
-      longitude,
-      accuracy,
-      error_code,
-      error_message.c_str(),
+      latitude, longitude, accuracy, error_code, error_message.c_str(),
       (unsigned)status,
-      (status < arraysize(status2string) ? status2string[status] : "unknown"));
+      (status < base::size(status2string) ? status2string[status] : "unknown"));
 }
 
 }  // namespace chromeos
diff --git a/chromeos/network/network_device_handler_impl.cc b/chromeos/network/network_device_handler_impl.cc
index 90e51e2..63980bc6 100644
--- a/chromeos/network/network_device_handler_impl.cc
+++ b/chromeos/network/network_device_handler_impl.cc
@@ -14,6 +14,7 @@
 #include "base/bind_helpers.h"
 #include "base/location.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/system/sys_info.h"
@@ -283,7 +284,7 @@
       // Must only be changed by policy/owner through.
       shill::kCellularAllowRoamingProperty};
 
-  for (size_t i = 0; i < arraysize(property_blacklist); ++i) {
+  for (size_t i = 0; i < base::size(property_blacklist); ++i) {
     if (property_name == property_blacklist[i]) {
       InvokeErrorCallback(
           device_path, error_callback,
diff --git a/chromeos/network/network_type_pattern.cc b/chromeos/network/network_type_pattern.cc
index d7e63e31..4f42f0d 100644
--- a/chromeos/network/network_type_pattern.cc
+++ b/chromeos/network/network_type_pattern.cc
@@ -6,6 +6,7 @@
 
 #include <stddef.h>
 
+#include "base/stl_util.h"
 #include "chromeos/network/network_event_log.h"
 #include "chromeos/network/tether_constants.h"
 #include "third_party/cros_system_api/dbus/service_constants.h"
@@ -45,7 +46,7 @@
                           {kTypeTether, kNetworkTypeTether}};
 
 NetworkTypeBitFlag ShillNetworkTypeToFlag(const std::string& shill_type) {
-  for (size_t i = 0; i < arraysize(shill_type_to_flag); ++i) {
+  for (size_t i = 0; i < base::size(shill_type_to_flag); ++i) {
     if (shill_type_to_flag[i].shill_network_type == shill_type)
       return shill_type_to_flag[i].bit_flag;
   }
@@ -165,7 +166,7 @@
 
   // Note: shill_type_to_flag includes kTypeTether.
   std::string str;
-  for (size_t i = 0; i < arraysize(shill_type_to_flag); ++i) {
+  for (size_t i = 0; i < base::size(shill_type_to_flag); ++i) {
     if (!(pattern_ & shill_type_to_flag[i].bit_flag))
       continue;
     if (!str.empty())
diff --git a/chromeos/process_proxy/process_output_watcher.cc b/chromeos/process_proxy/process_output_watcher.cc
index ac6a64ac..83058bf 100644
--- a/chromeos/process_proxy/process_output_watcher.cc
+++ b/chromeos/process_proxy/process_output_watcher.cc
@@ -15,6 +15,7 @@
 #include "base/logging.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/third_party/icu/icu_utf.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -58,7 +59,7 @@
       weak_factory_(this) {
   CHECK_GE(out_fd, 0);
   // We want to be sure we will be able to add 0 at the end of the input, so -1.
-  read_buffer_capacity_ = arraysize(read_buffer_) - 1;
+  read_buffer_capacity_ = base::size(read_buffer_) - 1;
 }
 
 ProcessOutputWatcher::~ProcessOutputWatcher() = default;
diff --git a/chromeos/process_proxy/process_proxy_unittest.cc b/chromeos/process_proxy/process_proxy_unittest.cc
index 6a368d1d..2f11ca6 100644
--- a/chromeos/process_proxy/process_proxy_unittest.cc
+++ b/chromeos/process_proxy/process_proxy_unittest.cc
@@ -17,6 +17,7 @@
 #include "base/process/process.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/sequenced_task_runner_handle.h"
 #include "base/threading/thread.h"
@@ -113,7 +114,7 @@
 
  private:
   bool ProcessReceivedCharacter(char received, size_t stream) {
-    if (stream >= arraysize(left_to_check_index_))
+    if (stream >= base::size(left_to_check_index_))
       return false;
     bool success = left_to_check_index_[stream] < expected_line_.length() &&
         expected_line_[left_to_check_index_[stream]] == received;
diff --git a/chromeos/settings/install_attributes.cc b/chromeos/settings/install_attributes.cc
index 7bb4fd2..e73166f 100644
--- a/chromeos/settings/install_attributes.cc
+++ b/chromeos/settings/install_attributes.cc
@@ -12,11 +12,11 @@
 #include "base/files/file_util.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_base.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/system/sys_info.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -224,7 +224,7 @@
         kAttrConsumerKioskEnabled,
       };
       std::map<std::string, std::string> attr_map;
-      for (size_t i = 0; i < arraysize(kEnterpriseAttributes); ++i) {
+      for (size_t i = 0; i < base::size(kEnterpriseAttributes); ++i) {
         std::string value;
         if (tpm_util::InstallAttributesGet(kEnterpriseAttributes[i], &value))
           attr_map[kEnterpriseAttributes[i]] = value;
diff --git a/chromeos/settings/timezone_settings.cc b/chromeos/settings/timezone_settings.cc
index 0ed31b7b..c5ec163 100644
--- a/chromeos/settings/timezone_settings.cc
+++ b/chromeos/settings/timezone_settings.cc
@@ -15,10 +15,10 @@
 #include "base/i18n/unicodestring.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/singleton.h"
 #include "base/observer_list.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/system/sys_info.h"
@@ -370,7 +370,7 @@
 }
 
 TimezoneSettingsBaseImpl::TimezoneSettingsBaseImpl() {
-  for (size_t i = 0; i < arraysize(kTimeZones); ++i) {
+  for (size_t i = 0; i < base::size(kTimeZones); ++i) {
     timezones_.push_back(base::WrapUnique(icu::TimeZone::createTimeZone(
         icu::UnicodeString(kTimeZones[i], -1, US_INV))));
   }
diff --git a/chromeos/system/name_value_pairs_parser_unittest.cc b/chromeos/system/name_value_pairs_parser_unittest.cc
index 7bed31a..9a3b907 100644
--- a/chromeos/system/name_value_pairs_parser_unittest.cc
+++ b/chromeos/system/name_value_pairs_parser_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "chromeos/system/name_value_pairs_parser.h"
 
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace chromeos {
@@ -92,8 +93,8 @@
 
   NameValuePairsParser::NameValueMap map;
   NameValuePairsParser parser(&map);
-  parser.ParseNameValuePairsFromTool(
-      arraysize(command), command, "=", "\n", "#");
+  parser.ParseNameValuePairsFromTool(base::size(command), command, "=", "\n",
+                                     "#");
   EXPECT_EQ(6u, map.size());
   EXPECT_EQ("x86", map["arch"]);
   EXPECT_EQ("1", map["cros_debug"]);
diff --git a/chromeos/system/statistics_provider.cc b/chromeos/system/statistics_provider.cc
index 8ad2064..58c17e3 100644
--- a/chromeos/system/statistics_provider.cc
+++ b/chromeos/system/statistics_provider.cc
@@ -15,10 +15,10 @@
 #include "base/json/json_file_value_serializer.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
 #include "base/path_service.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/synchronization/cancellation_flag.h"
@@ -523,11 +523,9 @@
   NameValuePairsParser parser(&machine_info_);
   if (base::SysInfo::IsRunningOnChromeOS()) {
     // Parse all of the key/value pairs from the crossystem tool.
-    if (!parser.ParseNameValuePairsFromTool(arraysize(kCrosSystemTool),
-                                            kCrosSystemTool,
-                                            kCrosSystemEq,
-                                            kCrosSystemDelim,
-                                            kCrosSystemCommentDelim)) {
+    if (!parser.ParseNameValuePairsFromTool(
+            base::size(kCrosSystemTool), kCrosSystemTool, kCrosSystemEq,
+            kCrosSystemDelim, kCrosSystemCommentDelim)) {
       LOG(ERROR) << "Errors parsing output from: " << kCrosSystemTool;
     }
     // Drop useless "(error)" values so they don't displace valid values
diff --git a/chromeos/timezone/timezone_request.cc b/chromeos/timezone/timezone_request.cc
index 82ffae1..31388388 100644
--- a/chromeos/timezone/timezone_request.cc
+++ b/chromeos/timezone/timezone_request.cc
@@ -11,6 +11,7 @@
 #include "base/json/json_reader.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
@@ -210,7 +211,7 @@
   }
 
   bool found = false;
-  for (size_t i = 0; i < arraysize(statusString2Enum); ++i) {
+  for (size_t i = 0; i < base::size(statusString2Enum); ++i) {
     if (status != statusString2Enum[i].string)
       continue;
 
@@ -426,13 +427,9 @@
   return base::StringPrintf(
       "dstOffset=%f, rawOffset=%f, timeZoneId='%s', timeZoneName='%s', "
       "error_message='%s', status=%u (%s)",
-      dstOffset,
-      rawOffset,
-      timeZoneId.c_str(),
-      timeZoneName.c_str(),
-      error_message.c_str(),
-      (unsigned)status,
-      (status < arraysize(status2string) ? status2string[status] : "unknown"));
+      dstOffset, rawOffset, timeZoneId.c_str(), timeZoneName.c_str(),
+      error_message.c_str(), (unsigned)status,
+      (status < base::size(status2string) ? status2string[status] : "unknown"));
 }
 
 }  // namespace chromeos
diff --git a/chromeos/tools/onc_validator/onc_validator.cc b/chromeos/tools/onc_validator/onc_validator.cc
index 0a7275f..28930f2 100644
--- a/chromeos/tools/onc_validator/onc_validator.cc
+++ b/chromeos/tools/onc_validator/onc_validator.cc
@@ -12,6 +12,7 @@
 #include "base/json/json_file_value_serializer.h"
 #include "base/json/json_reader.h"
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "chromeos/network/onc/onc_signature.h"
 #include "chromeos/network/onc/onc_validator.h"
@@ -62,13 +63,13 @@
           "  onc_validator [OPTION]... [TYPE] onc_file\n"
           "\n"
           "Valid TYPEs are:\n");
-  for (size_t i = 0; i < arraysize(kTypes); ++i)
+  for (size_t i = 0; i < base::size(kTypes); ++i)
     fprintf(stderr, "  %s\n", kTypes[i]);
 
   fprintf(stderr,
           "\n"
           "Valid OPTIONs are:\n");
-  for (size_t i = 0; i < arraysize(kSwitches); ++i)
+  for (size_t i = 0; i < base::size(kSwitches); ++i)
     fprintf(stderr, "  --%s\n", kSwitches[i]);
 
   fprintf(stderr,
diff --git a/chromeos/tpm/tpm_token_info_getter_unittest.cc b/chromeos/tpm/tpm_token_info_getter_unittest.cc
index d48a907..83d8c4d8 100644
--- a/chromeos/tpm/tpm_token_info_getter_unittest.cc
+++ b/chromeos/tpm/tpm_token_info_getter_unittest.cc
@@ -10,11 +10,11 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/optional.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task_runner.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "chromeos/cryptohome/cryptohome_parameters.h"
@@ -332,7 +332,7 @@
 
   const int64_t kExpectedDelays[] = {100};
   EXPECT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
@@ -357,7 +357,7 @@
 
   const int64_t kExpectedDelays[] = {100};
   EXPECT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
@@ -382,7 +382,7 @@
 
   const int64_t kExpectedDelays[] = {100};
   EXPECT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
@@ -409,7 +409,7 @@
 
   int64_t kExpectedDelays[] = {100, 200, 400, 800, 1600, 3200};
   ASSERT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
@@ -438,7 +438,7 @@
                                3200,   6400,   12800,  25600,  51200,
                                102400, 204800, 300000, 300000, 300000};
   ASSERT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
@@ -483,7 +483,7 @@
 
   const int64_t kExpectedDelays[] = {100};
   EXPECT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
@@ -508,7 +508,7 @@
 
   const int64_t kExpectedDelays[] = {100};
   EXPECT_EQ(std::vector<int64_t>(kExpectedDelays,
-                                 kExpectedDelays + arraysize(kExpectedDelays)),
+                                 kExpectedDelays + base::size(kExpectedDelays)),
             delays_);
 }
 
diff --git a/components/arc/arc_session_impl.cc b/components/arc/arc_session_impl.cc
index 67ebded..bf6dd34 100644
--- a/components/arc/arc_session_impl.cc
+++ b/components/arc/arc_session_impl.cc
@@ -18,6 +18,7 @@
 #include "base/location.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/task/post_task.h"
 #include "base/task/task_traits.h"
@@ -73,7 +74,7 @@
       {raw_socket_fd, POLLIN, 0}, {raw_cancel_fd, POLLIN, 0},
   };
 
-  if (HANDLE_EINTR(poll(fds, arraysize(fds), -1)) <= 0) {
+  if (HANDLE_EINTR(poll(fds, base::size(fds), -1)) <= 0) {
     PLOG(ERROR) << "poll()";
     return false;
   }
diff --git a/components/arc/bluetooth/bluetooth_struct_traits_unittest.cc b/components/arc/bluetooth/bluetooth_struct_traits_unittest.cc
index 933461c..243245f5 100644
--- a/components/arc/bluetooth/bluetooth_struct_traits_unittest.cc
+++ b/components/arc/bluetooth/bluetooth_struct_traits_unittest.cc
@@ -7,7 +7,7 @@
 #include <string>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "device/bluetooth/bluetooth_uuid.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -123,7 +123,7 @@
       converted_service = advertisement->service_data();
   EXPECT_EQ(converted_service->size(), 1U);
   EXPECT_EQ(converted_service->begin()->first, kUuid16Str);
-  for (size_t i = 0; i < arraysize(kServiceData); i++) {
+  for (size_t i = 0; i < base::size(kServiceData); i++) {
     EXPECT_EQ(kServiceData[i], converted_service->begin()->second[i]);
   }
 
@@ -134,7 +134,7 @@
   EXPECT_EQ(cic & 0xff, kManufacturerData[0]);
   EXPECT_EQ((cic >> 8) & 0xff, kManufacturerData[1]);
   EXPECT_EQ(converted_manufacturer->begin()->second.size(),
-            arraysize(kManufacturerData) - sizeof(uint16_t));
+            base::size(kManufacturerData) - sizeof(uint16_t));
 }
 
 TEST(BluetoothStructTraitsTest, DeserializeBluetoothAdvertisementFailure) {
diff --git a/components/arc/intent_helper/arc_intent_helper_bridge.cc b/components/arc/intent_helper/arc_intent_helper_bridge.cc
index a23bb77..9533944 100644
--- a/components/arc/intent_helper/arc_intent_helper_bridge.cc
+++ b/components/arc/intent_helper/arc_intent_helper_bridge.cc
@@ -15,6 +15,7 @@
 #include "base/memory/singleton.h"
 #include "base/memory/weak_ptr.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "components/arc/arc_bridge_service.h"
 #include "components/arc/arc_browser_context_keyed_service_factory_base.h"
@@ -70,7 +71,7 @@
                                        url::kMailToScheme};
 
 // mojom::ChromePage::LAST returns the ammout of valid entries - 1.
-static_assert(arraysize(kMapping) ==
+static_assert(base::size(kMapping) ==
                   static_cast<size_t>(mojom::ChromePage::LAST) + 1,
               "kMapping is out of sync");
 
diff --git a/components/autofill/content/renderer/form_autofill_util_browsertest.cc b/components/autofill/content/renderer/form_autofill_util_browsertest.cc
index d615352..cb6d671 100644
--- a/components/autofill/content/renderer/form_autofill_util_browsertest.cc
+++ b/components/autofill/content/renderer/form_autofill_util_browsertest.cc
@@ -4,6 +4,7 @@
 
 #include "components/autofill/content/renderer/form_autofill_util.h"
 
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "content/public/test/render_view_test.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -324,7 +325,7 @@
   } kExpectedFields[] = {
       {"name1", true}, {"name2", false}, {"name3", true}, {"name4", false},
   };
-  const size_t number_of_cases = arraysize(kExpectedFields);
+  const size_t number_of_cases = base::size(kExpectedFields);
   ASSERT_EQ(number_of_cases, target.fields.size());
   for (size_t i = 0; i < number_of_cases; ++i) {
     EXPECT_EQ(base::UTF8ToUTF16(kExpectedFields[i].name),
@@ -363,7 +364,7 @@
   } kExpectedFields[] = {
       {"name1", false}, {"name2", true}, {"name3", false}, {"name4", true},
   };
-  const size_t number_of_cases = arraysize(kExpectedFields);
+  const size_t number_of_cases = base::size(kExpectedFields);
   ASSERT_EQ(number_of_cases, target.fields.size());
   for (size_t i = 0; i < number_of_cases; ++i) {
     EXPECT_EQ(base::UTF8ToUTF16(kExpectedFields[i].name),
diff --git a/components/autofill/content/renderer/html_based_username_detector_vocabulary.cc b/components/autofill/content/renderer/html_based_username_detector_vocabulary.cc
index abf4e4bf..58b653d 100644
--- a/components/autofill/content/renderer/html_based_username_detector_vocabulary.cc
+++ b/components/autofill/content/renderer/html_based_username_detector_vocabulary.cc
@@ -4,7 +4,7 @@
 
 #include "components/autofill/content/renderer/html_based_username_detector_vocabulary.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace autofill {
 
@@ -23,7 +23,7 @@
     "second", "passwort", "middlename", "paroladordine",
     "codice", "pasvorto", "familyname", "inomboloyokuvula",
     "modpas", "salasana", "motdepasse", "numeraeleiloaesesi"};
-const int kNegativeLatinSize = arraysize(kNegativeLatin);
+const int kNegativeLatinSize = base::size(kNegativeLatin);
 
 const char* const kNegativeNonLatin[] = {"fjalëkalim",
                                          "የይለፍቃል",
@@ -74,7 +74,7 @@
                                          "mậtkhẩu",
                                          "פּאַראָל",
                                          "ọrọigbaniwọle"};
-const int kNegativeNonLatinSize = arraysize(kNegativeNonLatin);
+const int kNegativeNonLatinSize = base::size(kNegativeNonLatin);
 
 const char* const kUsernameLatin[] = {
     "gatti",      "uzantonomo",   "solonanarana",    "nombredeusuario",
@@ -86,7 +86,7 @@
     "mosebedisi", "kasutajanimi", "ainmcleachdaidh", "igamalomsebenzisi",
     "nomdusuari", "lomsebenzisi", "jenengpanganggo", "ingoakaiwhakamahi",
     "nomeutente", "namapengguna"};
-const int kUsernameLatinSize = arraysize(kUsernameLatin);
+const int kUsernameLatinSize = base::size(kUsernameLatin);
 
 const char* const kUsernameNonLatin[] = {"用户名",
                                          "کاتيجونالو",
@@ -146,7 +146,7 @@
                                          "ব্যবহারকারীরনাম",
                                          "užívateľskémeno",
                                          "ឈ្មោះអ្នកប្រើប្រាស់"};
-const int kUsernameNonLatinSize = arraysize(kUsernameNonLatin);
+const int kUsernameNonLatinSize = base::size(kUsernameNonLatin);
 
 const char* const kUserLatin[] = {
     "user",   "wosuta",   "gebruiker",  "utilizator",
@@ -159,7 +159,7 @@
     "usuari", "kasutaja", "defnyddiwr", "kaiwhakamahi",
     "utente", "korisnik", "mosebedisi", "foydalanuvchi",
     "uzanto", "pengguna", "mushandisi"};
-const int kUserLatinSize = arraysize(kUserLatin);
+const int kUserLatinSize = base::size(kUserLatin);
 
 const char* const kUserNonLatin[] = {"用户",
                                      "użytkownik",
@@ -218,7 +218,7 @@
                                      "пайдаланушы",
                                      "အသုံးပြုသူကို",
                                      "käyttäjä"};
-const int kUserNonLatinSize = arraysize(kUserNonLatin);
+const int kUserNonLatinSize = base::size(kUserNonLatin);
 
 const char* const kTechnicalWords[] = {
     "uid",         "newtel",     "uaccount",   "regaccount",  "ureg",
@@ -226,9 +226,9 @@
     "loginname",   "membername", "uname",      "ucreate",     "loginmail",
     "accountname", "umail",      "loginreg",   "accountid",   "loginaccount",
     "ulogin",      "regemail",   "newmobile",  "accountlogin"};
-const int kTechnicalWordsSize = arraysize(kTechnicalWords);
+const int kTechnicalWordsSize = base::size(kTechnicalWords);
 
 const char* const kWeakWords[] = {"id", "login", "mail"};
-const int kWeakWordsSize = arraysize(kWeakWords);
+const int kWeakWordsSize = base::size(kWeakWords);
 
 }  // namespace autofill
diff --git a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
index 94475b2..40c3ad1 100644
--- a/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
+++ b/components/autofill/content/renderer/password_form_conversion_utils_browsertest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -444,7 +444,7 @@
        "id",
        "123"}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Iteration " << i);
 
     PasswordFormBuilder builder(kTestFormActionURL);
@@ -595,7 +595,7 @@
        "name1",
        "johnsmith"}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Iteration " << i);
 
     PasswordFormBuilder builder(kTestFormActionURL);
@@ -827,7 +827,7 @@
        "John",
        "William+usrname2, Smith+usrname3"}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     for (size_t nonempty_username_fields = 0; nonempty_username_fields < 2;
          ++nonempty_username_fields) {
       SCOPED_TRACE(testing::Message()
@@ -904,7 +904,7 @@
       {{"", "beta"}, "password1", "", "password2", "beta", ""},
       {{"alpha", "beta"}, "password1", "alpha", "password2", "beta", ""}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Iteration " << i);
 
     PasswordFormBuilder builder(kTestFormActionURL);
@@ -973,7 +973,7 @@
       // them the same for now to keep our abstract interpretation less flaky.
       {{"", "", ""}, "password1", "", "password2", "", "password3"}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Iteration " << i);
 
     PasswordFormBuilder builder(kTestFormActionURL);
@@ -1336,7 +1336,7 @@
        "usrname2",
        "Smith"}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Iteration " << i);
 
     PasswordFormBuilder builder(kTestFormActionURL);
@@ -1756,7 +1756,7 @@
       {"alpha", "alpha", "alpha"},
       {"alpha", "beta", "alpha"}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Iteration " << i);
 
     PasswordFormBuilder builder(kTestFormActionURL);
@@ -2189,7 +2189,7 @@
        "anonymous_new_password"},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(testing::Message()
                  << "Iteration " << i << ", expected_username "
                  << test_cases[i].expected_username_element
diff --git a/components/autofill/core/browser/autofill_data_util.cc b/components/autofill/core/browser/autofill_data_util.cc
index af02067..5425717 100644
--- a/components/autofill/core/browser/autofill_data_util.cc
+++ b/components/autofill/core/browser/autofill_data_util.cc
@@ -8,6 +8,7 @@
 #include <vector>
 
 #include "base/i18n/char_iterator.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -114,7 +115,7 @@
 void StripPrefixes(std::vector<base::StringPiece16>* name_tokens) {
   auto iter = name_tokens->begin();
   while (iter != name_tokens->end()) {
-    if (!ContainsString(name_prefixes, arraysize(name_prefixes), *iter))
+    if (!ContainsString(name_prefixes, base::size(name_prefixes), *iter))
       break;
     ++iter;
   }
@@ -127,7 +128,7 @@
 // Removes common name suffixes from |name_tokens|.
 void StripSuffixes(std::vector<base::StringPiece16>* name_tokens) {
   while (!name_tokens->empty()) {
-    if (!ContainsString(name_suffixes, arraysize(name_suffixes),
+    if (!ContainsString(name_suffixes, base::size(name_suffixes),
                         name_tokens->back())) {
       break;
     }
@@ -216,13 +217,13 @@
       // ones)
       surname_length = std::max<size_t>(
           1, StartsWithAny(name, korean_multi_char_surnames,
-                           arraysize(korean_multi_char_surnames)));
+                           base::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,
-                           arraysize(common_cjk_multi_char_surnames)));
+                           base::size(common_cjk_multi_char_surnames)));
     }
     parts->family = name.substr(0, surname_length).as_string();
     parts->given = name.substr(surname_length).as_string();
@@ -335,7 +336,7 @@
   reverse_family_tokens.push_back(name_tokens.back());
   name_tokens.pop_back();
   while (name_tokens.size() >= 1 &&
-         ContainsString(family_name_prefixes, arraysize(family_name_prefixes),
+         ContainsString(family_name_prefixes, base::size(family_name_prefixes),
                         name_tokens.back())) {
     reverse_family_tokens.push_back(name_tokens.back());
     name_tokens.pop_back();
diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
index abc0088..1d218fc 100644
--- a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
+++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/win/registry.h"
 #include "components/autofill/core/browser/autofill_profile.h"
@@ -152,13 +152,13 @@
   profile_key.Create(HKEY_CURRENT_USER, kProfileKey, KEY_ALL_ACCESS);
   EXPECT_TRUE(profile_key.Valid());
 
-  CreateSubkey(&profile_key, L"0", profile1, arraysize(profile1));
-  CreateSubkey(&profile_key, L"1", profile2, arraysize(profile2));
+  CreateSubkey(&profile_key, L"0", profile1, base::size(profile1));
+  CreateSubkey(&profile_key, L"1", profile2, base::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, arraysize(credit_card));
+  CreateSubkey(&cc_key, L"0", credit_card, base::size(credit_card));
   EncryptAndWrite(&cc_key, &empty_password);
   EncryptAndWrite(&cc_key, &empty_salt);
 
diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
index bb5831e..108eb5cf 100644
--- a/components/autofill/core/browser/autofill_manager_unittest.cc
+++ b/components/autofill/core/browser/autofill_manager_unittest.cc
@@ -14,10 +14,10 @@
 #include "base/base64.h"
 #include "base/command_line.h"
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/field_trial.h"
 #include "base/metrics/metrics_hashes.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -5258,8 +5258,8 @@
   FormSubmitted(form);
 
   EXPECT_EQ(form.fields.size(), form_seen_by_ahm.fields.size());
-  ASSERT_EQ(arraysize(test_fields), form_seen_by_ahm.fields.size());
-  for (size_t i = 0; i < arraysize(test_fields); ++i) {
+  ASSERT_EQ(base::size(test_fields), form_seen_by_ahm.fields.size());
+  for (size_t i = 0; i < base::size(test_fields); ++i) {
     EXPECT_EQ(
         form_seen_by_ahm.fields[i].should_autocomplete,
         test_fields[i].expected_field_type != CREDIT_CARD_VERIFICATION_CODE);
diff --git a/components/autofill/core/browser/autofill_profile.cc b/components/autofill/core/browser/autofill_profile.cc
index a7ac525..d413da9 100644
--- a/components/autofill/core/browser/autofill_profile.cc
+++ b/components/autofill/core/browser/autofill_profile.cc
@@ -15,7 +15,6 @@
 #include "base/i18n/case_conversion.h"
 #include "base/i18n/char_iterator.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/sha1.h"
 #include "base/stl_util.h"
@@ -151,9 +150,9 @@
 
   std::vector<ServerFieldType> default_fields;
   if (!suggested_fields) {
-    default_fields.assign(
-        kDefaultDistinguishingFields,
-        kDefaultDistinguishingFields + arraysize(kDefaultDistinguishingFields));
+    default_fields.assign(kDefaultDistinguishingFields,
+                          kDefaultDistinguishingFields +
+                              base::size(kDefaultDistinguishingFields));
     if (excluded_field == UNKNOWN_TYPE) {
       distinguishing_fields->swap(default_fields);
       return;
diff --git a/components/autofill/core/browser/autofill_profile_unittest.cc b/components/autofill/core/browser/autofill_profile_unittest.cc
index 5a019e3..b70b6f2 100644
--- a/components/autofill/core/browser/autofill_profile_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_unittest.cc
@@ -11,7 +11,6 @@
 
 #include "base/format_macros.h"
 #include "base/guid.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
@@ -290,7 +289,7 @@
   };
 
   std::vector<base::string16> labels;
-  for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
     AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
                                           UNKNOWN_TYPE, i, "en-US", &labels);
     ASSERT_FALSE(labels.empty());
@@ -329,7 +328,7 @@
   };
 
   std::vector<base::string16> labels;
-  for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
     AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
                                           UNKNOWN_TYPE, i, "en-US", &labels);
     ASSERT_FALSE(labels.empty());
@@ -373,7 +372,7 @@
   };
 
   std::vector<base::string16> labels;
-  for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
     AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
                                           UNKNOWN_TYPE, i, "en-US", &labels);
     ASSERT_FALSE(labels.empty());
@@ -410,7 +409,7 @@
   };
 
   std::vector<base::string16> labels;
-  for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
     AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
                                           UNKNOWN_TYPE, i, "en-US", &labels);
     ASSERT_FALSE(labels.empty());
@@ -443,7 +442,7 @@
   };
 
   std::vector<base::string16> labels;
-  for (size_t i = 0; i < arraysize(kExpectedLabels); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedLabels); ++i) {
     AutofillProfile::CreateInferredLabels(ToRawPointerVector(profiles), nullptr,
                                           UNKNOWN_TYPE, i, "en-US", &labels);
     ASSERT_FALSE(labels.empty());
diff --git a/components/autofill/core/browser/country_data.cc b/components/autofill/core/browser/country_data.cc
index 90401b0..a0c4e6a 100644
--- a/components/autofill/core/browser/country_data.cc
+++ b/components/autofill/core/browser/country_data.cc
@@ -7,6 +7,7 @@
 #include <utility>
 
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "components/strings/grit/components_strings.h"
 #include "third_party/icu/source/common/unicode/locid.h"
 
@@ -782,7 +783,7 @@
 // based on |kCountryData|.
 std::vector<std::string> GetCountryCodes() {
   std::vector<std::string> country_codes;
-  country_codes.reserve(arraysize(kCountryData));
+  country_codes.reserve(base::size(kCountryData));
   for (const auto& static_data : kCountryData) {
     country_codes.push_back(static_data.country_code);
   }
diff --git a/components/autofill/core/browser/field_filler_unittest.cc b/components/autofill/core/browser/field_filler_unittest.cc
index b092bfbf..eb2f6986 100644
--- a/components/autofill/core/browser/field_filler_unittest.cc
+++ b/components/autofill/core/browser/field_filler_unittest.cc
@@ -10,8 +10,8 @@
 
 #include "base/base_paths.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -1139,10 +1139,10 @@
   test.card_number_ = "5187654321098765";
   test.total_splits_ = 4;
   int splits[] = {4, 4, 4, 4};
-  test.splits_ = std::vector<int>(splits, splits + arraysize(splits));
+  test.splits_ = std::vector<int>(splits, splits + base::size(splits));
   std::string results[] = {"5187", "6543", "2109", "8765"};
   test.expected_results_ =
-      std::vector<std::string>(results, results + arraysize(results));
+      std::vector<std::string>(results, results + base::size(results));
 
   FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
   for (size_t i = 0; i < test.total_splits_; ++i) {
@@ -1181,10 +1181,10 @@
   test.card_number_ = "423456789012345";
   test.total_splits_ = 3;
   int splits[] = {4, 6, 5};
-  test.splits_ = std::vector<int>(splits, splits + arraysize(splits));
+  test.splits_ = std::vector<int>(splits, splits + base::size(splits));
   std::string results[] = {"4234", "567890", "12345"};
   test.expected_results_ =
-      std::vector<std::string>(results, results + arraysize(results));
+      std::vector<std::string>(results, results + base::size(results));
 
   FieldFiller filler(/*app_locale=*/"en-US", /*address_normalizer=*/nullptr);
   // Start executing test cases to verify parts and full credit card number.
diff --git a/components/autofill/core/browser/phone_field.cc b/components/autofill/core/browser/phone_field.cc
index 7c19aab..343504b 100644
--- a/components/autofill/core/browser/phone_field.cc
+++ b/components/autofill/core/browser/phone_field.cc
@@ -10,7 +10,7 @@
 #include <utility>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -139,12 +139,12 @@
   // The form owns the following variables, so they should not be deleted.
   AutofillField* parsed_fields[FIELD_MAX];
 
-  for (size_t i = 0; i < arraysize(kPhoneFieldGrammars); ++i) {
+  for (size_t i = 0; i < base::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 < arraysize(kPhoneFieldGrammars) &&
+    for (; i < base::size(kPhoneFieldGrammars) &&
            kPhoneFieldGrammars[i].regex != REGEX_SEPARATOR;
          ++i) {
       if (!ParsePhoneField(scanner, GetRegExp(kPhoneFieldGrammars[i].regex),
@@ -158,7 +158,7 @@
       }
     }
 
-    if (i >= arraysize(kPhoneFieldGrammars)) {
+    if (i >= base::size(kPhoneFieldGrammars)) {
       scanner->RewindTo(saved_cursor);
       return nullptr;  // Parsing failed.
     }
@@ -168,11 +168,11 @@
     // Proceed to the next grammar.
     do {
       ++i;
-    } while (i < arraysize(kPhoneFieldGrammars) &&
+    } while (i < base::size(kPhoneFieldGrammars) &&
              kPhoneFieldGrammars[i].regex != REGEX_SEPARATOR);
 
     scanner->RewindTo(saved_cursor);
-    if (i + 1 == arraysize(kPhoneFieldGrammars)) {
+    if (i + 1 == base::size(kPhoneFieldGrammars)) {
       return nullptr;  // Tried through all the possibilities - did not match.
     }
   }
diff --git a/components/autofill/core/browser/webdata/autofill_table_unittest.cc b/components/autofill/core/browser/webdata/autofill_table_unittest.cc
index 6b20deb..6b46556 100644
--- a/components/autofill/core/browser/webdata/autofill_table_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_table_unittest.cc
@@ -13,7 +13,6 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/guid.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -243,8 +242,8 @@
                    AutofillKey(ASCIIToUTF16("Favorite Color"),
                                ASCIIToUTF16("Green"))),
   };
-  EXPECT_EQ(arraysize(kExpectedChanges), changes.size());
-  for (size_t i = 0; i < arraysize(kExpectedChanges); ++i) {
+  EXPECT_EQ(base::size(kExpectedChanges), changes.size());
+  for (size_t i = 0; i < base::size(kExpectedChanges); ++i) {
     EXPECT_EQ(kExpectedChanges[i], changes[i]);
   }
 
@@ -468,7 +467,7 @@
   const char kName[] = "foo";
   const char kValue[] = "bar";
   // A value which contains terminating character.
-  std::string value(kValue, arraysize(kValue));
+  std::string value(kValue, base::size(kValue));
 
   AutofillEntry entry0(MakeAutofillEntry(kName, kValue, 1, -1));
   AutofillEntry entry1(MakeAutofillEntry(kName, value, 2, 3));
diff --git a/components/bookmarks/browser/bookmark_index_unittest.cc b/components/bookmarks/browser/bookmark_index_unittest.cc
index 2d03597..06766f48 100644
--- a/components/bookmarks/browser/bookmark_index_unittest.cc
+++ b/components/bookmarks/browser/bookmark_index_unittest.cc
@@ -8,7 +8,7 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.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"
@@ -192,7 +192,7 @@
     // Prefix match on subsequent terms.
     { "abc def",                    "abc d",    "" },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     std::vector<TitleAndURL> bookmarks;
     for (const std::string& title : base::SplitString(
              data[i].titles, ";",
@@ -253,7 +253,7 @@
     // Exact and prefix match.
     { "ab cdef;abcd;abcd cdefg",    "ab cdef",  "ab cdef;abcd cdefg" },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     std::vector<TitleAndURL> bookmarks;
     for (const std::string& title : base::SplitString(
              data[i].titles, ";",
@@ -321,7 +321,7 @@
     { "foo bar", "Baz Bur",      "http://foo.com/blah/flub",    false }
   };
 
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     model_ = TestBookmarkClient::CreateModel();
     std::vector<TitleAndURL> bookmarks;
     bookmarks.push_back(TitleAndURL(data[i].title, data[i].url));
@@ -355,7 +355,7 @@
   };
 
   GURL url(kAboutBlankURL);
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     model_->AddURL(model_->other_node(), 0, UTF8ToUTF16(data[i].title), url);
     std::vector<TitledUrlMatch> matches;
     model_->GetBookmarksMatching(UTF8ToUTF16(data[i].query), 10, &matches);
@@ -381,7 +381,7 @@
     { "foobar foobar",            "foobar foo",   "0,6:7,13" },
     { "foobar foobar",            "foo foobar",   "0,6:7,13" },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     std::vector<TitleAndURL> bookmarks;
     TitleAndURL bookmark(data[i].title, kAboutBlankURL);
     bookmarks.push_back(bookmark);
@@ -432,7 +432,7 @@
                                                          "130,134:139,143"  }
   };
 
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     model_ = TestBookmarkClient::CreateModel();
     std::vector<TitleAndURL> bookmarks;
     TitleAndURL bookmark("123456", data[i].url);
@@ -454,7 +454,7 @@
 TEST_F(BookmarkIndexTest, Remove) {
   const char* titles[] = { "a", "b" };
   const char* urls[] = {kAboutBlankURL, kAboutBlankURL};
-  AddBookmarks(titles, urls, arraysize(titles));
+  AddBookmarks(titles, urls, base::size(titles));
 
   // Remove the node and make sure we don't get back any results.
   model_->Remove(model_->other_node()->GetChild(0));
@@ -465,12 +465,12 @@
 TEST_F(BookmarkIndexTest, ChangeTitle) {
   const char* titles[] = { "a", "b" };
   const char* urls[] = {kAboutBlankURL, kAboutBlankURL};
-  AddBookmarks(titles, urls, arraysize(titles));
+  AddBookmarks(titles, urls, base::size(titles));
 
   // Remove the node and make sure we don't get back any results.
   const char* expected[] = { "blah" };
   model_->SetTitle(model_->other_node()->GetChild(0), ASCIIToUTF16("blah"));
-  ExpectMatches("BlAh", expected, arraysize(expected));
+  ExpectMatches("BlAh", expected, base::size(expected));
 }
 
 // Makes sure index is updated when a node's URL is changed.
@@ -478,18 +478,18 @@
   const char* titles[] = { "a", "b" };
   const char* urls[] = {"http://fizz",
                         "http://fuzz"};
-  AddBookmarks(titles, urls, arraysize(titles));
+  AddBookmarks(titles, urls, base::size(titles));
 
   const char* expected[] = { "a" };
   model_->SetURL(model_->other_node()->GetChild(0), GURL("http://blah"));
-  ExpectMatches("blah", expected, arraysize(expected));
+  ExpectMatches("blah", expected, base::size(expected));
 }
 
 // Makes sure no more than max queries is returned.
 TEST_F(BookmarkIndexTest, HonorMax) {
   const char* titles[] = { "abcd", "abcde" };
   const char* urls[] = {kAboutBlankURL, kAboutBlankURL};
-  AddBookmarks(titles, urls, arraysize(titles));
+  AddBookmarks(titles, urls, base::size(titles));
 
   std::vector<TitledUrlMatch> matches;
   model_->GetBookmarksMatching(ASCIIToUTF16("ABc"), 1, &matches);
@@ -523,14 +523,14 @@
   };
 
   std::map<GURL, int> typed_count_map;
-  for (size_t i = 0; i < arraysize(data); ++i)
+  for (size_t i = 0; i < base::size(data); ++i)
     typed_count_map.insert(std::make_pair(data[i].url, data[i].typed_count));
 
   std::unique_ptr<BookmarkModel> model =
       TestBookmarkClient::CreateModelWithClient(
           std::make_unique<BookmarkClientMock>(typed_count_map));
 
-  for (size_t i = 0; i < arraysize(data); ++i)
+  for (size_t i = 0; i < base::size(data); ++i)
     // Populate the bookmark index.
     model->AddURL(
         model->other_node(), i, UTF8ToUTF16(data[i].title), data[i].url);
diff --git a/components/bookmarks/browser/bookmark_model_unittest.cc b/components/bookmarks/browser/bookmark_model_unittest.cc
index adb04299..ae5f04c 100644
--- a/components/bookmarks/browser/bookmark_model_unittest.cc
+++ b/components/bookmarks/browser/bookmark_model_unittest.cc
@@ -17,7 +17,6 @@
 #include "base/compiler_specific.h"
 #include "base/containers/hash_tables.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
 #include "base/strings/string16.h"
@@ -538,7 +537,7 @@
 }
 
 TEST_F(BookmarkModelTest, AddURLWithWhitespaceTitle) {
-  for (size_t i = 0; i < arraysize(url_whitespace_test_cases); ++i) {
+  for (size_t i = 0; i < base::size(url_whitespace_test_cases); ++i) {
     const BookmarkNode* root = model_->bookmark_bar_node();
     const base::string16 title(
         ASCIIToUTF16(url_whitespace_test_cases[i].input_title));
@@ -625,7 +624,7 @@
 }
 
 TEST_F(BookmarkModelTest, AddFolderWithWhitespaceTitle) {
-  for (size_t i = 0; i < arraysize(title_whitespace_test_cases); ++i) {
+  for (size_t i = 0; i < base::size(title_whitespace_test_cases); ++i) {
     const BookmarkNode* root = model_->bookmark_bar_node();
     const base::string16 title(
         ASCIIToUTF16(title_whitespace_test_cases[i].input_title));
@@ -738,7 +737,7 @@
 }
 
 TEST_F(BookmarkModelTest, SetTitleWithWhitespace) {
-  for (size_t i = 0; i < arraysize(title_whitespace_test_cases); ++i) {
+  for (size_t i = 0; i < base::size(title_whitespace_test_cases); ++i) {
     const BookmarkNode* root = model_->bookmark_bar_node();
     base::string16 title(ASCIIToUTF16("dummy"));
     const GURL url("http://foo.com");
@@ -1311,7 +1310,7 @@
     { "a b c [ d e [ f ] ]", "g h i [ j k [ l ] ]"},
   };
   std::unique_ptr<BookmarkModel> model;
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     model = TestBookmarkClient::CreateModel();
 
     TestNode bbn;
diff --git a/components/bookmarks/browser/bookmark_utils_unittest.cc b/components/bookmarks/browser/bookmark_utils_unittest.cc
index f35dbfc..218324e1 100644
--- a/components/bookmarks/browser/bookmark_utils_unittest.cc
+++ b/components/bookmarks/browser/bookmark_utils_unittest.cc
@@ -10,7 +10,7 @@
 #include <utility>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "build/build_config.h"
@@ -240,7 +240,7 @@
                                                &query.url, &query.title};
 
   // Test two fields matching.
-  for (size_t i = 0; i < arraysize(fields); i++) {
+  for (size_t i = 0; i < base::size(fields); i++) {
     std::unique_ptr<base::string16> original_value(fields[i]->release());
     GetBookmarksMatchingProperties(model.get(), query, 100, &nodes);
     ASSERT_EQ(1U, nodes.size());
@@ -250,7 +250,7 @@
   }
 
   // Test two fields matching with one non-matching field.
-  for (size_t i = 0; i < arraysize(fields); i++) {
+  for (size_t i = 0; i < base::size(fields); i++) {
     std::unique_ptr<base::string16> original_value(fields[i]->release());
     fields[i]->reset(new base::string16(ASCIIToUTF16("fjdkslafjkldsa")));
     GetBookmarksMatchingProperties(model.get(), query, 100, &nodes);
diff --git a/components/browser_sync/profile_sync_service_bookmark_unittest.cc b/components/browser_sync/profile_sync_service_bookmark_unittest.cc
index b1404be0..5076b1b 100644
--- a/components/browser_sync/profile_sync_service_bookmark_unittest.cc
+++ b/components/browser_sync/profile_sync_service_bookmark_unittest.cc
@@ -19,9 +19,9 @@
 #include "base/containers/stack.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -1401,7 +1401,7 @@
       "890123456789"};
   // Create both folders and bookmarks using each name.
   GURL url("http://www.doublemint.com");
-  for (size_t i = 0; i < arraysize(names); ++i) {
+  for (size_t i = 0; i < base::size(names); ++i) {
     model()->AddFolder(model()->other_node(), 0, base::ASCIIToUTF16(names[i]));
     model()->AddURL(model()->other_node(), 0, base::ASCIIToUTF16(names[i]),
                     url);
@@ -1409,7 +1409,7 @@
 
   // Verify that the browser model matches the sync model.
   EXPECT_EQ(static_cast<size_t>(model()->other_node()->child_count()),
-            2 * arraysize(names));
+            2 * base::size(names));
   ExpectModelMatch();
 
   // Restart and re-associate. Verify things still match.
@@ -1417,7 +1417,7 @@
   LoadBookmarkModel(LOAD_FROM_STORAGE, SAVE_TO_STORAGE);
   StartSync();
   EXPECT_EQ(static_cast<size_t>(model()->other_node()->child_count()),
-            2 * arraysize(names));
+            2 * base::size(names));
   ExpectModelMatch();
 }
 
@@ -1817,39 +1817,39 @@
   const BookmarkNode* bookmarks_bar_node = model()->bookmark_bar_node();
   int count = 0;
   PopulateFromTestData(bookmarks_bar_node, kBookmarkBarChildren,
-                       arraysize(kBookmarkBarChildren), &count);
+                       base::size(kBookmarkBarChildren), &count);
 
   ASSERT_GE(bookmarks_bar_node->child_count(), 4);
   const BookmarkNode* f1_node = bookmarks_bar_node->GetChild(1);
-  PopulateFromTestData(f1_node, kF1Children, arraysize(kF1Children), &count);
+  PopulateFromTestData(f1_node, kF1Children, base::size(kF1Children), &count);
   const BookmarkNode* f2_node = bookmarks_bar_node->GetChild(3);
-  PopulateFromTestData(f2_node, kF2Children, arraysize(kF2Children), &count);
+  PopulateFromTestData(f2_node, kF2Children, base::size(kF2Children), &count);
 
   const BookmarkNode* other_bookmarks_node = model()->other_node();
   PopulateFromTestData(other_bookmarks_node, kOtherBookmarkChildren,
-                       arraysize(kOtherBookmarkChildren), &count);
+                       base::size(kOtherBookmarkChildren), &count);
 
   ASSERT_GE(other_bookmarks_node->child_count(), 6);
   const BookmarkNode* f3_node = other_bookmarks_node->GetChild(0);
-  PopulateFromTestData(f3_node, kF3Children, arraysize(kF3Children), &count);
+  PopulateFromTestData(f3_node, kF3Children, base::size(kF3Children), &count);
   const BookmarkNode* f4_node = other_bookmarks_node->GetChild(3);
-  PopulateFromTestData(f4_node, kF4Children, arraysize(kF4Children), &count);
+  PopulateFromTestData(f4_node, kF4Children, base::size(kF4Children), &count);
   const BookmarkNode* dup_node = other_bookmarks_node->GetChild(4);
-  PopulateFromTestData(dup_node, kDup1Children, arraysize(kDup1Children),
+  PopulateFromTestData(dup_node, kDup1Children, base::size(kDup1Children),
                        &count);
   dup_node = other_bookmarks_node->GetChild(5);
-  PopulateFromTestData(dup_node, kDup2Children, arraysize(kDup2Children),
+  PopulateFromTestData(dup_node, kDup2Children, base::size(kDup2Children),
                        &count);
 
   const BookmarkNode* mobile_bookmarks_node = model()->mobile_node();
   PopulateFromTestData(mobile_bookmarks_node, kMobileBookmarkChildren,
-                       arraysize(kMobileBookmarkChildren), &count);
+                       base::size(kMobileBookmarkChildren), &count);
 
   ASSERT_GE(mobile_bookmarks_node->child_count(), 3);
   const BookmarkNode* f5_node = mobile_bookmarks_node->GetChild(0);
-  PopulateFromTestData(f5_node, kF5Children, arraysize(kF5Children), &count);
+  PopulateFromTestData(f5_node, kF5Children, base::size(kF5Children), &count);
   const BookmarkNode* f6_node = mobile_bookmarks_node->GetChild(1);
-  PopulateFromTestData(f6_node, kF6Children, arraysize(kF6Children), &count);
+  PopulateFromTestData(f6_node, kF6Children, base::size(kF6Children), &count);
 
   ExpectBookmarkModelMatchesTestData();
 }
@@ -1859,39 +1859,39 @@
   const BookmarkNode* bookmark_bar_node = model()->bookmark_bar_node();
   int count = 0;
   CompareWithTestData(bookmark_bar_node, kBookmarkBarChildren,
-                      arraysize(kBookmarkBarChildren), &count);
+                      base::size(kBookmarkBarChildren), &count);
 
   ASSERT_GE(bookmark_bar_node->child_count(), 4);
   const BookmarkNode* f1_node = bookmark_bar_node->GetChild(1);
-  CompareWithTestData(f1_node, kF1Children, arraysize(kF1Children), &count);
+  CompareWithTestData(f1_node, kF1Children, base::size(kF1Children), &count);
   const BookmarkNode* f2_node = bookmark_bar_node->GetChild(3);
-  CompareWithTestData(f2_node, kF2Children, arraysize(kF2Children), &count);
+  CompareWithTestData(f2_node, kF2Children, base::size(kF2Children), &count);
 
   const BookmarkNode* other_bookmarks_node = model()->other_node();
   CompareWithTestData(other_bookmarks_node, kOtherBookmarkChildren,
-                      arraysize(kOtherBookmarkChildren), &count);
+                      base::size(kOtherBookmarkChildren), &count);
 
   ASSERT_GE(other_bookmarks_node->child_count(), 6);
   const BookmarkNode* f3_node = other_bookmarks_node->GetChild(0);
-  CompareWithTestData(f3_node, kF3Children, arraysize(kF3Children), &count);
+  CompareWithTestData(f3_node, kF3Children, base::size(kF3Children), &count);
   const BookmarkNode* f4_node = other_bookmarks_node->GetChild(3);
-  CompareWithTestData(f4_node, kF4Children, arraysize(kF4Children), &count);
+  CompareWithTestData(f4_node, kF4Children, base::size(kF4Children), &count);
   const BookmarkNode* dup_node = other_bookmarks_node->GetChild(4);
-  CompareWithTestData(dup_node, kDup1Children, arraysize(kDup1Children),
+  CompareWithTestData(dup_node, kDup1Children, base::size(kDup1Children),
                       &count);
   dup_node = other_bookmarks_node->GetChild(5);
-  CompareWithTestData(dup_node, kDup2Children, arraysize(kDup2Children),
+  CompareWithTestData(dup_node, kDup2Children, base::size(kDup2Children),
                       &count);
 
   const BookmarkNode* mobile_bookmarks_node = model()->mobile_node();
   CompareWithTestData(mobile_bookmarks_node, kMobileBookmarkChildren,
-                      arraysize(kMobileBookmarkChildren), &count);
+                      base::size(kMobileBookmarkChildren), &count);
 
   ASSERT_GE(mobile_bookmarks_node->child_count(), 3);
   const BookmarkNode* f5_node = mobile_bookmarks_node->GetChild(0);
-  CompareWithTestData(f5_node, kF5Children, arraysize(kF5Children), &count);
+  CompareWithTestData(f5_node, kF5Children, base::size(kF5Children), &count);
   const BookmarkNode* f6_node = mobile_bookmarks_node->GetChild(1);
-  CompareWithTestData(f6_node, kF6Children, arraysize(kF6Children), &count);
+  CompareWithTestData(f6_node, kF6Children, base::size(kF6Children), &count);
 }
 
 // Tests persistence of the profile sync service by unloading the
diff --git a/components/captive_portal/captive_portal_types.cc b/components/captive_portal/captive_portal_types.cc
index 22a6f76..ffb93dc9 100644
--- a/components/captive_portal/captive_portal_types.cc
+++ b/components/captive_portal/captive_portal_types.cc
@@ -5,7 +5,7 @@
 #include "components/captive_portal/captive_portal_types.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace captive_portal {
 
@@ -17,7 +17,7 @@
   "BehindCaptivePortal",
   "NumCaptivePortalResults",
 };
-static_assert(arraysize(kCaptivePortalResultNames) == RESULT_COUNT + 1,
+static_assert(base::size(kCaptivePortalResultNames) == RESULT_COUNT + 1,
               "kCaptivePortalResultNames should have "
               "RESULT_COUNT + 1 elements");
 
@@ -27,7 +27,7 @@
 std::string CaptivePortalResultToString(CaptivePortalResult result) {
   DCHECK_GE(result, 0);
   DCHECK_LT(static_cast<unsigned int>(result),
-            arraysize(kCaptivePortalResultNames));
+            base::size(kCaptivePortalResultNames));
   return kCaptivePortalResultNames[result];
 }
 
diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc
index 6af8d600..c570567 100644
--- a/components/cbor/reader_unittest.cc
+++ b/components/cbor/reader_unittest.cc
@@ -8,6 +8,7 @@
 #include "components/cbor/reader.h"
 
 #include "base/containers/span.h"
+#include "base/stl_util.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -742,7 +743,7 @@
   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, arraysize(kMapTestCase));
+  EXPECT_EQ(num_bytes_consumed, base::size(kMapTestCase));
 }
 
 TEST(CBORReaderTest, TestReadNestedMap) {
diff --git a/components/cbor/writer_unittest.cc b/components/cbor/writer_unittest.cc
index 3fb96884..63e4d76 100644
--- a/components/cbor/writer_unittest.cc
+++ b/components/cbor/writer_unittest.cc
@@ -7,6 +7,7 @@
 #include <limits>
 #include <string>
 
+#include "base/stl_util.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -134,7 +135,7 @@
   ASSERT_TRUE(cbor.has_value());
   EXPECT_THAT(cbor.value(),
               testing::ElementsAreArray(kArrayTestCaseCbor,
-                                        arraysize(kArrayTestCaseCbor)));
+                                        base::size(kArrayTestCaseCbor)));
 }
 
 TEST(CBORWriterTest, TestWriteMap) {
@@ -257,8 +258,9 @@
   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, arraysize(kMapTestCaseCbor)));
+  EXPECT_THAT(cbor.value(),
+              testing::ElementsAreArray(kMapTestCaseCbor,
+                                        base::size(kMapTestCaseCbor)));
 }
 
 TEST(CBORWriterTest, TestWriteMapWithArray) {
@@ -284,7 +286,7 @@
   ASSERT_TRUE(cbor.has_value());
   EXPECT_THAT(cbor.value(),
               testing::ElementsAreArray(kMapArrayTestCaseCbor,
-                                        arraysize(kMapArrayTestCaseCbor)));
+                                        base::size(kMapArrayTestCaseCbor)));
 }
 
 TEST(CBORWriterTest, TestWriteNestedMap) {
@@ -313,7 +315,7 @@
   ASSERT_TRUE(cbor.has_value());
   EXPECT_THAT(cbor.value(),
               testing::ElementsAreArray(kNestedMapTestCase,
-                                        arraysize(kNestedMapTestCase)));
+                                        base::size(kNestedMapTestCase)));
 }
 
 TEST(CBORWriterTest, TestSignedExchangeExample) {
@@ -360,7 +362,7 @@
   ASSERT_TRUE(cbor.has_value());
   EXPECT_THAT(cbor.value(),
               testing::ElementsAreArray(kSignedExchangeExample,
-                                        arraysize(kSignedExchangeExample)));
+                                        base::size(kSignedExchangeExample)));
 }
 
 TEST(CBORWriterTest, TestWriteSimpleValue) {
diff --git a/components/cdm/common/widevine_drm_delegate_android.cc b/components/cdm/common/widevine_drm_delegate_android.cc
index 3bb5469..7fe46b8 100644
--- a/components/cdm/common/widevine_drm_delegate_android.cc
+++ b/components/cdm/common/widevine_drm_delegate_android.cc
@@ -4,7 +4,7 @@
 
 #include "components/cdm/common/widevine_drm_delegate_android.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/cdm/cenc_utils.h"
 
 namespace cdm {
@@ -23,7 +23,7 @@
 
 const std::vector<uint8_t> WidevineDrmDelegateAndroid::GetUUID() const {
   return std::vector<uint8_t>(kWidevineUuid,
-                              kWidevineUuid + arraysize(kWidevineUuid));
+                              kWidevineUuid + base::size(kWidevineUuid));
 }
 
 bool WidevineDrmDelegateAndroid::OnCreateSession(
diff --git a/components/certificate_transparency/log_dns_client.cc b/components/certificate_transparency/log_dns_client.cc
index 1f109e7..c95e336 100644
--- a/components/certificate_transparency/log_dns_client.cc
+++ b/components/certificate_transparency/log_dns_client.cc
@@ -11,6 +11,7 @@
 #include "base/logging.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/strcat.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -68,7 +69,7 @@
   const uint16_t kIanaAddressFamilyIpV4 = 1;
 
   char buf[4];
-  base::BigEndianWriter writer(buf, arraysize(buf));
+  base::BigEndianWriter writer(buf, base::size(buf));
   // family - address is empty so the value of this is irrelevant, so long as
   // it's valid (see https://tools.ietf.org/html/rfc7871#section-7.1.2).
   writer.WriteU16(kIanaAddressFamilyIpV4);
@@ -79,7 +80,7 @@
   // no address - don't want a client subnet in the query.
 
   return net::OptRecordRdata::Opt(kClientSubnetExtensionCode,
-                                  base::StringPiece(buf, arraysize(buf)));
+                                  base::StringPiece(buf, base::size(buf)));
 }
 
 // Parses the DNS response and extracts a single string from the TXT RDATA.
diff --git a/components/certificate_transparency/log_dns_client_unittest.cc b/components/certificate_transparency/log_dns_client_unittest.cc
index ba6c7559..a7027d8 100644
--- a/components/certificate_transparency/log_dns_client_unittest.cc
+++ b/components/certificate_transparency/log_dns_client_unittest.cc
@@ -12,6 +12,7 @@
 
 #include "base/format_macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/metrics/histogram_tester.h"
@@ -677,8 +678,8 @@
   // Check that 3 queries can be performed in parallel.
   constexpr size_t kNumOfParallelQueries = 3;
   ASSERT_THAT(kNumOfParallelQueries,
-              AllOf(Le(arraysize(kLeafIndexQnames)),
-                    Le(arraysize(kLeafIndices)), Le(arraysize(kTreeSizes))))
+              AllOf(Le(base::size(kLeafIndexQnames)),
+                    Le(base::size(kLeafIndices)), Le(base::size(kTreeSizes))))
       << "Not enough test data for this many parallel queries";
 
   std::unique_ptr<LogDnsClient> log_client =
diff --git a/components/client_update_protocol/ecdsa.cc b/components/client_update_protocol/ecdsa.cc
index 1325d6a..53b7e90 100644
--- a/components/client_update_protocol/ecdsa.cc
+++ b/components/client_update_protocol/ecdsa.cc
@@ -5,8 +5,8 @@
 #include "components/client_update_protocol/ecdsa.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
@@ -49,7 +49,7 @@
   // Remove the weak prefix, then remove the begin and the end quotes.
   const char kWeakETagPrefix[] = "W/";
   if (etag_header_value.starts_with(kWeakETagPrefix))
-    etag_header_value.remove_prefix(arraysize(kWeakETagPrefix) - 1);
+    etag_header_value.remove_prefix(base::size(kWeakETagPrefix) - 1);
   if (etag_header_value.size() >= 2 && etag_header_value.starts_with("\"") &&
       etag_header_value.ends_with("\"")) {
     etag_header_value.remove_prefix(1);
diff --git a/components/cloud_devices/common/printer_description.cc b/components/cloud_devices/common/printer_description.cc
index 878b398f..733c1dc 100644
--- a/components/cloud_devices/common/printer_description.cc
+++ b/components/cloud_devices/common/printer_description.cc
@@ -12,7 +12,7 @@
 
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
 #include "components/cloud_devices/common/cloud_device_description_consts.h"
@@ -345,7 +345,7 @@
 #undef MAP_CLOUD_PRINT_MEDIA_TYPE
 
 const MediaDefinition& FindMediaByType(MediaType type) {
-  for (size_t i = 0; i < arraysize(kMediaDefinitions); ++i) {
+  for (size_t i = 0; i < base::size(kMediaDefinitions); ++i) {
     if (kMediaDefinitions[i].id == type)
       return kMediaDefinitions[i];
   }
@@ -355,7 +355,7 @@
 
 const MediaDefinition* FindMediaBySize(int32_t width_um, int32_t height_um) {
   const MediaDefinition* result = nullptr;
-  for (size_t i = 0; i < arraysize(kMediaDefinitions); ++i) {
+  for (size_t i = 0; i < base::size(kMediaDefinitions); ++i) {
     int32_t diff =
         std::max(std::abs(width_um - kMediaDefinitions[i].width_um),
                  std::abs(height_um - kMediaDefinitions[i].height_um));
@@ -367,7 +367,7 @@
 
 template <class T, class IdType>
 std::string TypeToString(const T& names, IdType id) {
-  for (size_t i = 0; i < arraysize(names); ++i) {
+  for (size_t i = 0; i < base::size(names); ++i) {
     if (id == names[i].id)
       return names[i].json_name;
   }
@@ -377,7 +377,7 @@
 
 template <class T, class IdType>
 bool TypeFromString(const T& names, const std::string& type, IdType* id) {
-  for (size_t i = 0; i < arraysize(names); ++i) {
+  for (size_t i = 0; i < base::size(names); ++i) {
     if (type == names[i].json_name) {
       *id = names[i].id;
       return true;
diff --git a/components/constrained_window/BUILD.gn b/components/constrained_window/BUILD.gn
index 346cf11..33ae96c 100644
--- a/components/constrained_window/BUILD.gn
+++ b/components/constrained_window/BUILD.gn
@@ -47,7 +47,6 @@
   deps = [
     ":constrained_window",
     "//components/web_modal:test_support",
-    "//ui/views",
     "//ui/views:test_support",
   ]
 }
diff --git a/components/content_settings/core/browser/content_settings_policy_provider.cc b/components/content_settings/core/browser/content_settings_policy_provider.cc
index 3e636a9..99b0c54 100644
--- a/components/content_settings/core/browser/content_settings_policy_provider.cc
+++ b/components/content_settings/core/browser/content_settings_policy_provider.cc
@@ -11,7 +11,7 @@
 #include "base/bind.h"
 #include "base/feature_list.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/content_settings/core/browser/content_settings_info.h"
 #include "components/content_settings/core/browser/content_settings_registry.h"
@@ -211,7 +211,7 @@
 
 void PolicyProvider::GetContentSettingsFromPreferences(
     OriginIdentifierValueMap* value_map) {
-  for (size_t i = 0; i < arraysize(kPrefsForManagedContentSettingsMap); ++i) {
+  for (size_t i = 0; i < base::size(kPrefsForManagedContentSettingsMap); ++i) {
     const char* pref_name = kPrefsForManagedContentSettingsMap[i].pref_name;
     // Skip unset policies.
     if (!prefs_->HasPrefPath(pref_name)) {
diff --git a/components/content_settings/core/browser/content_settings_registry.cc b/components/content_settings/core/browser/content_settings_registry.cc
index 4924d2c..912fdeba2 100644
--- a/components/content_settings/core/browser/content_settings_registry.cc
+++ b/components/content_settings/core/browser/content_settings_registry.cc
@@ -8,7 +8,6 @@
 #include <utility>
 
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/values.h"
 #include "build/build_config.h"
@@ -37,14 +36,14 @@
 std::vector<std::string> WhitelistedSchemes(const char* scheme1,
                                             const char* scheme2) {
   const char* schemes[] = {scheme1, scheme2};
-  return std::vector<std::string>(schemes, schemes + arraysize(schemes));
+  return std::vector<std::string>(schemes, schemes + base::size(schemes));
 }
 
 std::vector<std::string> WhitelistedSchemes(const char* scheme1,
                                             const char* scheme2,
                                             const char* scheme3) {
   const char* schemes[] = {scheme1, scheme2, scheme3};
-  return std::vector<std::string>(schemes, schemes + arraysize(schemes));
+  return std::vector<std::string>(schemes, schemes + base::size(schemes));
 }
 
 std::set<ContentSetting> ValidSettings() {
@@ -54,14 +53,14 @@
 std::set<ContentSetting> ValidSettings(ContentSetting setting1,
                                        ContentSetting setting2) {
   ContentSetting settings[] = {setting1, setting2};
-  return std::set<ContentSetting>(settings, settings + arraysize(settings));
+  return std::set<ContentSetting>(settings, settings + base::size(settings));
 }
 
 std::set<ContentSetting> ValidSettings(ContentSetting setting1,
                                        ContentSetting setting2,
                                        ContentSetting setting3) {
   ContentSetting settings[] = {setting1, setting2, setting3};
-  return std::set<ContentSetting>(settings, settings + arraysize(settings));
+  return std::set<ContentSetting>(settings, settings + base::size(settings));
 }
 
 std::set<ContentSetting> ValidSettings(ContentSetting setting1,
@@ -69,7 +68,7 @@
                                        ContentSetting setting3,
                                        ContentSetting setting4) {
   ContentSetting settings[] = {setting1, setting2, setting3, setting4};
-  return std::set<ContentSetting>(settings, settings + arraysize(settings));
+  return std::set<ContentSetting>(settings, settings + base::size(settings));
 }
 
 ContentSetting GetInitialDefaultContentSettingForProtectedMediaIdentifier() {
diff --git a/components/content_settings/core/browser/content_settings_utils.cc b/components/content_settings/core/browser/content_settings_utils.cc
index 6f087c5..cb34da5 100644
--- a/components/content_settings/core/browser/content_settings_utils.cc
+++ b/components/content_settings/core/browser/content_settings_utils.cc
@@ -9,7 +9,7 @@
 #include <vector>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/values.h"
 #include "components/content_settings/core/browser/host_content_settings_map.h"
@@ -31,7 +31,7 @@
     {CONTENT_SETTING_SESSION_ONLY, "session_only"},
     {CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, "detect_important_content"},
 };
-static_assert(arraysize(kContentSettingsStringMapping) ==
+static_assert(base::size(kContentSettingsStringMapping) ==
                   CONTENT_SETTING_NUM_SETTINGS,
               "kContentSettingsToFromString should have "
               "CONTENT_SETTING_NUM_SETTINGS elements");
@@ -50,8 +50,8 @@
     CONTENT_SETTING_BLOCK
 };
 
-static_assert(arraysize(kContentSettingOrder) ==
-              CONTENT_SETTING_NUM_SETTINGS - 1,
+static_assert(base::size(kContentSettingOrder) ==
+                  CONTENT_SETTING_NUM_SETTINGS - 1,
               "kContentSettingOrder should have CONTENT_SETTING_NUM_SETTINGS-1"
               "entries");
 
@@ -69,7 +69,7 @@
 
 bool ContentSettingFromString(const std::string& name,
                               ContentSetting* setting) {
-  for (size_t i = 0; i < arraysize(kContentSettingsStringMapping); ++i) {
+  for (size_t i = 0; i < base::size(kContentSettingsStringMapping); ++i) {
     if (name == kContentSettingsStringMapping[i].content_setting_str) {
       *setting = kContentSettingsStringMapping[i].content_setting;
       return true;
diff --git a/components/content_settings/core/browser/content_settings_utils_unittest.cc b/components/content_settings/core/browser/content_settings_utils_unittest.cc
index 8860b2b..8de20d0 100644
--- a/components/content_settings/core/browser/content_settings_utils_unittest.cc
+++ b/components/content_settings/core/browser/content_settings_utils_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/content_settings/core/test/content_settings_test_utils.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -24,7 +24,7 @@
   "session_only",
   "detect_important_content",
 };
-static_assert(arraysize(kContentSettingNames) == CONTENT_SETTING_NUM_SETTINGS,
+static_assert(base::size(kContentSettingNames) == CONTENT_SETTING_NUM_SETTINGS,
               "kContentSettingNames has an unexpected number of elements");
 
 }  // namespace
@@ -68,7 +68,7 @@
       ContentSettingToString(CONTENT_SETTING_NUM_SETTINGS);
   EXPECT_TRUE(setting_string.empty());
 
-  for (size_t i = 0; i < arraysize(kContentSettingNames); ++i) {
+  for (size_t i = 0; i < base::size(kContentSettingNames); ++i) {
     ContentSetting setting = static_cast<ContentSetting>(i);
     setting_string = ContentSettingToString(setting);
     EXPECT_EQ(kContentSettingNames[i], setting_string);
diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc
index 7b32f55c..7d705f2 100644
--- a/components/content_settings/core/browser/host_content_settings_map.cc
+++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -12,10 +12,10 @@
 
 #include "base/command_line.h"
 #include "base/containers/flat_map.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -77,7 +77,7 @@
 };
 
 static_assert(
-    arraysize(kProviderNamesSourceMap) ==
+    base::size(kProviderNamesSourceMap) ==
         HostContentSettingsMap::NUM_PROVIDER_TYPES,
     "kProviderNamesSourceMap should have NUM_PROVIDER_TYPES elements");
 
@@ -868,7 +868,7 @@
 // static
 HostContentSettingsMap::ProviderType
 HostContentSettingsMap::GetProviderTypeFromSource(const std::string& source) {
-  for (size_t i = 0; i < arraysize(kProviderNamesSourceMap); ++i) {
+  for (size_t i = 0; i < base::size(kProviderNamesSourceMap); ++i) {
     if (source == kProviderNamesSourceMap[i].provider_name)
       return static_cast<ProviderType>(i);
   }
diff --git a/components/content_settings/core/common/content_settings.cc b/components/content_settings/core/common/content_settings.cc
index 0b5c2d2..0e3d289 100644
--- a/components/content_settings/core/common/content_settings.cc
+++ b/components/content_settings/core/common/content_settings.cc
@@ -9,7 +9,6 @@
 #include <utility>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "build/build_config.h"
 #include "components/content_settings/core/common/content_settings_utils.h"
@@ -85,7 +84,7 @@
 
 int ContentSettingTypeToHistogramValue(ContentSettingsType content_setting,
                                        size_t* num_values) {
-  *num_values = arraysize(kHistogramValue);
+  *num_values = base::size(kHistogramValue);
 
   // Verify the array is sorted by enum type and contains all values.
   DCHECK(std::is_sorted(std::begin(kHistogramValue), std::end(kHistogramValue),
diff --git a/components/content_settings/core/common/content_settings_pattern.cc b/components/content_settings/core/common/content_settings_pattern.cc
index 6c84bfb..13b54f4 100644
--- a/components/content_settings/core/common/content_settings_pattern.cc
+++ b/components/content_settings/core/common/content_settings_pattern.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "components/content_settings/core/common/content_settings_pattern_parser.h"
@@ -30,7 +30,7 @@
                                     url::kFileScheme, "chrome-extension",
                                     "chrome-search"};
 
-static_assert(arraysize(kSchemeNames) == ContentSettingsPattern::SCHEME_MAX,
+static_assert(base::size(kSchemeNames) == ContentSettingsPattern::SCHEME_MAX,
               "kSchemeNames should have SCHEME_MAX elements");
 
 std::string GetDefaultPort(const std::string& scheme) {
@@ -514,7 +514,7 @@
   if (parts_.is_scheme_wildcard)
     return SCHEME_WILDCARD;
 
-  for (size_t i = 2; i < arraysize(kSchemeNames); ++i) {
+  for (size_t i = 2; i < base::size(kSchemeNames); ++i) {
     if (parts_.scheme == kSchemeNames[i])
       return static_cast<SchemeType>(i);
   }
diff --git a/components/crash/content/app/breakpad_win.cc b/components/crash/content/app/breakpad_win.cc
index dfb140d..dec9daf 100644
--- a/components/crash/content/app/breakpad_win.cc
+++ b/components/crash/content/app/breakpad_win.cc
@@ -24,9 +24,9 @@
 #include "base/debug/dump_without_crashing.h"
 #include "base/environment.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/no_destructor.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
@@ -210,7 +210,7 @@
       { PT_ROAMING, L"roaming" },
       { PT_TEMPORARY, L"temporary" },
     };
-    for (size_t i = 0; i < arraysize(kBitNames); ++i) {
+    for (size_t i = 0; i < base::size(kBitNames); ++i) {
       const DWORD this_bit = kBitNames[i].bit;
       if ((profile_bits & this_bit) != 0) {
         profile_type.append(kBitNames[i].name);
diff --git a/components/crash/content/app/crashpad_win.cc b/components/crash/content/app/crashpad_win.cc
index 8b55f0a..cc16c40 100644
--- a/components/crash/content/app/crashpad_win.cc
+++ b/components/crash/content/app/crashpad_win.cc
@@ -10,6 +10,7 @@
 #include "base/environment.h"
 #include "base/files/file_util.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
@@ -30,7 +31,7 @@
     std::map<std::string, std::string>* annotations) {
   CrashReporterClient* crash_reporter_client = GetCrashReporterClient();
   wchar_t exe_file[MAX_PATH] = {};
-  CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file)));
+  CHECK(::GetModuleFileName(nullptr, exe_file, base::size(exe_file)));
   base::string16 product_name, version, special_build, channel_name;
   crash_reporter_client->GetProductNameAndVersion(
       exe_file, &product_name, &version, &special_build, &channel_name);
@@ -96,7 +97,7 @@
     if (exe_file.empty()) {
       wchar_t exe_file_path[MAX_PATH] = {};
       CHECK(::GetModuleFileName(nullptr, exe_file_path,
-                                arraysize(exe_file_path)));
+                                base::size(exe_file_path)));
 
       exe_file = base::FilePath(exe_file_path);
     }
diff --git a/components/crash/core/browser/crashes_ui_util.cc b/components/crash/core/browser/crashes_ui_util.cc
index 78fa705f..b714115 100644
--- a/components/crash/core/browser/crashes_ui_util.cc
+++ b/components/crash/core/browser/crashes_ui_util.cc
@@ -9,7 +9,7 @@
 #include <vector>
 
 #include "base/i18n/time_formatting.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/strings/grit/components_chromium_strings.h"
 #include "components/strings/grit/components_strings.h"
@@ -38,7 +38,7 @@
 };
 
 const size_t kCrashesUILocalizedStringsCount =
-    arraysize(kCrashesUILocalizedStrings);
+    base::size(kCrashesUILocalizedStrings);
 
 const char kCrashesUICrashesJS[] = "crashes.js";
 const char kCrashesUIRequestCrashList[] = "requestCrashList";
diff --git a/components/crash/core/common/crash_key_unittest.cc b/components/crash/core/common/crash_key_unittest.cc
index 466eb255..cb9ad966 100644
--- a/components/crash/core/common/crash_key_unittest.cc
+++ b/components/crash/core/common/crash_key_unittest.cc
@@ -6,6 +6,7 @@
 
 #include "base/debug/crash_logging.h"
 #include "base/debug/stack_trace.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -35,7 +36,7 @@
       0x0badbeef, 0x77778888, 0xabc, 0x000ddeeff, 0x12345678,
   };
   base::debug::StackTrace trace(reinterpret_cast<const void* const*>(addresses),
-                                arraysize(addresses));
+                                base::size(addresses));
 
   std::string too_small = internal::FormatStackTrace(trace, 3);
   EXPECT_EQ(0u, too_small.size());
@@ -56,7 +57,7 @@
       0xbaaaabaaaaba, 0x1000000000000000,
   };
   base::debug::StackTrace trace(reinterpret_cast<const void* const*>(addresses),
-                                arraysize(addresses));
+                                base::size(addresses));
 
   std::string too_small = internal::FormatStackTrace(trace, 8);
   EXPECT_EQ(0u, too_small.size());
diff --git a/components/crash/core/common/crash_keys.cc b/components/crash/core/common/crash_keys.cc
index bbb0af7..0261928 100644
--- a/components/crash/core/common/crash_keys.cc
+++ b/components/crash/core/common/crash_keys.cc
@@ -10,6 +10,7 @@
 #include "base/command_line.h"
 #include "base/format_macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
@@ -130,7 +131,7 @@
 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 < arraysize(printer_info_keys); ++i) {
+  for (size_t i = 0; i < base::size(printer_info_keys); ++i) {
     if (i < info.size())
       printer_info_keys[i].Set(info[i]);
     else
diff --git a/components/cronet/stale_host_resolver_unittest.cc b/components/cronet/stale_host_resolver_unittest.cc
index 8cd15cd..556a5fb 100644
--- a/components/cronet/stale_host_resolver_unittest.cc
+++ b/components/cronet/stale_host_resolver_unittest.cc
@@ -13,6 +13,7 @@
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "base/test/test_timeouts.h"
@@ -538,7 +539,7 @@
 
   SetStaleDelay(kNoStaleDelaySec);
 
-  for (size_t i = 0; i < arraysize(kUsabilityTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kUsabilityTestCases); ++i) {
     const auto& test_case = kUsabilityTestCases[i];
 
     SetStaleUsability(test_case.max_expired_time_sec, test_case.max_stale_uses,
diff --git a/components/crx_file/crx_creator.cc b/components/crx_file/crx_creator.cc
index 63e2904..8ec6bb3 100644
--- a/components/crx_file/crx_creator.cc
+++ b/components/crx_file/crx_creator.cc
@@ -6,6 +6,7 @@
 
 #include "base/files/file.h"
 #include "base/files/file_path.h"
+#include "base/stl_util.h"
 #include "components/crx_file/crx3.pb.h"
 #include "components/crx_file/crx_file.h"
 #include "crypto/rsa_private_key.h"
@@ -31,7 +32,7 @@
   int read = 0;
   static_assert(sizeof(char) == sizeof(uint8_t), "Unsupported char size.");
   while ((read = file->ReadAtCurrentPos(reinterpret_cast<char*>(buffer),
-                                        arraysize(buffer))) > 0) {
+                                        base::size(buffer))) > 0) {
     if (!signer->Update(buffer, read))
       return CreatorResult::ERROR_SIGNING_FAILURE;
   }
@@ -49,7 +50,7 @@
   char buffer[1 << 12] = {};
   int read = 0;
   in->Seek(base::File::Whence::FROM_BEGIN, 0);
-  while ((read = in->ReadAtCurrentPos(buffer, arraysize(buffer))) > 0) {
+  while ((read = in->ReadAtCurrentPos(buffer, base::size(buffer))) > 0) {
     if (out->WriteAtCurrentPos(buffer, read) != read)
       return false;
   }
@@ -80,9 +81,9 @@
   // through, run ZIP through.
   auto signer = crypto::SignatureCreator::Create(
       signing_key, crypto::SignatureCreator::HashAlgorithm::SHA256);
-  signer->Update(kSignatureContext, arraysize(kSignatureContext));
+  signer->Update(kSignatureContext, base::size(kSignatureContext));
   signer->Update(signed_header_size_octets,
-                 arraysize(signed_header_size_octets));
+                 base::size(signed_header_size_octets));
   signer->Update(
       reinterpret_cast<const uint8_t*>(signed_header_data_str.data()),
       signed_header_data_str.size());
@@ -115,9 +116,9 @@
   static_assert(sizeof(char) == sizeof(uint8_t), "Unsupported char size.");
   if (!WriteBuffer(&crx, kCrxFileHeaderMagic, kCrxFileHeaderMagicSize) ||
       !WriteBuffer(&crx, reinterpret_cast<const char*>(format_version_octets),
-                   arraysize(format_version_octets)) ||
+                   base::size(format_version_octets)) ||
       !WriteBuffer(&crx, reinterpret_cast<const char*>(header_size_octets),
-                   arraysize(header_size_octets)) ||
+                   base::size(header_size_octets)) ||
       !WriteBuffer(&crx, header_str.c_str(), header_str.length()) ||
       !WriteArchive(&crx, &file)) {
     return CreatorResult::ERROR_FILE_WRITE_FAILURE;
diff --git a/components/crx_file/crx_verifier.cc b/components/crx_file/crx_verifier.cc
index a342d74..7aef781 100644
--- a/components/crx_file/crx_verifier.cc
+++ b/components/crx_file/crx_verifier.cc
@@ -15,6 +15,7 @@
 #include "base/callback.h"
 #include "base/files/file.h"
 #include "base/files/file_path.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "components/crx_file/crx3.pb.h"
 #include "components/crx_file/crx_file.h"
@@ -74,7 +75,8 @@
                               const VerifierCollection& verifiers) {
   uint8_t buffer[1 << 12] = {};
   size_t len = 0;
-  while ((len = ReadAndHashBuffer(buffer, arraysize(buffer), file, hash)) > 0) {
+  while ((len = ReadAndHashBuffer(buffer, base::size(buffer), file, hash)) >
+         0) {
     for (auto& verifier : verifiers)
       verifier->VerifyUpdate(base::make_span(buffer, len));
   }
diff --git a/components/crx_file/id_util_unittest.cc b/components/crx_file/id_util_unittest.cc
index d7b467ad..ee31110 100644
--- a/components/crx_file/id_util_unittest.cc
+++ b/components/crx_file/id_util_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace crx_file {
@@ -30,7 +30,7 @@
       0x0f, 0x02, 0x03, 0x01, 0x00, 0x01};
   std::string extension_id =
       GenerateId(std::string(reinterpret_cast<const char*>(&public_key_info[0]),
-                             arraysize(public_key_info)));
+                             base::size(public_key_info)));
   EXPECT_EQ("melddjfinppjdikinhbgehiennejpfhp", extension_id);
 
   EXPECT_EQ("daibjpdaanagajckigeiigphanababab",
diff --git a/components/data_reduction_proxy/content/browser/content_lofi_decider_unittest.cc b/components/data_reduction_proxy/content/browser/content_lofi_decider_unittest.cc
index 4cdaea57..044de4b 100644
--- a/components/data_reduction_proxy/content/browser/content_lofi_decider_unittest.cc
+++ b/components/data_reduction_proxy/content/browser/content_lofi_decider_unittest.cc
@@ -10,8 +10,8 @@
 #include <utility>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/scoped_feature_list.h"
@@ -346,7 +346,7 @@
                {content::RESOURCE_TYPE_CSP_REPORT},
                {content::RESOURCE_TYPE_PLUGIN_RESOURCE}};
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::unique_ptr<net::URLRequest> request = CreateRequestByType(
         tests[i].resource_type, false,
         content::SERVER_LOFI_ON | content::SERVER_LITE_PAGE_ON);
@@ -375,7 +375,7 @@
       {content::PREVIEWS_OFF}, {content::SERVER_LOFI_ON},
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::unique_ptr<net::URLRequest> request =
         CreateRequest(false, tests[i].previews_state);
     net::HttpRequestHeaders headers;
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
index 89701e25..1983e3ea 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol_unittest.cc
@@ -10,7 +10,6 @@
 #include <utility>
 
 #include "base/containers/span.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/field_trial.h"
@@ -539,7 +538,7 @@
       { "POST", false },
       { "CONNECT", false },
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::unique_ptr<net::URLRequest> request(context.CreateRequest(
         GURL("http://www.google.com/"), net::DEFAULT_PRIORITY, nullptr,
         TRAFFIC_ANNOTATION_FOR_TESTS));
@@ -582,7 +581,7 @@
                              .proxy_server()
                              .host_port_pair()
                              .ToString();
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     base::HistogramTester histogram_tester;
 
     ConfigureTestDependencies(
@@ -1035,7 +1034,7 @@
                              .proxy_server()
                              .host_port_pair()
                              .ToString();
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     ConfigureTestDependencies(
         ProxyResolutionService::CreateFixedFromPacResult(
             net::ProxyServer::FromURI(primary, net::ProxyServer::SCHEME_HTTP)
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
index 20d9dbc..1f45db1 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats_unittest.cc
@@ -14,9 +14,9 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram.h"
+#include "base/stl_util.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/test/scoped_task_environment.h"
 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h"
@@ -755,7 +755,7 @@
       {true, "HTTP/1.1 404 Not Found\n", 404, -1},
       {false, "HTTP/1.1 404 Not Found\n", -1, 404}};
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     base::HistogramTester histogram_tester;
     std::string raw_headers(test_cases[i].headers);
     HeadersToRaw(&raw_headers);
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
index d2cbfc7c..f0f0995 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client_unittest.cc
@@ -12,9 +12,9 @@
 
 #include "base/base64.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/bind_test_util.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/test/mock_entropy_provider.h"
@@ -664,7 +664,7 @@
       },
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     SetDataReductionProxyEnabled(true, tests[i].secure_proxies_allowed);
     config_client()->RetrieveConfig();
 
@@ -1220,7 +1220,7 @@
       },
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     base::HistogramTester histogram_tester;
     SetDataReductionProxyEnabled(tests[i].enabled_by_user, true);
 
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
index cb7b3174..5295167 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
@@ -17,10 +17,10 @@
 #include "base/feature_list.h"
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/field_trial.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/safe_sprintf.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -657,7 +657,7 @@
                                    .host_port_pair()
                                    .ToString());
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     net::ProxyConfig::ProxyRules rules;
     std::vector<std::string> proxies;
 
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_unittest.cc
index e377775..28fb500 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_data_unittest.cc
@@ -9,6 +9,7 @@
 #include <memory>
 #include <string>
 
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "net/base/request_priority.h"
 #include "net/nqe/effective_connection_type.h"
@@ -121,7 +122,7 @@
       },
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     static const char kSessionKey[] = "test-key";
     static const GURL kTestURL("test-url");
     std::unique_ptr<DataReductionProxyData> data(new DataReductionProxyData());
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
index 9a7528f..4cfc161 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc
@@ -15,12 +15,12 @@
 
 #include "base/command_line.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/optional.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/safe_sprintf.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -913,7 +913,7 @@
   // Enable Lo-Fi.
   bool is_data_reduction_proxy_enabled[] = {false, true};
 
-  for (size_t i = 0; i < arraysize(is_data_reduction_proxy_enabled); ++i) {
+  for (size_t i = 0; i < base::size(is_data_reduction_proxy_enabled); ++i) {
     net::ProxyInfo data_reduction_proxy_info;
     std::string proxy;
     if (is_data_reduction_proxy_enabled[i]) {
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_util.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_util.cc
index 6c5d235..4bf28f7 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_util.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_util.cc
@@ -6,6 +6,7 @@
 
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/time/time.h"
 #include "base/version.h"
@@ -97,10 +98,10 @@
   // properly formed, e.g. the version string is at least as long as "0.0.0.0",
   // and starts and ends with numeric digits. This is to prevent another
   // regression like http://crbug.com/595471.
-  static_assert(arraysize(PRODUCT_VERSION) >= arraysize("0.0.0.0") &&
+  static_assert(base::size(PRODUCT_VERSION) >= base::size("0.0.0.0") &&
                     '0' <= PRODUCT_VERSION[0] && PRODUCT_VERSION[0] <= '9' &&
-                    '0' <= PRODUCT_VERSION[arraysize(PRODUCT_VERSION) - 2] &&
-                    PRODUCT_VERSION[arraysize(PRODUCT_VERSION) - 2] <= '9',
+                    '0' <= PRODUCT_VERSION[base::size(PRODUCT_VERSION) - 2] &&
+                    PRODUCT_VERSION[base::size(PRODUCT_VERSION) - 2] <= '9',
                 "PRODUCT_VERSION must be a string of the form "
                 "'MAJOR.MINOR.BUILD.PATCH', e.g. '1.2.3.4'. "
                 "PRODUCT_VERSION='" PRODUCT_VERSION "' is badly formed.");
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc
index 0446d92..fdac908 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers.cc
@@ -13,6 +13,7 @@
 
 #include "base/metrics/field_trial_params.h"
 #include "base/rand_util.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"
@@ -125,7 +126,7 @@
 
     // Check policy directive for empty-image entry.
     base::StringPiece page_policies_value = base::StringPiece(directive).substr(
-        arraysize(kChromeProxyPagePoliciesDirective));
+        base::size(kChromeProxyPagePoliciesDirective));
     for (const auto& policy :
          base::SplitStringPiece(page_policies_value, "|", base::TRIM_WHITESPACE,
                                 base::SPLIT_WANT_NONEMPTY)) {
@@ -356,7 +357,7 @@
   // 'Via: 1.1 Chrome-Compression-Proxy'
   while (headers.EnumerateHeader(&iter, "via", &value)) {
     if (base::StringPiece(value).substr(
-            kVersionSize, arraysize(kDataReductionProxyViaValue) - 1) ==
+            kVersionSize, base::size(kDataReductionProxyViaValue) - 1) ==
         kDataReductionProxyViaValue) {
       if (has_intermediary)
         // We assume intermediary exists if there is another Via header after
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc
index 521bab2..5d05820 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_headers_unittest.cc
@@ -10,8 +10,8 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/scoped_feature_list.h"
 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h"
@@ -63,7 +63,7 @@
           false,
       },
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::string headers(tests[i].headers);
     HeadersToRaw(&headers);
     scoped_refptr<net::HttpResponseHeaders> parsed(
@@ -132,7 +132,7 @@
           false,
       },
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::string headers(tests[i].headers);
     HeadersToRaw(&headers);
     scoped_refptr<net::HttpResponseHeaders> parsed(
@@ -219,7 +219,7 @@
       "",
     },
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::string headers(tests[i].headers);
     HeadersToRaw(&headers);
     scoped_refptr<net::HttpResponseHeaders> parsed(
@@ -469,7 +469,7 @@
       false,
     },
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::string headers(tests[i].headers);
     HeadersToRaw(&headers);
     scoped_refptr<net::HttpResponseHeaders> parsed(
@@ -580,7 +580,7 @@
       false,
     },
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::string headers(tests[i].headers);
     HeadersToRaw(&headers);
     scoped_refptr<net::HttpResponseHeaders> parsed(
@@ -774,7 +774,7 @@
                    "Via: 1.1 Chrome-Compression-Proxy\n",
                    BYPASS_EVENT_TYPE_MAX,
                }};
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::string headers(tests[i].headers);
     HeadersToRaw(&headers);
     scoped_refptr<net::HttpResponseHeaders> parsed(
diff --git a/components/discardable_memory/common/discardable_shared_memory_heap.cc b/components/discardable_memory/common/discardable_shared_memory_heap.cc
index d750db40..e9e030b 100644
--- a/components/discardable_memory/common/discardable_shared_memory_heap.cc
+++ b/components/discardable_memory/common/discardable_shared_memory_heap.cc
@@ -9,9 +9,9 @@
 #include <utility>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/memory/discardable_shared_memory.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/memory_dump_manager.h"
 
@@ -102,7 +102,7 @@
   memory_segments_.clear();
   DCHECK_EQ(num_blocks_, 0u);
   DCHECK_EQ(num_free_blocks_, 0u);
-  DCHECK_EQ(std::count_if(free_spans_, free_spans_ + arraysize(free_spans_),
+  DCHECK_EQ(std::count_if(free_spans_, free_spans_ + base::size(free_spans_),
                           [](const base::LinkedList<Span>& free_spans) {
                             return !free_spans.empty();
                           }),
@@ -196,7 +196,7 @@
   size_t max_length = blocks + slack;
 
   // Search array of free lists for a suitable span.
-  while (length - 1 < arraysize(free_spans_) - 1) {
+  while (length - 1 < base::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.
@@ -209,7 +209,7 @@
   }
 
   const base::LinkedList<Span>& overflow_free_spans =
-      free_spans_[arraysize(free_spans_) - 1];
+      free_spans_[base::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.
@@ -265,7 +265,7 @@
 void DiscardableSharedMemoryHeap::InsertIntoFreeList(
     std::unique_ptr<DiscardableSharedMemoryHeap::Span> span) {
   DCHECK(!IsInFreeList(span.get()));
-  size_t index = std::min(span->length_, arraysize(free_spans_)) - 1;
+  size_t index = std::min(span->length_, base::size(free_spans_)) - 1;
   free_spans_[index].Append(span.release());
 }
 
diff --git a/components/dom_distiller/content/renderer/distillability_agent.cc b/components/dom_distiller/content/renderer/distillability_agent.cc
index c34f9bb..2a5b68b 100644
--- a/components/dom_distiller/content/renderer/distillability_agent.cc
+++ b/components/dom_distiller/content/renderer/distillability_agent.cc
@@ -5,6 +5,7 @@
 #include "components/dom_distiller/content/renderer/distillability_agent.h"
 
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "components/dom_distiller/content/common/distillability_service.mojom.h"
 #include "components/dom_distiller/core/distillable_page_detector.h"
@@ -66,7 +67,7 @@
 }
 
 bool IsBlacklisted(const GURL& url) {
-  for (size_t i = 0; i < arraysize(kBlacklist); ++i) {
+  for (size_t i = 0; i < base::size(kBlacklist); ++i) {
     if (base::LowerCaseEqualsASCII(url.host(), kBlacklist[i])) {
       return true;
     }
diff --git a/components/domain_reliability/google_configs.cc b/components/domain_reliability/google_configs.cc
index 31ad3f1..9357e3c 100644
--- a/components/domain_reliability/google_configs.cc
+++ b/components/domain_reliability/google_configs.cc
@@ -8,7 +8,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/domain_reliability/config.h"
 
 namespace domain_reliability {
@@ -561,7 +561,7 @@
     config->collectors.push_back(
         std::make_unique<GURL>(config->origin.ReplaceComponents(replacements)));
   }
-  for (size_t i = 0; i < arraysize(kGoogleStandardCollectors); i++)
+  for (size_t i = 0; i < base::size(kGoogleStandardCollectors); i++)
     config->collectors.push_back(
         std::make_unique<GURL>(kGoogleStandardCollectors[i]));
   config->success_sample_rate = 0.05;
diff --git a/components/domain_reliability/quic_error_mapping.cc b/components/domain_reliability/quic_error_mapping.cc
index 80fface..564b3a6 100644
--- a/components/domain_reliability/quic_error_mapping.cc
+++ b/components/domain_reliability/quic_error_mapping.cc
@@ -4,6 +4,8 @@
 
 #include "components/domain_reliability/quic_error_mapping.h"
 
+#include "base/stl_util.h"
+
 namespace domain_reliability {
 
 namespace {
@@ -311,7 +313,7 @@
 const int kActiveQuicErrorCount =
     quic::QUIC_LAST_ERROR - kDeprecatedQuicErrorCount;
 
-static_assert(arraysize(kQuicErrorMap) == kActiveQuicErrorCount,
+static_assert(base::size(kQuicErrorMap) == kActiveQuicErrorCount,
               "quic_error_map is not in sync with quic protocol!");
 
 }  // namespace
@@ -322,7 +324,7 @@
   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 < arraysize(kQuicErrorMap); i++) {
+    for (size_t i = 0; i < base::size(kQuicErrorMap); i++) {
       if (kQuicErrorMap[i].quic_error == quic_error) {
         *beacon_quic_error_out = kQuicErrorMap[i].beacon_quic_error;
         return true;
diff --git a/components/domain_reliability/util.cc b/components/domain_reliability/util.cc
index ece9219..91d1b42 100644
--- a/components/domain_reliability/util.cc
+++ b/components/domain_reliability/util.cc
@@ -8,8 +8,8 @@
 
 #include "base/callback.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "base/timer/timer.h"
 #include "net/base/net_errors.h"
@@ -91,7 +91,7 @@
   }
 
   // TODO(juliatuttle): Consider sorting and using binary search?
-  for (size_t i = 0; i < arraysize(net_error_map); i++) {
+  for (size_t i = 0; i < base::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;
diff --git a/components/download/internal/common/base_file_unittest.cc b/components/download/internal/common/base_file_unittest.cc
index ea64590..f86edf1b 100644
--- a/components/download/internal/common/base_file_unittest.cc
+++ b/components/download/internal/common/base_file_unittest.cc
@@ -12,7 +12,7 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/test_file_util.h"
 #include "build/build_config.h"
@@ -29,10 +29,10 @@
 const char kTestData2[] = "Writing more data.\n";
 const char kTestData3[] = "Final line.";
 const char kTestData4[] = "supercalifragilisticexpialidocious";
-const int kTestDataLength1 = arraysize(kTestData1) - 1;
-const int kTestDataLength2 = arraysize(kTestData2) - 1;
-const int kTestDataLength3 = arraysize(kTestData3) - 1;
-const int kTestDataLength4 = arraysize(kTestData4) - 1;
+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;
 int64_t kTestDataBytesWasted = 0;
 
 // SHA-256 hash of kTestData1 (excluding terminating NUL).
@@ -730,7 +730,7 @@
   ASSERT_FALSE(base::PathExists(full_path));
 
   const char kData[] = "hello";
-  const int kDataLength = static_cast<int>(arraysize(kData) - 1);
+  const int kDataLength = static_cast<int>(base::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.
diff --git a/components/download/internal/common/download_stats.cc b/components/download/internal/common/download_stats.cc
index 2848008..11ac2934 100644
--- a/components/download/internal/common/download_stats.cc
+++ b/components/download/internal/common/download_stats.cc
@@ -8,9 +8,9 @@
 
 #include "base/callback.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "components/download/public/common/download_interrupt_reasons.h"
 #include "net/http/http_content_disposition.h"
@@ -418,7 +418,7 @@
 
 // Maps extensions to their matching UMA histogram int value.
 int GetDangerousFileType(const base::FilePath& file_path) {
-  for (size_t i = 0; i < arraysize(kDangerousFileTypes); ++i) {
+  for (size_t i = 0; i < base::size(kDangerousFileTypes); ++i) {
     if (file_path.MatchesExtension(kDangerousFileTypes[i]))
       return i + 1;
   }
diff --git a/components/download/quarantine/quarantine_unittest.cc b/components/download/quarantine/quarantine_unittest.cc
index 0c73c497..a70fd27e 100644
--- a/components/download/quarantine/quarantine_unittest.cc
+++ b/components/download/quarantine/quarantine_unittest.cc
@@ -10,7 +10,7 @@
 #include "base/files/file.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
 
@@ -30,8 +30,8 @@
   ASSERT_TRUE(test_dir.CreateUniqueTempDir());
 
   base::FilePath test_file = test_dir.GetPath().AppendASCII("foo.class");
-  ASSERT_EQ(static_cast<int>(arraysize(kTestData)),
-            base::WriteFile(test_file, kTestData, arraysize(kTestData)));
+  ASSERT_EQ(static_cast<int>(base::size(kTestData)),
+            base::WriteFile(test_file, kTestData, base::size(kTestData)));
 
   EXPECT_EQ(QuarantineFileResult::OK,
             QuarantineFile(test_file, GURL(kInternetURL),
@@ -47,8 +47,8 @@
   ASSERT_TRUE(test_dir.CreateUniqueTempDir());
 
   base::FilePath test_file = test_dir.GetPath().AppendASCII("foo.class");
-  ASSERT_EQ(static_cast<int>(arraysize(kTestData)),
-            base::WriteFile(test_file, kTestData, arraysize(kTestData)));
+  ASSERT_EQ(static_cast<int>(base::size(kTestData)),
+            base::WriteFile(test_file, kTestData, base::size(kTestData)));
 
   EXPECT_EQ(QuarantineFileResult::OK,
             QuarantineFile(test_file, GURL(kInternetURL),
diff --git a/components/drive/change_list_processor_unittest.cc b/components/drive/change_list_processor_unittest.cc
index 02feb01..2730770 100644
--- a/components/drive/change_list_processor_unittest.cc
+++ b/components/drive/change_list_processor_unittest.cc
@@ -11,8 +11,8 @@
 
 #include "base/command_line.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
 #include "components/drive/chromeos/drive_test_util.h"
@@ -205,7 +205,7 @@
            "", FILE},
   };
 
-  for (size_t i = 0; i < arraysize(kExpected); ++i) {
+  for (size_t i = 0; i < base::size(kExpected); ++i) {
     std::unique_ptr<ResourceEntry> entry = GetResourceEntry(kExpected[i].path);
     ASSERT_TRUE(entry) << "for path: " << kExpected[i].path;
     EXPECT_EQ(kExpected[i].id, entry->resource_id());
diff --git a/components/drive/drive_api_util.cc b/components/drive/drive_api_util.cc
index 6848f9da..7de3d7e4 100644
--- a/components/drive/drive_api_util.cc
+++ b/components/drive/drive_api_util.cc
@@ -11,8 +11,8 @@
 
 #include "base/files/file.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/md5.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -174,7 +174,7 @@
 }
 
 std::string GetHostedDocumentExtension(const std::string& mime_type) {
-  for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) {
+  for (size_t i = 0; i < base::size(kHostedDocumentKinds); ++i) {
     if (mime_type == kHostedDocumentKinds[i].mime_type)
       return kHostedDocumentKinds[i].extension;
   }
@@ -182,7 +182,7 @@
 }
 
 bool IsKnownHostedDocumentMimeType(const std::string& mime_type) {
-  for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) {
+  for (size_t i = 0; i < base::size(kHostedDocumentKinds); ++i) {
     if (mime_type == kHostedDocumentKinds[i].mime_type)
       return true;
   }
@@ -191,7 +191,7 @@
 
 bool HasHostedDocumentExtension(const base::FilePath& path) {
   const std::string extension = base::FilePath(path.Extension()).AsUTF8Unsafe();
-  for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) {
+  for (size_t i = 0; i < base::size(kHostedDocumentKinds); ++i) {
     if (extension == kHostedDocumentKinds[i].extension)
       return true;
   }
diff --git a/components/drive/file_write_watcher_unittest.cc b/components/drive/file_write_watcher_unittest.cc
index a3ddbf5..c59fbd5 100644
--- a/components/drive/file_write_watcher_unittest.cc
+++ b/components/drive/file_write_watcher_unittest.cc
@@ -9,8 +9,8 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/test/test_browser_thread_bundle.h"
@@ -50,8 +50,8 @@
   EXPECT_TRUE(watch_success) << path.value();
 
   const char kDummy[] = "hello";
-  ASSERT_EQ(static_cast<int>(arraysize(kDummy)),
-            base::WriteFile(path, kDummy, arraysize(kDummy)));
+  ASSERT_EQ(static_cast<int>(base::size(kDummy)),
+            base::WriteFile(path, kDummy, base::size(kDummy)));
 }
 
 class FileWriteWatcherTest : public testing::Test {
diff --git a/components/drive/resource_metadata_storage.cc b/components/drive/resource_metadata_storage.cc
index 62017e93..6f8f3bf 100644
--- a/components/drive/resource_metadata_storage.cc
+++ b/components/drive/resource_metadata_storage.cc
@@ -15,11 +15,11 @@
 #include "base/files/file_util.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/scoped_blocking_call.h"
 #include "components/drive/drive.pb.h"
 #include "components/drive/drive_api_util.h"
@@ -100,7 +100,7 @@
 bool IsCacheEntryKey(const leveldb::Slice& key) {
   // A cache entry key should end with |kDBKeyDelimeter + kCacheEntryKeySuffix|.
   const leveldb::Slice expected_suffix(kCacheEntryKeySuffix,
-                                       arraysize(kCacheEntryKeySuffix) - 1);
+                                       base::size(kCacheEntryKeySuffix) - 1);
   if (key.size() < 1 + expected_suffix.size() ||
       key[key.size() - expected_suffix.size() - 1] != kDBKeyDelimeter)
     return false;
@@ -114,7 +114,7 @@
 std::string GetIdFromCacheEntryKey(const leveldb::Slice& key) {
   DCHECK(IsCacheEntryKey(key));
   // Drop the suffix |kDBKeyDelimeter + kCacheEntryKeySuffix| from the key.
-  const size_t kSuffixLength = arraysize(kCacheEntryKeySuffix) - 1;
+  const size_t kSuffixLength = base::size(kCacheEntryKeySuffix) - 1;
   const int id_length = key.size() - 1 - kSuffixLength;
   return std::string(key.data(), id_length);
 }
@@ -134,7 +134,7 @@
   // A resource-ID-to-local-ID entry key should start with
   // |kDBKeyDelimeter + kIdEntryKeyPrefix + kDBKeyDelimeter|.
   const leveldb::Slice expected_prefix(kIdEntryKeyPrefix,
-                                       arraysize(kIdEntryKeyPrefix) - 1);
+                                       base::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 +148,7 @@
   DCHECK(IsIdEntryKey(key));
   // Drop the prefix |kDBKeyDelimeter + kIdEntryKeyPrefix + kDBKeyDelimeter|
   // from the key.
-  const size_t kPrefixLength = arraysize(kIdEntryKeyPrefix) - 1;
+  const size_t kPrefixLength = base::size(kIdEntryKeyPrefix) - 1;
   const int offset = kPrefixLength + 2;
   return std::string(key.data() + offset, key.size() - offset);
 }
diff --git a/components/drive/resource_metadata_storage_unittest.cc b/components/drive/resource_metadata_storage_unittest.cc
index e01ecf4..b3335b4 100644
--- a/components/drive/resource_metadata_storage_unittest.cc
+++ b/components/drive/resource_metadata_storage_unittest.cc
@@ -12,7 +12,6 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
 #include "base/strings/string_split.h"
@@ -226,7 +225,7 @@
 TEST_F(ResourceMetadataStorageTest, GetChildren) {
   const std::string parents_id[] = { "mercury", "venus", "mars", "jupiter",
                                      "saturn" };
-  std::vector<base::StringPairs> children_name_id(arraysize(parents_id));
+  std::vector<base::StringPairs> children_name_id(base::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"));
diff --git a/components/drive/search_metadata_unittest.cc b/components/drive/search_metadata_unittest.cc
index 79861ca..a314355 100644
--- a/components/drive/search_metadata_unittest.cc
+++ b/components/drive/search_metadata_unittest.cc
@@ -13,9 +13,9 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/i18n/string_search.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "components/drive/chromeos/drive_test_util.h"
@@ -464,7 +464,7 @@
 // "drive", "drive/root", "drive/other" should be excluded.
 TEST_F(SearchMetadataTest, SearchMetadata_ExcludeSpecialDirectories) {
   const char* const kQueries[] = { "drive", "root", "other" };
-  for (size_t i = 0; i < arraysize(kQueries); ++i) {
+  for (size_t i = 0; i < base::size(kQueries); ++i) {
     FileError error = FILE_ERROR_FAILED;
     std::unique_ptr<MetadataSearchResultVector> result;
 
diff --git a/components/error_page/common/localized_error.cc b/components/error_page/common/localized_error.cc
index fcaaed49..71ece78 100644
--- a/components/error_page/common/localized_error.cc
+++ b/components/error_page/common/localized_error.cc
@@ -12,9 +12,9 @@
 #include "base/command_line.h"
 #include "base/i18n/rtl.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -459,12 +459,11 @@
     // history to an uncached page created by a POST.
     if (is_post && error_code == net::ERR_CACHE_MISS)
       return &repost_error;
-    return FindErrorMapInArray(net_error_options,
-                               arraysize(net_error_options),
+    return FindErrorMapInArray(net_error_options, base::size(net_error_options),
                                error_code);
   } else if (error_domain == Error::kHttpErrorDomain) {
     const LocalizedErrorMap* map = FindErrorMapInArray(
-        http_error_options, arraysize(http_error_options), error_code);
+        http_error_options, base::size(http_error_options), error_code);
     // Handle miscellaneous 400/500 errors.
     return !map && error_code >= 400 && error_code < 600
                ? &generic_4xx_5xx_error
@@ -472,8 +471,7 @@
   } else if (error_domain == Error::kDnsProbeErrorDomain) {
     const LocalizedErrorMap* map =
         FindErrorMapInArray(dns_probe_error_options,
-                            arraysize(dns_probe_error_options),
-                            error_code);
+                            base::size(dns_probe_error_options), error_code);
     DCHECK(map);
     return map;
   } else {
diff --git a/components/exo/buffer.cc b/components/exo/buffer.cc
index 910ad92..c0e1767 100644
--- a/components/exo/buffer.cc
+++ b/components/exo/buffer.cc
@@ -14,8 +14,8 @@
 
 #include "base/callback_helpers.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
@@ -59,7 +59,7 @@
       GL_RGB_YCBCR_420V_CHROMIUM,          // YUV_420_BIPLANAR
       GL_RGB_YCBCR_422_CHROMIUM,           // UYVY_422
   };
-  static_assert(arraysize(kGLInternalFormats) ==
+  static_assert(base::size(kGLInternalFormats) ==
                     (static_cast<int>(gfx::BufferFormat::LAST) + 1),
                 "BufferFormat::LAST must be last value of kGLInternalFormats");
 
diff --git a/components/exo/wayland/clients/blur.cc b/components/exo/wayland/clients/blur.cc
index 46c72ce..4b37d4db 100644
--- a/components/exo/wayland/clients/blur.cc
+++ b/components/exo/wayland/clients/blur.cc
@@ -8,6 +8,7 @@
 #include <vector>
 
 #include "base/command_line.h"
+#include "base/stl_util.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"
@@ -86,7 +87,7 @@
                                  SK_ColorRED,  SK_ColorYELLOW,
                                  SK_ColorCYAN, SK_ColorMAGENTA};
       SkPaint paint;
-      paint.setColor(kColors[(y * kGridSize + x) % arraysize(kColors)]);
+      paint.setColor(kColors[(y * kGridSize + x) % base::size(kColors)]);
       canvas->save();
       canvas->translate(
           x * cell_size.width() + SkScalarHalf(cell_size.width()),
diff --git a/components/exo/wayland/clients/rects.cc b/components/exo/wayland/clients/rects.cc
index 827a95f..ad40af6 100644
--- a/components/exo/wayland/clients/rects.cc
+++ b/components/exo/wayland/clients/rects.cc
@@ -20,10 +20,10 @@
 #include "base/command_line.h"
 #include "base/containers/circular_deque.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
 #include "base/message_loop/message_loop.h"
 #include "base/scoped_generic.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
@@ -419,7 +419,7 @@
                                    SK_ColorRED,  SK_ColorYELLOW,
                                    SK_ColorCYAN, SK_ColorMAGENTA};
         SkPaint paint;
-        paint.setColor(SkColorSetA(kColors[i % arraysize(kColors)], 0xA0));
+        paint.setColor(SkColorSetA(kColors[i % base::size(kColors)], 0xA0));
         canvas->rotate(rotation / num_rects);
         canvas->drawIRect(rect, paint);
       }
diff --git a/components/exo/wayland/clients/simple.cc b/components/exo/wayland/clients/simple.cc
index 2712e35..d04bfa6 100644
--- a/components/exo/wayland/clients/simple.cc
+++ b/components/exo/wayland/clients/simple.cc
@@ -8,6 +8,7 @@
 
 #include "base/command_line.h"
 #include "base/containers/circular_deque.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "components/exo/wayland/clients/client_helper.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -104,7 +105,7 @@
     SkCanvas* canvas = buffer->sk_surface->getCanvas();
 
     static const SkColor kColors[] = {SK_ColorRED, SK_ColorBLACK};
-    canvas->clear(kColors[++frame_count % arraysize(kColors)]);
+    canvas->clear(kColors[++frame_count % base::size(kColors)]);
 
     if (gr_context_) {
       gr_context_->flush();
diff --git a/components/exo/wayland/clients/subsurface.cc b/components/exo/wayland/clients/subsurface.cc
index 6edab28..c8b7f780 100644
--- a/components/exo/wayland/clients/subsurface.cc
+++ b/components/exo/wayland/clients/subsurface.cc
@@ -5,6 +5,7 @@
 #include "base/at_exit.h"
 #include "base/command_line.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "components/exo/wayland/clients/client_base.h"
 #include "components/exo/wayland/clients/client_helper.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -110,7 +111,7 @@
       Buffer* buffer = buffers_.front().get();
       SkCanvas* canvas = buffer->sk_surface->getCanvas();
       static const SkColor kColors[] = {SK_ColorRED, SK_ColorBLACK};
-      canvas->clear(kColors[frame_count % arraysize(kColors)]);
+      canvas->clear(kColors[frame_count % base::size(kColors)]);
       if (gr_context_) {
         gr_context_->flush();
         glFinish();
diff --git a/components/exo/wayland/clients/vulkan.cc b/components/exo/wayland/clients/vulkan.cc
index f87cd98e..06d4e5f 100644
--- a/components/exo/wayland/clients/vulkan.cc
+++ b/components/exo/wayland/clients/vulkan.cc
@@ -5,6 +5,7 @@
 #include "base/at_exit.h"
 #include "base/command_line.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "components/exo/wayland/clients/client_base.h"
 #include "components/exo/wayland/clients/client_helper.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -139,7 +140,7 @@
 
       ScopedVulkanRenderFrame vulkan_frame(
           this, buffer->vk_framebuffer->get(),
-          kColors[++frame_count % arraysize(kColors)]);
+          kColors[++frame_count % base::size(kColors)]);
 
       // This is where the drawing code would go.
       // This client is not drawing anything. Just clearing the fb.
diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc
index 8111cb33..7109f51 100644
--- a/components/exo/wayland/server.cc
+++ b/components/exo/wayland/server.cc
@@ -44,10 +44,10 @@
 #include "base/cancelable_callback.h"
 #include "base/command_line.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/memory/free_deleter.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -468,12 +468,12 @@
                             uint32_t format) {
   const auto* supported_format =
       std::find_if(shm_supported_formats,
-                   shm_supported_formats + arraysize(shm_supported_formats),
+                   shm_supported_formats + base::size(shm_supported_formats),
                    [format](const shm_supported_format& supported_format) {
                      return supported_format.shm_format == format;
                    });
   if (supported_format ==
-      (shm_supported_formats + arraysize(shm_supported_formats))) {
+      (shm_supported_formats + base::size(shm_supported_formats))) {
     wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FORMAT,
                            "invalid format 0x%x", format);
     return;
diff --git a/components/favicon/core/fallback_url_util_unittest.cc b/components/favicon/core/fallback_url_util_unittest.cc
index 767972a6..dac7bde 100644
--- a/components/favicon/core/fallback_url_util_unittest.cc
+++ b/components/favicon/core/fallback_url_util_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
@@ -44,7 +44,7 @@
       {"http://xn--oogle-60a/", "X"},
       {"http://xn-oogle-60a/", "X"},
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     base::string16 expected = base::ASCIIToUTF16(test_cases[i].expected);
     GURL url(test_cases[i].url_str);
     EXPECT_EQ(expected, GetFallbackIconText(url)) << " for test_cases[" << i
diff --git a/components/favicon_base/select_favicon_frames_unittest.cc b/components/favicon_base/select_favicon_frames_unittest.cc
index f405230..955b499 100644
--- a/components/favicon_base/select_favicon_frames_unittest.cc
+++ b/components/favicon_base/select_favicon_frames_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkBitmap.h"
@@ -29,7 +29,7 @@
 
 #define SCOPED_FAVICON_SCALE_FACTOR(list)          \
   ui::test::ScopedSetSupportedScaleFactors scoped( \
-      std::vector<ui::ScaleFactor>(list, list + arraysize(list)))
+      std::vector<ui::ScaleFactor>(list, list + base::size(list)))
 
 #define SCOPED_FAVICON_SCALE_FACTOR_1X \
   SCOPED_FAVICON_SCALE_FACTOR(FaviconScaleFactor1x)
diff --git a/components/feature_engagement/public/feature_list.cc b/components/feature_engagement/public/feature_list.cc
index 9ae9e4d..0d53df5 100644
--- a/components/feature_engagement/public/feature_list.cc
+++ b/components/feature_engagement/public/feature_list.cc
@@ -4,6 +4,7 @@
 
 #include "components/feature_engagement/public/feature_list.h"
 
+#include "base/stl_util.h"
 #include "components/feature_engagement/buildflags.h"
 #include "components/feature_engagement/public/feature_constants.h"
 
@@ -59,7 +60,7 @@
 
 std::vector<const base::Feature*> GetAllFeatures() {
   return std::vector<const base::Feature*>(
-      kAllFeatures, kAllFeatures + arraysize(kAllFeatures));
+      kAllFeatures, kAllFeatures + base::size(kAllFeatures));
 }
 
 }  // namespace feature_engagement
diff --git a/components/feature_engagement/public/feature_list.h b/components/feature_engagement/public/feature_list.h
index c43440f..b444357 100644
--- a/components/feature_engagement/public/feature_list.h
+++ b/components/feature_engagement/public/feature_list.h
@@ -8,6 +8,7 @@
 #include <vector>
 
 #include "base/feature_list.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "components/feature_engagement/buildflags.h"
 #include "components/feature_engagement/public/feature_constants.h"
@@ -40,7 +41,7 @@
 #define VARIATION_ENTRY(base_feature)                                \
   {                                                                  \
     base_feature##Variation[0].param_value, base_feature##Variation, \
-        arraysize(base_feature##Variation), nullptr                  \
+        base::size(base_feature##Variation), nullptr                 \
   }
 
 // Defines a flags_ui::FeatureEntry::FeatureParam for each feature.
diff --git a/components/feedback/anonymizer_tool.cc b/components/feedback/anonymizer_tool.cc
index f9f1fd6..a891a95 100644
--- a/components/feedback/anonymizer_tool.cc
+++ b/components/feedback/anonymizer_tool.cc
@@ -7,6 +7,7 @@
 #include <memory>
 #include <utility>
 
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -229,15 +230,15 @@
                                  Arg*... match_groups) {
   re2::StringPiece* args[] = {match_groups...};
   return FindAndConsumeAndGetSkippedN(input, pattern, skipped_input, args,
-                                      arraysize(args));
+                                      base::size(args));
 }
 
 }  // namespace
 
 AnonymizerTool::AnonymizerTool()
-    : custom_patterns_with_context_(arraysize(kCustomPatternsWithContext)),
+    : custom_patterns_with_context_(base::size(kCustomPatternsWithContext)),
       custom_patterns_without_context_(
-          arraysize(kCustomPatternsWithoutContext)) {
+          base::size(kCustomPatternsWithoutContext)) {
   DETACH_FROM_SEQUENCE(sequence_checker_);
 }
 
@@ -313,12 +314,12 @@
 }
 
 std::string AnonymizerTool::AnonymizeCustomPatterns(std::string input) {
-  for (size_t i = 0; i < arraysize(kCustomPatternsWithContext); i++) {
+  for (size_t i = 0; i < base::size(kCustomPatternsWithContext); i++) {
     input =
         AnonymizeCustomPatternWithContext(input, kCustomPatternsWithContext[i],
                                           &custom_patterns_with_context_[i]);
   }
-  for (size_t i = 0; i < arraysize(kCustomPatternsWithoutContext); i++) {
+  for (size_t i = 0; i < base::size(kCustomPatternsWithoutContext); i++) {
     input = AnonymizeCustomPatternWithoutContext(
         input, kCustomPatternsWithoutContext[i],
         &custom_patterns_without_context_[i]);
diff --git a/components/feedback/anonymizer_tool_unittest.cc b/components/feedback/anonymizer_tool_unittest.cc
index ef800ba..a77b967 100644
--- a/components/feedback/anonymizer_tool_unittest.cc
+++ b/components/feedback/anonymizer_tool_unittest.cc
@@ -6,6 +6,7 @@
 
 #include <gtest/gtest.h>
 
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 
 namespace feedback {
@@ -155,7 +156,7 @@
     "rtsp://root@example.com/",
     "https://aaaaaaaaaaaaaaaa.com",
   };
-  for (size_t i = 0; i < arraysize(kURLs); ++i) {
+  for (size_t i = 0; i < base::size(kURLs); ++i) {
     SCOPED_TRACE(kURLs[i]);
     std::string got = AnonymizeCustomPatterns(kURLs[i]);
     EXPECT_TRUE(
diff --git a/components/filename_generation/filename_generation_unittest.cc b/components/filename_generation/filename_generation_unittest.cc
index e4db3d12..5b47d02 100644
--- a/components/filename_generation/filename_generation_unittest.cc
+++ b/components/filename_generation/filename_generation_unittest.cc
@@ -7,6 +7,7 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -62,7 +63,7 @@
 #define MAYBE_TestEnsureHtmlExtension TestEnsureHtmlExtension
 #endif
 TEST(FilenameGenerationTest, MAYBE_TestEnsureHtmlExtension) {
-  for (size_t i = 0; i < arraysize(kExtensionTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kExtensionTestCases); ++i) {
     base::FilePath original = base::FilePath(kExtensionTestCases[i].page_title);
     base::FilePath expected =
         base::FilePath(kExtensionTestCases[i].expected_name);
@@ -109,7 +110,7 @@
     {FPL("filename.abc"), FPL("filename.abc"), "unknown/unknown"},
     {FPL("filename"), FPL("filename"), "unknown/unknown"},
   };
-  for (uint32_t i = 0; i < arraysize(kExtensionTests); ++i) {
+  for (uint32_t i = 0; i < base::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);
@@ -169,7 +170,7 @@
 #define MAYBE_TestGenerateFilename TestGenerateFilename
 #endif
 TEST(FilenameGenerationTest, MAYBE_TestGenerateFilename) {
-  for (size_t i = 0; i < arraysize(kGenerateFilenameCases); ++i) {
+  for (size_t i = 0; i < base::size(kGenerateFilenameCases); ++i) {
     base::FilePath save_name = GenerateFilename(
         kGenerateFilenameCases[i].page_title,
         GURL(kGenerateFilenameCases[i].page_url),
diff --git a/components/flags_ui/feature_entry_macros.h b/components/flags_ui/feature_entry_macros.h
index 3d52071..02bceb73 100644
--- a/components/flags_ui/feature_entry_macros.h
+++ b/components/flags_ui/feature_entry_macros.h
@@ -5,7 +5,7 @@
 #ifndef COMPONENTS_FLAGS_UI_FEATURE_ENTRY_MACROS_H_
 #define COMPONENTS_FLAGS_UI_FEATURE_ENTRY_MACROS_H_
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 // Macros to simplify specifying the type of FeatureEntry. Please refer to
 // the comments on FeatureEntry::Type in feature_entry.h, which explain the
@@ -31,14 +31,14 @@
   ENABLE_DISABLE_VALUE_TYPE_AND_VALUE(enable_switch, "", disable_switch, "")
 #define MULTI_VALUE_TYPE(choices)                                          \
   flags_ui::FeatureEntry::MULTI_VALUE, nullptr, nullptr, nullptr, nullptr, \
-      nullptr, arraysize(choices), choices, nullptr, nullptr
+      nullptr, base::size(choices), choices, nullptr, nullptr
 #define FEATURE_VALUE_TYPE(feature)                                          \
   flags_ui::FeatureEntry::FEATURE_VALUE, nullptr, nullptr, nullptr, nullptr, \
       &feature, 3, nullptr, nullptr, nullptr
-#define FEATURE_WITH_PARAMS_VALUE_TYPE(feature, feature_variations,           \
-                                       feature_trial)                         \
-  flags_ui::FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr,        \
-      nullptr, nullptr, &feature, 3 + arraysize(feature_variations), nullptr, \
+#define FEATURE_WITH_PARAMS_VALUE_TYPE(feature, feature_variations,            \
+                                       feature_trial)                          \
+  flags_ui::FeatureEntry::FEATURE_WITH_PARAMS_VALUE, nullptr, nullptr,         \
+      nullptr, nullptr, &feature, 3 + base::size(feature_variations), nullptr, \
       feature_variations, feature_trial
 
 #endif  // COMPONENTS_FLAGS_UI_FEATURE_ENTRY_MACROS_H_
diff --git a/components/flags_ui/flags_state.cc b/components/flags_ui/flags_state.cc
index fa27d5a5..6114397 100644
--- a/components/flags_ui/flags_state.cc
+++ b/components/flags_ui/flags_state.cc
@@ -12,7 +12,6 @@
 #include "base/containers/span.h"
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/stl_util.h"
 #include "base/strings/string_piece.h"
@@ -108,7 +107,7 @@
 // Adds a |StringValue| to |list| for each platform where |bitmask| indicates
 // whether the entry is available on that platform.
 void AddOsStrings(unsigned bitmask, base::ListValue* list) {
-  for (size_t i = 0; i < arraysize(kBitsToOs); ++i) {
+  for (size_t i = 0; i < base::size(kBitsToOs); ++i) {
     if (bitmask & kBitsToOs[i].bit)
       list->AppendString(kBitsToOs[i].name);
   }
diff --git a/components/flags_ui/flags_state_unittest.cc b/components/flags_ui/flags_state_unittest.cc
index 17a8a9e..b278bc6d 100644
--- a/components/flags_ui/flags_state_unittest.cc
+++ b/components/flags_ui/flags_state_unittest.cc
@@ -14,7 +14,6 @@
 #include "base/bind.h"
 #include "base/feature_list.h"
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
@@ -123,7 +122,7 @@
     {kFlags4, kDummyName, kDummyDescription,
      0,  // Ends up being mapped to the current platform.
      FeatureEntry::MULTI_VALUE, "", "", "", "", nullptr,
-     arraysize(kMultiChoices), kMultiChoices, nullptr, nullptr},
+     base::size(kMultiChoices), kMultiChoices, nullptr, nullptr},
     {kFlags5, kDummyName, kDummyDescription,
      0,  // Ends up being mapped to the current platform.
      FeatureEntry::ENABLE_DISABLE_VALUE, kSwitch1, kEnableDisableValue1,
@@ -157,14 +156,14 @@
   FlagsStateTest() : flags_storage_(&prefs_), trial_list_(nullptr) {
     prefs_.registry()->RegisterListPref(prefs::kEnabledLabsExperiments);
 
-    for (size_t i = 0; i < arraysize(kEntries); ++i)
+    for (size_t i = 0; i < base::size(kEntries); ++i)
       kEntries[i].supported_platforms = FlagsState::GetCurrentPlatform();
 
     int os_other_than_current = 1;
     while (os_other_than_current == FlagsState::GetCurrentPlatform())
       os_other_than_current <<= 1;
     kEntries[2].supported_platforms = os_other_than_current;
-    flags_state_.reset(new FlagsState(kEntries, arraysize(kEntries)));
+    flags_state_.reset(new FlagsState(kEntries, base::size(kEntries)));
   }
 
   ~FlagsStateTest() override {
@@ -558,7 +557,7 @@
       {2, "A,B", "C", "A,B", "C,FeatureName1"},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::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
@@ -853,7 +852,7 @@
       {2, nullptr, "Foo,Bar", "", "Foo,Bar,FeatureName1"},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::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
@@ -895,7 +894,7 @@
   // All |kEntries| except for |kFlags3| should be supported.
   EXPECT_EQ(10u, supported_entries.GetSize());
   EXPECT_EQ(1u, unsupported_entries.GetSize());
-  EXPECT_EQ(arraysize(kEntries),
+  EXPECT_EQ(base::size(kEntries),
             supported_entries.GetSize() + unsupported_entries.GetSize());
 }
 
diff --git a/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc b/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc
index 021a079..62517a9d 100644
--- a/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc
+++ b/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -43,7 +43,7 @@
     { "keyid=foo;someothervalue=1;rs=42", "foo", "", 42 },
   };
 
-  for (size_t i = 0; i < arraysize(expected_results); i++) {
+  for (size_t i = 0; i < base::size(expected_results); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_results[i].header);
@@ -85,7 +85,7 @@
         { "", "sixteencoolbytes", kDefaultRecordSize } } },
   };
 
-  for (size_t i = 0; i < arraysize(expected_results); i++) {
+  for (size_t i = 0; i < base::size(expected_results); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_results[i].header);
@@ -146,7 +146,7 @@
     "rs=2,rs=0",
   };
 
-  for (size_t i = 0; i < arraysize(expected_failures); i++) {
+  for (size_t i = 0; i < base::size(expected_failures); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_failures[i]);
@@ -155,7 +155,7 @@
     EXPECT_FALSE(iterator.GetNext());
   }
 
-  for (size_t i = 0; i < arraysize(expected_failures_second_iter); i++) {
+  for (size_t i = 0; i < base::size(expected_failures_second_iter); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_failures_second_iter[i]);
@@ -190,7 +190,7 @@
       "foo", "twelvecoolbytes", "" },
   };
 
-  for (size_t i = 0; i < arraysize(expected_results); i++) {
+  for (size_t i = 0; i < base::size(expected_results); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_results[i].header);
@@ -232,7 +232,7 @@
         { "", "sixteencoolbytes", "" } } },
   };
 
-  for (size_t i = 0; i < arraysize(expected_results); i++) {
+  for (size_t i = 0; i < base::size(expected_results); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_results[i].header);
@@ -284,7 +284,7 @@
     "dh=dHdlbHZlY29vbGJ5dGVz,aesgcm128=123$xyz",
   };
 
-  for (size_t i = 0; i < arraysize(expected_failures); i++) {
+  for (size_t i = 0; i < base::size(expected_failures); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_failures[i]);
@@ -293,7 +293,7 @@
     EXPECT_FALSE(iterator.GetNext());
   }
 
-  for (size_t i = 0; i < arraysize(expected_failures_second_iter); i++) {
+  for (size_t i = 0; i < base::size(expected_failures_second_iter); i++) {
     SCOPED_TRACE(i);
 
     std::string header(expected_failures_second_iter[i]);
diff --git a/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc b/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc
index d9d85d3..17f354cd 100644
--- a/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc
+++ b/components/gcm_driver/crypto/gcm_message_cryptographer_unittest.cc
@@ -8,13 +8,14 @@
 
 #include "base/base64url.h"
 #include "base/big_endian.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "components/gcm_driver/crypto/message_payload_parser.h"
 #include "components/gcm_driver/crypto/p256_key_util.h"
+#include "crypto/ec_private_key.h"
 #include "crypto/random.h"
 #include "testing/gtest/include/gtest/gtest.h"
-#include "crypto/ec_private_key.h"
 
 namespace gcm {
 
@@ -37,7 +38,7 @@
     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(arraysize(kCommonSenderPublicKey) == 65,
+static_assert(base::size(kCommonSenderPublicKey) == 65,
               "Raw P-256 public keys must be 65 bytes in size.");
 
 const unsigned char kCommonRecipientPublicKey[] = {
@@ -47,7 +48,7 @@
     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(arraysize(kCommonRecipientPublicKey) == 65,
+static_assert(base::size(kCommonRecipientPublicKey) == 65,
               "Raw P-256 public keys must be 65 bytes in size.");
 
 const unsigned char kCommonRecipientPrivateKey[] = {
@@ -67,7 +68,7 @@
 const unsigned char kCommonAuthSecret[] = {0x25, 0xF2, 0xC2, 0xB8, 0x19, 0xD8,
                                            0xFD, 0x35, 0x97, 0xDF, 0xFB, 0x5E,
                                            0xF6, 0x0B, 0xD7, 0xA4};
-static_assert(arraysize(kCommonAuthSecret) == 16,
+static_assert(base::size(kCommonAuthSecret) == 16,
               "Auth secrets must be 16 bytes in size.");
 
 // Test vectors containing reference input for draft-ietf-webpush-encryption
@@ -276,14 +277,14 @@
   void SetUp() override {
     recipient_public_key_.assign(
         kCommonRecipientPublicKey,
-        kCommonRecipientPublicKey + arraysize(kCommonRecipientPublicKey));
+        kCommonRecipientPublicKey + base::size(kCommonRecipientPublicKey));
     sender_public_key_.assign(
         kCommonSenderPublicKey,
-        kCommonSenderPublicKey + arraysize(kCommonSenderPublicKey));
+        kCommonSenderPublicKey + base::size(kCommonSenderPublicKey));
 
     std::string recipient_private_key(
         kCommonRecipientPrivateKey,
-        kCommonRecipientPrivateKey + arraysize(kCommonRecipientPrivateKey));
+        kCommonRecipientPrivateKey + base::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 =
@@ -293,7 +294,7 @@
         *recipient_key, sender_public_key_, &ecdh_shared_secret_));
 
     auth_secret_.assign(kCommonAuthSecret,
-                        kCommonAuthSecret + arraysize(kCommonAuthSecret));
+                        kCommonAuthSecret + base::size(kCommonAuthSecret));
   }
 
  protected:
@@ -581,7 +582,7 @@
   std::string ecdh_shared_secret, auth_secret, salt, ciphertext, output;
   size_t record_size = 0;
 
-  for (size_t i = 0; i < arraysize(kEncryptionTestVectorsDraft03); ++i) {
+  for (size_t i = 0; i < base::size(kEncryptionTestVectorsDraft03); ++i) {
     SCOPED_TRACE(i);
 
     ecdh_shared_secret.assign(
@@ -614,7 +615,7 @@
       GCMMessageCryptographer::Version::DRAFT_03);
 
   std::string input, ecdh_shared_secret, auth_secret, salt, plaintext;
-  for (size_t i = 0; i < arraysize(kDecryptionTestVectorsDraft03); ++i) {
+  for (size_t i = 0; i < base::size(kDecryptionTestVectorsDraft03); ++i) {
     SCOPED_TRACE(i);
 
     ASSERT_TRUE(base::Base64UrlDecode(
@@ -656,7 +657,7 @@
   std::string ecdh_shared_secret, auth_secret, salt, ciphertext, output;
   size_t record_size = 0;
 
-  for (size_t i = 0; i < arraysize(kEncryptionTestVectorsDraft08); ++i) {
+  for (size_t i = 0; i < base::size(kEncryptionTestVectorsDraft08); ++i) {
     SCOPED_TRACE(i);
 
     ecdh_shared_secret.assign(
@@ -690,7 +691,7 @@
 
   std::string input, ecdh_shared_secret, auth_secret, salt, plaintext;
 
-  for (size_t i = 0; i < arraysize(kDecryptionTestVectorsDraft08); ++i) {
+  for (size_t i = 0; i < base::size(kDecryptionTestVectorsDraft08); ++i) {
     SCOPED_TRACE(i);
 
     ASSERT_TRUE(base::Base64UrlDecode(
diff --git a/components/gcm_driver/crypto/message_payload_parser_unittest.cc b/components/gcm_driver/crypto/message_payload_parser_unittest.cc
index 0d0f4468..9394071 100644
--- a/components/gcm_driver/crypto/message_payload_parser_unittest.cc
+++ b/components/gcm_driver/crypto/message_payload_parser_unittest.cc
@@ -5,6 +5,7 @@
 #include "components/gcm_driver/crypto/message_payload_parser.h"
 
 #include "base/big_endian.h"
+#include "base/stl_util.h"
 #include "components/gcm_driver/crypto/gcm_decryption_result.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -35,13 +36,13 @@
     0x3F, 0xD8, 0x95, 0x2C, 0xA2, 0x11, 0xBD, 0x7B, 0x57, 0xB2, 0x00, 0xBD,
     0x57, 0x68, 0x3F, 0xF0, 0x14, 0x57};
 
-static_assert(arraysize(kValidMessage) == 104,
+static_assert(base::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),
-                     arraysize(kValidMessage));
+                     base::size(kValidMessage));
 }
 
 TEST(MessagePayloadParserTest, ValidMessage) {
@@ -72,7 +73,7 @@
 
 TEST(MessagePayloadParserTest, MinimumMessageSize) {
   std::string message = CreateMessageString();
-  message.resize(arraysize(kValidMessage) / 2);
+  message.resize(base::size(kValidMessage) / 2);
 
   MessagePayloadParser parser(message);
   EXPECT_FALSE(parser.IsValid());
diff --git a/components/history/content/browser/content_history_backend_db_unittest.cc b/components/history/content/browser/content_history_backend_db_unittest.cc
index d189ba0..59c6a028 100644
--- a/components/history/content/browser/content_history_backend_db_unittest.cc
+++ b/components/history/content/browser/content_history_backend_db_unittest.cc
@@ -21,7 +21,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/history/core/test/history_backend_db_base_test.h"
 
 namespace history {
@@ -89,11 +89,11 @@
        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 < arraysize(current_reasons); i++) {
+  for (size_t i = 0; i < base::size(current_reasons); i++) {
     const InterruptReasonAssociation& cur_reason(current_reasons[i]);
     bool found = false;
 
-    for (size_t j = 0; j < arraysize(historical_reasons); ++j) {
+    for (size_t j = 0; j < base::size(historical_reasons); ++j) {
       const InterruptReasonAssociation& hist_reason(historical_reasons[j]);
 
       if (hist_reason.value == cur_reason.value) {
diff --git a/components/history/core/browser/android/android_history_types.cc b/components/history/core/browser/android/android_history_types.cc
index 4f30446..36d44f7 100644
--- a/components/history/core/browser/android/android_history_types.cc
+++ b/components/history/core/browser/android/android_history_types.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "sql/statement.h"
 
 namespace history {
@@ -37,9 +37,9 @@
  public:
   BookmarkIDMapping() {
     static_assert(
-        arraysize(kAndroidBookmarkColumn) <= HistoryAndBookmarkRow::COLUMN_END,
+        base::size(kAndroidBookmarkColumn) <= HistoryAndBookmarkRow::COLUMN_END,
         "kAndroidBookmarkColumn should not have more than COLUMN_END elements");
-    for (size_t i = 0; i < arraysize(kAndroidBookmarkColumn); ++i) {
+    for (size_t i = 0; i < base::size(kAndroidBookmarkColumn); ++i) {
       (*this)[kAndroidBookmarkColumn[i]] =
           static_cast<HistoryAndBookmarkRow::ColumnID>(i);
     }
@@ -53,10 +53,10 @@
 class SearchIDMapping : public std::map<std::string, SearchRow::ColumnID> {
  public:
   SearchIDMapping() {
-    static_assert(arraysize(kAndroidSearchColumn) <= SearchRow::COLUMN_END,
+    static_assert(base::size(kAndroidSearchColumn) <= SearchRow::COLUMN_END,
                   "kAndroidSearchColumn should not have more than "
                   "COLUMN_END elements");
-    for (size_t i = 0; i < arraysize(kAndroidSearchColumn); ++i) {
+    for (size_t i = 0; i < base::size(kAndroidSearchColumn); ++i) {
       (*this)[kAndroidSearchColumn[i]] = static_cast<SearchRow::ColumnID>(i);
     }
   }
diff --git a/components/history/core/browser/android/android_urls_sql_handler.cc b/components/history/core/browser/android/android_urls_sql_handler.cc
index 31d2299..db1f0d5 100644
--- a/components/history/core/browser/android/android_urls_sql_handler.cc
+++ b/components/history/core/browser/android/android_urls_sql_handler.cc
@@ -5,7 +5,7 @@
 #include "components/history/core/browser/android/android_urls_sql_handler.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/history/core/browser/android/android_urls_database.h"
 
 namespace history {
@@ -20,9 +20,8 @@
 
 AndroidURLsSQLHandler::AndroidURLsSQLHandler(
     AndroidURLsDatabase* android_urls_db)
-    : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
-      android_urls_db_(android_urls_db) {
-}
+    : SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
+      android_urls_db_(android_urls_db) {}
 
 AndroidURLsSQLHandler::~AndroidURLsSQLHandler() {
 }
diff --git a/components/history/core/browser/android/favicon_sql_handler.cc b/components/history/core/browser/android/favicon_sql_handler.cc
index 28205cf0..0857764 100644
--- a/components/history/core/browser/android/favicon_sql_handler.cc
+++ b/components/history/core/browser/android/favicon_sql_handler.cc
@@ -5,9 +5,9 @@
 #include "components/history/core/browser/android/favicon_sql_handler.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/ref_counted_memory.h"
+#include "base/stl_util.h"
 #include "components/history/core/browser/thumbnail_database.h"
 
 using base::Time;
@@ -23,9 +23,8 @@
 }  // namespace
 
 FaviconSQLHandler::FaviconSQLHandler(ThumbnailDatabase* thumbnail_db)
-    : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
-      thumbnail_db_(thumbnail_db) {
-}
+    : SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
+      thumbnail_db_(thumbnail_db) {}
 
 FaviconSQLHandler::~FaviconSQLHandler() {
 }
diff --git a/components/history/core/browser/android/urls_sql_handler.cc b/components/history/core/browser/android/urls_sql_handler.cc
index 2dfd6c5..292c13b 100644
--- a/components/history/core/browser/android/urls_sql_handler.cc
+++ b/components/history/core/browser/android/urls_sql_handler.cc
@@ -5,7 +5,7 @@
 #include "components/history/core/browser/android/urls_sql_handler.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/history/core/browser/url_database.h"
 
 using base::Time;
@@ -21,9 +21,8 @@
 }  // namespace
 
 UrlsSQLHandler::UrlsSQLHandler(URLDatabase* url_db)
-    : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
-      url_db_(url_db) {
-}
+    : SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
+      url_db_(url_db) {}
 
 UrlsSQLHandler:: ~UrlsSQLHandler() {
 }
diff --git a/components/history/core/browser/android/visit_sql_handler.cc b/components/history/core/browser/android/visit_sql_handler.cc
index 5af06e7..2135344 100644
--- a/components/history/core/browser/android/visit_sql_handler.cc
+++ b/components/history/core/browser/android/visit_sql_handler.cc
@@ -7,7 +7,7 @@
 #include <stdint.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/history/core/browser/url_database.h"
 #include "components/history/core/browser/visit_database.h"
 
@@ -25,10 +25,9 @@
 } // namespace
 
 VisitSQLHandler::VisitSQLHandler(URLDatabase* url_db, VisitDatabase* visit_db)
-    : SQLHandler(kInterestingColumns, arraysize(kInterestingColumns)),
+    : SQLHandler(kInterestingColumns, base::size(kInterestingColumns)),
       url_db_(url_db),
-      visit_db_(visit_db) {
-}
+      visit_db_(visit_db) {}
 
 VisitSQLHandler::~VisitSQLHandler() {
 }
diff --git a/components/history/core/browser/expire_history_backend_unittest.cc b/components/history/core/browser/expire_history_backend_unittest.cc
index 4238edb..8d274b3 100644
--- a/components/history/core/browser/expire_history_backend_unittest.cc
+++ b/components/history/core/browser/expire_history_backend_unittest.cc
@@ -15,10 +15,10 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/run_loop.h"
 #include "base/scoped_observer.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_feature_list.h"
@@ -568,7 +568,7 @@
   std::vector<GURL> urls;
   // Push back a bogus URL (which shouldn't change anything).
   urls.push_back(GURL());
-  for (size_t i = 0; i < arraysize(rows); ++i) {
+  for (size_t i = 0; i < base::size(rows); ++i) {
     ASSERT_TRUE(main_db_->GetURLRow(url_ids[i], &rows[i]));
     favicon_ids[i] =
         GetFavicon(rows[i].url(), favicon_base::IconType::kFavicon);
diff --git a/components/history/core/browser/history_backend_unittest.cc b/components/history/core/browser/history_backend_unittest.cc
index 4f735fa9..98e1895 100644
--- a/components/history/core/browser/history_backend_unittest.cc
+++ b/components/history/core/browser/history_backend_unittest.cc
@@ -19,13 +19,13 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/histogram_base.h"
 #include "base/metrics/histogram_samples.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -3411,7 +3411,7 @@
   ASSERT_TRUE(backend_.get());
 
   HistoryAddPageArgs args[10];
-  for (size_t i = 0; i < arraysize(args); ++i) {
+  for (size_t i = 0; i < base::size(args); ++i) {
     args[i].url = GURL("http://example" +
                        std::string((i % 2 == 0 ? ".com" : ".net")));
     args[i].time = base::Time::FromInternalValue(i);
@@ -3420,7 +3420,7 @@
   EXPECT_EQ(base::Time(), backend_->GetFirstRecordedTimeForTest());
 
   URLRow row;
-  for (size_t i = 0; i < arraysize(args); ++i) {
+  for (size_t i = 0; i < base::size(args); ++i) {
     EXPECT_TRUE(backend_->GetURL(args[i].url, &row));
   }
 
@@ -3469,14 +3469,14 @@
 
   // Insert 4 entries into the database.
   HistoryAddPageArgs args[4];
-  for (size_t i = 0; i < arraysize(args); ++i) {
+  for (size_t i = 0; i < base::size(args); ++i) {
     args[i].url = GURL("http://example" + base::NumberToString(i) + ".com");
     args[i].time = reference_time + base::TimeDelta::FromDays(i);
     backend_->AddPage(args[i]);
   }
 
   URLRow url_rows[4];
-  for (unsigned int i = 0; i < arraysize(args); ++i)
+  for (unsigned int i = 0; i < base::size(args); ++i)
     ASSERT_TRUE(backend_->GetURL(args[i].url, &url_rows[i]));
 
   std::vector<ExpireHistoryArgs> expire_list;
@@ -3510,7 +3510,7 @@
   EXPECT_EQ(backend_->GetFirstRecordedTimeForTest(), args[1].time);
 
   // Now delete the rest of the visits in one call.
-  for (unsigned int i = 1; i < arraysize(args); ++i) {
+  for (unsigned int i = 1; i < base::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);
diff --git a/components/history/core/browser/history_querying_unittest.cc b/components/history/core/browser/history_querying_unittest.cc
index 3cdc1660c..6f1f950 100644
--- a/components/history/core/browser/history_querying_unittest.cc
+++ b/components/history/core/browser/history_querying_unittest.cc
@@ -9,8 +9,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/cancelable_task_tracker.h"
 #include "base/test/scoped_task_environment.h"
@@ -173,7 +173,7 @@
 
     // Fill the test data.
     base::Time now = base::Time::Now().LocalMidnight();
-    for (size_t i = 0; i < arraysize(test_entries); i++) {
+    for (size_t i = 0; i < base::size(test_entries); i++) {
       test_entries[i].time =
           now - (test_entries[i].days_ago * base::TimeDelta::FromDays(1));
       AddEntryToHistory(test_entries[i]);
@@ -410,7 +410,7 @@
                        L"\u0438\u0434\u0435\u043d\u0442.\u0440\u0444"), 1, },
   };
 
-  for (size_t i = 0; i < arraysize(queries); ++i) {
+  for (size_t i = 0; i < base::size(queries); ++i) {
     QueryHistory(queries[i].query, options, &results);
     EXPECT_EQ(queries[i].results_size, results.size());
   }
@@ -421,7 +421,7 @@
   // 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, 0 };
-  TestPaging(std::string(), expected_results, arraysize(expected_results));
+  TestPaging(std::string(), expected_results, base::size(expected_results));
 }
 
 TEST_F(HistoryQueryTest, TextSearchPaging) {
@@ -429,7 +429,7 @@
   // 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, arraysize(expected_results));
+  TestPaging("title", expected_results, base::size(expected_results));
 }
 
 }  // namespace history
diff --git a/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc b/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
index be84297..b937aec 100644
--- a/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
+++ b/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
@@ -8,6 +8,7 @@
 
 #include "base/big_endian.h"
 #include "base/files/scoped_temp_dir.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -1421,8 +1422,8 @@
 
   DiffVisits(old_visits, new_url, &new_visits, &removed_visits);
   EXPECT_TRUE(new_visits.empty());
-  ASSERT_EQ(removed_visits.size(), arraysize(visits_removed));
-  for (size_t i = 0; i < arraysize(visits_removed); ++i) {
+  ASSERT_EQ(removed_visits.size(), base::size(visits_removed));
+  for (size_t i = 0; i < base::size(visits_removed); ++i) {
     EXPECT_EQ(removed_visits[i].visit_time.ToInternalValue(),
               visits_removed[i]);
   }
@@ -1455,8 +1456,8 @@
 
   DiffVisits(old_visits, new_url, &new_visits, &removed_visits);
   EXPECT_TRUE(removed_visits.empty());
-  ASSERT_TRUE(new_visits.size() == arraysize(visits_added));
-  for (size_t i = 0; i < arraysize(visits_added); ++i) {
+  ASSERT_TRUE(new_visits.size() == base::size(visits_added));
+  for (size_t i = 0; i < base::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));
diff --git a/components/history/core/browser/top_sites_cache_unittest.cc b/components/history/core/browser/top_sites_cache_unittest.cc
index 327402f..c4510c7b 100644
--- a/components/history/core/browser/top_sites_cache_unittest.cc
+++ b/components/history/core/browser/top_sites_cache_unittest.cc
@@ -11,7 +11,7 @@
 #include <vector>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -81,7 +81,7 @@
 };
 
 TEST_F(TopSitesCacheTest, GetCanonicalURL) {
-  InitTopSiteCache(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic));
+  InitTopSiteCache(kTopSitesSpecBasic, base::size(kTopSitesSpecBasic));
   struct {
     const char* expected;
     const char* query;
@@ -105,7 +105,7 @@
     // Prefix should not work: as-is.
     {"http://www.youtube.com/a", "http://www.youtube.com/a"},
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::string expected(test_cases[i].expected);
     std::string query(test_cases[i].query);
     EXPECT_EQ(expected, cache_.GetCanonicalURL(GURL(query)).spec())
@@ -114,7 +114,7 @@
 }
 
 TEST_F(TopSitesCacheTest, IsKnownUrl) {
-  InitTopSiteCache(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic));
+  InitTopSiteCache(kTopSitesSpecBasic, base::size(kTopSitesSpecBasic));
   // Matches.
   EXPECT_TRUE(cache_.IsKnownURL(GURL("http://www.google.com")));
   EXPECT_TRUE(cache_.IsKnownURL(GURL("http://www.gooogle.com")));
diff --git a/components/history/core/browser/url_database.cc b/components/history/core/browser/url_database.cc
index 9a34fcc..286fc9f 100644
--- a/components/history/core/browser/url_database.cc
+++ b/components/history/core/browser/url_database.cc
@@ -9,7 +9,7 @@
 #include <vector>
 
 #include "base/i18n/case_conversion.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/history/core/browser/keyword_search_term.h"
 #include "components/url_formatter/url_formatter.h"
@@ -322,7 +322,7 @@
     url::kFtpScheme
   };
   URLRows dummy;
-  for (size_t i = 0; i < arraysize(schemes); ++i) {
+  for (size_t i = 0; i < base::size(schemes); ++i) {
     std::string scheme_and_host(schemes[i]);
     scheme_and_host += url::kStandardSchemeSeparator + host;
     if (AutocompleteForPrefix(scheme_and_host + '/', 1, true, &dummy) ||
diff --git a/components/history/core/browser/url_utils_unittest.cc b/components/history/core/browser/url_utils_unittest.cc
index 1b8a3e8..ad19bd8 100644
--- a/components/history/core/browser/url_utils_unittest.cc
+++ b/components/history/core/browser/url_utils_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
 
@@ -36,11 +36,11 @@
     "http://www.google.com:80/",
     "https://www.google.com",
   };
-  for (size_t i = 0; i < arraysize(sorted_list); ++i) {
+  for (size_t i = 0; i < base::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 < arraysize(sorted_list); ++j) {
+    for (size_t j = i + 1; j < base::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 +64,7 @@
     {"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 < arraysize(true_cases); ++i) {
+  for (size_t i = 0; i < base::size(true_cases); ++i) {
     EXPECT_TRUE(HaveSameSchemeHostAndPort(GURL(true_cases[i].s1),
                                GURL(true_cases[i].s2)))
         << " for true_cases[" << i << "]";
@@ -79,7 +79,7 @@
     {"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 < arraysize(false_cases); ++i) {
+  for (size_t i = 0; i < base::size(false_cases); ++i) {
     EXPECT_FALSE(HaveSameSchemeHostAndPort(GURL(false_cases[i].s1),
                                 GURL(false_cases[i].s2)))
         << " for false_cases[" << i << "]";
@@ -99,7 +99,7 @@
     {"/test", "/test/with/dir/"},
     {"/test/", "/test/with/dir"},
   };
-  for (size_t i = 0; i < arraysize(true_cases); ++i) {
+  for (size_t i = 0; i < base::size(true_cases); ++i) {
     EXPECT_TRUE(IsPathPrefix(true_cases[i].p1, true_cases[i].p2))
         << " for true_cases[" << i << "]";
   }
@@ -114,7 +114,7 @@
     {"/test", "/test-bed"},
     {"/test-", "/test"},
   };
-  for (size_t i = 0; i < arraysize(false_cases); ++i) {
+  for (size_t i = 0; i < base::size(false_cases); ++i) {
     EXPECT_FALSE(IsPathPrefix(false_cases[i].p1, false_cases[i].p2))
         << " for false_cases[" << i << "]";
   }
diff --git a/components/history/core/browser/visit_tracker_unittest.cc b/components/history/core/browser/visit_tracker_unittest.cc
index 27dbb68..3c69e7cf 100644
--- a/components/history/core/browser/visit_tracker_unittest.cc
+++ b/components/history/core/browser/visit_tracker_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "components/history/core/browser/visit_tracker.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace history {
@@ -58,7 +58,7 @@
   };
 
   VisitTracker tracker;
-  RunTest(&tracker, test_simple, arraysize(test_simple));
+  RunTest(&tracker, test_simple, base::size(test_simple));
 }
 
 // Test that referrer is properly computed when there are different frame
@@ -80,7 +80,7 @@
   };
 
   VisitTracker tracker;
-  RunTest(&tracker, test_frames, arraysize(test_frames));
+  RunTest(&tracker, test_frames, base::size(test_frames));
 }
 
 // Test frame navigation to make sure that the referrer is properly computed
@@ -102,7 +102,7 @@
   };
 
   VisitTracker tracker;
-  RunTest(&tracker, test_processes, arraysize(test_processes));
+  RunTest(&tracker, test_processes, base::size(test_processes));
 }
 
 // Test that processes get removed properly.
@@ -114,7 +114,7 @@
   };
 
   VisitTracker tracker;
-  RunTest(&tracker, part1, arraysize(part1));
+  RunTest(&tracker, part1, base::size(part1));
 
   // Say that context has been invalidated.
   tracker.ClearCachedDataForContextID(reinterpret_cast<ContextID>(1));
@@ -124,7 +124,7 @@
   VisitToTest part2[] = {
       {1, 1, "http://images.google.com/", 2, "http://www.google.com/", 0},
   };
-  RunTest(&tracker, part2, arraysize(part2));
+  RunTest(&tracker, part2, base::size(part2));
 }
 
 }  // namespace history
diff --git a/components/image_fetcher/ios/webp_decoder_unittest.mm b/components/image_fetcher/ios/webp_decoder_unittest.mm
index cca0f5d..fa723efd 100644
--- a/components/image_fetcher/ios/webp_decoder_unittest.mm
+++ b/components/image_fetcher/ios/webp_decoder_unittest.mm
@@ -17,9 +17,9 @@
 #include "base/logging.h"
 #include "base/mac/scoped_cftyperef.h"
 #import "base/mac/scoped_nsobject.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "build/build_config.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -261,8 +261,9 @@
 TEST_F(WebpDecoderTest, InvalidFormat) {
   EXPECT_CALL(*delegate_, OnFinishedDecoding(false)).Times(1);
   const char dummy_image[] = "(>'-')> <('-'<) ^('-')^ <('-'<) (>'-')>";
-  base::scoped_nsobject<NSData> data(
-      [[NSData alloc] initWithBytes:dummy_image length:arraysize(dummy_image)]);
+  base::scoped_nsobject<NSData> data([[NSData alloc]
+      initWithBytes:dummy_image
+             length:base::size(dummy_image)]);
   decoder_->OnDataReceived(data);
   EXPECT_EQ(0u, [delegate_->GetImage() length]);
 }
diff --git a/components/invalidation/impl/ticl_invalidation_service.cc b/components/invalidation/impl/ticl_invalidation_service.cc
index c75c680f..2a2f9dc 100644
--- a/components/invalidation/impl/ticl_invalidation_service.cc
+++ b/components/invalidation/impl/ticl_invalidation_service.cc
@@ -8,8 +8,8 @@
 #include <utility>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "components/gcm_driver/gcm_driver.h"
 #include "components/invalidation/impl/gcm_invalidation_bridge.h"
 #include "components/invalidation/impl/invalidation_service_util.h"
@@ -199,7 +199,7 @@
     return;
   request_access_token_retry_timer_.Stop();
   OAuth2TokenService::ScopeSet oauth2_scopes;
-  for (size_t i = 0; i < arraysize(kOAuth2Scopes); i++)
+  for (size_t i = 0; i < base::size(kOAuth2Scopes); i++)
     oauth2_scopes.insert(kOAuth2Scopes[i]);
   // Invalidate previous token, otherwise the identity provider will return the
   // same token again.
diff --git a/components/language/content/browser/regional_language_code_locator.cc b/components/language/content/browser/regional_language_code_locator.cc
index b9256b6d..da07a35 100644
--- a/components/language/content/browser/regional_language_code_locator.cc
+++ b/components/language/content/browser/regional_language_code_locator.cc
@@ -4,6 +4,7 @@
 
 #include "components/language/content/browser/regional_language_code_locator.h"
 
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "third_party/s2cellid/src/s2/s2cellid.h"
 #include "third_party/s2cellid/src/s2/s2latlng.h"
@@ -16,7 +17,7 @@
 RegionalLanguageCodeLocator::RegionalLanguageCodeLocator() {
   int pos = 0;
   int index = 0;
-  std::vector<std::pair<uint32_t, char>> items(arraysize(kDistrictPositions));
+  std::vector<std::pair<uint32_t, char>> items(base::size(kDistrictPositions));
   for (const uint16_t language_count : kLanguageCodeCounts) {
     for (int i = 0; i < language_count; ++i) {
       items[pos] = std::make_pair(kDistrictPositions[pos], index);
diff --git a/components/language/core/browser/heuristic_language_model_unittest.cc b/components/language/core/browser/heuristic_language_model_unittest.cc
index 68356759..3021ae1 100644
--- a/components/language/core/browser/heuristic_language_model_unittest.cc
+++ b/components/language/core/browser/heuristic_language_model_unittest.cc
@@ -7,7 +7,7 @@
 #include <cmath>
 
 #include "base/json/json_reader.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/language/core/browser/url_language_histogram.h"
 #include "components/prefs/pref_registry_simple.h"
@@ -242,11 +242,11 @@
     const std::vector<std::vector<std::string>>& input_langs) {
   const float delta = 0.01f;
   const float weights[] = {2.0f, 1.1f, 1.0f, 0.5f};
-  CHECK_EQ(arraysize(weights), input_langs.size());
+  CHECK_EQ(base::size(weights), input_langs.size());
 
   // Construct input to model.
   std::vector<std::pair<float, std::vector<std::string>>> input;
-  for (unsigned long i = 0; i < arraysize(weights); ++i)
+  for (unsigned long i = 0; i < base::size(weights); ++i)
     input.push_back({weights[i], input_langs[i]});
 
   // Construct model itself.
diff --git a/components/metrics/field_trials_provider_unittest.cc b/components/metrics/field_trials_provider_unittest.cc
index 2f6c8eff..3559998 100644
--- a/components/metrics/field_trials_provider_unittest.cc
+++ b/components/metrics/field_trials_provider_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "components/metrics/field_trials_provider.h"
 
+#include "base/stl_util.h"
 #include "components/variations/active_field_trials.h"
 #include "components/variations/synthetic_trial_registry.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -34,18 +35,18 @@
 // Check that the values in |system_values| correspond to the test data
 // defined at the top of this file.
 void CheckSystemProfile(const metrics::SystemProfileProto& system_profile) {
-  ASSERT_EQ(arraysize(kFieldTrialIds) + arraysize(kSyntheticTrials),
+  ASSERT_EQ(base::size(kFieldTrialIds) + base::size(kSyntheticTrials),
             static_cast<size_t>(system_profile.field_trial_size()));
-  for (size_t i = 0; i < arraysize(kFieldTrialIds); ++i) {
+  for (size_t i = 0; i < base::size(kFieldTrialIds); ++i) {
     const metrics::SystemProfileProto::FieldTrial& field_trial =
         system_profile.field_trial(i);
     EXPECT_EQ(kFieldTrialIds[i].name, field_trial.name_id());
     EXPECT_EQ(kFieldTrialIds[i].group, field_trial.group_id());
   }
   // Verify the right data is present for the synthetic trials.
-  for (size_t i = 0; i < arraysize(kSyntheticTrials); ++i) {
+  for (size_t i = 0; i < base::size(kSyntheticTrials); ++i) {
     const metrics::SystemProfileProto::FieldTrial& field_trial =
-        system_profile.field_trial(i + arraysize(kFieldTrialIds));
+        system_profile.field_trial(i + base::size(kFieldTrialIds));
     EXPECT_EQ(kSyntheticTrials[i].name, field_trial.name_id());
     EXPECT_EQ(kSyntheticTrials[i].group, field_trial.group_id());
   }
diff --git a/components/metrics/file_metrics_provider.cc b/components/metrics/file_metrics_provider.cc
index 9333235..e9931d0c 100644
--- a/components/metrics/file_metrics_provider.cc
+++ b/components/metrics/file_metrics_provider.cc
@@ -18,6 +18,7 @@
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/persistent_histogram_allocator.h"
 #include "base/metrics/persistent_memory_allocator.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/task/post_task.h"
 #include "base/task/task_traits.h"
@@ -217,7 +218,7 @@
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
 
   // Ensure that kSourceOptions has been filled for this type.
-  DCHECK_GT(arraysize(kSourceOptions), static_cast<size_t>(params.type));
+  DCHECK_GT(base::size(kSourceOptions), static_cast<size_t>(params.type));
 
   std::unique_ptr<SourceInfo> source(new SourceInfo(params));
 
diff --git a/components/metrics/file_metrics_provider_unittest.cc b/components/metrics/file_metrics_provider_unittest.cc
index c0d90575..dbbbcba 100644
--- a/components/metrics/file_metrics_provider_unittest.cc
+++ b/components/metrics/file_metrics_provider_unittest.cc
@@ -9,7 +9,6 @@
 #include "base/files/file_util.h"
 #include "base/files/memory_mapped_file.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/metrics/histogram.h"
 #include "base/metrics/histogram_flattener.h"
 #include "base/metrics/histogram_snapshot_manager.h"
@@ -17,6 +16,7 @@
 #include "base/metrics/persistent_memory_allocator.h"
 #include "base/metrics/sparse_histogram.h"
 #include "base/metrics/statistics_recorder.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/test/test_simple_task_runner.h"
@@ -363,7 +363,7 @@
   const FileMetricsProvider::FilterAction actions[] = {
       FileMetricsProvider::FILTER_TRY_LATER,
       FileMetricsProvider::FILTER_PROCESS_FILE};
-  SetFilterActions(&params, actions, arraysize(actions));
+  SetFilterActions(&params, actions, base::size(actions));
   provider()->RegisterSource(params);
 
   // Processing the file should touch it but yield no results. File timestamp
@@ -402,7 +402,7 @@
       FileMetricsProvider::ASSOCIATE_CURRENT_RUN, kMetricsName);
   const FileMetricsProvider::FilterAction actions[] = {
       FileMetricsProvider::FILTER_SKIP_FILE};
-  SetFilterActions(&params, actions, arraysize(actions));
+  SetFilterActions(&params, actions, base::size(actions));
   provider()->RegisterSource(params);
 
   // Processing the file should delete it.
@@ -478,7 +478,7 @@
   // Files could come out in the order: a1, c2, d4, b3. They are recognizeable
   // by the number of histograms contained within each.
   const uint32_t expect_order[] = {1, 2, 4, 3, 0};
-  for (size_t i = 0; i < arraysize(expect_order); ++i) {
+  for (size_t i = 0; i < base::size(expect_order); ++i) {
     // Record embedded snapshots via snapshot-manager.
     OnDidCreateMetricsLog();
     RunTasks();
@@ -788,13 +788,13 @@
       FileMetricsProvider::FILTER_SKIP_FILE,      // d4
       FileMetricsProvider::FILTER_PROCESS_FILE,   // b3
       FileMetricsProvider::FILTER_PROCESS_FILE};  // c2 (again)
-  SetFilterActions(&params, actions, arraysize(actions));
+  SetFilterActions(&params, actions, base::size(actions));
   provider()->RegisterSource(params);
 
   // Files could come out in the order: a1, b3, c2. They are recognizeable
   // by the number of histograms contained within each.
   const uint32_t expect_order[] = {1, 3, 2, 0};
-  for (size_t i = 0; i < arraysize(expect_order); ++i) {
+  for (size_t i = 0; i < base::size(expect_order); ++i) {
     // Record embedded snapshots via snapshot-manager.
     OnDidCreateMetricsLog();
     RunTasks();
diff --git a/components/metrics/system_session_analyzer_win.cc b/components/metrics/system_session_analyzer_win.cc
index e64501f..657a539 100644
--- a/components/metrics/system_session_analyzer_win.cc
+++ b/components/metrics/system_session_analyzer_win.cc
@@ -4,7 +4,7 @@
 
 #include "components/metrics/system_session_analyzer_win.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 
 namespace metrics {
@@ -249,7 +249,7 @@
 
 SystemSessionAnalyzer::EvtHandle SystemSessionAnalyzer::CreateRenderContext() {
   LPCWSTR value_paths[] = {kEventIdPath, kEventTimePath};
-  const DWORD kValueCnt = arraysize(value_paths);
+  const DWORD kValueCnt = base::size(value_paths);
 
   EVT_HANDLE context = nullptr;
   context =
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index 8cdc8c5..afe8b14 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -17,7 +17,6 @@
 #include "base/feature_list.h"
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
 #include "base/process/launch.h"
@@ -922,7 +921,7 @@
     switches::kV,
     switches::kVModule,
   };
-  for (size_t i = 0; i < arraysize(flag_whitelist); ++i) {
+  for (size_t i = 0; i < base::size(flag_whitelist); ++i) {
     std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]);
     if (!value.empty()) {
       args.switch_names.push_back(flag_whitelist[i]);
diff --git a/components/nacl/common/nacl_cmd_line.cc b/components/nacl/common/nacl_cmd_line.cc
index 3645d2b8..545b702 100644
--- a/components/nacl/common/nacl_cmd_line.cc
+++ b/components/nacl/common/nacl_cmd_line.cc
@@ -4,7 +4,7 @@
 
 #include "base/base_switches.h"
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "components/nacl/common/nacl_switches.h"
 #include "content/public/common/content_switches.h"
@@ -32,7 +32,7 @@
 #endif
   };
   cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
-                             arraysize(kSwitchNames));
+                             base::size(kSwitchNames));
 }
 
 }  // namespace nacl
diff --git a/components/nacl/renderer/json_manifest.cc b/components/nacl/renderer/json_manifest.cc
index 7e95c60f4..6bceb54 100644
--- a/components/nacl/renderer/json_manifest.cc
+++ b/components/nacl/renderer/json_manifest.cc
@@ -11,7 +11,7 @@
 
 #include "base/json/json_reader.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/nacl/common/nacl_types.h"
 #include "components/nacl/renderer/nexe_load_manager.h"
 #include "url/gurl.h"
@@ -172,7 +172,7 @@
         kUrlKey, kOptLevelKey,
     };
     url_spec_plus_optional = kPnaclUrlSpecPlusOptional;
-    url_spec_plus_optional_length = arraysize(kPnaclUrlSpecPlusOptional);
+    url_spec_plus_optional_length = base::size(kPnaclUrlSpecPlusOptional);
   } else {
     // URL specifications must not contain "pnacl-translate" keys.
     // This prohibits NaCl clients from invoking PNaCl.
@@ -184,12 +184,12 @@
       return false;
     }
     url_spec_plus_optional = kManifestUrlSpecRequired;
-    url_spec_plus_optional_length = arraysize(kManifestUrlSpecRequired);
+    url_spec_plus_optional_length = base::size(kManifestUrlSpecRequired);
   }
   if (!IsValidDictionary(*url_dict, container_key, parent_key,
                          url_spec_plus_optional, url_spec_plus_optional_length,
                          kManifestUrlSpecRequired,
-                         arraysize(kManifestUrlSpecRequired), error_string)) {
+                         base::size(kManifestUrlSpecRequired), error_string)) {
     return false;
   }
   // Verify the correct types of the fields if they exist.
@@ -245,8 +245,8 @@
 
   if (!IsValidDictionary(
           *pnacl_dict, container_key, parent_key, kManifestPnaclSpecValid,
-          arraysize(kManifestPnaclSpecValid), kManifestPnaclSpecRequired,
-          arraysize(kManifestPnaclSpecRequired), error_string)) {
+          base::size(kManifestPnaclSpecValid), kManifestPnaclSpecRequired,
+          base::size(kManifestPnaclSpecRequired), error_string)) {
     return false;
   }
   // kPnaclTranslateKey checked to be required above.
@@ -287,7 +287,7 @@
       kPortableKey
     };
     isaProperties = kPnaclManifestISAProperties;
-    isaPropertiesLength = arraysize(kPnaclManifestISAProperties);
+    isaPropertiesLength = base::size(kPnaclManifestISAProperties);
   } else {
     // The known values for NaCl ISA dictionaries in the manifest.
     static const char* kNaClManifestISAProperties[] = {
@@ -303,7 +303,7 @@
       kPortableKey
     };
     isaProperties = kNaClManifestISAProperties;
-    isaPropertiesLength = arraysize(kNaClManifestISAProperties);
+    isaPropertiesLength = base::size(kNaClManifestISAProperties);
   }
   // Check that entries in the dictionary are structurally correct.
   for (base::DictionaryValue::Iterator it(*dictionary); !it.IsAtEnd();
@@ -520,9 +520,8 @@
   for (base::DictionaryValue::Iterator it(*dictionary_); !it.IsAtEnd();
        it.Advance()) {
     const std::string& property_name = it.key();
-    if (!FindMatchingProperty(property_name,
-                              kManifestTopLevelProperties,
-                              arraysize(kManifestTopLevelProperties))) {
+    if (!FindMatchingProperty(property_name, kManifestTopLevelProperties,
+                              base::size(kManifestTopLevelProperties))) {
       VLOG(1) << "JsonManifest::MatchesSchema: WARNING: unknown top-level "
               << "section '" << property_name << "' in manifest.";
     }
diff --git a/components/nacl/zygote/nacl_fork_delegate_linux.cc b/components/nacl/zygote/nacl_fork_delegate_linux.cc
index c5c5f29c..27b2222 100644
--- a/components/nacl/zygote/nacl_fork_delegate_linux.cc
+++ b/components/nacl/zygote/nacl_fork_delegate_linux.cc
@@ -18,7 +18,6 @@
 #include "base/files/file_path.h"
 #include "base/files/scoped_file.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/pickle.h"
 #include "base/posix/eintr_wrapper.h"
@@ -26,6 +25,7 @@
 #include "base/posix/unix_domain_socket.h"
 #include "base/process/kill.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "build/build_config.h"
 #include "components/nacl/common/nacl_nonsfi_util.h"
@@ -230,7 +230,7 @@
       const base::CommandLine& current_cmd_line =
           *base::CommandLine::ForCurrentProcess();
       cmd_line.CopySwitchesFrom(current_cmd_line, kForwardSwitches,
-                                arraysize(kForwardSwitches));
+                                base::size(kForwardSwitches));
 
       // The command line needs to be tightly controlled to use
       // |helper_bootstrap_exe|. So from now on, argv_to_launch should be
diff --git a/components/navigation_metrics/navigation_metrics.cc b/components/navigation_metrics/navigation_metrics.cc
index 407e8d0..c5c11c0d 100644
--- a/components/navigation_metrics/navigation_metrics.cc
+++ b/components/navigation_metrics/navigation_metrics.cc
@@ -4,8 +4,8 @@
 
 #include "components/navigation_metrics/navigation_metrics.h"
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "components/dom_distiller/core/url_constants.h"
 #include "url/gurl.h"
 
@@ -34,7 +34,7 @@
     "externalfile",
 };
 
-static_assert(arraysize(kSchemeNames) == static_cast<int>(Scheme::COUNT),
+static_assert(base::size(kSchemeNames) == static_cast<int>(Scheme::COUNT),
               "kSchemeNames should have Scheme::COUNT elements");
 
 }  // namespace
diff --git a/components/network_session_configurator/common/network_switches.cc b/components/network_session_configurator/common/network_switches.cc
index 7178b17..6d9a3df 100644
--- a/components/network_session_configurator/common/network_switches.cc
+++ b/components/network_session_configurator/common/network_switches.cc
@@ -5,6 +5,7 @@
 #include "components/network_session_configurator/common/network_switches.h"
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 
 namespace switches {
 
@@ -25,7 +26,7 @@
   };
 
   dest_command_line->CopySwitchesFrom(src_command_line, kSwitchNames,
-                                      arraysize(kSwitchNames));
+                                      base::size(kSwitchNames));
 }
 
 }  // namespace network_session_configurator
diff --git a/components/network_time/network_time_tracker_unittest.cc b/components/network_time/network_time_tracker_unittest.cc
index ff98ac7..e6b9b0f 100644
--- a/components/network_time/network_time_tracker_unittest.cc
+++ b/components/network_time/network_time_tracker_unittest.cc
@@ -10,6 +10,7 @@
 
 #include "base/compiler_specific.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/test/scoped_task_environment.h"
@@ -852,7 +853,7 @@
   net::test_server::BasicHttpResponse* response =
       new net::test_server::BasicHttpResponse();
 
-  if (next_time_index_ >= arraysize(kGoodTimeResponseBody)) {
+  if (next_time_index_ >= base::size(kGoodTimeResponseBody)) {
     response->set_code(net::HTTP_BAD_REQUEST);
     return std::unique_ptr<net::test_server::HttpResponse>(response);
   }
@@ -867,7 +868,7 @@
 }
 
 base::Time MultipleGoodTimeResponseHandler::GetTimeAtIndex(unsigned int i) {
-  if (i >= arraysize(kGoodTimeResponseHandlerJsTime))
+  if (i >= base::size(kGoodTimeResponseHandlerJsTime))
     return base::Time();
   return base::Time::FromJsTime(kGoodTimeResponseHandlerJsTime[i]);
 }
diff --git a/components/ntp_snippets/features.cc b/components/ntp_snippets/features.cc
index 55f2112..b3e424fe 100644
--- a/components/ntp_snippets/features.cc
+++ b/components/ntp_snippets/features.cc
@@ -6,6 +6,7 @@
 
 #include "base/feature_list.h"
 #include "base/metrics/field_trial_params.h"
+#include "base/stl_util.h"
 #include "base/time/clock.h"
 #include "components/ntp_snippets/category_rankers/click_based_category_ranker.h"
 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
@@ -156,7 +157,7 @@
 std::vector<const base::Feature*> GetAllFeatures() {
   // Skip the last feature as it's a nullptr.
   return std::vector<const base::Feature*>(
-      kAllFeatures, kAllFeatures + arraysize(kAllFeatures));
+      kAllFeatures, kAllFeatures + base::size(kAllFeatures));
 }
 
 // Default referrer for the content suggestions.
diff --git a/components/ntp_snippets/remote/remote_suggestions_scheduler_impl.cc b/components/ntp_snippets/remote/remote_suggestions_scheduler_impl.cc
index 2469b87e..6248cc6 100644
--- a/components/ntp_snippets/remote/remote_suggestions_scheduler_impl.cc
+++ b/components/ntp_snippets/remote/remote_suggestions_scheduler_impl.cc
@@ -14,6 +14,7 @@
 #include "base/location.h"
 #include "base/metrics/field_trial_params.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/clock.h"
@@ -111,23 +112,24 @@
 
 static_assert(
     static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kDefaultFetchingIntervalHoursRareNtpUser) &&
+            base::size(kDefaultFetchingIntervalHoursRareNtpUser) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kDefaultFetchingIntervalHoursActiveNtpUser) &&
+            base::size(kDefaultFetchingIntervalHoursActiveNtpUser) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kDefaultFetchingIntervalHoursActiveSuggestionsConsumer) &&
+            base::size(
+                kDefaultFetchingIntervalHoursActiveSuggestionsConsumer) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kM58FetchingIntervalHoursRareNtpUser) &&
+            base::size(kM58FetchingIntervalHoursRareNtpUser) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kM58FetchingIntervalHoursActiveNtpUser) &&
+            base::size(kM58FetchingIntervalHoursActiveNtpUser) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kM58FetchingIntervalHoursActiveSuggestionsConsumer) &&
+            base::size(kM58FetchingIntervalHoursActiveSuggestionsConsumer) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kFetchingIntervalParamNameRareNtpUser) &&
+            base::size(kFetchingIntervalParamNameRareNtpUser) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kFetchingIntervalParamNameActiveNtpUser) &&
+            base::size(kFetchingIntervalParamNameActiveNtpUser) &&
         static_cast<unsigned int>(FetchingInterval::COUNT) ==
-            arraysize(kFetchingIntervalParamNameActiveSuggestionsConsumer),
+            base::size(kFetchingIntervalParamNameActiveSuggestionsConsumer),
     "Fill in all the info for fetching intervals.");
 
 // For backward compatibility "ntp_opened" value is kept and denotes the
@@ -152,7 +154,7 @@
     UserClassifier::UserClass user_class) {
   DCHECK(interval != FetchingInterval::COUNT);
   const unsigned int index = static_cast<unsigned int>(interval);
-  DCHECK(index < arraysize(kDefaultFetchingIntervalHoursRareNtpUser));
+  DCHECK(index < base::size(kDefaultFetchingIntervalHoursRareNtpUser));
 
   bool emulateM58 = base::FeatureList::IsEnabled(
       kRemoteSuggestionsEmulateM58FetchingSchedule);
@@ -894,7 +896,7 @@
 std::set<RemoteSuggestionsSchedulerImpl::TriggerType>
 RemoteSuggestionsSchedulerImpl::GetEnabledTriggerTypes() {
   static_assert(static_cast<unsigned int>(TriggerType::COUNT) ==
-                    arraysize(kTriggerTypeNames),
+                    base::size(kTriggerTypeNames),
                 "Fill in names for trigger types.");
 
   std::string param_value = base::GetFieldTrialParamValueByFeature(
diff --git a/components/ntp_snippets/user_classifier.cc b/components/ntp_snippets/user_classifier.cc
index 8c00124..873cb8f8 100644
--- a/components/ntp_snippets/user_classifier.cc
+++ b/components/ntp_snippets/user_classifier.cc
@@ -9,6 +9,7 @@
 #include <string>
 
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/time/clock.h"
 #include "components/ntp_snippets/features.h"
@@ -82,15 +83,15 @@
     "user_classifier_default_interval_suggestions_shown",
     "user_classifier_default_interval_suggestions_used"};
 
-static_assert(arraysize(kMetrics) ==
+static_assert(base::size(kMetrics) ==
                       static_cast<int>(UserClassifier::Metric::COUNT) &&
-                  arraysize(kMetricKeys) ==
+                  base::size(kMetricKeys) ==
                       static_cast<int>(UserClassifier::Metric::COUNT) &&
-                  arraysize(kLastTimeKeys) ==
+                  base::size(kLastTimeKeys) ==
                       static_cast<int>(UserClassifier::Metric::COUNT) &&
-                  arraysize(kInitialHoursBetweenEvents) ==
+                  base::size(kInitialHoursBetweenEvents) ==
                       static_cast<int>(UserClassifier::Metric::COUNT) &&
-                  arraysize(kInitialHoursBetweenEventsParams) ==
+                  base::size(kInitialHoursBetweenEventsParams) ==
                       static_cast<int>(UserClassifier::Metric::COUNT),
               "Fill in info for all metrics.");
 
diff --git a/components/omnibox/browser/autocomplete_input.cc b/components/omnibox/browser/autocomplete_input.cc
index 42e80de..adb08e88 100644
--- a/components/omnibox/browser/autocomplete_input.cc
+++ b/components/omnibox/browser/autocomplete_input.cc
@@ -6,7 +6,7 @@
 
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -259,7 +259,7 @@
         &http_parts.query,
         &http_parts.ref,
       };
-      for (size_t i = 0; i < arraysize(components); ++i) {
+      for (size_t i = 0; i < base::size(components); ++i) {
         url_formatter::OffsetComponent(
             -static_cast<int>(http_scheme_prefix.length()), components[i]);
       }
diff --git a/components/omnibox/browser/autocomplete_input_unittest.cc b/components/omnibox/browser/autocomplete_input_unittest.cc
index f50878eb..00bbc9a 100644
--- a/components/omnibox/browser/autocomplete_input_unittest.cc
+++ b/components/omnibox/browser/autocomplete_input_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -201,7 +201,7 @@
     {ASCIIToUTF16("test:80/"), metrics::OmniboxInputType::URL},
   };
 
-  for (size_t i = 0; i < arraysize(input_cases); ++i) {
+  for (size_t i = 0; i < base::size(input_cases); ++i) {
     SCOPED_TRACE(input_cases[i].input);
     AutocompleteInput input(input_cases[i].input,
                             metrics::OmniboxEventProto::OTHER,
@@ -243,7 +243,7 @@
        std::string()},
   };
 
-  for (size_t i = 0; i < arraysize(input_cases); ++i) {
+  for (size_t i = 0; i < base::size(input_cases); ++i) {
     SCOPED_TRACE(input_cases[i].input);
     AutocompleteInput input(input_cases[i].input, base::string16::npos, "com",
                             metrics::OmniboxEventProto::OTHER,
@@ -297,7 +297,7 @@
         Component(12, 11), kInvalidComponent }
   };
 
-  for (size_t i = 0; i < arraysize(input_cases); ++i) {
+  for (size_t i = 0; i < base::size(input_cases); ++i) {
     SCOPED_TRACE(input_cases[i].input);
     Component scheme, host;
     AutocompleteInput::ParseForEmphasizeComponents(input_cases[i].input,
@@ -339,7 +339,7 @@
     { ASCIIToUTF16("  ?  foo bar"), 6, ASCIIToUTF16("?  foo bar"), 4 },
   };
 
-  for (size_t i = 0; i < arraysize(input_cases); ++i) {
+  for (size_t i = 0; i < base::size(input_cases); ++i) {
     SCOPED_TRACE(input_cases[i].input);
     AutocompleteInput input(
         input_cases[i].input, input_cases[i].cursor_position,
diff --git a/components/omnibox/browser/autocomplete_match.cc b/components/omnibox/browser/autocomplete_match.cc
index 9e5ef2e5f..5d6a027c 100644
--- a/components/omnibox/browser/autocomplete_match.cc
+++ b/components/omnibox/browser/autocomplete_match.cc
@@ -9,7 +9,7 @@
 
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
@@ -507,7 +507,7 @@
 
   // Remove the www. prefix from the host.
   static const char prefix[] = "www.";
-  static const size_t prefix_len = arraysize(prefix) - 1;
+  static const size_t prefix_len = base::size(prefix) - 1;
   std::string host = stripped_destination_url.host();
   if (host.compare(0, prefix_len, prefix) == 0 && host.length() > prefix_len) {
     replacements.SetHostStr(base::StringPiece(host).substr(prefix_len));
diff --git a/components/omnibox/browser/autocomplete_match_type.cc b/components/omnibox/browser/autocomplete_match_type.cc
index 246ad99..8d365a7 100644
--- a/components/omnibox/browser/autocomplete_match_type.cc
+++ b/components/omnibox/browser/autocomplete_match_type.cc
@@ -5,7 +5,7 @@
 #include "components/omnibox/browser/autocomplete_match_type.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/omnibox/browser/autocomplete_match.h"
@@ -45,7 +45,7 @@
     "pedal",
   };
   // clang-format on
-  static_assert(arraysize(strings) == AutocompleteMatchType::NUM_TYPES,
+  static_assert(base::size(strings) == AutocompleteMatchType::NUM_TYPES,
                 "strings array must have NUM_TYPES elements");
   return strings[type];
 }
@@ -130,7 +130,7 @@
       // TODO(orinj): Determine appropriate accessibility labels for Pedals
       0,  // PEDAL
   };
-  static_assert(arraysize(message_ids) == AutocompleteMatchType::NUM_TYPES,
+  static_assert(base::size(message_ids) == AutocompleteMatchType::NUM_TYPES,
                 "message_ids must have NUM_TYPES elements");
 
   if (label_prefix_length)
diff --git a/components/omnibox/browser/autocomplete_match_unittest.cc b/components/omnibox/browser/autocomplete_match_unittest.cc
index cd61f95..a1ffcfd9 100644
--- a/components/omnibox/browser/autocomplete_match_unittest.cc
+++ b/components/omnibox/browser/autocomplete_match_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/omnibox/browser/test_scheme_classifier.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -47,7 +47,7 @@
   AutocompleteMatch m2(nullptr, 0, false,
                        AutocompleteMatchType::URL_WHAT_YOU_TYPED);
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     m1.relevance = cases[i].r1;
     m2.relevance = cases[i].r2;
     EXPECT_EQ(cases[i].expected_result,
@@ -341,7 +341,7 @@
     { L"http://www./", "http://www./", "http://google.com/", false },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE("input=" + base::WideToUTF8(cases[i].input) +
                  " url1=" + cases[i].url1 + " url2=" + cases[i].url2);
     AutocompleteInput input(base::WideToUTF16(cases[i].input),
diff --git a/components/omnibox/browser/autocomplete_provider_unittest.cc b/components/omnibox/browser/autocomplete_provider_unittest.cc
index 79b53c0..67f22b4 100644
--- a/components/omnibox/browser/autocomplete_provider_unittest.cc
+++ b/components/omnibox/browser/autocomplete_provider_unittest.cc
@@ -11,10 +11,10 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -646,7 +646,7 @@
 
     SCOPED_TRACE("Duplicate url");
     RunKeywordTest(base::ASCIIToUTF16("fo"), duplicate_url,
-                   arraysize(duplicate_url));
+                   base::size(duplicate_url));
   }
 
   {
@@ -658,7 +658,7 @@
 
     SCOPED_TRACE("Duplicate url with keyword match");
     RunKeywordTest(base::ASCIIToUTF16("fo"), keyword_match,
-                   arraysize(keyword_match));
+                   base::size(keyword_match));
   }
 
   {
@@ -673,7 +673,7 @@
 
     SCOPED_TRACE("Duplicate url with multiple keywords");
     RunKeywordTest(base::ASCIIToUTF16("fo"), multiple_keyword,
-                   arraysize(multiple_keyword));
+                   base::size(multiple_keyword));
   }
 }
 
@@ -690,7 +690,7 @@
 
     SCOPED_TRACE("keyword match as usual");
     RunKeywordTest(base::ASCIIToUTF16("fo"), keyword_match,
-                   arraysize(keyword_match));
+                   base::size(keyword_match));
   }
 
   // The same result set with an input of "f" (versus "fo") should get
@@ -705,7 +705,7 @@
 
     SCOPED_TRACE("keyword exact match");
     RunKeywordTest(base::ASCIIToUTF16("f"), keyword_match,
-                   arraysize(keyword_match));
+                   base::size(keyword_match));
   }
 }
 
@@ -727,7 +727,7 @@
       { AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, "chrome..69i57" }
     };
     SCOPED_TRACE("One match");
-    RunAssistedQueryStatsTest(test_data, arraysize(test_data));
+    RunAssistedQueryStatsTest(test_data, base::size(test_data));
   }
 
   {
@@ -750,7 +750,7 @@
         "chrome.7.69i57j69i58j5l2j0l3j69i59" },
     };
     SCOPED_TRACE("Multiple matches");
-    RunAssistedQueryStatsTest(test_data, arraysize(test_data));
+    RunAssistedQueryStatsTest(test_data, base::size(test_data));
   }
 }
 
diff --git a/components/omnibox/browser/autocomplete_result_unittest.cc b/components/omnibox/browser/autocomplete_result_unittest.cc
index f3e0377b..18251657 100644
--- a/components/omnibox/browser/autocomplete_result_unittest.cc
+++ b/components/omnibox/browser/autocomplete_result_unittest.cc
@@ -10,7 +10,6 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
@@ -276,9 +275,9 @@
     { 1, 1, 399,  true },
   };
 
-  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, arraysize(last),
-                                                current, arraysize(current),
-                                                result, arraysize(result)));
+  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, base::size(last), current,
+                                                base::size(current), result,
+                                                base::size(result)));
 }
 
 // Tests that if the new results have a lower max relevance score than last,
@@ -302,9 +301,9 @@
     { 2, 1, 899,  true },
   };
 
-  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, arraysize(last),
-                                                current, arraysize(current),
-                                                result, arraysize(result)));
+  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, base::size(last), current,
+                                                base::size(current), result,
+                                                base::size(result)));
 }
 
 // Tests that matches are copied correctly from two distinct providers.
@@ -331,9 +330,9 @@
     { 4, 1, 499,  false  },
   };
 
-  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, arraysize(last),
-                                                current, arraysize(current),
-                                                result, arraysize(result)));
+  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, base::size(last), current,
+                                                base::size(current), result,
+                                                base::size(result)));
 }
 
 // Tests that matches are copied correctly from two distinct providers when
@@ -359,9 +358,9 @@
     { 7, 1, 500,  true  },
   };
 
-  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, arraysize(last),
-                                                current, arraysize(current),
-                                                result, arraysize(result)));
+  ASSERT_NO_FATAL_FAILURE(RunCopyOldMatchesTest(last, base::size(last), current,
+                                                base::size(current), result,
+                                                base::size(result)));
 }
 
 // Tests that matches with empty destination URLs aren't treated as duplicates
@@ -376,7 +375,7 @@
   };
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   matches[1].destination_url = GURL();
   matches[3].destination_url = GURL();
   matches[4].destination_url = GURL();
@@ -417,7 +416,7 @@
   // clang-format on
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   // These will get sorted up, but still removed.
   matches[3].type = AutocompleteMatchType::SEARCH_SUGGEST_TAIL;
   matches[4].type = AutocompleteMatchType::SEARCH_SUGGEST_TAIL;
@@ -450,7 +449,7 @@
   // clang-format on
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   // Make sure that even bad tail suggestions, if the only default match,
   // are kept.
   matches[0].type = AutocompleteMatchType::SEARCH_SUGGEST_TAIL;
@@ -485,7 +484,7 @@
   // clang-format on
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   // Make sure that even a bad non-tail default suggestion is kept.
   for (size_t i = 1; i < 5; ++i)
     matches[i].type = AutocompleteMatchType::SEARCH_SUGGEST_TAIL;
@@ -522,7 +521,7 @@
   // clang-format on
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   // These will not be removed.
   for (size_t i = 1; i < 5; ++i)
     matches[i].type = AutocompleteMatchType::SEARCH_SUGGEST_TAIL;
@@ -559,7 +558,7 @@
   };
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   matches[0].destination_url = GURL("http://www.foo.com/s?q=foo");
   matches[1].destination_url = GURL("http://www.foo.com/s?q=foo2");
   matches[2].destination_url = GURL("http://www.foo.com/s?q=foo&oq=f");
@@ -609,7 +608,7 @@
   };
 
   ACMatches matches;
-  PopulateAutocompleteMatches(data, arraysize(data), &matches);
+  PopulateAutocompleteMatches(data, base::size(data), &matches);
   matches[0].destination_url = GURL("http://www.foo.com/s?q=foo");
   matches[1].destination_url = GURL("http://www.foo.com/s?q=foo2");
   matches[2].destination_url = GURL("http://www.foo.com/s?q=foo&oq=f");
@@ -654,7 +653,7 @@
     { "http://history-title/", AutocompleteMatchType::HISTORY_TITLE },
     { "http://search-history/", AutocompleteMatchType::SEARCH_HISTORY },
   };
-  PopulateAutocompleteMatchesFromTestData(data, arraysize(data), &matches);
+  PopulateAutocompleteMatchesFromTestData(data, base::size(data), &matches);
 
   // Demote the search history match relevance score.
   matches.back().relevance = 500;
@@ -699,7 +698,7 @@
     { "http://search-url/", AutocompleteMatchType::SEARCH_SUGGEST },
     { "http://history-url/", AutocompleteMatchType::HISTORY_URL },
   };
-  PopulateAutocompleteMatchesFromTestData(data, arraysize(data), &matches);
+  PopulateAutocompleteMatchesFromTestData(data, base::size(data), &matches);
 
   // Add a rule demoting HISTORY_URL.
   {
@@ -751,7 +750,7 @@
     // is already a legal default match (which is the default from
     // PopulateAutocompleteMatches()).
     ACMatches matches;
-    PopulateAutocompleteMatches(data, arraysize(data), &matches);
+    PopulateAutocompleteMatches(data, base::size(data), &matches);
     AutocompleteInput input(base::ASCIIToUTF16("a"),
                             metrics::OmniboxEventProto::HOME_PAGE,
                             test_scheme_classifier);
@@ -764,7 +763,7 @@
   {
     // Check that reorder swaps up a result appropriately.
     ACMatches matches;
-    PopulateAutocompleteMatches(data, arraysize(data), &matches);
+    PopulateAutocompleteMatches(data, base::size(data), &matches);
     matches[0].allowed_to_be_default_match = false;
     matches[1].allowed_to_be_default_match = false;
     AutocompleteInput input(base::ASCIIToUTF16("a"),
@@ -972,7 +971,7 @@
   AutocompleteResult result;
   result.AppendMatches(AutocompleteInput(), matches);
   result.InlineTailPrefixes();
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     EXPECT_EQ(result.match_at(i)->contents,
               base::UTF8ToUTF16(cases[i].after_contents));
     EXPECT_TRUE(EqualClassifications(result.match_at(i)->contents_class,
diff --git a/components/omnibox/browser/bookmark_provider.cc b/components/omnibox/browser/bookmark_provider.cc
index 42802e63..7e21cffe 100644
--- a/components/omnibox/browser/bookmark_provider.cc
+++ b/components/omnibox/browser/bookmark_provider.cc
@@ -9,6 +9,7 @@
 #include <vector>
 
 #include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/trace_event/trace_event.h"
@@ -223,9 +224,9 @@
   const int kURLCountBoost[4] = { 0, 75, 125, 150 };
   std::vector<const BookmarkNode*> nodes;
   bookmark_model_->GetNodesByURL(url, &nodes);
-  DCHECK_GE(std::min(arraysize(kURLCountBoost), nodes.size()), 1U);
+  DCHECK_GE(std::min(base::size(kURLCountBoost), nodes.size()), 1U);
   relevance +=
-      kURLCountBoost[std::min(arraysize(kURLCountBoost), nodes.size()) - 1];
+      kURLCountBoost[std::min(base::size(kURLCountBoost), nodes.size()) - 1];
   relevance = std::min(kMaxBookmarkScore, relevance);
   return relevance;
 }
diff --git a/components/omnibox/browser/bookmark_provider_unittest.cc b/components/omnibox/browser/bookmark_provider_unittest.cc
index 8114a4b..c9cd5bbf 100644
--- a/components/omnibox/browser/bookmark_provider_unittest.cc
+++ b/components/omnibox/browser/bookmark_provider_unittest.cc
@@ -11,8 +11,8 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
@@ -192,7 +192,7 @@
 
   provider_ = new BookmarkProvider(provider_client_.get());
   const BookmarkNode* other_node = model_->other_node();
-  for (size_t i = 0; i < arraysize(bookmark_provider_test_data); ++i) {
+  for (size_t i = 0; i < base::size(bookmark_provider_test_data); ++i) {
     const BookmarksTestInfo& cur(bookmark_provider_test_data[i]);
     const GURL url(cur.url);
     model_->AddURL(other_node, other_node->child_count(),
@@ -271,7 +271,7 @@
     {"emptytitle",            1, {}},
   };
 
-  for (size_t i = 0; i < arraysize(query_data); ++i) {
+  for (size_t i = 0; i < base::size(query_data); ++i) {
     AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query),
                             metrics::OmniboxEventProto::OTHER,
                             TestSchemeClassifier());
@@ -350,7 +350,7 @@
                       "burning worms #2"}},  // not boosted
   };
 
-  for (size_t i = 0; i < arraysize(query_data); ++i) {
+  for (size_t i = 0; i < base::size(query_data); ++i) {
     AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query),
                             metrics::OmniboxEventProto::OTHER,
                             TestSchemeClassifier());
@@ -403,7 +403,7 @@
     // actually bookmarked.
   };
 
-  for (size_t i = 0; i < arraysize(query_data); ++i) {
+  for (size_t i = 0; i < base::size(query_data); ++i) {
     const std::string description = "for query=" + query_data[i].query +
         " and url=" + query_data[i].url;
     AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query),
@@ -448,7 +448,7 @@
       // clang-format on
   };
 
-  for (size_t i = 0; i < arraysize(query_data); ++i) {
+  for (size_t i = 0; i < base::size(query_data); ++i) {
     std::string description = "for query=" + query_data[i].query;
     AutocompleteInput input(base::ASCIIToUTF16(query_data[i].query),
                             metrics::OmniboxEventProto::OTHER,
diff --git a/components/omnibox/browser/builtin_provider_unittest.cc b/components/omnibox/browser/builtin_provider_unittest.cc
index a568b7f5..1893fd4 100644
--- a/components/omnibox/browser/builtin_provider_unittest.cc
+++ b/components/omnibox/browser/builtin_provider_unittest.cc
@@ -11,7 +11,7 @@
 #include <vector>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -172,7 +172,7 @@
     {ASCIIToUTF16("ChRoMe://"), {kURL1, kURL2, kURL3}},
   };
 
-  RunTest(typing_scheme_cases, arraysize(typing_scheme_cases));
+  RunTest(typing_scheme_cases, base::size(typing_scheme_cases));
 }
 
 TEST_F(BuiltinProviderTest, NonEmbedderURLs) {
@@ -190,7 +190,7 @@
     {ASCIIToUTF16("scheme://host/path?query#ref"), {}},
   };
 
-  RunTest(test_cases, arraysize(test_cases));
+  RunTest(test_cases, base::size(test_cases));
 }
 
 TEST_F(BuiltinProviderTest, EmbedderProvidedURLs) {
@@ -240,7 +240,7 @@
     {kEmbedder + kSep2 + kHostM3,              {kURLM2, kURLM3}},
   };
 
-  RunTest(test_cases, arraysize(test_cases));
+  RunTest(test_cases, base::size(test_cases));
 }
 
 TEST_F(BuiltinProviderTest, AboutBlank) {
@@ -295,7 +295,7 @@
     {kAboutBlank.substr(0, 9) + ASCIIToUTF16("#r"), {}},
   };
 
-  RunTest(about_blank_cases, arraysize(about_blank_cases));
+  RunTest(about_blank_cases, base::size(about_blank_cases));
 }
 
 TEST_F(BuiltinProviderTest, DoesNotSupportMatchesOnFocus) {
@@ -329,7 +329,7 @@
     {kSubpage + kPageTwo,                              {kURLTwo}},
   };
 
-  RunTest(settings_subpage_cases, arraysize(settings_subpage_cases));
+  RunTest(settings_subpage_cases, base::size(settings_subpage_cases));
 }
 
 TEST_F(BuiltinProviderTest, Inlining) {
@@ -426,7 +426,7 @@
   };
 
   ACMatches matches;
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf(
         "case %" PRIuS ": %s", i, base::UTF16ToUTF8(cases[i].input).c_str()));
     AutocompleteInput input(cases[i].input, metrics::OmniboxEventProto::OTHER,
diff --git a/components/omnibox/browser/history_quick_provider_performance_unittest.cc b/components/omnibox/browser/history_quick_provider_performance_unittest.cc
index 000a610..793ec31 100644
--- a/components/omnibox/browser/history_quick_provider_performance_unittest.cc
+++ b/components/omnibox/browser/history_quick_provider_performance_unittest.cc
@@ -8,9 +8,9 @@
 #include <random>
 #include <string>
 
-#include "base/macros.h"
 #include "base/no_destructor.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "components/history/core/browser/history_backend.h"
@@ -33,7 +33,7 @@
       "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,/=+?#";
   static base::NoDestructor<std::mt19937> engine;
   std::uniform_int_distribution<size_t> index_distribution(
-      0, arraysize(kSyms) - 2 /* trailing \0 */);
+      0, base::size(kSyms) - 2 /* trailing \0 */);
 
   std::string res;
   res.reserve(sym_count);
diff --git a/components/omnibox/browser/history_quick_provider_unittest.cc b/components/omnibox/browser/history_quick_provider_unittest.cc
index da7fedbe..1c5f4d3 100644
--- a/components/omnibox/browser/history_quick_provider_unittest.cc
+++ b/components/omnibox/browser/history_quick_provider_unittest.cc
@@ -14,8 +14,8 @@
 #include <vector>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "components/bookmarks/browser/bookmark_model.h"
@@ -490,7 +490,7 @@
   // increase that number in the future.  Regardless, we require the first
   // five offsets to be correct--in this example these cover at least one
   // occurrence of each term.
-  EXPECT_LE(contents_class.size(), arraysize(expected_offsets));
+  EXPECT_LE(contents_class.size(), base::size(expected_offsets));
   EXPECT_GE(contents_class.size(), 5u);
   for (size_t i = 0; i < contents_class.size(); ++i)
     EXPECT_EQ(expected_offsets[i], contents_class[i].offset);
diff --git a/components/omnibox/browser/history_url_provider_unittest.cc b/components/omnibox/browser/history_url_provider_unittest.cc
index 11cf2535..b6eda60 100644
--- a/components/omnibox/browser/history_url_provider_unittest.cc
+++ b/components/omnibox/browser/history_url_provider_unittest.cc
@@ -10,8 +10,8 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
@@ -288,7 +288,7 @@
   // case the time would be specifed in the test_db structure.
   const Time now = Time::Now();
 
-  for (size_t i = 0; i < arraysize(test_db); ++i) {
+  for (size_t i = 0; i < base::size(test_db); ++i) {
     const TestURLInfo& cur = test_db[i];
     const GURL current_url(cur.url);
     client_->GetHistoryService()->AddPageWithDetails(
@@ -391,7 +391,7 @@
     { "http://slashdot.org/", false }
   };
   RunTest(ASCIIToUTF16("slash"), std::string(), true, expected_nonsynth,
-          arraysize(expected_nonsynth));
+          base::size(expected_nonsynth));
 
   // Test that hosts get synthesized above less popular pages.
   const UrlAndLegalDefault expected_synth[] = {
@@ -399,7 +399,7 @@
     { "http://kerneltrap.org/not_very_popular.html", false }
   };
   RunTest(ASCIIToUTF16("kernel"), std::string(), true, expected_synth,
-          arraysize(expected_synth));
+          base::size(expected_synth));
 
   // Test that unpopular pages are ignored completely.
   RunTest(ASCIIToUTF16("fresh"), std::string(), true, nullptr, 0);
@@ -413,14 +413,14 @@
     { "http://synthesisatest.com/foo/", true }
   };
   RunTest(ASCIIToUTF16("synthesisa"), std::string(), false, expected_synthesisa,
-          arraysize(expected_synthesisa));
+          base::size(expected_synthesisa));
   EXPECT_LT(matches_.front().relevance, 1200);
   const UrlAndLegalDefault expected_synthesisb[] = {
     { "http://synthesisbtest.com/foo/", true },
     { "http://synthesisbtest.com/foo/bar.html", true }
   };
   RunTest(ASCIIToUTF16("synthesisb"), std::string(), false, expected_synthesisb,
-          arraysize(expected_synthesisb));
+          base::size(expected_synthesisb));
   EXPECT_GE(matches_.front().relevance, 1410);
 
   // Test that if we have a synthesized host that matches a suggestion, they
@@ -431,7 +431,7 @@
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("news"), std::string(), true,
                                   expected_combine,
-                                  arraysize(expected_combine)));
+                                  base::size(expected_combine)));
   // The title should also have gotten set properly on the host for the
   // synthesized one, since it was also in the results.
   EXPECT_EQ(ASCIIToUTF16("Google News"), matches_.front().description);
@@ -445,7 +445,7 @@
     { "http://foo.com/dir/", false }
   };
   RunTest(ASCIIToUTF16("foo"), std::string(), true, short_1,
-          arraysize(short_1));
+          base::size(short_1));
 
   // When the user types the whole host, make sure we don't get two results for
   // it.
@@ -456,9 +456,9 @@
     { "http://foo.com/dir/another/", false }
   };
   RunTest(ASCIIToUTF16("foo.com"), std::string(), true, short_2,
-          arraysize(short_2));
+          base::size(short_2));
   RunTest(ASCIIToUTF16("foo.com/"), std::string(), true, short_2,
-          arraysize(short_2));
+          base::size(short_2));
 
   // The filename is the second best of the foo.com* entries, but there is a
   // shorter URL that's "good enough".  The host doesn't match the user input
@@ -470,7 +470,7 @@
     { "http://foo.com/dir/", false }
   };
   RunTest(ASCIIToUTF16("foo.com/d"), std::string(), true, short_3,
-          arraysize(short_3));
+          base::size(short_3));
   // If prevent_inline_autocomplete is false, we won't bother creating the
   // URL-what-you-typed match because we have promoted inline autocompletions.
   const UrlAndLegalDefault short_3_allow_inline[] = {
@@ -479,7 +479,7 @@
     { "http://foo.com/dir/", true }
   };
   RunTest(ASCIIToUTF16("foo.com/d"), std::string(), false, short_3_allow_inline,
-          arraysize(short_3_allow_inline));
+          base::size(short_3_allow_inline));
 
   // We shouldn't promote shorter URLs than the best if they're not good
   // enough.
@@ -489,7 +489,7 @@
     { "http://foo.com/dir/another/again/", false }
   };
   RunTest(ASCIIToUTF16("foo.com/dir/another/a"), std::string(), true, short_4,
-          arraysize(short_4));
+          base::size(short_4));
   // If prevent_inline_autocomplete is false, we won't bother creating the
   // URL-what-you-typed match because we have promoted inline autocompletions.
   const UrlAndLegalDefault short_4_allow_inline[] = {
@@ -497,7 +497,7 @@
     { "http://foo.com/dir/another/again/", true }
   };
   RunTest(ASCIIToUTF16("foo.com/dir/another/a"), std::string(), false,
-          short_4_allow_inline, arraysize(short_4_allow_inline));
+          short_4_allow_inline, base::size(short_4_allow_inline));
 
   // Exact matches should always be best no matter how much more another match
   // has been typed.
@@ -514,9 +514,9 @@
   // Note that there is an http://g/ URL that is marked as hidden.  It shouldn't
   // show up at all.  This test implicitly tests this fact too.
   RunTest(ASCIIToUTF16("g"), std::string(), false, short_5a,
-          arraysize(short_5a));
+          base::size(short_5a));
   RunTest(ASCIIToUTF16("go"), std::string(), false, short_5b,
-          arraysize(short_5b));
+          base::size(short_5b));
 }
 
 TEST_F(HistoryURLProviderTest, CullRedirects) {
@@ -532,7 +532,7 @@
     {"http://redirects/B", 20},
     {"http://redirects/C", 10}
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     client_->GetHistoryService()->AddPageWithDetails(
         GURL(test_cases[i].url), ASCIIToUTF16("Title"), test_cases[i].count,
         test_cases[i].count, Time::Now(), false, history::SOURCE_BROWSED);
@@ -559,7 +559,7 @@
     { base::UTF16ToUTF8(typing), true }
   };
   RunTest(typing, std::string(), true, expected_results,
-          arraysize(expected_results));
+          base::size(expected_results));
 
   // If prevent_inline_autocomplete is false, we won't bother creating the
   // URL-what-you-typed match because we have promoted inline autocompletions.
@@ -569,7 +569,7 @@
     { test_cases[0].url, true }
   };
   RunTest(typing, std::string(), false, expected_results_allow_inlining,
-          arraysize(expected_results_allow_inlining));
+          base::size(expected_results_allow_inlining));
 }
 
 TEST_F(HistoryURLProviderTestNoSearchProvider, WhatYouTypedNoSearchProvider) {
@@ -580,7 +580,7 @@
     { "http://wytmatch/", true }
   };
   RunTest(ASCIIToUTF16("wytmatch"), std::string(), false, results_1,
-          arraysize(results_1));
+          base::size(results_1));
 
   RunTest(ASCIIToUTF16("wytmatch foo bar"), std::string(), false, nullptr, 0);
   RunTest(ASCIIToUTF16("wytmatch+foo+bar"), std::string(), false, nullptr, 0);
@@ -588,8 +588,8 @@
   const UrlAndLegalDefault results_2[] = {
     { "http://wytmatch+foo+bar.com/", true }
   };
-  RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), std::string(), false,
-          results_2, arraysize(results_2));
+  RunTest(ASCIIToUTF16("wytmatch+foo+bar.com"), std::string(), false, results_2,
+          base::size(results_2));
 }
 
 TEST_F(HistoryURLProviderTest, WhatYouTyped) {
@@ -604,37 +604,37 @@
     { "http://www.wytmatch.com/", true }
   };
   RunTest(ASCIIToUTF16("wytmatch"), "com", false, results_1,
-          arraysize(results_1));
+          base::size(results_1));
 
   const UrlAndLegalDefault results_2[] = {
     { "http://wytmatch%20foo%20bar/", false }
   };
   RunTest(ASCIIToUTF16("http://wytmatch foo bar"), std::string(), false,
-          results_2, arraysize(results_2));
+          results_2, base::size(results_2));
 
   const UrlAndLegalDefault results_3[] = {
     { "https://wytmatch%20foo%20bar/", false }
   };
   RunTest(ASCIIToUTF16("https://wytmatch foo bar"), std::string(), false,
-          results_3, arraysize(results_3));
+          results_3, base::size(results_3));
 
   const UrlAndLegalDefault results_4[] = {{"https://wytih/", true},
                                           {"https://www.wytih/file", true},
                                           {"ftp://wytih/file", true},
                                           {"https://www.wytih/page", true}};
   RunTest(ASCIIToUTF16("wytih"), std::string(), false, results_4,
-          arraysize(results_4));
+          base::size(results_4));
 
   const UrlAndLegalDefault results_5[] = {{"https://www.wytih/", true},
                                           {"https://www.wytih/file", true},
                                           {"https://www.wytih/page", true}};
   RunTest(ASCIIToUTF16("www.wytih"), std::string(), false, results_5,
-          arraysize(results_5));
+          base::size(results_5));
 
   const UrlAndLegalDefault results_6[] = {{"ftp://wytih/file", true},
                                           {"https://www.wytih/file", true}};
   RunTest(ASCIIToUTF16("wytih/file"), std::string(), false, results_6,
-          arraysize(results_6));
+          base::size(results_6));
 }
 
 TEST_F(HistoryURLProviderTest, Fixup) {
@@ -646,7 +646,7 @@
     { "http://%EF%BD%A5@s/", false }
   };
   RunTest(base::WideToUTF16(L"\uff65@s"), std::string(), false, fixup_crash,
-          arraysize(fixup_crash));
+          base::size(fixup_crash));
   RunTest(base::WideToUTF16(L"\u2015\u2015@ \uff7c"), std::string(), false,
           nullptr, 0);
 
@@ -656,8 +656,8 @@
   const UrlAndLegalDefault fixup_1[] = {
     { "file:///C:/foo.txt", true }
   };
-  ASSERT_NO_FATAL_FAILURE(RunTest(input_1, std::string(), false, fixup_1,
-                                  arraysize(fixup_1)));
+  ASSERT_NO_FATAL_FAILURE(
+      RunTest(input_1, std::string(), false, fixup_1, base::size(fixup_1)));
   EXPECT_EQ(ASCIIToUTF16("///C:/foo.txt"),
             matches_.front().inline_autocompletion);
 
@@ -669,8 +669,8 @@
     { "http://bogussite.com/b", true },
     { "http://bogussite.com/c", true }
   };
-  ASSERT_NO_FATAL_FAILURE(RunTest(input_2, std::string(), false, fixup_2,
-                                  arraysize(fixup_2)));
+  ASSERT_NO_FATAL_FAILURE(
+      RunTest(input_2, std::string(), false, fixup_2, base::size(fixup_2)));
   EXPECT_EQ(ASCIIToUTF16("/bogussite.com/a"),
             matches_.front().inline_autocompletion);
 
@@ -679,7 +679,7 @@
   const UrlAndLegalDefault fixup_3[] = {
     { "http://www.56.com/", true }
   };
-  RunTest(ASCIIToUTF16("56"), "com", true, fixup_3, arraysize(fixup_3));
+  RunTest(ASCIIToUTF16("56"), "com", true, fixup_3, base::size(fixup_3));
 
   // An input looks like a IP address like "127.0.0.1" should result in
   // "http://127.0.0.1/".
@@ -687,14 +687,14 @@
     { "http://127.0.0.1/", true }
   };
   RunTest(ASCIIToUTF16("127.0.0.1"), std::string(), false, fixup_4,
-          arraysize(fixup_4));
+          base::size(fixup_4));
 
   // An number "17173" should result in "http://www.17173.com/" in db.
   const UrlAndLegalDefault fixup_5[] = {
     { "http://www.17173.com/", true }
   };
   RunTest(ASCIIToUTF16("17173"), std::string(), false, fixup_5,
-          arraysize(fixup_5));
+          base::size(fixup_5));
 }
 
 // Make sure the results for the input 'p' don't change between the first and
@@ -732,13 +732,13 @@
     { "http://test.com/", true }
   };
   RunTest(ASCIIToUTF16("test.com"), std::string(), false, navigation_1,
-          arraysize(navigation_1));
+          base::size(navigation_1));
 
   UrlAndLegalDefault navigation_2[] = {
     { "http://slash/", false }
   };
   RunTest(ASCIIToUTF16("slash"), std::string(), false, navigation_2,
-          arraysize(navigation_2));
+          base::size(navigation_2));
 
   RunTest(ASCIIToUTF16("this is a query"), std::string(), false, nullptr, 0);
 }
@@ -767,7 +767,7 @@
     { "http://user@foo.com/", false }
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("user@foo.com"), std::string(),
-                                  false, expected, arraysize(expected)));
+                                  false, expected, base::size(expected)));
   EXPECT_LE(1200, matches_[0].relevance);
   EXPECT_LT(matches_[0].relevance, 1210);
 }
@@ -787,7 +787,7 @@
     { "gooey/a", 1400, true },
     { "gooey/a b", 1400, true },
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(test_cases[i].input);
     if (test_cases[i].relevance == 0) {
       RunTest(ASCIIToUTF16(test_cases[i].input), std::string(), false, nullptr,
@@ -797,7 +797,8 @@
           {url_formatter::FixupURL(test_cases[i].input, std::string()).spec(),
            test_cases[i].allowed_to_be_default_match}};
       ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input),
-                              std::string(), false, output, arraysize(output)));
+                                      std::string(), false, output,
+                                      base::size(output)));
       // Actual relevance should be at least what test_cases expects and
       // and no more than 10 more.
       EXPECT_LE(test_cases[i].relevance, matches_[0].relevance);
@@ -816,7 +817,7 @@
     { "http://intra/two", true }
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/t"), std::string(), false,
-                                  expected1, arraysize(expected1)));
+                                  expected1, base::size(expected1)));
   EXPECT_LE(1410, matches_[0].relevance);
   EXPECT_LT(matches_[0].relevance, 1420);
   // It uses the default scoring.
@@ -827,7 +828,7 @@
     { "http://moo/bar", true }
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("moo/b"), std::string(), false,
-                                  expected2, arraysize(expected2)));
+                                  expected2, base::size(expected2)));
   // The url what you typed match should be around 1400, otherwise the
   // search what you typed match is going to be first.
   EXPECT_LE(1400, matches_[0].relevance);
@@ -837,19 +838,19 @@
                                           {"http://intra/one", true},
                                           {"http://intra/two", true}};
   RunTest(ASCIIToUTF16("intra"), std::string(), false, expected3,
-          arraysize(expected3));
+          base::size(expected3));
 
   const UrlAndLegalDefault expected4[] = {{"http://intra/three", true},
                                           {"http://intra/one", true},
                                           {"http://intra/two", true}};
   RunTest(ASCIIToUTF16("intra/"), std::string(), false, expected4,
-          arraysize(expected4));
+          base::size(expected4));
 
   const UrlAndLegalDefault expected5[] = {
     { "http://intra/one", true }
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/o"), std::string(), false,
-                                  expected5, arraysize(expected5)));
+                                  expected5, base::size(expected5)));
   EXPECT_LE(1410, matches_[0].relevance);
   EXPECT_LT(matches_[0].relevance, 1420);
 
@@ -857,7 +858,7 @@
     { "http://intra/x", true }
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("intra/x"), std::string(), false,
-                                  expected6, arraysize(expected6)));
+                                  expected6, base::size(expected6)));
   EXPECT_LE(1400, matches_[0].relevance);
   EXPECT_LT(matches_[0].relevance, 1410);
 
@@ -866,13 +867,13 @@
   };
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("typedhost/untypedpath"),
                                   std::string(), false, expected7,
-                                  arraysize(expected7)));
+                                  base::size(expected7)));
   EXPECT_LE(1400, matches_[0].relevance);
   EXPECT_LT(matches_[0].relevance, 1410);
 
   const UrlAndLegalDefault expected8[] = {{"https://www.prefixintra/x", true}};
   ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16("prefixintra/x"), std::string(),
-                                  false, expected8, arraysize(expected8)));
+                                  false, expected8, base::size(expected8)));
 }
 
 TEST_F(HistoryURLProviderTest, CrashDueToFixup) {
@@ -882,7 +883,7 @@
     "\\@st",
     "view-source:x",
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     AutocompleteInput input(ASCIIToUTF16(test_cases[i]),
                             metrics::OmniboxEventProto::OTHER,
                             TestSchemeClassifier());
@@ -908,21 +909,21 @@
     { "http://puny.xn--h2by8byc123p.in/", true },
   };
   RunTest(ASCIIToUTF16("pun"), std::string(), false, expected1_true,
-          arraysize(expected1_true));
+          base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny."), std::string(), false, expected1_true,
-          arraysize(expected1_true));
+          base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny.x"), std::string(), false, expected1_true,
-          arraysize(expected1_true));
+          base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny.xn"), std::string(), false, expected1_true,
-          arraysize(expected1_true));
+          base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny.xn--"), std::string(), false, expected1_true,
-          arraysize(expected1_true));
+          base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny.xn--h2"), std::string(), false, expected1_true,
-          arraysize(expected1_true));
+          base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny.xn--h2by8byc123p"), std::string(), false,
-          expected1_true, arraysize(expected1_true));
+          expected1_true, base::size(expected1_true));
   RunTest(ASCIIToUTF16("puny.xn--h2by8byc123p."), std::string(), false,
-          expected1_true, arraysize(expected1_true));
+          expected1_true, base::size(expected1_true));
 
   // When the punycode part of the URL is rendered as international characters,
   // this match should not be allowed to be the default match if the inline
@@ -934,21 +935,21 @@
     { "http://two_puny.xn--1lq90ic7f1rc.cn/", false },
   };
   RunTest(ASCIIToUTF16("two"), std::string(), false, expected2_true,
-          arraysize(expected2_true));
+          base::size(expected2_true));
   RunTest(ASCIIToUTF16("two_puny."), std::string(), false, expected2_true,
-          arraysize(expected2_true));
+          base::size(expected2_true));
   RunTest(ASCIIToUTF16("two_puny.x"), std::string(), false, expected2_false,
-          arraysize(expected2_false));
+          base::size(expected2_false));
   RunTest(ASCIIToUTF16("two_puny.xn"), std::string(), false, expected2_false,
-          arraysize(expected2_false));
+          base::size(expected2_false));
   RunTest(ASCIIToUTF16("two_puny.xn--"), std::string(), false, expected2_false,
-          arraysize(expected2_false));
+          base::size(expected2_false));
   RunTest(ASCIIToUTF16("two_puny.xn--1l"), std::string(), false,
-          expected2_false, arraysize(expected2_false));
+          expected2_false, base::size(expected2_false));
   RunTest(ASCIIToUTF16("two_puny.xn--1lq90ic7f1rc"), std::string(), false,
-          expected2_true, arraysize(expected2_true));
+          expected2_true, base::size(expected2_true));
   RunTest(ASCIIToUTF16("two_puny.xn--1lq90ic7f1rc."), std::string(), false,
-          expected2_true, arraysize(expected2_true));
+          expected2_true, base::size(expected2_true));
 }
 
 TEST_F(HistoryURLProviderTest, CullSearchResults) {
@@ -975,7 +976,7 @@
     {"https://testsearch.com/?q=foobar", 20},
     {"http://foobar.com/", 10}
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     client_->GetHistoryService()->AddPageWithDetails(
         GURL(test_cases[i].url), base::UTF8ToUTF16("Title"),
         test_cases[i].count, test_cases[i].count, Time::Now(), false,
@@ -987,14 +988,16 @@
     { test_cases[2].url, false }
   };
   RunTest(ASCIIToUTF16("foobar"), std::string(), true,
-      expected_when_searching_query, arraysize(expected_when_searching_query));
+          expected_when_searching_query,
+          base::size(expected_when_searching_query));
 
   // We should not see search URLs when typing the search engine name.
   const UrlAndLegalDefault expected_when_searching_site[] = {
     { test_cases[0].url, false }
   };
   RunTest(ASCIIToUTF16("testsearch"), std::string(), true,
-      expected_when_searching_site, arraysize(expected_when_searching_site));
+          expected_when_searching_site,
+          base::size(expected_when_searching_site));
 }
 
 TEST_F(HistoryURLProviderTest, SuggestExactInput) {
@@ -1054,7 +1057,7 @@
     { "mailto://a@b.com", false,
       "mailto://a@b.com", {0, npos, npos}, 0 },
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(testing::Message() << "Index " << i << " input: "
                                     << test_cases[i].input << ", trim_http: "
                                     << test_cases[i].trim_http);
@@ -1159,7 +1162,7 @@
        max_1100_visit_typed_decays,
        {{"7.com/5", 1203, 1203}, {"7.com/5a", 1202, 50}, {nullptr, 0, 0}}},
   };
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(test_cases[i].input);
     UrlAndLegalDefault output[kMaxMatches];
     int max_matches;
diff --git a/components/omnibox/browser/in_memory_url_index_types_unittest.cc b/components/omnibox/browser/in_memory_url_index_types_unittest.cc
index c8788ffb..52d05d4 100644
--- a/components/omnibox/browser/in_memory_url_index_types_unittest.cc
+++ b/components/omnibox/browser/in_memory_url_index_types_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -50,7 +50,7 @@
   EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[6]);
   // Verify the word starts.
   size_t expected_starts_a[] = {0, 7, 11, 18, 23, 31, 35};
-  EXPECT_TRUE(IntArraysEqual(expected_starts_a, arraysize(expected_starts_a),
+  EXPECT_TRUE(IntArraysEqual(expected_starts_a, base::size(expected_starts_a),
                              actual_starts_a));
 
   WordStarts actual_starts_b;
@@ -62,7 +62,7 @@
   EXPECT_EQ(UTF8ToUTF16("the"), string_vec[3]);
   EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[4]);
   size_t expected_starts_b[] = {0, 7, 23, 31, 35};
-  EXPECT_TRUE(IntArraysEqual(expected_starts_b, arraysize(expected_starts_b),
+  EXPECT_TRUE(IntArraysEqual(expected_starts_b, base::size(expected_starts_b),
                              actual_starts_b));
 
   base::string16 string_c(base::ASCIIToUTF16(
@@ -72,7 +72,7 @@
   ASSERT_EQ(8U, string_vec.size());
   // Note that we stop collecting words and word starts at kMaxSignificantChars.
   size_t expected_starts_c[] = {1, 7, 16, 22, 32, 43, 52, 55};
-  EXPECT_TRUE(IntArraysEqual(expected_starts_c, arraysize(expected_starts_c),
+  EXPECT_TRUE(IntArraysEqual(expected_starts_c, base::size(expected_starts_c),
                              actual_starts_c));
 
   base::string16 string_d(
@@ -88,7 +88,7 @@
   EXPECT_EQ(UTF8ToUTF16("the"), string_vec[5]);
   EXPECT_EQ(UTF8ToUTF16("brammy"), string_vec[6]);
   size_t expected_starts_d[] = {0, 7, 11, 18, 22, 29, 33};
-  EXPECT_TRUE(IntArraysEqual(expected_starts_d, arraysize(expected_starts_d),
+  EXPECT_TRUE(IntArraysEqual(expected_starts_d, base::size(expected_starts_d),
                              actual_starts_d));
 
   // Test String16SetFromString16
@@ -104,7 +104,7 @@
   EXPECT_TRUE(string_set.find(UTF8ToUTF16("search")) != string_set.end());
   EXPECT_TRUE(string_set.find(UTF8ToUTF16("web")) != string_set.end());
   size_t expected_starts_e[] = {0, 7, 11, 18, 22, 29, 36, 40};
-  EXPECT_TRUE(IntArraysEqual(expected_starts_e, arraysize(expected_starts_e),
+  EXPECT_TRUE(IntArraysEqual(expected_starts_e, base::size(expected_starts_e),
                              actual_starts_e));
 
   // Test SortMatches and DeoverlapMatches.
@@ -136,8 +136,8 @@
   TermMatches matches_g = MatchTermInString(
       UTF8ToUTF16("x"), UTF8ToUTF16("axbxcxdxex fxgx/hxixjx.kx"), 123);
   const size_t expected_offsets[] = { 1, 3, 5, 7, 9, 12, 14, 17, 19, 21, 24 };
-  ASSERT_EQ(arraysize(expected_offsets), matches_g.size());
-  for (size_t i = 0; i < arraysize(expected_offsets); ++i)
+  ASSERT_EQ(base::size(expected_offsets), matches_g.size());
+  for (size_t i = 0; i < base::size(expected_offsets); ++i)
     EXPECT_EQ(expected_offsets[i], matches_g[i].offset);
 }
 
@@ -151,7 +151,7 @@
   matches_a.push_back(TermMatch(4, 14, 5));
   std::vector<size_t> offsets = OffsetsFromTermMatches(matches_a);
   const size_t expected_offsets_a[] = {1, 3, 4, 7, 9, 10, 10, 11, 14, 19};
-  ASSERT_EQ(offsets.size(), arraysize(expected_offsets_a));
+  ASSERT_EQ(offsets.size(), base::size(expected_offsets_a));
   for (size_t i = 0; i < offsets.size(); ++i)
     EXPECT_EQ(expected_offsets_a[i], offsets[i]);
 
@@ -159,7 +159,7 @@
   offsets[4] = base::string16::npos;  // offset of third term
   TermMatches matches_b = ReplaceOffsetsInTermMatches(matches_a, offsets);
   const size_t expected_offsets_b[] = {1, 4, 10, 14};
-  ASSERT_EQ(arraysize(expected_offsets_b), matches_b.size());
+  ASSERT_EQ(base::size(expected_offsets_b), matches_b.size());
   for (size_t i = 0; i < matches_b.size(); ++i)
     EXPECT_EQ(expected_offsets_b[i], matches_b[i].offset);
 }
diff --git a/components/omnibox/browser/in_memory_url_index_unittest.cc b/components/omnibox/browser/in_memory_url_index_unittest.cc
index 70d81c2..5b5f5cf 100644
--- a/components/omnibox/browser/in_memory_url_index_unittest.cc
+++ b/components/omnibox/browser/in_memory_url_index_unittest.cc
@@ -16,9 +16,9 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/i18n/case_conversion.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -278,7 +278,7 @@
 
   // Set up a simple template URL service with a default search engine.
   template_url_service_ = std::make_unique<TemplateURLService>(
-      kTemplateURLData, arraysize(kTemplateURLData));
+      kTemplateURLData, base::size(kTemplateURLData));
   TemplateURL* template_url = template_url_service_->GetTemplateURLForKeyword(
       base::ASCIIToUTF16(kDefaultTemplateURLKeyword));
   template_url_service_->SetUserSelectedDefaultSearchProvider(template_url);
@@ -1094,7 +1094,7 @@
   };
 
   const SchemeSet& whitelist(scheme_whitelist());
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     GURL url(data[i].url_spec);
     EXPECT_EQ(data[i].expected_is_whitelisted,
               URLIndexPrivateData::URLSchemeIsWhitelisted(url, whitelist));
@@ -1342,7 +1342,7 @@
                     {"abcd :", 5, 2, {0, 1, kInvalid}},
                     {"abcd :", 2, 3, {0, 0, 1}}};
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(testing::Message()
                  << "search_string = " << test_cases[i].search_string
                  << ", cursor_position = " << test_cases[i].cursor_position);
@@ -1382,7 +1382,7 @@
                     {"abcd_", 4, 2, {0, 1, kInvalid}},
                     {"ab_cd", 5, 1, {0, kInvalid, kInvalid}}};
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(testing::Message()
                  << "search_string = " << test_cases[i].search_string
                  << ", cursor_position = " << test_cases[i].cursor_position);
diff --git a/components/omnibox/browser/keyword_provider_unittest.cc b/components/omnibox/browser/keyword_provider_unittest.cc
index 9b4418cb..9e51255 100644
--- a/components/omnibox/browser/keyword_provider_unittest.cc
+++ b/components/omnibox/browser/keyword_provider_unittest.cc
@@ -11,8 +11,8 @@
 #include <utility>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "components/omnibox/browser/autocomplete_match.h"
@@ -133,7 +133,7 @@
 void KeywordProviderTest::SetUpClientAndKeywordProvider() {
   client_.reset(new MockAutocompleteProviderClient());
   client_->set_template_url_service(
-      std::make_unique<TemplateURLService>(kTestData, arraysize(kTestData)));
+      std::make_unique<TemplateURLService>(kTestData, base::size(kTestData)));
   kw_provider_ = new KeywordProvider(client_.get(), nullptr);
 }
 
@@ -267,7 +267,7 @@
   };
 
   SetUpClientAndKeywordProvider();
-  RunTest<base::string16>(edit_cases, arraysize(edit_cases),
+  RunTest<base::string16>(edit_cases, base::size(edit_cases),
                           &AutocompleteMatch::fill_into_edit);
 }
 
@@ -318,7 +318,7 @@
       OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A");
 
   SetUpClientAndKeywordProvider();
-  RunTest<base::string16>(edit_cases, arraysize(edit_cases),
+  RunTest<base::string16>(edit_cases, base::size(edit_cases),
                           &AutocompleteMatch::fill_into_edit);
 }
 
@@ -363,7 +363,7 @@
       OmniboxFieldTrial::kBundledExperimentFieldTrialName, "A");
 
   SetUpClientAndKeywordProvider();
-  RunTest<base::string16>(edit_cases, arraysize(edit_cases),
+  RunTest<base::string16>(edit_cases, base::size(edit_cases),
                           &AutocompleteMatch::fill_into_edit);
 }
 
@@ -401,7 +401,7 @@
   };
 
   SetUpClientAndKeywordProvider();
-  RunTest<GURL>(url_cases, arraysize(url_cases),
+  RunTest<GURL>(url_cases, base::size(url_cases),
                 &AutocompleteMatch::destination_url);
 }
 
@@ -452,7 +452,7 @@
   };
 
   SetUpClientAndKeywordProvider();
-  RunTest<base::string16>(contents_cases, arraysize(contents_cases),
+  RunTest<base::string16>(contents_cases, base::size(contents_cases),
                           &AutocompleteMatch::contents);
 }
 
@@ -577,7 +577,7 @@
       base::string16::npos },
   };
   SetUpClientAndKeywordProvider();
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     AutocompleteInput input(
         ASCIIToUTF16(cases[i].text), cases[i].cursor_position,
         metrics::OmniboxEventProto::OTHER, TestingSchemeClassifier());
@@ -608,7 +608,7 @@
   };
 
   SetUpClientAndKeywordProvider();
-  RunTest<GURL>(url_cases, arraysize(url_cases),
+  RunTest<GURL>(url_cases, base::size(url_cases),
                 &AutocompleteMatch::destination_url);
 }
 
diff --git a/components/omnibox/browser/omnibox_edit_model_unittest.cc b/components/omnibox/browser/omnibox_edit_model_unittest.cc
index be488abe..084051a 100644
--- a/components/omnibox/browser/omnibox_edit_model_unittest.cc
+++ b/components/omnibox/browser/omnibox_edit_model_unittest.cc
@@ -9,6 +9,7 @@
 #include <memory>
 #include <string>
 
+#include "base/stl_util.h"
 #include "base/test/scoped_feature_list.h"
 #include "base/test/scoped_task_environment.h"
 #include "build/build_config.h"
@@ -134,7 +135,7 @@
        "https://a.de/b", "a.de/b"},
   };
 
-  for (size_t i = 0; i < arraysize(input); ++i) {
+  for (size_t i = 0; i < base::size(input); ++i) {
     location_bar_model()->set_formatted_full_url(
         base::ASCIIToUTF16(input[i].url_for_editing));
     location_bar_model()->set_url_for_display(
diff --git a/components/omnibox/browser/omnibox_view_unittest.cc b/components/omnibox/browser/omnibox_view_unittest.cc
index 30f20c4..b56abfe3 100644
--- a/components/omnibox/browser/omnibox_view_unittest.cc
+++ b/components/omnibox/browser/omnibox_view_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -94,7 +94,7 @@
       "alert(5)"   // Embedded control characters unsafe.
   };
 
-  for (size_t i = 0; i < arraysize(urls); i++) {
+  for (size_t i = 0; i < base::size(urls); i++) {
     EXPECT_EQ(ASCIIToUTF16(expecteds[i]),
               OmniboxView::StripJavascriptSchemas(base::UTF8ToUTF16(urls[i])));
   }
diff --git a/components/omnibox/browser/shortcuts_backend_unittest.cc b/components/omnibox/browser/shortcuts_backend_unittest.cc
index 5304de8..b64f98f 100644
--- a/components/omnibox/browser/shortcuts_backend_unittest.cc
+++ b/components/omnibox/browser/shortcuts_backend_unittest.cc
@@ -9,8 +9,8 @@
 #include <memory>
 
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
@@ -200,7 +200,7 @@
       "",        "",         AutocompleteMatchType::SEARCH_HISTORY },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     ShortcutsDatabase::Shortcut::MatchCore match_core(MatchCoreForTesting(
         std::string(), cases[i].input_contents_class,
         cases[i].input_description_class, cases[i].input_type));
diff --git a/components/omnibox/browser/shortcuts_database_unittest.cc b/components/omnibox/browser/shortcuts_database_unittest.cc
index d17b796..ec5389a 100644
--- a/components/omnibox/browser/shortcuts_database_unittest.cc
+++ b/components/omnibox/browser/shortcuts_database_unittest.cc
@@ -8,8 +8,8 @@
 
 #include "base/files/scoped_temp_dir.h"
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
@@ -140,9 +140,9 @@
 
 void ShortcutsDatabaseTest::AddAll() {
   ClearDB();
-  for (size_t i = 0; i < arraysize(shortcut_test_db); ++i)
+  for (size_t i = 0; i < base::size(shortcut_test_db); ++i)
     db_->AddShortcut(ShortcutFromTestInfo(shortcut_test_db[i]));
-  EXPECT_EQ(arraysize(shortcut_test_db), CountRecords());
+  EXPECT_EQ(base::size(shortcut_test_db), CountRecords());
 }
 
 // Actual tests ---------------------------------------------------------------
@@ -178,7 +178,7 @@
   shortcut_ids.push_back(shortcut_test_db[0].guid);
   shortcut_ids.push_back(shortcut_test_db[2].guid);
   EXPECT_TRUE(db_->DeleteShortcutsWithIDs(shortcut_ids));
-  EXPECT_EQ(arraysize(shortcut_test_db) - 2, CountRecords());
+  EXPECT_EQ(base::size(shortcut_test_db) - 2, CountRecords());
 
   ShortcutsDatabase::GuidToShortcutMap shortcuts;
   db_->LoadShortcuts(&shortcuts);
@@ -197,7 +197,7 @@
   AddAll();
 
   EXPECT_TRUE(db_->DeleteShortcutsWithURL("http://slashdot.org/"));
-  EXPECT_EQ(arraysize(shortcut_test_db) - 2, CountRecords());
+  EXPECT_EQ(base::size(shortcut_test_db) - 2, CountRecords());
 
   ShortcutsDatabase::GuidToShortcutMap shortcuts;
   db_->LoadShortcuts(&shortcuts);
@@ -216,7 +216,7 @@
   AddAll();
   ShortcutsDatabase::GuidToShortcutMap shortcuts;
   db_->LoadShortcuts(&shortcuts);
-  EXPECT_EQ(arraysize(shortcut_test_db), shortcuts.size());
+  EXPECT_EQ(base::size(shortcut_test_db), shortcuts.size());
   EXPECT_TRUE(db_->DeleteAllShortcuts());
   db_->LoadShortcuts(&shortcuts);
   EXPECT_EQ(0U, shortcuts.size());
diff --git a/components/omnibox/browser/shortcuts_provider_unittest.cc b/components/omnibox/browser/shortcuts_provider_unittest.cc
index b08fda7..ae812c0b 100644
--- a/components/omnibox/browser/shortcuts_provider_unittest.cc
+++ b/components/omnibox/browser/shortcuts_provider_unittest.cc
@@ -15,9 +15,9 @@
 #include <vector>
 
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
@@ -192,7 +192,7 @@
   provider_ = base::MakeRefCounted<ShortcutsProvider>(client_.get());
   PopulateShortcutsBackendWithTestData(client_->GetShortcutsBackend(),
                                        shortcut_test_db,
-                                       arraysize(shortcut_test_db));
+                                       base::size(shortcut_test_db));
 }
 
 void ShortcutsProviderTest::TearDown() {
@@ -509,7 +509,7 @@
   size_t original_shortcuts_count = backend->shortcuts_map().size();
 
   PopulateShortcutsBackendWithTestData(backend, shortcuts_to_test_delete,
-                                       arraysize(shortcuts_to_test_delete));
+                                       base::size(shortcuts_to_test_delete));
 
   EXPECT_EQ(original_shortcuts_count + 4, backend->shortcuts_map().size());
   EXPECT_FALSE(backend->shortcuts_map().end() ==
diff --git a/components/omnibox/browser/test_scheme_classifier.cc b/components/omnibox/browser/test_scheme_classifier.cc
index 3268364..eee01d62 100644
--- a/components/omnibox/browser/test_scheme_classifier.cc
+++ b/components/omnibox/browser/test_scheme_classifier.cc
@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/omnibox/browser/test_scheme_classifier.h"
 #include "net/url_request/url_request.h"
 #include "third_party/metrics_proto/omnibox_input_type.pb.h"
@@ -23,7 +23,7 @@
     url::kFileScheme, url::kAboutScheme, url::kFtpScheme, url::kBlobScheme,
     url::kFileSystemScheme, "view-source", "javascript", "chrome", "chrome-ui",
   };
-  for (size_t i = 0; i < arraysize(kKnownURLSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kKnownURLSchemes); ++i) {
     if (scheme == kKnownURLSchemes[i])
       return metrics::OmniboxInputType::URL;
   }
diff --git a/components/open_from_clipboard/clipboard_recent_content_generic_unittest.cc b/components/open_from_clipboard/clipboard_recent_content_generic_unittest.cc
index 83b9ac9..e03deef 100644
--- a/components/open_from_clipboard/clipboard_recent_content_generic_unittest.cc
+++ b/components/open_from_clipboard/clipboard_recent_content_generic_unittest.cc
@@ -7,6 +7,7 @@
 #include <memory>
 #include <utility>
 
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/time/time.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -62,7 +63,7 @@
 
   ClipboardRecentContentGeneric recent_content;
   base::Time now = base::Time::Now();
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     test_clipboard_->WriteText(test_data[i].clipboard.data(),
                                test_data[i].clipboard.length());
     test_clipboard_->SetLastModifiedTime(now -
diff --git a/components/open_from_clipboard/clipboard_recent_content_ios.mm b/components/open_from_clipboard/clipboard_recent_content_ios.mm
index 7894cd4..49cb850d 100644
--- a/components/open_from_clipboard/clipboard_recent_content_ios.mm
+++ b/components/open_from_clipboard/clipboard_recent_content_ios.mm
@@ -10,8 +10,8 @@
 #import <UIKit/UIKit.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/user_metrics.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/system/sys_info.h"
 #import "components/open_from_clipboard/clipboard_recent_content_impl_ios.h"
@@ -30,7 +30,7 @@
 NSSet<NSString*>* getAuthorizedSchemeList(
     const std::string& application_scheme) {
   NSMutableSet<NSString*>* schemes = [NSMutableSet set];
-  for (size_t i = 0; i < arraysize(kAuthorizedSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kAuthorizedSchemes); ++i) {
     [schemes addObject:base::SysUTF8ToNSString(kAuthorizedSchemes[i])];
   }
   if (!application_scheme.empty()) {
diff --git a/components/os_crypt/keyring_util_linux.cc b/components/os_crypt/keyring_util_linux.cc
index aa67be03..5acaa1e 100644
--- a/components/os_crypt/keyring_util_linux.cc
+++ b/components/os_crypt/keyring_util_linux.cc
@@ -7,6 +7,7 @@
 #include <dlfcn.h>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 
 decltype(&::gnome_keyring_is_available)
     GnomeKeyringLoader::gnome_keyring_is_available_ptr;
@@ -77,7 +78,7 @@
     return false;
   }
 
-  for (size_t i = 0; i < arraysize(functions); ++i) {
+  for (size_t i = 0; i < base::size(functions); ++i) {
     dlerror();
     *functions[i].pointer = dlsym(handle, functions[i].name);
     const char* error = dlerror();
diff --git a/components/os_crypt/os_crypt_linux.cc b/components/os_crypt/os_crypt_linux.cc
index 6b9c384..0b8fcbe 100644
--- a/components/os_crypt/os_crypt_linux.cc
+++ b/components/os_crypt/os_crypt_linux.cc
@@ -12,6 +12,7 @@
 #include "base/lazy_instance.h"
 #include "base/logging.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/synchronization/lock.h"
@@ -255,7 +256,7 @@
     std::string* (*get_password_v11_mock)()) {
   // Save the real implementation to restore it later.
   static bool is_get_password_saved = false;
-  static std::string* (*get_password_save[arraysize(g_get_password)])();
+  static std::string* (*get_password_save[base::size(g_get_password)])();
   if (!is_get_password_saved) {
     std::copy(std::begin(g_get_password), std::end(g_get_password),
               std::begin(get_password_save));
diff --git a/components/password_manager/core/browser/android_affiliation/facet_manager_unittest.cc b/components/password_manager/core/browser/android_affiliation/facet_manager_unittest.cc
index 4a3269e..a6b7bd9 100644
--- a/components/password_manager/core/browser/android_affiliation/facet_manager_unittest.cc
+++ b/components/password_manager/core/browser/android_affiliation/facet_manager_unittest.cc
@@ -12,9 +12,9 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/test/test_mock_time_task_runner.h"
 #include "base/test/test_simple_task_runner.h"
 #include "base/time/clock.h"
@@ -595,7 +595,7 @@
   const base::TimeDelta kMaximumTestDuration = 2 * GetCacheHardExpiryPeriod();
 
   for (const bool cache_initially_stale : kFalseTrue) {
-    for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kTestCases); ++i) {
       SCOPED_TRACE(testing::Message() << "Test case: #" << i);
       SCOPED_TRACE(cache_initially_stale ? "Cache initially stale"
                                          : "Cache initially empty");
@@ -731,7 +731,7 @@
 
   const base::TimeDelta kMaximumTestDuration = 2 * GetCacheHardExpiryPeriod();
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "Test case: #" << i);
 
     fake_facet_manager_host()->set_fake_database_content(
@@ -796,7 +796,7 @@
 
   const base::TimeDelta kMaximumTestDuration = 2 * GetCacheHardExpiryPeriod();
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "Test case: #" << i);
 
     fake_facet_manager_host()->set_fake_database_content(
@@ -922,8 +922,8 @@
   const base::TimeDelta kTestDuration =
       GetCacheSoftExpiryPeriod() + GetCacheHardExpiryPeriod();
 
-  for (size_t j = 0; j < arraysize(kFirstPrefetchParams); ++j) {
-    for (size_t i = 0; i < arraysize(kSecondPrefetchParams); ++i) {
+  for (size_t j = 0; j < base::size(kFirstPrefetchParams); ++j) {
+    for (size_t i = 0; i < base::size(kSecondPrefetchParams); ++i) {
       SCOPED_TRACE(testing::Message() << "Test case: #" << j << "." << i);
 
       fake_facet_manager_host()->clear_fake_database_content();
@@ -987,7 +987,7 @@
   const base::TimeDelta kTestDuration =
       GetCacheSoftExpiryPeriod() + GetCacheHardExpiryPeriod();
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "Test case: #" << i);
 
     fake_facet_manager_host()->clear_fake_database_content();
@@ -1112,7 +1112,7 @@
                                                GetCacheHardExpiryPeriod() +
                                                2 * GetShortTestPeriod();
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "Test case: #" << i);
 
     fake_facet_manager_host()->clear_fake_database_content();
@@ -1192,7 +1192,7 @@
       GetCacheSoftExpiryPeriod(),
       2 * GetCacheSoftExpiryPeriod()};
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(testing::Message() << "Test case: #" << i);
 
     fake_facet_manager_host()->clear_fake_database_content();
diff --git a/components/password_manager/core/browser/login_database.cc b/components/password_manager/core/browser/login_database.cc
index 693f619..b12a8bc1 100644
--- a/components/password_manager/core/browser/login_database.cc
+++ b/components/password_manager/core/browser/login_database.cc
@@ -17,7 +17,6 @@
 #include "base/feature_list.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/numerics/safe_conversions.h"
@@ -243,7 +242,7 @@
   enum Scheme { SCHEME_HTTP, SCHEME_HTTPS };
   const Scheme kAllSchemes[] = {SCHEME_HTTP, SCHEME_HTTPS};
 
-  StatisticsPerScheme statistics[arraysize(kAllSchemes)];
+  StatisticsPerScheme statistics[base::size(kAllSchemes)];
   std::map<std::string, std::string> domain_to_registry_controlled_domain;
 
   for (const std::string& signon_realm : signon_realms) {
@@ -262,7 +261,7 @@
         domain_to_registry_controlled_domain[domain];
 
     Scheme scheme = SCHEME_HTTP;
-    static_assert(arraysize(kAllSchemes) == 2, "Update this logic");
+    static_assert(base::size(kAllSchemes) == 2, "Update this logic");
     if (signon_realm_url.SchemeIs(url::kHttpsScheme))
       scheme = SCHEME_HTTPS;
     else if (!signon_realm_url.SchemeIs(url::kHttpScheme))
@@ -284,11 +283,11 @@
           domain_to_registry_controlled_domain[domain];
 
       Scheme other_scheme = scheme == SCHEME_HTTP ? SCHEME_HTTPS : SCHEME_HTTP;
-      static_assert(arraysize(kAllSchemes) == 2, "Update |other_scheme|");
+      static_assert(base::size(kAllSchemes) == 2, "Update |other_scheme|");
 
       // Discount the account at hand from the number of accounts with the same
       // domain and scheme.
-      int num_accounts_for_same_domain[arraysize(kAllSchemes)] = {};
+      int num_accounts_for_same_domain[base::size(kAllSchemes)] = {};
       num_accounts_for_same_domain[scheme] =
           statistics[scheme].num_accounts_per_domain[domain] - 1;
       num_accounts_for_same_domain[other_scheme] =
@@ -302,7 +301,7 @@
 
       // Discount PSL matches from the number of accounts with different domains
       // but the same scheme.
-      int num_accounts_for_different_domain[arraysize(kAllSchemes)] = {};
+      int num_accounts_for_different_domain[base::size(kAllSchemes)] = {};
       num_accounts_for_different_domain[scheme] =
           statistics[scheme].num_total_accounts -
           statistics[scheme].num_accounts_per_registry_controlled_domain
@@ -313,7 +312,7 @@
 
       std::string source_realm_kind =
           scheme == SCHEME_HTTP ? "FromHttpRealm" : "FromHttpsRealm";
-      static_assert(arraysize(kAllSchemes) == 2, "Update |source_realm_kind|");
+      static_assert(base::size(kAllSchemes) == 2, "Update |source_realm_kind|");
 
       // So far, the calculation has been carried out once per "source" domain,
       // but the metrics need to be recorded on a per-account basis. The set of
diff --git a/components/password_manager/core/browser/login_database_ios_unittest.cc b/components/password_manager/core/browser/login_database_ios_unittest.cc
index 96ce8347e..dd6baba 100644
--- a/components/password_manager/core/browser/login_database_ios_unittest.cc
+++ b/components/password_manager/core/browser/login_database_ios_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "base/files/scoped_temp_dir.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "components/autofill/core/common/password_form.h"
@@ -53,7 +53,7 @@
   const void* queryKeys[] = {kSecClass};
   const void* queryValues[] = {kSecClassGenericPassword};
   ScopedCFTypeRef<CFDictionaryRef> query(CFDictionaryCreate(
-      NULL, queryKeys, queryValues, arraysize(queryKeys),
+      NULL, queryKeys, queryValues, base::size(queryKeys),
       &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
   OSStatus status = SecItemDelete(query);
   // iOS7 returns an error of |errSecItemNotFound| if you try to clear an empty
@@ -90,7 +90,7 @@
       base::string16(),
   };
 
-  for (unsigned int i = 0; i < arraysize(test_passwords); i++) {
+  for (unsigned int i = 0; i < base::size(test_passwords); i++) {
     std::string encrypted;
     EXPECT_EQ(LoginDatabase::ENCRYPTION_RESULT_SUCCESS,
               login_db_->EncryptedString(test_passwords[i], &encrypted));
@@ -164,7 +164,7 @@
   forms[2].date_created = base::Time::FromDoubleT(300);
   forms[2].password_value = base::ASCIIToUTF16("pass2");
 
-  for (size_t i = 0; i < arraysize(forms); i++) {
+  for (size_t i = 0; i < base::size(forms); i++) {
     ignore_result(login_db_->AddLogin(forms[i]));
   }
 
diff --git a/components/password_manager/core/browser/password_reuse_detection_manager_unittest.cc b/components/password_manager/core/browser/password_reuse_detection_manager_unittest.cc
index b0c6dfb..a3b6ba79 100644
--- a/components/password_manager/core/browser/password_reuse_detection_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_reuse_detection_manager_unittest.cc
@@ -5,6 +5,7 @@
 #include "components/password_manager/core/browser/password_reuse_detection_manager.h"
 
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/test/simple_test_clock.h"
@@ -72,7 +73,7 @@
       .WillRepeatedly(testing::Return(store_.get()));
   PasswordReuseDetectionManager manager(&client_);
 
-  for (size_t test = 0; test < arraysize(gurls); ++test) {
+  for (size_t test = 0; test < base::size(gurls); ++test) {
     manager.DidNavigateMainFrame(gurls[test]);
     for (size_t i = 0; i < input[test].size(); ++i) {
       base::string16 expected_input = input[test].substr(0, i + 1);
diff --git a/components/password_manager/core/browser/password_store_default_unittest.cc b/components/password_manager/core/browser/password_store_default_unittest.cc
index c3c4ec6..28e69ac 100644
--- a/components/password_manager/core/browser/password_store_default_unittest.cc
+++ b/components/password_manager/core/browser/password_store_default_unittest.cc
@@ -10,8 +10,8 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
@@ -175,7 +175,7 @@
 
   // Build the expected forms vector and add the forms to the store.
   std::vector<std::unique_ptr<PasswordForm>> expected_forms;
-  for (unsigned int i = 0; i < arraysize(form_data); ++i) {
+  for (unsigned int i = 0; i < base::size(form_data); ++i) {
     expected_forms.push_back(FillPasswordFormWithData(form_data[i]));
     store->AddLogin(*expected_forms.back());
   }
diff --git a/components/password_manager/core/browser/password_store_unittest.cc b/components/password_manager/core/browser/password_store_unittest.cc
index 14e9f46..67cd326c 100644
--- a/components/password_manager/core/browser/password_store_unittest.cc
+++ b/components/password_manager/core/browser/password_store_unittest.cc
@@ -9,8 +9,8 @@
 
 #include "base/bind.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/synchronization/waitable_event.h"
@@ -188,7 +188,7 @@
 
   // Build the forms vector and add the forms to the store.
   std::vector<std::unique_ptr<PasswordForm>> all_forms;
-  for (size_t i = 0; i < arraysize(form_data); ++i) {
+  for (size_t i = 0; i < base::size(form_data); ++i) {
     all_forms.push_back(FillPasswordFormWithData(form_data[i]));
     store->AddLogin(*all_forms.back());
   }
@@ -386,7 +386,7 @@
   store->Init(syncer::SyncableService::StartSyncFlare(), nullptr);
 
   std::vector<std::unique_ptr<PasswordForm>> all_credentials;
-  for (size_t i = 0; i < arraysize(kTestCredentials); ++i) {
+  for (size_t i = 0; i < base::size(kTestCredentials); ++i) {
     all_credentials.push_back(FillPasswordFormWithData(kTestCredentials[i]));
     store->AddLogin(*all_credentials.back());
   }
@@ -659,7 +659,7 @@
 
       // Set up the initial test data set.
       std::vector<std::unique_ptr<PasswordForm>> all_credentials;
-      for (size_t i = 0; i < arraysize(kTestCredentials); ++i) {
+      for (size_t i = 0; i < base::size(kTestCredentials); ++i) {
         all_credentials.push_back(
             FillPasswordFormWithData(kTestCredentials[i]));
         all_credentials.back()->date_synced =
diff --git a/components/payments/core/strings_util.cc b/components/payments/core/strings_util.cc
index d2587fe..977f8ad 100644
--- a/components/payments/core/strings_util.cc
+++ b/components/payments/core/strings_util.cc
@@ -7,6 +7,7 @@
 #include <vector>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "components/autofill/core/browser/autofill_profile.h"
 #include "components/autofill/core/browser/field_types.h"
 #include "components/strings/grit/components_strings.h"
@@ -50,8 +51,8 @@
       autofill::ADDRESS_HOME_SORTING_CODE,
   };
 
-  return profile.ConstructInferredLabel(kLabelFields, arraysize(kLabelFields),
-                                        arraysize(kLabelFields), locale);
+  return profile.ConstructInferredLabel(kLabelFields, base::size(kLabelFields),
+                                        base::size(kLabelFields), locale);
 }
 
 base::string16 GetBillingAddressLabelFromAutofillProfile(
@@ -68,8 +69,8 @@
       autofill::ADDRESS_HOME_SORTING_CODE,
   };
 
-  return profile.ConstructInferredLabel(kLabelFields, arraysize(kLabelFields),
-                                        arraysize(kLabelFields), locale);
+  return profile.ConstructInferredLabel(kLabelFields, base::size(kLabelFields),
+                                        base::size(kLabelFields), locale);
 }
 
 base::string16 GetShippingAddressSelectorInfoMessage(
diff --git a/components/payments/core/strings_util_unittest.cc b/components/payments/core/strings_util_unittest.cc
index e3eacb6..e2e8239 100644
--- a/components/payments/core/strings_util_unittest.cc
+++ b/components/payments/core/strings_util_unittest.cc
@@ -7,6 +7,7 @@
 #include <string>
 #include <vector>
 
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -39,7 +40,7 @@
       {{DEBIT, PREPAID}, "Accepted Debit and Prepaid Cards"},
       {{CREDIT, DEBIT, PREPAID}, "Accepted Cards"},
   };
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     EXPECT_EQ(
         base::UTF8ToUTF16(kTestCases[i].expected_text),
         GetAcceptedCardTypesText(std::set<CardType>(
@@ -62,7 +63,7 @@
       {{DEBIT, PREPAID}, "Accepted debit and prepaid cards"},
       {{CREDIT, DEBIT, PREPAID}, "Accepted cards"},
   };
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     EXPECT_EQ(
         base::UTF8ToUTF16(kTestCases[i].expected_text),
         GetAcceptedCardTypesText(std::set<CardType>(
@@ -86,7 +87,7 @@
       {{DEBIT, PREPAID}, "Debit and prepaid cards are accepted."},
       {{CREDIT, DEBIT, PREPAID}, ""},
   };
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     EXPECT_EQ(
         base::UTF8ToUTF16(kTestCases[i].expected_text),
         GetCardTypesAreAcceptedText(std::set<CardType>(
diff --git a/components/policy/core/browser/browser_policy_connector.cc b/components/policy/core/browser/browser_policy_connector.cc
index 290fb1e..977f93ab 100644
--- a/components/policy/core/browser/browser_policy_connector.cc
+++ b/components/policy/core/browser/browser_policy_connector.cc
@@ -11,9 +11,9 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -83,8 +83,8 @@
     DLOG(ERROR) << "Possible invalid domain pattern: " << pattern
                 << " - Error: " << status;
     ReportRegexSuccessMetric(false);
-    UMA_HISTOGRAM_ENUMERATION("Enterprise.DomainWhitelistRegexFailure",
-                              index, arraysize(kNonManagedDomainPatterns));
+    UMA_HISTOGRAM_ENUMERATION("Enterprise.DomainWhitelistRegexFailure", index,
+                              base::size(kNonManagedDomainPatterns));
     base::UmaHistogramSparse("Enterprise.DomainWhitelistRegexFailureStatus",
                              status);
     return false;
@@ -144,7 +144,7 @@
   }
   const base::string16 domain = base::UTF8ToUTF16(
       gaia::ExtractDomainName(gaia::CanonicalizeEmail(username)));
-  for (size_t i = 0; i < arraysize(kNonManagedDomainPatterns); i++) {
+  for (size_t i = 0; i < base::size(kNonManagedDomainPatterns); i++) {
     base::string16 pattern = base::WideToUTF16(kNonManagedDomainPatterns[i]);
     if (MatchDomain(domain, pattern, i))
       return true;
diff --git a/components/policy/core/browser/browser_policy_connector_unittest.cc b/components/policy/core/browser/browser_policy_connector_unittest.cc
index fb32074..61afdd2f 100644
--- a/components/policy/core/browser/browser_policy_connector_unittest.cc
+++ b/components/policy/core/browser/browser_policy_connector_unittest.cc
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
 #include "components/policy/core/browser/browser_policy_connector.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace policy {
@@ -34,12 +34,12 @@
     "user@hotmail.enterprise.com",
   };
 
-  for (unsigned int i = 0; i < arraysize(kNonEnterpriseUsers); ++i) {
+  for (unsigned int i = 0; i < base::size(kNonEnterpriseUsers); ++i) {
     std::string username(kNonEnterpriseUsers[i]);
     EXPECT_TRUE(BrowserPolicyConnector::IsNonEnterpriseUser(username)) <<
         "IsNonEnterpriseUser returned false for " << username;
   }
-  for (unsigned int i = 0; i < arraysize(kEnterpriseUsers); ++i) {
+  for (unsigned int i = 0; i < base::size(kEnterpriseUsers); ++i) {
     std::string username(kEnterpriseUsers[i]);
     EXPECT_FALSE(BrowserPolicyConnector::IsNonEnterpriseUser(username)) <<
         "IsNonEnterpriseUser returned true for " << username;
diff --git a/components/policy/core/browser/proxy_policy_handler.cc b/components/policy/core/browser/proxy_policy_handler.cc
index 2684937..686b27d 100644
--- a/components/policy/core/browser/proxy_policy_handler.cc
+++ b/components/policy/core/browser/proxy_policy_handler.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/values.h"
 #include "components/policy/core/browser/configuration_policy_handler.h"
@@ -89,7 +89,7 @@
     return true;
 
   bool is_valid_mode = false;
-  for (size_t i = 0; i != arraysize(kProxyModeValidationMap); ++i) {
+  for (size_t i = 0; i != base::size(kProxyModeValidationMap); ++i) {
     const ProxyModeValidationEntry& entry = kProxyModeValidationMap[i];
     if (entry.mode_value != mode_value)
       continue;
diff --git a/components/policy/core/browser/url_blacklist_manager.cc b/components/policy/core/browser/url_blacklist_manager.cc
index 1588fa4..34bf45cb 100644
--- a/components/policy/core/browser/url_blacklist_manager.cc
+++ b/components/policy/core/browser/url_blacklist_manager.cc
@@ -16,7 +16,6 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
@@ -128,7 +127,7 @@
 
 bool BypassBlacklistWildcardForURL(const GURL& url) {
   const std::string& scheme = url.scheme();
-  for (size_t i = 0; i < arraysize(kBypassBlacklistWildcardForSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kBypassBlacklistWildcardForSchemes); ++i) {
     if (scheme == kBypassBlacklistWildcardForSchemes[i])
       return true;
   }
diff --git a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
index c156e18..3636fc2 100644
--- a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
+++ b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
@@ -14,8 +14,8 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/compiler_specific.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "build/build_config.h"
 #include "components/policy/core/common/cloud/cloud_policy_util.h"
@@ -1020,7 +1020,7 @@
   expected_namespaces.insert(key);
   key.first = dm_protocol::kChromeExtensionPolicyType;
   expected_namespaces.insert(key);
-  for (size_t i = 0; i < arraysize(kExtensions); ++i) {
+  for (size_t i = 0; i < base::size(kExtensions); ++i) {
     key.second = kExtensions[i];
     em::PolicyData policy_data;
     policy_data.set_policy_type(key.first);
diff --git a/components/policy/core/common/cloud/cloud_policy_util.cc b/components/policy/core/common/cloud/cloud_policy_util.cc
index 517a717..8cff60c 100644
--- a/components/policy/core/common/cloud/cloud_policy_util.cc
+++ b/components/policy/core/common/cloud/cloud_policy_util.cc
@@ -35,6 +35,7 @@
 #include <utility>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/system/sys_info.h"
 #include "components/version_info/version_info.h"
 
@@ -95,7 +96,7 @@
   return std::string();
 #elif defined(OS_WIN)
   wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
-  DWORD size = arraysize(computer_name);
+  DWORD size = base::size(computer_name);
   if (::GetComputerNameW(computer_name, &size)) {
     std::string result;
     bool conversion_successful = base::WideToUTF8(computer_name, size, &result);
diff --git a/components/policy/core/common/cloud/cloud_policy_validator.cc b/components/policy/core/common/cloud/cloud_policy_validator.cc
index 84cb9ef..5820cbd 100644
--- a/components/policy/core/common/cloud/cloud_policy_validator.cc
+++ b/components/policy/core/common/cloud/cloud_policy_validator.cc
@@ -9,7 +9,6 @@
 
 #include "base/bind_helpers.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
@@ -337,7 +336,7 @@
       {VALIDATE_VALUES, &CloudPolicyValidatorBase::CheckValues},
   };
 
-  for (size_t i = 0; i < arraysize(kCheckFunctions); ++i) {
+  for (size_t i = 0; i < base::size(kCheckFunctions); ++i) {
     if (validation_flags_ & kCheckFunctions[i].flag) {
       status_ = (this->*(kCheckFunctions[i].checkFunction))();
       if (status_ != VALIDATION_OK)
diff --git a/components/policy/core/common/cloud/device_management_service_unittest.cc b/components/policy/core/common/cloud/device_management_service_unittest.cc
index 9e84356..e44a3b57 100644
--- a/components/policy/core/common/cloud/device_management_service_unittest.cc
+++ b/components/policy/core/common/cloud/device_management_service_unittest.cc
@@ -10,9 +10,9 @@
 
 #include "base/bind.h"
 #include "base/callback_helpers.h"
-#include "base/macros.h"
 #include "base/optional.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/strcat.h"
 #include "base/strings/string_split.h"
 #include "base/test/scoped_task_environment.h"
@@ -41,7 +41,7 @@
 // Encoded empty response messages for testing the error code paths.
 const char kResponseEmpty[] = "\x08\x00";
 
-#define PROTO_STRING(name) (std::string(name, arraysize(name) - 1))
+#define PROTO_STRING(name) (std::string(name, base::size(name) - 1))
 
 // Some helper constants.
 const char kGaiaAuthToken[] = "gaia-auth-token";
diff --git a/components/policy/core/common/cloud/policy_builder.cc b/components/policy/core/common/cloud/policy_builder.cc
index 748aefb..af0f25a 100644
--- a/components/policy/core/common/cloud/policy_builder.cc
+++ b/components/policy/core/common/cloud/policy_builder.cc
@@ -4,7 +4,7 @@
 
 #include "components/policy/core/common/cloud/policy_builder.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
 #include "crypto/signature_creator.h"
@@ -205,7 +205,7 @@
 }
 
 void PolicyBuilder::SetDefaultSigningKey() {
-  raw_signing_key_.assign(kSigningKey, kSigningKey + arraysize(kSigningKey));
+  raw_signing_key_.assign(kSigningKey, kSigningKey + base::size(kSigningKey));
 }
 
 void PolicyBuilder::UnsetSigningKey() {
@@ -221,7 +221,7 @@
 
 void PolicyBuilder::SetDefaultNewSigningKey() {
   raw_new_signing_key_.assign(kNewSigningKey,
-                              kNewSigningKey + arraysize(kNewSigningKey));
+                              kNewSigningKey + base::size(kNewSigningKey));
   raw_new_signing_key_signature_ = GetTestOtherSigningKeySignature();
 }
 
@@ -232,7 +232,7 @@
 
 void PolicyBuilder::SetDefaultInitialSigningKey() {
   raw_new_signing_key_.assign(kSigningKey,
-                              kSigningKey + arraysize(kSigningKey));
+                              kSigningKey + base::size(kSigningKey));
   raw_new_signing_key_signature_ = GetTestSigningKeySignature();
   UnsetSigningKey();
 }
@@ -293,7 +293,7 @@
 // static
 std::unique_ptr<crypto::RSAPrivateKey> PolicyBuilder::CreateTestSigningKey() {
   std::vector<uint8_t> raw_signing_key(kSigningKey,
-                                       kSigningKey + arraysize(kSigningKey));
+                                       kSigningKey + base::size(kSigningKey));
   return crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(raw_signing_key);
 }
 
@@ -301,7 +301,7 @@
 std::unique_ptr<crypto::RSAPrivateKey>
 PolicyBuilder::CreateTestOtherSigningKey() {
   std::vector<uint8_t> raw_new_signing_key(
-      kNewSigningKey, kNewSigningKey + arraysize(kNewSigningKey));
+      kNewSigningKey, kNewSigningKey + base::size(kNewSigningKey));
   return crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(raw_new_signing_key);
 }
 
diff --git a/components/policy/core/common/config_dir_policy_loader.cc b/components/policy/core/common/config_dir_policy_loader.cc
index e1d9c51c..6a81e76 100644
--- a/components/policy/core/common/config_dir_policy_loader.cc
+++ b/components/policy/core/common/config_dir_policy_loader.cc
@@ -17,7 +17,6 @@
 #include "base/json/json_file_value_serializer.h"
 #include "base/json/json_reader.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "components/policy/core/common/policy_bundle.h"
 #include "components/policy/core/common/policy_load_status.h"
@@ -100,7 +99,7 @@
   base::Time last_modification = base::Time();
   base::File::Info info;
 
-  for (size_t i = 0; i < arraysize(kConfigDirSuffixes); ++i) {
+  for (size_t i = 0; i < base::size(kConfigDirSuffixes); ++i) {
     base::FilePath path(config_dir_.Append(kConfigDirSuffixes[i]));
 
     // Skip if the file doesn't exist, or it isn't a directory.
diff --git a/components/policy/core/common/policy_loader_mac_unittest.cc b/components/policy/core/common/policy_loader_mac_unittest.cc
index 6549d434..ecaffd70 100644
--- a/components/policy/core/common/policy_loader_mac_unittest.cc
+++ b/components/policy/core/common/policy_loader_mac_unittest.cc
@@ -12,9 +12,9 @@
 #include "base/callback.h"
 #include "base/files/file_path.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/values.h"
 #include "components/policy/core/common/async_policy_provider.h"
@@ -171,9 +171,8 @@
       base::SysUTF8ToCFStringRef(test_keys::kKeyString));
   const char buffer[] = "binary \xde\xad\xbe\xef data";
   ScopedCFTypeRef<CFDataRef> invalid_data(
-      CFDataCreate(kCFAllocatorDefault,
-                   reinterpret_cast<const UInt8 *>(buffer),
-                   arraysize(buffer)));
+      CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(buffer),
+                   base::size(buffer)));
   ASSERT_TRUE(invalid_data);
   prefs_->AddTestItem(name, invalid_data.get(), true);
   prefs_->AddTestItem(name, invalid_data.get(), false);
diff --git a/components/policy/core/common/policy_loader_win.cc b/components/policy/core/common/policy_loader_win.cc
index 7fc507c..7722ee1 100644
--- a/components/policy/core/common/policy_loader_win.cc
+++ b/components/policy/core/common/policy_loader_win.cc
@@ -23,7 +23,6 @@
 #include "base/json/json_writer.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram.h"
 #include "base/metrics/histogram_functions.h"
@@ -146,7 +145,7 @@
     }
   }
 
-  for (size_t i = 0; i < arraysize(kInsecurePolicies); ++i) {
+  for (size_t i = 0; i < base::size(kInsecurePolicies); ++i) {
     if (policy->Get(kInsecurePolicies[i])) {
       // TODO(pastarmovj): Surface this issue in the about:policy page.
       policy->Erase(kInsecurePolicies[i]);
@@ -367,7 +366,7 @@
   std::unique_ptr<PolicyBundle> bundle(new PolicyBundle());
   PolicyMap* chrome_policy =
       &bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
-  for (size_t i = 0; i < arraysize(kScopes); ++i) {
+  for (size_t i = 0; i < base::size(kScopes); ++i) {
     PolicyScope scope = kScopes[i].scope;
     PolicyLoadStatusUmaReporter status;
     RegistryDict gpo_dict;
@@ -425,7 +424,7 @@
       {POLICY_LEVEL_RECOMMENDED, kKeyRecommended},
   };
 
-  for (size_t i = 0; i < arraysize(k3rdPartyDomains); i++) {
+  for (size_t i = 0; i < base::size(k3rdPartyDomains); i++) {
     const char* name = k3rdPartyDomains[i].name;
     const PolicyDomain domain = k3rdPartyDomains[i].domain;
     const RegistryDict* domain_dict = gpo_dict->GetKey(name);
@@ -445,7 +444,7 @@
       Schema schema = *schema_from_map;
 
       // Parse policy.
-      for (size_t j = 0; j < arraysize(kLevels); j++) {
+      for (size_t j = 0; j < base::size(kLevels); j++) {
         const RegistryDict* policy_dict =
             component->second->GetKey(kLevels[j].path);
         if (!policy_dict)
diff --git a/components/policy/core/common/policy_service_impl.cc b/components/policy/core/common/policy_service_impl.cc
index 5e163d3..3ff79f1 100644
--- a/components/policy/core/common/policy_service_impl.cc
+++ b/components/policy/core/common/policy_service_impl.cc
@@ -11,8 +11,8 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
 #include "components/policy/core/common/policy_bundle.h"
@@ -43,7 +43,7 @@
   PolicySource inherited_source = POLICY_SOURCE_ENTERPRISE_DEFAULT;
   std::unique_ptr<base::DictionaryValue> proxy_settings(
       new base::DictionaryValue);
-  for (size_t i = 0; i < arraysize(kProxyPolicies); ++i) {
+  for (size_t i = 0; i < base::size(kProxyPolicies); ++i) {
     const PolicyMap::Entry* entry = policies->Get(kProxyPolicies[i]);
     if (entry) {
       if (entry->has_higher_priority_than(current_priority)) {
diff --git a/components/policy/core/common/preg_parser.cc b/components/policy/core/common/preg_parser.cc
index 7312e814f..38a039a 100644
--- a/components/policy/core/common/preg_parser.cc
+++ b/components/policy/core/common/preg_parser.cc
@@ -18,8 +18,8 @@
 #include "base/files/file_path.h"
 #include "base/files/memory_mapped_file.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -259,7 +259,7 @@
 
   std::string data_utf8;
   std::string action_trigger(base::ToLowerASCII(
-      value_name.substr(arraysize(kActionTriggerPrefix) - 1)));
+      value_name.substr(base::size(kActionTriggerPrefix) - 1)));
   if (action_trigger == kActionTriggerDeleteValues) {
     if (DecodePRegStringValue(data, &data_utf8)) {
       for (const std::string& value :
@@ -277,8 +277,8 @@
     }
   } else if (base::StartsWith(action_trigger, kActionTriggerDel,
                               base::CompareCase::SENSITIVE)) {
-    dict->RemoveValue(value_name.substr(arraysize(kActionTriggerPrefix) - 1 +
-                                        arraysize(kActionTriggerDel) - 1));
+    dict->RemoveValue(value_name.substr(base::size(kActionTriggerPrefix) - 1 +
+                                        base::size(kActionTriggerDel) - 1));
   } else if (base::StartsWith(action_trigger, kActionTriggerDelVals,
                               base::CompareCase::SENSITIVE)) {
     // Delete all values.
@@ -334,7 +334,7 @@
   }
 
   // Check the header.
-  const int kHeaderSize = arraysize(kPRegFileHeader);
+  const int kHeaderSize = base::size(kPRegFileHeader);
   if (!preg_data || preg_data_size < kHeaderSize ||
       memcmp(kPRegFileHeader, preg_data, kHeaderSize) != 0) {
     LOG(ERROR) << "Bad PReg " << debug_name;
diff --git a/components/policy/core/common/schema_unittest.cc b/components/policy/core/common/schema_unittest.cc
index a45d81d..493b993 100644
--- a/components/policy/core/common/schema_unittest.cc
+++ b/components/policy/core/common/schema_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "components/policy/core/common/schema_internal.h"
@@ -424,7 +424,7 @@
     { "StringWithPattern",            base::Value::Type::STRING },
   };
   Schema::Iterator it = schema.GetPropertiesIterator();
-  for (size_t i = 0; i < arraysize(kExpectedProperties); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedProperties); ++i) {
     ASSERT_FALSE(it.IsAtEnd());
     EXPECT_STREQ(kExpectedProperties[i].expected_key, it.key());
     ASSERT_TRUE(it.schema().valid());
@@ -485,7 +485,7 @@
     { "aba",    base::Value::Type::INTEGER },
     { "abab",   base::Value::Type::STRING },
   };
-  for (size_t i = 0; i < arraysize(kExpectedKeys); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedKeys); ++i) {
     Schema sub = schema.GetKnownProperty(kExpectedKeys[i].expected_key);
     ASSERT_TRUE(sub.valid());
     EXPECT_EQ(kExpectedKeys[i].expected_type, sub.type());
@@ -611,7 +611,7 @@
   };
 
   Schema::Iterator it = schema.GetPropertiesIterator();
-  for (size_t i = 0; i < arraysize(kExpectedProperties); ++i) {
+  for (size_t i = 0; i < base::size(kExpectedProperties); ++i) {
     ASSERT_FALSE(it.IsAtEnd());
     EXPECT_STREQ(kExpectedProperties[i].key, it.key());
     Schema sub = it.schema();
diff --git a/components/prefs/json_pref_store_unittest.cc b/components/prefs/json_pref_store_unittest.cc
index 8f5bf74..d4e7870c 100644
--- a/components/prefs/json_pref_store_unittest.cc
+++ b/components/prefs/json_pref_store_unittest.cc
@@ -14,12 +14,12 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/histogram_samples.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -208,8 +208,8 @@
 // Test fallback behavior for an invalid file.
 TEST_P(JsonPrefStoreTest, InvalidFile) {
   base::FilePath invalid_file = temp_dir_.GetPath().AppendASCII("invalid.json");
-  ASSERT_LT(0, base::WriteFile(invalid_file,
-                               kInvalidJson, arraysize(kInvalidJson) - 1));
+  ASSERT_LT(0, base::WriteFile(invalid_file, kInvalidJson,
+                               base::size(kInvalidJson) - 1));
 
   auto pref_store = base::MakeRefCounted<JsonPrefStore>(invalid_file);
   EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE,
@@ -305,8 +305,8 @@
 
 TEST_P(JsonPrefStoreTest, Basic) {
   base::FilePath input_file = temp_dir_.GetPath().AppendASCII("write.json");
-  ASSERT_LT(0, base::WriteFile(input_file,
-                               kReadJson, arraysize(kReadJson) - 1));
+  ASSERT_LT(0,
+            base::WriteFile(input_file, kReadJson, base::size(kReadJson) - 1));
 
   // Test that the persistent value can be loaded.
   ASSERT_TRUE(PathExists(input_file));
@@ -331,8 +331,8 @@
 
 TEST_P(JsonPrefStoreTest, BasicAsync) {
   base::FilePath input_file = temp_dir_.GetPath().AppendASCII("write.json");
-  ASSERT_LT(0, base::WriteFile(input_file,
-                               kReadJson, arraysize(kReadJson) - 1));
+  ASSERT_LT(0,
+            base::WriteFile(input_file, kReadJson, base::size(kReadJson) - 1));
 
   // Test that the persistent value can be loaded.
   auto pref_store = base::MakeRefCounted<JsonPrefStore>(input_file);
@@ -437,8 +437,8 @@
 
 TEST_P(JsonPrefStoreTest, ReadWithInterceptor) {
   base::FilePath input_file = temp_dir_.GetPath().AppendASCII("write.json");
-  ASSERT_LT(0, base::WriteFile(input_file,
-                               kReadJson, arraysize(kReadJson) - 1));
+  ASSERT_LT(0,
+            base::WriteFile(input_file, kReadJson, base::size(kReadJson) - 1));
 
   std::unique_ptr<InterceptingPrefFilter> intercepting_pref_filter(
       new InterceptingPrefFilter());
@@ -479,8 +479,8 @@
 
 TEST_P(JsonPrefStoreTest, ReadAsyncWithInterceptor) {
   base::FilePath input_file = temp_dir_.GetPath().AppendASCII("write.json");
-  ASSERT_LT(0, base::WriteFile(input_file,
-                               kReadJson, arraysize(kReadJson) - 1));
+  ASSERT_LT(0,
+            base::WriteFile(input_file, kReadJson, base::size(kReadJson) - 1));
 
   std::unique_ptr<InterceptingPrefFilter> intercepting_pref_filter(
       new InterceptingPrefFilter());
@@ -851,7 +851,7 @@
 TEST_F(JsonPrefStoreCallbackTest, TestSerializeDataCallbacks) {
   base::FilePath input_file = temp_dir_.GetPath().AppendASCII("write.json");
   ASSERT_LT(0,
-            base::WriteFile(input_file, kReadJson, arraysize(kReadJson) - 1));
+            base::WriteFile(input_file, kReadJson, base::size(kReadJson) - 1));
 
   std::unique_ptr<InterceptingPrefFilter> intercepting_pref_filter(
       new InterceptingPrefFilter(write_callback_observer_.GetCallbackPair()));
diff --git a/components/prefs/pref_service_unittest.cc b/components/prefs/pref_service_unittest.cc
index b85f47a..dfc51f6 100644
--- a/components/prefs/pref_service_unittest.cc
+++ b/components/prefs/pref_service_unittest.cc
@@ -7,7 +7,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "base/values.h"
 #include "components/prefs/json_pref_store.h"
@@ -377,7 +377,7 @@
        PrefRegistry::LOSSY_PREF | kCustomRegistrationFlag,
        WriteablePrefStore::LOSSY_PREF_WRITE_FLAG}};
 
-  for (size_t i = 0; i < arraysize(kRegistrationToWriteFlags); ++i) {
+  for (size_t i = 0; i < base::size(kRegistrationToWriteFlags); ++i) {
     RegistrationToWriteFlags entry = kRegistrationToWriteFlags[i];
     registry->RegisterDictionaryPref(entry.pref_name,
                                      std::make_unique<base::DictionaryValue>(),
diff --git a/components/proxy_config/proxy_prefs.cc b/components/proxy_config/proxy_prefs.cc
index bd5e6a6..30eef91e 100644
--- a/components/proxy_config/proxy_prefs.cc
+++ b/components/proxy_config/proxy_prefs.cc
@@ -5,7 +5,7 @@
 #include "components/proxy_config/proxy_prefs.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ProxyPrefs {
 
@@ -19,7 +19,7 @@
                                   kFixedServersProxyModeName,
                                   kSystemProxyModeName };
 
-static_assert(arraysize(kProxyModeNames) == kModeCount,
+static_assert(base::size(kProxyModeNames) == kModeCount,
               "kProxyModeNames must have kModeCount elements");
 
 }  // namespace
diff --git a/components/query_parser/query_parser_unittest.cc b/components/query_parser/query_parser_unittest.cc
index e99bf5a..b64e2b5af 100644
--- a/components/query_parser/query_parser_unittest.cc
+++ b/components/query_parser/query_parser_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/query_parser/query_parser.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -84,7 +84,7 @@
     { "foo \"bar baz\"  blah", 4 },
   };
 
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     base::string16 query_string;
     EXPECT_EQ(data[i].expected_word_count,
               query_parser_.ParseQuery(base::UTF8ToUTF16(data[i].input),
@@ -120,7 +120,7 @@
     { "\"foo blah\"",  "\"foo blah\"",     true,  1, 9, 0, 0 },
     { "foo blah",      "\"foo bar blah\"", true,  1, 4, 9, 13 },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     QueryParser parser;
     query_parser::QueryNodeVector query_nodes;
     parser.ParseQueryNodes(base::UTF8ToUTF16(data[i].query),
@@ -157,7 +157,7 @@
     { "\"foo bar\"",   "foo", "bar", "",  2 },
     { "\"foo bar\" a", "foo", "bar", "a", 3 },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     std::vector<base::string16> results;
     QueryParser parser;
     parser.ParseQueryWords(base::UTF8ToUTF16(data[i].text),
diff --git a/components/query_parser/snippet_unittest.cc b/components/query_parser/snippet_unittest.cc
index c96fad6..0d0b6e6 100644
--- a/components/query_parser/snippet_unittest.cc
+++ b/components/query_parser/snippet_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -240,7 +240,7 @@
     { "0 0 1 2 0 0 1 1",                    1,     { 1, 3 } },
     { "0 0 1 1 0 0 5 2 0 0 10 1 0 0 3 10",  2,     { 1, 2, 3, 13 } },
   };
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     Snippet::MatchPositions matches;
     Snippet::ExtractMatchPositions(data[i].offsets_string, "0", &matches);
     EXPECT_EQ(data[i].expected_match_count, matches.size());
diff --git a/components/rlz/rlz_tracker_unittest.cc b/components/rlz/rlz_tracker_unittest.cc
index 81273ae..f8c99f6 100644
--- a/components/rlz/rlz_tracker_unittest.cc
+++ b/components/rlz/rlz_tracker_unittest.cc
@@ -6,9 +6,9 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -334,7 +334,7 @@
 
 void RlzLibTest::ExpectEventRecorded(const char* event_name, bool expected) {
   char cgi[rlz_lib::kMaxCgiLength];
-  GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi));
+  GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi));
   if (expected) {
     EXPECT_STR_CONTAINS(cgi, event_name);
   } else {
diff --git a/components/safe_browsing/db/util.cc b/components/safe_browsing/db/util.cc
index 523242f..a7f52a0 100644
--- a/components/safe_browsing/db/util.cc
+++ b/components/safe_browsing/db/util.cc
@@ -11,7 +11,6 @@
 #endif
 #include "base/environment.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -29,7 +28,7 @@
 namespace {
 
 bool IsKnownList(const std::string& name) {
-  for (size_t i = 0; i < arraysize(kAllLists); ++i) {
+  for (size_t i = 0; i < base::size(kAllLists); ++i) {
     if (!strcmp(kAllLists[i], name.c_str())) {
       return true;
     }
diff --git a/components/safe_browsing/db/v4_protocol_manager_util_unittest.cc b/components/safe_browsing/db/v4_protocol_manager_util_unittest.cc
index f925b8e..33464c11 100644
--- a/components/safe_browsing/db/v4_protocol_manager_util_unittest.cc
+++ b/components/safe_browsing/db/v4_protocol_manager_util_unittest.cc
@@ -212,7 +212,7 @@
       {"javascript:alert()", "", "", ""},
       {"mailto:abc@example.com", "", "", ""},
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     SCOPED_TRACE(base::StringPrintf("Test: %s", tests[i].input_url));
     GURL url(tests[i].input_url);
 
diff --git a/components/safe_browsing/db/v4_store.cc b/components/safe_browsing/db/v4_store.cc
index b182fd0..b54b6805e 100644
--- a/components/safe_browsing/db/v4_store.cc
+++ b/components/safe_browsing/db/v4_store.cc
@@ -668,7 +668,7 @@
       if (checksum[i] != expected_checksum[i]) {
 #if DCHECK_IS_ON()
         std::string checksum_b64, expected_checksum_b64;
-        base::Base64Encode(base::StringPiece(checksum, arraysize(checksum)),
+        base::Base64Encode(base::StringPiece(checksum, base::size(checksum)),
                            &checksum_b64);
         base::Base64Encode(expected_checksum, &expected_checksum_b64);
         DVLOG(1) << "Failure: Checksum mismatch: calculated: " << checksum_b64
@@ -848,7 +848,7 @@
                               store_path_);
 #if DCHECK_IS_ON()
       std::string checksum_b64, expected_checksum_b64;
-      base::Base64Encode(base::StringPiece(checksum, arraysize(checksum)),
+      base::Base64Encode(base::StringPiece(checksum, base::size(checksum)),
                          &checksum_b64);
       base::Base64Encode(expected_checksum_, &expected_checksum_b64);
       DVLOG(1) << "Failure: Checksum mismatch: calculated: " << checksum_b64
diff --git a/components/search_engines/default_search_policy_handler.cc b/components/search_engines/default_search_policy_handler.cc
index 7bd0d8d9..68863cc 100644
--- a/components/search_engines/default_search_policy_handler.cc
+++ b/components/search_engines/default_search_policy_handler.cc
@@ -8,7 +8,6 @@
 
 #include <utility>
 
-#include "base/macros.h"
 #include "base/strings/string_number_conversions.h"
 #include "components/policy/core/browser/policy_error_map.h"
 #include "components/policy/core/common/policy_map.h"
@@ -147,7 +146,7 @@
     return;
 
   std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
-  for (size_t i = 0; i < arraysize(kDefaultSearchPolicyDataMap); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultSearchPolicyDataMap); ++i) {
     const char* policy_name = kDefaultSearchPolicyDataMap[i].policy_name;
     // kDefaultSearchProviderEnabled has already been handled.
     if (policy_name == key::kDefaultSearchProviderEnabled)
diff --git a/components/search_engines/template_url.cc b/components/search_engines/template_url.cc
index d0dfdbf..159004b 100644
--- a/components/search_engines/template_url.cc
+++ b/components/search_engines/template_url.cc
@@ -13,7 +13,6 @@
 #include "base/i18n/icu_string_conversions.h"
 #include "base/i18n/rtl.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
@@ -1291,7 +1290,7 @@
   GURL::Replacements rep;
 
   const char favicon_path[] = "/favicon.ico";
-  int favicon_path_len = arraysize(favicon_path) - 1;
+  int favicon_path_len = base::size(favicon_path) - 1;
 
   rep.SetPath(favicon_path, url::Component(0, favicon_path_len));
   rep.ClearUsername();
diff --git a/components/search_engines/template_url_prepopulate_data.cc b/components/search_engines/template_url_prepopulate_data.cc
index c49d0c0..e8042c05 100644
--- a/components/search_engines/template_url_prepopulate_data.cc
+++ b/components/search_engines/template_url_prepopulate_data.cc
@@ -5,7 +5,7 @@
 #include "components/search_engines/template_url_prepopulate_data.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "components/country_codes/country_codes.h"
 #include "components/google/core/common/google_util.h"
@@ -989,10 +989,10 @@
   switch (country_id) {
 #define UNHANDLED_COUNTRY(code1, code2) \
   case country_codes::CountryCharsToCountryID((#code1)[0], (#code2)[0]):
-#define END_UNHANDLED_COUNTRIES(code1, code2)\
-      engines = engines_##code1##code2;\
-      num_engines = arraysize(engines_##code1##code2);\
-      break;
+#define END_UNHANDLED_COUNTRIES(code1, code2)       \
+  engines = engines_##code1##code2;                 \
+  num_engines = base::size(engines_##code1##code2); \
+  break;
 #define DECLARE_COUNTRY(code1, code2)\
     UNHANDLED_COUNTRY(code1, code2)\
     END_UNHANDLED_COUNTRIES(code1, code2)
@@ -1444,7 +1444,7 @@
     return google.type;
 
   // Now check the rest of the prepopulate data.
-  for (size_t i = 0; i < arraysize(kAllEngines); ++i) {
+  for (size_t i = 0; i < base::size(kAllEngines); ++i) {
     // First check the main search URL.
     if (SameDomain(url, GURL(kAllEngines[i]->search_url)))
       return kAllEngines[i]->type;
diff --git a/components/search_engines/template_url_prepopulate_data_unittest.cc b/components/search_engines/template_url_prepopulate_data_unittest.cc
index 17d550d..8445929 100644
--- a/components/search_engines/template_url_prepopulate_data_unittest.cc
+++ b/components/search_engines/template_url_prepopulate_data_unittest.cc
@@ -11,7 +11,7 @@
 
 #include "base/command_line.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
 #include "components/country_codes/country_codes.h"
@@ -106,7 +106,7 @@
       'V'<<8|'N', 'V'<<8|'U', 'W'<<8|'F', 'W'<<8|'S', 'Y'<<8|'E',
       'Y'<<8|'T', 'Z'<<8|'A', 'Z'<<8|'M', 'Z'<<8|'W', -1 };
 
-  for (size_t i = 0; i < arraysize(kCountryIds); ++i) {
+  for (size_t i = 0; i < base::size(kCountryIds); ++i) {
     prefs_.SetInteger(country_codes::kCountryIDAtInstall, kCountryIds[i]);
     std::vector<std::unique_ptr<TemplateURLData>> urls =
         TemplateURLPrepopulateData::GetPrepopulatedEngines(&prefs_, nullptr);
@@ -312,7 +312,7 @@
     // Custom with a country TLD and almost no query params:
     "http://www.google.ru/search?q={searchTerms}"
   };
-  for (size_t i = 0; i < arraysize(kGoogleURLs); ++i) {
+  for (size_t i = 0; i < base::size(kGoogleURLs); ++i) {
     EXPECT_EQ(SEARCH_ENGINE_GOOGLE, GetEngineType(kGoogleURLs[i]));
   }
 
@@ -324,7 +324,7 @@
       // Aggressively match types by checking just TLD+1.
       "http://someothersite.yahoo.com/",
   };
-  for (size_t i = 0; i < arraysize(kYahooURLs); ++i) {
+  for (size_t i = 0; i < base::size(kYahooURLs); ++i) {
     EXPECT_EQ(SEARCH_ENGINE_YAHOO, GetEngineType(kYahooURLs[i]));
   }
 
diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc
index fd7c635..8a4efdf 100644
--- a/components/search_engines/template_url_unittest.cc
+++ b/components/search_engines/template_url_unittest.cc
@@ -7,7 +7,7 @@
 #include "base/base_paths.h"
 #include "base/command_line.h"
 #include "base/i18n/case_conversion.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -89,7 +89,7 @@
     { "http://en.wikipedia.org/{searchTerms}", ASCIIToUTF16("wiki/?"),
       "http://en.wikipedia.org/wiki/%3F" }
   };
-  for (size_t i = 0; i < arraysize(search_term_cases); ++i) {
+  for (size_t i = 0; i < base::size(search_term_cases); ++i) {
     const SearchTermsCase& value = search_term_cases[i];
     TemplateURLData data;
     data.SetURL(value.url);
@@ -387,7 +387,7 @@
 
   TestingSearchTermsData search_terms_data("http://example.com/e/");
   TemplateURLData data;
-  for (size_t i = 0; i < arraysize(search_term_cases); ++i) {
+  for (size_t i = 0; i < base::size(search_term_cases); ++i) {
     const SearchTermsCase& value = search_term_cases[i];
     data.SetURL(value.url);
     TemplateURL url(data);
@@ -429,7 +429,7 @@
   TemplateURL url(data);
   EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
   ASSERT_TRUE(url.url_ref().SupportsReplacement(search_terms_data_));
-  for (size_t i = 0; i < arraysize(to_wide_cases); i++) {
+  for (size_t i = 0; i < base::size(to_wide_cases); i++) {
     EXPECT_EQ(to_wide_cases[i].expected_decoded_term,
               url.url_ref().SearchTermToString16(
                   to_wide_cases[i].encoded_search_term));
@@ -451,7 +451,7 @@
       ASCIIToUTF16("http://foo%s{language}") },
   };
   TemplateURLData data;
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
     EXPECT_EQ(test_data[i].expected_result,
@@ -494,7 +494,7 @@
   };
   TemplateURLData data;
   data.input_encodings.push_back("UTF-8");
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
     EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
@@ -531,7 +531,7 @@
        "http://foo/{searchTerms}/bar", "http://foo/%82%A0%20%82%A2/bar"},
   };
   TemplateURLData data;
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     data.input_encodings.clear();
     data.input_encodings.push_back(test_data[i].encoding);
@@ -583,7 +583,7 @@
   };
 
   TemplateURLData data;
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     data.input_encodings = test_data[i].encodings;
     TemplateURL url(data);
@@ -639,7 +639,7 @@
   };
   TemplateURLData data;
   data.input_encodings.push_back("UTF-8");
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
     EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
@@ -677,7 +677,7 @@
   };
   TemplateURLData data;
   data.input_encodings.push_back("UTF-8");
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
     EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
@@ -708,7 +708,7 @@
   };
   TemplateURLData data;
   data.input_encodings.push_back("UTF-8");
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
     EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
@@ -745,7 +745,7 @@
   };
   TemplateURLData data;
   data.input_encodings.push_back("UTF-8");
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
     EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
@@ -783,7 +783,7 @@
   TemplateURL url(data);
   EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
   ASSERT_TRUE(url.url_ref().SupportsReplacement(search_terms_data_));
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     TemplateURLRef::SearchTermsArgs search_terms_args(
         ASCIIToUTF16("foobar"));
     search_terms_args.accepted_suggestion = test_data[i].accepted_suggestion;
@@ -853,7 +853,7 @@
       {"http://blah/?q=stock:{searchTerms}", "blah", "/", "q"},
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     TemplateURLData data;
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
@@ -898,7 +898,7 @@
        "", "", ""},
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     TemplateURLData data;
     data.SetURL(test_data[i].url);
     TemplateURL url(data);
@@ -927,7 +927,7 @@
     { "http://google.com/intl/xx/", "http://google.com/complete/", },
   };
 
-  for (size_t i = 0; i < arraysize(data); ++i)
+  for (size_t i = 0; i < base::size(data); ++i)
     CheckSuggestBaseURL(data[i].base_url, data[i].base_suggest_url);
 }
 
@@ -1617,7 +1617,7 @@
     { "http://bar/newtab", false, },
   };
 
-  for (size_t i = 0; i < arraysize(url_data); ++i) {
+  for (size_t i = 0; i < base::size(url_data); ++i) {
     EXPECT_EQ(url_data[i].result,
               search_provider.IsSearchURL(GURL(url_data[i].url),
                                           search_terms_data_));
@@ -1734,7 +1734,7 @@
       "http://foo/blah.blah.blah.blah.blah" }
   };
 
-  for (size_t i = 0; i < arraysize(generate_url_cases); ++i) {
+  for (size_t i = 0; i < base::size(generate_url_cases); ++i) {
     TemplateURLData data;
     data.SetURL(generate_url_cases[i].url);
     TemplateURL t_url(data);
diff --git a/components/services/filesystem/directory_impl_unittest.cc b/components/services/filesystem/directory_impl_unittest.cc
index 83c590ae..ef2a1ae 100644
--- a/components/services/filesystem/directory_impl_unittest.cc
+++ b/components/services/filesystem/directory_impl_unittest.cc
@@ -8,7 +8,7 @@
 #include <map>
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/services/filesystem/files_test_base.h"
 
 namespace filesystem {
@@ -31,7 +31,7 @@
       {"my_file1", mojom::kFlagRead | mojom::kFlagWrite | mojom::kFlagCreate},
       {"my_file2", mojom::kFlagWrite | mojom::kFlagCreate},
       {"my_file3", mojom::kFlagAppend | mojom::kFlagCreate}};
-  for (size_t i = 0; i < arraysize(files_to_create); i++) {
+  for (size_t i = 0; i < base::size(files_to_create); i++) {
     error = base::File::Error::FILE_ERROR_FAILED;
     bool handled = directory->OpenFile(files_to_create[i].name, nullptr,
                                        files_to_create[i].open_flags, &error);
diff --git a/components/sessions/core/session_backend_unittest.cc b/components/sessions/core/session_backend_unittest.cc
index 5829bf6..9fc9ec4 100644
--- a/components/sessions/core/session_backend_unittest.cc
+++ b/components/sessions/core/session_backend_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -107,7 +107,7 @@
     { 13, "abcdefghijklm" },
   };
 
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     scoped_refptr<SessionBackend> backend(
         new SessionBackend(sessions::BaseSessionService::SESSION_RESTORE,
                            path_));
diff --git a/components/signin/core/browser/signin_error_controller_unittest.cc b/components/signin/core/browser/signin_error_controller_unittest.cc
index fabde75..e98af60 100644
--- a/components/signin/core/browser/signin_error_controller_unittest.cc
+++ b/components/signin/core/browser/signin_error_controller_unittest.cc
@@ -9,8 +9,8 @@
 #include <functional>
 #include <memory>
 
-#include "base/macros.h"
 #include "base/scoped_observer.h"
+#include "base/stl_util.h"
 #include "components/prefs/testing_pref_service.h"
 #include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -160,8 +160,8 @@
       GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE,
       GoogleServiceAuthError::SERVICE_ERROR,
       GoogleServiceAuthError::WEB_LOGIN_REQUIRED};
-  static_assert(arraysize(table) == GoogleServiceAuthError::NUM_STATES,
-      "table array does not match the number of auth error types");
+  static_assert(base::size(table) == GoogleServiceAuthError::NUM_STATES,
+                "table array does not match the number of auth error types");
 
   for (GoogleServiceAuthError::State state : table) {
     if (GoogleServiceAuthError::IsDeprecated(state))
diff --git a/components/spellcheck/browser/android/component_jni_registrar.cc b/components/spellcheck/browser/android/component_jni_registrar.cc
index 306b4d68..6f0197c 100644
--- a/components/spellcheck/browser/android/component_jni_registrar.cc
+++ b/components/spellcheck/browser/android/component_jni_registrar.cc
@@ -6,7 +6,7 @@
 
 #include "base/android/jni_android.h"
 #include "base/android/jni_registrar.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/spellcheck/browser/spellchecker_session_bridge_android.h"
 
 namespace spellcheck {
@@ -19,9 +19,8 @@
 
 bool RegisterSpellcheckJni(JNIEnv* env) {
   return base::android::RegisterNativeMethods(
-      env,
-          kSpellcheckRegisteredMethods,
-      arraysize(kSpellcheckRegisteredMethods));
+      env, kSpellcheckRegisteredMethods,
+      base::size(kSpellcheckRegisteredMethods));
 }
 
 }  // namespace android
diff --git a/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc b/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc
index 28b4bb4..9d030076 100644
--- a/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc
+++ b/components/spellcheck/browser/spellcheck_host_metrics_unittest.cc
@@ -8,8 +8,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/metrics/histogram_samples.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/test/scoped_task_environment.h"
@@ -83,7 +83,7 @@
   RecordWordCountsForTesting();
 
   // Get samples for all affected histograms.
-  for (size_t i = 0; i < arraysize(histogram_names); ++i)
+  for (size_t i = 0; i < base::size(histogram_names); ++i)
     histogram_tester.ExpectTotalCount(histogram_names[i], 0);
 }
 
diff --git a/components/spellcheck/browser/spellcheck_platform_mac_unittest.cc b/components/spellcheck/browser/spellcheck_platform_mac_unittest.cc
index 7af8386..155c206 100644
--- a/components/spellcheck/browser/spellcheck_platform_mac_unittest.cc
+++ b/components/spellcheck/browser/spellcheck_platform_mac_unittest.cc
@@ -7,9 +7,9 @@
 #include <stddef.h>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
@@ -66,7 +66,7 @@
     "noooen",
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const base::string16 word(base::ASCIIToUTF16(kTestCases[i]));
     const int doc_tag = spellcheck_platform::GetDocumentTag();
 
@@ -364,7 +364,7 @@
     {"writting", "writing"},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     const base::string16 word(base::ASCIIToUTF16(kTestCases[i].input));
     EXPECT_FALSE(spellcheck_platform::CheckSpelling(word, 0)) << word;
 
diff --git a/components/spellcheck/common/spellcheck_common.cc b/components/spellcheck/common/spellcheck_common.cc
index 2523bdd..fe89924 100644
--- a/components/spellcheck/common/spellcheck_common.cc
+++ b/components/spellcheck/common/spellcheck_common.cc
@@ -7,8 +7,8 @@
 #include "base/command_line.h"
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "third_party/icu/source/common/unicode/uloc.h"
 #include "third_party/icu/source/common/unicode/urename.h"
@@ -174,9 +174,9 @@
   if (!locale.empty()) {
     UErrorCode error = U_ZERO_ERROR;
     char id[ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY];
-    uloc_addLikelySubtags(locale.c_str(), id, arraysize(id), &error);
+    uloc_addLikelySubtags(locale.c_str(), id, base::size(id), &error);
     error = U_ZERO_ERROR;
-    uloc_getLanguage(id, language, arraysize(language), &error);
+    uloc_getLanguage(id, language, base::size(language), &error);
     country = uloc_getISO3Country(id);
   }
   *language_code = std::string(language);
diff --git a/components/spellcheck/renderer/spellcheck_multilingual_unittest.cc b/components/spellcheck/renderer/spellcheck_multilingual_unittest.cc
index 622e4a6..f356798 100644
--- a/components/spellcheck/renderer/spellcheck_multilingual_unittest.cc
+++ b/components/spellcheck/renderer/spellcheck_multilingual_unittest.cc
@@ -8,8 +8,8 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -150,7 +150,7 @@
   do {
     std::string reordered_languages = base::JoinString(permuted_languages, ",");
     ExpectSpellCheckWordResults(reordered_languages, kTestCases,
-                                arraysize(kTestCases));
+                                base::size(kTestCases));
   } while (std::next_permutation(permuted_languages.begin(),
                                  permuted_languages.end()));
 }
@@ -181,7 +181,8 @@
       {L"hola sand hola sand hola sand", 0, 0},
       {L"hola:legs", 0, 9},
       {L"legs:hola", 0, 9}};
-  ExpectSpellCheckWordResults("en-US,es-ES", kTestCases, arraysize(kTestCases));
+  ExpectSpellCheckWordResults("en-US,es-ES", kTestCases,
+                              base::size(kTestCases));
 }
 
 // If there are no spellcheck languages, no text should be marked as misspelled.
@@ -237,7 +238,7 @@
       {L"asdne", 0, 5, L"sadness,desasne"},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     blink::WebVector<blink::WebString> suggestions;
     int misspelling_start;
     int misspelling_length;
diff --git a/components/spellcheck/renderer/spellcheck_unittest.cc b/components/spellcheck/renderer/spellcheck_unittest.cc
index 5832240..947ef73 100644
--- a/components/spellcheck/renderer/spellcheck_unittest.cc
+++ b/components/spellcheck/renderer/spellcheck_unittest.cc
@@ -11,9 +11,9 @@
 
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
@@ -402,7 +402,7 @@
     {L"3.141592653", true},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     size_t input_length = 0;
     if (kTestCases[i].input)
       input_length = wcslen(kTestCases[i].input);
@@ -824,7 +824,7 @@
     },
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     ReinitializeSpellCheck(kTestCases[i].language);
     size_t input_length = 0;
     if (kTestCases[i].input)
@@ -883,7 +883,7 @@
     },
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     ReinitializeSpellCheck(kTestCases[i].language);
 
     base::string16 word(base::WideToUTF16(kTestCases[i].input));
@@ -1291,9 +1291,9 @@
 
   static const char* const kLocales[] = { "en-GB", "en-US", "en-CA", "en-AU" };
 
-  for (size_t j = 0; j < arraysize(kLocales); ++j) {
+  for (size_t j = 0; j < base::size(kLocales); ++j) {
     ReinitializeSpellCheck(kLocales[j]);
-    for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+    for (size_t i = 0; i < base::size(kTestCases); ++i) {
       size_t input_length = 0;
       if (kTestCases[i].input)
         input_length = strlen(kTestCases[i].input);
@@ -1424,7 +1424,7 @@
   InitializeIfNeeded();
   ASSERT_FALSE(InitializeIfNeeded());
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     bool result = CheckSpelling(kTestCases[i].word, 0);
     EXPECT_EQ(kTestCases[i].expected_result, result) <<
         "Failed test for " << kTestCases[i].word;
@@ -1442,7 +1442,7 @@
     { "accidently", "accidentally" }
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     int misspelling_start = 0;
     int misspelling_length = 0;
     std::vector<base::string16> suggestions;
@@ -1470,9 +1470,9 @@
       L"in" TYPOGRAPHICAL_APOSTROPHE L"n" TYPOGRAPHICAL_APOSTROPHE L"out",
   };
 
-  for (size_t i = 0; i < arraysize(kLanguages); ++i) {
+  for (size_t i = 0; i < base::size(kLanguages); ++i) {
     ReinitializeSpellCheck(kLanguages[i]);
-    for (size_t j = 0; j < arraysize(kWords); ++j)
+    for (size_t j = 0; j < base::size(kWords); ++j)
       EXPECT_TRUE(IsValidContraction(base::WideToUTF16(kWords[j]), 0));
   }
 }
diff --git a/components/spellcheck/renderer/spellcheck_worditerator.cc b/components/spellcheck/renderer/spellcheck_worditerator.cc
index 1bd631cb..00351e19 100644
--- a/components/spellcheck/renderer/spellcheck_worditerator.cc
+++ b/components/spellcheck/renderer/spellcheck_worditerator.cc
@@ -13,7 +13,7 @@
 
 #include "base/i18n/break_iterator.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/spellcheck/renderer/spellcheck.h"
@@ -141,7 +141,7 @@
   UErrorCode error = U_ZERO_ERROR;
   UScriptCode script_code[8];
   int scripts = uscript_getCode(language.c_str(), script_code,
-                                arraysize(script_code), &error);
+                                base::size(script_code), &error);
   if (U_SUCCESS(error) && scripts >= 1)
     script_code_ = script_code[0];
 
diff --git a/components/spellcheck/renderer/spellcheck_worditerator_unittest.cc b/components/spellcheck/renderer/spellcheck_worditerator_unittest.cc
index 37ac36d..e415d5e 100644
--- a/components/spellcheck/renderer/spellcheck_worditerator_unittest.cc
+++ b/components/spellcheck/renderer/spellcheck_worditerator_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "base/format_macros.h"
 #include "base/i18n/break_iterator.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -156,7 +156,7 @@
     },
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestCases[%" PRIuS "]: language=%s", i,
                                     kTestCases[i].language));
 
@@ -261,7 +261,7 @@
     },
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestCases[%" PRIuS "]: language=%s", i,
                                     kTestCases[i].language));
 
@@ -308,7 +308,7 @@
       {"en-US", L"....you\x2019re", L"you\x2019re"},
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     SpellcheckCharAttribute attributes;
     attributes.SetDefaultLanguage(kTestCases[i].language);
 
diff --git a/components/ssl_errors/error_info.cc b/components/ssl_errors/error_info.cc
index 1ed896c..fe7e645 100644
--- a/components/ssl_errors/error_info.cc
+++ b/components/ssl_errors/error_info.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/i18n/message_formatter.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/strings/grit/components_strings.h"
 #include "net/base/escape.h"
@@ -262,9 +262,9 @@
       CERTIFICATE_TRANSPARENCY_REQUIRED,
       CERT_SYMANTEC_LEGACY,
   };
-  DCHECK(arraysize(kErrorFlags) == arraysize(kErrorTypes));
+  DCHECK(base::size(kErrorFlags) == base::size(kErrorTypes));
 
-  for (size_t i = 0; i < arraysize(kErrorFlags); ++i) {
+  for (size_t i = 0; i < base::size(kErrorFlags); ++i) {
     if ((cert_status & kErrorFlags[i]) && errors) {
       errors->push_back(
           ErrorInfo::CreateError(kErrorTypes[i], cert.get(), url));
diff --git a/components/storage_monitor/mtab_watcher_linux.cc b/components/storage_monitor/mtab_watcher_linux.cc
index 83297f6..ff7c787 100644
--- a/components/storage_monitor/mtab_watcher_linux.cc
+++ b/components/storage_monitor/mtab_watcher_linux.cc
@@ -11,7 +11,7 @@
 #include <stdio.h>
 
 #include "base/bind.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/scoped_blocking_call.h"
 
 namespace {
@@ -71,7 +71,7 @@
   // devices that have been mounted over.
   while (getmntent_r(fp, &entry, buf, sizeof(buf))) {
     // We only care about real file systems.
-    for (size_t i = 0; i < arraysize(kKnownFileSystems); ++i) {
+    for (size_t i = 0; i < base::size(kKnownFileSystems); ++i) {
       if (strcmp(kKnownFileSystems[i], entry.mnt_type) == 0) {
         device_map[base::FilePath(entry.mnt_dir)] =
             base::FilePath(entry.mnt_fsname);
diff --git a/components/storage_monitor/storage_monitor_linux_unittest.cc b/components/storage_monitor/storage_monitor_linux_unittest.cc
index b99e207..f687267 100644
--- a/components/storage_monitor/storage_monitor_linux_unittest.cc
+++ b/components/storage_monitor/storage_monitor_linux_unittest.cc
@@ -17,8 +17,8 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/task_scheduler/task_scheduler.h"
 #include "base/test/scoped_task_environment.h"
@@ -76,7 +76,7 @@
                                            const base::FilePath& mount_point) {
   bool device_found = false;
   size_t i = 0;
-  for (; i < arraysize(kTestDeviceData); i++) {
+  for (; i < base::size(kTestDeviceData); i++) {
     if (device_path.value() == kTestDeviceData[i].device_path) {
       device_found = true;
       break;
@@ -101,7 +101,7 @@
 }
 
 uint64_t GetDevicePartitionSize(const std::string& device) {
-  for (size_t i = 0; i < arraysize(kTestDeviceData); ++i) {
+  for (size_t i = 0; i < base::size(kTestDeviceData); ++i) {
     if (device == kTestDeviceData[i].device_path)
       return kTestDeviceData[i].partition_size_in_bytes;
   }
@@ -109,7 +109,7 @@
 }
 
 std::string GetDeviceId(const std::string& device) {
-  for (size_t i = 0; i < arraysize(kTestDeviceData); ++i) {
+  for (size_t i = 0; i < base::size(kTestDeviceData); ++i) {
     if (device == kTestDeviceData[i].device_path) {
       return StorageInfo::MakeDeviceId(kTestDeviceData[i].type,
                                             kTestDeviceData[i].unique_id);
@@ -178,9 +178,8 @@
     MtabTestData initial_test_data[] = {
       MtabTestData("dummydevice", "dummydir", kInvalidFS),
     };
-    WriteToMtab(initial_test_data,
-                arraysize(initial_test_data),
-                true  /* overwrite */);
+    WriteToMtab(initial_test_data, base::size(initial_test_data),
+                true /* overwrite */);
 
     monitor_.reset(new TestStorageMonitorLinux(mtab_file_));
 
@@ -333,7 +332,7 @@
   };
   // Only |kDeviceDCIM2| should be attached, since |kDeviceFixed| has a bad
   // path.
-  AppendToMtabAndRunLoop(test_data, arraysize(test_data));
+  AppendToMtabAndRunLoop(test_data, base::size(test_data));
 
   EXPECT_EQ(1, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
@@ -355,7 +354,7 @@
     MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS),
   };
   // |kDeviceDCIM1| should be attached as expected.
-  AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
+  AppendToMtabAndRunLoop(test_data1, base::size(test_data1));
 
   EXPECT_EQ(1, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
@@ -368,7 +367,7 @@
   MtabTestData test_data2[] = {
     MtabTestData(kDeviceFixed, test_path_b.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
+  AppendToMtabAndRunLoop(test_data2, base::size(test_data2));
   EXPECT_EQ(1, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
@@ -382,7 +381,7 @@
   MtabTestData test_data3[] = {
     MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data3, arraysize(test_data3));
+  AppendToMtabAndRunLoop(test_data3, base::size(test_data3));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(1, observer().detach_calls());
   EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), observer().last_attached().device_id());
@@ -410,7 +409,7 @@
     MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS),
     MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
+  AppendToMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
@@ -422,7 +421,7 @@
     MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS),
     MtabTestData(kDeviceDCIM2, test_path_a.value(), kValidFS),
   };
-  OverwriteMtabAndRunLoop(test_data2, arraysize(test_data2));
+  OverwriteMtabAndRunLoop(test_data2, base::size(test_data2));
   EXPECT_EQ(4, observer().attach_calls());
   EXPECT_EQ(2, observer().detach_calls());
 
@@ -447,7 +446,7 @@
     MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS),
     MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
+  AppendToMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
@@ -460,7 +459,7 @@
   MtabTestData test_data2[] = {
     MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
+  AppendToMtabAndRunLoop(test_data2, base::size(test_data2));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(1, observer().detach_calls());
 
@@ -472,7 +471,7 @@
     MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS),
     MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS),
   };
-  OverwriteMtabAndRunLoop(test_data3, arraysize(test_data3));
+  OverwriteMtabAndRunLoop(test_data3, base::size(test_data3));
   EXPECT_EQ(3, observer().attach_calls());
   EXPECT_EQ(2, observer().detach_calls());
 
@@ -483,14 +482,14 @@
   MtabTestData test_data4[] = {
     MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data4, arraysize(test_data4));
+  AppendToMtabAndRunLoop(test_data4, base::size(test_data4));
   EXPECT_EQ(3, observer().attach_calls());
   EXPECT_EQ(2, observer().detach_calls());
 
   // Detach |kDeviceDCIM1| from |kMountPointB|.
   // kDeviceDCIM1 -> kMountPointA *
   // kDeviceDCIM2 -> kMountPointB *
-  OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1));
+  OverwriteMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(5, observer().attach_calls());
   EXPECT_EQ(3, observer().detach_calls());
 
@@ -512,7 +511,7 @@
   MtabTestData test_data1[] = {
     MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
+  AppendToMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(1, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
@@ -522,7 +521,7 @@
   MtabTestData test_data2[] = {
     MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
+  AppendToMtabAndRunLoop(test_data2, base::size(test_data2));
   EXPECT_EQ(1, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
@@ -534,7 +533,7 @@
     MtabTestData(kDeviceFixed, test_path_a.value(), kValidFS),
   };
   RemoveDCIMDirFromMountPoint(kMountPointA);
-  AppendToMtabAndRunLoop(test_data3, arraysize(test_data3));
+  AppendToMtabAndRunLoop(test_data3, base::size(test_data3));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(1, observer().detach_calls());
 
@@ -546,7 +545,7 @@
     MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS),
   };
   CreateMountPointWithDCIMDir(kMountPointA);
-  OverwriteMtabAndRunLoop(test_data4, arraysize(test_data4));
+  OverwriteMtabAndRunLoop(test_data4, base::size(test_data4));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(1, observer().detach_calls());
 
@@ -558,7 +557,7 @@
     MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS),
   };
   base::DeleteFile(test_path_b.Append(kDCIMDirectoryName), false);
-  AppendToMtabAndRunLoop(test_data5, arraysize(test_data5));
+  AppendToMtabAndRunLoop(test_data5, base::size(test_data5));
   EXPECT_EQ(4, observer().attach_calls());
   EXPECT_EQ(2, observer().detach_calls());
 
@@ -570,13 +569,13 @@
     MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS),
   };
   CreateMountPointWithDCIMDir(kMountPointB);
-  OverwriteMtabAndRunLoop(test_data6, arraysize(test_data6));
+  OverwriteMtabAndRunLoop(test_data6, base::size(test_data6));
   EXPECT_EQ(4, observer().attach_calls());
   EXPECT_EQ(3, observer().detach_calls());
 
   // Detach |kDeviceDCIM1| from |kMountPointB|.
   // kDeviceDCIM1 -> kMountPointA *
-  OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1));
+  OverwriteMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(4, observer().attach_calls());
   EXPECT_EQ(3, observer().detach_calls());
 
@@ -604,7 +603,7 @@
     MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS),
     MtabTestData(kDeviceFixed, test_path_c.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
+  AppendToMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
@@ -645,7 +644,7 @@
     MtabTestData(kDeviceFixed, test_path_b.value(), kValidFS),
     MtabTestData(kDeviceFixed, test_path_c.value(), kValidFS),
   };
-  AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
+  AppendToMtabAndRunLoop(test_data2, base::size(test_data2));
 
   EXPECT_TRUE(notifier()->GetStorageInfoForPath(test_path_a, &device_info));
   EXPECT_EQ(GetDeviceId(kDeviceDCIM1), device_info.device_id());
@@ -671,7 +670,7 @@
     MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS),
     MtabTestData(kDeviceFixed, kInvalidPath, kInvalidFS),
   };
-  AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
+  AppendToMtabAndRunLoop(test_data1, base::size(test_data1));
   EXPECT_EQ(2, observer().attach_calls());
   EXPECT_EQ(0, observer().detach_calls());
 
diff --git a/components/subresource_filter/content/browser/async_document_subresource_filter_unittest.cc b/components/subresource_filter/content/browser/async_document_subresource_filter_unittest.cc
index db8389e..91d4fe7 100644
--- a/components/subresource_filter/content/browser/async_document_subresource_filter_unittest.cc
+++ b/components/subresource_filter/content/browser/async_document_subresource_filter_unittest.cc
@@ -9,8 +9,8 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/test/test_simple_task_runner.h"
 #include "base/threading/sequenced_task_runner_handle.h"
@@ -408,7 +408,7 @@
        MakeState(true, true)},
   };
 
-  for (size_t i = 0, size = arraysize(kTestCases); i != size; ++i) {
+  for (size_t i = 0, size = base::size(kTestCases); i != size; ++i) {
     SCOPED_TRACE(::testing::Message() << "Test number: " << i);
     const auto& test_case = kTestCases[i];
 
diff --git a/components/sync/base/get_session_name_win.cc b/components/sync/base/get_session_name_win.cc
index b14eb404..ef08f294 100644
--- a/components/sync/base/get_session_name_win.cc
+++ b/components/sync/base/get_session_name_win.cc
@@ -7,7 +7,7 @@
 #include <windows.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 
 namespace syncer {
@@ -15,7 +15,7 @@
 
 std::string GetComputerName() {
   wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
-  DWORD size = arraysize(computer_name);
+  DWORD size = base::size(computer_name);
   if (::GetComputerNameW(computer_name, &size)) {
     std::string result;
     bool conversion_successful = base::WideToUTF8(computer_name, size, &result);
diff --git a/components/sync/base/immutable_unittest.cc b/components/sync/base/immutable_unittest.cc
index c8e0e1c..1402b389 100644
--- a/components/sync/base/immutable_unittest.cc
+++ b/components/sync/base/immutable_unittest.cc
@@ -11,6 +11,7 @@
 #include <vector>
 
 #include "base/containers/circular_deque.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace syncer {
@@ -164,7 +165,7 @@
 void RunTokenContainerTest(const char* token) {
   SCOPED_TRACE(token);
   const Token tokens[] = {Token(), Token(token)};
-  const size_t token_count = arraysize(tokens);
+  const size_t token_count = base::size(tokens);
   C c(tokens, tokens + token_count);
   const int copy_count = c.begin()->GetCopyCount();
   EXPECT_GT(copy_count, 0);
diff --git a/components/sync/base/node_ordinal_unittest.cc b/components/sync/base/node_ordinal_unittest.cc
index ca76c660..c6c3ba14 100644
--- a/components/sync/base/node_ordinal_unittest.cc
+++ b/components/sync/base/node_ordinal_unittest.cc
@@ -10,7 +10,7 @@
 #include <limits>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace syncer {
@@ -59,7 +59,7 @@
                                INT64_MIN + 1,
                                INT64_MAX - 1};
 
-const size_t kNumTestValues = arraysize(kTestValues);
+const size_t kNumTestValues = base::size(kTestValues);
 
 // Convert each test value to an ordinal.  All ordinals should be
 // valid.
diff --git a/components/sync/base/unique_position_unittest.cc b/components/sync/base/unique_position_unittest.cc
index d79799a..f13fe34 100644
--- a/components/sync/base/unique_position_unittest.cc
+++ b/components/sync/base/unique_position_unittest.cc
@@ -411,9 +411,10 @@
 class PositionScenariosTest : public UniquePositionTest {
  public:
   PositionScenariosTest()
-      : generator1_(std::string(kCacheGuidStr1, arraysize(kCacheGuidStr1) - 1)),
+      : generator1_(
+            std::string(kCacheGuidStr1, base::size(kCacheGuidStr1) - 1)),
         generator2_(
-            std::string(kCacheGuidStr2, arraysize(kCacheGuidStr2) - 1)) {}
+            std::string(kCacheGuidStr2, base::size(kCacheGuidStr2) - 1)) {}
 
   std::string NextClient1Suffix() { return generator1_.NextSuffix(); }
 
@@ -499,8 +500,8 @@
 class PositionFromIntTest : public UniquePositionTest {
  public:
   PositionFromIntTest()
-      : generator_(std::string(kCacheGuidStr1, arraysize(kCacheGuidStr1) - 1)) {
-  }
+      : generator_(
+            std::string(kCacheGuidStr1, base::size(kCacheGuidStr1) - 1)) {}
 
  protected:
   static const int64_t kTestValues[];
@@ -555,7 +556,7 @@
                                                     INT64_MAX - 1};
 
 const size_t PositionFromIntTest::kNumTestValues =
-    arraysize(PositionFromIntTest::kTestValues);
+    base::size(PositionFromIntTest::kTestValues);
 
 TEST_F(PositionFromIntTest, IsValid) {
   for (size_t i = 0; i < kNumTestValues; ++i) {
diff --git a/components/sync/driver/model_association_manager.cc b/components/sync/driver/model_association_manager.cc
index a5bcb2fa..3179121 100644
--- a/components/sync/driver/model_association_manager.cc
+++ b/components/sync/driver/model_association_manager.cc
@@ -14,6 +14,7 @@
 #include "base/barrier_closure.h"
 #include "base/logging.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "components/sync/base/model_type.h"
 #include "components/sync/base/sync_stop_metadata_fate.h"
@@ -46,7 +47,7 @@
     DEPRECATED_SUPERVISED_USER_SHARED_SETTINGS, DEPRECATED_ARTICLES,
     SEND_TAB_TO_SELF};
 
-static_assert(arraysize(kStartOrder) ==
+static_assert(base::size(kStartOrder) ==
                   MODEL_TYPE_COUNT - FIRST_REAL_MODEL_TYPE,
               "When adding a new type, update kStartOrder.");
 
@@ -218,7 +219,7 @@
     }
   }
   // Load in kStartOrder.
-  for (size_t i = 0; i < arraysize(kStartOrder); i++) {
+  for (size_t i = 0; i < base::size(kStartOrder); i++) {
     ModelType type = kStartOrder[i];
     if (!desired_types_.Has(type))
       continue;
@@ -268,7 +269,7 @@
                               weak_ptr_factory_.GetWeakPtr(), INITIALIZED));
 
   // Start association of types that are loaded in specified order.
-  for (size_t i = 0; i < arraysize(kStartOrder); i++) {
+  for (size_t i = 0; i < base::size(kStartOrder); i++) {
     ModelType type = kStartOrder[i];
     if (!associating_types_.Has(type) || !loaded_types_.Has(type))
       continue;
diff --git a/components/sync/engine/engine_util.cc b/components/sync/engine/engine_util.cc
index 74e0367..a0e8a16 100644
--- a/components/sync/engine/engine_util.cc
+++ b/components/sync/engine/engine_util.cc
@@ -9,7 +9,7 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/sync/base/cryptographer.h"
 #include "components/sync/protocol/password_specifics.pb.h"
 #include "components/sync/protocol/sync.pb.h"
@@ -71,7 +71,7 @@
 // also illegal, but are not considered here.
 bool IsNameServerIllegalAfterTrimming(const std::string& name) {
   size_t untrimmed_count = name.find_last_not_of(' ') + 1;
-  for (size_t i = 0; i < arraysize(kForbiddenServerNames); ++i) {
+  for (size_t i = 0; i < base::size(kForbiddenServerNames); ++i) {
     if (name.compare(0, untrimmed_count, kForbiddenServerNames[i]) == 0)
       return true;
   }
diff --git a/components/sync/engine_impl/directory_update_handler_unittest.cc b/components/sync/engine_impl/directory_update_handler_unittest.cc
index 39095e04..02addc6 100644
--- a/components/sync/engine_impl/directory_update_handler_unittest.cc
+++ b/components/sync/engine_impl/directory_update_handler_unittest.cc
@@ -11,6 +11,7 @@
 #include <utility>
 
 #include "base/compiler_specific.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "components/sync/engine_impl/cycle/directory_type_debug_info_emitter.h"
 #include "components/sync/engine_impl/cycle/status_controller.h"
@@ -138,7 +139,7 @@
   std::unique_ptr<sync_pb::SyncEntity> e =
       CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS);
   e->set_originator_cache_guid(
-      std::string(kCacheGuid, arraysize(kCacheGuid) - 1));
+      std::string(kCacheGuid, base::size(kCacheGuid) - 1));
   Id client_id = Id::CreateFromClientString("-2");
   e->set_originator_client_item_id(client_id.GetServerId());
   e->set_position_in_parent(0);
diff --git a/components/sync/engine_impl/syncer_unittest.cc b/components/sync/engine_impl/syncer_unittest.cc
index 2b2b452..5e9ca93 100644
--- a/components/sync/engine_impl/syncer_unittest.cc
+++ b/components/sync/engine_impl/syncer_unittest.cc
@@ -19,6 +19,7 @@
 #include "base/bind_helpers.h"
 #include "base/compiler_specific.h"
 #include "base/location.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/test/scoped_task_environment.h"
@@ -425,7 +426,7 @@
         const base::Time& now_minus_2h =
             base::Time::Now() - base::TimeDelta::FromHours(2);
         entry.PutMtime(now_plus_30s);
-        for (size_t i = 0; i < arraysize(test->features); ++i) {
+        for (size_t i = 0; i < base::size(test->features); ++i) {
           switch (test->features[i]) {
             case LIST_END:
               break;
diff --git a/components/sync/syncable/directory_backing_store.cc b/components/sync/syncable/directory_backing_store.cc
index f7caaea..2ea4ac7f4 100644
--- a/components/sync/syncable/directory_backing_store.cc
+++ b/components/sync/syncable/directory_backing_store.cc
@@ -17,6 +17,7 @@
 #include "base/metrics/histogram_macros.h"
 #include "base/rand_util.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -237,9 +238,9 @@
 
 string ComposeCreateTableColumnSpecs() {
   const ColumnSpec* begin = g_metas_columns;
-  const ColumnSpec* end = g_metas_columns + arraysize(g_metas_columns);
+  const ColumnSpec* end = g_metas_columns + base::size(g_metas_columns);
   // Verify that the array was fully initialized.
-  DCHECK(g_metas_columns[arraysize(g_metas_columns) - 1].name != nullptr);
+  DCHECK(g_metas_columns[base::size(g_metas_columns) - 1].name != nullptr);
   string query;
   query.reserve(kUpdateStatementBufferSize);
   char separator = '(';
diff --git a/components/sync/syncable/directory_unittest.cc b/components/sync/syncable/directory_unittest.cc
index ab0a039..de27121 100644
--- a/components/sync/syncable/directory_unittest.cc
+++ b/components/sync/syncable/directory_unittest.cc
@@ -8,9 +8,9 @@
 
 #include <cstdlib>
 
-#include "base/macros.h"
 #include "base/rand_util.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/values_test_util.h"
 #include "components/sync/base/mock_unrecoverable_error_handler.h"
@@ -1328,7 +1328,7 @@
   TestIdFactory id_factory;
   Id null_child_id;
   const char null_cstr[] = "\0null\0test";
-  std::string null_str(null_cstr, arraysize(null_cstr) - 1);
+  std::string null_str(null_cstr, base::size(null_cstr) - 1);
   // Pad up to the minimum length with 0x7f characters, then add a string that
   // contains a few nulls to the end.  This is slightly wrong, since the suffix
   // part of a UniquePosition shouldn't contain nulls, but it's good enough for
diff --git a/components/sync/syncable/model_type.cc b/components/sync/syncable/model_type.cc
index 191c4ae..bb45a57 100644
--- a/components/sync/syncable/model_type.cc
+++ b/components/sync/syncable/model_type.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/values.h"
 #include "components/sync/protocol/app_notification_specifics.pb.h"
@@ -159,7 +159,7 @@
      sync_pb::EntitySpecifics::kExperimentsFieldNumber, 19},
 };
 
-static_assert(arraysize(kModelTypeInfoMap) == MODEL_TYPE_COUNT,
+static_assert(base::size(kModelTypeInfoMap) == MODEL_TYPE_COUNT,
               "kModelTypeInfoMap should have MODEL_TYPE_COUNT elements");
 
 static_assert(43 == syncer::MODEL_TYPE_COUNT,
@@ -549,7 +549,7 @@
 ModelType ModelTypeFromString(const std::string& model_type_string) {
   if (model_type_string != "Unspecified" &&
       model_type_string != "Top Level Folder") {
-    for (size_t i = 0; i < arraysize(kModelTypeInfoMap); ++i) {
+    for (size_t i = 0; i < base::size(kModelTypeInfoMap); ++i) {
       if (kModelTypeInfoMap[i].model_type_string == model_type_string)
         return kModelTypeInfoMap[i].model_type;
     }
@@ -639,7 +639,7 @@
     *model_type = UNSPECIFIED;
     return false;
   }
-  for (size_t i = 0; i < arraysize(kModelTypeInfoMap); ++i) {
+  for (size_t i = 0; i < base::size(kModelTypeInfoMap); ++i) {
     if (kModelTypeInfoMap[i].notification_type == notification_type) {
       *model_type = kModelTypeInfoMap[i].model_type;
       return true;
diff --git a/components/test/components_test_suite.cc b/components/test/components_test_suite.cc
index 2d4e426..5bedab8 100644
--- a/components/test/components_test_suite.cc
+++ b/components/test/components_test_suite.cc
@@ -9,8 +9,8 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/test/launcher/unit_test_launcher.h"
 #include "base/test/test_suite.h"
 #include "build/build_config.h"
@@ -97,7 +97,7 @@
 
     ContentSettingsPattern::SetNonWildcardDomainNonPortSchemes(
         kNonWildcardDomainNonPortSchemes,
-        arraysize(kNonWildcardDomainNonPortSchemes));
+        base::size(kNonWildcardDomainNonPortSchemes));
   }
 
   void Shutdown() override {
diff --git a/components/tracing/common/graphics_memory_dump_provider_android.cc b/components/tracing/common/graphics_memory_dump_provider_android.cc
index 520f72b..d38aa20 100644
--- a/components/tracing/common/graphics_memory_dump_provider_android.cc
+++ b/components/tracing/common/graphics_memory_dump_provider_android.cc
@@ -13,8 +13,8 @@
 #include <sys/un.h>
 
 #include "base/files/scoped_file.h"
-#include "base/macros.h"
 #include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_tokenizer.h"
@@ -129,7 +129,7 @@
 
     // Append a row to the memory dump.
     std::string dump_name;
-    dump_name.reserve(arraysize(kDumpBaseName) + row_name.size() + 1);
+    dump_name.reserve(base::size(kDumpBaseName) + row_name.size() + 1);
     dump_name.assign(kDumpBaseName);
     row_name.AppendToString(&dump_name);
     MemoryAllocatorDump* mad = pmd->GetOrCreateAllocatorDump(dump_name);
diff --git a/components/translate/core/browser/translate_browser_metrics.cc b/components/translate/core/browser/translate_browser_metrics.cc
index 7a3ef47ac..88e42b60 100644
--- a/components/translate/core/browser/translate_browser_metrics.cc
+++ b/components/translate/core/browser/translate_browser_metrics.cc
@@ -8,10 +8,10 @@
 
 #include <string>
 
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/metrics_hashes.h"
+#include "base/stl_util.h"
 #include "components/language_usage_metrics/language_usage_metrics.h"
 
 namespace translate {
@@ -58,7 +58,7 @@
     kTranslateTargetLanguage },
 };
 
-static_assert(arraysize(kMetricsEntries) == TranslateBrowserMetrics::UMA_MAX,
+static_assert(base::size(kMetricsEntries) == TranslateBrowserMetrics::UMA_MAX,
               "kMetricsEntries should have UMA_MAX elements");
 
 }  // namespace
@@ -105,7 +105,7 @@
 }
 
 const char* GetMetricsName(MetricsNameIndex index) {
-  for (size_t i = 0; i < arraysize(kMetricsEntries); ++i) {
+  for (size_t i = 0; i < base::size(kMetricsEntries); ++i) {
     if (kMetricsEntries[i].index == index)
       return kMetricsEntries[i].name;
   }
diff --git a/components/translate/core/browser/translate_language_list.cc b/components/translate/core/browser/translate_language_list.cc
index e6016ab..159bee1 100644
--- a/components/translate/core/browser/translate_language_list.cc
+++ b/components/translate/core/browser/translate_language_list.cc
@@ -12,7 +12,7 @@
 #include "base/json/json_reader.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
@@ -157,7 +157,7 @@
   // We default to our hard coded list of languages in
   // |kDefaultSupportedLanguages|. This list will be overridden by a server
   // providing supported languages list.
-  for (size_t i = 0; i < arraysize(kDefaultSupportedLanguages); ++i)
+  for (size_t i = 0; i < base::size(kDefaultSupportedLanguages); ++i)
     supported_languages_.insert(kDefaultSupportedLanguages[i]);
 
   if (update_is_disabled)
diff --git a/components/translate/core/common/translate_util.cc b/components/translate/core/common/translate_util.cc
index 6e1ec09c..87e7a20 100644
--- a/components/translate/core/common/translate_util.cc
+++ b/components/translate/core/common/translate_util.cc
@@ -11,7 +11,7 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/language/core/common/locale_util.h"
 #include "components/translate/core/common/translate_switches.h"
 #include "url/gurl.h"
@@ -60,7 +60,7 @@
 const char kSecurityOrigin[] = "https://translate.googleapis.com/";
 
 void ToTranslateLanguageSynonym(std::string* language) {
-  for (size_t i = 0; i < arraysize(kLanguageCodeSimilitudes); ++i) {
+  for (size_t i = 0; i < base::size(kLanguageCodeSimilitudes); ++i) {
     if (*language == kLanguageCodeSimilitudes[i].chrome_language) {
       *language = kLanguageCodeSimilitudes[i].translate_language;
       return;
@@ -79,7 +79,7 @@
   // instead of the main_part.
   // Note that "zh" does not have any mapping and as such we leave it as is. See
   // https://crbug/798512 for more info.
-  for (size_t i = 0; i < arraysize(kLanguageCodeChineseCompatiblePairs); ++i) {
+  for (size_t i = 0; i < base::size(kLanguageCodeChineseCompatiblePairs); ++i) {
     if (*language == kLanguageCodeChineseCompatiblePairs[i].chrome_language) {
       *language = kLanguageCodeChineseCompatiblePairs[i].translate_language;
       return;
@@ -90,7 +90,7 @@
   }
 
   // Apply linear search here because number of items in the list is just four.
-  for (size_t i = 0; i < arraysize(kLanguageCodeSynonyms); ++i) {
+  for (size_t i = 0; i < base::size(kLanguageCodeSynonyms); ++i) {
     if (main_part == kLanguageCodeSynonyms[i].chrome_language) {
       main_part = std::string(kLanguageCodeSynonyms[i].translate_language);
       break;
@@ -101,7 +101,7 @@
 }
 
 void ToChromeLanguageSynonym(std::string* language) {
-  for (size_t i = 0; i < arraysize(kLanguageCodeSimilitudes); ++i) {
+  for (size_t i = 0; i < base::size(kLanguageCodeSimilitudes); ++i) {
     if (*language == kLanguageCodeSimilitudes[i].translate_language) {
       *language = kLanguageCodeSimilitudes[i].chrome_language;
       return;
@@ -114,7 +114,7 @@
     return;
 
   // Apply liner search here because number of items in the list is just four.
-  for (size_t i = 0; i < arraysize(kLanguageCodeSynonyms); ++i) {
+  for (size_t i = 0; i < base::size(kLanguageCodeSynonyms); ++i) {
     if (main_part == kLanguageCodeSynonyms[i].translate_language) {
       main_part = std::string(kLanguageCodeSynonyms[i].chrome_language);
       break;
diff --git a/components/translate/core/language_detection/language_detection_util.cc b/components/translate/core/language_detection/language_detection_util.cc
index e4e59ed..5bb8b516 100644
--- a/components/translate/core/language_detection/language_detection_util.cc
+++ b/components/translate/core/language_detection/language_detection_util.cc
@@ -7,11 +7,11 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_base.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/metrics_hashes.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -39,7 +39,7 @@
 
 // Checks |kSimilarLanguageCodes| and returns group code.
 int GetSimilarLanguageGroupCode(const std::string& language) {
-  for (size_t i = 0; i < arraysize(kSimilarLanguageCodes); ++i) {
+  for (size_t i = 0; i < base::size(kSimilarLanguageCodes); ++i) {
     if (language.find(kSimilarLanguageCodes[i].code) != 0)
       continue;
     return kSimilarLanguageCodes[i].group;
@@ -323,7 +323,7 @@
 }
 
 bool IsServerWrongConfigurationLanguage(const std::string& language_code) {
-  for (size_t i = 0; i < arraysize(kWellKnownCodesOnWrongConfiguration); ++i) {
+  for (size_t i = 0; i < base::size(kWellKnownCodesOnWrongConfiguration); ++i) {
     if (language_code == kWellKnownCodesOnWrongConfiguration[i])
       return true;
   }
diff --git a/components/url_formatter/elide_url_unittest.cc b/components/url_formatter/elide_url_unittest.cc
index 859822cb..90b919f 100644
--- a/components/url_formatter/elide_url_unittest.cc
+++ b/components/url_formatter/elide_url_unittest.cc
@@ -6,8 +6,8 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "build/build_config.h"
@@ -382,7 +382,7 @@
      kEllipsisStr + ".\xCE\xB5.\xCE\xB6.com"},
   };
 
-  for (size_t i = 0; i < arraysize(testcases); ++i) {
+  for (size_t i = 0; i < base::size(testcases); ++i) {
     // Note this does not use GetWidth(), so typesetting will be done with
     // gfx::Typesetter::DEFAULT. ElideHost() supports either typesetter on Mac.
     const float available_width = gfx::GetStringWidthF(
@@ -489,7 +489,7 @@
      L"https://www.example.com.", L"www.example.com.", L"www.example.com."}};
 
 TEST(TextEliderTest, FormatUrlForSecurityDisplay) {
-  for (size_t i = 0; i < arraysize(common_tests); ++i) {
+  for (size_t i = 0; i < base::size(common_tests); ++i) {
     base::string16 formatted =
         url_formatter::FormatUrlForSecurityDisplay(GURL(common_tests[i].input));
     EXPECT_EQ(base::WideToUTF16(common_tests[i].output), formatted)
@@ -562,7 +562,7 @@
        L"blob:http://www.html5rocks.com/"
        L"4d4ff040-6d61-4446-86d3-13ca07ec9ab9"}};
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     base::string16 formatted =
         url_formatter::FormatUrlForSecurityDisplay(GURL(tests[i].input));
     EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted)
@@ -602,7 +602,7 @@
 }
 
 TEST(TextEliderTest, FormatOriginForSecurityDisplay) {
-  for (size_t i = 0; i < arraysize(common_tests); ++i) {
+  for (size_t i = 0; i < base::size(common_tests); ++i) {
     base::string16 formatted = url_formatter::FormatOriginForSecurityDisplay(
         url::Origin::Create(GURL(common_tests[i].input)));
     EXPECT_EQ(base::WideToUTF16(common_tests[i].output), formatted)
@@ -652,7 +652,7 @@
        L"http://www.html5rocks.com", L"www.html5rocks.com",
        L"http://www.html5rocks.com"}};
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     base::string16 formatted = url_formatter::FormatOriginForSecurityDisplay(
         url::Origin::Create(GURL(tests[i].input)));
     EXPECT_EQ(base::WideToUTF16(tests[i].output), formatted)
diff --git a/components/url_formatter/url_fixer_unittest.cc b/components/url_formatter/url_fixer_unittest.cc
index 77f3856..939e191 100644
--- a/components/url_formatter/url_fixer_unittest.cc
+++ b/components/url_formatter/url_fixer_unittest.cc
@@ -9,7 +9,7 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -246,7 +246,7 @@
   std::string result;
   url::Parsed parts;
 
-  for (size_t i = 0; i < arraysize(segment_cases); ++i) {
+  for (size_t i = 0; i < base::size(segment_cases); ++i) {
     SegmentCase value = segment_cases[i];
     result = url_formatter::SegmentURL(value.input, &parts);
     EXPECT_EQ(value.result, result);
@@ -356,7 +356,7 @@
 };
 
 TEST(URLFixerTest, FixupURL) {
-  for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
+  for (size_t i = 0; i < base::size(fixup_cases); ++i) {
     FixupCase value = fixup_cases[i];
     EXPECT_EQ(value.output,
               url_formatter::FixupURL(value.input, "").possibly_invalid_spec())
@@ -401,7 +401,7 @@
       {"http://somedomainthatwillnotbeagtld:123",
        "http://www.somedomainthatwillnotbeagtld.com:123/"},
   };
-  for (size_t i = 0; i < arraysize(tld_cases); ++i) {
+  for (size_t i = 0; i < base::size(tld_cases); ++i) {
     FixupCase value = tld_cases[i];
     EXPECT_EQ(value.output, url_formatter::FixupURL(value.input, "com")
                                 .possibly_invalid_spec());
@@ -487,7 +487,7 @@
   };
 #endif
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     EXPECT_EQ(cases[i].output,
               url_formatter::FixupURL(cases[i].input, std::string())
                   .possibly_invalid_spec());
@@ -507,7 +507,7 @@
   ASSERT_FALSE(full_path.empty());
 
   // make sure we pass through good URLs
-  for (size_t i = 0; i < arraysize(fixup_cases); ++i) {
+  for (size_t i = 0; i < base::size(fixup_cases); ++i) {
     FixupCase value = fixup_cases[i];
     base::FilePath input = base::FilePath::FromUTF8Unsafe(value.input);
     EXPECT_EQ(value.output,
diff --git a/components/url_formatter/url_formatter.cc b/components/url_formatter/url_formatter.cc
index 516883c..caa6fb0 100644
--- a/components/url_formatter/url_formatter.cc
+++ b/components/url_formatter/url_formatter.cc
@@ -9,8 +9,8 @@
 #include <vector>
 
 #include "base/lazy_instance.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_offset_string_conversions.h"
@@ -202,7 +202,7 @@
     base::OffsetAdjuster::Adjustments* adjustments) {
   DCHECK(new_parsed);
   const char kViewSource[] = "view-source:";
-  const size_t kViewSourceLength = arraysize(kViewSource) - 1;
+  const size_t kViewSourceLength = base::size(kViewSource) - 1;
 
   // Format the underlying URL and record adjustments.
   const std::string& url_str(url.possibly_invalid_spec());
@@ -365,7 +365,7 @@
   IDNConversionStatus idn_status = NO_IDN;
   // Only transform if the input can be an IDN component.
   static const base::char16 kIdnPrefix[] = {'x', 'n', '-', '-'};
-  if ((comp_len > arraysize(kIdnPrefix)) &&
+  if ((comp_len > base::size(kIdnPrefix)) &&
       !memcmp(comp, kIdnPrefix, sizeof(kIdnPrefix))) {
     UIDNA* uidna = g_uidna.Get().value;
     DCHECK(uidna != nullptr);
diff --git a/components/url_formatter/url_formatter_unittest.cc b/components/url_formatter/url_formatter_unittest.cc
index eac7a01..469d654 100644
--- a/components/url_formatter/url_formatter_unittest.cc
+++ b/components/url_formatter/url_formatter_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/stringprintf.h"
@@ -1079,7 +1079,7 @@
       test::kTopDomainsRootPosition};
   IDNSpoofChecker::SetTrieParamsForTesting(trie_params);
 
-  for (size_t i = 0; i < arraysize(idn_cases); i++) {
+  for (size_t i = 0; i < base::size(idn_cases); i++) {
     base::string16 output(IDNToUnicode(idn_cases[i].input));
     base::string16 expected(idn_cases[i].unicode_allowed
                                 ? WideToUTF16(idn_cases[i].unicode_output)
@@ -1374,7 +1374,7 @@
   };
   // clang-format on
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     size_t prefix_len;
     base::string16 formatted = FormatUrl(
         GURL(tests[i].input), tests[i].format_types, tests[i].escape_rules,
diff --git a/components/url_matcher/url_matcher_factory_unittest.cc b/components/url_matcher/url_matcher_factory_unittest.cc
index 1df02966..df62aff 100644
--- a/components/url_matcher/url_matcher_factory_unittest.cc
+++ b/components/url_matcher/url_matcher_factory_unittest.cc
@@ -10,7 +10,7 @@
 #include <utility>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "components/url_matcher/url_matcher_constants.h"
@@ -155,7 +155,7 @@
     &invalid_condition5
   };
 
-  for (size_t i = 0; i < arraysize(invalid_conditions); ++i) {
+  for (size_t i = 0; i < base::size(invalid_conditions); ++i) {
     error.clear();
     result = URLMatcherFactory::CreateFromURLFilterDictionary(
         matcher.condition_factory(), invalid_conditions[i], 1, &error);
@@ -336,7 +336,7 @@
                          kIsUrlCaseSensitive, kIsUrlLowerCaseEnforced, url),
   };
 
-  for (size_t i = 0; i < arraysize(case_tests); ++i) {
+  for (size_t i = 0; i < base::size(case_tests); ++i) {
     SCOPED_TRACE(base::StringPrintf("Iteration: %" PRIuS, i));
     case_tests[i].Test();
   }
diff --git a/components/url_matcher/url_matcher_unittest.cc b/components/url_matcher/url_matcher_unittest.cc
index c9304a8..88c1ae13 100644
--- a/components/url_matcher/url_matcher_unittest.cc
+++ b/components/url_matcher/url_matcher_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
@@ -127,7 +127,7 @@
       {URLMatcherCondition(URLMatcherCondition::HOST_PREFIX, &p1),
        URLMatcherCondition(URLMatcherCondition::HOST_SUFFIX, nullptr)},
   };
-  for (size_t i = 0; i < arraysize(test_smaller); ++i) {
+  for (size_t i = 0; i < base::size(test_smaller); ++i) {
     EXPECT_TRUE(test_smaller[i][0] < test_smaller[i][1])
         << "Test " << i << " of test_smaller failed";
     EXPECT_FALSE(test_smaller[i][1] < test_smaller[i][0])
@@ -139,7 +139,7 @@
       {URLMatcherCondition(URLMatcherCondition::HOST_PREFIX, nullptr),
        URLMatcherCondition(URLMatcherCondition::HOST_PREFIX, nullptr)},
   };
-  for (size_t i = 0; i < arraysize(test_equal); ++i) {
+  for (size_t i = 0; i < base::size(test_equal); ++i) {
     EXPECT_FALSE(test_equal[i][0] < test_equal[i][1])
         << "Test " << i << " of test_equal failed";
     EXPECT_FALSE(test_equal[i][1] < test_equal[i][0])
diff --git a/components/vector_icons/cc_macros.h b/components/vector_icons/cc_macros.h
index 7589f34..83b8a9d 100644
--- a/components/vector_icons/cc_macros.h
+++ b/components/vector_icons/cc_macros.h
@@ -5,6 +5,8 @@
 #ifndef COMPONENTS_VECTOR_ICONS_CC_MACROS_H_
 #define COMPONENTS_VECTOR_ICONS_CC_MACROS_H_
 
+#include "base/stl_util.h"  // For base::size().
+
 // This file holds macros that are common to each vector icon target's
 // vector_icons.cc.template file.
 
@@ -28,7 +30,7 @@
   constexpr char icon_name##Id[] = VECTOR_ICON_ID_PREFIX #icon_name;   \
   static constexpr gfx::VectorIconRep rep_list_name[] = {__VA_ARGS__}; \
   VECTOR_ICON_EXPORT const gfx::VectorIcon icon_name = {               \
-      rep_list_name, arraysize(rep_list_name), icon_name##Id};
+      rep_list_name, base::size(rep_list_name), icon_name##Id};
 
 #else  // !COMPONENTS_VECTOR_ICONS_CC_MACROS_H_
 #error This file should only be included once.
diff --git a/components/visitedlink/browser/visitedlink_master.cc b/components/visitedlink/browser/visitedlink_master.cc
index b41cde5..b48bedf 100644
--- a/components/visitedlink/browser/visitedlink_master.cc
+++ b/components/visitedlink/browser/visitedlink_master.cc
@@ -17,8 +17,8 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_file.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/threading/thread_restrictions.h"
 #include "build/build_config.h"
@@ -997,7 +997,7 @@
   int desired = item_count * 3;
 
   // Find the closest prime.
-  for (size_t i = 0; i < arraysize(table_sizes); i ++) {
+  for (size_t i = 0; i < base::size(table_sizes); i++) {
     if (table_sizes[i] > desired)
       return table_sizes[i];
   }
diff --git a/components/viz/common/gl_helper_benchmark.cc b/components/viz/common/gl_helper_benchmark.cc
index af88ea0..ded755d 100644
--- a/components/viz/common/gl_helper_benchmark.cc
+++ b/components/viz/common/gl_helper_benchmark.cc
@@ -21,8 +21,8 @@
 #include "base/at_exit.h"
 #include "base/command_line.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -131,9 +131,9 @@
   int input_sizes[] = {3200, 2040, 2560, 1476,  // Pixel tab size
                        1920, 1080, 1280, 720,  800, 480, 256, 144};
 
-  for (size_t q = 0; q < arraysize(kQualities); q++) {
-    for (size_t outsize = 0; outsize < arraysize(output_sizes); outsize += 2) {
-      for (size_t insize = 0; insize < arraysize(input_sizes); insize += 2) {
+  for (size_t q = 0; q < base::size(kQualities); q++) {
+    for (size_t outsize = 0; outsize < base::size(output_sizes); outsize += 2) {
+      for (size_t insize = 0; insize < base::size(input_sizes); insize += 2) {
         uint32_t src_texture;
         gl_->GenTextures(1, &src_texture);
         uint32_t dst_texture;
diff --git a/components/viz/common/gl_helper_unittest.cc b/components/viz/common/gl_helper_unittest.cc
index 1b671de..ae1bf5189 100644
--- a/components/viz/common/gl_helper_unittest.cc
+++ b/components/viz/common/gl_helper_unittest.cc
@@ -19,9 +19,9 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -1333,20 +1333,20 @@
     ,
     GLHelperPixelReadbackTest,
     ::testing::Combine(
-        ::testing::Range<unsigned int>(0, arraysize(kQualities)),
-        ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)),
-        ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)),
-        ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes)),
-        ::testing::Range<unsigned int>(0, arraysize(kRGBReadBackSizes))));
+        ::testing::Range<unsigned int>(0, base::size(kQualities)),
+        ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)),
+        ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)),
+        ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes)),
+        ::testing::Range<unsigned int>(0, base::size(kRGBReadBackSizes))));
 
 // Validate that all scaling generates valid pipelines.
 TEST_F(GLHelperTest, ValidateScalerPipelines) {
   int sizes[] = {7, 99, 128, 256, 512, 719, 720, 721, 1920, 2011, 3217, 4096};
-  for (size_t q = 0; q < arraysize(kQualities); q++) {
-    for (size_t x = 0; x < arraysize(sizes); x++) {
-      for (size_t y = 0; y < arraysize(sizes); y++) {
-        for (size_t dst_x = 0; dst_x < arraysize(sizes); dst_x++) {
-          for (size_t dst_y = 0; dst_y < arraysize(sizes); dst_y++) {
+  for (size_t q = 0; q < base::size(kQualities); q++) {
+    for (size_t x = 0; x < base::size(sizes); x++) {
+      for (size_t y = 0; y < base::size(sizes); y++) {
+        for (size_t dst_x = 0; dst_x < base::size(sizes); dst_x++) {
+          for (size_t dst_y = 0; dst_y < base::size(sizes); dst_y++) {
             TestScalerPipeline(q, sizes[x], sizes[y], sizes[dst_x],
                                sizes[dst_y]);
             if (HasFailure()) {
diff --git a/components/viz/common/resources/resource_format_utils.cc b/components/viz/common/resources/resource_format_utils.cc
index 0ea185ae..eb4fdf7 100644
--- a/components/viz/common/resources/resource_format_utils.cc
+++ b/components/viz/common/resources/resource_format_utils.cc
@@ -5,7 +5,7 @@
 #include "components/viz/common/resources/resource_format_utils.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "third_party/khronos/GLES2/gl2.h"
 #include "third_party/khronos/GLES2/gl2ext.h"
 #include "ui/gfx/buffer_types.h"
@@ -114,7 +114,7 @@
       GL_ZERO,                             // YUV_420_BIPLANAR
       GL_ZERO,                             // UYVY_422
   };
-  static_assert(arraysize(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1),
+  static_assert(base::size(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1),
                 "format_gl_data_type does not handle all cases.");
 
   return format_gl_data_type[format];
@@ -144,7 +144,7 @@
       GL_ZERO,           // YUV_420_BIPLANAR
       GL_ZERO,           // UYVY_422
   };
-  static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
+  static_assert(base::size(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
                 "format_gl_data_format does not handle all cases.");
 
   return format_gl_data_format[format];
@@ -194,7 +194,7 @@
       GL_ZERO,       // UYVY_422
   };
 
-  static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
+  static_assert(base::size(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
                 "format_gl_data_format does not handle all cases.");
 
   return format_gl_data_format[format];
diff --git a/components/viz/common/yuv_readback_unittest.cc b/components/viz/common/yuv_readback_unittest.cc
index 45b1adfa..a780291 100644
--- a/components/viz/common/yuv_readback_unittest.cc
+++ b/components/viz/common/yuv_readback_unittest.cc
@@ -7,6 +7,7 @@
 #include "base/json/json_reader.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/trace_event/trace_event.h"
@@ -523,8 +524,8 @@
   unsigned int x = std::get<2>(GetParam());
   unsigned int y = std::get<3>(GetParam());
 
-  for (unsigned int ox = x; ox < arraysize(kYUVReadbackSizes); ox++) {
-    for (unsigned int oy = y; oy < arraysize(kYUVReadbackSizes); oy++) {
+  for (unsigned int ox = x; ox < base::size(kYUVReadbackSizes); ox++) {
+    for (unsigned int oy = y; oy < base::size(kYUVReadbackSizes); oy++) {
       // If output is a subsection of the destination frame, (letterbox)
       // then try different variations of where the subsection goes.
       for (Margin xm = x < ox ? MarginLeft : MarginRight; xm <= MarginRight;
@@ -555,8 +556,8 @@
     ::testing::Combine(
         ::testing::Bool(),
         ::testing::Bool(),
-        ::testing::Range<unsigned int>(0, arraysize(kYUVReadbackSizes)),
-        ::testing::Range<unsigned int>(0, arraysize(kYUVReadbackSizes))));
+        ::testing::Range<unsigned int>(0, base::size(kYUVReadbackSizes)),
+        ::testing::Range<unsigned int>(0, base::size(kYUVReadbackSizes))));
 
 }  // namespace viz
 
diff --git a/components/viz/service/display/bsp_tree_unittest.cc b/components/viz/service/display/bsp_tree_unittest.cc
index 9f550d81..01bc051 100644
--- a/components/viz/service/display/bsp_tree_unittest.cc
+++ b/components/viz/service/display/bsp_tree_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 
 #include "base/containers/circular_deque.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/viz/service/display/bsp_walk_action.h"
 #include "components/viz/service/display/draw_polygon.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -26,7 +26,7 @@
   } while (false);
 
 #define INT_VECTOR_FROM_ARRAY(array) \
-  std::vector<int>(array, array + arraysize(array))
+  std::vector<int>(array, array + base::size(array))
 
 #define CREATE_DRAW_POLYGON(vertex_vector, normal, polygon_id) \
   new DrawPolygon(NULL, vertex_vector, normal, polygon_id)
diff --git a/components/viz/service/display/color_lut_cache.cc b/components/viz/service/display/color_lut_cache.cc
index 38d1a8ca..e1c1312d6 100644
--- a/components/viz/service/display/color_lut_cache.cc
+++ b/components/viz/service/display/color_lut_cache.cc
@@ -8,6 +8,7 @@
 #include <cmath>
 #include <vector>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/client/gles2_interface.h"
 #include "third_party/khronos/GLES2/gl2ext.h"
 #include "ui/gfx/color_transform.h"
@@ -27,7 +28,7 @@
   size_t n = 0;
   for (const auto& cache_entry : lut_cache_) {
     textures[n++] = cache_entry.second.lut.texture;
-    if (n == arraysize(textures)) {
+    if (n == base::size(textures)) {
       gl_->DeleteTextures(n, textures);
       n = 0;
     }
diff --git a/components/viz/service/display/gl_renderer.cc b/components/viz/service/display/gl_renderer.cc
index 41555b8..bc9cfdd 100644
--- a/components/viz/service/display/gl_renderer.cc
+++ b/components/viz/service/display/gl_renderer.cc
@@ -20,8 +20,8 @@
 #include "base/bind_helpers.h"
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -395,7 +395,7 @@
       output_surface_->capabilities().uses_default_gl_framebuffer;
   GLenum attachments[] = {static_cast<GLenum>(
       using_default_framebuffer ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0_EXT)};
-  gl_->DiscardFramebufferEXT(GL_FRAMEBUFFER, arraysize(attachments),
+  gl_->DiscardFramebufferEXT(GL_FRAMEBUFFER, base::size(attachments),
                              attachments);
 }
 
@@ -3579,7 +3579,7 @@
 
   OverdrawFeedbackCallback overdraw_feedback_callback = base::Bind(
       &GLRenderer::ProcessOverdrawFeedback, weak_ptr_factory_.GetWeakPtr(),
-      base::Owned(new std::vector<int>), arraysize(stencil_tests), max_result);
+      base::Owned(new std::vector<int>), base::size(stencil_tests), max_result);
 
   for (const auto& test : stencil_tests) {
     GLuint query = 0;
diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc b/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
index 6bc4cf92..d7a0676 100644
--- a/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
+++ b/components/viz/service/frame_sinks/compositor_frame_sink_support_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "components/viz/service/frame_sinks/compositor_frame_sink_support.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/viz/common/frame_sinks/copy_output_request.h"
 #include "components/viz/common/frame_sinks/copy_output_result.h"
 #include "components/viz/common/quads/compositor_frame.h"
@@ -230,7 +230,7 @@
 TEST_F(CompositorFrameSinkSupportTest, ResourceLifetimeSimple) {
   ResourceId first_frame_ids[] = {1, 2, 3};
   SubmitCompositorFrameWithResources(first_frame_ids,
-                                     arraysize(first_frame_ids));
+                                     base::size(first_frame_ids));
 
   // All of the resources submitted in the first frame are still in use at this
   // time by virtue of being in the pending frame, so none can be returned to
@@ -247,11 +247,11 @@
   // Resources were never consumed so no sync token should be set.
   CheckReturnedResourcesMatchExpected(
       expected_returned_ids, expected_returned_counts,
-      arraysize(expected_returned_counts), gpu::SyncToken());
+      base::size(expected_returned_counts), gpu::SyncToken());
 
   ResourceId third_frame_ids[] = {4, 5, 6};
   SubmitCompositorFrameWithResources(third_frame_ids,
-                                     arraysize(third_frame_ids));
+                                     base::size(third_frame_ids));
 
   // All of the resources submitted in the third frame are still in use at this
   // time by virtue of being in the pending frame, so none can be returned to
@@ -263,14 +263,14 @@
   // make all resources of third frame available to be returned.
   ResourceId forth_frame_ids[] = {7, 8, 9};
   SubmitCompositorFrameWithResources(forth_frame_ids,
-                                     arraysize(forth_frame_ids));
+                                     base::size(forth_frame_ids));
 
   ResourceId forth_expected_returned_ids[] = {4, 5, 6};
   int forth_expected_returned_counts[] = {1, 1, 1};
   // Resources were never consumed so no sync token should be set.
   CheckReturnedResourcesMatchExpected(
       forth_expected_returned_ids, forth_expected_returned_counts,
-      arraysize(forth_expected_returned_counts), gpu::SyncToken());
+      base::size(forth_expected_returned_counts), gpu::SyncToken());
 }
 
 // Tests submitting a frame with resources followed by one with no resources
@@ -279,7 +279,7 @@
        ResourceLifetimeSimpleWithProviderHoldingAlive) {
   ResourceId first_frame_ids[] = {1, 2, 3};
   SubmitCompositorFrameWithResources(first_frame_ids,
-                                     arraysize(first_frame_ids));
+                                     base::size(first_frame_ids));
 
   // All of the resources submitted in the first frame are still in use at this
   // time by virtue of being in the pending frame, so none can be returned to
@@ -298,7 +298,7 @@
   fake_support_client_.clear_returned_resources();
 
   int release_counts[] = {1, 1, 1};
-  UnrefResources(first_frame_ids, release_counts, arraysize(first_frame_ids));
+  UnrefResources(first_frame_ids, release_counts, base::size(first_frame_ids));
 
   // None is returned to the client since DidReceiveCompositorAck is not
   // invoked.
@@ -311,7 +311,7 @@
   int expected_returned_counts[] = {1, 1, 1};
   CheckReturnedResourcesMatchExpected(
       expected_returned_ids, expected_returned_counts,
-      arraysize(expected_returned_counts), consumer_sync_token_);
+      base::size(expected_returned_counts), consumer_sync_token_);
 }
 
 // Tests referencing a resource, unref'ing it to zero, then using it again
@@ -319,14 +319,14 @@
 TEST_F(CompositorFrameSinkSupportTest, ResourceReusedBeforeReturn) {
   ResourceId first_frame_ids[] = {7};
   SubmitCompositorFrameWithResources(first_frame_ids,
-                                     arraysize(first_frame_ids));
+                                     base::size(first_frame_ids));
 
   // This removes all references to resource id 7.
   SubmitCompositorFrameWithResources(nullptr, 0);
 
   // This references id 7 again.
   SubmitCompositorFrameWithResources(first_frame_ids,
-                                     arraysize(first_frame_ids));
+                                     base::size(first_frame_ids));
 
   // This removes it again.
   SubmitCompositorFrameWithResources(nullptr, 0);
@@ -349,7 +349,7 @@
 TEST_F(CompositorFrameSinkSupportTest, ResourceRefMultipleTimes) {
   ResourceId first_frame_ids[] = {3, 4};
   SubmitCompositorFrameWithResources(first_frame_ids,
-                                     arraysize(first_frame_ids));
+                                     base::size(first_frame_ids));
 
   // Ref resources from the first frame twice.
   RefCurrentFrameResources();
@@ -357,7 +357,7 @@
 
   ResourceId second_frame_ids[] = {4, 5};
   SubmitCompositorFrameWithResources(second_frame_ids,
-                                     arraysize(second_frame_ids));
+                                     base::size(second_frame_ids));
 
   // Ref resources from the second frame 3 times.
   RefCurrentFrameResources();
@@ -379,18 +379,18 @@
     SCOPED_TRACE("unref all 3");
     ResourceId ids_to_unref[] = {3, 4, 5};
     int counts[] = {1, 1, 1};
-    UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref));
+    UnrefResources(ids_to_unref, counts, base::size(ids_to_unref));
 
     EXPECT_EQ(0u, fake_support_client_.returned_resources().size());
     fake_support_client_.clear_returned_resources();
 
-    UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref));
+    UnrefResources(ids_to_unref, counts, base::size(ids_to_unref));
     SubmitCompositorFrameWithResources(nullptr, 0);
     ResourceId expected_returned_ids[] = {3};
     int expected_returned_counts[] = {1};
     CheckReturnedResourcesMatchExpected(
         expected_returned_ids, expected_returned_counts,
-        arraysize(expected_returned_counts), consumer_sync_token_);
+        base::size(expected_returned_counts), consumer_sync_token_);
   }
 
   // Expected refs remaining:
@@ -400,14 +400,14 @@
     SCOPED_TRACE("unref 4 and 5");
     ResourceId ids_to_unref[] = {4, 5};
     int counts[] = {1, 1};
-    UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref));
+    UnrefResources(ids_to_unref, counts, base::size(ids_to_unref));
     SubmitCompositorFrameWithResources(nullptr, 0);
 
     ResourceId expected_returned_ids[] = {5};
     int expected_returned_counts[] = {1};
     CheckReturnedResourcesMatchExpected(
         expected_returned_ids, expected_returned_counts,
-        arraysize(expected_returned_counts), consumer_sync_token_);
+        base::size(expected_returned_counts), consumer_sync_token_);
   }
 
   // Now, just 2 refs remaining on resource 4. Unref both at once and make sure
@@ -416,21 +416,21 @@
     SCOPED_TRACE("unref only 4");
     ResourceId ids_to_unref[] = {4};
     int counts[] = {2};
-    UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref));
+    UnrefResources(ids_to_unref, counts, base::size(ids_to_unref));
     SubmitCompositorFrameWithResources(nullptr, 0);
 
     ResourceId expected_returned_ids[] = {4};
     int expected_returned_counts[] = {2};
     CheckReturnedResourcesMatchExpected(
         expected_returned_ids, expected_returned_counts,
-        arraysize(expected_returned_counts), consumer_sync_token_);
+        base::size(expected_returned_counts), consumer_sync_token_);
   }
 }
 
 TEST_F(CompositorFrameSinkSupportTest, ResourceLifetime) {
   ResourceId first_frame_ids[] = {1, 2, 3};
   SubmitCompositorFrameWithResources(first_frame_ids,
-                                     arraysize(first_frame_ids));
+                                     base::size(first_frame_ids));
 
   // All of the resources submitted in the first frame are still in use at this
   // time by virtue of being in the pending frame, so none can be returned to
@@ -443,14 +443,14 @@
   // only referenced by the first frame.
   ResourceId second_frame_ids[] = {2, 3, 4};
   SubmitCompositorFrameWithResources(second_frame_ids,
-                                     arraysize(second_frame_ids));
+                                     base::size(second_frame_ids));
   {
     SCOPED_TRACE("second frame");
     ResourceId expected_returned_ids[] = {1};
     int expected_returned_counts[] = {1};
     CheckReturnedResourcesMatchExpected(
         expected_returned_ids, expected_returned_counts,
-        arraysize(expected_returned_counts), gpu::SyncToken());
+        base::size(expected_returned_counts), gpu::SyncToken());
   }
 
   // The third frame references a disjoint set of resources, so we expect to
@@ -459,7 +459,7 @@
   // resource ID 4 will have a count of 1.
   ResourceId third_frame_ids[] = {10, 11, 12, 13};
   SubmitCompositorFrameWithResources(third_frame_ids,
-                                     arraysize(third_frame_ids));
+                                     base::size(third_frame_ids));
 
   {
     SCOPED_TRACE("third frame");
@@ -467,7 +467,7 @@
     int expected_returned_counts[] = {2, 2, 1};
     CheckReturnedResourcesMatchExpected(
         expected_returned_ids, expected_returned_counts,
-        arraysize(expected_returned_counts), gpu::SyncToken());
+        base::size(expected_returned_counts), gpu::SyncToken());
   }
 
   // Simulate a ResourceProvider taking a ref on all of the resources.
@@ -475,7 +475,7 @@
 
   ResourceId fourth_frame_ids[] = {12, 13};
   SubmitCompositorFrameWithResources(fourth_frame_ids,
-                                     arraysize(fourth_frame_ids));
+                                     base::size(fourth_frame_ids));
 
   EXPECT_EQ(0u, fake_support_client_.returned_resources().size());
 
@@ -490,7 +490,7 @@
   {
     ResourceId ids_to_unref[] = {10, 11, 12, 13};
     int counts[] = {1, 1, 1, 1};
-    UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref));
+    UnrefResources(ids_to_unref, counts, base::size(ids_to_unref));
   }
 
   // Nothing is returned to the client yet since DidReceiveCompositorFrameAck
@@ -504,7 +504,7 @@
   {
     ResourceId ids_to_unref[] = {12, 13};
     int counts[] = {1, 1};
-    UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref));
+    UnrefResources(ids_to_unref, counts, base::size(ids_to_unref));
   }
 
   // Resources 12 and 13 are still in use by the current frame, so they
@@ -521,7 +521,7 @@
     int expected_returned_counts[] = {1, 1, 2, 2};
     CheckReturnedResourcesMatchExpected(
         expected_returned_ids, expected_returned_counts,
-        arraysize(expected_returned_counts), consumer_sync_token_);
+        base::size(expected_returned_counts), consumer_sync_token_);
   }
 }
 
diff --git a/components/viz/service/surfaces/surface_hittest_unittest.cc b/components/viz/service/surfaces/surface_hittest_unittest.cc
index 15f1277..580f2b4 100644
--- a/components/viz/service/surfaces/surface_hittest_unittest.cc
+++ b/components/viz/service/surfaces/surface_hittest_unittest.cc
@@ -4,6 +4,7 @@
 
 #include <stddef.h>
 
+#include "base/stl_util.h"
 #include "components/viz/common/quads/compositor_frame.h"
 #include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
 #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
@@ -162,7 +163,7 @@
        gfx::Point(100, 100), false},
   };
 
-  RunTests(nullptr, surface_manager(), tests, arraysize(tests));
+  RunTests(nullptr, surface_manager(), tests, base::size(tests));
 }
 
 TEST_F(SurfaceHittestTest, Hittest_ChildSurface) {
@@ -224,7 +225,7 @@
                       {root_surface_id, gfx::Point(290, 290), root_surface_id,
                        gfx::Point(290, 290), false}};
 
-  RunTests(nullptr, surface_manager(), tests, arraysize(tests));
+  RunTests(nullptr, surface_manager(), tests, base::size(tests));
 
   // Submit another root frame, with a slightly perturbed child Surface.
   root_frame = CreateCompositorFrame(root_rect, &root_pass);
@@ -329,7 +330,7 @@
                       {root_surface_id, gfx::Point(290, 290), root_surface_id,
                        gfx::Point(290, 290), false}};
 
-  RunTests(nullptr, surface_manager(), tests, arraysize(tests));
+  RunTests(nullptr, surface_manager(), tests, base::size(tests));
 }
 
 // This test verifies that hit testing will progress to the next quad if it
@@ -398,7 +399,7 @@
                       {root_surface_id, gfx::Point(290, 290), root_surface_id,
                        gfx::Point(290, 290), false}};
 
-  RunTests(nullptr, surface_manager(), tests, arraysize(tests));
+  RunTests(nullptr, surface_manager(), tests, base::size(tests));
 }
 
 TEST_F(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
@@ -462,7 +463,7 @@
                       {root_surface_id, gfx::Point(100, 100), root_surface_id,
                        gfx::Point(100, 100), false}};
 
-  RunTests(nullptr, surface_manager(), tests, arraysize(tests));
+  RunTests(nullptr, surface_manager(), tests, base::size(tests));
 }
 
 TEST_F(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
@@ -528,7 +529,7 @@
 
   TestSurfaceHittestDelegate empty_delegate;
   RunTests(&empty_delegate, surface_manager(), test_expectations_without_insets,
-           arraysize(test_expectations_without_insets));
+           base::size(test_expectations_without_insets));
 
   // Verify that insets have NOT affected hit targeting.
   EXPECT_EQ(0, empty_delegate.reject_target_overrides());
@@ -560,7 +561,7 @@
                                             gfx::Insets(10, 10, 10, 10));
   RunTests(&reject_delegate, surface_manager(),
            test_expectations_with_reject_insets,
-           arraysize(test_expectations_with_reject_insets));
+           base::size(test_expectations_with_reject_insets));
 
   // Verify that insets have affected hit targeting.
   EXPECT_EQ(4, reject_delegate.reject_target_overrides());
@@ -587,7 +588,7 @@
                                             gfx::Insets(5, 5, 5, 5));
   RunTests(&accept_delegate, surface_manager(),
            test_expectations_with_accept_insets,
-           arraysize(test_expectations_with_accept_insets));
+           base::size(test_expectations_with_accept_insets));
 
   // Verify that insets have affected hit targeting.
   EXPECT_EQ(0, accept_delegate.reject_target_overrides());
@@ -655,7 +656,7 @@
                       {root_surface_id, gfx::Point(290, 290), root_surface_id,
                        gfx::Point(290, 290), false}};
 
-  RunTests(nullptr, surface_manager(), tests, arraysize(tests));
+  RunTests(nullptr, surface_manager(), tests, base::size(tests));
 
   // Submit another root frame, with a slightly perturbed child Surface.
   root_frame = CreateCompositorFrame(root_rect, &root_pass);
diff --git a/components/viz/test/test_context_provider.cc b/components/viz/test/test_context_provider.cc
index a9c796f5..a41fa9c 100644
--- a/components/viz/test/test_context_provider.cc
+++ b/components/viz/test/test_context_provider.cc
@@ -15,6 +15,7 @@
 #include "base/bind.h"
 #include "base/callback_helpers.h"
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "components/viz/common/gpu/context_cache_controller.h"
 #include "components/viz/test/test_gles2_interface.h"
 #include "gpu/command_buffer/client/raster_implementation_gles.h"
@@ -61,7 +62,7 @@
     return nullptr;
   }
   const GrGLubyte* GetStringi(GrGLenum name, GrGLuint i) override {
-    if (name == GL_EXTENSIONS && i < arraysize(kExtensions))
+    if (name == GL_EXTENSIONS && i < base::size(kExtensions))
       return reinterpret_cast<const GLubyte*>(kExtensions[i]);
     return nullptr;
   }
@@ -94,7 +95,7 @@
  private:
   static std::string BuildExtensionString(std::string additional_extensions) {
     std::string extension_string = kExtensions[0];
-    for (size_t i = 1; i < arraysize(kExtensions); ++i) {
+    for (size_t i = 1; i < base::size(kExtensions); ++i) {
       extension_string += " ";
       extension_string += kExtensions[i];
     }
diff --git a/components/webcrypto/algorithms/aes_cbc_unittest.cc b/components/webcrypto/algorithms/aes_cbc_unittest.cc
index a7e08843..b4b36cf 100644
--- a/components/webcrypto/algorithms/aes_cbc_unittest.cc
+++ b/components/webcrypto/algorithms/aes_cbc_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/webcrypto/algorithm_dispatch.h"
 #include "components/webcrypto/algorithms/test_helpers.h"
@@ -168,7 +168,7 @@
   // Check key generation for each allowed key length.
   std::vector<blink::WebCryptoAlgorithm> algorithm;
   const unsigned short kKeyLength[] = {128, 256};
-  for (size_t key_length_i = 0; key_length_i < arraysize(kKeyLength);
+  for (size_t key_length_i = 0; key_length_i < base::size(kKeyLength);
        ++key_length_i) {
     blink::WebCryptoKey key;
 
@@ -198,7 +198,7 @@
 TEST_F(WebCryptoAesCbcTest, GenerateKeyBadLength) {
   const unsigned short kKeyLen[] = {0, 127, 257};
   blink::WebCryptoKey key;
-  for (size_t i = 0; i < arraysize(kKeyLen); ++i) {
+  for (size_t i = 0; i < base::size(kKeyLen); ++i) {
     SCOPED_TRACE(i);
     EXPECT_EQ(Status::ErrorGenerateAesKeyLength(),
               GenerateSecretKey(CreateAesCbcKeyGenAlgorithm(kKeyLen[i]), true,
@@ -440,7 +440,7 @@
 
   std::vector<uint8_t> key_bytes(16);
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey key;
@@ -458,7 +458,7 @@
       blink::kWebCryptoKeyUsageDecrypt | blink::kWebCryptoKeyUsageVerify,
   };
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey key;
diff --git a/components/webcrypto/algorithms/aes_ctr_unittest.cc b/components/webcrypto/algorithms/aes_ctr_unittest.cc
index c8203cb..f08fa9fe 100644
--- a/components/webcrypto/algorithms/aes_ctr_unittest.cc
+++ b/components/webcrypto/algorithms/aes_ctr_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/webcrypto/algorithm_dispatch.h"
 #include "components/webcrypto/algorithms/test_helpers.h"
@@ -82,7 +82,7 @@
   std::vector<uint8_t> input(32);
   std::vector<uint8_t> output;
 
-  for (size_t i = 0; i < arraysize(kBadCounterBlockLengthBytes); ++i) {
+  for (size_t i = 0; i < base::size(kBadCounterBlockLengthBytes); ++i) {
     std::vector<uint8_t> bad_counter(kBadCounterBlockLengthBytes[i]);
 
     EXPECT_EQ(Status::ErrorIncorrectSizeAesCtrCounter(),
@@ -108,7 +108,7 @@
   std::vector<uint8_t> input(32);
   std::vector<uint8_t> output;
 
-  for (size_t i = 0; i < arraysize(kBadCounterLengthBits); ++i) {
+  for (size_t i = 0; i < base::size(kBadCounterLengthBits); ++i) {
     uint8_t bad_counter_length_bits = kBadCounterLengthBits[i];
 
     EXPECT_EQ(Status::ErrorInvalidAesCtrCounterLength(),
@@ -146,7 +146,7 @@
 
   std::vector<uint8_t> output;
 
-  for (size_t i = 0; i < arraysize(kStartCounter); ++i) {
+  for (size_t i = 0; i < base::size(kStartCounter); ++i) {
     std::vector<uint8_t> counter(16);
     counter[15] = kStartCounter[i];
 
diff --git a/components/webcrypto/algorithms/aes_gcm_unittest.cc b/components/webcrypto/algorithms/aes_gcm_unittest.cc
index 2b38c8b..185a43cb 100644
--- a/components/webcrypto/algorithms/aes_gcm_unittest.cc
+++ b/components/webcrypto/algorithms/aes_gcm_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/webcrypto/algorithm_dispatch.h"
 #include "components/webcrypto/algorithms/test_helpers.h"
@@ -99,7 +99,7 @@
 TEST_F(WebCryptoAesGcmTest, GenerateKeyBadLength) {
   const unsigned short kKeyLen[] = {0, 127, 257};
   blink::WebCryptoKey key;
-  for (size_t i = 0; i < arraysize(kKeyLen); ++i) {
+  for (size_t i = 0; i < base::size(kKeyLen); ++i) {
     SCOPED_TRACE(i);
     EXPECT_EQ(Status::ErrorGenerateAesKeyLength(),
               GenerateSecretKey(CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true,
@@ -205,7 +205,7 @@
 
     // Try different incorrect tag lengths
     uint8_t kAlternateTagLengths[] = {0, 8, 96, 120, 128, 160, 255};
-    for (size_t tag_i = 0; tag_i < arraysize(kAlternateTagLengths); ++tag_i) {
+    for (size_t tag_i = 0; tag_i < base::size(kAlternateTagLengths); ++tag_i) {
       unsigned int wrong_tag_size_bits = kAlternateTagLengths[tag_i];
       if (test_tag_size_bits == wrong_tag_size_bits)
         continue;
diff --git a/components/webcrypto/algorithms/aes_kw_unittest.cc b/components/webcrypto/algorithms/aes_kw_unittest.cc
index 8211eff..fd38d647 100644
--- a/components/webcrypto/algorithms/aes_kw_unittest.cc
+++ b/components/webcrypto/algorithms/aes_kw_unittest.cc
@@ -7,7 +7,6 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/values.h"
 #include "components/webcrypto/algorithm_dispatch.h"
@@ -32,7 +31,7 @@
 TEST_F(WebCryptoAesKwTest, GenerateKeyBadLength) {
   const unsigned short kKeyLen[] = {0, 127, 257};
   blink::WebCryptoKey key;
-  for (size_t i = 0; i < arraysize(kKeyLen); ++i) {
+  for (size_t i = 0; i < base::size(kKeyLen); ++i) {
     SCOPED_TRACE(i);
     EXPECT_EQ(Status::ErrorGenerateAesKeyLength(),
               GenerateSecretKey(CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true,
@@ -438,7 +437,7 @@
 
   std::vector<uint8_t> key_bytes(16);
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey key;
@@ -476,7 +475,7 @@
       "C2B7F19A32EE31372CD40C9C969B8CD67553E5AEA7FD1144874584E46ABCD79FDC308848"
       "B2DD8BD36A2D61062B9C5B8B499B8D6EF8EB320D87A614952B4EE771";
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey key;
@@ -525,7 +524,7 @@
       "40C72DCF0AEA454113CC47457B13305B25507CBEAB9BDC8D8E0F867F9167F9DCEF0D9F9B"
       "30F2EE83CEDFD51136852C8A5939B768";
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey key;
diff --git a/components/webcrypto/algorithms/ec.cc b/components/webcrypto/algorithms/ec.cc
index 47d4605e..4274040 100644
--- a/components/webcrypto/algorithms/ec.cc
+++ b/components/webcrypto/algorithms/ec.cc
@@ -8,7 +8,7 @@
 #include <utility>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/webcrypto/algorithms/asymmetric_key_util.h"
 #include "components/webcrypto/algorithms/util.h"
 #include "components/webcrypto/blink_key_handle.h"
@@ -82,7 +82,7 @@
   if (status.IsError())
     return status;
 
-  for (size_t i = 0; i < arraysize(kJwkCrvMappings); ++i) {
+  for (size_t i = 0; i < base::size(kJwkCrvMappings); ++i) {
     if (kJwkCrvMappings[i].jwk_curve == jwk_curve) {
       *named_curve = kJwkCrvMappings[i].named_curve;
       return Status::Success();
@@ -95,7 +95,7 @@
 // Converts a WebCryptoNamedCurve to an equivalent JWK "crv".
 Status WebCryptoCurveToJwkCrv(blink::WebCryptoNamedCurve named_curve,
                               std::string* jwk_crv) {
-  for (size_t i = 0; i < arraysize(kJwkCrvMappings); ++i) {
+  for (size_t i = 0; i < base::size(kJwkCrvMappings); ++i) {
     if (kJwkCrvMappings[i].named_curve == named_curve) {
       *jwk_crv = kJwkCrvMappings[i].jwk_curve;
       return Status::Success();
diff --git a/components/webcrypto/algorithms/rsa_oaep_unittest.cc b/components/webcrypto/algorithms/rsa_oaep_unittest.cc
index dcfff34..ebd998f 100644
--- a/components/webcrypto/algorithms/rsa_oaep_unittest.cc
+++ b/components/webcrypto/algorithms/rsa_oaep_unittest.cc
@@ -7,7 +7,7 @@
 
 #include "base/base64url.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "components/webcrypto/algorithm_dispatch.h"
 #include "components/webcrypto/algorithms/test_helpers.h"
 #include "components/webcrypto/crypto_data.h"
@@ -129,7 +129,7 @@
                    {blink::kWebCryptoAlgorithmIdSha256, "RSA-OAEP-256"},
                    {blink::kWebCryptoAlgorithmIdSha384, "RSA-OAEP-384"},
                    {blink::kWebCryptoAlgorithmIdSha512, "RSA-OAEP-512"}};
-  for (size_t i = 0; i < arraysize(kTestData); ++i) {
+  for (size_t i = 0; i < base::size(kTestData); ++i) {
     const TestData& test_data = kTestData[i];
     SCOPED_TRACE(test_data.expected_jwk_alg);
 
@@ -479,7 +479,7 @@
       {blink::kWebCryptoAlgorithmIdSha512, blink::kWebCryptoKeyUsageEncrypt,
        "RSA-OAEP-512"}};
 
-  for (size_t test_index = 0; test_index < arraysize(kTests); ++test_index) {
+  for (size_t test_index = 0; test_index < base::size(kTests); ++test_index) {
     SCOPED_TRACE(test_index);
     const TestCase& test = kTests[test_index];
 
diff --git a/components/webcrypto/algorithms/rsa_ssa_unittest.cc b/components/webcrypto/algorithms/rsa_ssa_unittest.cc
index 8d09c4cd..5017ae2 100644
--- a/components/webcrypto/algorithms/rsa_ssa_unittest.cc
+++ b/components/webcrypto/algorithms/rsa_ssa_unittest.cc
@@ -6,7 +6,7 @@
 #include <stdint.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/webcrypto/algorithm_dispatch.h"
 #include "components/webcrypto/algorithms/test_helpers.h"
@@ -477,7 +477,7 @@
 
   const std::vector<uint8_t> public_exponent = HexStringToBytes("010001");
 
-  for (size_t i = 0; i < arraysize(kBadModulusBits); ++i) {
+  for (size_t i = 0; i < base::size(kBadModulusBits); ++i) {
     const unsigned int modulus_length_bits = kBadModulusBits[i];
     blink::WebCryptoAlgorithm algorithm = CreateRsaHashedKeyGenAlgorithm(
         blink::kWebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
@@ -509,7 +509,7 @@
       "010000",  // 65536
   };
 
-  for (size_t i = 0; i < arraysize(kPublicExponents); ++i) {
+  for (size_t i = 0; i < base::size(kPublicExponents); ++i) {
     SCOPED_TRACE(i);
     blink::WebCryptoAlgorithm algorithm = CreateRsaHashedKeyGenAlgorithm(
         blink::kWebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
@@ -689,7 +689,7 @@
       blink::kWebCryptoKeyUsageEncrypt | blink::kWebCryptoKeyUsageDecrypt,
   };
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey public_key;
@@ -719,7 +719,7 @@
   dict.Remove("use", nullptr);
   dict.SetString("alg", "RS256");
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey public_key;
@@ -741,7 +741,7 @@
   const unsigned int modulus_length = 256;
   const std::vector<uint8_t> public_exponent = HexStringToBytes("010001");
 
-  for (size_t i = 0; i < arraysize(bad_usages); ++i) {
+  for (size_t i = 0; i < base::size(bad_usages); ++i) {
     SCOPED_TRACE(i);
 
     blink::WebCryptoKey public_key;
@@ -877,7 +877,7 @@
                              {blink::kWebCryptoAlgorithmIdSha512,
                               blink::kWebCryptoKeyUsageVerify, "RS512"}};
 
-  for (size_t test_index = 0; test_index < arraysize(kTests); ++test_index) {
+  for (size_t test_index = 0; test_index < base::size(kTests); ++test_index) {
     SCOPED_TRACE(test_index);
     const TestCase& test = kTests[test_index];
 
@@ -944,7 +944,7 @@
 
   // Fail if either "n" or "e" is not present or malformed.
   const std::string kKtyParmName[] = {"n", "e"};
-  for (size_t idx = 0; idx < arraysize(kKtyParmName); ++idx) {
+  for (size_t idx = 0; idx < base::size(kKtyParmName); ++idx) {
     // Fail on missing parameter.
     dict.Remove(kKtyParmName[idx], nullptr);
     EXPECT_NE(Status::Success(),
diff --git a/components/webcrypto/algorithms/test_helpers.cc b/components/webcrypto/algorithms/test_helpers.cc
index c50004a..394805d 100644
--- a/components/webcrypto/algorithms/test_helpers.cc
+++ b/components/webcrypto/algorithms/test_helpers.cc
@@ -13,8 +13,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
@@ -240,7 +240,7 @@
       {"sha-512", blink::kWebCryptoAlgorithmIdSha512},
   };
 
-  for (size_t i = 0; i < arraysize(kDigestNameToId); ++i) {
+  for (size_t i = 0; i < base::size(kDigestNameToId); ++i) {
     if (kDigestNameToId[i].name == algorithm_name)
       return CreateAlgorithm(kDigestNameToId[i].id);
   }
diff --git a/components/webcrypto/jwk.cc b/components/webcrypto/jwk.cc
index bc78dca9..b76d6d2f 100644
--- a/components/webcrypto/jwk.cc
+++ b/components/webcrypto/jwk.cc
@@ -11,7 +11,6 @@
 #include "base/base64url.h"
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/stringprintf.h"
@@ -80,7 +79,7 @@
 
 bool JwkKeyOpToWebCryptoUsage(const std::string& key_op,
                               blink::WebCryptoKeyUsage* usage) {
-  for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) {
+  for (size_t i = 0; i < base::size(kJwkWebCryptoUsageMap); ++i) {
     if (kJwkWebCryptoUsageMap[i].jwk_key_op == key_op) {
       *usage = kJwkWebCryptoUsageMap[i].webcrypto_usage;
       return true;
@@ -93,7 +92,7 @@
 std::unique_ptr<base::ListValue> CreateJwkKeyOpsFromWebCryptoUsages(
     blink::WebCryptoKeyUsageMask usages) {
   std::unique_ptr<base::ListValue> jwk_key_ops(new base::ListValue());
-  for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) {
+  for (size_t i = 0; i < base::size(kJwkWebCryptoUsageMap); ++i) {
     if (usages & kJwkWebCryptoUsageMap[i].webcrypto_usage)
       jwk_key_ops->AppendString(kJwkWebCryptoUsageMap[i].jwk_key_op);
   }
diff --git a/components/zoom/page_zoom_constants.cc b/components/zoom/page_zoom_constants.cc
index 388a337a..0c9052b 100644
--- a/components/zoom/page_zoom_constants.cc
+++ b/components/zoom/page_zoom_constants.cc
@@ -4,7 +4,7 @@
 
 #include "components/zoom/page_zoom_constants.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace zoom {
 
@@ -14,6 +14,6 @@
 const double kPresetZoomFactors[] = {0.25, 1 / 3.0, 0.5, 2 / 3.0, 0.75, 0.8,
                                      0.9, 1.0, 1.1, 1.25, 1.5, 1.75, 2.0, 2.5,
                                      3.0, 4.0, 5.0};
-const std::size_t kPresetZoomFactorsSize = arraysize(kPresetZoomFactors);
+const std::size_t kPresetZoomFactorsSize = base::size(kPresetZoomFactors);
 
 }  // namespace ui_zoom
diff --git a/content/BUILD.gn b/content/BUILD.gn
index bce6285..0ca39d7 100644
--- a/content/BUILD.gn
+++ b/content/BUILD.gn
@@ -2,9 +2,9 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//tools/grit/grit_rule.gni")
 import("//build/config/nacl/config.gni")
 import("//ppapi/buildflags/buildflags.gni")
-import("//tools/grit/grit_rule.gni")
 
 # Applied by targets internal to content.
 config("content_implementation") {
@@ -128,6 +128,7 @@
     "//content/public/app:plugin_manifest",
     "//content/public/app:renderer_manifest",
     "//content/public/app:utility_manifest",
+    "//services/catalog:manifest",
   ]
 }
 
diff --git a/content/app/content_service_manager_main_delegate.cc b/content/app/content_service_manager_main_delegate.cc
index 3a6bc4e..fc86a74 100644
--- a/content/app/content_service_manager_main_delegate.cc
+++ b/content/app/content_service_manager_main_delegate.cc
@@ -74,9 +74,9 @@
     config->is_broker_process = true;
 }
 
-std::vector<service_manager::Manifest>
-ContentServiceManagerMainDelegate::GetServiceManifests() {
-  return std::vector<service_manager::Manifest>();
+std::unique_ptr<base::Value>
+ContentServiceManagerMainDelegate::CreateServiceCatalog() {
+  return nullptr;
 }
 
 bool ContentServiceManagerMainDelegate::ShouldLaunchAsServiceProcess(
diff --git a/content/app/content_service_manager_main_delegate.h b/content/app/content_service_manager_main_delegate.h
index 864f2a5..6f32f97 100644
--- a/content/app/content_service_manager_main_delegate.h
+++ b/content/app/content_service_manager_main_delegate.h
@@ -30,7 +30,7 @@
   void ShutDownEmbedderProcess() override;
   service_manager::ProcessType OverrideProcessType() override;
   void OverrideMojoConfiguration(mojo::core::Configuration* config) override;
-  std::vector<service_manager::Manifest> GetServiceManifests() override;
+  std::unique_ptr<base::Value> CreateServiceCatalog() override;
   bool ShouldLaunchAsServiceProcess(
       const service_manager::Identity& identity) override;
   void AdjustServiceProcessCommandLine(
diff --git a/content/browser/accessibility/accessibility_tree_formatter_android.cc b/content/browser/accessibility/accessibility_tree_formatter_android.cc
index 282de50..7202c9e2 100644
--- a/content/browser/accessibility/accessibility_tree_formatter_android.cc
+++ b/content/browser/accessibility/accessibility_tree_formatter_android.cc
@@ -10,7 +10,7 @@
 #include "base/android/jni_string.h"
 #include "base/files/file_path.h"
 #include "base/json/json_writer.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -188,14 +188,14 @@
         &line);
   }
 
-  for (unsigned i = 0; i < arraysize(BOOL_ATTRIBUTES); i++) {
+  for (unsigned i = 0; i < base::size(BOOL_ATTRIBUTES); i++) {
     const char* attribute_name = BOOL_ATTRIBUTES[i];
     bool value;
     if (dict.GetBoolean(attribute_name, &value) && value)
       WriteAttribute(true, attribute_name, &line);
   }
 
-  for (unsigned i = 0; i < arraysize(STRING_ATTRIBUTES); i++) {
+  for (unsigned i = 0; i < base::size(STRING_ATTRIBUTES); i++) {
     const char* attribute_name = STRING_ATTRIBUTES[i];
     std::string value;
     if (!dict.GetString(attribute_name, &value) || value.empty())
@@ -205,7 +205,7 @@
                    &line);
   }
 
-  for (unsigned i = 0; i < arraysize(INT_ATTRIBUTES); i++) {
+  for (unsigned i = 0; i < base::size(INT_ATTRIBUTES); i++) {
     const char* attribute_name = INT_ATTRIBUTES[i];
     int value;
     if (!dict.GetInteger(attribute_name, &value) || value == 0)
diff --git a/content/browser/accessibility/accessibility_tree_formatter_utils_win.cc b/content/browser/accessibility/accessibility_tree_formatter_utils_win.cc
index a54957c6..91bfb20 100644
--- a/content/browser/accessibility/accessibility_tree_formatter_utils_win.cc
+++ b/content/browser/accessibility/accessibility_tree_formatter_utils_win.cc
@@ -9,8 +9,8 @@
 #include <map>
 #include <string>
 
-#include "base/macros.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "third_party/iaccessible2/ia2_api_all.h"
@@ -76,7 +76,7 @@
       QUOTE(ROLE_SYSTEM_WHITESPACE),     QUOTE(ROLE_SYSTEM_WINDOW),
   };
 
-  return GetNameForPlatformConstant(ia_table, arraysize(ia_table), ia_role);
+  return GetNameForPlatformConstant(ia_table, base::size(ia_table), ia_role);
 }
 
 CONTENT_EXPORT base::string16 IAccessible2RoleToString(int32_t ia2_role) {
@@ -136,7 +136,7 @@
       QUOTE(IA2_ROLE_CONTENT_INSERTION),
   };
 
-  return GetNameForPlatformConstant(ia2_table, arraysize(ia2_table), ia2_role);
+  return GetNameForPlatformConstant(ia2_table, base::size(ia2_table), ia2_role);
 }
 
 CONTENT_EXPORT base::string16 AccessibilityEventToString(int32_t event) {
@@ -210,7 +210,8 @@
       QUOTE(IA2_EVENT_VISIBLE_DATA_CHANGED),
   };
 
-  return GetNameForPlatformConstant(event_table, arraysize(event_table), event);
+  return GetNameForPlatformConstant(event_table, base::size(event_table),
+                                    event);
 }
 
 void IAccessibleStateToStringVector(int32_t ia_state,
diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc
index 63606fbd..2eb5ea3 100644
--- a/content/browser/accessibility/browser_accessibility_android.cc
+++ b/content/browser/accessibility/browser_accessibility_android.cc
@@ -423,8 +423,14 @@
 }
 
 const char* BrowserAccessibilityAndroid::GetClassName() const {
-  return ui::AXRoleToAndroidClassName(GetRole(),
-                                      PlatformGetParent() != nullptr);
+  ax::mojom::Role role = GetRole();
+
+  // On Android, contenteditable needs to be handled the same as any
+  // other text field.
+  if (IsPlainTextField() || IsRichTextField())
+    role = ax::mojom::Role::kTextField;
+
+  return ui::AXRoleToAndroidClassName(role, PlatformGetParent() != nullptr);
 }
 
 base::string16 BrowserAccessibilityAndroid::GetText() const {
diff --git a/content/browser/accessibility/browser_accessibility_state_impl_win.cc b/content/browser/accessibility/browser_accessibility_state_impl_win.cc
index 625be876..8c876758 100644
--- a/content/browser/accessibility/browser_accessibility_state_impl_win.cc
+++ b/content/browser/accessibility/browser_accessibility_state_impl_win.cc
@@ -12,8 +12,8 @@
 #include <memory>
 
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "ui/accessibility/platform/ax_platform_node_win.h"
 
@@ -125,7 +125,7 @@
   size_t module_count = bytes_required / sizeof(HMODULE);
   for (size_t i = 0; i < module_count; i++) {
     TCHAR filename[MAX_PATH];
-    GetModuleFileName(modules[i], filename, arraysize(filename));
+    GetModuleFileName(modules[i], filename, base::size(filename));
     base::string16 module_name(base::FilePath(filename).BaseName().value());
     if (base::LowerCaseEqualsASCII(module_name, "fsdomsrv.dll"))
       jaws = true;
diff --git a/content/browser/android/content_feature_list.cc b/content/browser/android/content_feature_list.cc
index 507ec54..538ef50a 100644
--- a/content/browser/android/content_feature_list.cc
+++ b/content/browser/android/content_feature_list.cc
@@ -6,7 +6,7 @@
 
 #include "base/android/jni_string.h"
 #include "base/feature_list.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/public/common/content_features.h"
 #include "jni/ContentFeatureList_jni.h"
 
@@ -27,7 +27,7 @@
 };
 
 const base::Feature* FindFeatureExposedToJava(const std::string& feature_name) {
-  for (size_t i = 0; i < arraysize(kFeaturesExposedToJava); ++i) {
+  for (size_t i = 0; i < base::size(kFeaturesExposedToJava); ++i) {
     if (kFeaturesExposedToJava[i]->name == feature_name)
       return kFeaturesExposedToJava[i];
   }
diff --git a/content/browser/android/java/java_type_unittest.cc b/content/browser/android/java/java_type_unittest.cc
index 44a143b3..6594b038 100644
--- a/content/browser/android/java/java_type_unittest.cc
+++ b/content/browser/android/java/java_type_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace content {
@@ -38,7 +38,7 @@
      "Ljava/lang/Object;"},
     {"my.nested.Type$Foo", JavaType::TypeObject, "my/nested/Type$Foo",
      "Lmy/nested/Type$Foo;"}};
-  for (size_t i = 0; i < arraysize(scalar_types); ++i) {
+  for (size_t i = 0; i < base::size(scalar_types); ++i) {
     JavaType jt = JavaType::CreateFromBinaryName(scalar_types[i].binary_type);
     EXPECT_EQ(scalar_types[i].java_type, jt.type);
     EXPECT_FALSE(jt.inner_type);
diff --git a/content/browser/appcache/appcache_database.cc b/content/browser/appcache/appcache_database.cc
index 11dfdfa..0d5ae8d9 100644
--- a/content/browser/appcache/appcache_database.cc
+++ b/content/browser/appcache/appcache_database.cc
@@ -9,7 +9,7 @@
 #include "base/command_line.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "content/browser/appcache/appcache_entry.h"
 #include "content/browser/appcache/appcache_histograms.h"
@@ -167,8 +167,8 @@
     true },
 };
 
-const int kTableCount = arraysize(kTables);
-const int kIndexCount = arraysize(kIndexes);
+const int kTableCount = base::size(kTables);
+const int kIndexCount = base::size(kIndexes);
 
 bool CreateTable(sql::Database* db, const TableInfo& info) {
   std::string sql("CREATE TABLE ");
diff --git a/content/browser/appcache/appcache_manifest_parser_unittest.cc b/content/browser/appcache/appcache_manifest_parser_unittest.cc
index 07f005b..dba03d1 100644
--- a/content/browser/appcache/appcache_manifest_parser_unittest.cc
+++ b/content/browser/appcache/appcache_manifest_parser_unittest.cc
@@ -7,7 +7,7 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/browser/appcache/appcache_manifest_parser.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
@@ -42,7 +42,7 @@
     "\xEF\xBE\xBF" "CACHE MANIFEST\r",  // bad UTF-8 BOM value
   };
 
-  for (size_t i = 0; i < arraysize(kBadSignatures); ++i) {
+  for (size_t i = 0; i < base::size(kBadSignatures); ++i) {
     const std::string bad = kBadSignatures[i];
     EXPECT_FALSE(ParseManifest(url, bad.c_str(), bad.length(),
                                PARSE_MANIFEST_ALLOWING_DANGEROUS_FEATURES,
@@ -61,7 +61,7 @@
     "\xEF\xBB\xBF" "CACHE MANIFEST \r\n",   // BOM present
   };
 
-  for (size_t i = 0; i < arraysize(kGoodSignatures); ++i) {
+  for (size_t i = 0; i < base::size(kGoodSignatures); ++i) {
     const std::string good = kGoodSignatures[i];
     EXPECT_TRUE(ParseManifest(url, good.c_str(), good.length(),
                               PARSE_MANIFEST_ALLOWING_DANGEROUS_FEATURES,
diff --git a/content/browser/appcache/appcache_request_handler_unittest.cc b/content/browser/appcache/appcache_request_handler_unittest.cc
index 0ed52f2..8d44fb3 100644
--- a/content/browser/appcache/appcache_request_handler_unittest.cc
+++ b/content/browser/appcache/appcache_request_handler_unittest.cc
@@ -15,10 +15,10 @@
 #include "base/callback.h"
 #include "base/containers/stack.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/task/post_task.h"
@@ -554,7 +554,7 @@
         "\0";
     net::HttpResponseInfo info;
     info.headers = new net::HttpResponseHeaders(
-        std::string(kOverrideHeaders, arraysize(kOverrideHeaders)));
+        std::string(kOverrideHeaders, base::size(kOverrideHeaders)));
     SimulateResponseInfo(info);
 
     SetAppCacheJob(handler_->MaybeLoadFallbackForResponse(nullptr));
diff --git a/content/browser/appcache/appcache_response_unittest.cc b/content/browser/appcache/appcache_response_unittest.cc
index 5d0aaa0a0..e9cc370 100644
--- a/content/browser/appcache/appcache_response_unittest.cc
+++ b/content/browser/appcache/appcache_response_unittest.cc
@@ -14,10 +14,10 @@
 #include "base/compiler_specific.h"
 #include "base/containers/stack.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/pickle.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread.h"
@@ -171,7 +171,7 @@
     static const char kHttpBody[] = "Hello";
     scoped_refptr<IOBuffer> body =
         base::MakeRefCounted<WrappedIOBuffer>(kHttpBody);
-    std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
+    std::string raw_headers(kHttpHeaders, base::size(kHttpHeaders));
     WriteResponse(
         MakeHttpResponseInfo(raw_headers), body.get(), strlen(kHttpBody));
   }
@@ -495,7 +495,7 @@
 
   void AmountWritten() {
     static const char kHttpHeaders[] = "HTTP/1.0 200 OK\0\0";
-    std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
+    std::string raw_headers(kHttpHeaders, base::size(kHttpHeaders));
     std::unique_ptr<net::HttpResponseInfo> head =
         MakeHttpResponseInfo(raw_headers);
     int expected_amount_written =
diff --git a/content/browser/appcache/appcache_service_unittest.cc b/content/browser/appcache/appcache_service_unittest.cc
index a50ce5ca..3b1e665 100644
--- a/content/browser/appcache/appcache_service_unittest.cc
+++ b/content/browser/appcache/appcache_service_unittest.cc
@@ -9,10 +9,10 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/pickle.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/browser/appcache/appcache_response.h"
@@ -162,7 +162,7 @@
     info->response_time = base::Time::Now();
     info->was_cached = false;
     info->headers = new net::HttpResponseHeaders(
-        std::string(kMockHeaders, arraysize(kMockHeaders)));
+        std::string(kMockHeaders, base::size(kMockHeaders)));
     return info;
   }
 
diff --git a/content/browser/appcache/appcache_storage_impl_unittest.cc b/content/browser/appcache/appcache_storage_impl_unittest.cc
index 9599a172..1ee4bbef 100644
--- a/content/browser/appcache/appcache_storage_impl_unittest.cc
+++ b/content/browser/appcache/appcache_storage_impl_unittest.cc
@@ -16,10 +16,10 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/sequenced_task_runner_handle.h"
@@ -91,14 +91,14 @@
         "\n";
 
     if (path == "/manifest") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n";
     } else if (path == "/empty.html") {
-      (*headers) = std::string(page_headers, arraysize(page_headers));
+      (*headers) = std::string(page_headers, base::size(page_headers));
       (*body) = "";
     } else {
-      (*headers) = std::string(not_found_headers,
-                               arraysize(not_found_headers));
+      (*headers) =
+          std::string(not_found_headers, base::size(not_found_headers));
       (*body) = "";
     }
   }
diff --git a/content/browser/appcache/appcache_update_job_unittest.cc b/content/browser/appcache/appcache_update_job_unittest.cc
index ffb2202..d45f46e0 100644
--- a/content/browser/appcache/appcache_update_job_unittest.cc
+++ b/content/browser/appcache/appcache_update_job_unittest.cc
@@ -13,7 +13,6 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
 #include "base/single_thread_task_runner.h"
@@ -125,46 +124,46 @@
         "\n";
 
     if (path == "/files/missing-mime-manifest") {
-      (*headers) = std::string(ok_headers, arraysize(ok_headers));
+      (*headers) = std::string(ok_headers, base::size(ok_headers));
       (*body) = "CACHE MANIFEST\n";
     } else if (path == "/files/bad-manifest") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "BAD CACHE MANIFEST";
     } else if (path == "/files/empty1") {
-      (*headers) = std::string(ok_headers, arraysize(ok_headers));
+      (*headers) = std::string(ok_headers, base::size(ok_headers));
       (*body) = "";
     } else if (path == "/files/empty-file-manifest") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "empty1\n";
     } else if (path == "/files/empty-manifest") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n";
     } else if (path == "/files/explicit1") {
-      (*headers) = std::string(ok_headers, arraysize(ok_headers));
+      (*headers) = std::string(ok_headers, base::size(ok_headers));
       (*body) = "explicit1";
     } else if (path == "/files/explicit2") {
-      (*headers) = std::string(ok_headers, arraysize(ok_headers));
+      (*headers) = std::string(ok_headers, base::size(ok_headers));
       (*body) = "explicit2";
     } else if (path == "/files/fallback1a") {
-      (*headers) = std::string(ok_headers, arraysize(ok_headers));
+      (*headers) = std::string(ok_headers, base::size(ok_headers));
       (*body) = "fallback1a";
     } else if (path == "/files/intercept1a") {
-      (*headers) = std::string(ok_headers, arraysize(ok_headers));
+      (*headers) = std::string(ok_headers, base::size(ok_headers));
       (*body) = "intercept1a";
     } else if (path == "/files/gone") {
-      (*headers) = std::string(gone_headers, arraysize(gone_headers));
+      (*headers) = std::string(gone_headers, base::size(gone_headers));
       (*body) = "";
     } else if (path == "/files/manifest1") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = kManifest1Contents;
     } else if (path == "/files/manifest1-with-notmodified") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = kManifest1Contents;
       (*body).append("CACHE:\n"
                      "notmodified\n");
     } else if (path == "/files/manifest-fb-404") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "explicit1\n"
                 "FALLBACK:\n"
@@ -173,7 +172,7 @@
                 "NETWORK:\n"
                 "online1\n";
     } else if (path == "/files/manifest-merged-types") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "explicit1\n"
                 "# manifest is also an explicit entry\n"
@@ -184,7 +183,7 @@
                 "NETWORK:\n"
                 "online1\n";
     } else if (path == "/files/manifest-with-404") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "explicit-404\n"
                 "explicit1\n"
@@ -195,32 +194,31 @@
                 "NETWORK:\n"
                 "online1\n";
     } else if (path == "/files/manifest-with-intercept") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "CHROMIUM-INTERCEPT:\n"
                 "intercept1 return intercept1a\n";
     } else if (path == "/files/notmodified") {
-      (*headers) = std::string(not_modified_headers,
-                               arraysize(not_modified_headers));
+      (*headers) =
+          std::string(not_modified_headers, base::size(not_modified_headers));
       (*body) = "";
     } else if (path == "/files/servererror") {
-      (*headers) = std::string(error_headers,
-                               arraysize(error_headers));
+      (*headers) = std::string(error_headers, base::size(error_headers));
       (*body) = "error";
     } else if (path == "/files/valid_cross_origin_https_manifest") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "https://cross_origin_host/files/explicit1\n";
     } else if (path == "/files/invalid_cross_origin_https_manifest") {
-      (*headers) = std::string(manifest_headers, arraysize(manifest_headers));
+      (*headers) = std::string(manifest_headers, base::size(manifest_headers));
       (*body) = "CACHE MANIFEST\n"
                 "https://cross_origin_host/files/no-store-headers\n";
     } else if (path == "/files/no-store-headers") {
-      (*headers) = std::string(no_store_headers, arraysize(no_store_headers));
+      (*headers) = std::string(no_store_headers, base::size(no_store_headers));
       (*body) = "no-store";
     } else {
-      (*headers) = std::string(not_found_headers,
-                               arraysize(not_found_headers));
+      (*headers) =
+          std::string(not_found_headers, base::size(not_found_headers));
       (*body) = "";
     }
   }
@@ -453,12 +451,12 @@
 
     switch (retry_after_) {
       case NO_RETRY_AFTER:
-        return std::string(no_retry_after, arraysize(no_retry_after));
+        return std::string(no_retry_after, base::size(no_retry_after));
       case NONZERO_RETRY_AFTER:
-        return std::string(nonzero, arraysize(nonzero));
+        return std::string(nonzero, base::size(nonzero));
       case RETRY_AFTER_0:
       default:
-        return std::string(retry_after_0, arraysize(retry_after_0));
+        return std::string(retry_after_0, base::size(retry_after_0));
     }
   }
 
@@ -467,7 +465,7 @@
         "HTTP/1.1 200 OK\n"
         "Content-type: text/cache-manifest\n"
         "\n";
-    return std::string(headers, arraysize(headers));
+    return std::string(headers, base::size(headers));
   }
 
   static std::string data() {
@@ -1785,7 +1783,7 @@
         "HTTP/1.1 200 OK\0"
         "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
         "\0";
-    const std::string kRawHeaders(kData, arraysize(kData));
+    const std::string kRawHeaders(kData, base::size(kData));
     MakeAppCacheResponseInfo(kManifestUrl, 444, kRawHeaders);
     MakeAppCacheResponseInfo(kManifestUrl, 555, kRawHeaders);
 
@@ -2222,7 +2220,7 @@
         "Content-type: text/cache-manifest\0"
         "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
         "\0";
-    const std::string kRawHeaders(kData, arraysize(kData));
+    const std::string kRawHeaders(kData, base::size(kData));
     MakeAppCacheResponseInfo(kManifestUrl, kManifestResponseId, kRawHeaders);
 
     group_ = new AppCacheGroup(
@@ -3077,7 +3075,7 @@
         "HTTP/1.1 200 OK\0"
         "\0";
     net::HttpResponseHeaders* headers =
-        new net::HttpResponseHeaders(std::string(data, arraysize(data)));
+        new net::HttpResponseHeaders(std::string(data, base::size(data)));
     net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
     response_info->headers = headers;  // adds ref to headers
 
@@ -3129,7 +3127,7 @@
         "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0"
         "\0";
     net::HttpResponseHeaders* headers2 =
-        new net::HttpResponseHeaders(std::string(data2, arraysize(data2)));
+        new net::HttpResponseHeaders(std::string(data2, base::size(data2)));
     net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
     response_info->headers = headers2;
 
@@ -3336,7 +3334,7 @@
         "ETag: \"LadeDade\"\0"
         "\0";
     net::HttpResponseHeaders* headers =
-        new net::HttpResponseHeaders(std::string(data, arraysize(data)));
+        new net::HttpResponseHeaders(std::string(data, base::size(data)));
     net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
     response_info->headers = headers;  // adds ref to headers
 
@@ -3390,7 +3388,7 @@
         "ETag: \"LadeDade\"\0"
         "\0";
     net::HttpResponseHeaders* headers =
-        new net::HttpResponseHeaders(std::string(data, arraysize(data)));
+        new net::HttpResponseHeaders(std::string(data, base::size(data)));
     net::HttpResponseInfo* response_info = new net::HttpResponseInfo();
     response_info->headers = headers;  // adds ref to headers
 
diff --git a/content/browser/appcache/appcache_url_request_job_unittest.cc b/content/browser/appcache/appcache_url_request_job_unittest.cc
index a373b78..6135fad 100644
--- a/content/browser/appcache/appcache_url_request_job_unittest.cc
+++ b/content/browser/appcache/appcache_url_request_job_unittest.cc
@@ -17,11 +17,11 @@
 #include "base/containers/stack.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_loop.h"
 #include "base/pickle.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread.h"
@@ -341,7 +341,7 @@
   void WriteBasicResponse() {
     scoped_refptr<IOBuffer> body =
         base::MakeRefCounted<WrappedIOBuffer>(kHttpBasicBody);
-    std::string raw_headers(kHttpBasicHeaders, arraysize(kHttpBasicHeaders));
+    std::string raw_headers(kHttpBasicHeaders, base::size(kHttpBasicHeaders));
     WriteResponse(
         MakeHttpResponseInfo(raw_headers), body.get(), strlen(kHttpBasicBody));
   }
@@ -709,7 +709,7 @@
     char* p = body->data();
     for (int i = 0; i < 3; ++i, p += kBlockSize)
       FillData(i + 1, p, kBlockSize);
-    std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
+    std::string raw_headers(kHttpHeaders, base::size(kHttpHeaders));
     WriteResponse(
         MakeHttpResponseInfo(raw_headers), body.get(), kBlockSize * 3);
   }
diff --git a/content/browser/blob_storage/blob_url_unittest.cc b/content/browser/blob_storage/blob_url_unittest.cc
index 283ded19..a63695e9 100644
--- a/content/browser/blob_storage/blob_url_unittest.cc
+++ b/content/browser/blob_storage/blob_url_unittest.cc
@@ -11,10 +11,10 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "content/browser/url_loader_factory_getter.h"
@@ -169,17 +169,17 @@
     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
 
     temp_file1_ = temp_dir_.GetPath().AppendASCII("BlobFile1.dat");
-    ASSERT_EQ(static_cast<int>(arraysize(kTestFileData1) - 1),
+    ASSERT_EQ(static_cast<int>(base::size(kTestFileData1) - 1),
               base::WriteFile(temp_file1_, kTestFileData1,
-                              arraysize(kTestFileData1) - 1));
+                              base::size(kTestFileData1) - 1));
     base::File::Info file_info1;
     base::GetFileInfo(temp_file1_, &file_info1);
     temp_file_modification_time1_ = file_info1.last_modified;
 
     temp_file2_ = temp_dir_.GetPath().AppendASCII("BlobFile2.dat");
-    ASSERT_EQ(static_cast<int>(arraysize(kTestFileData2) - 1),
+    ASSERT_EQ(static_cast<int>(base::size(kTestFileData2) - 1),
               base::WriteFile(temp_file2_, kTestFileData2,
-                              arraysize(kTestFileData2) - 1));
+                              base::size(kTestFileData2) - 1));
     base::File::Info file_info2;
     base::GetFileInfo(temp_file2_, &file_info2);
     temp_file_modification_time2_ = file_info2.last_modified;
@@ -217,12 +217,12 @@
     const char kFilename1[] = "FileSystemFile1.dat";
     temp_file_system_file1_ = GetFileSystemURL(kFilename1);
     WriteFileSystemFile(kFilename1, kTestFileSystemFileData1,
-                        arraysize(kTestFileSystemFileData1) - 1,
+                        base::size(kTestFileSystemFileData1) - 1,
                         &temp_file_system_file_modification_time1_);
     const char kFilename2[] = "FileSystemFile2.dat";
     temp_file_system_file2_ = GetFileSystemURL(kFilename2);
     WriteFileSystemFile(kFilename2, kTestFileSystemFileData2,
-                        arraysize(kTestFileSystemFileData2) - 1,
+                        base::size(kTestFileSystemFileData2) - 1,
                         &temp_file_system_file_modification_time2_);
   }
 
@@ -443,13 +443,13 @@
 
 TEST_P(BlobURLRequestJobTest, TestGetSimpleDataRequest) {
   blob_data_->AppendData(kTestData1);
-  TestSuccessNonrangeRequest(kTestData1, arraysize(kTestData1) - 1);
+  TestSuccessNonrangeRequest(kTestData1, base::size(kTestData1) - 1);
 }
 
 TEST_P(BlobURLRequestJobTest, TestGetSimpleFileRequest) {
   blob_data_->AppendFile(temp_file1_, 0, std::numeric_limits<uint64_t>::max(),
                          base::Time());
-  TestSuccessNonrangeRequest(kTestFileData1, arraysize(kTestFileData1) - 1);
+  TestSuccessNonrangeRequest(kTestFileData1, base::size(kTestFileData1) - 1);
 }
 
 TEST_P(BlobURLRequestJobTest, TestGetLargeFileRequest) {
@@ -494,7 +494,7 @@
                                    std::numeric_limits<uint64_t>::max(),
                                    base::Time(), file_system_context_);
   TestSuccessNonrangeRequest(kTestFileSystemFileData1,
-                             arraysize(kTestFileSystemFileData1) - 1);
+                             base::size(kTestFileSystemFileData1) - 1);
 }
 
 TEST_P(BlobURLRequestJobTest, TestGetLargeFileSystemFileRequest) {
@@ -554,7 +554,7 @@
                                    disk_cache_entry_.get(),
                                    kTestDiskCacheStreamIndex);
   TestSuccessNonrangeRequest(kTestDiskCacheData1,
-                             arraysize(kTestDiskCacheData1) - 1);
+                             base::size(kTestDiskCacheData1) - 1);
 }
 
 TEST_P(BlobURLRequestJobTest, TestGetComplicatedDataFileAndDiskCacheRequest) {
@@ -658,7 +658,7 @@
   expected_status_code_ = 200;
   expected_response_ = kTestDiskCacheData2;
   TestRequest("GET", net::HttpRequestHeaders());
-  EXPECT_EQ(static_cast<int>(arraysize(kTestDiskCacheData2) - 1),
+  EXPECT_EQ(static_cast<int>(base::size(kTestDiskCacheData2) - 1),
             response_headers_->GetContentLength());
 
   EXPECT_EQ(std::string(kTestDiskCacheSideData), response_metadata_);
@@ -675,7 +675,7 @@
   expected_status_code_ = 200;
   expected_response_ = kTestDiskCacheData2;
   TestRequest("GET", net::HttpRequestHeaders());
-  EXPECT_EQ(static_cast<int>(arraysize(kTestDiskCacheData2) - 1),
+  EXPECT_EQ(static_cast<int>(base::size(kTestDiskCacheData2) - 1),
             response_headers_->GetContentLength());
 
   EXPECT_TRUE(response_metadata_.empty());
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index a43a30d..43a33d7 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -33,6 +33,7 @@
 #include "base/process/process_metrics.h"
 #include "base/run_loop.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/synchronization/waitable_event.h"
@@ -291,7 +292,7 @@
   // Register GLib-handled assertions to go through our logging system.
   const char* const kLogDomains[] =
       { nullptr, "Gtk", "Gdk", "GLib", "GLib-GObject" };
-  for (size_t i = 0; i < arraysize(kLogDomains); i++) {
+  for (size_t i = 0; i < base::size(kLogDomains); i++) {
     g_log_set_handler(
         kLogDomains[i],
         static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL |
diff --git a/content/browser/browser_url_handler_impl.cc b/content/browser/browser_url_handler_impl.cc
index d75e689..5f6d1f2 100644
--- a/content/browser/browser_url_handler_impl.cc
+++ b/content/browser/browser_url_handler_impl.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "content/browser/frame_host/debug_urls.h"
 #include "content/browser/webui/web_ui_impl.h"
@@ -37,7 +37,7 @@
     // Merge all the schemes for which view-source is allowed by default, with
     // the view-source schemes defined by the ContentBrowserClient.
     std::vector<std::string> all_allowed_sub_schemes;
-    for (size_t i = 0; i < arraysize(default_allowed_sub_schemes); ++i)
+    for (size_t i = 0; i < base::size(default_allowed_sub_schemes); ++i)
       all_allowed_sub_schemes.push_back(default_allowed_sub_schemes[i]);
     GetContentClient()->browser()->GetAdditionalViewSourceSchemes(
         &all_allowed_sub_schemes);
diff --git a/content/browser/browsing_data/clear_site_data_throttle_unittest.cc b/content/browser/browsing_data/clear_site_data_throttle_unittest.cc
index 4630b9c..024f339 100644
--- a/content/browser/browsing_data/clear_site_data_throttle_unittest.cc
+++ b/content/browser/browsing_data/clear_site_data_throttle_unittest.cc
@@ -8,6 +8,7 @@
 
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/task/post_task.h"
 #include "base/test/scoped_command_line.h"
@@ -626,7 +627,7 @@
     bool defer;
     throttle->WillStartRequest(&defer);
 
-    for (size_t i = 0; i < arraysize(kTestCases); i++) {
+    for (size_t i = 0; i < base::size(kTestCases); i++) {
       throttle->SetResponseHeaders(std::string(kClearSiteDataHeaderPrefix) +
                                    kTestCases[i].header);
 
@@ -635,7 +636,7 @@
       throttle->SetCurrentURLForTesting(GURL(kTestCases[i].url));
 
       net::RedirectInfo redirect_info;
-      if (i < arraysize(kTestCases) - 1)
+      if (i < base::size(kTestCases) - 1)
         throttle->WillRedirectRequest(redirect_info, &defer);
       else
         throttle->WillProcessResponse(&defer);
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 6b7f72e..bd16e1b 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -149,7 +149,7 @@
 // static
 void ChildProcessLauncher::SetRegisteredFilesForService(
     const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+    catalog::RequiredFileMap required_files) {
   ChildProcessLauncherHelper::SetRegisteredFilesForService(
       service_name, std::move(required_files));
 }
diff --git a/content/browser/child_process_launcher.h b/content/browser/child_process_launcher.h
index 415d916d..26f1376 100644
--- a/content/browser/child_process_launcher.h
+++ b/content/browser/child_process_launcher.h
@@ -210,7 +210,7 @@
   // for the service |service_name|.
   static void SetRegisteredFilesForService(
       const std::string& service_name,
-      std::map<std::string, base::FilePath> required_files);
+      catalog::RequiredFileMap required_files);
 
   // Resets all files registered by |SetRegisteredFilesForService|. Used to
   // support multiple shell context creation in unit_tests.
diff --git a/content/browser/child_process_launcher_helper.h b/content/browser/child_process_launcher_helper.h
index 9b93e1f..4dbac12 100644
--- a/content/browser/child_process_launcher_helper.h
+++ b/content/browser/child_process_launcher_helper.h
@@ -5,7 +5,6 @@
 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_
 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_H_
 
-#include <map>
 #include <memory>
 
 #include "base/macros.h"
@@ -18,6 +17,7 @@
 #include "content/public/common/result_codes.h"
 #include "mojo/public/cpp/platform/platform_channel.h"
 #include "mojo/public/cpp/system/invitation.h"
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
 #include "services/service_manager/zygote/common/zygote_buildflags.h"
 
 #if !defined(OS_FUCHSIA)
@@ -182,7 +182,7 @@
 
   static void SetRegisteredFilesForService(
       const std::string& service_name,
-      std::map<std::string, base::FilePath> required_files);
+      catalog::RequiredFileMap required_files);
 
   static void ResetRegisteredFilesForTesting();
 
diff --git a/content/browser/child_process_launcher_helper_android.cc b/content/browser/child_process_launcher_helper_android.cc
index 04bfd4ac..caacdf8 100644
--- a/content/browser/child_process_launcher_helper_android.cc
+++ b/content/browser/child_process_launcher_helper_android.cc
@@ -234,7 +234,7 @@
 // static
 void ChildProcessLauncherHelper::SetRegisteredFilesForService(
     const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+    catalog::RequiredFileMap required_files) {
   SetFilesToShareForServicePosix(service_name, std::move(required_files));
 }
 
diff --git a/content/browser/child_process_launcher_helper_fuchsia.cc b/content/browser/child_process_launcher_helper_fuchsia.cc
index 06e1067..bd84693 100644
--- a/content/browser/child_process_launcher_helper_fuchsia.cc
+++ b/content/browser/child_process_launcher_helper_fuchsia.cc
@@ -40,7 +40,7 @@
 // static
 void ChildProcessLauncherHelper::SetRegisteredFilesForService(
     const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+    catalog::RequiredFileMap required_files) {
   // TODO(fuchsia): Implement this. (crbug.com/707031)
   NOTIMPLEMENTED();
 }
diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc
index c715a86d0..c981f7f 100644
--- a/content/browser/child_process_launcher_helper_linux.cc
+++ b/content/browser/child_process_launcher_helper_linux.cc
@@ -164,7 +164,7 @@
 // static
 void ChildProcessLauncherHelper::SetRegisteredFilesForService(
     const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+    catalog::RequiredFileMap required_files) {
   SetFilesToShareForServicePosix(service_name, std::move(required_files));
 }
 
diff --git a/content/browser/child_process_launcher_helper_mac.cc b/content/browser/child_process_launcher_helper_mac.cc
index d240f93..de7b7ff 100644
--- a/content/browser/child_process_launcher_helper_mac.cc
+++ b/content/browser/child_process_launcher_helper_mac.cc
@@ -254,7 +254,7 @@
 // static
 void ChildProcessLauncherHelper::SetRegisteredFilesForService(
     const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+    catalog::RequiredFileMap required_files) {
   // No file passing from the manifest on Mac yet.
   DCHECK(required_files.empty());
 }
diff --git a/content/browser/child_process_launcher_helper_posix.cc b/content/browser/child_process_launcher_helper_posix.cc
index 2ca43941..15a9977 100644
--- a/content/browser/child_process_launcher_helper_posix.cc
+++ b/content/browser/child_process_launcher_helper_posix.cc
@@ -16,6 +16,7 @@
 #include "content/public/common/content_descriptors.h"
 #include "content/public/common/content_switches.h"
 #include "mojo/public/cpp/platform/platform_channel_endpoint.h"
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
 #include "services/service_manager/embedder/shared_file_util.h"
 #include "services/service_manager/embedder/switches.h"
 
@@ -25,7 +26,7 @@
 namespace {
 
 using RequiredFilesByServiceMap =
-    std::map<std::string, std::map<std::string, base::FilePath>>;
+    std::map<std::string, catalog::RequiredFileMap>;
 
 RequiredFilesByServiceMap& GetRequiredFilesByServiceMap() {
   static auto* required_files_by_service = new RequiredFilesByServiceMap();
@@ -112,8 +113,7 @@
   const std::string& service_name = service_name_iter->second;
   auto files_iter = GetRequiredFilesByServiceMap().find(service_name);
   if (files_iter != GetRequiredFilesByServiceMap().end()) {
-    const std::map<std::string, base::FilePath>& required_files_map =
-        files_iter->second;
+    const catalog::RequiredFileMap& required_files_map = files_iter->second;
     base::GlobalDescriptors::Key key = kContentDynamicDescriptorStart;
     service_manager::SharedFileSwitchValueBuilder file_switch_value_builder;
     for (const auto& key_path_iter : required_files_map) {
@@ -137,9 +137,8 @@
   return files_to_register;
 }
 
-void SetFilesToShareForServicePosix(
-    const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+void SetFilesToShareForServicePosix(const std::string& service_name,
+                                    catalog::RequiredFileMap required_files) {
   if (required_files.empty())
     return;
 
diff --git a/content/browser/child_process_launcher_helper_posix.h b/content/browser/child_process_launcher_helper_posix.h
index 9622650..956c6d3a 100644
--- a/content/browser/child_process_launcher_helper_posix.h
+++ b/content/browser/child_process_launcher_helper_posix.h
@@ -5,11 +5,11 @@
 #ifndef CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_POSIX_H_
 #define CONTENT_BROWSER_CHILD_PROCESS_LAUNCHER_HELPER_POSIX_H_
 
-#include <map>
 #include <memory>
 
 #include "base/files/file.h"
 #include "base/files/memory_mapped_file.h"
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
 
 namespace base {
 class CommandLine;
@@ -38,9 +38,8 @@
 
 // Called by the service manager to register the files that should be mapped for
 // a service in the child process.
-void SetFilesToShareForServicePosix(
-    const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files);
+void SetFilesToShareForServicePosix(const std::string& service_name,
+                                    catalog::RequiredFileMap required_files);
 
 // Called from unit_tests in order to reset all previously registered files.
 void ResetFilesToShareForTestingPosix();
diff --git a/content/browser/child_process_launcher_helper_win.cc b/content/browser/child_process_launcher_helper_win.cc
index 4aa0c71..4deb943 100644
--- a/content/browser/child_process_launcher_helper_win.cc
+++ b/content/browser/child_process_launcher_helper_win.cc
@@ -121,7 +121,7 @@
 // static
 void ChildProcessLauncherHelper::SetRegisteredFilesForService(
     const std::string& service_name,
-    std::map<std::string, base::FilePath> required_files) {
+    catalog::RequiredFileMap required_files) {
   // No file passing from the manifest on Windows yet.
   DCHECK(required_files.empty());
 }
diff --git a/content/browser/devtools/devtools_io_context.cc b/content/browser/devtools/devtools_io_context.cc
index 02bc1fad..f7c4a2b 100644
--- a/content/browser/devtools/devtools_io_context.cc
+++ b/content/browser/devtools/devtools_io_context.cc
@@ -6,6 +6,7 @@
 
 #include "base/bind.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
 #include "content/browser/devtools/devtools_stream_blob.h"
@@ -66,7 +67,7 @@
   static const char* kTextMIMETypePrefixes[] = {
       "text/", "application/x-javascript", "application/json",
       "application/xml"};
-  for (size_t i = 0; i < arraysize(kTextMIMETypePrefixes); ++i) {
+  for (size_t i = 0; i < base::size(kTextMIMETypePrefixes); ++i) {
     if (base::StartsWith(mime_type, kTextMIMETypePrefixes[i],
                          base::CompareCase::INSENSITIVE_ASCII))
       return true;
diff --git a/content/browser/devtools/protocol/schema_handler.cc b/content/browser/devtools/protocol/schema_handler.cc
index e466bc93..938fcc6 100644
--- a/content/browser/devtools/protocol/schema_handler.cc
+++ b/content/browser/devtools/protocol/schema_handler.cc
@@ -4,6 +4,8 @@
 
 #include "content/browser/devtools/protocol/schema_handler.h"
 
+#include "base/stl_util.h"
+
 namespace content {
 namespace protocol {
 
@@ -33,7 +35,7 @@
       "HeapProfiler",  "Schema",     "Target",        "Overlay",
       "Performance",   "Audits",     "HeadlessExperimental"};
   *domains = protocol::Array<Schema::Domain>::create();
-  for (size_t i = 0; i < arraysize(kDomains); ++i) {
+  for (size_t i = 0; i < base::size(kDomains); ++i) {
     (*domains)->addItem(Schema::Domain::Create()
         .SetName(kDomains[i])
         .SetVersion(kVersion)
diff --git a/content/browser/do_not_track_browsertest.cc b/content/browser/do_not_track_browsertest.cc
index e73aab1..fa15ead 100644
--- a/content/browser/do_not_track_browsertest.cc
+++ b/content/browser/do_not_track_browsertest.cc
@@ -42,25 +42,29 @@
 class DoNotTrackTest : public ContentBrowserTest {
  protected:
   void SetUpOnMainThread() override {
-    original_client_ = SetBrowserClientForTesting(&client_);
-  }
-  void TearDownOnMainThread() override {
-    SetBrowserClientForTesting(original_client_);
-  }
-
-  // Returns false if we cannot enable do not track. It happens only when
-  // Android Kitkat or older systems.
-  // TODO(crbug.com/864403): It seems that we call unsupported Android APIs on
-  // KitKat when we set a ContentBrowserClient. Don't call such APIs and make
-  // this test available on KitKat.
-  bool EnableDoNotTrack() {
 #if defined(OS_ANDROID)
+    // TODO(crbug.com/864403): It seems that we call unsupported Android APIs on
+    // KitKat when we set a ContentBrowserClient. Don't call such APIs and make
+    // this test available on KitKat.
     int32_t major_version = 0, minor_version = 0, bugfix_version = 0;
     base::SysInfo::OperatingSystemVersionNumbers(&major_version, &minor_version,
                                                  &bugfix_version);
     if (major_version < 5)
-      return false;
+      return;
 #endif
+
+    original_client_ = SetBrowserClientForTesting(&client_);
+  }
+  void TearDownOnMainThread() override {
+    if (original_client_)
+      SetBrowserClientForTesting(original_client_);
+  }
+
+  // Returns false if we cannot enable do not track. It happens only when
+  // Android Kitkat or older systems.
+  bool EnableDoNotTrack() {
+    if (!original_client_)
+      return false;
     client_.EnableDoNotTrack();
     RendererPreferences* prefs =
         shell()->web_contents()->GetMutableRendererPrefs();
@@ -117,13 +121,7 @@
 }
 
 // Checks that the DNT header is not sent by default.
-// Disabled on Android due to test failures: crbug.com/916978
-#if defined(OS_ANDROID)
-#define MAYBE_NotEnabled DISABLED_NotEnabled
-#else
-#define MAYBE_NotEnabled NotEnabled
-#endif
-IN_PROC_BROWSER_TEST_F(DoNotTrackTest, MAYBE_NotEnabled) {
+IN_PROC_BROWSER_TEST_F(DoNotTrackTest, NotEnabled) {
   ASSERT_TRUE(embedded_test_server()->Start());
   EXPECT_TRUE(NavigateToURL(shell(), GetURL("/echoheader?DNT")));
   ExpectPageTextEq("None");
diff --git a/content/browser/download/save_package_unittest.cc b/content/browser/download/save_package_unittest.cc
index 4494255..e8e916e 100644
--- a/content/browser/download/save_package_unittest.cc
+++ b/content/browser/download/save_package_unittest.cc
@@ -9,8 +9,8 @@
 
 #include "base/files/file_path.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -194,7 +194,7 @@
 };
 
 TEST_F(SavePackageTest, TestSuccessfullyGenerateSavePackageFilename) {
-  for (size_t i = 0; i < arraysize(kGeneratedFiles); ++i) {
+  for (size_t i = 0; i < base::size(kGeneratedFiles); ++i) {
     base::FilePath::StringType file_name;
     bool ok = GetGeneratedFilename(true,
                                    kGeneratedFiles[i].disposition,
@@ -207,7 +207,7 @@
 }
 
 TEST_F(SavePackageTest, TestUnSuccessfullyGenerateSavePackageFilename) {
-  for (size_t i = 0; i < arraysize(kGeneratedFiles); ++i) {
+  for (size_t i = 0; i < base::size(kGeneratedFiles); ++i) {
     base::FilePath::StringType file_name;
     bool ok = GetGeneratedFilename(false,
                                    kGeneratedFiles[i].disposition,
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index e22d7d50..364fe0d 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -14,7 +14,6 @@
 
 #include "base/bind.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/stl_util.h"
 #include "base/strings/string_util.h"
@@ -4385,7 +4384,7 @@
   const GURL kInitialUrl("http://site3.com");
 
   std::vector<std::unique_ptr<NavigationEntry>> entries;
-  for (size_t i = 0; i < arraysize(kRestoredUrls); ++i) {
+  for (size_t i = 0; i < base::size(kRestoredUrls); ++i) {
     std::unique_ptr<NavigationEntry> entry =
         NavigationController::CreateNavigationEntry(
             kRestoredUrls[i], Referrer(), ui::PAGE_TRANSITION_RELOAD, false,
diff --git a/content/browser/frame_host/navigator_impl_unittest.cc b/content/browser/frame_host/navigator_impl_unittest.cc
index e69a9ff3..f7ea8cd6 100644
--- a/content/browser/frame_host/navigator_impl_unittest.cc
+++ b/content/browser/frame_host/navigator_impl_unittest.cc
@@ -5,7 +5,7 @@
 #include <stdint.h>
 
 #include "base/feature_list.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
 #include "content/browser/frame_host/navigation_controller_impl.h"
@@ -389,7 +389,7 @@
       new network::ResourceResponse);
   const char kNoContentHeaders[] = "HTTP/1.1 204 No Content\0\0";
   response->head.headers = new net::HttpResponseHeaders(
-      std::string(kNoContentHeaders, arraysize(kNoContentHeaders)));
+      std::string(kNoContentHeaders, base::size(kNoContentHeaders)));
   GetLoaderForNavigationRequest(main_request)
       ->CallOnResponseStarted(response, nullptr);
 
@@ -414,7 +414,7 @@
   response = new network::ResourceResponse;
   const char kResetContentHeaders[] = "HTTP/1.1 205 Reset Content\0\0";
   response->head.headers = new net::HttpResponseHeaders(
-      std::string(kResetContentHeaders, arraysize(kResetContentHeaders)));
+      std::string(kResetContentHeaders, base::size(kResetContentHeaders)));
   GetLoaderForNavigationRequest(main_request)
       ->CallOnResponseStarted(response, nullptr);
 
diff --git a/content/browser/gpu/compositor_util.cc b/content/browser/gpu/compositor_util.cc
index fe65297..931c1b7 100644
--- a/content/browser/gpu/compositor_util.cc
+++ b/content/browser/gpu/compositor_util.cc
@@ -13,9 +13,9 @@
 #include "base/command_line.h"
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
 #include "base/numerics/ranges.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/system/sys_info.h"
@@ -210,8 +210,8 @@
        !features::IsUsingSkiaRenderer(),
        "Skia renderer is not used by default.", false, false},
   };
-  DCHECK(index < arraysize(kGpuFeatureData));
-  *eof = (index == arraysize(kGpuFeatureData) - 1);
+  DCHECK(index < base::size(kGpuFeatureData));
+  *eof = (index == base::size(kGpuFeatureData) - 1);
   return kGpuFeatureData[index];
 }
 
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index f157872..de98ea5 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -17,13 +17,13 @@
 #include "base/command_line.h"
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/metrics/field_trial.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
 #include "base/threading/thread.h"
@@ -567,7 +567,7 @@
     return;
   }
   bool has_gpu = false;
-  for (size_t i = 0; i < arraysize(g_gpu_process_hosts); ++i) {
+  for (size_t i = 0; i < base::size(g_gpu_process_hosts); ++i) {
     GpuProcessHost* host = g_gpu_process_hosts[i];
     if (host && ValidateHost(host)) {
       has_gpu = true;
@@ -1077,7 +1077,7 @@
   // If you want a browser command-line switch passed to the GPU process
   // you need to add it to |kSwitchNames| at the beginning of this file.
   cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
-                             arraysize(kSwitchNames));
+                             base::size(kSwitchNames));
   cmd_line->CopySwitchesFrom(
       browser_command_line, switches::kGLSwitchesCopiedFromGpuProcessHost,
       switches::kGLSwitchesCopiedFromGpuProcessHostNumSwitches);
diff --git a/content/browser/host_zoom_map_impl_unittest.cc b/content/browser/host_zoom_map_impl_unittest.cc
index dd9d86d..15602c0b 100644
--- a/content/browser/host_zoom_map_impl_unittest.cc
+++ b/content/browser/host_zoom_map_impl_unittest.cc
@@ -6,8 +6,8 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_clock.h"
 #include "content/public/test/test_browser_thread_bundle.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -72,8 +72,8 @@
        zoomed},
       {HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST, "zoomed.com", "https",
        zoomed}, };
-  ASSERT_EQ(arraysize(expected), levels.size());
-  for (size_t i = 0; i < arraysize(expected); ++i) {
+  ASSERT_EQ(base::size(expected), levels.size());
+  for (size_t i = 0; i < base::size(expected); ++i) {
     SCOPED_TRACE(testing::Message() << "levels[" << i << "]");
     EXPECT_EQ(expected[i].mode, levels[i].mode);
     EXPECT_EQ(expected[i].scheme, levels[i].scheme);
@@ -108,8 +108,8 @@
       {HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST, "login", "chrome", 3.0,
        base::Time()},
   };
-  ASSERT_EQ(arraysize(expected), levels.size());
-  for (size_t i = 0; i < arraysize(expected); ++i) {
+  ASSERT_EQ(base::size(expected), levels.size());
+  for (size_t i = 0; i < base::size(expected); ++i) {
     SCOPED_TRACE(testing::Message() << "levels[" << i << "]");
     EXPECT_EQ(expected[i].mode, levels[i].mode);
     EXPECT_EQ(expected[i].scheme, levels[i].scheme);
diff --git a/content/browser/loader/intercepting_resource_handler_unittest.cc b/content/browser/loader/intercepting_resource_handler_unittest.cc
index 7d1f336..4ad5954 100644
--- a/content/browser/loader/intercepting_resource_handler_unittest.cc
+++ b/content/browser/loader/intercepting_resource_handler_unittest.cc
@@ -12,9 +12,9 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/browser/loader/mock_resource_loader.h"
 #include "content/browser/loader/resource_controller.h"
@@ -371,7 +371,7 @@
   const char kPayload[] = "The long long long long long payload";
   // This should be less than half the size of the payload, so it needs at least
   // 3 reads to receive.
-  const int kOldHandlerBufferSize = arraysize(kPayload) / 3;
+  const int kOldHandlerBufferSize = base::size(kPayload) / 3;
 
   // When sending a payload to the old ResourceHandler, the
   // InterceptingResourceHandler doesn't send a final EOF read.
diff --git a/content/browser/loader/resource_loader_unittest.cc b/content/browser/loader/resource_loader_unittest.cc
index c23f737..2b9ec1ba 100644
--- a/content/browser/loader/resource_loader_unittest.cc
+++ b/content/browser/loader/resource_loader_unittest.cc
@@ -13,12 +13,12 @@
 
 #include "base/containers/circular_deque.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/weak_ptr.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/browser/loader/resource_loader_delegate.h"
 #include "content/browser/loader/test_resource_handler.h"
@@ -251,7 +251,7 @@
       net::URLRequest* request,
       net::NetworkDelegate* network_delegate) const override {
     std::string headers =
-        redirect_ ? std::string(kRedirectHeaders, arraysize(kRedirectHeaders))
+        redirect_ ? std::string(kRedirectHeaders, base::size(kRedirectHeaders))
                   : net::URLRequestTestJob::test_headers();
     return new MockHTTPSURLRequestJob(request, network_delegate, headers,
                                       "dummy response", true);
diff --git a/content/browser/loader/upload_data_stream_builder_unittest.cc b/content/browser/loader/upload_data_stream_builder_unittest.cc
index 6f38daee..05e15622 100644
--- a/content/browser/loader/upload_data_stream_builder_unittest.cc
+++ b/content/browser/loader/upload_data_stream_builder_unittest.cc
@@ -11,8 +11,8 @@
 
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -58,7 +58,7 @@
     std::unique_ptr<BlobDataHandle> handle =
         context.AddFinishedBlob(std::move(builder));
 
-    request_body->AppendBytes(kData, arraysize(kData) - 1);
+    request_body->AppendBytes(kData, base::size(kData) - 1);
     request_body->AppendFileRange(base::FilePath(kFilePath), kFileOffset,
                                   kFileLength, kFileTime);
     request_body->AppendBlob(kBlob);
diff --git a/content/browser/media/media_internals.cc b/content/browser/media/media_internals.cc
index f626c60..6016791 100644
--- a/content/browser/media/media_internals.cc
+++ b/content/browser/media/media_internals.cc
@@ -11,7 +11,6 @@
 
 #include "base/containers/adapters.h"
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/stl_util.h"
@@ -67,7 +66,7 @@
   };
 
   std::string ret;
-  for (size_t i = 0; i < arraysize(flags); ++i) {
+  for (size_t i = 0; i < base::size(flags); ++i) {
     if (effects & flags[i].flag) {
       if (!ret.empty())
         ret += " | ";
diff --git a/content/browser/notifications/notification_database_unittest.cc b/content/browser/notifications/notification_database_unittest.cc
index 8f0978c..7bdbf34 100644
--- a/content/browser/notifications/notification_database_unittest.cc
+++ b/content/browser/notifications/notification_database_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "base/files/scoped_temp_dir.h"
 #include "base/guid.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "content/public/browser/notification_database_data.h"
@@ -82,7 +82,7 @@
   // their origin and Service Worker registration id.
   void PopulateDatabaseWithExampleData(NotificationDatabase* database) {
     std::string notification_id;
-    for (size_t i = 0; i < arraysize(kExampleNotificationData); ++i) {
+    for (size_t i = 0; i < base::size(kExampleNotificationData); ++i) {
       ASSERT_NO_FATAL_FAILURE(CreateAndWriteNotification(
           database, GURL(kExampleNotificationData[i].origin),
           kExampleNotificationData[i].tag,
@@ -504,7 +504,7 @@
   ASSERT_EQ(NotificationDatabase::STATUS_OK,
             database->ReadAllNotificationData(&notifications));
 
-  EXPECT_EQ(arraysize(kExampleNotificationData), notifications.size());
+  EXPECT_EQ(base::size(kExampleNotificationData), notifications.size());
 }
 
 TEST_F(NotificationDatabaseTest, ReadAllNotificationDataEmpty) {
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index ed82bb98..d7d70e9a 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -12,8 +12,8 @@
 #include "base/base_switches.h"
 #include "base/command_line.h"
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/metrics/field_trial.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -372,7 +372,7 @@
     switches::kVModule
   };
   cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches,
-                             arraysize(kCommonForwardSwitches));
+                             base::size(kCommonForwardSwitches));
 
   if (!is_broker_) {
     static const char* const kPluginForwardSwitches[] = {
@@ -384,7 +384,7 @@
       switches::kPpapiStartupDialog,
     };
     cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches,
-                               arraysize(kPluginForwardSwitches));
+                               base::size(kPluginForwardSwitches));
 
     // Copy any flash args over if necessary.
     // TODO(vtl): Stop passing flash args in the command line, or windows is
diff --git a/content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc b/content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc
index 7aa4947..95cb8c4 100644
--- a/content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc
+++ b/content/browser/renderer_host/dwrite_font_proxy_message_filter_win.cc
@@ -16,9 +16,9 @@
 #include "base/feature_list.h"
 #include "base/i18n/case_conversion.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_functions.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -597,7 +597,7 @@
   }
 
   // Temp code to help track down crbug.com/561873
-  for (size_t font = 0; font < arraysize(kLastResortFontNames); font++) {
+  for (size_t font = 0; font < base::size(kLastResortFontNames); font++) {
     uint32_t font_index = 0;
     BOOL exists = FALSE;
     if (SUCCEEDED(collection_->FindFamilyName(kLastResortFontNames[font],
diff --git a/content/browser/renderer_host/input/input_router_impl_unittest.cc b/content/browser/renderer_host/input/input_router_impl_unittest.cc
index 5cb1cb8..2f8b369e 100644
--- a/content/browser/renderer_host/input/input_router_impl_unittest.cc
+++ b/content/browser/renderer_host/input/input_router_impl_unittest.cc
@@ -14,9 +14,9 @@
 
 #include "base/command_line.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_feature_list.h"
 #include "base/test/scoped_task_environment.h"
@@ -952,7 +952,7 @@
       WebInputEvent::kGestureScrollBegin, WebInputEvent::kGestureScrollUpdate,
       WebInputEvent::kGesturePinchBegin,  WebInputEvent::kGesturePinchUpdate,
       WebInputEvent::kGesturePinchEnd,    WebInputEvent::kGestureScrollEnd};
-  for (size_t i = 0; i < arraysize(eventTypes); ++i) {
+  for (size_t i = 0; i < base::size(eventTypes); ++i) {
     WebInputEvent::Type type = eventTypes[i];
     if (ShouldBlockEventStream(GetEventWithType(type))) {
       PressAndSetTouchActionAuto();
@@ -1046,7 +1046,7 @@
       WebInputEvent::kGesturePinchUpdate,
       WebInputEvent::kTouchStart,
       WebInputEvent::kTouchMove};
-  for (size_t i = 0; i < arraysize(kRequiredEventAckTypes); ++i) {
+  for (size_t i = 0; i < base::size(kRequiredEventAckTypes); ++i) {
     const WebInputEvent::Type required_ack_type = kRequiredEventAckTypes[i];
     ASSERT_TRUE(ShouldBlockEventStream(GetEventWithType(required_ack_type)));
   }
diff --git a/content/browser/renderer_host/input/motion_event_web_unittest.cc b/content/browser/renderer_host/input/motion_event_web_unittest.cc
index bf31318a..6f36e8a 100644
--- a/content/browser/renderer_host/input/motion_event_web_unittest.cc
+++ b/content/browser/renderer_host/input/motion_event_web_unittest.cc
@@ -5,6 +5,7 @@
 #include <stddef.h>
 
 #include "base/numerics/math_constants.h"
+#include "base/stl_util.h"
 #include "content/browser/renderer_host/input/motion_event_web.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/blink/blink_event_util.h"
@@ -32,7 +33,7 @@
   PointerProperties pp;
   MotionEventGeneric generic_event(MotionEvent::Action::MOVE, event_time, pp);
   for (MotionEvent::ToolType tool_type : tool_types) {
-    for (size_t i = 0; i < arraysize(tilts_x); ++i) {
+    for (size_t i = 0; i < base::size(tilts_x); ++i) {
       const float tilt_x = tilts_x[i];
       const float tilt_y = tilts_y[i];
       const float orientation = orientations[i];
@@ -84,7 +85,7 @@
       }
 
       generic_event.RemovePointerAt(pointer_index);
-  }
+    }
 }
 }
 
diff --git a/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm b/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
index b0a397f1..61d9010 100644
--- a/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
+++ b/content/browser/renderer_host/input/web_input_event_builders_mac_unittest.mm
@@ -8,7 +8,7 @@
 #import <Cocoa/Cocoa.h>
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #import "ui/events/cocoa/cocoa_event_utils.h"
 #include "ui/events/event.h"
@@ -185,7 +185,7 @@
        ui::DomKey::FromCharacter('9')},
   };
 
-  for (size_t i = 0; i < arraysize(table); ++i) {
+  for (size_t i = 0; i < base::size(table); ++i) {
     NSEvent* mac_event = BuildFakeKeyEvent(table[i].mac_key_code,
                                            table[i].character, 0, NSKeyDown);
     WebKeyboardEvent web_event = WebKeyboardEventBuilder::Build(mac_event);
@@ -198,7 +198,7 @@
 // Test that left- and right-hand modifier keys are interpreted correctly when
 // pressed simultaneously.
 TEST(WebInputEventFactoryTestMac, SimultaneousModifierKeys) {
-  for (size_t i = 0; i < arraysize(kModifierKeys) / 2; ++i) {
+  for (size_t i = 0; i < base::size(kModifierKeys) / 2; ++i) {
     const ModifierKey& left = kModifierKeys[2 * i];
     const ModifierKey& right = kModifierKeys[2 * i + 1];
     // Press the left key.
@@ -229,7 +229,7 @@
 // Test that individual modifier keys are still reported correctly, even if the
 // undocumented left- or right-hand flags are not set.
 TEST(WebInputEventBuilderMacTest, MissingUndocumentedModifierFlags) {
-  for (size_t i = 0; i < arraysize(kModifierKeys); ++i) {
+  for (size_t i = 0; i < base::size(kModifierKeys); ++i) {
     const ModifierKey& key = kModifierKeys[i];
     NSEvent* mac_event = BuildFakeKeyEvent(
         key.mac_key_code, 0, key.non_specific_mask, NSFlagsChanged);
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index a722c5ba..53d03af 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -17,9 +17,9 @@
 #include "base/compiler_specific.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/power_monitor/power_monitor.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -102,8 +102,8 @@
   static const size_t kRfc4122LengthLabel = 36u;
   std::string label(kRfc4122LengthLabel, ' ');
   for (char& c : label) {
-    // Use |arraysize(kAlphabet) - 1| to avoid |kAlphabet|s terminating '\0';
-    c = kAlphabet[base::RandGenerator(arraysize(kAlphabet) - 1)];
+    // Use |base::size(kAlphabet) - 1| to avoid |kAlphabet|s terminating '\0';
+    c = kAlphabet[base::RandGenerator(base::size(kAlphabet) - 1)];
     DCHECK(std::isalnum(c)) << c;
   }
   return label;
@@ -1655,7 +1655,7 @@
   bool requested[] = {requested_audio_input, requested_video_input};
   MediaStreamType stream_types[] = {MEDIA_DEVICE_AUDIO_CAPTURE,
                                     MEDIA_DEVICE_VIDEO_CAPTURE};
-  for (size_t i = 0; i < arraysize(requested); ++i) {
+  for (size_t i = 0; i < base::size(requested); ++i) {
     if (!requested[i])
       continue;
 
diff --git a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
index 62c9808e..1d60dbc 100644
--- a/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
+++ b/content/browser/renderer_host/pepper/pepper_renderer_connection.cc
@@ -9,8 +9,8 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "content/browser/browser_child_process_host_impl.h"
 #include "content/browser/ppapi_plugin_process_host.h"
 #include "content/browser/renderer_host/pepper/browser_ppapi_host_impl.h"
@@ -96,7 +96,7 @@
 
 PepperRendererConnection::PepperRendererConnection(int render_process_id)
     : BrowserMessageFilter(kPepperFilteredMessageClasses,
-                           arraysize(kPepperFilteredMessageClasses)),
+                           base::size(kPepperFilteredMessageClasses)),
       render_process_id_(render_process_id) {
   // Only give the renderer permission for stable APIs.
   in_process_host_.reset(new BrowserPpapiHostImpl(this,
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_mac.mm b/content/browser/renderer_host/pepper/pepper_truetype_font_list_mac.mm
index c59c4a8..bfaf5ba 100644
--- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_mac.mm
+++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_mac.mm
@@ -7,7 +7,7 @@
 #import <Cocoa/Cocoa.h>
 
 #include "base/mac/scoped_nsautorelease_pool.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "ppapi/c/dev/ppb_truetype_font_dev.h"
 #include "ppapi/proxy/serialized_structs.h"
@@ -31,7 +31,7 @@
     PP_TRUETYPEFONTWEIGHT_ULTRABOLD,
     PP_TRUETYPEFONTWEIGHT_HEAVY,
 };
-const NSInteger kPepperFontWeightsLength = arraysize(kPepperFontWeights);
+const NSInteger kPepperFontWeightsLength = base::size(kPepperFontWeights);
 
 }  // namespace
 
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 53b4a977..9d4d674 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -14,8 +14,8 @@
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
 #include "base/debug/alias.h"
-#include "base/macros.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
@@ -89,7 +89,7 @@
     RenderWidgetHelper* render_widget_helper,
     MediaInternals* media_internals)
     : BrowserMessageFilter(kRenderFilteredMessageClasses,
-                           arraysize(kRenderFilteredMessageClasses)),
+                           base::size(kRenderFilteredMessageClasses)),
       BrowserAssociatedInterface<mojom::RenderMessageFilter>(this, this),
       resource_dispatcher_host_(ResourceDispatcherHostImpl::Get()),
       resource_context_(browser_context->GetResourceContext()),
@@ -97,7 +97,6 @@
       render_process_id_(render_process_id),
       media_internals_(media_internals),
       weak_ptr_factory_(this) {
-
   if (render_widget_helper)
     render_widget_helper_->Init(render_process_id_, resource_dispatcher_host_);
 }
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index cca56202..7fd819b 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -28,7 +28,6 @@
 #include "base/lazy_instance.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/memory_pressure_monitor.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
@@ -3137,7 +3136,7 @@
 #endif
   };
   renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames,
-                                 arraysize(kSwitchNames));
+                                 base::size(kSwitchNames));
 
   BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(renderer_cmd);
   BrowserChildProcessHostImpl::CopyTraceStartupFlags(renderer_cmd);
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.mm b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.mm
index 3f089d7..d0e908ba 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac_editcommand_helper.mm
@@ -7,7 +7,7 @@
 #import <objc/runtime.h>
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/browser/renderer_host/render_widget_host_impl.h"
 #import "content/browser/renderer_host/render_widget_host_view_mac.h"
 
@@ -181,7 +181,7 @@
 
 RenderWidgetHostViewMacEditCommandHelper::
     RenderWidgetHostViewMacEditCommandHelper() {
-  for (size_t i = 0; i < arraysize(kEditCommands); ++i) {
+  for (size_t i = 0; i < base::size(kEditCommands); ++i) {
     edit_command_set_.insert(kEditCommands[i]);
   }
 }
@@ -192,7 +192,7 @@
 // Dynamically adds Selectors to the aformentioned class.
 void RenderWidgetHostViewMacEditCommandHelper::AddEditingSelectorsToClass(
     Class klass) {
-  for (size_t i = 0; i < arraysize(kEditCommands); ++i) {
+  for (size_t i = 0; i < base::size(kEditCommands); ++i) {
     // Append trailing ':' to command name to get selector name.
     NSString* sel_str = [NSString stringWithFormat: @"%s:", kEditCommands[i]];
 
@@ -228,7 +228,7 @@
 }
 
 NSArray* RenderWidgetHostViewMacEditCommandHelper::GetEditSelectorNames() {
-  size_t num_edit_commands = arraysize(kEditCommands);
+  size_t num_edit_commands = base::size(kEditCommands);
   NSMutableArray* ret = [NSMutableArray arrayWithCapacity:num_edit_commands];
 
   for (size_t i = 0; i < num_edit_commands; ++i) {
diff --git a/content/browser/sandbox_ipc_linux.cc b/content/browser/sandbox_ipc_linux.cc
index 22683d6..9756262 100644
--- a/content/browser/sandbox_ipc_linux.cc
+++ b/content/browser/sandbox_ipc_linux.cc
@@ -15,11 +15,11 @@
 #include "base/command_line.h"
 #include "base/files/scoped_file.h"
 #include "base/linux_util.h"
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/posix/unix_domain_socket.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "content/public/common/content_switches.h"
 #include "sandbox/linux/services/libc_interceptor.h"
@@ -43,7 +43,7 @@
   int failed_polls = 0;
   for (;;) {
     const int r =
-        HANDLE_EINTR(poll(pfds, arraysize(pfds), -1 /* no timeout */));
+        HANDLE_EINTR(poll(pfds, base::size(pfds), -1 /* no timeout */));
     // '0' is not a possible return value with no timeout.
     DCHECK_NE(0, r);
     if (r < 0) {
diff --git a/content/browser/service_manager/service_manager_context.cc b/content/browser/service_manager/service_manager_context.cc
index 5d5630c..0f8d4ba4 100644
--- a/content/browser/service_manager/service_manager_context.cc
+++ b/content/browser/service_manager/service_manager_context.cc
@@ -56,6 +56,8 @@
 #include "mojo/public/cpp/system/invitation.h"
 #include "services/audio/public/mojom/constants.mojom.h"
 #include "services/audio/service_factory.h"
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
+#include "services/catalog/public/mojom/constants.mojom.h"
 #include "services/data_decoder/public/mojom/constants.mojom.h"
 #include "services/device/device_service.h"
 #include "services/device/public/mojom/constants.mojom.h"
@@ -71,6 +73,7 @@
 #include "services/resource_coordinator/public/mojom/service_constants.mojom.h"
 #include "services/resource_coordinator/resource_coordinator_service.h"
 #include "services/service_manager/connect_params.h"
+#include "services/service_manager/embedder/manifest_utils.h"
 #include "services/service_manager/public/cpp/connector.h"
 #include "services/service_manager/public/cpp/constants.h"
 #include "services/service_manager/public/cpp/manifest.h"
@@ -561,6 +564,7 @@
         {mojom::kPluginServiceName, IDR_MOJO_CONTENT_PLUGIN_MANIFEST},
         {mojom::kRendererServiceName, IDR_MOJO_CONTENT_RENDERER_MANIFEST},
         {mojom::kUtilityServiceName, IDR_MOJO_CONTENT_UTILITY_MANIFEST},
+        {catalog::mojom::kServiceName, IDR_MOJO_CATALOG_MANIFEST},
     };
     std::vector<service_manager::Manifest> manifests;
     for (const auto& manifest_info : kManifestInfo) {
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc
index 7b6d1e4e..0adedaf 100644
--- a/content/browser/service_worker/embedded_worker_test_helper.cc
+++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -13,6 +13,7 @@
 #include "base/atomic_sequence_num.h"
 #include "base/bind.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "content/browser/service_worker/embedded_worker_instance.h"
@@ -524,7 +525,7 @@
       "Content-Type: application/javascript\0"
       "\0";
   info.headers =
-      new net::HttpResponseHeaders(std::string(data, arraysize(data)));
+      new net::HttpResponseHeaders(std::string(data, base::size(data)));
   return info;
 }
 
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc
index 5928b82..3d266d6 100644
--- a/content/browser/service_worker/service_worker_browsertest.cc
+++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -13,11 +13,11 @@
 #include "base/callback.h"
 #include "base/command_line.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
@@ -407,7 +407,7 @@
       "Content-Type: application/javascript\0"
       "\0";
   info.headers =
-      new net::HttpResponseHeaders(std::string(data, arraysize(data)));
+      new net::HttpResponseHeaders(std::string(data, base::size(data)));
   return info;
 }
 
diff --git a/content/browser/service_worker/service_worker_cache_writer_unittest.cc b/content/browser/service_worker/service_worker_cache_writer_unittest.cc
index d37f40a40..3afddb09 100644
--- a/content/browser/service_worker/service_worker_cache_writer_unittest.cc
+++ b/content/browser/service_worker/service_worker_cache_writer_unittest.cc
@@ -10,8 +10,8 @@
 #include <string>
 
 #include "base/containers/queue.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "content/browser/service_worker/service_worker_disk_cache.h"
 #include "content/browser/service_worker/service_worker_test_utils.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -378,13 +378,13 @@
       "abcdef", "ghijkl", "mnopqr", "stuvwxyz",
   };
   size_t response_size = 0;
-  for (size_t i = 0; i < arraysize(expected_data); ++i)
+  for (size_t i = 0; i < base::size(expected_data); ++i)
     response_size += expected_data[i].size();
 
   MockServiceWorkerResponseReader* reader = ExpectReader();
 
   reader->ExpectReadInfoOk(response_size, true);
-  for (size_t i = 0; i < arraysize(expected_data); ++i) {
+  for (size_t i = 0; i < base::size(expected_data); ++i) {
     reader->ExpectReadDataOk(expected_data[i], true);
   }
   Initialize(false /* pause_when_not_identical */);
@@ -393,7 +393,7 @@
   EXPECT_EQ(net::ERR_IO_PENDING, error);
   reader->CompletePendingRead();
 
-  for (size_t i = 0; i < arraysize(expected_data); ++i) {
+  for (size_t i = 0; i < base::size(expected_data); ++i) {
     error = WriteData(expected_data[i]);
     EXPECT_EQ(net::ERR_IO_PENDING, error);
     reader->CompletePendingRead();
diff --git a/content/browser/service_worker/service_worker_database_unittest.cc b/content/browser/service_worker/service_worker_database_unittest.cc
index 90a2b42..305f0ffc 100644
--- a/content/browser/service_worker/service_worker_database_unittest.cc
+++ b/content/browser/service_worker/service_worker_database_unittest.cc
@@ -11,7 +11,6 @@
 
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/metrics/histogram_tester.h"
@@ -261,7 +260,7 @@
   EXPECT_EQ(
       ServiceWorkerDatabase::STATUS_OK,
       database->WriteUncommittedResourceIds(std::set<int64_t>(
-          kUncommittedIds, kUncommittedIds + arraysize(kUncommittedIds))));
+          kUncommittedIds, kUncommittedIds + base::size(kUncommittedIds))));
   EXPECT_EQ(
       ServiceWorkerDatabase::STATUS_OK,
       database->GetNextAvailableIds(&ids.reg_id, &ids.ver_id, &ids.res_id));
@@ -273,7 +272,7 @@
   const int64_t kPurgeableIds[] = {4, 12, 16, 17, 20};
   EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
             database->WriteUncommittedResourceIds(std::set<int64_t>(
-                kPurgeableIds, kPurgeableIds + arraysize(kPurgeableIds))));
+                kPurgeableIds, kPurgeableIds + base::size(kPurgeableIds))));
   EXPECT_EQ(
       ServiceWorkerDatabase::STATUS_OK,
       database->GetNextAvailableIds(&ids.reg_id, &ids.ver_id, &ids.res_id));
diff --git a/content/browser/service_worker/service_worker_job_unittest.cc b/content/browser/service_worker/service_worker_job_unittest.cc
index d7f87bf..b972b61b 100644
--- a/content/browser/service_worker/service_worker_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_job_unittest.cc
@@ -7,9 +7,9 @@
 
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/optional.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/test_simple_task_runner.h"
 #include "base/time/time.h"
 #include "content/browser/service_worker/embedded_worker_registry.h"
@@ -944,7 +944,7 @@
   scoped_refptr<IOBuffer> body_buffer =
       base::MakeRefCounted<WrappedIOBuffer>(body.data());
   const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0\0";
-  std::string headers(kHttpHeaders, arraysize(kHttpHeaders));
+  std::string headers(kHttpHeaders, base::size(kHttpHeaders));
   WriteResponse(storage, id, headers, body_buffer.get(), body.length());
 }
 
diff --git a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
index aef2b350..468ff72 100644
--- a/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_read_from_cache_job_unittest.cc
@@ -11,6 +11,7 @@
 #include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "content/browser/service_worker/embedded_worker_test_helper.h"
 #include "content/browser/service_worker/service_worker_context_core.h"
 #include "content/browser/service_worker/service_worker_registration.h"
@@ -112,8 +113,8 @@
   bool WriteResource(int64_t resource_id) {
     const char kHttpHeaders[] = "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
     const char kHttpBody[] = "Hello";
-    const int length = arraysize(kHttpBody);
-    std::string headers(kHttpHeaders, arraysize(kHttpHeaders));
+    const int length = base::size(kHttpBody);
+    std::string headers(kHttpHeaders, base::size(kHttpHeaders));
     scoped_refptr<net::IOBuffer> body =
         base::MakeRefCounted<net::WrappedIOBuffer>(kHttpBody);
 
diff --git a/content/browser/service_worker/service_worker_storage_unittest.cc b/content/browser/service_worker/service_worker_storage_unittest.cc
index 6f03308c..08bf400 100644
--- a/content/browser/service_worker/service_worker_storage_unittest.cc
+++ b/content/browser/service_worker/service_worker_storage_unittest.cc
@@ -12,8 +12,8 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "build/build_config.h"
@@ -208,7 +208,7 @@
 int WriteBasicResponse(ServiceWorkerStorage* storage, int64_t id) {
   const char kHttpHeaders[] = "HTTP/1.0 200 HONKYDORY\0Content-Length: 5\0\0";
   const char kHttpBody[] = "Hello";
-  std::string headers(kHttpHeaders, arraysize(kHttpHeaders));
+  std::string headers(kHttpHeaders, base::size(kHttpHeaders));
   return WriteStringResponse(storage, id, headers, std::string(kHttpBody));
 }
 
@@ -1844,7 +1844,7 @@
     bool IsOriginTrialsSupported() const override { return true; }
     base::StringPiece GetPublicKey() const override {
       return base::StringPiece(reinterpret_cast<const char*>(kTestPublicKey),
-                               arraysize(kTestPublicKey));
+                               base::size(kTestPublicKey));
     }
     bool IsOriginSecure(const GURL& url) const override {
       return content::IsOriginSecure(url);
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
index 4730ec0..b4b0ec0 100644
--- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
@@ -9,10 +9,10 @@
 
 #include "base/bind_helpers.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/browser/service_worker/embedded_worker_test_helper.h"
 #include "content/browser/service_worker/service_worker_context_core.h"
@@ -65,18 +65,16 @@
 net::URLRequestJob* CreateNormalURLRequestJob(
     net::URLRequest* request,
     net::NetworkDelegate* network_delegate) {
-  return new net::URLRequestTestJob(request,
-                                    network_delegate,
-                                    std::string(kHeaders, arraysize(kHeaders)),
-                                    kScriptCode,
-                                    true);
+  return new net::URLRequestTestJob(request, network_delegate,
+                                    std::string(kHeaders, base::size(kHeaders)),
+                                    kScriptCode, true);
 }
 
 net::URLRequestJob* CreateResponseJob(const std::string& response_data,
                                       net::URLRequest* request,
                                       net::NetworkDelegate* network_delegate) {
   return new net::URLRequestTestJob(request, network_delegate,
-                                    std::string(kHeaders, arraysize(kHeaders)),
+                                    std::string(kHeaders, base::size(kHeaders)),
                                     response_data, true);
 }
 
@@ -97,11 +95,9 @@
       "Expires: Thu, 1 Jan 2100 20:00:00 GMT\n"
       "\n";
   return new net::URLRequestTestJob(
-      request,
-      network_delegate,
-      std::string(kPlainTextHeaders, arraysize(kPlainTextHeaders)),
-      kScriptCode,
-      true);
+      request, network_delegate,
+      std::string(kPlainTextHeaders, base::size(kPlainTextHeaders)),
+      kScriptCode, true);
 }
 
 class SSLCertificateErrorJob : public net::URLRequestTestJob {
@@ -141,11 +137,9 @@
 net::URLRequestJob* CreateSSLCertificateErrorJob(
     net::URLRequest* request,
     net::NetworkDelegate* network_delegate) {
-  return new SSLCertificateErrorJob(request,
-                                    network_delegate,
-                                    std::string(kHeaders, arraysize(kHeaders)),
-                                    kScriptCode,
-                                    true);
+  return new SSLCertificateErrorJob(request, network_delegate,
+                                    std::string(kHeaders, base::size(kHeaders)),
+                                    kScriptCode, true);
 }
 
 class CertStatusErrorJob : public net::URLRequestTestJob {
@@ -172,11 +166,9 @@
 net::URLRequestJob* CreateCertStatusErrorJob(
     net::URLRequest* request,
     net::NetworkDelegate* network_delegate) {
-  return new CertStatusErrorJob(request,
-                                network_delegate,
-                                std::string(kHeaders, arraysize(kHeaders)),
-                                kScriptCode,
-                                true);
+  return new CertStatusErrorJob(request, network_delegate,
+                                std::string(kHeaders, base::size(kHeaders)),
+                                kScriptCode, true);
 }
 
 class MockHttpProtocolHandler
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 166635d8..02c5cd1 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -29,6 +29,7 @@
 #include "base/scoped_observer.h"
 #include "base/sequenced_task_runner.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/pattern.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
@@ -3791,10 +3792,10 @@
                  embedded_test_server()->GetURL("b.com", "/tall_page.html")};
   const std::string scrolling_values[] = {"yes", "auto", "no"};
 
-  for (size_t i = 0; i < arraysize(scrolling_values); ++i) {
+  for (size_t i = 0; i < base::size(scrolling_values); ++i) {
     bool expect_scrollbar = scrolling_values[i] != "no";
     set_scrolling_property(root->current_frame_host(), scrolling_values[i]);
-    for (size_t j = 0; j < arraysize(urls); ++j) {
+    for (size_t j = 0; j < base::size(urls); ++j) {
       NavigateFrameToURL(child, urls[j]);
       EXPECT_EQ(expect_scrollbar, has_scrollbar(child->current_frame_host()));
     }
@@ -3839,7 +3840,7 @@
   // Before each navigation, we change the marginwidth and marginheight
   // properties of the frame. We then check whether those properties are applied
   // correctly after the navigation has completed.
-  for (size_t i = 0; i < arraysize(urls); ++i) {
+  for (size_t i = 0; i < base::size(urls); ++i) {
     // Change marginwidth and marginheight before navigating.
     EXPECT_TRUE(ExecJs(
         root,
@@ -3899,7 +3900,7 @@
   // Before each navigation, we change the csp property of the frame.
   // We then check whether that property is applied
   // correctly after the navigation has completed.
-  for (size_t i = 0; i < arraysize(urls); ++i) {
+  for (size_t i = 0; i < base::size(urls); ++i) {
     // Change csp before navigating.
     EXPECT_TRUE(ExecuteScript(
         root,
@@ -7733,7 +7734,7 @@
 class PendingWidgetMessageFilter : public BrowserMessageFilter {
  public:
   PendingWidgetMessageFilter()
-      : BrowserMessageFilter(kMessageClasses, arraysize(kMessageClasses)),
+      : BrowserMessageFilter(kMessageClasses, base::size(kMessageClasses)),
         routing_id_(MSG_ROUTING_NONE) {}
 
   bool OnMessageReceived(const IPC::Message& message) override {
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc
index 2517a1f0..fb27505 100644
--- a/content/browser/storage_partition_impl_unittest.cc
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -7,9 +7,9 @@
 
 #include "base/files/file_util.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/test/scoped_feature_list.h"
 #include "base/threading/thread.h"
@@ -254,8 +254,8 @@
     auto serialized_origin =
         leveldb::StdStringToUint8Vector(origin.Serialize());
     std::vector<uint8_t> key;
-    key.reserve(arraysize(kMetaPrefix) + serialized_origin.size());
-    key.insert(key.end(), kMetaPrefix, kMetaPrefix + arraysize(kMetaPrefix));
+    key.reserve(base::size(kMetaPrefix) + serialized_origin.size());
+    key.insert(key.end(), kMetaPrefix, kMetaPrefix + base::size(kMetaPrefix));
     key.insert(key.end(), serialized_origin.begin(), serialized_origin.end());
     return key;
   }
@@ -1477,8 +1477,8 @@
   const char test_data[] = {0, 1, 2, 3, 4, 5};
   base::File file = tester.OpenClearKeyFileForWrite();
   EXPECT_TRUE(file.IsValid());
-  EXPECT_EQ(static_cast<int>(arraysize(test_data)),
-            file.Write(0, test_data, arraysize(test_data)));
+  EXPECT_EQ(static_cast<int>(base::size(test_data)),
+            file.Write(0, test_data, base::size(test_data)));
 
   base::RunLoop run_loop;
   base::ThreadTaskRunnerHandle::Get()->PostTask(
@@ -1490,8 +1490,8 @@
   EXPECT_FALSE(tester.DataExistsForOrigin(kOrigin2));
 
   const char more_data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
-  EXPECT_EQ(static_cast<int>(arraysize(more_data)),
-            file.WriteAtCurrentPos(more_data, arraysize(more_data)));
+  EXPECT_EQ(static_cast<int>(base::size(more_data)),
+            file.WriteAtCurrentPos(more_data, base::size(more_data)));
 
   base::File file2 = tester.OpenClearKeyFileForWrite();
   EXPECT_FALSE(file2.IsValid());
diff --git a/content/browser/utility_process_host.cc b/content/browser/utility_process_host.cc
index 233ce5d..074f2906 100644
--- a/content/browser/utility_process_host.cc
+++ b/content/browser/utility_process_host.cc
@@ -13,6 +13,7 @@
 #include "base/files/file_path.h"
 #include "base/i18n/base_i18n_switches.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
 #include "components/network_session_configurator/common/network_switches.h"
@@ -398,7 +399,7 @@
 #endif
     };
     cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
-                               arraysize(kSwitchNames));
+                               base::size(kSwitchNames));
 
     network_session_configurator::CopyNetworkSwitches(browser_command_line,
                                                       cmd_line.get());
diff --git a/content/browser/webui/web_ui_data_source_unittest.cc b/content/browser/webui/web_ui_data_source_unittest.cc
index 6125eb9..a9d1f501 100644
--- a/content/browser/webui/web_ui_data_source_unittest.cc
+++ b/content/browser/webui/web_ui_data_source_unittest.cc
@@ -3,8 +3,8 @@
 // found in the LICENSE file.
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "content/browser/webui/web_ui_data_source_impl.h"
 #include "content/public/test/test_browser_thread_bundle.h"
@@ -38,10 +38,10 @@
     base::RefCountedStaticMemory* bytes = nullptr;
     if (resource_id == kDummyDefaultResourceId) {
       bytes = new base::RefCountedStaticMemory(
-          kDummyDefaultResource, arraysize(kDummyDefaultResource));
+          kDummyDefaultResource, base::size(kDummyDefaultResource));
     } else if (resource_id == kDummyResourceId) {
       bytes = new base::RefCountedStaticMemory(kDummyResource,
-                                               arraysize(kDummyResource));
+                                               base::size(kDummyResource));
     }
     return bytes;
   }
diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc
index 7b3fab6f..ee19409 100644
--- a/content/child/blink_platform_impl.cc
+++ b/content/child/blink_platform_impl.cc
@@ -12,13 +12,13 @@
 #include "base/bind.h"
 #include "base/files/file_path.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
 #include "base/metrics/user_metrics_action.h"
 #include "base/rand_util.h"
 #include "base/run_loop.h"
 #include "base/sequence_checker.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -524,7 +524,7 @@
 
   // TODO(flackr): We should use a better than linear search here, a trie would
   // be ideal.
-  for (size_t i = 0; i < arraysize(kDataResources); ++i) {
+  for (size_t i = 0; i < base::size(kDataResources); ++i) {
     if (!strcmp(name, kDataResources[i].name)) {
       base::StringPiece resource = GetContentClient()->GetDataResource(
           kDataResources[i].id, kDataResources[i].scale_factor);
diff --git a/content/common/font_list_fontconfig.cc b/content/common/font_list_fontconfig.cc
index a14eae72..ed8d8584 100644
--- a/content/common/font_list_fontconfig.cc
+++ b/content/common/font_list_fontconfig.cc
@@ -11,6 +11,7 @@
 
 #include <fontconfig/fontconfig.h>
 
+#include "base/stl_util.h"
 #include "base/values.h"
 
 namespace content {
@@ -38,7 +39,7 @@
   // See https://www.freetype.org/freetype2/docs/reference/ft2-font_formats.html
   // for the list of possible formats.
   const char* allowed_formats[] = { "TrueType", "CFF" };
-  for (size_t i = 0; i < arraysize(allowed_formats); ++i) {
+  for (size_t i = 0; i < base::size(allowed_formats); ++i) {
     auto format_pattern = CreateFormatPattern(allowed_formats[i]);
     std::unique_ptr<FcFontSet, decltype(&FcFontSetDestroy)> fontset(
         FcFontList(nullptr, format_pattern.get(), object_set.get()),
diff --git a/content/common/unique_name_helper.cc b/content/common/unique_name_helper.cc
index 28b28172..26d8a5e2 100644
--- a/content/common/unique_name_helper.cc
+++ b/content/common/unique_name_helper.cc
@@ -8,6 +8,7 @@
 #include <utility>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
@@ -160,9 +161,9 @@
 
   std::string hashed_name;
   uint8_t result[crypto::kSHA256Length];
-  crypto::SHA256HashString(name, result, arraysize(result));
+  crypto::SHA256HashString(name, result, base::size(result));
   hashed_name += "<!--frameHash";
-  hashed_name += base::HexEncode(result, arraysize(result));
+  hashed_name += base::HexEncode(result, base::size(result));
   hashed_name += "-->";
   return hashed_name;
 }
diff --git a/content/common/webplugininfo_unittest.cc b/content/common/webplugininfo_unittest.cc
index a0b1b63..05ce782 100644
--- a/content/common/webplugininfo_unittest.cc
+++ b/content/common/webplugininfo_unittest.cc
@@ -10,7 +10,7 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/version.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -33,7 +33,7 @@
     { "1..0", "1.0.0" }                // Empty version component
   };
 
-  for (size_t i = 0; i < arraysize(versions); i++) {
+  for (size_t i = 0; i < base::size(versions); i++) {
     base::Version version;
     WebPluginInfo::CreateVersionFromString(
         base::ASCIIToUTF16(versions[i][0]), &version);
diff --git a/content/content_resources.grd b/content/content_resources.grd
index 44307b2..6578475 100644
--- a/content/content_resources.grd
+++ b/content/content_resources.grd
@@ -26,6 +26,7 @@
       <include name="IDR_INDEXED_DB_INTERNALS_CSS" file="browser/resources/indexed_db/indexeddb_internals.css" flattenhtml="true" compress="gzip" type="BINDATA" />
       <include name="IDR_MEDIA_INTERNALS_HTML" file="browser/resources/media/media_internals.html" flattenhtml="true" allowexternalscript="true" compress="gzip" type="BINDATA" />
       <include name="IDR_MEDIA_INTERNALS_JS" file="browser/resources/media/media_internals.js" flattenhtml="true" compress="gzip" type="BINDATA" />
+      <include name="IDR_MOJO_CATALOG_MANIFEST" file="../services/catalog/manifest.json" type="BINDATA" />
       <include name="IDR_MOJO_CONTENT_BROWSER_MANIFEST" file="${root_gen_dir}/content/public/app/browser_manifest.json" use_base_dir="false" type="BINDATA" />
       <include name="IDR_MOJO_CONTENT_GPU_MANIFEST" file="${root_gen_dir}/content/public/app/gpu_manifest.json" use_base_dir="false" type="BINDATA" />
       <include name="IDR_MOJO_CONTENT_PACKAGED_SERVICES_MANIFEST" file="${root_gen_dir}/content/public/app/packaged_services_manifest.json" use_base_dir="false" type="BINDATA" />
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java b/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java
index 0e59dc4..658127bd 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/accessibility/WebContentsAccessibilityTest.java
@@ -474,4 +474,25 @@
         Assert.assertEquals(textNode.isContentInvalid(), false);
         Assert.assertEquals(textNode.getError(), "");
     }
+
+    /**
+     * ContentEditable elements should get a class name of EditText.
+     **/
+    @Test
+    @MediumTest
+    @MinAndroidSdkLevel(Build.VERSION_CODES.LOLLIPOP)
+    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+    public void testContentEditableClassName() throws Throwable {
+        final String data = "<div contenteditable>Edit This</div>";
+
+        mActivityTestRule.launchContentShellWithUrl(UrlUtils.encodeHtmlDataUri(data));
+        mActivityTestRule.waitForActiveShellToBeDoneLoading();
+        AccessibilityNodeProvider provider = enableAccessibilityAndWaitForNodeProvider();
+        int textNodeVirtualViewId = waitForNodeWithClassName(provider, "android.widget.EditText");
+        AccessibilityNodeInfo editableNode =
+                provider.createAccessibilityNodeInfo(textNodeVirtualViewId);
+        Assert.assertNotNull(editableNode);
+        Assert.assertEquals(editableNode.isEditable(), true);
+        Assert.assertEquals(editableNode.getText().toString(), "Edit This");
+    }
 }
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index e8f77a30..6f604ca7 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -15,7 +15,6 @@
 #include "base/command_line.h"
 #include "base/guid.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/process/kill.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
@@ -3087,7 +3086,7 @@
 SynchronizeVisualPropertiesMessageFilter::
     SynchronizeVisualPropertiesMessageFilter()
     : content::BrowserMessageFilter(kMessageClassesToFilter,
-                                    arraysize(kMessageClassesToFilter)),
+                                    base::size(kMessageClassesToFilter)),
       screen_space_rect_run_loop_(std::make_unique<base::RunLoop>()),
       screen_space_rect_received_(false) {}
 
diff --git a/content/public/test/test_host_resolver.cc b/content/public/test/test_host_resolver.cc
index e8e02a4..4c040d2 100644
--- a/content/public/test/test_host_resolver.cc
+++ b/content/public/test/test_host_resolver.cc
@@ -4,7 +4,7 @@
 
 #include "content/public/test/test_host_resolver.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread.h"
 #include "content/browser/notification_service_impl.h"
 #include "net/base/net_errors.h"
@@ -33,7 +33,7 @@
     if (host == net::GetHostName()) {
       local = true;
     } else {
-      for (size_t i = 0; i < arraysize(kLocalHostNames); i++)
+      for (size_t i = 0; i < base::size(kLocalHostNames); i++)
         if (host == kLocalHostNames[i]) {
           local = true;
           break;
diff --git a/content/public/test/test_launcher.cc b/content/public/test/test_launcher.cc
index 38425c8..408ccb2c 100644
--- a/content/public/test/test_launcher.cc
+++ b/content/public/test/test_launcher.cc
@@ -508,8 +508,7 @@
   // parsing failed.
   if (have_test_results && !parsed_results.empty()) {
     // We expect only one test result here.
-    DCHECK_EQ(1U, parsed_results.size())
-        << "Unexpectedly ran test more than once: " << test_name;
+    DCHECK_EQ(1U, parsed_results.size());
     DCHECK_EQ(test_name, parsed_results.front().full_name);
 
     result = parsed_results.front();
diff --git a/content/renderer/java/gin_java_bridge_value_converter_unittest.cc b/content/renderer/java/gin_java_bridge_value_converter_unittest.cc
index 9e637b1..ef8e48d 100644
--- a/content/renderer/java/gin_java_bridge_value_converter_unittest.cc
+++ b/content/renderer/java/gin_java_bridge_value_converter_unittest.cc
@@ -9,7 +9,7 @@
 #include <cmath>
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "content/common/android/gin_java_bridge_value.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -118,7 +118,7 @@
     "4", "Int32Array", "4", "Uint32Array",
     "4", "Float32Array", "8", "Float64Array"
   };
-  for (size_t i = 0; i < arraysize(array_types); i += 2) {
+  for (size_t i = 0; i < base::size(array_types); i += 2) {
     const char* typed_array_type = array_types[i + 1];
     v8::Local<v8::Script> script(
         v8::Script::Compile(
diff --git a/content/renderer/loader/shared_memory_data_consumer_handle_unittest.cc b/content/renderer/loader/shared_memory_data_consumer_handle_unittest.cc
index bca355a..0a99ca6a 100644
--- a/content/renderer/loader/shared_memory_data_consumer_handle_unittest.cc
+++ b/content/renderer/loader/shared_memory_data_consumer_handle_unittest.cc
@@ -14,9 +14,9 @@
 #include "base/bind.h"
 #include "base/callback.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/task_runner.h"
 #include "base/test/scoped_task_environment.h"
@@ -379,31 +379,31 @@
 
   auto reader = handle_->ObtainReader(
       nullptr, blink::scheduler::GetSingleThreadTaskRunnerForTesting());
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 6, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(6u, read);
   EXPECT_STREQ("Once u", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 2, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(2u, read);
   EXPECT_STREQ("po", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 9, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(9u, read);
   EXPECT_STREQ("n a time ", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 3, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(3u, read);
   EXPECT_STREQ("the", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 20, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(9u, read);
@@ -424,19 +424,19 @@
 
   auto reader = handle_->ObtainReader(
       nullptr, blink::scheduler::GetSingleThreadTaskRunnerForTesting());
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 6, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(6u, read);
   EXPECT_STREQ("Once u", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 2, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(2u, read);
   EXPECT_STREQ("po", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 9, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(2u, read);
@@ -444,7 +444,7 @@
 
   writer_->AddData(NewFixedData("a "));
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 1, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(1u, read);
@@ -456,13 +456,13 @@
   writer_->AddData(NewFixedData("a "));
   writer_->Close();
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 9, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(9u, read);
   EXPECT_STREQ(" time the", buffer);
 
-  std::fill(&buffer[0], &buffer[arraysize(buffer)], 0);
+  std::fill(&buffer[0], &buffer[base::size(buffer)], 0);
   result = reader->Read(buffer, 20, kNone, &read);
   EXPECT_EQ(kOk, result);
   EXPECT_EQ(9u, read);
diff --git a/content/renderer/loader/web_url_loader_impl_unittest.cc b/content/renderer/loader/web_url_loader_impl_unittest.cc
index 0af9e414..56184d4 100644
--- a/content/renderer/loader/web_url_loader_impl_unittest.cc
+++ b/content/renderer/loader/web_url_loader_impl_unittest.cc
@@ -11,10 +11,10 @@
 #include <vector>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/time/default_tick_clock.h"
 #include "base/time/time.h"
@@ -364,9 +364,9 @@
   void DoCompleteRequest() {
     EXPECT_FALSE(client()->did_finish());
     network::URLLoaderCompletionStatus status(net::OK);
-    status.encoded_data_length = arraysize(kTestData);
-    status.encoded_body_length = arraysize(kTestData);
-    status.decoded_body_length = arraysize(kTestData);
+    status.encoded_data_length = base::size(kTestData);
+    status.encoded_body_length = base::size(kTestData);
+    status.decoded_body_length = base::size(kTestData);
     peer()->OnCompletedRequest(status);
     EXPECT_TRUE(client()->did_finish());
     // There should be no error.
@@ -376,9 +376,9 @@
   void DoFailRequest() {
     EXPECT_FALSE(client()->did_finish());
     network::URLLoaderCompletionStatus status(net::ERR_FAILED);
-    status.encoded_data_length = arraysize(kTestData);
-    status.encoded_body_length = arraysize(kTestData);
-    status.decoded_body_length = arraysize(kTestData);
+    status.encoded_data_length = base::size(kTestData);
+    status.encoded_body_length = base::size(kTestData);
+    status.decoded_body_length = base::size(kTestData);
     peer()->OnCompletedRequest(status);
     EXPECT_FALSE(client()->did_finish());
     ASSERT_TRUE(client()->error());
diff --git a/content/renderer/media/stream/media_stream_audio_processor_unittest.cc b/content/renderer/media/stream/media_stream_audio_processor_unittest.cc
index 7260cac..ea10f58 100644
--- a/content/renderer/media/stream/media_stream_audio_processor_unittest.cc
+++ b/content/renderer/media/stream/media_stream_audio_processor_unittest.cc
@@ -12,10 +12,10 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/aligned_memory.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -250,7 +250,7 @@
 
   static const int kSupportedSampleRates[] =
       { 8000, 16000, 22050, 32000, 44100, 48000 };
-  for (size_t i = 0; i < arraysize(kSupportedSampleRates); ++i) {
+  for (size_t i = 0; i < base::size(kSupportedSampleRates); ++i) {
     int buffer_size = kSupportedSampleRates[i] / 100;
     media::AudioParameters params(media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
                                   media::CHANNEL_LAYOUT_STEREO,
diff --git a/content/renderer/media/stream/media_stream_constraints_util_video_content_unittest.cc b/content/renderer/media/stream/media_stream_constraints_util_video_content_unittest.cc
index 32b5f5d..a4ad815 100644
--- a/content/renderer/media/stream/media_stream_constraints_util_video_content_unittest.cc
+++ b/content/renderer/media/stream/media_stream_constraints_util_video_content_unittest.cc
@@ -7,6 +7,7 @@
 #include <cmath>
 #include <string>
 
+#include "base/stl_util.h"
 #include "content/renderer/media/stream/media_stream_source.h"
 #include "content/renderer/media/stream/mock_constraint_factory.h"
 #include "media/base/limits.h"
@@ -2020,13 +2021,13 @@
   blink::WebString id_vector1[] = {blink::WebString::FromASCII(kDeviceID1),
                                    blink::WebString::FromASCII(kDeviceID2)};
   advanced1.device_id.SetExact(
-      blink::WebVector<blink::WebString>(id_vector1, arraysize(id_vector1)));
+      blink::WebVector<blink::WebString>(id_vector1, base::size(id_vector1)));
   blink::WebString id_vector2[] = {blink::WebString::FromASCII(kDeviceID2),
                                    blink::WebString::FromASCII(kDeviceID3)};
   blink::WebMediaTrackConstraintSet& advanced2 =
       constraint_factory_.AddAdvanced();
   advanced2.device_id.SetExact(
-      blink::WebVector<blink::WebString>(id_vector2, arraysize(id_vector2)));
+      blink::WebVector<blink::WebString>(id_vector2, base::size(id_vector2)));
   auto result = SelectSettings();
   EXPECT_TRUE(result.HasValue());
   // kDeviceID2 must be selected because it is the only one that satisfies both
@@ -2047,13 +2048,13 @@
   blink::WebString id_vector1[] = {blink::WebString::FromASCII(kDeviceID1),
                                    blink::WebString::FromASCII(kDeviceID2)};
   advanced1.device_id.SetExact(
-      blink::WebVector<blink::WebString>(id_vector1, arraysize(id_vector1)));
+      blink::WebVector<blink::WebString>(id_vector1, base::size(id_vector1)));
   blink::WebString id_vector2[] = {blink::WebString::FromASCII(kDeviceID3),
                                    blink::WebString::FromASCII(kDeviceID4)};
   blink::WebMediaTrackConstraintSet& advanced2 =
       constraint_factory_.AddAdvanced();
   advanced2.device_id.SetExact(
-      blink::WebVector<blink::WebString>(id_vector2, arraysize(id_vector2)));
+      blink::WebVector<blink::WebString>(id_vector2, base::size(id_vector2)));
   auto result = SelectSettings();
   EXPECT_TRUE(result.HasValue());
   // The second advanced set must be ignored because it contradicts the first
@@ -2072,12 +2073,12 @@
   blink::WebString id_vector1[] = {blink::WebString::FromASCII(kDeviceID1),
                                    blink::WebString::FromASCII(kDeviceID2)};
   advanced.device_id.SetExact(
-      blink::WebVector<blink::WebString>(id_vector1, arraysize(id_vector1)));
+      blink::WebVector<blink::WebString>(id_vector1, base::size(id_vector1)));
 
   blink::WebString id_vector2[] = {blink::WebString::FromASCII(kDeviceID2),
                                    blink::WebString::FromASCII(kDeviceID3)};
   constraint_factory_.basic().device_id.SetIdeal(
-      blink::WebVector<blink::WebString>(id_vector2, arraysize(id_vector2)));
+      blink::WebVector<blink::WebString>(id_vector2, base::size(id_vector2)));
   auto result = SelectSettings();
   EXPECT_TRUE(result.HasValue());
   // Should select kDeviceID2, which appears in ideal and satisfies the advanced
diff --git a/content/renderer/media/stream/webmediaplayer_ms_unittest.cc b/content/renderer/media/stream/webmediaplayer_ms_unittest.cc
index 75c5d37..89d89ec 100644
--- a/content/renderer/media/stream/webmediaplayer_ms_unittest.cc
+++ b/content/renderer/media/stream/webmediaplayer_ms_unittest.cc
@@ -10,6 +10,7 @@
 #include "base/containers/circular_deque.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
@@ -1119,7 +1120,7 @@
 
   // Change rotation.
   tokens[0] = 33;
-  timestamps = std::vector<int>(tokens, tokens + arraysize(tokens));
+  timestamps = std::vector<int>(tokens, tokens + base::size(tokens));
   provider->QueueFrames(timestamps, false, false, 17, media::VIDEO_ROTATION_0);
   if (enable_surface_layer_for_video_) {
     EXPECT_CALL(*submitter_ptr_, SetRotation(media::VIDEO_ROTATION_0));
@@ -1153,7 +1154,7 @@
   // Push one opaque frame.
   const int kTestBrake = static_cast<int>(FrameType::TEST_BRAKE);
   int tokens[] = {0, kTestBrake};
-  std::vector<int> timestamps(tokens, tokens + arraysize(tokens));
+  std::vector<int> timestamps(tokens, tokens + base::size(tokens));
   provider->QueueFrames(timestamps, true);
 
   if (enable_surface_layer_for_video_) {
@@ -1181,7 +1182,7 @@
 
   // Push one transparent frame.
   tokens[0] = 33;
-  timestamps = std::vector<int>(tokens, tokens + arraysize(tokens));
+  timestamps = std::vector<int>(tokens, tokens + base::size(tokens));
   provider->QueueFrames(timestamps, false);
   if (enable_surface_layer_for_video_) {
     EXPECT_CALL(*surface_layer_bridge_ptr_, SetContentsOpaque(false));
@@ -1196,7 +1197,7 @@
 
   // Push another transparent frame.
   tokens[0] = 66;
-  timestamps = std::vector<int>(tokens, tokens + arraysize(tokens));
+  timestamps = std::vector<int>(tokens, tokens + base::size(tokens));
   provider->QueueFrames(timestamps, true);
   if (enable_surface_layer_for_video_) {
     EXPECT_CALL(*surface_layer_bridge_ptr_, SetContentsOpaque(true));
diff --git a/content/renderer/media/webrtc/rtc_video_encoder.cc b/content/renderer/media/webrtc/rtc_video_encoder.cc
index c127936a..f3e50c9 100644
--- a/content/renderer/media/webrtc/rtc_video_encoder.cc
+++ b/content/renderer/media/webrtc/rtc_video_encoder.cc
@@ -14,10 +14,10 @@
 #include "base/containers/circular_deque.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/synchronization/lock.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/threading/thread_checker.h"
@@ -611,7 +611,7 @@
   static const char* const kErrorNames[] = {
       "kIllegalStateError", "kInvalidArgumentError", "kPlatformFailureError"};
   static_assert(
-      arraysize(kErrorNames) == media::VideoEncodeAccelerator::kErrorMax + 1,
+      base::size(kErrorNames) == media::VideoEncodeAccelerator::kErrorMax + 1,
       "Different number of errors and textual descriptions");
   DLOG(ERROR) << location.ToString() << kErrorNames[error] << " - " << str;
   NotifyError(error);
diff --git a/content/renderer/media/webrtc/stun_field_trial.cc b/content/renderer/media/webrtc/stun_field_trial.cc
index b7d064c6..4f810949 100644
--- a/content/renderer/media/webrtc/stun_field_trial.cc
+++ b/content/renderer/media/webrtc/stun_field_trial.cc
@@ -9,9 +9,9 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/strings/stringprintf.h"
@@ -42,7 +42,7 @@
 // This needs to match "NatType" in histograms.xml.
 const char* const NatTypeNames[] =
     {"NoNAT", "UnknownNAT", "SymNAT", "NonSymNAT"};
-static_assert(arraysize(NatTypeNames) == NAT_TYPE_MAX,
+static_assert(base::size(NatTypeNames) == NAT_TYPE_MAX,
               "NatType enums must match names");
 
 NatType GetNatType(stunprober::NatType nat_type) {
diff --git a/content/renderer/media_recorder/media_recorder_handler.cc b/content/renderer/media_recorder/media_recorder_handler.cc
index b6b1fb0..391d638 100644
--- a/content/renderer/media_recorder/media_recorder_handler.cc
+++ b/content/renderer/media_recorder/media_recorder_handler.cc
@@ -9,7 +9,7 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_tokenizer.h"
 #include "base/strings/string_util.h"
 #include "base/system/sys_info.h"
@@ -166,7 +166,7 @@
   static const char* const kAudioCodecs[] = {"opus", "pcm"};
   const char* const* codecs = video ? &kVideoCodecs[0] : &kAudioCodecs[0];
   const int codecs_count =
-      video ? arraysize(kVideoCodecs) : arraysize(kAudioCodecs);
+      video ? base::size(kVideoCodecs) : base::size(kAudioCodecs);
 
   std::vector<std::string> codecs_list;
   media::SplitCodecs(web_codecs.Utf8(), &codecs_list);
diff --git a/content/renderer/media_recorder/video_track_recorder.cc b/content/renderer/media_recorder/video_track_recorder.cc
index ef28d3170..bb709679 100644
--- a/content/renderer/media_recorder/video_track_recorder.cc
+++ b/content/renderer/media_recorder/video_track_recorder.cc
@@ -8,8 +8,8 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/task_runner_util.h"
 #include "base/threading/thread.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -71,7 +71,7 @@
 #endif
 };
 
-static_assert(arraysize(kPreferredCodecIdAndVEAProfiles) ==
+static_assert(base::size(kPreferredCodecIdAndVEAProfiles) ==
                   static_cast<int>(CodecId::LAST),
               "|kPreferredCodecIdAndVEAProfiles| should consider all CodecIds");
 
diff --git a/content/renderer/notifications/notification_data_conversions_unittest.cc b/content/renderer/notifications/notification_data_conversions_unittest.cc
index 33636ba..d1e90ce 100644
--- a/content/renderer/notifications/notification_data_conversions_unittest.cc
+++ b/content/renderer/notifications/notification_data_conversions_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -39,10 +39,11 @@
 TEST(NotificationDataConversionsTest, ToWebNotificationData) {
   std::vector<int> vibration_pattern(
       kNotificationVibrationPattern,
-      kNotificationVibrationPattern + arraysize(kNotificationVibrationPattern));
+      kNotificationVibrationPattern +
+          base::size(kNotificationVibrationPattern));
 
   std::vector<char> developer_data(
-      kNotificationData, kNotificationData + arraysize(kNotificationData));
+      kNotificationData, kNotificationData + base::size(kNotificationData));
 
   blink::PlatformNotificationData platform_data;
   platform_data.title = base::ASCIIToUTF16(kNotificationTitle);
diff --git a/content/renderer/p2p/filtering_network_manager_unittest.cc b/content/renderer/p2p/filtering_network_manager_unittest.cc
index 7bd8e49..bdeaef60 100644
--- a/content/renderer/p2p/filtering_network_manager_unittest.cc
+++ b/content/renderer/p2p/filtering_network_manager_unittest.cc
@@ -10,8 +10,8 @@
 #include <utility>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/test/test_simple_task_runner.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/renderer/p2p/empty_network_manager.h"
@@ -233,7 +233,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 // Test that multiple routes request is blocked and signaled right after
@@ -259,7 +259,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 // Test that multiple routes request is blocked and signaled right after
@@ -281,7 +281,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 // Test that after permissions have been denied, a network change signal from
@@ -302,7 +302,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 // Test that multiple routes request is granted and signaled right after
@@ -329,7 +329,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 // Test that multiple routes request is granted and signaled right after
@@ -352,7 +352,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 // Test that multiple routes request is granted and signaled right after
@@ -376,7 +376,7 @@
       {MOCK_NETWORKS_CHANGED, NO_SIGNAL},
   };
 
-  RunTests(tests, arraysize(tests));
+  RunTests(tests, base::size(tests));
 }
 
 }  // namespace content
diff --git a/content/renderer/pepper/pepper_audio_encoder_host.cc b/content/renderer/pepper/pepper_audio_encoder_host.cc
index 7a740801..bede139 100644
--- a/content/renderer/pepper/pepper_audio_encoder_host.cc
+++ b/content/renderer/pepper/pepper_audio_encoder_host.cc
@@ -8,8 +8,8 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
+#include "base/stl_util.h"
 #include "content/public/renderer/renderer_ppapi_host.h"
 #include "content/renderer/pepper/host_globals.h"
 #include "content/renderer/render_thread_impl.h"
@@ -93,7 +93,7 @@
   std::vector<PP_AudioProfileDescription> profiles;
   static const uint32_t sampling_rates[] = {8000, 12000, 16000, 24000, 48000};
 
-  for (uint32_t i = 0; i < arraysize(sampling_rates); ++i) {
+  for (uint32_t i = 0; i < base::size(sampling_rates); ++i) {
     PP_AudioProfileDescription profile;
     profile.profile = PP_AUDIOPROFILE_OPUS;
     profile.max_channels = 2;
diff --git a/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc b/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc
index c2d365a..340dbc5 100644
--- a/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc
+++ b/content/renderer/pepper/pepper_graphics_2d_host_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "content/renderer/pepper/gfx_conversion.h"
 #include "content/renderer/pepper/mock_renderer_ppapi_host.h"
@@ -136,7 +136,7 @@
                // Check negative scroll deltas
                {10, 10, 20, 20, 5, 5, 10, 10, -6, -4, -3, -2, 0.5, true},
                {10, 10, 20, 20, 5, 5, 10, 10, -6, -3, -3, -1, 0.5, false}, };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     gfx::Rect r1(tests[i].x1, tests[i].y1, tests[i].w1, tests[i].h1);
     gfx::Rect r2(tests[i].x2, tests[i].y2, tests[i].w2, tests[i].h2);
     gfx::Rect orig = r1;
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc
index b84b6ca..9eb54432 100644
--- a/content/renderer/render_frame_impl_browsertest.cc
+++ b/content/renderer/render_frame_impl_browsertest.cc
@@ -11,6 +11,7 @@
 #include "base/command_line.h"
 #include "base/debug/leak_annotations.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/bind_test_util.h"
 #include "base/test/gtest_util.h"
@@ -326,7 +327,7 @@
                {blink::WebEffectiveConnectionType::kType2G},
                {blink::WebEffectiveConnectionType::kType4G}};
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     SetEffectionConnectionType(GetMainRenderFrame(), tests[i].type);
     SetEffectionConnectionType(frame(), tests[i].type);
 
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 6f75ddd..0d63fca 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -12,9 +12,9 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -155,7 +155,7 @@
     { MockKeyboard::RIGHT_ALT, ui::EF_ALT_DOWN },
   };
   int flags = 0;
-  for (size_t i = 0; i < arraysize(kModifierMap); ++i) {
+  for (size_t i = 0; i < base::size(kModifierMap); ++i) {
     if (kModifierMap[i].src & modifiers) {
       flags |= kModifierMap[i].dst;
     }
@@ -594,7 +594,7 @@
 
   // Set up post data.
   const char raw_data[] = "post \0\ndata";
-  const size_t length = arraysize(raw_data);
+  const size_t length = base::size(raw_data);
   scoped_refptr<network::ResourceRequestBody> post_data(
       new network::ResourceRequestBody);
   post_data->AppendBytes(raw_data, length);
@@ -727,7 +727,7 @@
       blink::kWebNavigationTypeOther,
   };
 
-  for (size_t i = 0; i < arraysize(kNavTypes); ++i) {
+  for (size_t i = 0; i < base::size(kNavTypes); ++i) {
     auto navigation_info = std::make_unique<blink::WebNavigationInfo>();
     navigation_info->url_request = blink::WebURLRequest(GURL("http://foo.com"));
     navigation_info->url_request.SetRequestorOrigin(
@@ -1287,7 +1287,7 @@
     input_mode = p.mode;
     EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type);
 
-    for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) {
+    for (size_t i = 0; i < base::size(kInputModeTestCases); i++) {
       const InputModeTestCase* test_case = &kInputModeTestCases[i];
       std::string javascript =
           base::StringPrintf("document.getElementById('%s').focus();",
@@ -1387,7 +1387,7 @@
       {IME_FINISHCOMPOSINGTEXT, false, -1, -1, L"", L"\xC548\xB155"},
   };
 
-  for (size_t i = 0; i < arraysize(kImeMessages); i++) {
+  for (size_t i = 0; i < base::size(kImeMessages); i++) {
     const ImeMessage* ime_message = &kImeMessages[i];
     switch (ime_message->command) {
       case IME_INITIALIZE:
@@ -1479,7 +1479,7 @@
       {blink::kWebTextDirectionRightToLeft, L"rtl,rtl"},
       {blink::kWebTextDirectionLeftToRight, L"ltr,ltr"},
   };
-  for (size_t i = 0; i < arraysize(kTextDirection); ++i) {
+  for (size_t i = 0; i < base::size(kTextDirection); ++i) {
     // Set the text direction of the <textarea> element.
     ExecuteJavaScriptForTests("document.getElementById('test').focus();");
     ReceiveSetTextDirection(view()->GetWidget(), kTextDirection[i].direction);
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
index d6c313f..e03509393 100644
--- a/content/renderer/renderer_blink_platform_impl.cc
+++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -393,7 +393,7 @@
     blink::mojom::CodeCacheType cache_type,
     const blink::WebURL& url,
     base::Time response_time,
-    const char* data,
+    const uint8_t* data,
     size_t size) {
   // Only cache WebAssembly if we have isolated code caches.
   // TODO(bbudge) Remove this check when isolated code caches are on by default.
@@ -425,7 +425,7 @@
 void RendererBlinkPlatformImpl::CacheMetadataInCacheStorage(
     const blink::WebURL& url,
     base::Time response_time,
-    const char* data,
+    const uint8_t* data,
     size_t size,
     const blink::WebSecurityOrigin& cacheStorageOrigin,
     const blink::WebString& cacheStorageCacheName) {
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
index 49a961a..0052cff0 100644
--- a/content/renderer/renderer_blink_platform_impl.h
+++ b/content/renderer/renderer_blink_platform_impl.h
@@ -85,7 +85,7 @@
   void CacheMetadata(blink::mojom::CodeCacheType cache_type,
                      const blink::WebURL&,
                      base::Time,
-                     const char*,
+                     const uint8_t*,
                      size_t) override;
   void FetchCachedCode(
       blink::mojom::CodeCacheType cache_type,
@@ -97,7 +97,7 @@
   void CacheMetadataInCacheStorage(
       const blink::WebURL&,
       base::Time,
-      const char*,
+      const uint8_t*,
       size_t,
       const blink::WebSecurityOrigin& cacheStorageOrigin,
       const blink::WebString& cacheStorageCacheName) override;
diff --git a/content/renderer/v8_value_converter_impl_unittest.cc b/content/renderer/v8_value_converter_impl_unittest.cc
index 6c1b42b..124078b 100644
--- a/content/renderer/v8_value_converter_impl_unittest.cc
+++ b/content/renderer/v8_value_converter_impl_unittest.cc
@@ -276,7 +276,7 @@
   ASSERT_FALSE(v8_object.IsEmpty());
 
   EXPECT_EQ(static_cast<const base::DictionaryValue&>(*original_root).size(),
-            v8_object->GetPropertyNames()->Length());
+            v8_object->GetPropertyNames(context).ToLocalChecked()->Length());
   EXPECT_TRUE(v8_object
                   ->Get(v8::String::NewFromUtf8(
                             isolate_, "null", v8::NewStringType::kInternalized)
@@ -418,7 +418,7 @@
   v8::Local<v8::Object> copy =
       converter.ToV8Value(converted.get(), context).As<v8::Object>();
   EXPECT_FALSE(copy.IsEmpty());
-  EXPECT_EQ(2u, copy->GetPropertyNames()->Length());
+  EXPECT_EQ(2u, copy->GetPropertyNames(context).ToLocalChecked()->Length());
   EXPECT_EQ("foo", GetString(copy, "foo"));
   EXPECT_EQ("bar", GetString(copy, "bar"));
 }
@@ -560,7 +560,8 @@
   EXPECT_EQ(1, GetInt(result, "getters"));
   EXPECT_EQ(1, GetInt(result, "setters"));
 
-  EXPECT_EQ(1u, converted->GetPropertyNames()->Length());
+  EXPECT_EQ(1u,
+            converted->GetPropertyNames(context).ToLocalChecked()->Length());
   EXPECT_EQ("good value", GetString(converted, "foo"));
 
   // Getters/setters shouldn't be triggered while accessing existing values.
@@ -578,7 +579,8 @@
   EXPECT_EQ(1, GetInt(result, "getters"));
   EXPECT_EQ(1, GetInt(result, "setters"));
 
-  EXPECT_EQ(1u, converted2->GetPropertyNames()->Length());
+  EXPECT_EQ(1u,
+            converted2->GetPropertyNames(context).ToLocalChecked()->Length());
   EXPECT_EQ("hello", GetString(converted2, "otherkey"));
 
   // Missing key = should trigger getter upon access.
diff --git a/content/shell/app/blink_test_platform_support_win.cc b/content/shell/app/blink_test_platform_support_win.cc
index 0252431..22d3e5c3 100644
--- a/content/shell/app/blink_test_platform_support_win.cc
+++ b/content/shell/app/blink_test_platform_support_win.cc
@@ -14,8 +14,8 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/gfx/win/direct_write.h"
 
@@ -59,7 +59,7 @@
       {&metrics.lfStatusFont, &metrics.lfMenuFont, &metrics.lfSmCaptionFont};
   const wchar_t required_font[] = L"Segoe UI";
   int required_font_size = -12;
-  for (size_t i = 0; i < arraysize(system_fonts); ++i) {
+  for (size_t i = 0; i < base::size(system_fonts); ++i) {
     if (system_fonts[i]->lfHeight != required_font_size ||
         wcscmp(required_font, system_fonts[i]->lfFaceName)) {
       errors.push_back("Must use either the Aero or Basic theme.");
diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc
index a1647a127..02225da 100644
--- a/content/shell/browser/shell_content_browser_client.cc
+++ b/content/shell/browser/shell_content_browser_client.cc
@@ -13,8 +13,8 @@
 #include "base/files/file.h"
 #include "base/files/file_util.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "content/public/browser/client_certificate_delegate.h"
@@ -182,7 +182,7 @@
       url::kDataScheme,
       url::kFileScheme,
   };
-  for (size_t i = 0; i < arraysize(kProtocolList); ++i) {
+  for (size_t i = 0; i < base::size(kProtocolList); ++i) {
     if (url.scheme() == kProtocolList[i])
       return true;
   }
diff --git a/content/shell/browser/shell_download_manager_delegate.cc b/content/shell/browser/shell_download_manager_delegate.cc
index 65731c2..2ca93dab 100644
--- a/content/shell/browser/shell_download_manager_delegate.cc
+++ b/content/shell/browser/shell_download_manager_delegate.cc
@@ -15,7 +15,7 @@
 #include "base/command_line.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/task/post_task.h"
@@ -165,7 +165,7 @@
 #if defined(OS_WIN)
   std::wstring file_part = base::FilePath(suggested_path).BaseName().value();
   wchar_t file_name[MAX_PATH];
-  base::wcslcpy(file_name, file_part.c_str(), arraysize(file_name));
+  base::wcslcpy(file_name, file_part.c_str(), base::size(file_name));
   OPENFILENAME save_as;
   ZeroMemory(&save_as, sizeof(save_as));
   save_as.lStructSize = sizeof(OPENFILENAME);
@@ -174,7 +174,7 @@
                           ->GetHost()
                           ->GetAcceleratedWidget();
   save_as.lpstrFile = file_name;
-  save_as.nMaxFile = arraysize(file_name);
+  save_as.nMaxFile = base::size(file_name);
 
   std::wstring directory;
   if (!suggested_path.empty())
diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc
index ef4da07..cb407fb8 100644
--- a/content/shell/browser/shell_views.cc
+++ b/content/shell/browser/shell_views.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "content/public/browser/context_factory.h"
@@ -209,7 +209,7 @@
     static const ui::KeyboardCode keys[] = { ui::VKEY_F5,
                                              ui::VKEY_BROWSER_BACK,
                                              ui::VKEY_BROWSER_FORWARD };
-    for (size_t i = 0; i < arraysize(keys); ++i) {
+    for (size_t i = 0; i < base::size(keys); ++i) {
       GetFocusManager()->RegisterAccelerator(
         ui::Accelerator(keys[i], ui::EF_NONE),
         ui::AcceleratorManager::kNormalPriority,
diff --git a/content/shell/browser/web_test/web_test_push_messaging_service.cc b/content/shell/browser/web_test/web_test_push_messaging_service.cc
index 1c5e704..4d7cb1d 100644
--- a/content/shell/browser/web_test/web_test_push_messaging_service.cc
+++ b/content/shell/browser/web_test/web_test_push_messaging_service.cc
@@ -6,7 +6,7 @@
 
 #include "base/callback.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/common/service_worker/service_worker_types.h"
 #include "content/public/browser/permission_type.h"
 #include "content/public/common/push_messaging_status.mojom.h"
@@ -83,9 +83,9 @@
 
   if (permission_status == blink::mojom::PermissionStatus::GRANTED) {
     std::vector<uint8_t> p256dh(kTestP256Key,
-                                kTestP256Key + arraysize(kTestP256Key));
+                                kTestP256Key + base::size(kTestP256Key));
     std::vector<uint8_t> auth(kAuthentication,
-                              kAuthentication + arraysize(kAuthentication));
+                              kAuthentication + base::size(kAuthentication));
 
     subscribed_service_worker_registration_ = service_worker_registration_id;
     callback.Run("layoutTestRegistrationId", p256dh, auth,
@@ -104,9 +104,9 @@
     const std::string& subscription_id,
     const SubscriptionInfoCallback& callback) {
   std::vector<uint8_t> p256dh(kTestP256Key,
-                              kTestP256Key + arraysize(kTestP256Key));
+                              kTestP256Key + base::size(kTestP256Key));
   std::vector<uint8_t> auth(kAuthentication,
-                            kAuthentication + arraysize(kAuthentication));
+                            kAuthentication + base::size(kAuthentication));
 
   callback.Run(true /* is_valid */, p256dh, auth);
 }
diff --git a/content/shell/common/shell_origin_trial_policy.cc b/content/shell/common/shell_origin_trial_policy.cc
index b6e31223..64b20eb 100644
--- a/content/shell/common/shell_origin_trial_policy.cc
+++ b/content/shell/common/shell_origin_trial_policy.cc
@@ -5,6 +5,7 @@
 #include "content/shell/common/shell_origin_trial_policy.h"
 
 #include "base/feature_list.h"
+#include "base/stl_util.h"
 #include "content/public/common/content_features.h"
 #include "content/public/common/origin_util.h"
 
@@ -27,7 +28,7 @@
 ShellOriginTrialPolicy::ShellOriginTrialPolicy()
     : public_key_(base::StringPiece(
           reinterpret_cast<const char*>(kOriginTrialPublicKey),
-          arraysize(kOriginTrialPublicKey))) {}
+          base::size(kOriginTrialPublicKey))) {}
 
 ShellOriginTrialPolicy::~ShellOriginTrialPolicy() {}
 
diff --git a/content/shell/test_runner/accessibility_controller.cc b/content/shell/test_runner/accessibility_controller.cc
index 2c2c0fb..146b573 100644
--- a/content/shell/test_runner/accessibility_controller.cc
+++ b/content/shell/test_runner/accessibility_controller.cc
@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/shell/test_runner/web_view_test_proxy.h"
 #include "gin/handle.h"
 #include "gin/object_template_builder.h"
@@ -199,7 +199,7 @@
   };
   local_frame->CallFunctionEvenIfScriptDisabled(
       v8::Local<v8::Function>::New(isolate, notification_callback_),
-      context->Global(), arraysize(argv), argv);
+      context->Global(), base::size(argv), argv);
 }
 
 void AccessibilityController::LogAccessibilityEvents() {
diff --git a/content/shell/test_runner/mock_grammar_check.cc b/content/shell/test_runner/mock_grammar_check.cc
index a3971ef..83c1def 100644
--- a/content/shell/test_runner/mock_grammar_check.cc
+++ b/content/shell/test_runner/mock_grammar_check.cc
@@ -9,7 +9,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/shell/test_runner/test_common.h"
 #include "third_party/blink/public/platform/web_string.h"
 #include "third_party/blink/public/web/web_text_checking_result.h"
@@ -46,7 +46,7 @@
       {"the the adlj adaasj sdklj. there there", 33, 5},
       {"zz apple orange.", 0, 16},
   };
-  for (size_t i = 0; i < arraysize(kGrammarErrors); ++i) {
+  for (size_t i = 0; i < base::size(kGrammarErrors); ++i) {
     size_t offset = 0;
     base::string16 error(
         kGrammarErrors[i].text,
diff --git a/content/shell/test_runner/mock_spell_check.cc b/content/shell/test_runner/mock_spell_check.cc
index cfd7242a..db07974 100644
--- a/content/shell/test_runner/mock_spell_check.cc
+++ b/content/shell/test_runner/mock_spell_check.cc
@@ -9,7 +9,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/shell/test_runner/test_common.h"
 
 namespace test_runner {
@@ -158,7 +158,7 @@
       "ifmmp", "qwertyuiopasd", "qwertyuiopasdf", "upper case", "wellcome"};
 
   misspelled_words_.clear();
-  for (size_t i = 0; i < arraysize(misspelled_words); ++i)
+  for (size_t i = 0; i < base::size(misspelled_words); ++i)
     misspelled_words_.push_back(
         base::string16(misspelled_words[i],
                        misspelled_words[i] + strlen(misspelled_words[i])));
diff --git a/content/shell/test_runner/test_runner_for_specific_view.cc b/content/shell/test_runner/test_runner_for_specific_view.cc
index 8d34f2d..e01f88e 100644
--- a/content/shell/test_runner/test_runner_for_specific_view.cc
+++ b/content/shell/test_runner/test_runner_for_specific_view.cc
@@ -11,7 +11,7 @@
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "build/build_config.h"
 #include "cc/paint/paint_canvas.h"
@@ -290,7 +290,7 @@
   argv[2] = blink::WebArrayBufferConverter::ToV8Value(
       &buffer, context->Global(), isolate);
 
-  PostV8CallbackWithArgs(std::move(callback), arraysize(argv), argv);
+  PostV8CallbackWithArgs(std::move(callback), base::size(argv), argv);
 }
 
 void TestRunnerForSpecificView::CopyImageAtAndCapturePixelsAsyncThen(
diff --git a/content/shell/test_runner/web_ax_object_proxy.cc b/content/shell/test_runner/web_ax_object_proxy.cc
index 695b6b66..2860354 100644
--- a/content/shell/test_runner/web_ax_object_proxy.cc
+++ b/content/shell/test_runner/web_ax_object_proxy.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "gin/handle.h"
 #include "third_party/blink/public/platform/web_float_rect.h"
@@ -851,7 +851,7 @@
   };
   frame->CallFunctionEvenIfScriptDisabled(
       v8::Local<v8::Function>::New(isolate, notification_callback_),
-      context->Global(), arraysize(argv), argv);
+      context->Global(), base::size(argv), argv);
 }
 
 void WebAXObjectProxy::Reset() {
diff --git a/content/test/data/accessibility/aria/aria-readonly-expected-android.txt b/content/test/data/accessibility/aria/aria-readonly-expected-android.txt
index 27823ed..c98b338 100644
--- a/content/test/data/accessibility/aria/aria-readonly-expected-android.txt
+++ b/content/test/data/accessibility/aria/aria-readonly-expected-android.txt
@@ -5,8 +5,8 @@
 ++++android.widget.EditText clickable editable_text focusable has_non_empty_value name='Readonly-true input' input_type=1 text_change_added_count=19
 ++android.view.View clickable focusable name='Readonly-false plain div'
 ++android.view.View clickable focusable name='Readonly-true plain div'
-++android.view.View clickable editable_text focusable multiline hint='Readonly-false contenteditable div'
-++android.view.View clickable editable_text focusable multiline hint='Readonly-true contenteditable div'
+++android.widget.EditText clickable editable_text focusable multiline hint='Readonly-false contenteditable div'
+++android.widget.EditText clickable editable_text focusable multiline hint='Readonly-true contenteditable div'
 ++android.widget.EditText clickable editable_text focusable hint='Readonly-false role unimplemented textbox'
 ++android.widget.EditText clickable editable_text focusable hint='Readonly-true role unimplemented textbox'
 ++android.widget.EditText clickable editable_text focusable hint='Readonly-false contenteditable textbox'
diff --git a/content/test/data/accessibility/html/contenteditable-with-no-descendants-expected-android.txt b/content/test/data/accessibility/html/contenteditable-with-no-descendants-expected-android.txt
index 60dbe26c..46b7dc8 100644
--- a/content/test/data/accessibility/html/contenteditable-with-no-descendants-expected-android.txt
+++ b/content/test/data/accessibility/html/contenteditable-with-no-descendants-expected-android.txt
@@ -1,5 +1,5 @@
 android.webkit.WebView focusable focused scrollable
-++android.view.View clickable editable_text focusable multiline hint='label'
-++android.view.View clickable editable_text focusable multiline hint='description'
-++android.view.View clickable editable_text focusable multiline hint='title'
+++android.widget.EditText clickable editable_text focusable multiline hint='label'
+++android.widget.EditText clickable editable_text focusable multiline hint='description'
+++android.widget.EditText clickable editable_text focusable multiline hint='title'
 ++android.view.View name='description'
\ No newline at end of file
diff --git a/content/test/mock_keyboard_driver_win.cc b/content/test/mock_keyboard_driver_win.cc
index 363a3d1..a2f6b7d 100644
--- a/content/test/mock_keyboard_driver_win.cc
+++ b/content/test/mock_keyboard_driver_win.cc
@@ -8,7 +8,7 @@
 #include <string.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/test/mock_keyboard.h"
 
 namespace content {
@@ -103,7 +103,7 @@
     {L"00001009", MockKeyboard::LAYOUT_CANADIAN_FRENCH},
   };
 
-  for (size_t i = 0; i < arraysize(kLanguageIDs); ++i) {
+  for (size_t i = 0; i < base::size(kLanguageIDs); ++i) {
     if (layout == kLanguageIDs[i].keyboard_layout) {
       HKL new_keyboard_layout = LoadKeyboardLayout(kLanguageIDs[i].language,
                                                    KLF_ACTIVATE);
@@ -143,7 +143,7 @@
     {VK_RCONTROL, MockKeyboard::RIGHT_CONTROL},
     {VK_RMENU,    MockKeyboard::RIGHT_ALT},
   };
-  for (size_t i = 0; i < arraysize(kModifierMasks); ++i) {
+  for (size_t i = 0; i < base::size(kModifierMasks); ++i) {
     const int kKeyDownMask = 0x80;
     if (modifiers & kModifierMasks[i].mask)
       keyboard_states_[kModifierMasks[i].key_code] = kKeyDownMask;
@@ -159,9 +159,9 @@
   // the mofifiers.
   CHECK(output);
   wchar_t code[16];
-  int length = ToUnicodeEx(key_code, MapVirtualKey(key_code, 0),
-                           &keyboard_states_[0], &code[0], arraysize(code), 0,
-                           active_keyboard_layout_);
+  int length =
+      ToUnicodeEx(key_code, MapVirtualKey(key_code, 0), &keyboard_states_[0],
+                  &code[0], base::size(code), 0, active_keyboard_layout_);
   if (length > 0)
     output->assign(code);
   return length;
diff --git a/courgette/encoded_program_unittest.cc b/courgette/encoded_program_unittest.cc
index e8e461481..d394724 100644
--- a/courgette/encoded_program_unittest.cc
+++ b/courgette/encoded_program_unittest.cc
@@ -10,7 +10,7 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "courgette/image_utils.h"
 #include "courgette/label_manager.h"
 #include "courgette/streams.h"
@@ -109,7 +109,7 @@
       0xF8, 0xFF, 0xFF,
       0xFF  // REL32 from next line to base + 2
   };
-  EXPECT_TRUE(CompareSink(golden, arraysize(golden), &assembled));
+  EXPECT_TRUE(CompareSink(golden, base::size(golden), &assembled));
 }
 
 // A larger test with multiple addresses. We encode the program and check the
@@ -138,14 +138,14 @@
       0x03, 0x07, 0x03, 0x05  // 3 indexes: [7, 3, 5].
   };
   EXPECT_TRUE(CompareSink(golden_abs32_indexes,
-                          arraysize(golden_abs32_indexes),
+                          base::size(golden_abs32_indexes),
                           sinks.stream(kStreamAbs32Indexes)));
 
   const uint8_t golden_rel32_indexes[] = {
       0x03, 0x00, 0x03, 0x01  // 3 indexes: [0, 3, 1].
   };
   EXPECT_TRUE(CompareSink(golden_rel32_indexes,
-                          arraysize(golden_rel32_indexes),
+                          base::size(golden_rel32_indexes),
                           sinks.stream(kStreamRel32Indexes)));
 
   // Addresses: [_, _, _, 2, _, 23, _, 11].
@@ -159,7 +159,7 @@
       0x00, 0x00, 0x00, 0x04, 0x00, 0x2A, 0x00, 0x17,
   };
   EXPECT_TRUE(CompareSink(golden_abs32_addresses,
-                          arraysize(golden_abs32_addresses),
+                          base::size(golden_abs32_addresses),
                           sinks.stream(kStreamAbs32Addresses)));
 
   // Addresses: [16, 7, _, 32].
@@ -173,7 +173,7 @@
       0x20, 0x11, 0x00, 0x32,
   };
   EXPECT_TRUE(CompareSink(golden_rel32_addresses,
-                          arraysize(golden_rel32_addresses),
+                          base::size(golden_rel32_addresses),
                           sinks.stream(kStreamRel32Addresses)));
 }
 
diff --git a/courgette/memory_allocator_unittest.cc b/courgette/memory_allocator_unittest.cc
index 9d2d476..c861c36 100644
--- a/courgette/memory_allocator_unittest.cc
+++ b/courgette/memory_allocator_unittest.cc
@@ -8,14 +8,14 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 TEST(MemoryAllocatorTest, NoThrowBuffer) {
   const size_t size_list[] = {0U, 1U, 2U, 11U, 15U, 16U};
 
   // Repeat test for different sizes.
-  for (size_t idx = 0; idx < arraysize(size_list); ++idx) {
+  for (size_t idx = 0; idx < base::size(size_list); ++idx) {
     size_t size = size_list[idx];
 
     courgette::NoThrowBuffer<size_t> buf1;
diff --git a/courgette/third_party/bsdiff/bsdiff_search_unittest.cc b/courgette/third_party/bsdiff/bsdiff_search_unittest.cc
index 46332b0..2ea8ffd1b 100644
--- a/courgette/third_party/bsdiff/bsdiff_search_unittest.cc
+++ b/courgette/third_party/bsdiff/bsdiff_search_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <cstring>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "courgette/third_party/bsdiff/paged_array.h"
 #include "courgette/third_party/divsufsort/divsufsort.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -57,7 +57,7 @@
       {-1, 0, "(the"},
   };
 
-  for (size_t idx = 0; idx < arraysize(test_cases); ++idx) {
+  for (size_t idx = 0; idx < base::size(test_cases); ++idx) {
     const auto& test_case = test_cases[idx];
     int query_size = static_cast<int>(::strlen(test_case.query_str));
     const unsigned char* query_buf =
@@ -97,7 +97,7 @@
       "elephantelephantelephantelephantelephant",
       "011010011001011010010110011010010",
   };
-  for (size_t idx = 0; idx < arraysize(test_cases); ++idx) {
+  for (size_t idx = 0; idx < base::size(test_cases); ++idx) {
     int size = static_cast<int>(::strlen(test_cases[idx]));
     const unsigned char* buf =
         reinterpret_cast<const unsigned char*>(test_cases[idx]);
diff --git a/crypto/ec_private_key_unittest.cc b/crypto/ec_private_key_unittest.cc
index 00aa8a8..cfec13c 100644
--- a/crypto/ec_private_key_unittest.cc
+++ b/crypto/ec_private_key_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace {
@@ -266,7 +266,7 @@
   std::string raw_public_key;
   EXPECT_TRUE(keypair_openssl->ExportRawPublicKey(&raw_public_key));
   EXPECT_EQ(std::string(reinterpret_cast<const char*>(kOpenSSLRawPublicKey),
-                        arraysize(kOpenSSLRawPublicKey)),
+                        base::size(kOpenSSLRawPublicKey)),
             raw_public_key);
 }
 
diff --git a/crypto/encryptor_unittest.cc b/crypto/encryptor_unittest.cc
index 76178dcb..0fec305 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "crypto/symmetric_key.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -81,7 +81,7 @@
     0x48, 0x1D, 0x42, 0xB0, 0xBA, 0x21, 0xB2, 0x0C
   };
 
-  ASSERT_EQ(arraysize(expected_ciphertext), ciphertext.size());
+  ASSERT_EQ(base::size(expected_ciphertext), ciphertext.size());
   for (size_t i = 0; i < ciphertext.size(); ++i) {
     ASSERT_EQ(expected_ciphertext[i],
               static_cast<unsigned char>(ciphertext[i]));
@@ -236,7 +236,7 @@
   int kTestDecryptSizes[] = { 32, 16, 8 };
 
   int offset = 0;
-  for (size_t i = 0; i < arraysize(kTestDecryptSizes); ++i) {
+  for (size_t i = 0; i < base::size(kTestDecryptSizes); ++i) {
     std::string decrypted;
     size_t len = kTestDecryptSizes[i];
     EXPECT_TRUE(
@@ -250,35 +250,33 @@
 }  // namespace
 
 TEST(EncryptorTest, EncryptAES128CTR) {
-  TestAESCTREncrypt(
-      kAES128CTRKey, arraysize(kAES128CTRKey),
-      kAESCTRInitCounter, arraysize(kAESCTRInitCounter),
-      kAESCTRPlaintext, arraysize(kAESCTRPlaintext),
-      kAES128CTRCiphertext, arraysize(kAES128CTRCiphertext));
+  TestAESCTREncrypt(kAES128CTRKey, base::size(kAES128CTRKey),
+                    kAESCTRInitCounter, base::size(kAESCTRInitCounter),
+                    kAESCTRPlaintext, base::size(kAESCTRPlaintext),
+                    kAES128CTRCiphertext, base::size(kAES128CTRCiphertext));
 }
 
 TEST(EncryptorTest, EncryptAES256CTR) {
-  TestAESCTREncrypt(
-      kAES256CTRKey, arraysize(kAES256CTRKey),
-      kAESCTRInitCounter, arraysize(kAESCTRInitCounter),
-      kAESCTRPlaintext, arraysize(kAESCTRPlaintext),
-      kAES256CTRCiphertext, arraysize(kAES256CTRCiphertext));
+  TestAESCTREncrypt(kAES256CTRKey, base::size(kAES256CTRKey),
+                    kAESCTRInitCounter, base::size(kAESCTRInitCounter),
+                    kAESCTRPlaintext, base::size(kAESCTRPlaintext),
+                    kAES256CTRCiphertext, base::size(kAES256CTRCiphertext));
 }
 
 TEST(EncryptorTest, EncryptAES128CTR_MultipleDecrypt) {
-  TestAESCTRMultipleDecrypt(
-      kAES128CTRKey, arraysize(kAES128CTRKey),
-      kAESCTRInitCounter, arraysize(kAESCTRInitCounter),
-      kAESCTRPlaintext, arraysize(kAESCTRPlaintext),
-      kAES128CTRCiphertext, arraysize(kAES128CTRCiphertext));
+  TestAESCTRMultipleDecrypt(kAES128CTRKey, base::size(kAES128CTRKey),
+                            kAESCTRInitCounter, base::size(kAESCTRInitCounter),
+                            kAESCTRPlaintext, base::size(kAESCTRPlaintext),
+                            kAES128CTRCiphertext,
+                            base::size(kAES128CTRCiphertext));
 }
 
 TEST(EncryptorTest, EncryptAES256CTR_MultipleDecrypt) {
-  TestAESCTRMultipleDecrypt(
-      kAES256CTRKey, arraysize(kAES256CTRKey),
-      kAESCTRInitCounter, arraysize(kAESCTRInitCounter),
-      kAESCTRPlaintext, arraysize(kAESCTRPlaintext),
-      kAES256CTRCiphertext, arraysize(kAES256CTRCiphertext));
+  TestAESCTRMultipleDecrypt(kAES256CTRKey, base::size(kAES256CTRKey),
+                            kAESCTRInitCounter, base::size(kAESCTRInitCounter),
+                            kAESCTRPlaintext, base::size(kAESCTRPlaintext),
+                            kAES256CTRCiphertext,
+                            base::size(kAES256CTRCiphertext));
 }
 
 TEST(EncryptorTest, EncryptDecryptCTR) {
diff --git a/crypto/hmac_unittest.cc b/crypto/hmac_unittest.cc
index 9c42dad..2d39f03 100644
--- a/crypto/hmac_unittest.cc
+++ b/crypto/hmac_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "crypto/hmac.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -145,7 +145,7 @@
           "\xBB\xFF\x1A\x91" }
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     crypto::HMAC hmac(crypto::HMAC::SHA1);
     ASSERT_TRUE(hmac.Init(reinterpret_cast<const unsigned char*>(cases[i].key),
                           cases[i].key_len));
@@ -242,7 +242,7 @@
   ASSERT_TRUE(
       hmac.Init(reinterpret_cast<const unsigned char*>(kSimpleKey),
                 kSimpleKeyLength));
-  for (size_t i = 0; i < arraysize(kSimpleHmacCases); ++i) {
+  for (size_t i = 0; i < base::size(kSimpleHmacCases); ++i) {
     std::string data_string(kSimpleHmacCases[i].data,
                             kSimpleHmacCases[i].data_len);
     unsigned char digest[kSHA1DigestSize];
@@ -257,7 +257,7 @@
       hmac.Init(reinterpret_cast<const unsigned char*>(kSimpleKey),
                 kSimpleKeyLength));
   const char empty_digest[kSHA1DigestSize] = { 0 };
-  for (size_t i = 0; i < arraysize(kSimpleHmacCases); ++i) {
+  for (size_t i = 0; i < base::size(kSimpleHmacCases); ++i) {
     // Expected results
     EXPECT_TRUE(hmac.Verify(
         base::StringPiece(kSimpleHmacCases[i].data,
diff --git a/crypto/mock_apple_keychain.cc b/crypto/mock_apple_keychain.cc
index 453114e..6076813 100644
--- a/crypto/mock_apple_keychain.cc
+++ b/crypto/mock_apple_keychain.cc
@@ -5,8 +5,8 @@
 #include "crypto/mock_apple_keychain.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 
 namespace {
@@ -42,7 +42,7 @@
     // The function to free this data is mocked so the cast is fine.
     *passwordData = const_cast<char*>(kPassword);
     DCHECK(passwordLength);
-    *passwordLength = arraysize(kPassword);
+    *passwordLength = base::size(kPassword);
     password_data_count_++;
   }
 
diff --git a/crypto/p224_unittest.cc b/crypto/p224_unittest.cc
index 8cfe6e7..db3662a6 100644
--- a/crypto/p224_unittest.cc
+++ b/crypto/p224_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "crypto/p224.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace crypto {
@@ -785,7 +785,7 @@
 TEST(P224, ScalarBaseMult) {
   Point point;
 
-  for (size_t i = 0; i < arraysize(kNISTTestVectors); i++) {
+  for (size_t i = 0; i < base::size(kNISTTestVectors); i++) {
     p224::ScalarBaseMult(kNISTTestVectors[i].scalar, &point);
     const std::string external = point.ToString();
     ASSERT_EQ(external.size(), 56u);
diff --git a/dbus/end_to_end_async_unittest.cc b/dbus/end_to_end_async_unittest.cc
index 11faf80..92d4c7a 100644
--- a/dbus/end_to_end_async_unittest.cc
+++ b/dbus/end_to_end_async_unittest.cc
@@ -11,7 +11,6 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
@@ -310,7 +309,7 @@
 TEST_F(EndToEndAsyncTest, EchoThreeTimes) {
   const char* kMessages[] = { "foo", "bar", "baz" };
 
-  for (size_t i = 0; i < arraysize(kMessages); ++i) {
+  for (size_t i = 0; i < base::size(kMessages); ++i) {
     // Create the method call.
     MethodCall method_call("org.chromium.TestInterface", "Echo");
     MessageWriter writer(&method_call);
diff --git a/dbus/property_unittest.cc b/dbus/property_unittest.cc
index 2368fa0..9d4b447 100644
--- a/dbus/property_unittest.cc
+++ b/dbus/property_unittest.cc
@@ -13,9 +13,9 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/threading/thread.h"
 #include "base/threading/thread_restrictions.h"
@@ -338,7 +338,7 @@
   writer.OpenVariant("a{ss}", &variant_writer);
   variant_writer.OpenArray("{ss}", &variant_array_writer);
   const char* items[] = {"One", "Two", "Three", "Four"};
-  for (unsigned i = 0; i < arraysize(items); ++i) {
+  for (unsigned i = 0; i < base::size(items); ++i) {
     variant_array_writer.OpenDictEntry(&struct_entry_writer);
     struct_entry_writer.AppendString(items[i]);
     struct_entry_writer.AppendString(base::UintToString(i + 1));
@@ -388,7 +388,7 @@
   for (uint16_t i = 0; i < 5; ++i) {
     variant_array_writer.OpenStruct(&struct_entry_writer);
     ip_bytes[4] = 0x30 + i;
-    struct_entry_writer.AppendArrayOfBytes(ip_bytes, arraysize(ip_bytes));
+    struct_entry_writer.AppendArrayOfBytes(ip_bytes, base::size(ip_bytes));
     struct_entry_writer.AppendUint16(i);
     variant_array_writer.CloseContainer(&struct_entry_writer);
   }
@@ -416,7 +416,7 @@
   uint8_t ip_bytes[] = {0x54, 0x65, 0x73, 0x74, 0x30};
   for (uint16_t i = 0; i < 5; ++i) {
     ip_bytes[4] = 0x30 + i;
-    std::vector<uint8_t> bytes(ip_bytes, ip_bytes + arraysize(ip_bytes));
+    std::vector<uint8_t> bytes(ip_bytes, ip_bytes + base::size(ip_bytes));
     test_list.push_back(make_pair(bytes, 16));
   }
 
@@ -443,7 +443,7 @@
 
   const char* keys[] = {"One", "Two", "Three", "Four"};
   const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
-  for (unsigned i = 0; i < arraysize(keys); ++i) {
+  for (unsigned i = 0; i < base::size(keys); ++i) {
     MessageWriter entry_writer(nullptr);
     dict_writer.OpenDictEntry(&entry_writer);
 
@@ -464,8 +464,8 @@
   Property<std::map<std::string, std::vector<uint8_t>>> test_property;
   EXPECT_TRUE(test_property.PopValueFromReader(&reader));
 
-  ASSERT_EQ(arraysize(keys), test_property.value().size());
-  for (unsigned i = 0; i < arraysize(keys); ++i)
+  ASSERT_EQ(base::size(keys), test_property.value().size());
+  for (unsigned i = 0; i < base::size(keys); ++i)
     EXPECT_EQ(values[i], test_property.value().at(keys[i]));
 }
 
@@ -498,7 +498,7 @@
 
   const uint16_t keys[] = {11, 12, 13, 14};
   const std::vector<uint8_t> values[] = {{1}, {1, 2}, {1, 2, 3}, {1, 2, 3, 4}};
-  for (unsigned i = 0; i < arraysize(keys); ++i) {
+  for (unsigned i = 0; i < base::size(keys); ++i) {
     MessageWriter entry_writer(nullptr);
     dict_writer.OpenDictEntry(&entry_writer);
 
@@ -519,8 +519,8 @@
   Property<std::map<uint16_t, std::vector<uint8_t>>> test_property;
   EXPECT_TRUE(test_property.PopValueFromReader(&reader));
 
-  ASSERT_EQ(arraysize(keys), test_property.value().size());
-  for (unsigned i = 0; i < arraysize(keys); ++i)
+  ASSERT_EQ(base::size(keys), test_property.value().size());
+  for (unsigned i = 0; i < base::size(keys); ++i)
     EXPECT_EQ(values[i], test_property.value().at(keys[i]));
 }
 
diff --git a/dbus/values_util_unittest.cc b/dbus/values_util_unittest.cc
index 5a0b81e9..7ced1c6 100644
--- a/dbus/values_util_unittest.cc
+++ b/dbus/values_util_unittest.cc
@@ -13,7 +13,7 @@
 #include <vector>
 
 #include "base/json/json_writer.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "dbus/message.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -352,7 +352,7 @@
 TEST(ValuesUtilTest, PopDoubleToIntDictionary) {
   // Create test data.
   const int32_t kValues[] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
-  const std::vector<int32_t> values(kValues, kValues + arraysize(kValues));
+  const std::vector<int32_t> values(kValues, kValues + base::size(kValues));
   std::vector<double> keys(values.size());
   for (size_t i = 0; i != values.size(); ++i)
     keys[i] = std::sqrt(values[i]);
diff --git a/device/bluetooth/bluetooth_device_unittest.cc b/device/bluetooth/bluetooth_device_unittest.cc
index b681132..5a21ab62 100644
--- a/device/bluetooth/bluetooth_device_unittest.cc
+++ b/device/bluetooth/bluetooth_device_unittest.cc
@@ -6,7 +6,6 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -65,7 +64,7 @@
     "1a2b3c4d5e6f",
   };
 
-  for (size_t i = 0; i < arraysize(kValidFormats); ++i) {
+  for (size_t i = 0; i < base::size(kValidFormats); ++i) {
     SCOPED_TRACE(std::string("Input format: '") + kValidFormats[i] + "'");
     EXPECT_EQ("1A:2B:3C:4D:5E:6F",
               BluetoothDevice::CanonicalizeAddress(kValidFormats[i]));
@@ -90,7 +89,7 @@
     "1:A2:B3:C4:D5:E6F",
   };
 
-  for (size_t i = 0; i < arraysize(kValidFormats); ++i) {
+  for (size_t i = 0; i < base::size(kValidFormats); ++i) {
     SCOPED_TRACE(std::string("Input format: '") + kValidFormats[i] + "'");
     EXPECT_EQ(std::string(),
               BluetoothDevice::CanonicalizeAddress(kValidFormats[i]));
diff --git a/device/bluetooth/bluetooth_gatt_descriptor.cc b/device/bluetooth/bluetooth_gatt_descriptor.cc
index 4eab704d..5ddfd46 100644
--- a/device/bluetooth/bluetooth_gatt_descriptor.cc
+++ b/device/bluetooth/bluetooth_gatt_descriptor.cc
@@ -8,6 +8,7 @@
 #include <vector>
 
 #include "base/lazy_instance.h"
+#include "base/stl_util.h"
 
 namespace device {
 namespace {
@@ -24,7 +25,7 @@
         "0x2900", "0x2901", "0x2902", "0x2903", "0x2904", "0x2905"
     };
 
-    for (size_t i = 0; i < arraysize(strings); ++i)
+    for (size_t i = 0; i < base::size(strings); ++i)
       uuids.push_back(BluetoothUUID(strings[i]));
 
     return uuids;
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
index 0f388cd..967f2dc 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_unittest.cc
@@ -6,8 +6,8 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/bind_test_util.h"
 #include "build/build_config.h"
 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
@@ -807,7 +807,7 @@
   TestBluetoothAdapterObserver observer(adapter_);
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   characteristic1_->WriteRemoteCharacteristic(
       test_vector, GetCallback(Call::EXPECTED),
       GetGattErrorCallback(Call::NOT_EXPECTED));
@@ -848,7 +848,7 @@
       GetGattErrorCallback(Call::NOT_EXPECTED));
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   SimulateGattCharacteristicRead(characteristic1_, test_vector);
   base::RunLoop().RunUntilIdle();
   EXPECT_EQ(1, gatt_read_characteristic_attempts_);
@@ -894,7 +894,7 @@
       BluetoothRemoteGattCharacteristic::PROPERTY_WRITE));
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   characteristic1_->WriteRemoteCharacteristic(
       test_vector, GetCallback(Call::EXPECTED),
       GetGattErrorCallback(Call::NOT_EXPECTED));
diff --git a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
index 95f3d22..f1a79bf 100644
--- a/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_descriptor_unittest.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
@@ -369,7 +370,7 @@
   EXPECT_EQ(1, gatt_read_descriptor_attempts_);
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   SimulateGattDescriptorRead(descriptor1_, test_vector);
   base::RunLoop().RunUntilIdle();
 
@@ -400,7 +401,7 @@
   ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate());
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   descriptor1_->WriteRemoteDescriptor(test_vector, GetCallback(Call::EXPECTED),
                                       GetGattErrorCallback(Call::NOT_EXPECTED));
   EXPECT_EQ(1, gatt_write_descriptor_attempts_);
@@ -433,7 +434,7 @@
   EXPECT_EQ(1, gatt_read_descriptor_attempts_);
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   SimulateGattDescriptorRead(descriptor1_, test_vector);
   base::RunLoop().RunUntilIdle();
   EXPECT_EQ(1, callback_count_);
@@ -474,7 +475,7 @@
   ASSERT_NO_FATAL_FAILURE(FakeDescriptorBoilerplate());
 
   uint8_t values[] = {0, 1, 2, 3, 4, 0xf, 0xf0, 0xff};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   descriptor1_->WriteRemoteDescriptor(test_vector, GetCallback(Call::EXPECTED),
                                       GetGattErrorCallback(Call::NOT_EXPECTED));
   EXPECT_EQ(1, gatt_write_descriptor_attempts_);
@@ -988,7 +989,7 @@
   base::RunLoop().RunUntilIdle();
 
   uint8_t values[] = {0x34, 0x12};
-  std::vector<uint8_t> test_vector(values, values + arraysize(values));
+  std::vector<uint8_t> test_vector(values, values + base::size(values));
   EXPECT_EQ(test_vector, last_read_value_);
   EXPECT_EQ(test_vector, descriptor1_->GetValue());
 }
diff --git a/device/bluetooth/bluetooth_uuid_unittest.cc b/device/bluetooth/bluetooth_uuid_unittest.cc
index 647ff28..4f89420 100644
--- a/device/bluetooth/bluetooth_uuid_unittest.cc
+++ b/device/bluetooth/bluetooth_uuid_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -141,7 +141,7 @@
     { "00001aBc-0000-1000-8000-00805F9b34fB", k128Bit },
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE("Input UUID: " + test_cases[i].input_uuid);
     BluetoothUUID uuid(test_cases[i].input_uuid);
     EXPECT_TRUE(uuid.IsValid());
diff --git a/device/bluetooth/dbus/fake_bluetooth_media_transport_client.cc b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.cc
index 6fd6336ff..f3cf485b 100644
--- a/device/bluetooth/dbus/fake_bluetooth_media_transport_client.cc
+++ b/device/bluetooth/dbus/fake_bluetooth_media_transport_client.cc
@@ -12,8 +12,8 @@
 #include <sstream>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "device/bluetooth/dbus/bluetooth_media_client.h"
 #include "device/bluetooth/dbus/bluez_dbus_manager.h"
 #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h"
@@ -44,7 +44,7 @@
 }
 
 #define UINT8_VECTOR_FROM_ARRAY(array) \
-  std::vector<uint8_t>(array, array + arraysize(array))
+  std::vector<uint8_t>(array, array + base::size(array))
 
 }  // namespace
 
@@ -57,7 +57,7 @@
 const uint8_t FakeBluetoothMediaTransportClient::kTransportConfiguration[] = {
     0x21, 0x15, 0x33, 0x2C};
 const uint8_t FakeBluetoothMediaTransportClient::kTransportConfigurationLength =
-    arraysize(FakeBluetoothMediaTransportClient::kTransportConfiguration);
+    base::size(FakeBluetoothMediaTransportClient::kTransportConfiguration);
 const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5;
 const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 50;
 const uint16_t FakeBluetoothMediaTransportClient::kDefaultReadMtu = 20;
diff --git a/device/bluetooth/uribeacon/uri_encoder.cc b/device/bluetooth/uribeacon/uri_encoder.cc
index 7c982f0..435847515 100644
--- a/device/bluetooth/uribeacon/uri_encoder.cc
+++ b/device/bluetooth/uribeacon/uri_encoder.cc
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
 #include "uri_encoder.h"
+#include "base/stl_util.h"
 
 using base::StringPiece;
 
@@ -70,26 +70,26 @@
 struct expansion* LookupExpansionByValue(const std::string& input,
                                          int input_index) {
   return CommonLookupExpansionByValue(
-      expansions_list, arraysize(expansions_list), input, input_index);
+      expansions_list, base::size(expansions_list), input, input_index);
 }
 
 struct expansion* LookupPrefixExpansionByValue(const std::string& input,
                                                int input_index) {
   return CommonLookupExpansionByValue(prefix_expansions_list,
-                                      arraysize(prefix_expansions_list), input,
+                                      base::size(prefix_expansions_list), input,
                                       input_index);
 }
 
 struct expansion* LookupExpansionByCode(const std::vector<uint8_t>& input,
                                         int input_index) {
-  if (input[input_index] >= arraysize(expansions_list))
+  if (input[input_index] >= base::size(expansions_list))
     return NULL;
   return &expansions_list[input[input_index]];
 }
 
 struct expansion* LookupPrefixExpansionByCode(const std::vector<uint8_t>& input,
                                               int input_index) {
-  if (input[input_index] >= arraysize(prefix_expansions_list))
+  if (input[input_index] >= base::size(prefix_expansions_list))
     return NULL;
   return &prefix_expansions_list[input[input_index]];
 }
diff --git a/device/fido/ctap_response_unittest.cc b/device/fido/ctap_response_unittest.cc
index 609965c..aa5a403 100644
--- a/device/fido/ctap_response_unittest.cc
+++ b/device/fido/ctap_response_unittest.cc
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "base/stl_util.h"
 #include "components/cbor/reader.h"
 #include "components/cbor/values.h"
 #include "components/cbor/writer.h"
@@ -298,7 +299,7 @@
 
 // Get a subset of the response for testing error handling.
 std::vector<uint8_t> GetTestCorruptedSignResponse(size_t length) {
-  DCHECK_LE(length, arraysize(test_data::kTestU2fSignResponse));
+  DCHECK_LE(length, base::size(test_data::kTestU2fSignResponse));
   return fido_parsing_utils::Materialize(fido_parsing_utils::ExtractSpan(
       test_data::kTestU2fSignResponse, 0, length));
 }
diff --git a/device/gamepad/gamepad_platform_data_fetcher_linux.cc b/device/gamepad/gamepad_platform_data_fetcher_linux.cc
index 50f9dbf..2ed7534 100644
--- a/device/gamepad/gamepad_platform_data_fetcher_linux.cc
+++ b/device/gamepad/gamepad_platform_data_fetcher_linux.cc
@@ -12,6 +12,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -77,7 +78,7 @@
   base::TruncateUTF8ToByteSize(id, Gamepad::kIdLengthCap - 1, &id);
   base::string16 tmp16 = base::UTF8ToUTF16(id);
   memset(pad->id, 0, sizeof(pad->id));
-  tmp16.copy(pad->id, arraysize(pad->id) - 1);
+  tmp16.copy(pad->id, base::size(pad->id) - 1);
 
   // Set the mapper string to "standard" if the gamepad has a standard mapping,
   // or the empty string otherwise.
@@ -87,7 +88,7 @@
                                  &mapping);
     tmp16 = base::UTF8ToUTF16(mapping);
     memset(pad->mapping, 0, sizeof(pad->mapping));
-    tmp16.copy(pad->mapping, arraysize(pad->mapping) - 1);
+    tmp16.copy(pad->mapping, base::size(pad->mapping) - 1);
   } else {
     pad->mapping[0] = 0;
   }
diff --git a/device/gamepad/raw_input_data_fetcher_win.cc b/device/gamepad/raw_input_data_fetcher_win.cc
index b2ace74..90caf3b 100644
--- a/device/gamepad/raw_input_data_fetcher_win.cc
+++ b/device/gamepad/raw_input_data_fetcher_win.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/trace_event.h"
 #include "device/gamepad/gamepad_standard_mappings.h"
@@ -43,7 +43,7 @@
 }
 
 RAWINPUTDEVICE* RawInputDataFetcher::GetRawInputDevices(DWORD flags) {
-  size_t usage_count = arraysize(DeviceUsages);
+  size_t usage_count = base::size(DeviceUsages);
   std::unique_ptr<RAWINPUTDEVICE[]> devices(new RAWINPUTDEVICE[usage_count]);
   for (size_t i = 0; i < usage_count; ++i) {
     devices[i].dwFlags = flags;
@@ -78,7 +78,7 @@
   // Register to receive raw HID input.
   std::unique_ptr<RAWINPUTDEVICE[]> devices(
       GetRawInputDevices(RIDEV_INPUTSINK));
-  if (!::RegisterRawInputDevices(devices.get(), arraysize(DeviceUsages),
+  if (!::RegisterRawInputDevices(devices.get(), base::size(DeviceUsages),
                                  sizeof(RAWINPUTDEVICE))) {
     PLOG(ERROR) << "RegisterRawInputDevices() failed for RIDEV_INPUTSINK";
     window_.reset();
@@ -96,7 +96,7 @@
   DCHECK(window_);
   std::unique_ptr<RAWINPUTDEVICE[]> devices(GetRawInputDevices(RIDEV_REMOVE));
 
-  if (!::RegisterRawInputDevices(devices.get(), arraysize(DeviceUsages),
+  if (!::RegisterRawInputDevices(devices.get(), base::size(DeviceUsages),
                                  sizeof(RAWINPUTDEVICE))) {
     PLOG(INFO) << "RegisterRawInputDevices() failed for RIDEV_REMOVE";
   }
diff --git a/device/gamepad/xbox_data_fetcher_mac.cc b/device/gamepad/xbox_data_fetcher_mac.cc
index 7c2de10..5596503 100644
--- a/device/gamepad/xbox_data_fetcher_mac.cc
+++ b/device/gamepad/xbox_data_fetcher_mac.cc
@@ -16,6 +16,7 @@
 
 #include "base/logging.h"
 #include "base/mac/foundation_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 
@@ -314,9 +315,9 @@
   controller->SetLEDPattern((XboxControllerMac::LEDPattern)(
       XboxControllerMac::LED_FLASH_TOP_LEFT + controller->location_id()));
 
-  CopyToUString(state->data.id, arraysize(state->data.id),
+  CopyToUString(state->data.id, base::size(state->data.id),
                 base::UTF8ToUTF16(controller->GetIdString()));
-  CopyToUString(state->data.mapping, arraysize(state->data.mapping),
+  CopyToUString(state->data.mapping, base::size(state->data.mapping),
                 base::UTF8ToUTF16("standard"));
 
   state->data.connected = true;
@@ -376,7 +377,7 @@
     pad.buttons[16].pressed = data.buttons[14];
     pad.buttons[16].value = data.buttons[14] ? 1.0f : 0.0f;
   }
-  for (size_t i = 0; i < arraysize(data.axes); i++) {
+  for (size_t i = 0; i < base::size(data.axes); i++) {
     pad.axes[i] = data.axes[i];
   }
 
diff --git a/device/test/usb_test_gadget_impl.cc b/device/test/usb_test_gadget_impl.cc
index a9032a2..6c86bf4 100644
--- a/device/test/usb_test_gadget_impl.cc
+++ b/device/test/usb_test_gadget_impl.cc
@@ -15,7 +15,6 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/path_service.h"
@@ -23,6 +22,7 @@
 #include "base/run_loop.h"
 #include "base/scoped_observer.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -437,7 +437,7 @@
       const uint16_t product_id = device->product_id();
       if (product_id_ == -1) {
         bool found = false;
-        for (size_t i = 0; i < arraysize(kConfigurations); ++i) {
+        for (size_t i = 0; i < base::size(kConfigurations); ++i) {
           if (product_id == kConfigurations[i].product_id) {
             found = true;
             break;
@@ -569,7 +569,7 @@
 
 bool UsbTestGadgetImpl::SetType(Type type) {
   const struct UsbTestGadgetConfiguration* config = NULL;
-  for (size_t i = 0; i < arraysize(kConfigurations); ++i) {
+  for (size_t i = 0; i < base::size(kConfigurations); ++i) {
     if (kConfigurations[i].type == type) {
       config = &kConfigurations[i];
     }
diff --git a/device/vr/openvr/test/fake_openvr_impl_api.cc b/device/vr/openvr/test/fake_openvr_impl_api.cc
index e57421cd..877d920 100644
--- a/device/vr/openvr/test/fake_openvr_impl_api.cc
+++ b/device/vr/openvr/test/fake_openvr_impl_api.cc
@@ -2,6 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <D3D11_1.h>
+#include <DXGI1_4.h>
+#include <wrl.h>
+#include <memory>
+
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
 #include "device/vr/openvr/test/test_helper.h"
@@ -9,11 +15,6 @@
 #include "third_party/openvr/src/headers/openvr.h"
 #include "third_party/openvr/src/src/ivrclientcore.h"
 
-#include <D3D11_1.h>
-#include <DXGI1_4.h>
-#include <wrl.h>
-#include <memory>
-
 // TODO(https://crbug.com/892717): Update argument names to be consistent with
 // Chromium style guidelines.
 namespace vr {
@@ -440,7 +441,7 @@
     Microsoft::WRL::ComPtr<ID3D11DeviceContext> d3d11_device_context;
     if (SUCCEEDED(D3D11CreateDevice(
             adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, NULL, flags, feature_levels,
-            arraysize(feature_levels), D3D11_SDK_VERSION,
+            base::size(feature_levels), D3D11_SDK_VERSION,
             d3d11_device.GetAddressOf(), &feature_level_out,
             d3d11_device_context.GetAddressOf()))) {
       *adapter_index = i;
diff --git a/device/vr/windows/d3d11_texture_helper.cc b/device/vr/windows/d3d11_texture_helper.cc
index f24e9be..01e95c6 100644
--- a/device/vr/windows/d3d11_texture_helper.cc
+++ b/device/vr/windows/d3d11_texture_helper.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "device/vr/windows/d3d11_texture_helper.h"
+#include "base/stl_util.h"
 #include "mojo/public/c/system/platform_handle.h"
 
 namespace {
@@ -559,8 +560,9 @@
   Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device;
   HRESULT hr = D3D11CreateDevice(
       adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, NULL, flags, feature_levels,
-      arraysize(feature_levels), D3D11_SDK_VERSION, d3d11_device.GetAddressOf(),
-      &feature_level_out, render_state_.d3d11_device_context_.GetAddressOf());
+      base::size(feature_levels), D3D11_SDK_VERSION,
+      d3d11_device.GetAddressOf(), &feature_level_out,
+      render_state_.d3d11_device_context_.GetAddressOf());
   if (SUCCEEDED(hr)) {
     hr = d3d11_device.As(&render_state_.d3d11_device_);
     if (FAILED(hr)) {
diff --git a/extensions/browser/api/alarms/alarms_api_unittest.cc b/extensions/browser/api/alarms/alarms_api_unittest.cc
index 74517e8..19a9d627 100644
--- a/extensions/browser/api/alarms/alarms_api_unittest.cc
+++ b/extensions/browser/api/alarms/alarms_api_unittest.cc
@@ -8,6 +8,7 @@
 
 #include "base/json/json_reader.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_clock.h"
 #include "base/values.h"
 #include "content/public/browser/web_contents.h"
@@ -682,7 +683,7 @@
   };
 
   // Test once for unpacked and once for crx extension.
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     test_clock_.SetNow(base::Time::FromDoubleT(10));
 
     // Mimic retrieving an alarm from StateStore.
diff --git a/extensions/browser/api/app_window/app_window_api.cc b/extensions/browser/api/app_window/app_window_api.cc
index b651137..cec1228 100644
--- a/extensions/browser/api/app_window/app_window_api.cc
+++ b/extensions/browser/api/app_window/app_window_api.cc
@@ -8,7 +8,7 @@
 #include <utility>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/time/time.h"
@@ -273,8 +273,8 @@
         "0F585FB1D0FDFBEBCE1FEB5E9DFFB6DA476B8C9B"
       };
       if (AppWindowClient::Get()->IsCurrentChannelOlderThanDev() &&
-          !SimpleFeature::IsIdInArray(
-              extension_id(), kWhitelist, arraysize(kWhitelist))) {
+          !SimpleFeature::IsIdInArray(extension_id(), kWhitelist,
+                                      base::size(kWhitelist))) {
         return RespondNow(
             Error(app_window_constants::kAlphaEnabledWrongChannel));
       }
diff --git a/extensions/browser/api/declarative_net_request/indexed_rule_unittest.cc b/extensions/browser/api/declarative_net_request/indexed_rule_unittest.cc
index 15ae729..785092e0 100644
--- a/extensions/browser/api/declarative_net_request/indexed_rule_unittest.cc
+++ b/extensions/browser/api/declarative_net_request/indexed_rule_unittest.cc
@@ -8,8 +8,8 @@
 #include <utility>
 
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/version_info/version_info.h"
@@ -52,7 +52,7 @@
       {kMinValidID, ParseResult::SUCCESS},
       {kMinValidID + 1, ParseResult::SUCCESS},
   };
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->id = cases[i].id;
@@ -84,7 +84,7 @@
        kDefaultPriority},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->priority = std::move(cases[i].priority);
@@ -134,7 +134,7 @@
            flat_rule::OptionFlag_IS_CASE_INSENSITIVE},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->condition.domain_type = cases[i].domain_type;
@@ -199,7 +199,7 @@
        ParseResult::SUCCESS, flat_rule::ElementType_SCRIPT},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->condition.resource_types = std::move(cases[i].resource_types);
@@ -270,7 +270,7 @@
        flat_rule::AnchorType_NONE, "", ParseResult::ERROR_NON_ASCII_URL_FILTER},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->condition.url_filter = std::move(cases[i].input_url_filter);
@@ -366,7 +366,7 @@
        {}},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->condition.domains = std::move(cases[i].domains);
@@ -399,7 +399,7 @@
                {std::make_unique<std::string>("abc"),
                 ParseResult::ERROR_INVALID_REDIRECT_URL, ""}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     std::unique_ptr<dnr_api::Rule> rule = CreateGenericParsedRule();
     rule->action.redirect_url = std::move(cases[i].redirect_url);
diff --git a/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc b/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
index ffb2a79..2a7d79e 100644
--- a/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
+++ b/extensions/browser/api/declarative_webrequest/webrequest_condition_attribute_unittest.cc
@@ -10,9 +10,9 @@
 #include <utility>
 
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "content/public/browser/resource_request_info.h"
 #include "content/public/common/previews_state.h"
@@ -284,7 +284,7 @@
 
   // Check that exactly all active stages are considered in this test.
   unsigned int covered_stages = 0;
-  for (size_t i = 0; i < arraysize(active_stages); ++i)
+  for (size_t i = 0; i < base::size(active_stages); ++i)
     covered_stages |= active_stages[i].first;
   EXPECT_EQ(kActiveStages, covered_stages);
 
@@ -302,7 +302,7 @@
 
   // Create an attribute with all possible applicable stages.
   base::ListValue all_stages;
-  for (size_t i = 0; i < arraysize(active_stages); ++i)
+  for (size_t i = 0; i < base::size(active_stages); ++i)
     all_stages.AppendString(active_stages[i].second);
   scoped_refptr<const WebRequestConditionAttribute> attribute_with_all =
       WebRequestConditionAttribute::Create(keys::kStagesKey,
@@ -316,7 +316,7 @@
   std::vector<scoped_refptr<const WebRequestConditionAttribute> >
       one_stage_attributes;
 
-  for (size_t i = 0; i < arraysize(active_stages); ++i) {
+  for (size_t i = 0; i < base::size(active_stages); ++i) {
     base::ListValue single_stage_list;
     single_stage_list.AppendString(active_stages[i].second);
     one_stage_attributes.push_back(
@@ -335,7 +335,7 @@
                             TRAFFIC_ANNOTATION_FOR_TESTS));
   WebRequestInfo request_info(url_request.get());
 
-  for (size_t i = 0; i < arraysize(active_stages); ++i) {
+  for (size_t i = 0; i < base::size(active_stages); ++i) {
     EXPECT_FALSE(empty_attribute->IsFulfilled(
         WebRequestData(&request_info, active_stages[i].first)));
 
@@ -477,7 +477,7 @@
     keys::kValueSuffixKey, "alue",
     keys::kValuePrefixKey, "custom/value"
   };
-  const size_t kPassingConditionSizes[] = { arraysize(kPassingCondition) };
+  const size_t kPassingConditionSizes[] = {base::size(kPassingCondition)};
   GetArrayAsVector(kPassingCondition, kPassingConditionSizes, 1u, &tests);
   // Positive filter, passing (conjunction of tests).
   MatchAndCheck(
@@ -572,7 +572,7 @@
     keys::kValueContainsKey, "alu",
     keys::kValueEqualsKey, "custom/value"
   };
-  const size_t kPassingConditionSizes[] = { arraysize(kPassingCondition) };
+  const size_t kPassingConditionSizes[] = {base::size(kPassingCondition)};
   GetArrayAsVector(kPassingCondition, kPassingConditionSizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -596,7 +596,7 @@
     keys::kNameSuffixKey, "Header-B",
     keys::kValueEqualsKey, "custom/value"
   };
-  const size_t kMixingConditionSizes[] = { arraysize(kMixingCondition) };
+  const size_t kMixingConditionSizes[] = {base::size(kMixingCondition)};
   GetArrayAsVector(kMixingCondition, kMixingConditionSizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -607,7 +607,7 @@
     keys::kNameEqualsKey, "Custom-header-b",
     keys::kValueEqualsKey, "valueA"
   };
-  const size_t kMoreValues1Sizes[] = { arraysize(kMoreValues1) };
+  const size_t kMoreValues1Sizes[] = {base::size(kMoreValues1)};
   GetArrayAsVector(kMoreValues1, kMoreValues1Sizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -616,7 +616,7 @@
     keys::kNameEqualsKey, "Custom-header-b",
     keys::kValueEqualsKey, "valueB"
   };
-  const size_t kMoreValues2Sizes[] = { arraysize(kMoreValues2) };
+  const size_t kMoreValues2Sizes[] = {base::size(kMoreValues2)};
   GetArrayAsVector(kMoreValues2, kMoreValues2Sizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -634,7 +634,7 @@
                 &result);
   EXPECT_TRUE(result);
   // Then conjunction, conflict.
-  const size_t kConflictSizes[] = { arraysize(kConflict) };
+  const size_t kConflictSizes[] = {base::size(kConflict)};
   GetArrayAsVector(kConflict, kConflictSizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -645,7 +645,7 @@
     keys::kNameSuffixKey, "Header-C",
     keys::kValueEqualsKey, "valueC, valueD"
   };
-  const size_t kCommaSizes[] = { arraysize(kComma) };
+  const size_t kCommaSizes[] = {base::size(kComma)};
   GetArrayAsVector(kComma, kCommaSizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -656,7 +656,7 @@
     keys::kNameEqualsKey, "custom-header-d",
     keys::kValueEqualsKey, ""
   };
-  const size_t kEmptySizes[] = { arraysize(kEmpty) };
+  const size_t kEmptySizes[] = {base::size(kEmpty)};
   GetArrayAsVector(kEmpty, kEmptySizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -686,7 +686,7 @@
     keys::kNameEqualsKey, "CUSTOM-HEADER-B",
     keys::kNameContainsKey, "CUSTOM-HEADER-B"
   };
-  const size_t kUppercaseSizes[] = { arraysize(kUppercase) };  // Conjunction.
+  const size_t kUppercaseSizes[] = {base::size(kUppercase)};  // Conjunction.
   GetArrayAsVector(kUppercase, kUppercaseSizes, 1u, &tests);
   MatchAndCheck(tests, keys::kResponseHeadersKey, stage, url_request.get(),
                 &result);
@@ -710,7 +710,7 @@
     keys::kNameEqualsKey, "Non-existing",
     keys::kValueEqualsKey, "void"
   };
-  const size_t kNonExistentSizes[] = { arraysize(kNonExistent) };
+  const size_t kNonExistentSizes[] = {base::size(kNonExistent)};
   GetArrayAsVector(kNonExistent, kNonExistentSizes, 1u, &tests);
   MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, stage,
                 url_request.get(), &result);
@@ -721,7 +721,7 @@
     keys::kNameEqualsKey, "custom-header-b",
     keys::kValueEqualsKey, "valueB"
   };
-  const size_t kExistingSize[] = { arraysize(kExisting) };
+  const size_t kExistingSize[] = {base::size(kExisting)};
   GetArrayAsVector(kExisting, kExistingSize, 1u, &tests);
   MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, stage,
                 url_request.get(), &result);
@@ -756,7 +756,7 @@
   bool result;
   const RequestStage stage = ON_HEADERS_RECEIVED;
   const std::string kCondition[] = {keys::kValueEqualsKey, "custom/value"};
-  const size_t kConditionSizes[] = {arraysize(kCondition)};
+  const size_t kConditionSizes[] = {base::size(kCondition)};
   GetArrayAsVector(kCondition, kConditionSizes, 1u, &tests);
 
   {
diff --git a/extensions/browser/api/feedback_private/feedback_private_api.cc b/extensions/browser/api/feedback_private/feedback_private_api.cc
index 71f665f..1006234 100644
--- a/extensions/browser/api/feedback_private/feedback_private_api.cc
+++ b/extensions/browser/api/feedback_private/feedback_private_api.cc
@@ -10,10 +10,10 @@
 
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_base.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/metrics/user_metrics.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -65,7 +65,7 @@
   constexpr char kFakePathStr[] = "C:\\fakepath\\";
   if (base::StartsWith(path, kFakePathStr,
                        base::CompareCase::INSENSITIVE_ASCII))
-    return path.substr(arraysize(kFakePathStr) - 1);
+    return path.substr(base::size(kFakePathStr) - 1);
   return path;
 }
 
diff --git a/extensions/browser/api/file_system/file_system_api.cc b/extensions/browser/api/file_system/file_system_api.cc
index 9a42b879..2c6e0cbd 100644
--- a/extensions/browser/api/file_system/file_system_api.cc
+++ b/extensions/browser/api/file_system/file_system_api.cc
@@ -14,7 +14,6 @@
 #include "base/bind.h"
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/weak_ptr.h"
 #include "base/path_service.h"
@@ -550,7 +549,7 @@
     return;
   }
 
-  for (size_t i = 0; i < arraysize(kGraylistedPaths); i++) {
+  for (size_t i = 0; i < base::size(kGraylistedPaths); i++) {
     base::FilePath graylisted_path;
     if (!base::PathService::Get(kGraylistedPaths[i], &graylisted_path))
       continue;
diff --git a/extensions/browser/api/networking_private/networking_private_api.cc b/extensions/browser/api/networking_private/networking_private_api.cc
index 2895006a..b2d03fa 100644
--- a/extensions/browser/api/networking_private/networking_private_api.cc
+++ b/extensions/browser/api/networking_private/networking_private_api.cc
@@ -9,6 +9,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/callback.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "components/onc/onc_constants.h"
 #include "extensions/browser/api/extensions_api_client.h"
@@ -77,10 +78,10 @@
   size_t filter_size = 0;
   if (type == PropertiesType::GET) {
     filter = kPrivatePropertiesForGet;
-    filter_size = arraysize(kPrivatePropertiesForGet);
+    filter_size = base::size(kPrivatePropertiesForGet);
   } else {
     filter = kPrivatePropertiesForSet;
-    filter_size = arraysize(kPrivatePropertiesForSet);
+    filter_size = base::size(kPrivatePropertiesForSet);
   }
 
   std::vector<std::string> removed_properties;
diff --git a/extensions/browser/api/printer_provider/printer_provider_apitest.cc b/extensions/browser/api/printer_provider/printer_provider_apitest.cc
index eccef57..aa691c520 100644
--- a/extensions/browser/api/printer_provider/printer_provider_apitest.cc
+++ b/extensions/browser/api/printer_provider/printer_provider_apitest.cc
@@ -9,9 +9,9 @@
 
 #include "base/bind.h"
 #include "base/json/json_string_value_serializer.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_restrictions.h"
@@ -136,7 +136,7 @@
     job.content_type = "application/pdf";
     const unsigned char kDocumentBytes[] = {'b', 'y', 't', 'e', 's'};
     job.document_bytes =
-        new base::RefCountedBytes(kDocumentBytes, arraysize(kDocumentBytes));
+        new base::RefCountedBytes(kDocumentBytes, base::size(kDocumentBytes));
 
     PrinterProviderAPIFactory::GetInstance()
         ->GetForBrowserContext(browser_context())
diff --git a/extensions/browser/api/system_storage/system_storage_apitest.cc b/extensions/browser/api/system_storage/system_storage_apitest.cc
index af5fed7..f99d181 100644
--- a/extensions/browser/api/system_storage/system_storage_apitest.cc
+++ b/extensions/browser/api/system_storage/system_storage_apitest.cc
@@ -6,8 +6,8 @@
 
 #include <vector>
 
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "components/storage_monitor/storage_monitor.h"
 #include "components/storage_monitor/test_storage_monitor.h"
@@ -79,7 +79,7 @@
   }
 
   void SetUpAllMockStorageDevices() {
-    for (size_t i = 0; i < arraysize(kTestingData); ++i) {
+    for (size_t i = 0; i < base::size(kTestingData); ++i) {
       AttachRemovableStorage(kTestingData[i]);
     }
   }
@@ -99,11 +99,11 @@
 IN_PROC_BROWSER_TEST_F(SystemStorageApiTest, Storage) {
   SetUpAllMockStorageDevices();
   TestStorageInfoProvider* provider =
-      new TestStorageInfoProvider(kTestingData, arraysize(kTestingData));
+      new TestStorageInfoProvider(kTestingData, base::size(kTestingData));
   extensions::StorageInfoProvider::InitializeForTesting(provider);
   std::vector<std::unique_ptr<ExtensionTestMessageListener>>
       device_ids_listeners;
-  for (size_t i = 0; i < arraysize(kTestingData); ++i) {
+  for (size_t i = 0; i < base::size(kTestingData); ++i) {
     device_ids_listeners.push_back(
         std::make_unique<ExtensionTestMessageListener>(
             StorageMonitor::GetInstance()->GetTransientIdForDeviceId(
diff --git a/extensions/browser/api/web_request/form_data_parser.cc b/extensions/browser/api/web_request/form_data_parser.cc
index 18b5c44..23f3ad7 100644
--- a/extensions/browser/api/web_request/form_data_parser.cc
+++ b/extensions/browser/api/web_request/form_data_parser.cc
@@ -10,7 +10,7 @@
 
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
 #include "net/base/escape.h"
@@ -27,7 +27,7 @@
 namespace {
 
 const char kContentDisposition[] = "content-disposition:";
-const size_t kContentDispositionLength = arraysize(kContentDisposition) - 1;
+const size_t kContentDispositionLength = base::size(kContentDisposition) - 1;
 // kCharacterPattern is an allowed character in a URL encoding. Definition is
 // from RFC 1738, end of section 2.2.
 const char kCharacterPattern[] =
diff --git a/extensions/browser/api/web_request/form_data_parser_unittest.cc b/extensions/browser/api/web_request/form_data_parser_unittest.cc
index 82524290..e37181c 100644
--- a/extensions/browser/api/web_request/form_data_parser_unittest.cc
+++ b/extensions/browser/api/web_request/form_data_parser_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "extensions/browser/api/web_request/form_data_parser.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -189,7 +189,7 @@
                           "binary",
                           "\u0420\u043e\u0434\u0436\u0435\u0440 "
                           "\u0416\u0435\u043b\u044f\u0437\u043d\u044b"};
-  const std::vector<std::string> kExpected(kPairs, kPairs + arraysize(kPairs));
+  const std::vector<std::string> kExpected(kPairs, kPairs + base::size(kPairs));
 
   std::vector<const base::StringPiece*> input;
   std::vector<std::string> output;
diff --git a/extensions/browser/api/web_request/web_request_api.cc b/extensions/browser/api/web_request/web_request_api.cc
index d49ab7a..b67fc97 100644
--- a/extensions/browser/api/web_request/web_request_api.cc
+++ b/extensions/browser/api/web_request/web_request_api.cc
@@ -16,7 +16,6 @@
 #include "base/feature_list.h"
 #include "base/json/json_writer.h"
 #include "base/lazy_instance.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/metrics/user_metrics.h"
 #include "base/stl_util.h"
@@ -193,7 +192,7 @@
         0, strlen(webview::kWebViewEventPrefix), kWebRequestEventPrefix);
   }
   auto* const* web_request_events_end =
-      kWebRequestEvents + arraysize(kWebRequestEvents);
+      kWebRequestEvents + base::size(kWebRequestEvents);
   return std::find(kWebRequestEvents, web_request_events_end,
                    web_request_event_name) != web_request_events_end;
 }
@@ -352,7 +351,7 @@
       {events::WEB_REQUEST_ON_AUTH_REQUIRED, keys::kOnAuthRequiredEvent},
       {events::WEB_REQUEST_ON_RESPONSE_STARTED, keys::kOnResponseStartedEvent},
       {events::WEB_REQUEST_ON_HEADERS_RECEIVED, keys::kOnHeadersReceivedEvent}};
-  static_assert(arraysize(kWebRequestEvents) == arraysize(values_and_names),
+  static_assert(base::size(kWebRequestEvents) == base::size(values_and_names),
                 "kWebRequestEvents and values_and_names must be the same");
   for (const ValueAndName& value_and_name : values_and_names) {
     if (value_and_name.event_name == event_name)
@@ -577,7 +576,7 @@
       request_id_generator_(base::MakeRefCounted<RequestIDGenerator>()),
       may_have_proxies_(MayHaveProxies()) {
   EventRouter* event_router = EventRouter::Get(browser_context_);
-  for (size_t i = 0; i < arraysize(kWebRequestEvents); ++i) {
+  for (size_t i = 0; i < base::size(kWebRequestEvents); ++i) {
     // Observe the webRequest event.
     std::string event_name = kWebRequestEvents[i];
     event_router->RegisterObserver(this, event_name);
diff --git a/extensions/browser/api/web_request/web_request_info.cc b/extensions/browser/api/web_request/web_request_info.cc
index 250b6f5..011e516a 100644
--- a/extensions/browser/api/web_request/web_request_info.cc
+++ b/extensions/browser/api/web_request/web_request_info.cc
@@ -8,6 +8,7 @@
 #include <string>
 
 #include "base/files/file_path.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "content/public/browser/resource_request_info.h"
 #include "content/public/browser/websocket_handshake_request_info.h"
@@ -211,7 +212,7 @@
                                       keys::kRequestBodyRawKey};
   bool some_succeeded = false;
   if (!data_sources.empty()) {
-    for (size_t i = 0; i < arraysize(presenters); ++i) {
+    for (size_t i = 0; i < base::size(presenters); ++i) {
       for (auto& source : data_sources)
         source->FeedToPresenter(presenters[i]);
       if (presenters[i]->Succeeded()) {
diff --git a/extensions/browser/api/web_request/web_request_resource_type.cc b/extensions/browser/api/web_request/web_request_resource_type.cc
index 72ef618..0c05a2d 100644
--- a/extensions/browser/api/web_request/web_request_resource_type.cc
+++ b/extensions/browser/api/web_request/web_request_resource_type.cc
@@ -6,6 +6,7 @@
 
 #include "base/logging.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "content/public/browser/resource_request_info.h"
 #include "extensions/browser/api/web_request/web_request_info.h"
 
@@ -32,7 +33,7 @@
     {"other", WebRequestResourceType::OTHER},
 };
 
-constexpr size_t kResourceTypesLength = arraysize(kResourceTypes);
+constexpr size_t kResourceTypesLength = base::size(kResourceTypes);
 
 static_assert(kResourceTypesLength ==
                   base::strict_cast<size_t>(WebRequestResourceType::OTHER) + 1,
diff --git a/extensions/browser/api/webcam_private/v4l2_webcam.cc b/extensions/browser/api/webcam_private/v4l2_webcam.cc
index c7c7963..db95f8a 100644
--- a/extensions/browser/api/webcam_private/v4l2_webcam.cc
+++ b/extensions/browser/api/webcam_private/v4l2_webcam.cc
@@ -12,8 +12,8 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 
-#include "base/macros.h"
 #include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
 
 #define V4L2_CID_PAN_SPEED (V4L2_CID_CAMERA_CLASS_BASE+32)
 #define V4L2_CID_TILT_SPEED (V4L2_CID_CAMERA_CLASS_BASE+33)
@@ -44,7 +44,7 @@
     V4L2_CTRL_TYPE_MENU,
     UVC_CTRL_DATA_TYPE_ENUM,
     const_cast<uvc_menu_info*>(&kLogitechCmdMenu[0]),
-    arraysize(kLogitechCmdMenu),
+    base::size(kLogitechCmdMenu),
 };
 
 const uvc_xu_control_mapping kLogitechPanAbsoluteMapping = {
diff --git a/extensions/browser/api/webcam_private/visca_webcam.cc b/extensions/browser/api/webcam_private/visca_webcam.cc
index f7d43188..8a81610 100644
--- a/extensions/browser/api/webcam_private/visca_webcam.cc
+++ b/extensions/browser/api/webcam_private/visca_webcam.cc
@@ -10,8 +10,8 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/public/browser/browser_task_traits.h"
@@ -120,7 +120,7 @@
                                0x03, 0x03, 0x03, 0xFF};
 
 #define CHAR_VECTOR_FROM_ARRAY(array) \
-  std::vector<char>(array, array + arraysize(array))
+  std::vector<char>(array, array + base::size(array))
 
 int ShiftResponseLowerBits(char c, size_t shift) {
   return static_cast<int>(c & 0x0F) << shift;
diff --git a/extensions/browser/event_router_unittest.cc b/extensions/browser/event_router_unittest.cc
index f1e935b..1d28464 100644
--- a/extensions/browser/event_router_unittest.cc
+++ b/extensions/browser/event_router_unittest.cc
@@ -10,7 +10,7 @@
 
 #include "base/bind.h"
 #include "base/compiler_specific.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/values.h"
 #include "content/public/browser/browser_context.h"
@@ -366,7 +366,7 @@
   const std::string kExtensionId = "mbflcebpggnecokmikipoihdbecnjfoj";
   const std::string kHostSuffixes[] = {"foo.com", "bar.com", "baz.com"};
   std::vector<std::unique_ptr<DictionaryValue>> filters;
-  for (size_t i = 0; i < arraysize(kHostSuffixes); ++i) {
+  for (size_t i = 0; i < base::size(kHostSuffixes); ++i) {
     std::unique_ptr<base::DictionaryValue> filter =
         CreateHostSuffixFilter(kHostSuffixes[i]);
     event_router()->AddFilteredEventListener(kEventName, render_process_host(),
diff --git a/extensions/browser/extension_creator_filter.cc b/extensions/browser/extension_creator_filter.cc
index 741899f..780bde3 100644
--- a/extensions/browser/extension_creator_filter.cc
+++ b/extensions/browser/extension_creator_filter.cc
@@ -9,7 +9,7 @@
 #include <set>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "extensions/common/constants.h"
 
@@ -44,7 +44,7 @@
       FILE_PATH_LITERAL(".svn"),        FILE_PATH_LITERAL("__MACOSX"),
       FILE_PATH_LITERAL("desktop.ini"), FILE_PATH_LITERAL("Thumbs.db")};
   std::set<base::FilePath::StringType> names_to_exclude_set(
-      names_to_exclude, names_to_exclude + arraysize(names_to_exclude));
+      names_to_exclude, names_to_exclude + base::size(names_to_exclude));
   std::vector<base::FilePath::StringType> components;
   file_path.GetComponents(&components);
   for (size_t i = 0; i < components.size(); i++) {
diff --git a/extensions/browser/guest_view/extension_view/whitelist/extension_view_whitelist.cc b/extensions/browser/guest_view/extension_view/whitelist/extension_view_whitelist.cc
index 887fe0a..a83a476 100644
--- a/extensions/browser/guest_view/extension_view/whitelist/extension_view_whitelist.cc
+++ b/extensions/browser/guest_view/extension_view/whitelist/extension_view_whitelist.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace extensions {
 
@@ -30,7 +30,7 @@
 
 // static
 bool IsExtensionIdWhitelisted(const std::string& extension_id) {
-  for (size_t i = 0; i < arraysize(kWhitelist); ++i) {
+  for (size_t i = 0; i < base::size(kWhitelist); ++i) {
     if (extension_id == kWhitelist[i])
       return true;
   }
diff --git a/extensions/browser/guest_view/extensions_guest_view_message_filter.cc b/extensions/browser/guest_view/extensions_guest_view_message_filter.cc
index 3df8aad..5e655d75 100644
--- a/extensions/browser/guest_view/extensions_guest_view_message_filter.cc
+++ b/extensions/browser/guest_view/extensions_guest_view_message_filter.cc
@@ -5,8 +5,8 @@
 #include "extensions/browser/guest_view/extensions_guest_view_message_filter.h"
 
 #include "base/guid.h"
-#include "base/macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/time/time.h"
 #include "components/guest_view/browser/bad_message.h"
@@ -294,7 +294,7 @@
     int render_process_id,
     BrowserContext* context)
     : GuestViewMessageFilter(kFilteredMessageClasses,
-                             arraysize(kFilteredMessageClasses),
+                             base::size(kFilteredMessageClasses),
                              render_process_id,
                              context),
       content::BrowserAssociatedInterface<mojom::GuestView>(this, this) {
diff --git a/extensions/browser/image_loader_unittest.cc b/extensions/browser/image_loader_unittest.cc
index edc02e1..d362d08 100644
--- a/extensions/browser/image_loader_unittest.cc
+++ b/extensions/browser/image_loader_unittest.cc
@@ -8,9 +8,9 @@
 
 #include "base/files/file_path.h"
 #include "base/json/json_file_value_serializer.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "content/public/test/test_browser_context.h"
 #include "extensions/browser/extension_registry.h"
@@ -180,7 +180,7 @@
   std::vector<ImageLoader::ImageRepresentation> info_list;
   int sizes[] = {extension_misc::EXTENSION_ICON_BITTY,
                  extension_misc::EXTENSION_ICON_SMALLISH, };
-  for (size_t i = 0; i < arraysize(sizes); ++i) {
+  for (size_t i = 0; i < base::size(sizes); ++i) {
     ExtensionResource resource = IconsInfo::GetIconResource(
         extension.get(), sizes[i], ExtensionIconSet::MATCH_EXACTLY);
     info_list.push_back(ImageLoader::ImageRepresentation(
@@ -223,7 +223,7 @@
   std::vector<ImageLoader::ImageRepresentation> info_list;
   int sizes[] = {extension_misc::EXTENSION_ICON_BITTY,
                  extension_misc::EXTENSION_ICON_SMALLISH, };
-  for (size_t i = 0; i < arraysize(sizes); ++i) {
+  for (size_t i = 0; i < base::size(sizes); ++i) {
     ExtensionResource resource = IconsInfo::GetIconResource(
         extension.get(), sizes[i], ExtensionIconSet::MATCH_EXACTLY);
     info_list.push_back(ImageLoader::ImageRepresentation(
@@ -258,7 +258,7 @@
   EXPECT_EQ(1, image_loaded_count());
 
   // Check that all images were loaded.
-  for (size_t i = 0; i < arraysize(sizes); ++i) {
+  for (size_t i = 0; i < base::size(sizes); ++i) {
     const gfx::Image* image = image_family_.GetBest(sizes[i], sizes[i]);
     EXPECT_EQ(sizes[i], image->Width());
   }
diff --git a/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc b/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc
index 2ac2fad..b64b9ae 100644
--- a/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc
+++ b/extensions/common/api/sockets/sockets_manifest_permission_unittest.cc
@@ -6,8 +6,8 @@
 #include <tuple>
 
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/pickle.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "extensions/common/api/sockets/sockets_manifest_permission.h"
 #include "extensions/common/manifest_constants.h"
@@ -120,7 +120,7 @@
                                             const CheckFormatEntry& op1) {
   CheckFormatEntry entries[] = {op1};
   return CheckFormat(
-      std::multiset<CheckFormatEntry>(entries, entries + arraysize(entries)),
+      std::multiset<CheckFormatEntry>(entries, entries + base::size(entries)),
       json);
 }
 
@@ -129,7 +129,7 @@
                                             const CheckFormatEntry& op2) {
   CheckFormatEntry entries[] = {op1, op2};
   return CheckFormat(
-      std::multiset<CheckFormatEntry>(entries, entries + arraysize(entries)),
+      std::multiset<CheckFormatEntry>(entries, entries + base::size(entries)),
       json);
 }
 
@@ -145,7 +145,7 @@
                                             const CheckFormatEntry& op9) {
   CheckFormatEntry entries[] = {op1, op2, op3, op4, op5, op6, op7, op8, op9};
   return CheckFormat(
-      std::multiset<CheckFormatEntry>(entries, entries + arraysize(entries)),
+      std::multiset<CheckFormatEntry>(entries, entries + base::size(entries)),
       json);
 }
 
diff --git a/extensions/common/constants.cc b/extensions/common/constants.cc
index 40ac07f..16e65497 100644
--- a/extensions/common/constants.cc
+++ b/extensions/common/constants.cc
@@ -4,6 +4,8 @@
 
 #include "extensions/common/constants.h"
 
+#include "base/stl_util.h"
+
 namespace extensions {
 
 const char kExtensionScheme[] = "chrome-extension";
@@ -81,7 +83,7 @@
     0xcd, 0x02, 0x03, 0x01, 0x00, 0x01};
 
 const size_t kWebstoreSignaturesPublicKeySize =
-    arraysize(kWebstoreSignaturesPublicKey);
+    base::size(kWebstoreSignaturesPublicKey);
 
 const int kMainThreadId = 0;
 
diff --git a/extensions/common/csp_validator.cc b/extensions/common/csp_validator.cc
index c2dd2a3..270f829 100644
--- a/extensions/common/csp_validator.cc
+++ b/extensions/common/csp_validator.cc
@@ -14,7 +14,7 @@
 #include "base/bind.h"
 #include "base/callback.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -300,7 +300,7 @@
 
 // Returns true if the |plugin_type| is one of the fully sandboxed plugin types.
 bool PluginTypeAllowed(base::StringPiece plugin_type) {
-  for (size_t i = 0; i < arraysize(kSandboxedPluginTypes); ++i) {
+  for (size_t i = 0; i < base::size(kSandboxedPluginTypes); ++i) {
     if (plugin_type == kSandboxedPluginTypes[i])
       return true;
   }
@@ -522,7 +522,7 @@
   // representing the content security policy as an HTTP header.
   const char kBadChars[] = {',', '\r', '\n', '\0'};
 
-  return policy.find_first_of(kBadChars, 0, arraysize(kBadChars)) ==
+  return policy.find_first_of(kBadChars, 0, base::size(kBadChars)) ==
          std::string::npos;
 }
 
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc
index 4ba7807..a161b59 100644
--- a/extensions/common/extension_api.cc
+++ b/extensions/common/extension_api.cc
@@ -15,7 +15,7 @@
 #include "base/json/json_writer.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.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"
@@ -47,7 +47,7 @@
 
   // Tracking down http://crbug.com/121424
   char buf[128];
-  base::snprintf(buf, arraysize(buf), "%s: (%d) '%s'", name.c_str(),
+  base::snprintf(buf, base::size(buf), "%s: (%d) '%s'", name.c_str(),
                  result.get() ? static_cast<int>(result->type()) : -1,
                  error_message.c_str());
 
@@ -75,7 +75,7 @@
     const base::DictionaryValue* schema_node,
     const std::string& child_name) {
   const base::DictionaryValue* child_node = NULL;
-  for (size_t i = 0; i < arraysize(kChildKinds); ++i) {
+  for (size_t i = 0; i < base::size(kChildKinds); ++i) {
     const base::ListValue* list_node = NULL;
     if (!schema_node->GetList(kChildKinds[i], &list_node))
       continue;
@@ -156,7 +156,7 @@
 
 void ExtensionAPI::InitDefaultConfiguration() {
   const char* names[] = {"api", "manifest", "permission"};
-  for (size_t i = 0; i < arraysize(names); ++i)
+  for (size_t i = 0; i < base::size(names); ++i)
     RegisterDependencyProvider(names[i], FeatureProvider::GetByName(names[i]));
 
   default_configuration_initialized_ = true;
diff --git a/extensions/common/features/feature_util.h b/extensions/common/features/feature_util.h
index 342cc66..621a109 100644
--- a/extensions/common/features/feature_util.h
+++ b/extensions/common/features/feature_util.h
@@ -7,7 +7,7 @@
 
 #include "base/debug/alias.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 
 // Writes |message| to the stack so that it shows up in the minidump, then
@@ -18,14 +18,14 @@
 // This is provided in feature_util because for some reason features are prone
 // to mysterious crashes in named map lookups. For example see crbug.com/365192
 // and crbug.com/461915.
-#define CRASH_WITH_MINIDUMP(message)                                           \
-  {                                                                            \
-    std::string message_copy(message);                                         \
-    char minidump[BUFSIZ];                                                     \
-    base::debug::Alias(&minidump);                                             \
-    base::snprintf(minidump, arraysize(minidump), "e::%s:%d:\"%s\"", __FILE__, \
-                   __LINE__, message_copy.c_str());                            \
-    LOG(FATAL) << message_copy;                                                \
+#define CRASH_WITH_MINIDUMP(message)                                  \
+  {                                                                   \
+    std::string message_copy(message);                                \
+    char minidump[BUFSIZ];                                            \
+    base::debug::Alias(&minidump);                                    \
+    base::snprintf(minidump, base::size(minidump), "e::%s:%d:\"%s\"", \
+                   __FILE__, __LINE__, message_copy.c_str());         \
+    LOG(FATAL) << message_copy;                                       \
   }
 
 namespace extensions {
diff --git a/extensions/common/features/simple_feature_unittest.cc b/extensions/common/features/simple_feature_unittest.cc
index b75fd55..0f719e81 100644
--- a/extensions/common/features/simple_feature_unittest.cc
+++ b/extensions/common/features/simple_feature_unittest.cc
@@ -10,7 +10,6 @@
 #include <vector>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/scoped_command_line.h"
@@ -99,7 +98,7 @@
        Feature::UNSPECIFIED_PLATFORM, 25, Feature::IS_AVAILABLE}};
 
   SimpleFeature feature;
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     const IsAvailableTestData& test = tests[i];
     EXPECT_EQ(test.expected_result,
               feature
@@ -511,7 +510,7 @@
        FeatureSessionType::AUTOLAUNCHED_KIOSK,
        {FeatureSessionType::KIOSK}}};
 
-  for (size_t i = 0; i < arraysize(kTestData); ++i) {
+  for (size_t i = 0; i < base::size(kTestData); ++i) {
     std::unique_ptr<base::AutoReset<FeatureSessionType>> current_session(
         ScopedCurrentFeatureSessionType(kTestData[i].current_session_type));
 
@@ -710,13 +709,13 @@
     // aaaabbbbccccddddeeeeffffgggghhhh
     "9A0417016F345C934A1A88F55CA17C05014EEEBA"
   };
-  EXPECT_FALSE(SimpleFeature::IsIdInArray("", kIdArray, arraysize(kIdArray)));
-  EXPECT_FALSE(SimpleFeature::IsIdInArray(
-      "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", kIdArray, arraysize(kIdArray)));
-  EXPECT_TRUE(SimpleFeature::IsIdInArray(
-      "bbbbccccdddddddddeeeeeeffffgghhh", kIdArray, arraysize(kIdArray)));
-  EXPECT_TRUE(SimpleFeature::IsIdInArray(
-      "aaaabbbbccccddddeeeeffffgggghhhh", kIdArray, arraysize(kIdArray)));
+  EXPECT_FALSE(SimpleFeature::IsIdInArray("", kIdArray, base::size(kIdArray)));
+  EXPECT_FALSE(SimpleFeature::IsIdInArray("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+                                          kIdArray, base::size(kIdArray)));
+  EXPECT_TRUE(SimpleFeature::IsIdInArray("bbbbccccdddddddddeeeeeeffffgghhh",
+                                         kIdArray, base::size(kIdArray)));
+  EXPECT_TRUE(SimpleFeature::IsIdInArray("aaaabbbbccccddddeeeeffffgggghhhh",
+                                         kIdArray, base::size(kIdArray)));
 }
 
 // Tests that all combinations of feature channel and Chrome channel correctly
diff --git a/extensions/common/file_util_unittest.cc b/extensions/common/file_util_unittest.cc
index 4deab6f..89875207 100644
--- a/extensions/common/file_util_unittest.cc
+++ b/extensions/common/file_util_unittest.cc
@@ -11,9 +11,9 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/json/json_string_value_serializer.h"
-#include "base/macros.h"
 #include "base/optional.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -228,7 +228,7 @@
   static const base::FilePath::CharType* const folders[] = {
       kLocaleFolder, kPlatformSpecificFolder};
 
-  for (size_t i = 0; i < arraysize(folders); i++) {
+  for (size_t i = 0; i < base::size(folders); i++) {
     base::FilePath src_path = temp.GetPath().Append(folders[i]);
     ASSERT_TRUE(base::CreateDirectory(src_path));
   }
@@ -413,20 +413,20 @@
   base::FilePath src_path = temp.GetPath().AppendASCII("some_dir");
   ASSERT_TRUE(base::CreateDirectory(src_path));
 
-  ASSERT_EQ(static_cast<int>(arraysize(private_key)),
+  ASSERT_EQ(static_cast<int>(base::size(private_key)),
             base::WriteFile(src_path.AppendASCII("a_key.pem"), private_key,
-                            arraysize(private_key)));
-  ASSERT_EQ(static_cast<int>(arraysize(private_key)),
+                            base::size(private_key)));
+  ASSERT_EQ(static_cast<int>(base::size(private_key)),
             base::WriteFile(src_path.AppendASCII("second_key.pem"), private_key,
-                            arraysize(private_key)));
+                            base::size(private_key)));
   // Shouldn't find a key with a different extension.
-  ASSERT_EQ(static_cast<int>(arraysize(private_key)),
+  ASSERT_EQ(static_cast<int>(base::size(private_key)),
             base::WriteFile(src_path.AppendASCII("key.diff_ext"), private_key,
-                            arraysize(private_key)));
+                            base::size(private_key)));
   // Shouldn't find a key that isn't parsable.
-  ASSERT_EQ(static_cast<int>(arraysize(private_key)) - 30,
+  ASSERT_EQ(static_cast<int>(base::size(private_key)) - 30,
             base::WriteFile(src_path.AppendASCII("unparsable_key.pem"),
-                            private_key, arraysize(private_key) - 30));
+                            private_key, base::size(private_key) - 30));
   std::vector<base::FilePath> private_keys =
       file_util::FindPrivateKeyFiles(temp.GetPath());
   EXPECT_EQ(2U, private_keys.size());
@@ -575,7 +575,7 @@
   };
 #undef URL_PREFIX
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     GURL url(test_cases[i].url);
     base::FilePath expected_path =
         base::FilePath::FromUTF8Unsafe(test_cases[i].expected_relative_path);
diff --git a/extensions/common/manifest_handlers/csp_info_unittest.cc b/extensions/common/manifest_handlers/csp_info_unittest.cc
index 763e840..adfa397 100644
--- a/extensions/common/manifest_handlers/csp_info_unittest.cc
+++ b/extensions/common/manifest_handlers/csp_info_unittest.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include "extensions/common/manifest_handlers/csp_info.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "components/version_info/channel.h"
 #include "extensions/common/error_utils.h"
@@ -82,7 +83,7 @@
                errors::kInvalidSandboxedPagesCSP),
       Testcase("sandboxed_pages_invalid_5.json",
                errors::kInvalidSandboxedPagesCSP)};
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(CSPInfoUnitTest, CSPStringKey) {
@@ -145,7 +146,7 @@
                  GetInvalidManifestKeyError(kExtensionPagesKey)),
         Testcase("csp_invalid_3.json",
                  GetInvalidManifestKeyError(kExtensionPagesKey))};
-    RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+    RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
   }
 }
 
diff --git a/extensions/common/manifest_handlers/externally_connectable_unittest.cc b/extensions/common/manifest_handlers/externally_connectable_unittest.cc
index b6eaf708..1f59fab 100644
--- a/extensions/common/manifest_handlers/externally_connectable_unittest.cc
+++ b/extensions/common/manifest_handlers/externally_connectable_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "extensions/common/error_utils.h"
 #include "extensions/common/manifest_constants.h"
 #include "extensions/common/manifest_handlers/externally_connectable.h"
@@ -210,7 +210,7 @@
   // Not in order to test that ExternallyConnectableInfo sorts it.
   std::string matches_ids_array[] = {"g", "h", "c", "i", "a", "z", "b"};
   std::vector<std::string> matches_ids(
-      matches_ids_array, matches_ids_array + arraysize(matches_ids_array));
+      matches_ids_array, matches_ids_array + base::size(matches_ids_array));
 
   std::string nomatches_ids_array[] = {"2", "3", "1"};
 
@@ -219,7 +219,7 @@
     ExternallyConnectableInfo info(URLPatternSet(), matches_ids, false, false);
     for (size_t i = 0; i < matches_ids.size(); ++i)
       EXPECT_TRUE(info.IdCanConnect(matches_ids[i]));
-    for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i)
+    for (size_t i = 0; i < base::size(nomatches_ids_array); ++i)
       EXPECT_FALSE(info.IdCanConnect(nomatches_ids_array[i]));
   }
 
@@ -228,7 +228,7 @@
     ExternallyConnectableInfo info(URLPatternSet(), matches_ids, true, false);
     for (size_t i = 0; i < matches_ids.size(); ++i)
       EXPECT_TRUE(info.IdCanConnect(matches_ids[i]));
-    for (size_t i = 0; i < arraysize(nomatches_ids_array); ++i)
+    for (size_t i = 0; i < base::size(nomatches_ids_array); ++i)
       EXPECT_TRUE(info.IdCanConnect(nomatches_ids_array[i]));
   }
 }
diff --git a/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc b/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc
index 3d650e8c..75c336a6 100644
--- a/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc
+++ b/extensions/common/manifest_handlers/file_handler_manifest_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "extensions/common/manifest_constants.h"
 #include "extensions/common/manifest_handlers/file_handler_info.h"
 #include "extensions/common/manifest_test.h"
@@ -35,7 +35,7 @@
       Testcase("file_handlers_invalid_verb.json",
                errors::kInvalidFileHandlerVerb),
   };
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(FileHandlersManifestTest, ValidFileHandlers) {
diff --git a/extensions/common/manifest_handlers/mime_types_handler.cc b/extensions/common/manifest_handlers/mime_types_handler.cc
index 7d208c6..d3ed85ef 100644
--- a/extensions/common/manifest_handlers/mime_types_handler.cc
+++ b/extensions/common/manifest_handlers/mime_types_handler.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
@@ -52,7 +52,7 @@
 // static
 std::vector<std::string> MimeTypesHandler::GetMIMETypeWhitelist() {
   std::vector<std::string> whitelist;
-  for (size_t i = 0; i < arraysize(kMIMETypeHandlersWhitelist); ++i)
+  for (size_t i = 0; i < base::size(kMIMETypeHandlersWhitelist); ++i)
     whitelist.push_back(kMIMETypeHandlersWhitelist[i]);
   return whitelist;
 }
diff --git a/extensions/common/manifest_handlers/shared_module_manifest_unittest.cc b/extensions/common/manifest_handlers/shared_module_manifest_unittest.cc
index 27f043db..588286b 100644
--- a/extensions/common/manifest_handlers/shared_module_manifest_unittest.cc
+++ b/extensions/common/manifest_handlers/shared_module_manifest_unittest.cc
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/version.h"
 #include "extensions/common/extension.h"
 #include "extensions/common/manifest_handlers/shared_module_info.h"
@@ -77,7 +77,7 @@
       Testcase("shared_module_export_allowlist_not_list.json",
                "Invalid value for 'export.allowlist'."),
   };
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(SharedModuleManifestTest, SharedModuleStaticFunctions) {
@@ -124,7 +124,7 @@
     Testcase("shared_module_import_invalid_version.json",
              "Invalid value for 'import[0].minimum_version'."),
   };
-  RunTestcases(testcases, arraysize(testcases), EXPECT_TYPE_ERROR);
+  RunTestcases(testcases, base::size(testcases), EXPECT_TYPE_ERROR);
 }
 
 TEST_F(SharedModuleManifestTest, LegacyAllowlistKey) {
diff --git a/extensions/common/message_bundle_unittest.cc b/extensions/common/message_bundle_unittest.cc
index 08902765..fa15400a 100644
--- a/extensions/common/message_bundle_unittest.cc
+++ b/extensions/common/message_bundle_unittest.cc
@@ -12,7 +12,7 @@
 #include <vector>
 
 #include "base/i18n/rtl.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
@@ -368,7 +368,7 @@
   messages.insert(std::make_pair("bad name", "Doesn't matter"));
   messages.insert(std::make_pair("d1g1ts_are_ok", "I are d1g1t"));
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::string text = test_cases[i].original;
     std::string error;
     EXPECT_EQ(test_cases[i].pass,
diff --git a/extensions/common/url_pattern.cc b/extensions/common/url_pattern.cc
index a2046a53..aea0d49 100644
--- a/extensions/common/url_pattern.cc
+++ b/extensions/common/url_pattern.cc
@@ -8,7 +8,6 @@
 
 #include <ostream>
 
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/pattern.h"
 #include "base/strings/strcat.h"
@@ -45,7 +44,7 @@
     URLPattern::SCHEME_WSS,        URLPattern::SCHEME_DATA,
 };
 
-static_assert(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks),
+static_assert(base::size(kValidSchemes) == base::size(kValidSchemeMasks),
               "must keep these arrays in sync");
 
 const char kParseSuccess[] = "Success.";
@@ -126,7 +125,7 @@
 
 // static
 bool URLPattern::IsValidSchemeForExtensions(base::StringPiece scheme) {
-  for (size_t i = 0; i < arraysize(kValidSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kValidSchemes); ++i) {
     if (scheme == kValidSchemes[i])
       return true;
   }
@@ -136,7 +135,7 @@
 // static
 int URLPattern::GetValidSchemeMaskForExtensions() {
   int result = 0;
-  for (size_t i = 0; i < arraysize(kValidSchemeMasks); ++i)
+  for (size_t i = 0; i < base::size(kValidSchemeMasks); ++i)
     result |= kValidSchemeMasks[i];
   return result;
 }
@@ -399,7 +398,7 @@
   if (valid_schemes_ == SCHEME_ALL)
     return true;
 
-  for (size_t i = 0; i < arraysize(kValidSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kValidSchemes); ++i) {
     if (scheme == kValidSchemes[i] && (valid_schemes_ & kValidSchemeMasks[i]))
       return true;
   }
@@ -789,7 +788,7 @@
     return result;
   }
 
-  for (size_t i = 0; i < arraysize(kValidSchemes); ++i) {
+  for (size_t i = 0; i < base::size(kValidSchemes); ++i) {
     if (MatchesScheme(kValidSchemes[i])) {
       result.push_back(kValidSchemes[i]);
     }
diff --git a/extensions/common/url_pattern_unittest.cc b/extensions/common/url_pattern_unittest.cc
index 449d7b3..395e9334 100644
--- a/extensions/common/url_pattern_unittest.cc
+++ b/extensions/common/url_pattern_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "extensions/common/constants.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -45,7 +45,7 @@
       {"http://bar", URLPattern::ParseResult::kEmptyPath},
       {"http://foo.*/bar", URLPattern::ParseResult::kInvalidHostWildcard}};
 
-  for (size_t i = 0; i < arraysize(kInvalidPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kInvalidPatterns); ++i) {
     URLPattern pattern(URLPattern::SCHEME_ALL);
     EXPECT_EQ(kInvalidPatterns[i].expected_result,
               pattern.Parse(kInvalidPatterns[i].pattern))
@@ -88,7 +88,7 @@
       {"http://foo/bar:1234/path", URLPattern::ParseResult::kSuccess, "*"},
       {"http://*.foo.*/:1234", URLPattern::ParseResult::kSuccess, "*"}};
 
-  for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kTestPatterns); ++i) {
     URLPattern pattern(URLPattern::SCHEME_ALL);
     EXPECT_EQ(kTestPatterns[i].expected_result,
               pattern.Parse(kTestPatterns[i].pattern,
@@ -389,7 +389,7 @@
 
 // SCHEME_ALL and specific schemes.
 TEST(ExtensionURLPatternTest, Match13) {
-  for (size_t i = 0; i < arraysize(kMatch13UrlPatternTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kMatch13UrlPatternTestCases); ++i) {
     URLPattern pattern(URLPattern::SCHEME_ALL);
     EXPECT_EQ(URLPattern::ParseResult::kSuccess,
               pattern.Parse(kMatch13UrlPatternTestCases[i].pattern))
@@ -568,7 +568,7 @@
 };
 
 TEST(ExtensionURLPatternTest, GetAsString) {
-  for (size_t i = 0; i < arraysize(kGetAsStringTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kGetAsStringTestCases); ++i) {
     URLPattern pattern(URLPattern::SCHEME_ALL);
     EXPECT_EQ(URLPattern::ParseResult::kSuccess,
               pattern.Parse(kGetAsStringTestCases[i].pattern))
@@ -785,7 +785,7 @@
     }
   };
 
-  for (size_t i = 0; i < arraysize(kEqualsTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kEqualsTestCases); ++i) {
     std::string message = kEqualsTestCases[i].pattern1;
     message += " ";
     message += kEqualsTestCases[i].pattern2;
diff --git a/extensions/renderer/binding_generating_native_handler.cc b/extensions/renderer/binding_generating_native_handler.cc
index 3230338..650d54e 100644
--- a/extensions/renderer/binding_generating_native_handler.cc
+++ b/extensions/renderer/binding_generating_native_handler.cc
@@ -4,8 +4,8 @@
 
 #include "extensions/renderer/binding_generating_native_handler.h"
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/timer/elapsed_timer.h"
 #include "extensions/renderer/script_context.h"
 #include "extensions/renderer/v8_helpers.h"
@@ -87,7 +87,7 @@
         v8_context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks);
     // TODO(devlin): We should not be using v8::Function::Call() directly here.
     // Instead, we should use JSRunner once it's used outside native bindings.
-    if (!create_binding->Call(v8_context, binding, arraysize(argv), argv)
+    if (!create_binding->Call(v8_context, binding, base::size(argv), argv)
              .ToLocal(&binding_instance_value) ||
         !binding_instance_value->ToObject(v8_context)
              .ToLocal(&binding_instance)) {
diff --git a/extensions/renderer/bindings/api_binding_bridge.cc b/extensions/renderer/bindings/api_binding_bridge.cc
index 09967760..ce45f89 100644
--- a/extensions/renderer/bindings/api_binding_bridge.cc
+++ b/extensions/renderer/bindings/api_binding_bridge.cc
@@ -4,6 +4,7 @@
 
 #include "extensions/renderer/bindings/api_binding_bridge.h"
 
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "extensions/renderer/bindings/api_binding_hooks.h"
 #include "extensions/renderer/bindings/api_binding_util.h"
@@ -107,7 +108,7 @@
   // This CHECK is helping to track down https://crbug.com/819968, and should be
   // removed when that's fixed.
   CHECK(binding::IsContextValid(context));
-  JSRunner::Get(context)->RunJSFunction(function, context, arraysize(args),
+  JSRunner::Get(context)->RunJSFunction(function, context, base::size(args),
                                         args);
 }
 
diff --git a/extensions/renderer/bindings/api_binding_bridge_unittest.cc b/extensions/renderer/bindings/api_binding_bridge_unittest.cc
index c72dd26..e87e5e0 100644
--- a/extensions/renderer/bindings/api_binding_bridge_unittest.cc
+++ b/extensions/renderer/bindings/api_binding_bridge_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "extensions/renderer/bindings/api_binding_bridge.h"
 
+#include "base/stl_util.h"
 #include "extensions/renderer/bindings/api_binding_hooks.h"
 #include "extensions/renderer/bindings/api_binding_test.h"
 #include "extensions/renderer/bindings/api_binding_test_util.h"
@@ -33,7 +34,7 @@
   v8::Local<v8::Function> function = FunctionFromString(
       context, "(function(obj) { obj.registerCustomHook(function() {}); })");
   v8::Local<v8::Value> args[] = {bridge_object};
-  RunFunctionAndExpectError(function, context, arraysize(args), args,
+  RunFunctionAndExpectError(function, context, base::size(args), args,
                             "Uncaught Error: Extension context invalidated.");
 }
 
diff --git a/extensions/renderer/bindings/api_binding_js_util_unittest.cc b/extensions/renderer/bindings/api_binding_js_util_unittest.cc
index 82e655a..80d91d2 100644
--- a/extensions/renderer/bindings/api_binding_js_util_unittest.cc
+++ b/extensions/renderer/bindings/api_binding_js_util_unittest.cc
@@ -6,6 +6,7 @@
 
 #include "base/bind.h"
 #include "base/optional.h"
+#include "base/stl_util.h"
 #include "extensions/renderer/bindings/api_binding_test_util.h"
 #include "extensions/renderer/bindings/api_bindings_system.h"
 #include "extensions/renderer/bindings/api_bindings_system_unittest.h"
@@ -279,7 +280,7 @@
       context,
       "(function(util, handler) { util.setExceptionHandler(handler); })");
   v8::Local<v8::Value> args[] = {v8_util, v8_handler};
-  RunFunction(add_handler, context, arraysize(args), args);
+  RunFunction(add_handler, context, base::size(args), args);
 
   CallFunctionOnObject(context, v8_util, kHandleException);
   // The error should not have been reported to the console since we have a
@@ -302,10 +303,10 @@
     v8::Local<v8::Function> v8_function = FunctionFromString(context, function);
     v8::Local<v8::Value> args[] = {v8_util};
     if (expected_error) {
-      RunFunctionAndExpectError(v8_function, context, arraysize(args), args,
+      RunFunctionAndExpectError(v8_function, context, base::size(args), args,
                                 *expected_error);
     } else {
-      RunFunction(v8_function, context, arraysize(args), args);
+      RunFunction(v8_function, context, base::size(args), args);
     }
   };
 
@@ -350,7 +351,7 @@
     v8::Local<v8::Function> add_signature =
         FunctionFromString(context, kAddSignature);
     v8::Local<v8::Value> args[] = {v8_util};
-    RunFunction(add_signature, context, arraysize(args), args);
+    RunFunction(add_signature, context, base::size(args), args);
   }
 
   EXPECT_TRUE(bindings_system()->type_reference_map()->GetCustomSignature(
@@ -363,10 +364,10 @@
             FunctionFromString(context, function);
         v8::Local<v8::Value> args[] = {v8_util};
         if (expected_error) {
-          RunFunctionAndExpectError(v8_function, context, arraysize(args), args,
-                                    *expected_error);
+          RunFunctionAndExpectError(v8_function, context, base::size(args),
+                                    args, *expected_error);
         } else {
-          RunFunction(v8_function, context, arraysize(args), args);
+          RunFunction(v8_function, context, base::size(args), args);
         }
       };
 
diff --git a/extensions/renderer/bindings/api_binding_unittest.cc b/extensions/renderer/bindings/api_binding_unittest.cc
index db4465d..d0c304b 100644
--- a/extensions/renderer/bindings/api_binding_unittest.cc
+++ b/extensions/renderer/bindings/api_binding_unittest.cc
@@ -399,7 +399,7 @@
     SCOPED_TRACE(base::StringPrintf("Testing case-%s", test_case.func_name));
     v8::Local<v8::Function> func = FunctionFromString(
         context, base::StringPrintf(kFunctionCall, test_case.func_name));
-    RunFunction(func, context, arraysize(argv), argv);
+    RunFunction(func, context, base::size(argv), argv);
     ASSERT_TRUE(last_request());
     EXPECT_EQ(test_case.thread, last_request()->thread);
     reset_last_request();
@@ -614,10 +614,10 @@
       context, "(function(e) { e.addListener(function() {}); })");
   v8::Local<v8::Value> args[] = {
       GetPropertyFromObject(binding_object, context, "onBaz")};
-  RunFunction(add_listener, context, arraysize(args), args);
+  RunFunction(add_listener, context, base::size(args), args);
   EXPECT_EQ(1u, event_handler()->GetNumEventListenersForTesting("test.onBaz",
                                                                 context));
-  RunFunctionAndExpectError(add_listener, context, arraysize(args), args,
+  RunFunctionAndExpectError(add_listener, context, base::size(args), args,
                             "Uncaught TypeError: Too many listeners.");
   EXPECT_EQ(1u, event_handler()->GetNumEventListenersForTesting("test.onBaz",
                                                                 context));
@@ -739,7 +739,7 @@
   v8::Local<v8::Value> argv[] = {binding_object};
   DisposeContext(context);
 
-  RunFunctionAndExpectError(func, context, arraysize(argv), argv,
+  RunFunctionAndExpectError(func, context, base::size(argv), argv,
                             "Uncaught Error: Extension context invalidated.");
 
   EXPECT_FALSE(HandlerWasInvoked());
@@ -761,7 +761,7 @@
   v8::Local<v8::Value> argv[] = {binding_object};
   binding::InvalidateContext(context);
 
-  RunFunctionAndExpectError(func, context, arraysize(argv), argv,
+  RunFunctionAndExpectError(func, context, base::size(argv), argv,
                             "Uncaught Error: Extension context invalidated.");
 
   EXPECT_FALSE(HandlerWasInvoked());
@@ -850,7 +850,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, kRegisterHook);
     v8::Local<v8::Value> args[] = {js_hooks};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
   }
 
   SetFunctions(kFunctions);
@@ -903,7 +903,7 @@
   v8::Local<v8::Object> js_hooks = hooks->GetJSHookInterface(context);
   v8::Local<v8::Function> function = FunctionFromString(context, kRegisterHook);
   v8::Local<v8::Value> args[] = {js_hooks};
-  RunFunctionOnGlobal(function, context, arraysize(args), args);
+  RunFunctionOnGlobal(function, context, base::size(args), args);
 
   SetHooks(std::move(hooks));
   SetFunctions(kFunctions);
@@ -947,7 +947,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, kRegisterHook);
     v8::Local<v8::Value> args[] = {js_hooks};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
   }
 
   SetHooks(std::move(hooks));
@@ -963,7 +963,7 @@
   {
     TestJSRunner::AllowErrors allow_errors;
     RunFunctionAndExpectError(function, context, v8::Undefined(isolate()),
-                              arraysize(args), args,
+                              base::size(args), args,
                               "Uncaught Error: Custom Hook Error");
   }
 
@@ -990,7 +990,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, kRegisterHook);
     v8::Local<v8::Value> args[] = {js_hooks};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
   }
 
   SetHooks(std::move(hooks));
@@ -1004,7 +1004,7 @@
                          "(function(obj) { return obj.oneString('ping'); })");
   v8::Local<v8::Value> args[] = {binding_object};
   v8::Local<v8::Value> result =
-      RunFunction(function, context, arraysize(args), args);
+      RunFunction(function, context, base::size(args), args);
   ASSERT_FALSE(result.IsEmpty());
   std::unique_ptr<base::Value> json_result = V8ToBaseValue(result, context);
   ASSERT_TRUE(json_result);
@@ -1029,7 +1029,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, kRegisterHook);
     v8::Local<v8::Value> args[] = {js_hooks};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
   }
 
   SetHooks(std::move(hooks));
@@ -1045,7 +1045,7 @@
 
   TestJSRunner::AllowErrors allow_errors;
   RunFunctionAndExpectError(function, context, v8::Undefined(isolate()),
-                            arraysize(args), args,
+                            base::size(args), args,
                             "Uncaught Error: Custom Hook Error");
 }
 
@@ -1096,7 +1096,7 @@
             context, "(function(obj) { return obj.oneString('throw'); })");
     v8::Local<v8::Value> args[] = {binding_object};
     RunFunctionAndExpectError(function, context, v8::Undefined(isolate()),
-                              arraysize(args), args,
+                              base::size(args), args,
                               "Uncaught Error: Custom Hook Error");
   }
 
@@ -1107,7 +1107,7 @@
                            "(function(obj) { return obj.oneString('ping'); })");
     v8::Local<v8::Value> args[] = {binding_object};
     v8::Local<v8::Value> result =
-        RunFunction(function, context, arraysize(args), args);
+        RunFunction(function, context, base::size(args), args);
     ASSERT_FALSE(result.IsEmpty());
     std::unique_ptr<base::Value> json_result = V8ToBaseValue(result, context);
     ASSERT_TRUE(json_result);
@@ -1134,7 +1134,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, kRegisterHook);
     v8::Local<v8::Value> args[] = {js_hooks};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
   }
 
   SetHooks(std::move(hooks));
@@ -1182,7 +1182,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, kRegisterHook);
     v8::Local<v8::Value> args[] = {js_hooks};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
   }
 
   SetHooks(std::move(hooks));
@@ -1212,13 +1212,13 @@
 
   v8::Local<v8::Value> argv[] = {binding_object};
 
-  RunFunction(function, context, arraysize(argv), argv);
+  RunFunction(function, context, base::size(argv), argv);
   ASSERT_TRUE(last_request());
   EXPECT_FALSE(last_request()->has_user_gesture);
   reset_last_request();
 
   ScopedTestUserActivation test_user_activation;
-  RunFunction(function, context, arraysize(argv), argv);
+  RunFunction(function, context, base::size(argv), argv);
   ASSERT_TRUE(last_request());
   EXPECT_TRUE(last_request()->has_user_gesture);
 
@@ -1274,10 +1274,10 @@
         GetPropertyFromObject(binding_object, context, name);
     v8::Local<v8::Value> args[] = {event};
     if (expect_supports) {
-      RunFunction(function, context, context->Global(), arraysize(args), args);
+      RunFunction(function, context, context->Global(), base::size(args), args);
     } else {
       RunFunctionAndExpectError(
-          function, context, context->Global(), arraysize(args), args,
+          function, context, context->Global(), base::size(args), args,
           "Uncaught TypeError: This event does not support filters");
     }
   };
@@ -1487,7 +1487,7 @@
     v8::TryCatch try_catch(context->GetIsolate());
     // The throwException call will throw an exception; ignore it.
     ignore_result(call->Call(context, v8::Undefined(context->GetIsolate()),
-                             arraysize(args), args));
+                             base::size(args), args));
   };
 
   call_api_method("modifyArgs", "");
@@ -1610,7 +1610,7 @@
   binding::InvalidateContext(context);
 
   v8::Local<v8::Value> argv[] = {binding_object};
-  RunFunctionAndExpectError(function, context, arraysize(argv), argv,
+  RunFunctionAndExpectError(function, context, base::size(argv), argv,
                             "Uncaught Error: Extension context invalidated.");
 }
 
diff --git a/extensions/renderer/bindings/api_bindings_system_unittest.cc b/extensions/renderer/bindings/api_bindings_system_unittest.cc
index 730682c..d5b27f4 100644
--- a/extensions/renderer/bindings/api_bindings_system_unittest.cc
+++ b/extensions/renderer/bindings/api_bindings_system_unittest.cc
@@ -6,7 +6,6 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
@@ -271,7 +270,7 @@
     v8::Local<v8::Function> function = FunctionFromString(context, kTestCall);
     v8::Local<v8::Value> args[] = {alpha_api};
     RunFunctionAndExpectError(
-        function, context, arraysize(args), args,
+        function, context, base::size(args), args,
         "Uncaught TypeError: " +
             api_errors::InvocationError(
                 "alpha.functionWithEnum", "alpha.enumRef e",
@@ -392,7 +391,7 @@
   v8::Local<v8::Object> js_hooks = hooks->GetJSHookInterface(context);
   v8::Local<v8::Function> function = FunctionFromString(context, kHook);
   v8::Local<v8::Value> args[] = {js_hooks};
-  RunFunctionOnGlobal(function, context, arraysize(args), args);
+  RunFunctionOnGlobal(function, context, base::size(args), args);
 
   {
     const char kTestCall[] =
diff --git a/extensions/renderer/bindings/api_event_handler.cc b/extensions/renderer/bindings/api_event_handler.cc
index 8c7fe62d..0bc381a 100644
--- a/extensions/renderer/bindings/api_event_handler.cc
+++ b/extensions/renderer/bindings/api_event_handler.cc
@@ -12,6 +12,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/supports_user_data.h"
 #include "base/values.h"
 #include "content/public/renderer/v8_value_converter.h"
@@ -288,7 +289,7 @@
 
     v8::Local<v8::Value> massager_args[] = {args_array, dispatch_event};
     JSRunner::Get(context)->RunJSFunction(
-        massager, context, arraysize(massager_args), massager_args);
+        massager, context, base::size(massager_args), massager_args);
   }
 }
 
diff --git a/extensions/renderer/bindings/api_event_handler_unittest.cc b/extensions/renderer/bindings/api_event_handler_unittest.cc
index 1b354c3..ea1852b 100644
--- a/extensions/renderer/bindings/api_event_handler_unittest.cc
+++ b/extensions/renderer/bindings/api_event_handler_unittest.cc
@@ -9,6 +9,7 @@
 #include "base/callback_helpers.h"
 #include "base/optional.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/bind_test_util.h"
 #include "base/test/mock_callback.h"
 #include "base/values.h"
@@ -116,14 +117,14 @@
 
   {
     v8::Local<v8::Value> argv[] = {event, listener_function};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
   // There should only be one listener on the event.
   EXPECT_EQ(1u, handler()->GetNumEventListenersForTesting(kEventName, context));
 
   {
     v8::Local<v8::Value> argv[] = {event, listener_function};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
   // Trying to add the same listener again should be a no-op.
   EXPECT_EQ(1u, handler()->GetNumEventListenersForTesting(kEventName, context));
@@ -136,7 +137,7 @@
   {
     v8::Local<v8::Value> argv[] = {event, listener_function};
     v8::Local<v8::Value> result =
-        RunFunction(has_listener_function, context, arraysize(argv), argv);
+        RunFunction(has_listener_function, context, base::size(argv), argv);
     bool has_listener = false;
     EXPECT_TRUE(gin::Converter<bool>::FromV8(isolate(), result, &has_listener));
     EXPECT_TRUE(has_listener);
@@ -148,7 +149,7 @@
         FunctionFromString(context, "(function() {})");
     v8::Local<v8::Value> argv[] = {event, not_a_listener};
     v8::Local<v8::Value> result =
-        RunFunction(has_listener_function, context, arraysize(argv), argv);
+        RunFunction(has_listener_function, context, base::size(argv), argv);
     bool has_listener = false;
     EXPECT_TRUE(gin::Converter<bool>::FromV8(isolate(), result, &has_listener));
     EXPECT_FALSE(has_listener);
@@ -162,7 +163,7 @@
   {
     v8::Local<v8::Value> argv[] = {event};
     v8::Local<v8::Value> result =
-        RunFunction(has_listeners_function, context, arraysize(argv), argv);
+        RunFunction(has_listeners_function, context, base::size(argv), argv);
     bool has_listeners = false;
     EXPECT_TRUE(
         gin::Converter<bool>::FromV8(isolate(), result, &has_listeners));
@@ -173,14 +174,14 @@
       FunctionFromString(context, kRemoveListenerFunction);
   {
     v8::Local<v8::Value> argv[] = {event, listener_function};
-    RunFunction(remove_listener_function, context, arraysize(argv), argv);
+    RunFunction(remove_listener_function, context, base::size(argv), argv);
   }
   EXPECT_EQ(0u, handler()->GetNumEventListenersForTesting(kEventName, context));
 
   {
     v8::Local<v8::Value> argv[] = {event};
     v8::Local<v8::Value> result =
-        RunFunction(has_listeners_function, context, arraysize(argv), argv);
+        RunFunction(has_listeners_function, context, base::size(argv), argv);
     bool has_listeners = false;
     EXPECT_TRUE(
         gin::Converter<bool>::FromV8(isolate(), result, &has_listeners));
@@ -232,15 +233,15 @@
         FunctionFromString(context, kAddListenerFunction);
     {
       v8::Local<v8::Value> argv[] = {alpha_event, alpha_listener1};
-      RunFunction(add_listener_function, context, arraysize(argv), argv);
+      RunFunction(add_listener_function, context, base::size(argv), argv);
     }
     {
       v8::Local<v8::Value> argv[] = {alpha_event, alpha_listener2};
-      RunFunction(add_listener_function, context, arraysize(argv), argv);
+      RunFunction(add_listener_function, context, base::size(argv), argv);
     }
     {
       v8::Local<v8::Value> argv[] = {beta_event, beta_listener};
-      RunFunction(add_listener_function, context, arraysize(argv), argv);
+      RunFunction(add_listener_function, context, base::size(argv), argv);
     }
   }
 
@@ -304,7 +305,7 @@
     v8::Local<v8::Function> add_listener_function =
         FunctionFromString(context, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event, listener_function};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
 
   const char kArguments[] = "['foo',1,{'prop1':'bar'}]";
@@ -347,7 +348,7 @@
     v8::Local<v8::Function> add_listener_a =
         FunctionFromString(context_a, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event_a, listener_a};
-    RunFunction(add_listener_a, context_a, arraysize(argv), argv);
+    RunFunction(add_listener_a, context_a, base::size(argv), argv);
   }
   EXPECT_EQ(1u,
             handler()->GetNumEventListenersForTesting(kEventName, context_a));
@@ -358,7 +359,7 @@
     v8::Local<v8::Function> add_listener_b =
         FunctionFromString(context_b, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event_b, listener_b};
-    RunFunction(add_listener_b, context_b, arraysize(argv), argv);
+    RunFunction(add_listener_b, context_b, base::size(argv), argv);
   }
   EXPECT_EQ(1u,
             handler()->GetNumEventListenersForTesting(kEventName, context_a));
@@ -469,7 +470,7 @@
 
   {
     v8::Local<v8::Value> argv[] = {event, listener};
-    RunFunctionOnGlobal(add_listener_function, context, arraysize(argv), argv);
+    RunFunctionOnGlobal(add_listener_function, context, base::size(argv), argv);
   }
 
   v8::Local<v8::Function> fire_event_function =
@@ -478,7 +479,7 @@
           "(function(event) { event.dispatch(42, 'foo', {bar: 'baz'}); })");
   {
     v8::Local<v8::Value> argv[] = {event};
-    RunFunctionOnGlobal(fire_event_function, context, arraysize(argv), argv);
+    RunFunctionOnGlobal(fire_event_function, context, base::size(argv), argv);
   }
 
   EXPECT_EQ("[42,\"foo\",{\"bar\":\"baz\"}]",
@@ -502,7 +503,7 @@
             context,
            "(function(event) { this.testEvent = event; })");
     v8::Local<v8::Value> args[] = {event};
-    RunFunctionOnGlobal(set_event_on_global, context, arraysize(args), args);
+    RunFunctionOnGlobal(set_event_on_global, context, base::size(args), args);
     EXPECT_EQ(event,
               GetPropertyFromObject(context->Global(), context, "testEvent"));
   }
@@ -527,7 +528,7 @@
 
   for (const auto& listener : listeners) {
     v8::Local<v8::Value> argv[] = {event, listener};
-    RunFunctionOnGlobal(add_listener_function, context, arraysize(argv), argv);
+    RunFunctionOnGlobal(add_listener_function, context, base::size(argv), argv);
   }
 
   // Fire the event. All listeners should be removed (and we shouldn't crash).
@@ -580,7 +581,7 @@
     v8::Local<v8::Function> listener =
         FunctionFromString(context, kListenerFunction);
     v8::Local<v8::Value> argv[] = {event, listener};
-    RunFunctionOnGlobal(add_listener_function, context, arraysize(argv), argv);
+    RunFunctionOnGlobal(add_listener_function, context, base::size(argv), argv);
   }
   EXPECT_EQ(2u, handler()->GetNumEventListenersForTesting(kEventName, context));
 
@@ -641,7 +642,7 @@
                     nullptr, true, context_a))
         .Times(1);
     v8::Local<v8::Value> argv[] = {event1_a, listener1};
-    RunFunction(add_listener, context_a, arraysize(argv), argv);
+    RunFunction(add_listener, context_a, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
   EXPECT_EQ(1u,
@@ -653,7 +654,7 @@
       FunctionFromString(context_a, "(function() {})");
   {
     v8::Local<v8::Value> argv[] = {event1_a, listener2};
-    RunFunction(add_listener, context_a, arraysize(argv), argv);
+    RunFunction(add_listener, context_a, base::size(argv), argv);
   }
   EXPECT_EQ(2u,
             handler()->GetNumEventListenersForTesting(kEventName1, context_a));
@@ -664,7 +665,7 @@
       FunctionFromString(context_a, kRemoveListenerFunction);
   {
     v8::Local<v8::Value> argv[] = {event1_a, listener1};
-    RunFunction(remove_listener, context_a, arraysize(argv), argv);
+    RunFunction(remove_listener, context_a, base::size(argv), argv);
   }
 
   EXPECT_EQ(1u,
@@ -680,7 +681,7 @@
                     nullptr, true, context_a))
         .Times(1);
     v8::Local<v8::Value> argv[] = {event1_a, listener2};
-    RunFunction(remove_listener, context_a, arraysize(argv), argv);
+    RunFunction(remove_listener, context_a, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
   EXPECT_EQ(0u,
@@ -698,7 +699,7 @@
                     nullptr, true, context_a))
         .Times(1);
     v8::Local<v8::Value> argv[] = {event2_a, listener3};
-    RunFunction(add_listener, context_a, arraysize(argv), argv);
+    RunFunction(add_listener, context_a, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
   EXPECT_EQ(1u,
@@ -718,7 +719,7 @@
     v8::Local<v8::Function> listener =
         FunctionFromString(context_b, "(function() {})");
     v8::Local<v8::Value> argv[] = {event1_b, listener};
-    RunFunction(add_listener, context_b, arraysize(argv), argv);
+    RunFunction(add_listener, context_b, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
   EXPECT_EQ(1u,
@@ -775,7 +776,7 @@
     v8::Local<v8::Function> add_listener_function =
         FunctionFromString(context, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event, listener_function};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
 
   const char kArguments[] = "['first','second']";
@@ -821,7 +822,7 @@
     v8::Local<v8::Function> add_listener_function =
         FunctionFromString(context, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event, listener_function};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
 
   const char kArguments[] = "['first','second']";
@@ -846,7 +847,7 @@
       V8ValueFromScriptSource(context, "['primary', 'secondary']"),
   };
   RunFunction(dispatch_value.As<v8::Function>(), context,
-              arraysize(dispatch_args), dispatch_args);
+              base::size(dispatch_args), dispatch_args);
 
   EXPECT_EQ(
       "[\"primary\",\"secondary\"]",
@@ -877,7 +878,7 @@
   v8::Local<v8::Function> add_listener_function =
       FunctionFromString(context, kAddListenerFunction);
   v8::Local<v8::Value> argv[] = {event, listener_function};
-  RunFunction(add_listener_function, context, arraysize(argv), argv);
+  RunFunction(add_listener_function, context, base::size(argv), argv);
 
   handler()->FireEventInContext(kEventName, context, base::ListValue(),
                                 nullptr);
@@ -956,7 +957,7 @@
       "})";
   v8::Local<v8::Value> add_listener_argv[] = {event};
   RunFunction(FunctionFromString(context, kAddListenerFunction), context,
-              arraysize(add_listener_argv), add_listener_argv);
+              base::size(add_listener_argv), add_listener_argv);
 
   // Test dispatching to the listeners.
   const char kDispatchEventFunction[] =
@@ -965,7 +966,7 @@
       FunctionFromString(context, kDispatchEventFunction);
 
   v8::Local<v8::Value> dispatch_argv[] = {event};
-  RunFunction(dispatch_function, context, arraysize(dispatch_argv),
+  RunFunction(dispatch_function, context, base::size(dispatch_argv),
               dispatch_argv);
 
   EXPECT_EQ("[1,2,3]", GetStringPropertyFromObject(context->Global(), context,
@@ -978,7 +979,7 @@
 
   // Invalidate the event and try dispatching again. Nothing should happen.
   handler.InvalidateCustomEvent(context, event);
-  RunFunction(dispatch_function, context, arraysize(dispatch_argv),
+  RunFunction(dispatch_function, context, base::size(dispatch_argv),
               dispatch_argv);
   EXPECT_EQ("undefined", GetStringPropertyFromObject(context->Global(), context,
                                                      "eventArgs"));
@@ -1002,7 +1003,7 @@
       "})";
   v8::Local<v8::Value> add_listener_argv[] = {event};
   RunFunction(FunctionFromString(context, kAddListenerFunction), context,
-              arraysize(add_listener_argv), add_listener_argv);
+              base::size(add_listener_argv), add_listener_argv);
 
   DisposeContext(context);
 }
@@ -1034,7 +1035,7 @@
         "(function(event, listener) { event.addListener(listener); })";
     v8::Local<v8::Value> args[] = {event, listener};
     RunFunction(FunctionFromString(context, kAddListener), context,
-                arraysize(args), args);
+                base::size(args), args);
   }
 
   EXPECT_EQ(1u, handler.GetNumEventListenersForTesting(kEventName, context));
@@ -1050,7 +1051,7 @@
         "(function(event, listener) { event.removeListener(listener); })";
     v8::Local<v8::Value> args[] = {event, listener};
     RunFunction(FunctionFromString(context, kRemoveListener), context,
-                arraysize(args), args);
+                base::size(args), args);
   }
 
   EXPECT_EQ(0u, handler.GetNumEventListenersForTesting(kEventName, context));
@@ -1087,7 +1088,7 @@
                     nullptr, true, context))
         .Times(1);
     v8::Local<v8::Value> argv[] = {lazy_listeners_supported, listener};
-    RunFunction(add_listener, context, arraysize(argv), argv);
+    RunFunction(add_listener, context, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
 
@@ -1099,7 +1100,7 @@
                     nullptr, false, context))
         .Times(1);
     v8::Local<v8::Value> argv[] = {lazy_listeners_not_supported, listener};
-    RunFunction(add_listener, context, arraysize(argv), argv);
+    RunFunction(add_listener, context, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
 
@@ -1113,7 +1114,7 @@
                     nullptr, true, context))
         .Times(1);
     v8::Local<v8::Value> argv[] = {lazy_listeners_supported, listener};
-    RunFunction(remove_listener, context, arraysize(argv), argv);
+    RunFunction(remove_listener, context, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
 
@@ -1125,7 +1126,7 @@
                     nullptr, false, context))
         .Times(1);
     v8::Local<v8::Value> argv[] = {lazy_listeners_not_supported, listener};
-    RunFunction(remove_listener, context, arraysize(argv), argv);
+    RunFunction(remove_listener, context, base::size(argv), argv);
     ::testing::Mock::VerifyAndClearExpectations(&change_handler);
   }
 
@@ -1149,7 +1150,7 @@
     v8::Local<v8::Function> add_listener_function =
         FunctionFromString(context, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event, listener};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
 
   {
@@ -1202,7 +1203,7 @@
     v8::Local<v8::Function> add_listener_function =
         FunctionFromString(context, kAddListenerFunction);
     v8::Local<v8::Value> argv[] = {event, listener};
-    RunFunction(add_listener_function, context, arraysize(argv), argv);
+    RunFunction(add_listener_function, context, base::size(argv), argv);
   }
 
   TestJSRunner::AllowErrors allow_errors;
@@ -1253,11 +1254,11 @@
         FunctionFromString(context, kAddListenerFunction);
     {
       v8::Local<v8::Value> argv[] = {event, listener1};
-      RunFunction(add_listener_function, context, arraysize(argv), argv);
+      RunFunction(add_listener_function, context, base::size(argv), argv);
     }
     {
       v8::Local<v8::Value> argv[] = {event, listener2};
-      RunFunction(add_listener_function, context, arraysize(argv), argv);
+      RunFunction(add_listener_function, context, base::size(argv), argv);
     }
   }
   EXPECT_EQ(2u, handler()->GetNumEventListenersForTesting(kEventName, context));
@@ -1271,7 +1272,7 @@
       v8::Local<v8::Value> argv[] = {event, listener1};
       // Note: Use JSRunner() so that script suspension is respected.
       JSRunner::Get(context)->RunJSFunction(remove_listener_function, context,
-                                            arraysize(argv), argv);
+                                            base::size(argv), argv);
     }
 
     // Since script has been suspended, there should still be two listeners, and
diff --git a/extensions/renderer/bindings/argument_spec_unittest.cc b/extensions/renderer/bindings/argument_spec_unittest.cc
index 71e3f61..9b4dd8ac 100644
--- a/extensions/renderer/bindings/argument_spec_unittest.cc
+++ b/extensions/renderer/bindings/argument_spec_unittest.cc
@@ -5,6 +5,7 @@
 #include "extensions/renderer/bindings/argument_spec.h"
 #include "base/bind.h"
 #include "base/callback.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "extensions/renderer/bindings/api_binding_test_util.h"
 #include "extensions/renderer/bindings/api_invocation_errors.h"
@@ -394,7 +395,7 @@
       // A non-empty (but zero-filled) ArrayBufferView.
       const char kBuffer[] = {0, 0, 0, 0};
       std::unique_ptr<base::Value> expected_value =
-          base::Value::CreateWithCopiedBuffer(kBuffer, arraysize(kBuffer));
+          base::Value::CreateWithCopiedBuffer(kBuffer, base::size(kBuffer));
       ASSERT_TRUE(expected_value);
       ExpectSuccessWithNoConversion(spec, "(new Int32Array(2))");
     }
@@ -402,7 +403,7 @@
       // Actual data.
       const char kBuffer[] = {'p', 'i', 'n', 'g'};
       std::unique_ptr<base::Value> expected_value =
-          base::Value::CreateWithCopiedBuffer(kBuffer, arraysize(kBuffer));
+          base::Value::CreateWithCopiedBuffer(kBuffer, base::size(kBuffer));
       ASSERT_TRUE(expected_value);
       ExpectSuccess(spec,
                     "var b = new ArrayBuffer(4);\n"
diff --git a/extensions/renderer/bindings/declarative_event_unittest.cc b/extensions/renderer/bindings/declarative_event_unittest.cc
index df6d4cca..f541a1d 100644
--- a/extensions/renderer/bindings/declarative_event_unittest.cc
+++ b/extensions/renderer/bindings/declarative_event_unittest.cc
@@ -7,6 +7,7 @@
 #include <memory>
 
 #include "base/bind.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/values.h"
 #include "extensions/common/extension_api.h"
@@ -137,7 +138,7 @@
     v8::Local<v8::Function> function =
         FunctionFromString(context, base::StringPrintf(kAddRules, kGoodRules));
     v8::Local<v8::Value> args[] = {emitter_value};
-    RunFunctionOnGlobal(function, context, arraysize(args), args);
+    RunFunctionOnGlobal(function, context, base::size(args), args);
 
     EXPECT_TRUE(last_request());
     reset_last_request();
@@ -164,7 +165,7 @@
       v8::Local<v8::Function> function =
           FunctionFromString(context, base::StringPrintf(kAddRules, rules));
       v8::Local<v8::Value> args[] = {emitter_value};
-      RunFunctionAndExpectError(function, context, arraysize(args), args,
+      RunFunctionAndExpectError(function, context, base::size(args), args,
                                 "Uncaught TypeError: Invalid invocation");
       EXPECT_FALSE(last_request()) << rules;
       reset_last_request();
@@ -218,7 +219,7 @@
                   }]);
              }))";
     v8::Local<v8::Function> add_rules = FunctionFromString(context, kAddRules);
-    RunFunctionOnGlobal(add_rules, context, arraysize(args), args);
+    RunFunctionOnGlobal(add_rules, context, base::size(args), args);
     ValidateLastRequest("events.addRules",
                         "['alpha.declarativeEvent',0,"
                         "[{'actions':['cat'],"
@@ -234,7 +235,7 @@
         "})";
     v8::Local<v8::Function> remove_rules =
         FunctionFromString(context, kRemoveRules);
-    RunFunctionOnGlobal(remove_rules, context, arraysize(args), args);
+    RunFunctionOnGlobal(remove_rules, context, base::size(args), args);
     ValidateLastRequest("events.removeRules",
                         "['alpha.declarativeEvent',0,['rule']]");
     reset_last_request();
@@ -247,7 +248,7 @@
         "})";
     v8::Local<v8::Function> remove_rules =
         FunctionFromString(context, kGetRules);
-    RunFunctionOnGlobal(remove_rules, context, arraysize(args), args);
+    RunFunctionOnGlobal(remove_rules, context, base::size(args), args);
     ValidateLastRequest("events.getRules", "['alpha.declarativeEvent',0,null]");
     reset_last_request();
   }
diff --git a/extensions/renderer/bindings/event_emitter_unittest.cc b/extensions/renderer/bindings/event_emitter_unittest.cc
index 26c2db5..645e9e5 100644
--- a/extensions/renderer/bindings/event_emitter_unittest.cc
+++ b/extensions/renderer/bindings/event_emitter_unittest.cc
@@ -6,6 +6,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "extensions/renderer/bindings/api_binding_test.h"
 #include "extensions/renderer/bindings/api_binding_test_util.h"
@@ -76,7 +77,7 @@
     v8::Local<v8::Function> listener_function =
         FunctionFromString(context, listener);
     v8::Local<v8::Value> args[] = {v8_event, listener_function};
-    RunFunction(add_listener_function, context, arraysize(args), args);
+    RunFunction(add_listener_function, context, base::size(args), args);
   };
 
   const char kListener1[] =
@@ -115,7 +116,7 @@
   TestJSRunner::AllowErrors allow_errors;
   v8::Local<v8::Value> dispatch_result =
       RunFunctionOnGlobal(FunctionFromString(context, kDispatch), context,
-                          arraysize(dispatch_args), dispatch_args);
+                          base::size(dispatch_args), dispatch_args);
 
   const char kExpectedEventArgs[] = "[\"arg1\",2]";
   for (const char* property :
@@ -177,7 +178,7 @@
                           v8::External::New(isolate(), &closure_data))
             .ToLocalChecked();
     v8::Local<v8::Value> args[] = {v8_event, listener};
-    RunFunction(add_listener_function, context, arraysize(args), args);
+    RunFunction(add_listener_function, context, base::size(args), args);
   }
 
   EXPECT_EQ(kNumListeners, event->GetNumListeners());
diff --git a/extensions/renderer/bindings/exception_handler.cc b/extensions/renderer/bindings/exception_handler.cc
index b234c36..64005cf 100644
--- a/extensions/renderer/bindings/exception_handler.cc
+++ b/extensions/renderer/bindings/exception_handler.cc
@@ -5,6 +5,7 @@
 #include "extensions/renderer/bindings/exception_handler.h"
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/supports_user_data.h"
 #include "extensions/renderer/bindings/get_per_context_data.h"
@@ -77,7 +78,7 @@
     v8::TryCatch handler_try_catch(isolate);
     handler_try_catch.SetVerbose(true);
     JSRunner::Get(context)->RunJSFunction(handler, context,
-                                          arraysize(arguments), arguments);
+                                          base::size(arguments), arguments);
   } else {
     add_console_error_.Run(context, full_message);
   }
diff --git a/extensions/renderer/declarative_content_hooks_delegate.cc b/extensions/renderer/declarative_content_hooks_delegate.cc
index 4a43581..f747987 100644
--- a/extensions/renderer/declarative_content_hooks_delegate.cc
+++ b/extensions/renderer/declarative_content_hooks_delegate.cc
@@ -5,6 +5,7 @@
 #include "extensions/renderer/declarative_content_hooks_delegate.h"
 
 #include "base/bind.h"
+#include "base/stl_util.h"
 #include "extensions/common/api/declarative/declarative_constants.h"
 #include "extensions/renderer/bindings/api_type_reference_map.h"
 #include "extensions/renderer/bindings/argument_spec.h"
@@ -171,7 +172,7 @@
       {declarative_content_constants::kRequestContentScript,
        "RequestContentScript"},
   };
-  callbacks_.reserve(arraysize(kTypes));
+  callbacks_.reserve(base::size(kTypes));
   for (const auto& type : kTypes) {
     const ArgumentSpec* spec = type_refs.GetSpec(type.full_name);
     DCHECK(spec);
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index bf256f67..9df4190 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -16,9 +16,9 @@
 #include "base/debug/alias.h"
 #include "base/feature_list.h"
 #include "base/lazy_instance.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -465,7 +465,7 @@
       // The logging module.
       logging->NewInstance(),
   };
-  context->SafeCallFunction(main_function, arraysize(args), args);
+  context->SafeCallFunction(main_function, base::size(args), args);
 
   const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time;
   UMA_HISTOGRAM_TIMES(
@@ -867,11 +867,8 @@
     std::string& error = extension_load_errors_[extension_id];
     char minidump[256];
     base::debug::Alias(&minidump);
-    base::snprintf(minidump,
-                   arraysize(minidump),
-                   "e::dispatcher:%s:%s",
-                   extension_id.c_str(),
-                   error.c_str());
+    base::snprintf(minidump, base::size(minidump), "e::dispatcher:%s:%s",
+                   extension_id.c_str(), error.c_str());
     LOG(FATAL) << extension_id << " was never loaded: " << error;
   }
 
diff --git a/extensions/renderer/event_bindings.cc b/extensions/renderer/event_bindings.cc
index 588932fb..229bb9b 100644
--- a/extensions/renderer/event_bindings.cc
+++ b/extensions/renderer/event_bindings.cc
@@ -11,6 +11,7 @@
 #include <utility>
 
 #include "base/bind.h"
+#include "base/stl_util.h"
 #include "content/public/renderer/render_frame.h"
 #include "content/public/renderer/render_thread.h"
 #include "content/public/renderer/render_view.h"
@@ -132,7 +133,7 @@
   };
 
   context->module_system()->CallModuleMethodSafe(
-      kEventBindings, "dispatchEvent", arraysize(v8_args), v8_args);
+      kEventBindings, "dispatchEvent", base::size(v8_args), v8_args);
 }
 
 void EventBindings::AttachEventHandler(
diff --git a/extensions/renderer/gin_port_unittest.cc b/extensions/renderer/gin_port_unittest.cc
index 0486fbb..2fe0a631 100644
--- a/extensions/renderer/gin_port_unittest.cc
+++ b/extensions/renderer/gin_port_unittest.cc
@@ -7,6 +7,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/optional.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "extensions/common/api/messaging/message.h"
 #include "extensions/common/api/messaging/port_id.h"
@@ -142,7 +143,7 @@
   v8::Local<v8::Function> test_function =
       FunctionFromString(context, kTestFunction);
   v8::Local<v8::Value> args[] = {port_obj};
-  RunFunctionOnGlobal(test_function, context, arraysize(args), args);
+  RunFunctionOnGlobal(test_function, context, base::size(args), args);
 
   port->DispatchOnMessage(context, Message(R"({"foo":42})", false));
 
@@ -173,7 +174,7 @@
     v8::Local<v8::Value> args[] = {port_obj};
 
     if (expected_port_id) {
-      RunFunction(v8_function, context, arraysize(args), args);
+      RunFunction(v8_function, context, base::size(args), args);
       ASSERT_TRUE(delegate()->last_port_id());
       EXPECT_EQ(*expected_port_id, delegate()->last_port_id());
       ASSERT_TRUE(delegate()->last_message());
@@ -181,7 +182,7 @@
       EXPECT_EQ(expected_message->user_gesture,
                 delegate()->last_message()->user_gesture);
     } else {
-      RunFunctionAndExpectError(v8_function, context, arraysize(args), args,
+      RunFunctionAndExpectError(v8_function, context, base::size(args), args,
                                 "Uncaught Error: Could not serialize message.");
       EXPECT_FALSE(delegate()->last_port_id());
       EXPECT_FALSE(delegate()->last_message())
@@ -246,7 +247,7 @@
     v8::Local<v8::Function> function = FunctionFromString(context, kFunction);
     v8::Local<v8::Value> args[] = {port_obj};
     RunFunctionAndExpectError(
-        function, context, arraysize(args), args,
+        function, context, base::size(args), args,
         "Uncaught Error: Attempting to use a disconnected port object");
 
     EXPECT_FALSE(delegate()->last_port_id());
@@ -276,7 +277,7 @@
   v8::Local<v8::Function> test_function =
       FunctionFromString(context, kTestFunction);
   v8::Local<v8::Value> args[] = {port_obj};
-  RunFunctionOnGlobal(test_function, context, arraysize(args), args);
+  RunFunctionOnGlobal(test_function, context, base::size(args), args);
 
   port->DispatchOnDisconnect(context);
   EXPECT_EQ("true", GetStringPropertyFromObject(context->Global(), context,
@@ -299,7 +300,7 @@
   const char kFunction[] = "(function(port) { port.disconnect(); })";
   v8::Local<v8::Function> function = FunctionFromString(context, kFunction);
   v8::Local<v8::Value> args[] = {port_obj};
-  RunFunction(function, context, arraysize(args), args);
+  RunFunction(function, context, base::size(args), args);
   ::testing::Mock::VerifyAndClearExpectations(delegate());
   EXPECT_TRUE(port->is_closed_for_testing());
 }
@@ -360,7 +361,7 @@
         get_on_disconnect_function}) {
     SCOPED_TRACE(gin::V8ToString(isolate(),
                                  function->ToString(context).ToLocalChecked()));
-    RunFunctionAndExpectError(function, context, arraysize(function_args),
+    RunFunctionAndExpectError(function, context, base::size(function_args),
                               function_args,
                               "Uncaught Error: Extension context invalidated.");
   }
diff --git a/extensions/renderer/i18n_hooks_delegate.cc b/extensions/renderer/i18n_hooks_delegate.cc
index c79d584..c70d246 100644
--- a/extensions/renderer/i18n_hooks_delegate.cc
+++ b/extensions/renderer/i18n_hooks_delegate.cc
@@ -4,6 +4,7 @@
 
 #include "extensions/renderer/i18n_hooks_delegate.h"
 
+#include "base/stl_util.h"
 #include "content/public/renderer/render_frame.h"
 #include "content/public/renderer/render_thread.h"
 #include "extensions/common/extension.h"
@@ -112,7 +113,7 @@
   v8::Local<v8::Value> callback_args[] = {detected_languages};
   JSRunner::Get(v8_context)
       ->RunJSFunction(parsed_arguments[1].As<v8::Function>(),
-                      script_context->v8_context(), arraysize(callback_args),
+                      script_context->v8_context(), base::size(callback_args),
                       callback_args);
 
   return RequestResult(RequestResult::HANDLED);
diff --git a/extensions/renderer/js_renderer_messaging_service.cc b/extensions/renderer/js_renderer_messaging_service.cc
index f8dee4f..b93ee1d 100644
--- a/extensions/renderer/js_renderer_messaging_service.cc
+++ b/extensions/renderer/js_renderer_messaging_service.cc
@@ -8,6 +8,7 @@
 
 #include <string>
 
+#include "base/stl_util.h"
 #include "content/public/common/child_process_host.h"
 #include "content/public/renderer/v8_value_converter.h"
 #include "extensions/common/api/messaging/message.h"
@@ -120,7 +121,7 @@
 
   // Note: this can execute asynchronously if JS is suspended.
   script_context->module_system()->CallModuleMethodSafe(
-      "messaging", "dispatchOnConnect", arraysize(arguments), arguments);
+      "messaging", "dispatchOnConnect", base::size(arguments), arguments);
 }
 
 void JSRendererMessagingService::DispatchOnMessageToListeners(
diff --git a/extensions/renderer/messaging_util_unittest.cc b/extensions/renderer/messaging_util_unittest.cc
index bdc08b0..3ed46522 100644
--- a/extensions/renderer/messaging_util_unittest.cc
+++ b/extensions/renderer/messaging_util_unittest.cc
@@ -6,6 +6,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "extensions/common/api/messaging/message.h"
 #include "extensions/common/extension_builder.h"
@@ -111,7 +112,7 @@
       {gin::StringToV8(isolate(), "invalid id"), base::StringPiece(), false},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Test Case: %d", static_cast<int>(i)));
     const auto& test_case = test_cases[i];
     std::string target;
@@ -146,7 +147,7 @@
       {gin::StringToV8(isolate(), "invalid id"), base::StringPiece(), false},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Test Case: %d", static_cast<int>(i)));
     const auto& test_case = test_cases[i];
     std::string target;
diff --git a/extensions/renderer/module_system.cc b/extensions/renderer/module_system.cc
index 64cfd7a..1d8a819630 100644
--- a/extensions/renderer/module_system.cc
+++ b/extensions/renderer/module_system.cc
@@ -8,8 +8,8 @@
 #include "base/command_line.h"
 #include "base/feature_list.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/timer/elapsed_timer.h"
@@ -798,7 +798,7 @@
   {
     v8::TryCatch try_catch(GetIsolate());
     try_catch.SetCaptureMessage(true);
-    context_->SafeCallFunction(func, arraysize(args), args);
+    context_->SafeCallFunction(func, base::size(args), args);
     if (try_catch.HasCaught()) {
       HandleException(try_catch);
       return v8::Undefined(GetIsolate());
diff --git a/extensions/renderer/native_extension_bindings_system_unittest.cc b/extensions/renderer/native_extension_bindings_system_unittest.cc
index 6000867..02661d1 100644
--- a/extensions/renderer/native_extension_bindings_system_unittest.cc
+++ b/extensions/renderer/native_extension_bindings_system_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "extensions/renderer/native_extension_bindings_system_test_base.h"
 
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/bind_test_util.h"
 #include "components/crx_file/id_util.h"
@@ -431,7 +432,7 @@
               SendAddUnfilteredEventListenerIPC(script_context, kEventName))
       .Times(1);
   v8::Local<v8::Value> argv[] = {listener};
-  RunFunction(add_listener, context, arraysize(argv), argv);
+  RunFunction(add_listener, context, base::size(argv), argv);
   ::testing::Mock::VerifyAndClearExpectations(ipc_message_sender());
   EXPECT_TRUE(bindings_system()->HasEventListenerInContext(
       "idle.onStateChanged", script_context));
@@ -446,7 +447,7 @@
       .Times(1);
   v8::Local<v8::Function> remove_listener =
       FunctionFromString(context, kRemoveListener);
-  RunFunction(remove_listener, context, arraysize(argv), argv);
+  RunFunction(remove_listener, context, base::size(argv), argv);
   ::testing::Mock::VerifyAndClearExpectations(ipc_message_sender());
   EXPECT_FALSE(bindings_system()->HasEventListenerInContext(
       "idle.onStateChanged", script_context));
@@ -852,7 +853,7 @@
     // Trying to run a chrome.idle function should fail.
     v8::Local<v8::Value> args[] = {initial_idle};
     RunFunctionAndExpectError(
-        run_idle, context, arraysize(args), args,
+        run_idle, context, base::size(args), args,
         "Uncaught Error: 'idle.queryState' is not available in this context.");
     EXPECT_FALSE(has_last_params());
   }
@@ -886,7 +887,7 @@
   {
     // Trying to run a chrome.idle function should now succeed.
     v8::Local<v8::Value> args[] = {initial_idle};
-    RunFunction(run_idle, context, arraysize(args), args);
+    RunFunction(run_idle, context, base::size(args), args);
     EXPECT_EQ("idle.queryState", last_params().name);
   }
 }
@@ -1123,7 +1124,7 @@
 
     v8::Context::Scope context_scope(second_context);
     v8::Local<v8::Value> args[] = {chrome};
-    RunFunction(get_idle, second_context, arraysize(args), args);
+    RunFunction(get_idle, second_context, base::size(args), args);
   }
 
   // The apiBridge should have been created in the owning (original) context,
diff --git a/extensions/renderer/native_renderer_messaging_service_unittest.cc b/extensions/renderer/native_renderer_messaging_service_unittest.cc
index 72ebee1..69a9fa6 100644
--- a/extensions/renderer/native_renderer_messaging_service_unittest.cc
+++ b/extensions/renderer/native_renderer_messaging_service_unittest.cc
@@ -6,6 +6,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "components/crx_file/id_util.h"
 #include "content/public/common/child_process_host.h"
 #include "extensions/common/extension.h"
@@ -176,14 +177,14 @@
     v8::Local<v8::Function> add_on_message_listener = FunctionFromString(
         context, base::StringPrintf(kOnMessageListenerTemplate, kPort1Message));
     v8::Local<v8::Value> args[] = {port1.ToV8()};
-    RunFunctionOnGlobal(add_on_message_listener, context, arraysize(args),
+    RunFunctionOnGlobal(add_on_message_listener, context, base::size(args),
                         args);
   }
   {
     v8::Local<v8::Function> add_on_message_listener = FunctionFromString(
         context, base::StringPrintf(kOnMessageListenerTemplate, kPort2Message));
     v8::Local<v8::Value> args[] = {port2.ToV8()};
-    RunFunctionOnGlobal(add_on_message_listener, context, arraysize(args),
+    RunFunctionOnGlobal(add_on_message_listener, context, base::size(args),
                         args);
   }
 
@@ -233,7 +234,7 @@
         context,
         base::StringPrintf(kOnDisconnectListenerTemplate, kPort1Disconnect));
     v8::Local<v8::Value> args[] = {port1.ToV8()};
-    RunFunctionOnGlobal(add_on_disconnect_listener, context, arraysize(args),
+    RunFunctionOnGlobal(add_on_disconnect_listener, context, base::size(args),
                         args);
   }
   {
@@ -241,7 +242,7 @@
         context,
         base::StringPrintf(kOnDisconnectListenerTemplate, kPort2Disconnect));
     v8::Local<v8::Value> args[] = {port2.ToV8()};
-    RunFunctionOnGlobal(add_on_disconnect_listener, context, arraysize(args),
+    RunFunctionOnGlobal(add_on_disconnect_listener, context, base::size(args),
                         args);
   }
 
@@ -282,7 +283,7 @@
   EXPECT_CALL(*ipc_message_sender(),
               SendPostMessageToPort(MSG_ROUTING_NONE, port_id,
                                     Message(R"({"data":"hello"})", false)));
-  RunFunctionOnGlobal(post_message, context, arraysize(args), args);
+  RunFunctionOnGlobal(post_message, context, base::size(args), args);
   ::testing::Mock::VerifyAndClearExpectations(ipc_message_sender());
 }
 
@@ -307,7 +308,7 @@
 
   EXPECT_CALL(*ipc_message_sender(),
               SendCloseMessagePort(MSG_ROUTING_NONE, port_id, true));
-  RunFunctionOnGlobal(post_message, context, arraysize(args), args);
+  RunFunctionOnGlobal(post_message, context, base::size(args), args);
   ::testing::Mock::VerifyAndClearExpectations(ipc_message_sender());
 }
 
diff --git a/extensions/renderer/one_time_message_handler_unittest.cc b/extensions/renderer/one_time_message_handler_unittest.cc
index dd53dd4..0a34a84 100644
--- a/extensions/renderer/one_time_message_handler_unittest.cc
+++ b/extensions/renderer/one_time_message_handler_unittest.cc
@@ -7,6 +7,7 @@
 #include <memory>
 
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "extensions/common/api/messaging/message.h"
 #include "extensions/common/api/messaging/port_id.h"
@@ -334,13 +335,13 @@
                                     Message("\"hi\"", false)));
   EXPECT_CALL(*ipc_message_sender(),
               SendCloseMessagePort(MSG_ROUTING_NONE, port_id, true));
-  RunFunction(reply.As<v8::Function>(), context, arraysize(args), args);
+  RunFunction(reply.As<v8::Function>(), context, base::size(args), args);
   ::testing::Mock::VerifyAndClearExpectations(ipc_message_sender());
   EXPECT_FALSE(message_handler()->HasPort(script_context(), port_id));
 
   // Running the reply function a second time shouldn't do anything.
   // TODO(devlin): Add an error message.
-  RunFunction(reply.As<v8::Function>(), context, arraysize(args), args);
+  RunFunction(reply.As<v8::Function>(), context, base::size(args), args);
   EXPECT_FALSE(message_handler()->HasPort(script_context(), port_id));
 }
 
diff --git a/extensions/renderer/render_frame_observer_natives.cc b/extensions/renderer/render_frame_observer_natives.cc
index 7eb7dee0..b69bdfe 100644
--- a/extensions/renderer/render_frame_observer_natives.cc
+++ b/extensions/renderer/render_frame_observer_natives.cc
@@ -6,8 +6,8 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "content/public/renderer/render_frame.h"
 #include "content/public/renderer/render_frame_observer.h"
@@ -107,7 +107,7 @@
   v8::HandleScope handle_scope(isolate);
   v8::Local<v8::Value> args[] = {v8::Boolean::New(isolate, succeeded)};
   context()->SafeCallFunction(v8::Local<v8::Function>::New(isolate, callback),
-                              arraysize(args), args);
+                              base::size(args), args);
 }
 
 }  // namespace extensions
diff --git a/extensions/renderer/runtime_hooks_delegate.cc b/extensions/renderer/runtime_hooks_delegate.cc
index cb1dbb5..2ffb208f 100644
--- a/extensions/renderer/runtime_hooks_delegate.cc
+++ b/extensions/renderer/runtime_hooks_delegate.cc
@@ -5,6 +5,7 @@
 #include "extensions/renderer/runtime_hooks_delegate.h"
 
 #include "base/containers/span.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/stringprintf.h"
 #include "content/public/renderer/render_frame.h"
@@ -78,7 +79,7 @@
           isolate, script_context->extension()->id());
   v8::Local<v8::Value> args[] = {background_page};
   script_context->SafeCallFunction(info.Data().As<v8::Function>(),
-                                   arraysize(args), args);
+                                   base::size(args), args);
 }
 
 }  // namespace
diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
index b7a941b..9f182fc 100644
--- a/extensions/renderer/script_context.cc
+++ b/extensions/renderer/script_context.cc
@@ -7,7 +7,6 @@
 #include "base/command_line.h"
 #include "base/containers/flat_set.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -365,7 +364,7 @@
           .ToLocalChecked()};
 
   module_system()->CallModuleMethodSafe("sendRequest", "handleResponse",
-                                        arraysize(argv), argv);
+                                        base::size(argv), argv);
 }
 
 bool ScriptContext::HasAPIPermission(APIPermission::ID permission) const {
diff --git a/extensions/renderer/storage_area_unittest.cc b/extensions/renderer/storage_area_unittest.cc
index 7f3c404..7b0ac76 100644
--- a/extensions/renderer/storage_area_unittest.cc
+++ b/extensions/renderer/storage_area_unittest.cc
@@ -4,6 +4,7 @@
 
 #include "extensions/renderer/storage_area.h"
 
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "extensions/common/extension_builder.h"
 #include "extensions/renderer/bindings/api_binding_test_util.h"
@@ -43,7 +44,7 @@
       FunctionFromString(context, kRunStorageGet);
   v8::Local<v8::Value> args[] = {storage_get};
   RunFunctionAndExpectError(
-      run_storage_get, context, arraysize(args), args,
+      run_storage_get, context, base::size(args), args,
       "Uncaught TypeError: Illegal invocation: Function must be called on "
       "an object of type StorageArea");
 }
@@ -71,12 +72,12 @@
   v8::Local<v8::Function> run_storage_get =
       FunctionFromString(context, kRunStorageGet);
   v8::Local<v8::Value> args[] = {storage};
-  RunFunction(run_storage_get, context, arraysize(args), args);
+  RunFunction(run_storage_get, context, base::size(args), args);
 
   DisposeContext(context);
 
   EXPECT_FALSE(binding::IsContextValid(context));
-  RunFunctionAndExpectError(run_storage_get, context, arraysize(args), args,
+  RunFunctionAndExpectError(run_storage_get, context, base::size(args), args,
                             "Uncaught Error: Extension context invalidated.");
 }
 
diff --git a/extensions/renderer/wake_event_page.cc b/extensions/renderer/wake_event_page.cc
index 731afcfd..5175e18a 100644
--- a/extensions/renderer/wake_event_page.cc
+++ b/extensions/renderer/wake_event_page.cc
@@ -12,7 +12,7 @@
 #include "base/bind_helpers.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "content/public/renderer/render_thread.h"
 #include "content/public/renderer/worker_thread.h"
 #include "extensions/common/extension_messages.h"
@@ -93,7 +93,7 @@
         v8::Boolean::New(isolate, success),
     };
     context()->SafeCallFunction(v8::Local<v8::Function>::New(isolate, callback),
-                                arraysize(args), args);
+                                base::size(args), args);
   }
 
   MakeRequestCallback make_request_;
diff --git a/extensions/renderer/web_request_hooks.cc b/extensions/renderer/web_request_hooks.cc
index f1d8238..b1f9af5 100644
--- a/extensions/renderer/web_request_hooks.cc
+++ b/extensions/renderer/web_request_hooks.cc
@@ -4,6 +4,7 @@
 
 #include "extensions/renderer/web_request_hooks.h"
 
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "content/public/renderer/v8_value_converter.h"
 #include "extensions/common/api/web_request.h"
@@ -78,7 +79,7 @@
   v8::TryCatch try_catch(isolate);
   v8::Local<v8::Value> event;
   if (!JSRunner::Get(context)
-           ->RunJSFunctionSync(get_event, context, arraysize(args), args)
+           ->RunJSFunctionSync(get_event, context, base::size(args), args)
            .ToLocal(&event)) {
     // TODO(devlin): Do we care about the error? In theory, this should never
     // happen, so probably not.
diff --git a/extensions/shell/browser/shell_content_browser_client.cc b/extensions/shell/browser/shell_content_browser_client.cc
index 0040e49c..fbe35364 100644
--- a/extensions/shell/browser/shell_content_browser_client.cc
+++ b/extensions/shell/browser/shell_content_browser_client.cc
@@ -10,7 +10,7 @@
 
 #include "base/bind.h"
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "components/guest_view/browser/guest_view_message_filter.h"
 #include "components/nacl/common/buildflags.h"
@@ -352,7 +352,7 @@
       switches::kExtensionProcess,
   };
   command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
-                                 kSwitchNames, arraysize(kSwitchNames));
+                                 kSwitchNames, base::size(kSwitchNames));
 
 #if BUILDFLAG(ENABLE_NACL)
   // NOTE: app_shell does not support non-SFI mode, so it does not pass through
@@ -361,7 +361,8 @@
       ::switches::kEnableNaClDebug,
   };
   command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
-                                 kNaclSwitchNames, arraysize(kNaclSwitchNames));
+                                 kNaclSwitchNames,
+                                 base::size(kNaclSwitchNames));
 #endif  // BUILDFLAG(ENABLE_NACL)
 }
 
diff --git a/gin/converter_unittest.cc b/gin/converter_unittest.cc
index 066cc57a..2c40462 100644
--- a/gin/converter_unittest.cc
+++ b/gin/converter_unittest.cc
@@ -9,6 +9,7 @@
 #include <stdint.h>
 
 #include "base/compiler_specific.h"
+#include "base/stl_util.h"
 #include "gin/handle.h"
 #include "gin/public/isolate_holder.h"
 #include "gin/test/v8_test.h"
@@ -65,7 +66,7 @@
       {Undefined(instance_->isolate()).As<Value>(), false},
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     bool result = false;
     EXPECT_TRUE(Converter<bool>::FromV8(instance_->isolate(),
                                         test_data[i].input, &result));
@@ -82,7 +83,7 @@
   HandleScope handle_scope(instance_->isolate());
 
   int test_data_to[] = {-1, 0, 1};
-  for (size_t i = 0; i < arraysize(test_data_to); ++i) {
+  for (size_t i = 0; i < base::size(test_data_to); ++i) {
     EXPECT_TRUE(Converter<int32_t>::ToV8(instance_->isolate(), test_data_to[i])
                     ->StrictEquals(
                           Integer::New(instance_->isolate(), test_data_to[i])));
@@ -116,7 +117,7 @@
       {v8::Undefined(instance_->isolate()).As<Value>(), false, 0},
   };
 
-  for (size_t i = 0; i < arraysize(test_data_from); ++i) {
+  for (size_t i = 0; i < base::size(test_data_from); ++i) {
     int32_t result = std::numeric_limits<int32_t>::min();
     bool success = Converter<int32_t>::FromV8(instance_->isolate(),
                                               test_data_from[i].input, &result);
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc
index bb89c27..ea051097 100644
--- a/google_apis/drive/drive_api_parser.cc
+++ b/google_apis/drive/drive_api_parser.cc
@@ -9,7 +9,7 @@
 #include <memory>
 
 #include "base/json/json_value_converter.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
@@ -685,7 +685,7 @@
 // static
 bool ChangeResource::GetType(base::StringPiece type_name,
                              ChangeResource::ChangeType* result) {
-  for (size_t i = 0; i < arraysize(kChangeTypeMap); i++) {
+  for (size_t i = 0; i < base::size(kChangeTypeMap); i++) {
     if (type_name == kChangeTypeMap[i].type_name) {
       *result = kChangeTypeMap[i].type;
       return true;
diff --git a/google_apis/drive/drive_api_url_generator_unittest.cc b/google_apis/drive/drive_api_url_generator_unittest.cc
index a80bf33..596929b 100644
--- a/google_apis/drive/drive_api_url_generator_unittest.cc
+++ b/google_apis/drive/drive_api_url_generator_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "google_apis/drive/test_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
@@ -83,7 +83,7 @@
       {true, false, "&setModifiedDate=true&updateViewedDate=false"},
   };
 
-  for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kTestPatterns); ++i) {
     EXPECT_EQ(
         "https://www.example.com/drive/v2/files/0ADK06pfg"
         "?supportsTeamDrives=true" +
@@ -163,7 +163,7 @@
       "https://www.example.com/drive/v2/files?supportsTeamDrives=true&"
       "includeTeamDriveItems=true&corpora=default%2CallTeamDrives";
 
-  for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kTestPatterns); ++i) {
     EXPECT_EQ(kV2FilesUrlPrefixWithTeamDrives +
                   (kTestPatterns[i].expected_query.empty() ? "" : "&") +
                   kTestPatterns[i].expected_query,
@@ -282,7 +282,7 @@
   const std::string kV2ChangesUrlPrefixWithTeamDrives =
       "https://www.example.com/drive/v2/changes?"
       "supportsTeamDrives=true&includeTeamDriveItems=true";
-  for (size_t i = 0; i < arraysize(kTestPatterns); ++i) {
+  for (size_t i = 0; i < base::size(kTestPatterns); ++i) {
     EXPECT_EQ(kV2ChangesUrlPrefixWithTeamDrives +
                   (kTestPatterns[i].expected_query.empty() ? "" : "&") +
                   kTestPatterns[i].expected_query,
diff --git a/google_apis/gaia/oauth2_token_service_unittest.cc b/google_apis/gaia/oauth2_token_service_unittest.cc
index 16d46b5..f570bbf 100644
--- a/google_apis/gaia/oauth2_token_service_unittest.cc
+++ b/google_apis/gaia/oauth2_token_service_unittest.cc
@@ -6,9 +6,9 @@
 
 #include <string>
 
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "google_apis/gaia/fake_oauth2_token_service_delegate.h"
 #include "google_apis/gaia/gaia_constants.h"
 #include "google_apis/gaia/gaia_urls.h"
@@ -754,8 +754,8 @@
       OAuth2TokenService::RequestParameters("1", "1", set_1),
   };
 
-  for (size_t i = 0; i < arraysize(params); i++) {
-    for (size_t j = 0; j < arraysize(params); j++) {
+  for (size_t i = 0; i < base::size(params); i++) {
+    for (size_t j = 0; j < base::size(params); j++) {
       if (i == j) {
         EXPECT_FALSE(params[i] < params[j]) << " i=" << i << ", j=" << j;
         EXPECT_FALSE(params[j] < params[i]) << " i=" << i << ", j=" << j;
diff --git a/google_apis/gcm/base/mcs_util.cc b/google_apis/gcm/base/mcs_util.cc
index 94b1122..0aea22f 100644
--- a/google_apis/gcm/base/mcs_util.cc
+++ b/google_apis/gcm/base/mcs_util.cc
@@ -8,7 +8,7 @@
 
 #include "base/format_macros.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/clock.h"
@@ -39,7 +39,7 @@
   "mcs_proto.BindAccountResponse",
   "mcs_proto.TalkMetadata"
 };
-static_assert(arraysize(kProtoNames) == kNumProtoTypes,
+static_assert(base::size(kProtoNames) == kNumProtoTypes,
               "Proto Names Must Include All Tags");
 
 const char kLoginId[] = "chrome-";
diff --git a/google_apis/gcm/base/mcs_util_unittest.cc b/google_apis/gcm/base/mcs_util_unittest.cc
index 1708943e..e3e24dc 100644
--- a/google_apis/gcm/base/mcs_util_unittest.cc
+++ b/google_apis/gcm/base/mcs_util_unittest.cc
@@ -10,8 +10,8 @@
 #include <memory>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -52,7 +52,7 @@
     kIqStanzaTag,
     kDataMessageStanzaTag
   };
-  for (size_t i = 0; i < arraysize(kTagsWithPersistentIds); ++i) {
+  for (size_t i = 0; i < base::size(kTagsWithPersistentIds); ++i) {
     int tag = kTagsWithPersistentIds[i];
     std::unique_ptr<google::protobuf::MessageLite> protobuf =
         BuildProtobufFromTag(tag);
@@ -74,7 +74,7 @@
     kHeartbeatAckTag,
     kLoginResponseTag,
   };
-  for (size_t i = 0; i < arraysize(kTagsWithStreamIds); ++i) {
+  for (size_t i = 0; i < base::size(kTagsWithStreamIds); ++i) {
     int tag = kTagsWithStreamIds[i];
     std::unique_ptr<google::protobuf::MessageLite> protobuf =
         BuildProtobufFromTag(tag);
diff --git a/google_apis/gcm/base/socket_stream_unittest.cc b/google_apis/gcm/base/socket_stream_unittest.cc
index 25b9261..949713b9 100644
--- a/google_apis/gcm/base/socket_stream_unittest.cc
+++ b/google_apis/gcm/base/socket_stream_unittest.cc
@@ -12,9 +12,9 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/test/bind_test_util.h"
 #include "base/test/scoped_task_environment.h"
@@ -35,11 +35,11 @@
 typedef std::vector<net::MockWrite> WriteList;
 
 const char kReadData[] = "read_data";
-const int kReadDataSize = arraysize(kReadData) - 1;
+const int kReadDataSize = base::size(kReadData) - 1;
 const char kReadData2[] = "read_alternate_data";
-const int kReadData2Size = arraysize(kReadData2) - 1;
+const int kReadData2Size = base::size(kReadData2) - 1;
 const char kWriteData[] = "write_data";
-const int kWriteDataSize = arraysize(kWriteData) - 1;
+const int kWriteDataSize = base::size(kWriteData) - 1;
 
 class GCMSocketStreamTest : public testing::Test {
  public:
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index b29f31f..4d2711f4 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -11,7 +11,6 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/sequenced_task_runner.h"
 #include "base/stl_util.h"
@@ -123,7 +122,7 @@
 }
 
 std::string ParseRegistrationKey(const std::string& key) {
-  return key.substr(arraysize(kRegistrationKeyStart) - 1);
+  return key.substr(base::size(kRegistrationKeyStart) - 1);
 }
 
 std::string MakeIncomingKey(const std::string& persistent_id) {
@@ -135,7 +134,7 @@
 }
 
 std::string ParseOutgoingKey(const std::string& key) {
-  return key.substr(arraysize(kOutgoingMsgKeyStart) - 1);
+  return key.substr(base::size(kOutgoingMsgKeyStart) - 1);
 }
 
 std::string MakeGServiceSettingKey(const std::string& setting_name) {
@@ -143,7 +142,7 @@
 }
 
 std::string ParseGServiceSettingKey(const std::string& key) {
-  return key.substr(arraysize(kGServiceSettingKeyStart) - 1);
+  return key.substr(base::size(kGServiceSettingKeyStart) - 1);
 }
 
 std::string MakeAccountKey(const std::string& account_id) {
@@ -151,7 +150,7 @@
 }
 
 std::string ParseAccountKey(const std::string& key) {
-  return key.substr(arraysize(kAccountKeyStart) - 1);
+  return key.substr(base::size(kAccountKeyStart) - 1);
 }
 
 std::string MakeHeartbeatKey(const std::string& scope) {
@@ -159,7 +158,7 @@
 }
 
 std::string ParseHeartbeatKey(const std::string& key) {
-  return key.substr(arraysize(kHeartbeatKeyStart) - 1);
+  return key.substr(base::size(kHeartbeatKeyStart) - 1);
 }
 
 std::string MakeInstanceIDKey(const std::string& app_id) {
@@ -167,7 +166,7 @@
 }
 
 std::string ParseInstanceIDKey(const std::string& key) {
-  return key.substr(arraysize(kInstanceIDKeyStart) - 1);
+  return key.substr(base::size(kInstanceIDKeyStart) - 1);
 }
 
 // Note: leveldb::Slice keeps a pointer to the data in |s|, which must therefore
diff --git a/google_apis/gcm/engine/gcm_unregistration_request_handler.cc b/google_apis/gcm/engine/gcm_unregistration_request_handler.cc
index 92ca1460..8374981 100644
--- a/google_apis/gcm/engine/gcm_unregistration_request_handler.cc
+++ b/google_apis/gcm/engine/gcm_unregistration_request_handler.cc
@@ -4,8 +4,8 @@
 
 #include "google_apis/gcm/engine/gcm_unregistration_request_handler.h"
 
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "google_apis/gcm/base/gcm_util.h"
 #include "net/url_request/url_fetcher.h"
 
@@ -40,7 +40,7 @@
   DVLOG(1) << "Parsing unregistration response.";
   if (response.find(kDeletedPrefix) != std::string::npos) {
     std::string deleted_app_id = response.substr(
-        response.find(kDeletedPrefix) + arraysize(kDeletedPrefix) - 1);
+        response.find(kDeletedPrefix) + base::size(kDeletedPrefix) - 1);
     return deleted_app_id == app_id_ ?
         UnregistrationRequest::SUCCESS :
         UnregistrationRequest::INCORRECT_APP_ID;
diff --git a/google_apis/gcm/engine/gservices_settings.cc b/google_apis/gcm/engine/gservices_settings.cc
index d66e576c..d5fef7f 100644
--- a/google_apis/gcm/engine/gservices_settings.cc
+++ b/google_apis/gcm/engine/gservices_settings.cc
@@ -8,8 +8,8 @@
 
 #include "base/bind.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/sha1.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -230,7 +230,7 @@
     if (settings_diff && base::StartsWith(name, kDeleteSettingPrefix,
                                           base::CompareCase::SENSITIVE)) {
       std::string setting_to_delete =
-          name.substr(arraysize(kDeleteSettingPrefix) - 1);
+          name.substr(base::size(kDeleteSettingPrefix) - 1);
       new_settings.erase(setting_to_delete);
       DVLOG(1) << "Setting deleted: " << setting_to_delete;
     } else {
diff --git a/google_apis/gcm/engine/registration_request.cc b/google_apis/gcm/engine/registration_request.cc
index 455bbb28..adece69c 100644
--- a/google_apis/gcm/engine/registration_request.cc
+++ b/google_apis/gcm/engine/registration_request.cc
@@ -9,8 +9,8 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/metrics/histogram.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
@@ -256,8 +256,8 @@
   // some errors will have HTTP_OK response code!
   size_t error_pos = response.find(kErrorPrefix);
   if (error_pos != std::string::npos) {
-    std::string error = response.substr(
-        error_pos + arraysize(kErrorPrefix) - 1);
+    std::string error =
+        response.substr(error_pos + base::size(kErrorPrefix) - 1);
     DVLOG(1) << "Registration response error message: " << error;
     return GetStatusFromError(error);
   }
@@ -278,7 +278,7 @@
 
   size_t token_pos = response.find(kTokenPrefix);
   if (token_pos != std::string::npos) {
-    *token = response.substr(token_pos + arraysize(kTokenPrefix) - 1);
+    *token = response.substr(token_pos + base::size(kTokenPrefix) - 1);
     return SUCCESS;
   }
 
diff --git a/google_apis/gcm/engine/unregistration_request.cc b/google_apis/gcm/engine/unregistration_request.cc
index 21a6dd7..b9ff85b 100644
--- a/google_apis/gcm/engine/unregistration_request.cc
+++ b/google_apis/gcm/engine/unregistration_request.cc
@@ -8,6 +8,7 @@
 
 #include "base/bind.h"
 #include "base/location.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -217,7 +218,7 @@
   // some errors will have HTTP_OK response code!
   if (response.find(kErrorPrefix) != std::string::npos) {
     std::string error = response.substr(response.find(kErrorPrefix) +
-                                        arraysize(kErrorPrefix) - 1);
+                                        base::size(kErrorPrefix) - 1);
     DVLOG(1) << "Unregistration response error message: " << error;
     return GetStatusFromError(error);
   }
diff --git a/google_apis/google_api_keys_unittest.cc b/google_apis/google_api_keys_unittest.cc
index d334db5..77c3c84 100644
--- a/google_apis/google_api_keys_unittest.cc
+++ b/google_apis/google_api_keys_unittest.cc
@@ -12,7 +12,7 @@
 
 #include "google_apis/google_api_keys_unittest.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "google_apis/gaia/gaia_switches.h"
 
@@ -64,7 +64,7 @@
 void GoogleAPIKeysTest::SetUp() {
   // Unset all environment variables that can affect these tests,
   // for the duration of the tests.
-  for (size_t i = 0; i < arraysize(env_cache_); ++i) {
+  for (size_t i = 0; i < base::size(env_cache_); ++i) {
     EnvironmentCache& cache = env_cache_[i];
     cache.was_set = env_->HasVar(cache.variable_name);
     cache.value.clear();
@@ -77,7 +77,7 @@
 
 void GoogleAPIKeysTest::TearDown() {
   // Restore environment.
-  for (size_t i = 0; i < arraysize(env_cache_); ++i) {
+  for (size_t i = 0; i < base::size(env_cache_); ++i) {
     EnvironmentCache& cache = env_cache_[i];
     if (cache.was_set) {
       env_->SetVar(cache.variable_name, cache.value);
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc
index b09114e..dd1ef9d 100644
--- a/gpu/command_buffer/client/gles2_implementation.cc
+++ b/gpu/command_buffer/client/gles2_implementation.cc
@@ -13,16 +13,19 @@
 #include <GLES3/gl31.h>
 #include <stddef.h>
 #include <stdint.h>
+
 #include <algorithm>
 #include <map>
 #include <set>
 #include <sstream>
 #include <string>
+
 #include "base/atomic_sequence_num.h"
 #include "base/bits.h"
 #include "base/compiler_specific.h"
 #include "base/containers/span.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/stringprintf.h"
 #include "base/system/sys_info.h"
@@ -275,7 +278,7 @@
 
   if (support_client_side_arrays_) {
     GetIdHandler(SharedIdNamespaces::kBuffers)
-        ->MakeIds(this, kClientSideArrayId, arraysize(reserved_ids_),
+        ->MakeIds(this, kClientSideArrayId, base::size(reserved_ids_),
                   &reserved_ids_[0]);
   }
 
@@ -309,7 +312,7 @@
   // GLES2Implementation::Initialize() could fail before allocating
   // reserved_ids_, so we need delete them carefully.
   if (support_client_side_arrays_ && reserved_ids_[0]) {
-    DeleteBuffers(arraysize(reserved_ids_), &reserved_ids_[0]);
+    DeleteBuffers(base::size(reserved_ids_), &reserved_ids_[0]);
   }
 
   // Release remaining BufferRange mem; This is when a MapBufferRange() is
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index bedd663..c4e1a10 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -17,6 +17,7 @@
 #include <memory>
 
 #include "base/compiler_specific.h"
+#include "base/stl_util.h"
 #include "gpu/command_buffer/client/client_test_helper.h"
 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
 #include "gpu/command_buffer/client/mock_transfer_buffer.h"
@@ -852,9 +853,9 @@
   const GLint kFirst = 1;
   const GLsizei kCount = 2;
   const GLsizei kSize1 =
-      arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents1 * sizeof(verts[0][0]);
   const GLsizei kSize2 =
-      arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents2 * sizeof(verts[0][0]);
   const GLsizei kEmuOffset1 = 0;
   const GLsizei kEmuOffset2 = kSize1;
   const GLsizei kTotalSize = kSize1 + kSize2;
@@ -920,7 +921,7 @@
   const GLsizei kCount = 2;
   const GLuint kDivisor = 1;
   const GLsizei kSize1 =
-      arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents1 * sizeof(verts[0][0]);
   const GLsizei kSize2 =
       1 * kNumComponents2 * sizeof(verts[0][0]);
   const GLsizei kEmuOffset1 = 0;
@@ -998,9 +999,9 @@
   const GLsizei kClientStride = sizeof(verts[0]);
   const GLsizei kCount = 2;
   const GLsizei kSize1 =
-      arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents1 * sizeof(verts[0][0]);
   const GLsizei kSize2 =
-      arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents2 * sizeof(verts[0][0]);
   const GLsizei kEmuOffset1 = 0;
   const GLsizei kEmuOffset2 = kSize1;
   const GLsizei kTotalSize = kSize1 + kSize2;
@@ -1082,9 +1083,9 @@
   const GLsizei kClientStride = sizeof(verts[0]);
   const GLsizei kCount = 2;
   const GLsizei kSize1 =
-      arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents1 * sizeof(verts[0][0]);
   const GLsizei kSize2 =
-      arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents2 * sizeof(verts[0][0]);
   const GLsizei kEmuOffset1 = 0;
   const GLsizei kEmuOffset2 = kSize1;
   const GLsizei kTotalSize = kSize1 + kSize2;
@@ -1191,9 +1192,9 @@
   const GLsizei kClientStride = sizeof(verts[0]);
   const GLsizei kCount = 2;
   const GLsizei kSize1 =
-      arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents1 * sizeof(verts[0][0]);
   const GLsizei kSize2 =
-      arraysize(verts) * kNumComponents2 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents2 * sizeof(verts[0][0]);
   const GLsizei kEmuOffset1 = 0;
   const GLsizei kEmuOffset2 = kSize1;
   const GLsizei kTotalSize = kSize1 + kSize2;
@@ -1280,7 +1281,7 @@
   const GLsizei kClientStride = sizeof(verts[0]);
   const GLsizei kCount = 2;
   const GLsizei kSize1 =
-      arraysize(verts) * kNumComponents1 * sizeof(verts[0][0]);
+      base::size(verts) * kNumComponents1 * sizeof(verts[0][0]);
   const GLsizei kSize2 =
       1 * kNumComponents2 * sizeof(verts[0][0]);
   const GLuint kDivisor = 1;
@@ -2372,7 +2373,7 @@
   }
 
   for (int sub = 0; sub < 2; ++sub) {
-    for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
+    for (size_t a = 0; a < base::size(unpack_alignments); ++a) {
       const void* commands = GetPut();
 
       GLint alignment = unpack_alignments[a];
@@ -2513,7 +2514,7 @@
   }
 
   for (int sub = 0; sub < 2; ++sub) {
-    for (size_t a = 0; a < arraysize(unpack_alignments); ++a) {
+    for (size_t a = 0; a < base::size(unpack_alignments); ++a) {
       const void* commands = GetPut();
 
       GLint alignment = unpack_alignments[a];
@@ -2674,11 +2675,10 @@
   // to (runtime-detected) compression formats. Try to infer the error with an
   // aux check.
   const GLenum kCompressedFormat = GL_ETC1_RGB8_OES;
-  gl_->CompressedTexImage2D(
-      kTarget, kLevel, kCompressedFormat, kWidth, kHeight, kBorder,
-      arraysize(pixels), pixels);
+  gl_->CompressedTexImage2D(kTarget, kLevel, kCompressedFormat, kWidth, kHeight,
+                            kBorder, base::size(pixels), pixels);
 
-  // In the above, kCompressedFormat and arraysize(pixels) are possibly wrong
+  // In the above, kCompressedFormat and base::size(pixels) are possibly wrong
   // values. First ensure that these do not cause failures at the client. If
   // this check ever fails, it probably means that client checks more than at
   // the time of writing of this test. In this case, more code needs to be
@@ -2689,9 +2689,8 @@
 
   // Changing border to invalid border should make the call fail at the client
   // checks.
-  gl_->CompressedTexImage2D(
-      kTarget, kLevel, kCompressedFormat, kWidth, kHeight, kInvalidBorder,
-      arraysize(pixels), pixels);
+  gl_->CompressedTexImage2D(kTarget, kLevel, kCompressedFormat, kWidth, kHeight,
+                            kInvalidBorder, base::size(pixels), pixels);
   EXPECT_TRUE(NoCommandsWritten());
   EXPECT_EQ(GL_INVALID_VALUE, CheckError());
 }
@@ -3073,15 +3072,15 @@
   ExpectedMemoryInfo mem2 = GetExpectedMemory(kUsableSize);
 
   Cmds expected;
-  expected.set_size.Init(
-      GL_ARRAY_BUFFER, arraysize(buf), 0, 0, GL_DYNAMIC_DRAW);
+  expected.set_size.Init(GL_ARRAY_BUFFER, base::size(buf), 0, 0,
+                         GL_DYNAMIC_DRAW);
   expected.copy_data1.Init(
       GL_ARRAY_BUFFER, 0, kUsableSize, mem1.id, mem1.offset);
   expected.set_token1.Init(GetNextToken());
   expected.copy_data2.Init(
       GL_ARRAY_BUFFER, kUsableSize, kUsableSize, mem2.id, mem2.offset);
   expected.set_token2.Init(GetNextToken());
-  gl_->BufferData(GL_ARRAY_BUFFER, arraysize(buf), buf, GL_DYNAMIC_DRAW);
+  gl_->BufferData(GL_ARRAY_BUFFER, base::size(buf), buf, GL_DYNAMIC_DRAW);
   EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
 }
 
@@ -3102,7 +3101,7 @@
   };
   Cmds expected;
 
-  for (size_t ii = 0; ii < arraysize(kStates); ++ii) {
+  for (size_t ii = 0; ii < base::size(kStates); ++ii) {
     GLenum state = kStates[ii];
     expected.enable_cmd.Init(state);
     GLboolean result = gl_->IsEnabled(state);
@@ -3151,9 +3150,11 @@
     GLuint data[2];
   };
   GenCmds expected_gen_cmds;
-  expected_gen_cmds.gen.Init(arraysize(expected_ids), &expected_ids[0]);
-  GLuint ids[arraysize(expected_ids)] = { 0, };
-  gl_->GenQueriesEXT(arraysize(expected_ids), &ids[0]);
+  expected_gen_cmds.gen.Init(base::size(expected_ids), &expected_ids[0]);
+  GLuint ids[base::size(expected_ids)] = {
+      0,
+  };
+  gl_->GenQueriesEXT(base::size(expected_ids), &ids[0]);
   EXPECT_EQ(0, memcmp(
       &expected_gen_cmds, commands_, sizeof(expected_gen_cmds)));
   GLuint id1 = ids[0];
@@ -3338,9 +3339,11 @@
     GLuint data[2];
   };
   GenCmds expected_gen_cmds;
-  expected_gen_cmds.gen.Init(arraysize(expected_ids), &expected_ids[0]);
-  GLuint ids[arraysize(expected_ids)] = { 0, };
-  gl_->GenQueriesEXT(arraysize(expected_ids), &ids[0]);
+  expected_gen_cmds.gen.Init(base::size(expected_ids), &expected_ids[0]);
+  GLuint ids[base::size(expected_ids)] = {
+      0,
+  };
+  gl_->GenQueriesEXT(base::size(expected_ids), &ids[0]);
   EXPECT_EQ(0, memcmp(
       &expected_gen_cmds, commands_, sizeof(expected_gen_cmds)));
   GLuint id1 = ids[0];
@@ -3882,7 +3885,7 @@
   EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(sync_token))
       .WillOnce(Return(true));
   EXPECT_CALL(*gpu_control_, EnsureWorkVisible());
-  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
+  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, base::size(sync_token_datas));
   EXPECT_TRUE(NoCommandsWritten());
   EXPECT_EQ(GL_NO_ERROR, CheckError());
 
@@ -3939,7 +3942,7 @@
       .InSequence(sequence)
       .WillOnce(Return(true));
   EXPECT_CALL(*gpu_control_, EnsureWorkVisible()).InSequence(sequence);
-  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
+  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, base::size(sync_token_datas));
   EXPECT_EQ(GL_NO_ERROR, CheckError());
 
   EXPECT_TRUE(sync_token1.verified_flush());
@@ -3962,7 +3965,7 @@
   // Ensure proper sequence of checking and validating.
   EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)).Times(0);
   EXPECT_CALL(*gpu_control_, EnsureWorkVisible()).Times(0);
-  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
+  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, base::size(sync_token_datas));
   EXPECT_TRUE(NoCommandsWritten());
   EXPECT_EQ(GL_NO_ERROR, CheckError());
 
diff --git a/gpu/command_buffer/client/program_info_manager_unittest.cc b/gpu/command_buffer/client/program_info_manager_unittest.cc
index 302dc19..c533d99d 100644
--- a/gpu/command_buffer/client/program_info_manager_unittest.cc
+++ b/gpu/command_buffer/client/program_info_manager_unittest.cc
@@ -7,6 +7,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/client/program_info_manager.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -100,8 +101,8 @@
     data->uniform_loc0[0] = 1;
     data->uniform_loc1[0] = 2;
     data->uniform_loc1[1] = 3;
-    memcpy(data->uniform_name0, kName[0], arraysize(data->uniform_name0));
-    memcpy(data->uniform_name1, kName[1], arraysize(data->uniform_name1));
+    memcpy(data->uniform_name0, kName[0], base::size(data->uniform_name0));
+    memcpy(data->uniform_name1, kName[1], base::size(data->uniform_name1));
   }
 
   void SetupUniformBlocksData(UniformBlocksData* data) {
@@ -115,23 +116,23 @@
     data->entry[0].binding = 0;
     data->entry[0].data_size = 8;
     data->entry[0].name_offset = ComputeOffset(data, data->name0);
-    data->entry[0].name_length = arraysize(data->name0);
-    data->entry[0].active_uniforms = arraysize(data->indices0);
+    data->entry[0].name_length = base::size(data->name0);
+    data->entry[0].active_uniforms = base::size(data->indices0);
     data->entry[0].active_uniform_offset = ComputeOffset(data, data->indices0);
     data->entry[0].referenced_by_vertex_shader = static_cast<uint32_t>(true);
     data->entry[0].referenced_by_fragment_shader = static_cast<uint32_t>(false);
     data->entry[1].binding = 1;
     data->entry[1].data_size = 4;
     data->entry[1].name_offset = ComputeOffset(data, data->name1);
-    data->entry[1].name_length = arraysize(data->name1);
-    data->entry[1].active_uniforms = arraysize(data->indices1);
+    data->entry[1].name_length = base::size(data->name1);
+    data->entry[1].active_uniforms = base::size(data->indices1);
     data->entry[1].active_uniform_offset = ComputeOffset(data, data->indices1);
     data->entry[1].referenced_by_vertex_shader = static_cast<uint32_t>(false);
     data->entry[1].referenced_by_fragment_shader = static_cast<uint32_t>(true);
-    memcpy(data->name0, kName[0], arraysize(data->name0));
+    memcpy(data->name0, kName[0], base::size(data->name0));
     data->indices0[0] = kIndices[0][0];
     data->indices0[1] = kIndices[0][1];
-    memcpy(data->name1, kName[1], arraysize(data->name1));
+    memcpy(data->name1, kName[1], base::size(data->name1));
     data->indices1[0] = kIndices[1][0];
   }
 
@@ -158,13 +159,13 @@
     data->entry[0].size = 1;
     data->entry[0].type = GL_FLOAT_VEC2;
     data->entry[0].name_offset = ComputeOffset(data, data->name0);
-    data->entry[0].name_length = arraysize(data->name0);
+    data->entry[0].name_length = base::size(data->name0);
     data->entry[1].size = 2;
     data->entry[1].type = GL_FLOAT;
     data->entry[1].name_offset = ComputeOffset(data, data->name1);
-    data->entry[1].name_length = arraysize(data->name1);
-    memcpy(data->name0, kName[0], arraysize(data->name0));
-    memcpy(data->name1, kName[1], arraysize(data->name1));
+    data->entry[1].name_length = base::size(data->name1);
+    memcpy(data->name0, kName[0], base::size(data->name0));
+    memcpy(data->name1, kName[1], base::size(data->name1));
   }
 
   std::unique_ptr<ProgramInfoManager> program_info_manager_;
diff --git a/gpu/command_buffer/client/query_tracker_unittest.cc b/gpu/command_buffer/client/query_tracker_unittest.cc
index 01a1460..a43c9519 100644
--- a/gpu/command_buffer/client/query_tracker_unittest.cc
+++ b/gpu/command_buffer/client/query_tracker_unittest.cc
@@ -13,6 +13,7 @@
 #include <memory>
 #include <vector>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/client/client_test_helper.h"
 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
 #include "gpu/command_buffer/client/mapped_memory.h"
@@ -59,7 +60,7 @@
   QuerySyncManager::QueryInfo infos[4];
   memset(&infos, 0xBD, sizeof(infos));
 
-  for (size_t ii = 0; ii < arraysize(infos); ++ii) {
+  for (size_t ii = 0; ii < base::size(infos); ++ii) {
     EXPECT_TRUE(sync_manager_->Alloc(&infos[ii]));
     ASSERT_TRUE(infos[ii].sync != nullptr);
     EXPECT_EQ(0, infos[ii].sync->process_count);
@@ -67,7 +68,7 @@
     EXPECT_EQ(0, infos[ii].submit_count);
   }
 
-  for (size_t ii = 0; ii < arraysize(infos); ++ii) {
+  for (size_t ii = 0; ii < base::size(infos); ++ii) {
     sync_manager_->Free(infos[ii]);
   }
 }
@@ -76,7 +77,7 @@
   QuerySyncManager::QueryInfo infos[4];
   memset(&infos, 0xBD, sizeof(infos));
 
-  for (size_t ii = 0; ii < arraysize(infos); ++ii) {
+  for (size_t ii = 0; ii < base::size(infos); ++ii) {
     EXPECT_TRUE(sync_manager_->Alloc(&infos[ii]));
   }
 }
diff --git a/gpu/command_buffer/client/raster_implementation_unittest.cc b/gpu/command_buffer/client/raster_implementation_unittest.cc
index d75d844..385c158 100644
--- a/gpu/command_buffer/client/raster_implementation_unittest.cc
+++ b/gpu/command_buffer/client/raster_implementation_unittest.cc
@@ -15,6 +15,7 @@
 #include <memory>
 
 #include "base/compiler_specific.h"
+#include "base/stl_util.h"
 #include "cc/paint/raw_memory_transfer_cache_entry.h"
 #include "cc/paint/transfer_cache_serialize_helper.h"
 #include "gpu/command_buffer/client/client_test_helper.h"
@@ -404,11 +405,11 @@
     GLuint data[2];
   };
   GenCmds expected_gen_cmds;
-  expected_gen_cmds.gen.Init(arraysize(expected_ids), &expected_ids[0]);
-  GLuint ids[arraysize(expected_ids)] = {
+  expected_gen_cmds.gen.Init(base::size(expected_ids), &expected_ids[0]);
+  GLuint ids[base::size(expected_ids)] = {
       0,
   };
-  gl_->GenQueriesEXT(arraysize(expected_ids), &ids[0]);
+  gl_->GenQueriesEXT(base::size(expected_ids), &ids[0]);
   EXPECT_EQ(0,
             memcmp(&expected_gen_cmds, commands_, sizeof(expected_gen_cmds)));
   GLuint id1 = ids[0];
@@ -613,7 +614,7 @@
   EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(sync_token))
       .WillOnce(Return(true));
   EXPECT_CALL(*gpu_control_, EnsureWorkVisible());
-  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
+  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, base::size(sync_token_datas));
   EXPECT_TRUE(NoCommandsWritten());
   EXPECT_EQ(GL_NO_ERROR, CheckError());
 
@@ -670,7 +671,7 @@
       .InSequence(sequence)
       .WillOnce(Return(true));
   EXPECT_CALL(*gpu_control_, EnsureWorkVisible()).InSequence(sequence);
-  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
+  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, base::size(sync_token_datas));
   EXPECT_EQ(GL_NO_ERROR, CheckError());
 
   EXPECT_TRUE(sync_token1.verified_flush());
@@ -693,7 +694,7 @@
   // Ensure proper sequence of checking and validating.
   EXPECT_CALL(*gpu_control_, CanWaitUnverifiedSyncToken(_)).Times(0);
   EXPECT_CALL(*gpu_control_, EnsureWorkVisible()).Times(0);
-  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, arraysize(sync_token_datas));
+  gl_->VerifySyncTokensCHROMIUM(sync_token_datas, base::size(sync_token_datas));
   EXPECT_TRUE(NoCommandsWritten());
   EXPECT_EQ(GL_NO_ERROR, CheckError());
 
diff --git a/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc b/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc
index 7e1f2ef..b532ef7 100644
--- a/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc
+++ b/gpu/command_buffer/client/vertex_array_object_manager_unittest.cc
@@ -12,6 +12,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace gpu {
@@ -81,9 +82,9 @@
   const GLuint kElementArray = 789;
   bool changed = false;
   GLuint ids[2] = { 1, 3, };
-  manager_->GenVertexArrays(arraysize(ids), ids);
+  manager_->GenVertexArrays(base::size(ids), ids);
   // Bind buffers to attribs on 2 vaos.
-  for (size_t ii = 0; ii < arraysize(ids); ++ii) {
+  for (size_t ii = 0; ii < base::size(ids); ++ii) {
     EXPECT_TRUE(manager_->BindVertexArray(ids[ii], &changed));
     EXPECT_TRUE(manager_->SetAttribPointer(
         kBufferToUnbind, 0, 4, GL_FLOAT, false, 0, 0, GL_FALSE));
@@ -117,7 +118,7 @@
   static const GLuint expected_element_array[] = {
     0, kElementArray,
   };
-  for (size_t ii = 0; ii < arraysize(ids); ++ii) {
+  for (size_t ii = 0; ii < base::size(ids); ++ii) {
     EXPECT_TRUE(manager_->BindVertexArray(ids[ii], &changed));
     for (size_t jj = 0; jj < 4; ++jj) {
       uint32_t param = 1;
@@ -200,7 +201,7 @@
 TEST_F(VertexArrayObjectManagerTest, BindElementArray) {
   bool changed = false;
   GLuint ids[2] = { 1, 3, };
-  manager_->GenVertexArrays(arraysize(ids), ids);
+  manager_->GenVertexArrays(base::size(ids), ids);
 
   // Check the default element array is 0.
   EXPECT_EQ(0u, manager_->bound_element_array_buffer());
@@ -240,7 +241,7 @@
   EXPECT_FALSE(changed);
 
   GLuint ids[2] = { 1, 3, };
-  manager_->GenVertexArrays(arraysize(ids), ids);
+  manager_->GenVertexArrays(base::size(ids), ids);
   // Check Genned arrays succeed.
   EXPECT_TRUE(manager_->BindVertexArray(1, &changed));
   EXPECT_TRUE(changed);
diff --git a/gpu/command_buffer/common/gles2_cmd_format.cc b/gpu/command_buffer/common/gles2_cmd_format.cc
index a5ba131..6371553 100644
--- a/gpu/command_buffer/common/gles2_cmd_format.cc
+++ b/gpu/command_buffer/common/gles2_cmd_format.cc
@@ -7,13 +7,16 @@
 
 // We explicitly do NOT include gles2_cmd_format.h here because client side
 // and service side have different requirements.
+
 #include "gpu/command_buffer/common/cmd_buffer_common.h"
 
+#include <stddef.h>
+
+#include "base/stl_util.h"
+
 namespace gpu {
 namespace gles2 {
 
-#include <stddef.h>
-
 #include "gpu/command_buffer/common/gles2_cmd_ids_autogen.h"
 
 const char* GetCommandName(CommandId id) {
@@ -26,7 +29,7 @@
   };
 
   size_t index = static_cast<size_t>(id) - kFirstGLES2Command;
-  return (index < arraysize(names)) ?  names[index] : "*unknown-command*";
+  return (index < base::size(names)) ? names[index] : "*unknown-command*";
 }
 
 }  // namespace gles2
diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
index 6e258666..7c7a455 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils.cc
+++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
@@ -1584,8 +1584,8 @@
   static EnumToString string_table[] = {
     { GL_NONE, "GL_NONE" },
   };
-  return GLES2Util::GetQualifiedEnumString(
-      string_table, arraysize(string_table), value);
+  return GLES2Util::GetQualifiedEnumString(string_table,
+                                           base::size(string_table), value);
 }
 
 std::string GLES2Util::GetStringBool(uint32_t value) {
diff --git a/gpu/command_buffer/common/mailbox.cc b/gpu/command_buffer/common/mailbox.cc
index fdec1e6..7681b4e 100644
--- a/gpu/command_buffer/common/mailbox.cc
+++ b/gpu/command_buffer/common/mailbox.cc
@@ -10,6 +10,7 @@
 
 #include "base/logging.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 
 namespace gpu {
@@ -19,7 +20,7 @@
 }
 
 bool Mailbox::IsZero() const {
-  for (size_t i = 0; i < arraysize(name); ++i) {
+  for (size_t i = 0; i < base::size(name); ++i) {
     if (name[i])
       return false;
   }
diff --git a/gpu/command_buffer/common/raster_cmd_format.cc b/gpu/command_buffer/common/raster_cmd_format.cc
index 1a21bed5..6729d13c 100644
--- a/gpu/command_buffer/common/raster_cmd_format.cc
+++ b/gpu/command_buffer/common/raster_cmd_format.cc
@@ -9,11 +9,13 @@
 // and service side have different requirements.
 #include "gpu/command_buffer/common/cmd_buffer_common.h"
 
+#include <stddef.h>
+
+#include "base/stl_util.h"
+
 namespace gpu {
 namespace raster {
 
-#include <stddef.h>
-
 #include "gpu/command_buffer/common/raster_cmd_ids_autogen.h"
 
 const char* GetCommandName(CommandId id) {
@@ -26,7 +28,7 @@
   };
 
   size_t index = static_cast<size_t>(id) - kFirstRasterCommand;
-  return (index < arraysize(names)) ? names[index] : "*unknown-command*";
+  return (index < base::size(names)) ? names[index] : "*unknown-command*";
 }
 
 }  // namespace raster
diff --git a/gpu/command_buffer/service/buffer_manager_unittest.cc b/gpu/command_buffer/service/buffer_manager_unittest.cc
index 43ad1aa..02a839e 100644
--- a/gpu/command_buffer/service/buffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/buffer_manager_unittest.cc
@@ -7,6 +7,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/service/buffer_manager.h"
 #include "gpu/command_buffer/service/error_state_mock.h"
 #include "gpu/command_buffer/service/feature_info.h"
@@ -526,7 +527,7 @@
       GL_TRANSFORM_FEEDBACK_BUFFER,
       GL_UNIFORM_BUFFER
     };
-    for (size_t ii = 0; ii < arraysize(kTargets); ++ii) {
+    for (size_t ii = 0; ii < base::size(kTargets); ++ii) {
       client_id++;
       service_id++;
       manager_->CreateBuffer(client_id, service_id);
@@ -534,7 +535,7 @@
       ASSERT_TRUE(buffer != nullptr);
 
       EXPECT_TRUE(manager_->SetTarget(buffer, kTargets[ii]));
-      for (size_t jj = 0; jj < arraysize(kTargets); ++jj) {
+      for (size_t jj = 0; jj < base::size(kTargets); ++jj) {
         EXPECT_TRUE(manager_->SetTarget(buffer, kTargets[jj]));
       }
       EXPECT_EQ(kTargets[ii], GetInitialTarget(buffer));
@@ -553,7 +554,7 @@
       GL_TRANSFORM_FEEDBACK_BUFFER,
       GL_UNIFORM_BUFFER
     };
-    for (size_t ii = 0; ii < arraysize(kTargets); ++ii) {
+    for (size_t ii = 0; ii < base::size(kTargets); ++ii) {
       client_id++;
       service_id++;
       manager_->CreateBuffer(client_id, service_id);
@@ -561,7 +562,7 @@
       ASSERT_TRUE(buffer != nullptr);
 
       EXPECT_TRUE(manager_->SetTarget(buffer, kTargets[ii]));
-      for (size_t jj = 0; jj < arraysize(kTargets); ++jj) {
+      for (size_t jj = 0; jj < base::size(kTargets); ++jj) {
         EXPECT_TRUE(manager_->SetTarget(buffer, kTargets[jj]));
       }
     }
diff --git a/gpu/command_buffer/service/common_decoder.cc b/gpu/command_buffer/service/common_decoder.cc
index 7cafcc4..0a02d3f 100644
--- a/gpu/command_buffer/service/common_decoder.cc
+++ b/gpu/command_buffer/service/common_decoder.cc
@@ -10,6 +10,7 @@
 #include <algorithm>
 
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "gpu/command_buffer/service/command_buffer_service.h"
 
 namespace gpu {
@@ -212,7 +213,7 @@
 error::Error CommonDecoder::DoCommonCommand(unsigned int command,
                                             unsigned int arg_count,
                                             const volatile void* cmd_data) {
-  if (command < arraysize(command_info)) {
+  if (command < base::size(command_info)) {
     const CommandInfo& info = command_info[command];
     unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
     if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index d72125c..17fd14f 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -11,6 +11,7 @@
 
 #include "base/command_line.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "build/build_config.h"
@@ -1721,8 +1722,8 @@
       GLenum formats[] = {
           GL_RED, GL_RG, GL_RGBA, GL_RED, GL_RG, GL_RGB,
       };
-      DCHECK_EQ(arraysize(internal_formats), arraysize(formats));
-      for (size_t i = 0; i < arraysize(formats); ++i) {
+      DCHECK_EQ(base::size(internal_formats), base::size(formats));
+      for (size_t i = 0; i < base::size(formats); ++i) {
         glTexImage2D(GL_TEXTURE_2D, 0, internal_formats[i], width, width, 0,
                      formats[i], GL_FLOAT, nullptr);
         full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) ==
diff --git a/gpu/command_buffer/service/framebuffer_manager_unittest.cc b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
index 04b71c5..13c7c84 100644
--- a/gpu/command_buffer/service/framebuffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
@@ -5,6 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/client/client_test_helper.h"
 #include "gpu/command_buffer/service/error_state_mock.h"
 #include "gpu/command_buffer/service/feature_info.h"
@@ -1081,7 +1082,7 @@
               framebuffer_->GetDrawBuffer(i));
   }
 
-  for (size_t ii = 0; ii < arraysize(kTextureClientId); ++ii) {
+  for (size_t ii = 0; ii < base::size(kTextureClientId); ++ii) {
     texture_manager_->CreateTexture(
         kTextureClientId[ii], kTextureServiceId[ii]);
     scoped_refptr<TextureRef> texture(
@@ -1184,7 +1185,7 @@
       GL_FLOAT,
       GL_UNSIGNED_INT};
 
-  for (size_t ii = 0; ii < arraysize(kTextureClientId); ++ii) {
+  for (size_t ii = 0; ii < base::size(kTextureClientId); ++ii) {
     texture_manager_->CreateTexture(
         kTextureClientId[ii], kTextureServiceId[ii]);
     scoped_refptr<TextureRef> texture(
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index f864bfd..e04ab57 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -30,6 +30,7 @@
 #include "base/numerics/ranges.h"
 #include "base/numerics/safe_math.h"
 #include "base/optional.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/trace_event.h"
@@ -5823,7 +5824,7 @@
 
     const unsigned int arg_count = size - 1;
     unsigned int command_index = command - kFirstGLES2Command;
-    if (command_index < arraysize(command_info)) {
+    if (command_index < base::size(command_info)) {
       const CommandInfo& info = command_info[command_index];
       unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
       if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
@@ -14026,7 +14027,7 @@
 };
 
 const CompressedFormatInfo* GetCompressedFormatInfo(GLenum format) {
-  for (size_t i = 0; i < arraysize(kCompressedFormatInfoArray); i++) {
+  for (size_t i = 0; i < base::size(kCompressedFormatInfoArray); i++) {
     if (kCompressedFormatInfoArray[i].format == format) {
       return &kCompressedFormatInfoArray[i];
     }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
index 9e14ab0..e1e95fe 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
@@ -8,6 +8,7 @@
 #include <utility>
 
 #include "base/callback.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "gpu/command_buffer/service/command_buffer_service.h"
 #include "gpu/command_buffer/service/decoder_client.h"
@@ -608,7 +609,7 @@
 
     const unsigned int arg_count = size - 1;
     unsigned int command_index = command - kFirstGLES2Command;
-    if (command_index < arraysize(command_info)) {
+    if (command_index < base::size(command_info)) {
       const CommandInfo& info = command_info[command_index];
       unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
       if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
@@ -707,7 +708,7 @@
     };
     RequestExtensions(api(), requestable_extensions,
                       kRequiredFunctionalityExtensions,
-                      arraysize(kRequiredFunctionalityExtensions));
+                      base::size(kRequiredFunctionalityExtensions));
 
     if (request_optional_extensions_) {
       static constexpr const char* kOptionalFunctionalityExtensions[] = {
@@ -754,7 +755,7 @@
       };
       RequestExtensions(api(), requestable_extensions,
                         kOptionalFunctionalityExtensions,
-                        arraysize(kOptionalFunctionalityExtensions));
+                        base::size(kOptionalFunctionalityExtensions));
     }
 
     context->ReinitializeDynamicBindings();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 6eda7db..a982b5ce 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -925,7 +926,7 @@
 }
 
 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryIdFails) {
-  for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
+  for (size_t i = 0; i < base::size(kQueryTypes); ++i) {
     CheckBeginEndQueryBadMemoryFails(this, kNewClientId, kQueryTypes[i],
                                      kInvalidSharedMemoryId,
                                      kSharedMemoryOffset);
@@ -933,7 +934,7 @@
 }
 
 TEST_P(GLES2DecoderManualInitTest, BeginEndQueryEXTBadMemoryOffsetFails) {
-  for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
+  for (size_t i = 0; i < base::size(kQueryTypes); ++i) {
     // Out-of-bounds.
     CheckBeginEndQueryBadMemoryFails(this, kNewClientId, kQueryTypes[i],
                                      shared_memory_id_,
@@ -945,7 +946,7 @@
 }
 
 TEST_P(GLES2DecoderManualInitTest, QueryReuseTest) {
-  for (size_t i = 0; i < arraysize(kQueryTypes); ++i) {
+  for (size_t i = 0; i < base::size(kQueryTypes); ++i) {
     const QueryType& query_type = kQueryTypes[i];
 
     GLES2DecoderTestBase::InitState init;
@@ -1256,7 +1257,7 @@
   static const GLenum kStates[] = {
       GL_DEPTH_TEST, GL_STENCIL_TEST,
   };
-  for (size_t ii = 0; ii < arraysize(kStates); ++ii) {
+  for (size_t ii = 0; ii < base::size(kStates); ++ii) {
     Enable enable_cmd;
     GLenum state = kStates[ii];
     enable_cmd.Init(state);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_attribs.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_attribs.cc
index c3199d3b..acbfc81 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_attribs.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_attribs.cc
@@ -7,6 +7,7 @@
 #include <stddef.h>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -14,7 +15,6 @@
 #include "gpu/command_buffer/service/context_state.h"
 #include "gpu/command_buffer/service/gl_surface_mock.h"
 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
-
 #include "gpu/command_buffer/service/gpu_switches.h"
 #include "gpu/command_buffer/service/image_manager.h"
 #include "gpu/command_buffer/service/mailbox_manager.h"
@@ -207,15 +207,15 @@
   static const GLsizei stride_offset[] = {
       0, 0, 1, 0, 1, 0, 0,
   };
-  for (size_t tt = 0; tt < arraysize(types); ++tt) {
+  for (size_t tt = 0; tt < base::size(types); ++tt) {
     GLenum type = types[tt];
     GLsizei num_bytes = sizes[tt];
-    for (size_t ii = 0; ii < arraysize(indices); ++ii) {
+    for (size_t ii = 0; ii < base::size(indices); ++ii) {
       GLuint index = indices[ii];
       for (GLint size = 0; size < 5; ++size) {
-        for (size_t oo = 0; oo < arraysize(offset_mult); ++oo) {
+        for (size_t oo = 0; oo < base::size(offset_mult); ++oo) {
           GLuint offset = num_bytes * offset_mult[oo] + offset_offset[oo];
-          for (size_t ss = 0; ss < arraysize(stride_mult); ++ss) {
+          for (size_t ss = 0; ss < base::size(stride_mult); ++ss) {
             GLsizei stride = num_bytes * stride_mult[ss] + stride_offset[ss];
             for (int normalize = 0; normalize < 2; ++normalize) {
               bool index_good = index < static_cast<GLuint>(kNumVertexAttribs);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 8ac4b41..856224e 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -13,6 +13,7 @@
 #include <vector>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
@@ -58,7 +59,7 @@
       "GL_APPLE_vertex_array_object"
   };
   bool contains_vao_extension = false;
-  for (size_t ii = 0; ii < arraysize(kVAOExtensions); ++ii) {
+  for (size_t ii = 0; ii < base::size(kVAOExtensions); ++ii) {
     if (init->extensions.find(kVAOExtensions[ii]) != std::string::npos) {
       contains_vao_extension = true;
       break;
@@ -291,9 +292,9 @@
   static GLuint fixed_attrib_buffer_id[] = {
     kServiceFixedAttribBufferId,
   };
-  EXPECT_CALL(*gl_, GenBuffersARB(arraysize(attrib_0_id), _))
+  EXPECT_CALL(*gl_, GenBuffersARB(base::size(attrib_0_id), _))
       .WillOnce(SetArrayArgument<1>(attrib_0_id,
-                                    attrib_0_id + arraysize(attrib_0_id)))
+                                    attrib_0_id + base::size(attrib_0_id)))
       .RetiresOnSaturation();
   EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, kServiceAttrib0BufferId))
       .Times(1)
@@ -304,10 +305,10 @@
   EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, 0))
       .Times(1)
       .RetiresOnSaturation();
-  EXPECT_CALL(*gl_, GenBuffersARB(arraysize(fixed_attrib_buffer_id), _))
+  EXPECT_CALL(*gl_, GenBuffersARB(base::size(fixed_attrib_buffer_id), _))
       .WillOnce(SetArrayArgument<1>(
           fixed_attrib_buffer_id,
-          fixed_attrib_buffer_id + arraysize(fixed_attrib_buffer_id)))
+          fixed_attrib_buffer_id + base::size(fixed_attrib_buffer_id)))
       .RetiresOnSaturation();
 
   for (GLint tt = 0; tt < TestHelper::kNumTextureUnits; ++tt) {
@@ -421,13 +422,13 @@
   };
   EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_VIEWPORT_DIMS, _))
       .WillOnce(SetArrayArgument<1>(
-          max_viewport_dims, max_viewport_dims + arraysize(max_viewport_dims)))
-        .RetiresOnSaturation();
+          max_viewport_dims, max_viewport_dims + base::size(max_viewport_dims)))
+      .RetiresOnSaturation();
 
   static GLfloat line_width_range[] = { 1.0f, 2.0f };
   EXPECT_CALL(*gl_, GetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, _))
       .WillOnce(SetArrayArgument<1>(
-          line_width_range, line_width_range + arraysize(line_width_range)))
+          line_width_range, line_width_range + base::size(line_width_range)))
       .RetiresOnSaturation();
 
   if (group_->feature_info()->feature_flags().ext_window_rectangles) {
@@ -1054,10 +1055,10 @@
   const GLuint kServiceVertexShaderId = 6001;
   const GLuint kClientFragmentShaderId = 5002;
   const GLuint kServiceFragmentShaderId = 6002;
-  SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
-              client_program_id_, kServiceProgramId,
-              kClientVertexShaderId, kServiceVertexShaderId,
-              kClientFragmentShaderId, kServiceFragmentShaderId);
+  SetupShader(attribs, base::size(attribs), uniforms, base::size(uniforms),
+              client_program_id_, kServiceProgramId, kClientVertexShaderId,
+              kServiceVertexShaderId, kClientFragmentShaderId,
+              kServiceFragmentShaderId);
 
   EXPECT_CALL(*gl_, UseProgram(kServiceProgramId))
       .Times(1)
@@ -1965,10 +1966,10 @@
         kUniform8FakeLocation, kUniform8RealLocation,
         kUniform8DesiredLocation },
     };
-    SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
-                client_program_id_, kServiceProgramId,
-                client_vertex_shader_id_, kServiceVertexShaderId,
-                client_fragment_shader_id_, kServiceFragmentShaderId);
+    SetupShader(attribs, base::size(attribs), uniforms, base::size(uniforms),
+                client_program_id_, kServiceProgramId, client_vertex_shader_id_,
+                kServiceVertexShaderId, client_fragment_shader_id_,
+                kServiceFragmentShaderId);
   }
 
   {
@@ -2011,10 +2012,10 @@
         kUniform7FakeLocation, kUniform7RealLocation,
         kUniform7DesiredLocation },
     };
-    SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
-                client_program_id_, kServiceProgramId,
-                client_vertex_shader_id_, kServiceVertexShaderId,
-                client_fragment_shader_id_, kServiceFragmentShaderId);
+    SetupShader(attribs, base::size(attribs), uniforms, base::size(uniforms),
+                client_program_id_, kServiceProgramId, client_vertex_shader_id_,
+                kServiceVertexShaderId, client_fragment_shader_id_,
+                kServiceFragmentShaderId);
   }
 
   {
@@ -2057,10 +2058,10 @@
         kUniform7FakeLocation, kUniform7RealLocation,
         kUniform7DesiredLocation },
     };
-    SetupShader(attribs, arraysize(attribs), uniforms, arraysize(uniforms),
-                client_program_id_, kServiceProgramId,
-                client_vertex_shader_id_, kServiceVertexShaderId,
-                client_fragment_shader_id_, kServiceFragmentShaderId);
+    SetupShader(attribs, base::size(attribs), uniforms, base::size(uniforms),
+                client_program_id_, kServiceProgramId, client_vertex_shader_id_,
+                kServiceVertexShaderId, client_fragment_shader_id_,
+                kServiceFragmentShaderId);
   }
 
   {
@@ -2278,7 +2279,7 @@
                client_element_buffer_id_,
                kServiceElementBufferId);
   static const GLshort indices[] = {100, 1, 2, 3, 4, 5, 6, 7, 100, 9};
-  static_assert(arraysize(indices) == kNumIndices,
+  static_assert(base::size(indices) == kNumIndices,
                 "indices should have kNumIndices elements");
   DoBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices));
   DoBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, 2, indices);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions.cc
index f700b99..015fdbb 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions.cc
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
@@ -1377,7 +1378,7 @@
 
   const GLuint kPaths[] = {client_path_id_, client_path_id_ + 5,
                            client_path_id_, client_path_id_ + 18};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
 
   struct {
     GLenum fill_mode;
@@ -1393,7 +1394,7 @@
 
   GLuint* paths = GetSharedMemoryAs<GLuint*>();
 
-  for (size_t i = 0; i < arraysize(testcases); ++i) {
+  for (size_t i = 0; i < base::size(testcases); ++i) {
     memcpy(paths, kPaths, sizeof(kPaths));
     sfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_,
                  shared_memory_offset_, 0, testcases[i].fill_mode,
@@ -1421,7 +1422,7 @@
 
   const GLuint kPaths[] = {client_path_id_, client_path_id_ + 5,
                            client_path_id_, client_path_id_ + 18};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
 
   static const GLenum kFillModes[] = {GL_INVERT, GL_COUNT_UP_CHROMIUM,
                                       GL_COUNT_DOWN_CHROMIUM};
@@ -1429,7 +1430,7 @@
 
   GLuint* paths = GetSharedMemoryAs<GLuint*>();
 
-  for (size_t i = 0; i < arraysize(kFillModes); ++i) {
+  for (size_t i = 0; i < base::size(kFillModes); ++i) {
     memcpy(paths, kPaths, sizeof(kPaths));
     EXPECT_CALL(*gl_, StencilFillPathInstancedNV(kPathCount, GL_UNSIGNED_INT, _,
                                                  0, kFillModes[i], kMask,
@@ -1458,7 +1459,7 @@
   SetupExpectationsForApplyingDefaultDirtyState();
 
   const GLuint kPaths[] = {0, client_path_id_, 15, client_path_id_};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
 
   // The path base will be client_path_id_, and so 0 is a
   // valid path.
@@ -1561,7 +1562,7 @@
 
   };
 
-  for (size_t i = 0; i < arraysize(testcases); ++i) {
+  for (size_t i = 0; i < base::size(testcases); ++i) {
     SCOPED_TRACE(testing::Message() << "InstancedCalls testcase " << i);
     CallAllInstancedCommands(testcases[i]);
   }
@@ -1569,7 +1570,7 @@
 
 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedNoCalls) {
   const GLuint kPaths[] = {1, client_path_id_, 5, client_path_id_};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
 
   const GLenum kFillMode = GL_INVERT;
   const GLuint kMask = 0x80;
@@ -1634,7 +1635,7 @@
        GL_NO_ERROR, false},
 
   };
-  for (size_t i = 0; i < arraysize(testcases); ++i) {
+  for (size_t i = 0; i < base::size(testcases); ++i) {
     SCOPED_TRACE(testing::Message() << "InstancedNoCalls testcase " << i);
     CallAllInstancedCommands(testcases[i]);
   }
@@ -1642,7 +1643,7 @@
 
 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedInvalidSHMValues) {
   const GLuint kPaths[] = {1, client_path_id_, 5, client_path_id_};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
   GLfloat transform_values[12 * kPathCount];
   for (GLsizei i = 0; i < kPathCount; ++i) {
     for (int j = 0; j < 12; ++j) {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
index f15105d..ce62a0a 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
@@ -11,6 +11,7 @@
 #include <memory>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -18,7 +19,6 @@
 #include "gpu/command_buffer/service/context_state.h"
 #include "gpu/command_buffer/service/gl_surface_mock.h"
 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
-
 #include "gpu/command_buffer/service/gpu_switches.h"
 #include "gpu/command_buffer/service/image_manager.h"
 #include "gpu/command_buffer/service/mailbox_manager.h"
@@ -1146,7 +1146,7 @@
       },  // completely off right
   };
 
-  for (size_t tt = 0; tt < arraysize(tests); ++tt) {
+  for (size_t tt = 0; tt < base::size(tests); ++tt) {
     CheckReadPixelsOutOfRange(
         tests[tt][0], tests[tt][1], tests[tt][2], tests[tt][3], tt == 0);
   }
@@ -3263,7 +3263,7 @@
   DrawBuffersEXTImmediate& cmd = *GetImmediateAs<DrawBuffersEXTImmediate>();
   {
     const GLenum bufs[] = {GL_BACK};
-    const GLsizei count = arraysize(bufs);
+    const GLsizei count = base::size(bufs);
     cmd.Init(count, bufs);
 
     EXPECT_CALL(*gl_, DrawBuffersARB(count, Pointee(GL_BACK)))
@@ -3284,7 +3284,7 @@
   }
   {
     const GLenum bufs[] = {GL_BACK, GL_NONE};
-    const GLsizei count = arraysize(bufs);
+    const GLsizei count = base::size(bufs);
     cmd.Init(count, bufs);
 
     EXPECT_CALL(*gl_, DrawBuffersARB(_, _)).Times(0).RetiresOnSaturation();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_programs.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_programs.cc
index 73b997ef..6a14f50 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_programs.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_programs.cc
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -829,7 +830,7 @@
     GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
     GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER,
   };
-  for (size_t ii = 0; ii < arraysize(kPname); ++ii) {
+  for (size_t ii = 0; ii < base::size(kPname); ++ii) {
     result->SetNumResults(0);
     cmd.Init(client_program_id_,
              0,
@@ -1070,7 +1071,7 @@
   const char kName0[] = "Cow";
   const char kName1[] = "Chicken";
   const char* kNames[] = { kName0, kName1 };
-  const size_t kCount = arraysize(kNames);
+  const size_t kCount = base::size(kNames);
   const char kValidStrEnd = 0;
   const GLuint kIndices[] = { 1, 2 };
   SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
@@ -1103,7 +1104,7 @@
   const char kName0[] = "Cow";
   const char kName1[] = "Chicken";
   const char* kNames[] = { kName0, kName1 };
-  const size_t kCount = arraysize(kNames);
+  const size_t kCount = base::size(kNames);
   const char kValidStrEnd = 0;
   SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
   GetUniformIndices::Result* result =
@@ -1132,7 +1133,7 @@
   const char kName0[] = "Cow";
   const char kName1[] = "Chicken";
   const char* kNames[] = { kName0, kName1 };
-  const size_t kCount = arraysize(kNames);
+  const size_t kCount = base::size(kNames);
   const char kValidStrEnd = 0;
   const GLuint kIndices[] = { 1, 2 };
   SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
@@ -1162,7 +1163,7 @@
   const char kName0[] = "Cow";
   const char kName1[] = "Chicken";
   const char* kNames[] = { kName0, kName1 };
-  const size_t kCount = arraysize(kNames);
+  const size_t kCount = base::size(kNames);
   const char kValidStrEnd = 0;
   SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
   GetUniformIndices::Result* result =
@@ -1178,7 +1179,7 @@
   const char kName0[] = "Cow";
   const char kName1[] = "Chicken";
   const char* kNames[] = { kName0, kName1 };
-  const size_t kCount = arraysize(kNames);
+  const size_t kCount = base::size(kNames);
   const char kValidStrEnd = 0;
   SetBucketAsCStrings(kBucketId, kCount, kNames, kCount, kValidStrEnd);
   GetUniformIndices::Result* result =
@@ -1200,7 +1201,7 @@
   const uint32_t kBucketId = 123;
   const GLuint kIndices[] = { 1, 2 };
   const GLint kResults[] = { 1976, 321 };
-  const size_t kCount = arraysize(kIndices);
+  const size_t kCount = base::size(kIndices);
   SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
   GetActiveUniformsiv::Result* result =
       static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
@@ -1227,7 +1228,7 @@
 TEST_P(GLES3DecoderWithShaderTest, GetActiveUniformsivBadProgramFails) {
   const uint32_t kBucketId = 123;
   const GLuint kIndices[] = { 1, 2 };
-  const size_t kCount = arraysize(kIndices);
+  const size_t kCount = base::size(kIndices);
   SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
   GetActiveUniformsiv::Result* result =
       static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
@@ -1254,7 +1255,7 @@
 TEST_P(GLES3DecoderWithShaderTest, GetActiveUniformsivBadParamsFails) {
   const uint32_t kBucketId = 123;
   const GLuint kIndices[] = { 1, 100 };
-  const size_t kCount = arraysize(kIndices);
+  const size_t kCount = base::size(kIndices);
   SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
   GetActiveUniformsiv::Result* result =
       static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
@@ -1270,7 +1271,7 @@
 TEST_P(GLES3DecoderWithShaderTest, GetActiveUniformsivBadPnameFails) {
   const uint32_t kBucketId = 123;
   const GLuint kIndices[] = { 1, 2 };
-  const size_t kCount = arraysize(kIndices);
+  const size_t kCount = base::size(kIndices);
   SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
   GetActiveUniformsiv::Result* result =
       static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
@@ -1294,7 +1295,7 @@
 TEST_P(GLES3DecoderWithShaderTest, GetActiveUniformsivResultNotInitFails) {
   const uint32_t kBucketId = 123;
   const GLuint kIndices[] = { 1, 2 };
-  const size_t kCount = arraysize(kIndices);
+  const size_t kCount = base::size(kIndices);
   SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
   GetActiveUniformsiv::Result* result =
       static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
@@ -1308,7 +1309,7 @@
 TEST_P(GLES3DecoderWithShaderTest, GetActiveUniformsivBadSharedMemoryFails) {
   const uint32_t kBucketId = 123;
   const GLuint kIndices[] = { 1, 2 };
-  const size_t kCount = arraysize(kIndices);
+  const size_t kCount = base::size(kIndices);
   SetBucketData(kBucketId, kIndices, sizeof(GLuint) * kCount);
   GetActiveUniformsiv::Result* result =
       static_cast<GetActiveUniformsiv::Result*>(shared_memory_address_);
@@ -2087,18 +2088,12 @@
         {kUniform3Name, kUniform3Size, kUniform3Type, kUniform3FakeLocation,
          kUniform3RealLocation, kUniform3DesiredLocation},
     };
-    SetupShader(attribs,
-                arraysize(attribs),
-                uniforms,
-                arraysize(uniforms),
-                client_program_id_,
-                kServiceProgramId,
-                client_vertex_shader_id_,
-                kServiceVertexShaderId,
-                client_fragment_shader_id_,
+    SetupShader(attribs, base::size(attribs), uniforms, base::size(uniforms),
+                client_program_id_, kServiceProgramId, client_vertex_shader_id_,
+                kServiceVertexShaderId, client_fragment_shader_id_,
                 kServiceFragmentShaderId);
-    TestHelper::SetupExpectationsForClearingUniforms(
-        gl_.get(), uniforms, arraysize(uniforms));
+    TestHelper::SetupExpectationsForClearingUniforms(gl_.get(), uniforms,
+                                                     base::size(uniforms));
   }
 
   {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
index 29aa110..098085c 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
@@ -8,6 +8,7 @@
 #include <stdint.h>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
@@ -695,7 +696,7 @@
   EXPECT_CALL(*gl_, GetError()).WillRepeatedly(Return(GL_NO_ERROR));
   EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
       .WillRepeatedly(Return(GL_FRAMEBUFFER_COMPLETE));
-  for (size_t i = 0; i < arraysize(kUnsizedInternalFormats); ++i) {
+  for (size_t i = 0; i < base::size(kUnsizedInternalFormats); ++i) {
     // Copy from main framebuffer to texture, using the unsized internal format.
     DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0);
     GLenum internal_format = kUnsizedInternalFormats[i];
@@ -776,7 +777,7 @@
   EXPECT_CALL(*gl_, GetError()).WillRepeatedly(Return(GL_NO_ERROR));
   EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(_))
       .WillRepeatedly(Return(GL_FRAMEBUFFER_COMPLETE));
-  for (size_t i = 0; i < arraysize(kUnsizedInternalFormats); ++i) {
+  for (size_t i = 0; i < base::size(kUnsizedInternalFormats); ++i) {
     // Copy from main framebuffer to texture, using the unsized internal format.
     DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0);
     GLenum internal_format = kUnsizedInternalFormats[i].unsized;
@@ -1718,7 +1719,7 @@
       },
   };
 
-  for (size_t ii = 0; ii < arraysize(test_data); ++ii) {
+  for (size_t ii = 0; ii < base::size(test_data); ++ii) {
     const S3TCTestData& test = test_data[ii];
     CompressedTexImage2DBucket cmd;
     // test small width.
@@ -1875,7 +1876,7 @@
       },
   };
 
-  for (size_t ii = 0; ii < arraysize(test_data); ++ii) {
+  for (size_t ii = 0; ii < base::size(test_data); ++ii) {
     const S3TCTestData& test = test_data[ii];
     CompressedTexImage2DBucket cmd;
     // test small width.
diff --git a/gpu/command_buffer/service/gpu_tracer.cc b/gpu/command_buffer/service/gpu_tracer.cc
index 2376e8d..667c025 100644
--- a/gpu/command_buffer/service/gpu_tracer.cc
+++ b/gpu/command_buffer/service/gpu_tracer.cc
@@ -10,6 +10,7 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -31,7 +32,7 @@
     "TraceCmd",       // kTraceDecoder,
     "Disjoint",       // kTraceDisjoint, // Used internally.
 };
-static_assert(NUM_TRACER_SOURCES == arraysize(kGpuTraceSourceNames),
+static_assert(NUM_TRACER_SOURCES == base::size(kGpuTraceSourceNames),
               "Trace source names must match enumeration.");
 
 TraceMarker::TraceMarker(const std::string& category, const std::string& name)
diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc
index fbeaea6d..c0fb8d8 100644
--- a/gpu/command_buffer/service/program_manager.cc
+++ b/gpu/command_buffer/service/program_manager.cc
@@ -19,6 +19,7 @@
 #include "base/logging.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -99,7 +100,7 @@
       "gl_FrontFacing",
       "gl_PointCoord"
   };
-  for (size_t ii = 0; ii < arraysize(kBuiltInVaryings); ++ii) {
+  for (size_t ii = 0; ii < base::size(kBuiltInVaryings); ++ii) {
     if (name == kBuiltInVaryings[ii])
       return true;
   }
@@ -1040,14 +1041,14 @@
     // Unlike when binding uniforms, we expect the driver to give correct
     // names: "name" for simple variable, "name[0]" for an array.
     GLsizei query_length = 0;
-    GLint query_results[arraysize(kQueryProperties)] = {
+    GLint query_results[base::size(kQueryProperties)] = {
         0,
     };
     glGetProgramResourceiv(service_id_, GL_FRAGMENT_INPUT_NV, ii,
-                           arraysize(kQueryProperties), kQueryProperties,
-                           arraysize(query_results), &query_length,
+                           base::size(kQueryProperties), kQueryProperties,
+                           base::size(query_results), &query_length,
                            query_results);
-    DCHECK(query_length == arraysize(kQueryProperties));
+    DCHECK(query_length == base::size(kQueryProperties));
 
     GLenum type = static_cast<GLenum>(query_results[1]);
     GLsizei size = static_cast<GLsizei>(query_results[2]);
@@ -2532,7 +2533,7 @@
     GL_UNIFORM_IS_ROW_MAJOR,
   };
   const GLint kDefaultValue[] = { -1, -1, -1, -1, 0 };
-  const size_t kNumPnames = arraysize(kPname);
+  const size_t kNumPnames = base::size(kPname);
   std::vector<GLuint> indices(count);
   for (GLsizei ii = 0; ii < count; ++ii) {
     indices[ii] = ii;
diff --git a/gpu/command_buffer/service/program_manager_unittest.cc b/gpu/command_buffer/service/program_manager_unittest.cc
index e2e55c7..095a9a1 100644
--- a/gpu/command_buffer/service/program_manager_unittest.cc
+++ b/gpu/command_buffer/service/program_manager_unittest.cc
@@ -11,6 +11,7 @@
 #include <memory>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "gpu/command_buffer/common/gles2_cmd_format.h"
@@ -523,7 +524,7 @@
 #endif
 
 const size_t ProgramManagerWithShaderTest::kNumAttribs =
-    arraysize(ProgramManagerWithShaderTest::kAttribs);
+    base::size(ProgramManagerWithShaderTest::kAttribs);
 
 ProgramManagerWithShaderTest::UniformInfo
     ProgramManagerWithShaderTest::kUniforms[] = {
@@ -554,7 +555,7 @@
 };
 
 const size_t ProgramManagerWithShaderTest::kNumUniforms =
-    arraysize(ProgramManagerWithShaderTest::kUniforms);
+    base::size(ProgramManagerWithShaderTest::kUniforms);
 
 const char* ProgramManagerWithShaderTest::kAttrib1Name = "attrib1";
 const char* ProgramManagerWithShaderTest::kAttrib2Name = "attrib2";
@@ -817,7 +818,7 @@
        kUniform3NameWithArrayIndex,
       },
   };
-  const size_t kNumUniforms = arraysize(kUniforms);
+  const size_t kNumUniforms = base::size(kUniforms);
   SetupShaderExpectations(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
                           kServiceProgramId);
   Shader* vshader = shader_manager_.CreateShader(
@@ -881,7 +882,7 @@
       kUniform3Name,
     },
   };
-  const size_t kNumUniforms = arraysize(kUniforms);
+  const size_t kNumUniforms = base::size(kUniforms);
   SetupShaderExpectations(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
                           kServiceProgramId);
   Shader* vshader = shader_manager_.CreateShader(
@@ -982,8 +983,8 @@
       kUniform3NameWithArrayIndex,
     },
   };
-  const size_t kNumAttribs= arraysize(kAttribs);
-  const size_t kNumUniforms = arraysize(kUniforms);
+  const size_t kNumAttribs = base::size(kAttribs);
+  const size_t kNumUniforms = base::size(kUniforms);
   SetupShaderExpectations(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
                           kServiceProgramId);
   Program* program =
@@ -1133,8 +1134,8 @@
       bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader));
   ASSERT_TRUE(header != nullptr);
   EXPECT_EQ(1u, header->link_status);
-  EXPECT_EQ(arraysize(kAttribs), header->num_attribs);
-  EXPECT_EQ(arraysize(kUniforms), header->num_uniforms);
+  EXPECT_EQ(base::size(kAttribs), header->num_attribs);
+  EXPECT_EQ(base::size(kUniforms), header->num_uniforms);
   const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>(
       sizeof(*header),
       sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms));
@@ -1235,23 +1236,23 @@
   data.entry[0].binding = 0;
   data.entry[0].data_size = 8;
   data.entry[0].name_offset = ComputeOffset(&data, data.name0);
-  data.entry[0].name_length = arraysize(data.name0);
-  data.entry[0].active_uniforms = arraysize(data.indices0);
+  data.entry[0].name_length = base::size(data.name0);
+  data.entry[0].active_uniforms = base::size(data.indices0);
   data.entry[0].active_uniform_offset = ComputeOffset(&data, data.indices0);
   data.entry[0].referenced_by_vertex_shader = static_cast<uint32_t>(true);
   data.entry[0].referenced_by_fragment_shader = static_cast<uint32_t>(false);
   data.entry[1].binding = 1;
   data.entry[1].data_size = 4;
   data.entry[1].name_offset = ComputeOffset(&data, data.name1);
-  data.entry[1].name_length = arraysize(data.name1);
-  data.entry[1].active_uniforms = arraysize(data.indices1);
+  data.entry[1].name_length = base::size(data.name1);
+  data.entry[1].active_uniforms = base::size(data.indices1);
   data.entry[1].active_uniform_offset = ComputeOffset(&data, data.indices1);
   data.entry[1].referenced_by_vertex_shader = static_cast<uint32_t>(false);
   data.entry[1].referenced_by_fragment_shader = static_cast<uint32_t>(true);
-  memcpy(data.name0, kName[0], arraysize(data.name0));
+  memcpy(data.name0, kName[0], base::size(data.name0));
   data.indices0[0] = kIndices[0][0];
   data.indices0[1] = kIndices[0][1];
-  memcpy(data.name1, kName[1], arraysize(data.name1));
+  memcpy(data.name1, kName[1], base::size(data.name1));
   data.indices1[0] = kIndices[1][0];
 
   EXPECT_CALL(*(gl_.get()),
@@ -1398,14 +1399,13 @@
   data.entry[0].size = 1;
   data.entry[0].type = GL_FLOAT_VEC2;
   data.entry[0].name_offset = ComputeOffset(&data, data.name0);
-  data.entry[0].name_length = arraysize(data.name0);
+  data.entry[0].name_length = base::size(data.name0);
   data.entry[1].size = 2;
   data.entry[1].type = GL_FLOAT;
   data.entry[1].name_offset = ComputeOffset(&data, data.name1);
-  data.entry[1].name_length = arraysize(data.name1);
-  memcpy(data.name0, kName[0], arraysize(data.name0));
-  memcpy(data.name1, kName[1], arraysize(data.name1));
-
+  data.entry[1].name_length = base::size(data.name1);
+  memcpy(data.name0, kName[0], base::size(data.name0));
+  memcpy(data.name1, kName[1], base::size(data.name1));
 
   EXPECT_CALL(*(gl_.get()),
               GetProgramiv(kServiceProgramId,
@@ -1526,7 +1526,7 @@
     kMatrixStride,
     kIsRowMajor,
   };
-  const size_t kNumIterations = arraysize(kPname);
+  const size_t kNumIterations = base::size(kPname);
   for (size_t ii = 0; ii < kNumIterations; ++ii) {
     EXPECT_CALL(*(gl_.get()),
                 GetActiveUniformsiv(
@@ -1552,7 +1552,7 @@
   ASSERT_TRUE(program != nullptr);
   // Emulate the situation that only the first element has a valid location.
   // TODO(zmo): Don't assume these are in order.
-  for (size_t ii = 0; ii < arraysize(kUniforms); ++ii) {
+  for (size_t ii = 0; ii < base::size(kUniforms); ++ii) {
     Program::UniformInfo* uniform = const_cast<Program::UniformInfo*>(
         program->GetUniformInfo(ii));
     ASSERT_TRUE(uniform != nullptr);
@@ -1566,8 +1566,8 @@
       bucket.GetDataAs<ProgramInfoHeader*>(0, sizeof(ProgramInfoHeader));
   ASSERT_TRUE(header != nullptr);
   EXPECT_EQ(1u, header->link_status);
-  EXPECT_EQ(arraysize(kAttribs), header->num_attribs);
-  EXPECT_EQ(arraysize(kUniforms), header->num_uniforms);
+  EXPECT_EQ(base::size(kAttribs), header->num_attribs);
+  EXPECT_EQ(base::size(kUniforms), header->num_uniforms);
   const ProgramInput* inputs = bucket.GetDataAs<const ProgramInput*>(
       sizeof(*header),
       sizeof(ProgramInput) * (header->num_attribs + header->num_uniforms));
@@ -2009,7 +2009,7 @@
     GL_SAMPLER_3D_OES,
     GL_SAMPLER_2D_RECT_ARB,
   };
-  const size_t kNumSamplerTypes = arraysize(kSamplerTypes);
+  const size_t kNumSamplerTypes = base::size(kSamplerTypes);
   for (size_t ii = 0; ii < kNumSamplerTypes; ++ii) {
     static ProgramManagerWithShaderTest::AttribInfo kAttribs[] = {
       { kAttrib1Name, kAttrib1Size, kAttrib1Type, kAttrib1Location, },
@@ -2042,8 +2042,8 @@
         kUniform3NameWithArrayIndex,
       },
     };
-    const size_t kNumAttribs = arraysize(kAttribs);
-    const size_t kNumUniforms = arraysize(kUniforms);
+    const size_t kNumAttribs = base::size(kAttribs);
+    const size_t kNumUniforms = base::size(kUniforms);
     SetupShaderExpectations(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
                             kServiceProgramId);
     program->Link(nullptr, Program::kCountOnlyStaticallyUsed, this);
@@ -2107,8 +2107,8 @@
     },
   };
 
-  const size_t kNumAttribs = arraysize(kAttribs);
-  const size_t kNumUniforms = arraysize(kUniforms);
+  const size_t kNumAttribs = base::size(kAttribs);
+  const size_t kNumUniforms = base::size(kUniforms);
   SetupShaderExpectations(kAttribs, kNumAttribs, kUniforms, kNumUniforms,
                           kServiceProgramId);
   program->Link(nullptr, Program::kCountOnlyStaticallyUsed, this);
@@ -2129,7 +2129,7 @@
           kUniform1DesiredLocation, kUniform1Name,
       },
   };
-  const size_t kNumInvalidUniforms = arraysize(kInvalidUniforms);
+  const size_t kNumInvalidUniforms = base::size(kInvalidUniforms);
 
   SetupShaderExpectations(kAttribs, kNumAttribs, kInvalidUniforms,
                           kNumInvalidUniforms, kServiceProgramId);
@@ -2519,8 +2519,9 @@
   };
   TestHelper::SetupShaderExpectationsWithVaryings(
       gl_.get(), feature_info_.get(), nullptr, 0, nullptr, 0,
-      kFragmentInputExpectationInfos, arraysize(kFragmentInputExpectationInfos),
-      nullptr, 0, kServiceProgramId);
+      kFragmentInputExpectationInfos,
+      base::size(kFragmentInputExpectationInfos), nullptr, 0,
+      kServiceProgramId);
   program->Link(nullptr, Program::kCountOnlyStaticallyUsed, this);
   const Program::FragmentInputInfo* info1 =
       program->GetFragmentInputInfoByFakeLocation(
@@ -2591,7 +2592,7 @@
   int shader_version = 100;
   Program* program =
       SetupProgramForVariables(nullptr, 0, kFragmentVaryings,
-                               arraysize(kFragmentVaryings), &shader_version);
+                               base::size(kFragmentVaryings), &shader_version);
 
   const gl::GLVersionInfo& gl_version = feature_info_->gl_version_info();
   if (!gl_version.is_es) {
@@ -2618,7 +2619,7 @@
   int shader_version = 100;
   Program* program =
       SetupProgramForVariables(nullptr, 0, kFragmentVaryings,
-                               arraysize(kFragmentVaryings), &shader_version);
+                               base::size(kFragmentVaryings), &shader_version);
 
   const gl::GLVersionInfo& gl_version = feature_info_->gl_version_info();
   if (!gl_version.is_es) {
diff --git a/gpu/command_buffer/service/raster_decoder.cc b/gpu/command_buffer/service/raster_decoder.cc
index 27c4265b..5819a99 100644
--- a/gpu/command_buffer/service/raster_decoder.cc
+++ b/gpu/command_buffer/service/raster_decoder.cc
@@ -17,6 +17,7 @@
 #include "base/logging.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/trace_event.h"
 #include "build/build_config.h"
@@ -1229,7 +1230,7 @@
 
     const unsigned int arg_count = size - 1;
     unsigned int command_index = command - kFirstRasterCommand;
-    if (command_index < arraysize(command_info)) {
+    if (command_index < base::size(command_info)) {
       const CommandInfo& info = command_info[command_index];
       if (sk_surface_) {
         if (!AllowedBetweenBeginEndRaster(command)) {
diff --git a/gpu/command_buffer/service/sync_point_manager.cc b/gpu/command_buffer/service/sync_point_manager.cc
index 09a39933..740ffaa6 100644
--- a/gpu/command_buffer/service/sync_point_manager.cc
+++ b/gpu/command_buffer/service/sync_point_manager.cc
@@ -13,6 +13,7 @@
 #include "base/logging.h"
 #include "base/memory/ref_counted.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 
 namespace gpu {
 
@@ -362,7 +363,8 @@
   {
     base::AutoLock auto_lock(lock_);
     DCHECK_GE(namespace_id, 0);
-    DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_state_maps_));
+    DCHECK_LT(static_cast<size_t>(namespace_id),
+              base::size(client_state_maps_));
     DCHECK(!client_state_maps_[namespace_id].count(command_buffer_id));
     client_state_maps_[namespace_id].insert(
         std::make_pair(command_buffer_id, client_state));
@@ -376,7 +378,7 @@
     CommandBufferId command_buffer_id) {
   base::AutoLock auto_lock(lock_);
   DCHECK_GE(namespace_id, 0);
-  DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_state_maps_));
+  DCHECK_LT(static_cast<size_t>(namespace_id), base::size(client_state_maps_));
   DCHECK(client_state_maps_[namespace_id].count(command_buffer_id));
   client_state_maps_[namespace_id].erase(command_buffer_id);
 }
@@ -466,7 +468,8 @@
     CommandBufferNamespace namespace_id,
     CommandBufferId command_buffer_id) {
   if (namespace_id >= 0) {
-    DCHECK_LT(static_cast<size_t>(namespace_id), arraysize(client_state_maps_));
+    DCHECK_LT(static_cast<size_t>(namespace_id),
+              base::size(client_state_maps_));
     base::AutoLock auto_lock(lock_);
     ClientStateMap& client_state_map = client_state_maps_[namespace_id];
     auto it = client_state_map.find(command_buffer_id);
diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc
index 9a3cfc7..86c8fab 100644
--- a/gpu/command_buffer/service/test_helper.cc
+++ b/gpu/command_buffer/service/test_helper.cc
@@ -10,6 +10,7 @@
 #include <algorithm>
 #include <string>
 
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "gpu/command_buffer/service/buffer_manager.h"
 #include "gpu/command_buffer/service/error_state_mock.h"
@@ -174,7 +175,7 @@
           GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
           GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
         };
-        for (size_t ii = 0; ii < arraysize(faces); ++ii) {
+        for (size_t ii = 0; ii < base::size(faces); ++ii) {
           EXPECT_CALL(*gl, TexImage2D(faces[ii], 0, GL_RGBA, 1, 1, 0, GL_RGBA,
                                       GL_UNSIGNED_BYTE, _))
               .Times(1)
@@ -954,7 +955,7 @@
 
         static const GLenum kPropsArray[] = {GL_LOCATION, GL_TYPE,
                                              GL_ARRAY_SIZE};
-        static const size_t kPropsSize = arraysize(kPropsArray);
+        static const size_t kPropsSize = base::size(kPropsArray);
         EXPECT_CALL(
             *gl, GetProgramResourceiv(
                      service_id, GL_FRAGMENT_INPUT_NV, ii, kPropsSize,
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc
index 34b21e40..68b78db3 100644
--- a/gpu/command_buffer/service/texture_manager.cc
+++ b/gpu/command_buffer/service/texture_manager.cc
@@ -16,6 +16,7 @@
 #include "base/format_macros.h"
 #include "base/lazy_instance.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/trace_event/memory_dump_manager.h"
@@ -258,11 +259,11 @@
         {GL_RED, GL_RED, GL_UNSIGNED_SHORT},
     };
 
-    for (size_t ii = 0; ii < arraysize(kSupportedFormatTypes); ++ii) {
+    for (size_t ii = 0; ii < base::size(kSupportedFormatTypes); ++ii) {
       supported_combinations_.insert(kSupportedFormatTypes[ii]);
     }
 
-    for (size_t ii = 0; ii < arraysize(kSupportedFormatTypesES2Only); ++ii) {
+    for (size_t ii = 0; ii < base::size(kSupportedFormatTypesES2Only); ++ii) {
       supported_combinations_es2_only_.insert(kSupportedFormatTypesES2Only[ii]);
     }
   }
@@ -312,7 +313,7 @@
 
 const Texture::CompatibilitySwizzle* GetCompatibilitySwizzleInternal(
     GLenum format) {
-  size_t count = arraysize(kSwizzledFormats);
+  size_t count = base::size(kSwizzledFormats);
   for (size_t i = 0; i < count; ++i) {
     if (kSwizzledFormats[i].format == format)
       return &kSwizzledFormats[i];
@@ -494,7 +495,7 @@
   }
 
   if (have_context_) {
-    glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_);
+    glDeleteTextures(base::size(black_texture_ids_), black_texture_ids_);
   }
 
   DCHECK_EQ(0u, memory_type_tracker_->GetMemRepresented());
diff --git a/gpu/command_buffer/tests/fuzzer_main.cc b/gpu/command_buffer/tests/fuzzer_main.cc
index 76d9e174..ca13ceb1 100644
--- a/gpu/command_buffer/tests/fuzzer_main.cc
+++ b/gpu/command_buffer/tests/fuzzer_main.cc
@@ -1,6 +1,7 @@
 // Copyright 2016 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
 #include <stddef.h>
 #include <stdint.h>
 
@@ -13,6 +14,7 @@
 #include "base/command_line.h"
 #include "base/logging.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
@@ -173,7 +175,7 @@
     "GL_OES_texture_half_float_linear",
     "GL_OES_texture_npot",
     "GL_OES_vertex_array_object"};
-constexpr size_t kExtensionCount = arraysize(kExtensions);
+constexpr size_t kExtensionCount = base::size(kExtensions);
 
 #if defined(GPU_FUZZER_USE_STUB)
 constexpr const char* kDriverVersions[] = {"OpenGL ES 2.0", "OpenGL ES 3.1",
diff --git a/gpu/command_buffer/tests/gl_apply_screen_space_antialiasing_CHROMIUM_unittest.cc b/gpu/command_buffer/tests/gl_apply_screen_space_antialiasing_CHROMIUM_unittest.cc
index 6c5f24e2..b943e111 100644
--- a/gpu/command_buffer/tests/gl_apply_screen_space_antialiasing_CHROMIUM_unittest.cc
+++ b/gpu/command_buffer/tests/gl_apply_screen_space_antialiasing_CHROMIUM_unittest.cc
@@ -13,6 +13,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/tests/gl_manager.h"
 #include "gpu/command_buffer/tests/gl_test_utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -160,7 +161,7 @@
 
   GLint formats[] = {GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE,
                      GL_LUMINANCE_ALPHA};
-  for (size_t index = 0; index < arraysize(formats); index++) {
+  for (size_t index = 0; index < base::size(formats); index++) {
     glTexImage2D(GL_TEXTURE_2D, 0, formats[index], 1, 1, 0, formats[index],
                  GL_UNSIGNED_BYTE, nullptr);
     EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
diff --git a/gpu/command_buffer/tests/gl_chromium_path_rendering_unittest.cc b/gpu/command_buffer/tests/gl_chromium_path_rendering_unittest.cc
index 4b19fdd..375b568 100644
--- a/gpu/command_buffer/tests/gl_chromium_path_rendering_unittest.cc
+++ b/gpu/command_buffer/tests/gl_chromium_path_rendering_unittest.cc
@@ -10,6 +10,7 @@
 #include <cmath>
 
 #include "base/command_line.h"
+#include "base/stl_util.h"
 #include "gpu/command_buffer/service/gpu_switches.h"
 #include "gpu/command_buffer/tests/gl_manager.h"
 #include "gpu/command_buffer/tests/gl_test_utils.h"
@@ -132,8 +133,8 @@
                                       25.0f,
                                       75.0f};
 
-    glPathCommandsCHROMIUM(path, arraysize(kCommands), kCommands,
-                           arraysize(kCoords), GL_FLOAT, kCoords);
+    glPathCommandsCHROMIUM(path, base::size(kCommands), kCommands,
+                           base::size(kCoords), GL_FLOAT, kCoords);
 
     glPathParameterfCHROMIUM(path, GL_PATH_STROKE_WIDTH_CHROMIUM, 5.0f);
     glPathParameterfCHROMIUM(path, GL_PATH_MITER_LIMIT_CHROMIUM, 1.0f);
@@ -150,7 +151,7 @@
                                         28.0f, 66.0f, 63.0f};
     static const uint8_t kBlue[] = {0, 0, 255, 255};
 
-    for (size_t i = 0; i < arraysize(kFillCoords); i += 2) {
+    for (size_t i = 0; i < base::size(kFillCoords); i += 2) {
       float fx = kFillCoords[i];
       float fy = kFillCoords[i + 1];
 
@@ -165,7 +166,7 @@
     const float kBackgroundCoords[] = {80.0f, 80.0f, 20.0f, 20.0f, 90.0f, 1.0f};
     const uint8_t kExpectedColor[] = {0, 0, 0, 0};
 
-    for (size_t i = 0; i < arraysize(kBackgroundCoords); i += 2) {
+    for (size_t i = 0; i < base::size(kBackgroundCoords); i += 2) {
       float bx = kBackgroundCoords[i];
       float by = kBackgroundCoords[i + 1];
 
@@ -227,7 +228,7 @@
   static const GLenum kGetMatrixModes[] = {GL_PATH_MODELVIEW_MATRIX_CHROMIUM,
                                            GL_PATH_PROJECTION_MATRIX_CHROMIUM};
 
-  for (size_t i = 0; i < arraysize(kMatrixModes); ++i) {
+  for (size_t i = 0; i < base::size(kMatrixModes); ++i) {
     GLfloat mf[16];
     GLint mi[16];
     memset(mf, 0, sizeof(mf));
@@ -317,8 +318,8 @@
   EXPECT_FALSE(glIsPathCHROMIUM(path));
   GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM};
   GLfloat coords[] = {50.0f, 50.0f};
-  glPathCommandsCHROMIUM(path, arraysize(commands), commands, arraysize(coords),
-                         GL_FLOAT, coords);
+  glPathCommandsCHROMIUM(path, base::size(commands), commands,
+                         base::size(coords), GL_FLOAT, coords);
   EXPECT_TRUE(glIsPathCHROMIUM(path));
   glDeletePathsCHROMIUM(path, 1);
   EXPECT_FALSE(glIsPathCHROMIUM(path));
@@ -441,8 +442,8 @@
   EXPECT_FALSE(glIsPathCHROMIUM(path));
   GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM};
   GLfloat coords[] = {50.0f, 50.0f};
-  glPathCommandsCHROMIUM(path, arraysize(commands), commands, arraysize(coords),
-                         GL_FLOAT, coords);
+  glPathCommandsCHROMIUM(path, base::size(commands), commands,
+                         base::size(coords), GL_FLOAT, coords);
   EXPECT_TRUE(glIsPathCHROMIUM(path));
   glPathCommandsCHROMIUM(path, 0, nullptr, 0, GL_FLOAT, nullptr);
   EXPECT_TRUE(glIsPathCHROMIUM(path));  // The surprise.
@@ -473,8 +474,8 @@
   EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
   GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM};
   GLfloat coords[] = {50.0f, 50.0f};
-  glPathCommandsCHROMIUM(555, arraysize(commands), commands, arraysize(coords),
-                         GL_FLOAT, coords);
+  glPathCommandsCHROMIUM(555, base::size(commands), commands,
+                         base::size(coords), GL_FLOAT, coords);
   EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
 
   // PathParameter*: Using non-existing path object produces error.
@@ -497,24 +498,24 @@
   GLubyte commands[] = {GL_MOVE_TO_CHROMIUM, GL_CLOSE_PATH_CHROMIUM};
   GLfloat coords[] = {50.0f, 50.0f};
 
-  glPathCommandsCHROMIUM(path, arraysize(commands), commands, -4, GL_FLOAT,
+  glPathCommandsCHROMIUM(path, base::size(commands), commands, -4, GL_FLOAT,
                          coords);
   EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), glGetError());
 
-  glPathCommandsCHROMIUM(path, -1, commands, arraysize(coords), GL_FLOAT,
+  glPathCommandsCHROMIUM(path, -1, commands, base::size(coords), GL_FLOAT,
                          coords);
   EXPECT_EQ(static_cast<GLenum>(GL_INVALID_VALUE), glGetError());
 
-  glPathCommandsCHROMIUM(path, arraysize(commands), commands, arraysize(coords),
-                         kInvalidCoordType, coords);
+  glPathCommandsCHROMIUM(path, base::size(commands), commands,
+                         base::size(coords), kInvalidCoordType, coords);
   EXPECT_EQ(static_cast<GLenum>(GL_INVALID_ENUM), glGetError());
 
   // These can not distinquish between the check that should fail them.
   // This should fail due to coord count * float size overflow.
-  glPathCommandsCHROMIUM(path, arraysize(commands), commands,
+  glPathCommandsCHROMIUM(path, base::size(commands), commands,
                          std::numeric_limits<GLsizei>::max(), GL_FLOAT, coords);
   // This should fail due to cmd count + coord count * short size.
-  glPathCommandsCHROMIUM(path, arraysize(commands), commands,
+  glPathCommandsCHROMIUM(path, base::size(commands), commands,
                          std::numeric_limits<GLsizei>::max(), GL_SHORT, coords);
   EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
 
@@ -684,7 +685,7 @@
   SetupPathStateForTestPattern(path);
 
   const GLuint kPaths[] = {1, 1, 1, 1, 1};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
   const GLfloat kShapeSize = 80.0f;
   static const GLfloat kTransforms[kPathCount * 12] = {
       1.0f, 0.0f, 0.0f, 0.0f,           1.0f,       0.0f,
@@ -761,7 +762,7 @@
   SetupPathStateForTestPattern(path);
 
   const GLuint kPaths[] = {1, 1, 1, 1, 1};
-  const GLsizei kPathCount = arraysize(kPaths);
+  const GLsizei kPathCount = base::size(kPaths);
   const GLfloat kShapeSize = 80.0f;
   static const GLfloat kTransforms[] = {
       0.0f, 0.0f, kShapeSize, 0.0f,       kShapeSize * 2,
@@ -910,8 +911,8 @@
     };
 
     GLuint path = glGenPathsCHROMIUM(1);
-    glPathCommandsCHROMIUM(path, arraysize(kCommands), kCommands,
-                           arraysize(kCoords), GL_FLOAT, kCoords);
+    glPathCommandsCHROMIUM(path, base::size(kCommands), kCommands,
+                           base::size(kCoords), GL_FLOAT, kCoords);
     EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
 
     GLfloat path_model_translate[16] = {
@@ -1076,7 +1077,7 @@
 
   for (int j = 0; j < kTestRows; ++j) {
     for (int i = 0; i < kTestColumns; ++i) {
-      for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
+      for (size_t k = 0; k < base::size(kFillCoords); k += 2) {
         SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
                                         << ", " << j << " coord " << k);
         float fx = kFillCoords[k];
@@ -1176,7 +1177,7 @@
 
   for (int j = 0; j < kTestRows; ++j) {
     for (int i = 0; i < kTestColumns; ++i) {
-      for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
+      for (size_t k = 0; k < base::size(kFillCoords); k += 2) {
         SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
                                         << ", " << j << " coord " << k);
         float fx = kFillCoords[k];
@@ -1291,7 +1292,7 @@
 
   for (size_t ii = 0; ii < sizeof(variables) / sizeof(variables[0]); ++ii) {
     for (GLint components = 0; components <= 4; ++components) {
-      for (size_t jj = 0; jj < arraysize(kGenModes); ++jj) {
+      for (size_t jj = 0; jj < base::size(kGenModes); ++jj) {
         GLenum gen_mode = kGenModes[jj];
         SCOPED_TRACE(testing::Message()
                      << "Testing glProgramPathFragmentInputGenCHROMIUM "
@@ -1579,7 +1580,7 @@
     DrawTestPattern();
     for (int j = 0; j < kTestRows; ++j) {
       for (int i = 0; i < kTestColumns; ++i) {
-        for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
+        for (size_t k = 0; k < base::size(kFillCoords); k += 2) {
           SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
                                           << ", " << j << " coord " << k);
           float fx = kFillCoords[k];
@@ -1673,7 +1674,7 @@
 
   for (int j = 0; j < kTestRows; ++j) {
     for (int i = 0; i < kTestColumns; ++i) {
-      for (size_t k = 0; k < arraysize(kFillCoords); k += 2) {
+      for (size_t k = 0; k < base::size(kFillCoords); k += 2) {
         SCOPED_TRACE(testing::Message() << "Verifying fill for shape " << i
                                         << ", " << j << " coord " << k);
         float fx = kFillCoords[k];
diff --git a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
index 45a361d..2288f1b 100644
--- a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
+++ b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
@@ -13,6 +13,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/tests/gl_manager.h"
 #include "gpu/command_buffer/tests/gl_test_utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -770,8 +771,8 @@
                          GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT};
   GLint dest_formats[] = {GL_RGB, GL_RGBA, GL_BGRA_EXT};
 
-  for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) {
-    for (size_t dest_index = 0; dest_index < arraysize(dest_formats);
+  for (size_t src_index = 0; src_index < base::size(src_formats); src_index++) {
+    for (size_t dest_index = 0; dest_index < base::size(dest_formats);
          dest_index++) {
       CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
       glBindTexture(GL_TEXTURE_2D, textures_[0]);
@@ -861,7 +862,7 @@
 
   // Check unsupported format reports error.
   GLint unsupported_dest_formats[] = {GL_RED, GL_RG};
-  for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats);
+  for (size_t dest_index = 0; dest_index < base::size(unsupported_dest_formats);
        dest_index++) {
     if (copy_type == TexImage) {
       glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
@@ -901,7 +902,7 @@
     {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1},
     {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5},
   };
-  for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types);
+  for (size_t dest_index = 0; dest_index < base::size(unsupported_format_types);
        dest_index++) {
     glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
                           unsupported_format_types[dest_index].format,
@@ -1611,9 +1612,9 @@
   uint8_t white[1 * 4] = {255u, 255u, 255u, 255u};
   uint8_t grey[1 * 4] = {199u, 199u, 199u, 255u};
 
-  for (size_t src_index = 0; src_index < arraysize(src_targets); src_index++) {
+  for (size_t src_index = 0; src_index < base::size(src_targets); src_index++) {
     GLenum src_target = src_targets[src_index];
-    for (size_t dest_index = 0; dest_index < arraysize(dest_targets);
+    for (size_t dest_index = 0; dest_index < base::size(dest_targets);
          dest_index++) {
       GLenum dest_target = dest_targets[dest_index];
 
diff --git a/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc b/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc
index a21b279..6c11b55 100644
--- a/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc
+++ b/gpu/command_buffer/tests/gl_cube_map_texture_unittest.cc
@@ -7,6 +7,7 @@
 
 #include <memory>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/tests/gl_manager.h"
 #include "gpu/command_buffer/tests/gl_test_utils.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -91,7 +92,7 @@
   EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
 
   // Make a cube texture complete
-  for (unsigned i = 0; i < arraysize(kCubeMapTextureTargets); i++) {
+  for (unsigned i = 0; i < base::size(kCubeMapTextureTargets); i++) {
     glTexImage2D(kCubeMapTextureTargets[i], 0, GL_RGBA, width_, width_, 0,
                  GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
     EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
diff --git a/gpu/command_buffer/tests/gl_depth_texture_unittest.cc b/gpu/command_buffer/tests/gl_depth_texture_unittest.cc
index 1f3fdc8..d720005 100644
--- a/gpu/command_buffer/tests/gl_depth_texture_unittest.cc
+++ b/gpu/command_buffer/tests/gl_depth_texture_unittest.cc
@@ -7,6 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "gpu/command_buffer/tests/gl_manager.h"
 #include "gpu/command_buffer/tests/gl_test_utils.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -133,7 +134,7 @@
     { GL_DEPTH_COMPONENT, GL_UNSIGNED_INT },
     { GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES },
   };
-  for (size_t ii = 0; ii < arraysize(format_types); ++ii) {
+  for (size_t ii = 0; ii < base::size(format_types); ++ii) {
     const FormatType& format_type = format_types[ii];
     GLenum format = format_type.format;
     GLenum type = format_type.type;
diff --git a/gpu/config/gpu_control_list_entry_unittest.cc b/gpu/config/gpu_control_list_entry_unittest.cc
index b02a5ab..6214f40 100644
--- a/gpu/config/gpu_control_list_entry_unittest.cc
+++ b/gpu/config/gpu_control_list_entry_unittest.cc
@@ -4,6 +4,7 @@
 
 #include <stddef.h>
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "gpu/config/gpu_control_list.h"
 #include "gpu/config/gpu_control_list_testing_data.h"
@@ -87,7 +88,7 @@
   EXPECT_EQ(kOsAny, entry.conditions.os_type);
   const GpuControlList::OsType os_type[] = {kOsMacosx, kOsWin, kOsLinux,
                                             kOsChromeOS, kOsAndroid};
-  for (size_t i = 0; i < arraysize(os_type); ++i)
+  for (size_t i = 0; i < base::size(os_type); ++i)
     EXPECT_TRUE(entry.Contains(os_type[i], "10.6", gpu_info()));
 }
 
@@ -96,7 +97,7 @@
   EXPECT_EQ(kOsLinux, entry.conditions.os_type);
   const GpuControlList::OsType os_type[] = {kOsMacosx, kOsWin, kOsChromeOS,
                                             kOsAndroid};
-  for (size_t i = 0; i < arraysize(os_type); ++i)
+  for (size_t i = 0; i < base::size(os_type); ++i)
     EXPECT_FALSE(entry.Contains(os_type[i], "10.6", gpu_info()));
   EXPECT_TRUE(entry.Contains(kOsLinux, "10.6", gpu_info()));
 }
@@ -107,7 +108,7 @@
   EXPECT_EQ(kOsLinux, entry.conditions.os_type);
   const GpuControlList::OsType os_type[] = {kOsMacosx, kOsWin, kOsLinux,
                                             kOsChromeOS, kOsAndroid};
-  for (size_t i = 0; i < arraysize(os_type); ++i)
+  for (size_t i = 0; i < base::size(os_type); ++i)
     EXPECT_FALSE(entry.Contains(os_type[i], "10.6", gpu_info()));
 }
 
@@ -117,7 +118,7 @@
   EXPECT_EQ(kOsLinux, entry.conditions.os_type);
   const GpuControlList::OsType os_type[] = {kOsMacosx, kOsWin, kOsChromeOS,
                                             kOsAndroid};
-  for (size_t i = 0; i < arraysize(os_type); ++i)
+  for (size_t i = 0; i < base::size(os_type); ++i)
     EXPECT_FALSE(entry.Contains(os_type[i], "10.6", gpu_info()));
   EXPECT_TRUE(entry.Contains(kOsLinux, "10.6", gpu_info()));
 }
@@ -139,7 +140,7 @@
   EXPECT_EQ(kOsAny, entry.conditions.os_type);
   const GpuControlList::OsType os_type[] = {kOsMacosx, kOsWin, kOsLinux,
                                             kOsChromeOS, kOsAndroid};
-  for (size_t i = 0; i < arraysize(os_type); ++i)
+  for (size_t i = 0; i < base::size(os_type); ++i)
     EXPECT_TRUE(entry.Contains(os_type[i], "10.6", gpu_info()));
 }
 
@@ -148,7 +149,7 @@
   EXPECT_EQ(kOsChromeOS, entry.conditions.os_type);
   const GpuControlList::OsType os_type[] = {kOsMacosx, kOsWin, kOsLinux,
                                             kOsAndroid};
-  for (size_t i = 0; i < arraysize(os_type); ++i)
+  for (size_t i = 0; i < base::size(os_type); ++i)
     EXPECT_FALSE(entry.Contains(os_type[i], "10.6", gpu_info()));
   EXPECT_TRUE(entry.Contains(kOsChromeOS, "10.6", gpu_info()));
 }
@@ -548,7 +549,7 @@
     const Entry& entry = GetEntry(kGpuControlListEntryTest_OsComparisonAny);
     const GpuControlList::OsType os_type[] = {kOsWin, kOsLinux, kOsMacosx,
                                               kOsChromeOS, kOsAndroid};
-    for (size_t i = 0; i < arraysize(os_type); ++i) {
+    for (size_t i = 0; i < base::size(os_type); ++i) {
       EXPECT_TRUE(entry.Contains(os_type[i], std::string(), gpu_info()));
       EXPECT_TRUE(entry.Contains(os_type[i], "7.8", gpu_info()));
     }
diff --git a/gpu/config/gpu_driver_bug_list.cc b/gpu/config/gpu_driver_bug_list.cc
index 6e828f7..af5331d2 100644
--- a/gpu/config/gpu_driver_bug_list.cc
+++ b/gpu/config/gpu_driver_bug_list.cc
@@ -5,6 +5,7 @@
 #include "gpu/config/gpu_driver_bug_list.h"
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "gpu/config/gpu_driver_bug_list_autogen.h"
 #include "gpu/config/gpu_driver_bug_workaround_type.h"
 #include "gpu/config/gpu_switches.h"
@@ -44,7 +45,7 @@
     const GpuControlListData& data) {
   std::unique_ptr<GpuDriverBugList> list(new GpuDriverBugList(data));
 
-  DCHECK_EQ(static_cast<int>(arraysize(kFeatureList)),
+  DCHECK_EQ(static_cast<int>(base::size(kFeatureList)),
             NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES);
   for (int i = 0; i < NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES; ++i) {
     list->AddSupportedFeature(kFeatureList[i].name,
diff --git a/gpu/config/gpu_dx_diagnostics_win.cc b/gpu/config/gpu_dx_diagnostics_win.cc
index cd239609..9e85f16 100644
--- a/gpu/config/gpu_dx_diagnostics_win.cc
+++ b/gpu/config/gpu_dx_diagnostics_win.cc
@@ -9,6 +9,7 @@
 #include <dxdiag.h>
 #include <windows.h>
 
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/com_init_util.h"
@@ -34,7 +35,7 @@
   if (SUCCEEDED(hr)) {
     for (DWORD i = 0; i < prop_count; i++) {
       WCHAR prop_name16[256];
-      hr = container->EnumPropNames(i, prop_name16, arraysize(prop_name16));
+      hr = container->EnumPropNames(i, prop_name16, base::size(prop_name16));
       if (SUCCEEDED(hr)) {
         std::string prop_name8 = base::WideToUTF8(prop_name16);
 
@@ -70,9 +71,8 @@
     if (SUCCEEDED(hr)) {
       for (DWORD i = 0; i < child_count; i++) {
         WCHAR child_name16[256];
-        hr = container->EnumChildContainerNames(i,
-                                                child_name16,
-                                                arraysize(child_name16));
+        hr = container->EnumChildContainerNames(i, child_name16,
+                                                base::size(child_name16));
         if (SUCCEEDED(hr)) {
           std::string child_name8 = base::WideToUTF8(child_name16);
           DxDiagNode* output_child = &output->children[child_name8];
diff --git a/gpu/config/gpu_info_collector.cc b/gpu/config/gpu_info_collector.cc
index af06601..c47e7f3 100644
--- a/gpu/config/gpu_info_collector.cc
+++ b/gpu/config/gpu_info_collector.cc
@@ -14,6 +14,7 @@
 #include "base/command_line.h"
 #include "base/logging.h"
 #include "base/metrics/histogram_functions.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
@@ -294,16 +295,16 @@
   uint32_t active_vendor_id = 0;
   if (!gpu_info->gl_vendor.empty()) {
     std::string gl_vendor_lower = base::ToLowerASCII(gpu_info->gl_vendor);
-    int index = StringContainsName(
-        gl_vendor_lower, kVendorNames, arraysize(kVendorNames));
+    int index = StringContainsName(gl_vendor_lower, kVendorNames,
+                                   base::size(kVendorNames));
     if (index >= 0) {
       active_vendor_id = kVendorIDs[index];
     }
   }
   if (active_vendor_id == 0 && !gpu_info->gl_renderer.empty()) {
     std::string gl_renderer_lower = base::ToLowerASCII(gpu_info->gl_renderer);
-    int index = StringContainsName(
-        gl_renderer_lower, kVendorNames, arraysize(kVendorNames));
+    int index = StringContainsName(gl_renderer_lower, kVendorNames,
+                                   base::size(kVendorNames));
     if (index >= 0) {
       active_vendor_id = kVendorIDs[index];
     }
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index 5e954369..8974101 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -4,6 +4,7 @@
 
 #include "gpu/gles2_conform_support/egl/display.h"
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "gpu/gles2_conform_support/egl/config.h"
 #include "gpu/gles2_conform_support/egl/context.h"
@@ -86,7 +87,7 @@
   if (!configs)
     config_size = 0;
   *num_config = 0;
-  for (size_t i = 0; i < arraysize(configs_); ++i) {
+  for (size_t i = 0; i < base::size(configs_); ++i) {
     if (configs_[i]->Matches(attrib_list)) {
       if (*num_config < config_size) {
         configs[*num_config] = configs_[i].get();
@@ -109,9 +110,9 @@
   InitializeConfigsIfNeeded();
   if (!configs)
     config_size = 0;
-  *num_config = arraysize(configs_);
+  *num_config = base::size(configs_);
   size_t count =
-      std::min(arraysize(configs_), static_cast<size_t>(config_size));
+      std::min(base::size(configs_), static_cast<size_t>(config_size));
   for (size_t i = 0; i < count; ++i)
     configs[i] = configs_[i].get();
   return ts->ReturnSuccess(EGL_TRUE);
diff --git a/gpu/ipc/service/gpu_watchdog_thread.cc b/gpu/ipc/service/gpu_watchdog_thread.cc
index 7a546b7..81a6337c 100644
--- a/gpu/ipc/service/gpu_watchdog_thread.cc
+++ b/gpu/ipc/service/gpu_watchdog_thread.cc
@@ -15,12 +15,12 @@
 #include "base/files/file_util.h"
 #include "base/format_macros.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/power_monitor/power_monitor.h"
 #include "base/process/process.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/threading/platform_thread.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -525,7 +525,7 @@
 void GpuWatchdogThread::SetupXChangeProp() {
   DCHECK(display_);
   XChangeProperty(display_, window_, atom_, XA_STRING, 8, PropModeReplace, text,
-                  (arraysize(text) - 1));
+                  (base::size(text) - 1));
 }
 
 bool GpuWatchdogThread::MatchXEventAtom(XEvent* event) {
diff --git a/ios/chrome/browser/snapshots/snapshot_tab_helper.h b/ios/chrome/browser/snapshots/snapshot_tab_helper.h
index f3dbe40a..99749ad 100644
--- a/ios/chrome/browser/snapshots/snapshot_tab_helper.h
+++ b/ios/chrome/browser/snapshots/snapshot_tab_helper.h
@@ -11,8 +11,10 @@
 
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
 #include "components/infobars/core/infobar_manager.h"
-#import "ios/web/public/web_state/web_state_observer.h"
+#import "ios/web/public/web_state/web_state.h"
+#include "ios/web/public/web_state/web_state_observer.h"
 #import "ios/web/public/web_state/web_state_user_data.h"
 
 @class SnapshotGenerator;
@@ -87,6 +89,10 @@
 
   web::WebState* web_state_ = nullptr;
   SnapshotGenerator* snapshot_generator_ = nil;
+
+  // Manages this object as an observer of |web_state_|.
+  ScopedObserver<web::WebState, web::WebStateObserver> web_state_observer_;
+
   std::unique_ptr<infobars::InfoBarManager::Observer> infobar_observer_;
   bool ignore_next_load_ = false;
 
diff --git a/ios/chrome/browser/snapshots/snapshot_tab_helper.mm b/ios/chrome/browser/snapshots/snapshot_tab_helper.mm
index 4aaab675..d478e3c5 100644
--- a/ios/chrome/browser/snapshots/snapshot_tab_helper.mm
+++ b/ios/chrome/browser/snapshots/snapshot_tab_helper.mm
@@ -165,7 +165,9 @@
 
 SnapshotTabHelper::SnapshotTabHelper(web::WebState* web_state,
                                      NSString* session_id)
-    : web_state_(web_state), weak_ptr_factory_(this) {
+    : web_state_(web_state),
+      web_state_observer_(this),
+      weak_ptr_factory_(this) {
   snapshot_generator_ = [[SnapshotGenerator alloc] initWithWebState:web_state_
                                                   snapshotSessionId:session_id];
 
@@ -176,7 +178,7 @@
         std::make_unique<SnapshotInfobarObserver>(this, infobar_manager);
   }
 
-  web_state_->AddObserver(this);
+  web_state_observer_.Add(web_state_);
 }
 
 void SnapshotTabHelper::DidStartLoading(web::WebState* web_state) {
@@ -203,7 +205,7 @@
 }
 
 void SnapshotTabHelper::WebStateDestroyed(web::WebState* web_state) {
-  DCHECK_EQ(web_state_, web_state_);
-  web_state_->RemoveObserver(this);
+  DCHECK_EQ(web_state_, web_state);
+  web_state_observer_.Remove(web_state);
   web_state_ = nullptr;
 }
diff --git a/ios/chrome/browser/ui/settings/cells/BUILD.gn b/ios/chrome/browser/ui/settings/cells/BUILD.gn
index 2326f3f4..d1f55a4b 100644
--- a/ios/chrome/browser/ui/settings/cells/BUILD.gn
+++ b/ios/chrome/browser/ui/settings/cells/BUILD.gn
@@ -40,6 +40,8 @@
     "settings_switch_item.mm",
     "settings_text_item.h",
     "settings_text_item.mm",
+    "sync_switch_item.h",
+    "sync_switch_item.mm",
     "table_view_clear_browsing_data_item.h",
     "table_view_clear_browsing_data_item.mm",
     "text_and_error_item.h",
diff --git a/ios/chrome/browser/ui/settings/cells/sync_switch_item.h b/ios/chrome/browser/ui/settings/cells/sync_switch_item.h
new file mode 100644
index 0000000..b8136f4
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/cells/sync_switch_item.h
@@ -0,0 +1,33 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SYNC_SWITCH_ITEM_H_
+#define IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SYNC_SWITCH_ITEM_H_
+
+#import <UIKit/UIKit.h>
+
+#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
+
+// SyncSwitchItem is a model class that uses SettingsSwitchCell.
+@interface SyncSwitchItem : TableViewItem
+
+// The text to display.
+@property(nonatomic, copy) NSString* text;
+
+// The detail text string.
+@property(nonatomic, copy) NSString* detailText;
+
+// The current state of the switch.
+@property(nonatomic, assign, getter=isOn) BOOL on;
+
+// Whether or not the switch is enabled.  Disabled switches are automatically
+// drawn as in the "off" state, with dimmed text.
+@property(nonatomic, assign, getter=isEnabled) BOOL enabled;
+
+// SyncSetupService::SyncableDatatype value for the item.
+@property(nonatomic, assign) NSInteger dataType;
+
+@end
+
+#endif  // IOS_CHROME_BROWSER_UI_SETTINGS_CELLS_SYNC_SWITCH_ITEM_H_
diff --git a/ios/chrome/browser/ui/settings/cells/sync_switch_item.mm b/ios/chrome/browser/ui/settings/cells/sync_switch_item.mm
new file mode 100644
index 0000000..0ecf1fe8
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/cells/sync_switch_item.mm
@@ -0,0 +1,38 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h"
+
+#import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation SyncSwitchItem
+
+- (instancetype)initWithType:(NSInteger)type {
+  self = [super initWithType:type];
+  if (self) {
+    self.cellClass = [SettingsSwitchCell class];
+    self.enabled = YES;
+  }
+  return self;
+}
+
+#pragma mark TableViewItem
+
+- (void)configureCell:(SettingsSwitchCell*)cell
+           withStyler:(ChromeTableViewStyler*)styler {
+  [super configureCell:cell withStyler:styler];
+  cell.textLabel.text = self.text;
+  cell.detailTextLabel.text = self.detailText;
+  cell.switchView.enabled = self.enabled;
+  cell.switchView.on = self.on;
+  cell.textLabel.textColor =
+      [SettingsSwitchCell defaultTextColorForState:cell.switchView.state];
+  cell.selectionStyle = UITableViewCellSelectionStyleNone;
+}
+
+@end
diff --git a/ios/chrome/browser/ui/settings/table_cell_catalog_view_controller.mm b/ios/chrome/browser/ui/settings/table_cell_catalog_view_controller.mm
index b630f74..87a2490a 100644
--- a/ios/chrome/browser/ui/settings/table_cell_catalog_view_controller.mm
+++ b/ios/chrome/browser/ui/settings/table_cell_catalog_view_controller.mm
@@ -12,6 +12,7 @@
 #import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
 #import "ios/chrome/browser/ui/settings/cells/settings_detail_item.h"
 #import "ios/chrome/browser/ui/settings/cells/settings_switch_item.h"
+#import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h"
 #import "ios/chrome/browser/ui/table_view/cells/table_view_detail_text_item.h"
 #import "ios/chrome/browser/ui/table_view/cells/table_view_image_item.h"
 #import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
@@ -55,6 +56,7 @@
   ItemTypeDetailText,
   ItemTypeSettingsSwitch1,
   ItemTypeSettingsSwitch2,
+  ItemTypeSyncSwitch,
   ItemTypeAutofillEditItem,
   ItemTypeAutofillData,
   ItemTypeAccount,
@@ -176,19 +178,28 @@
 
   SettingsSwitchItem* settingsSwitchItem =
       [[SettingsSwitchItem alloc] initWithType:ItemTypeSettingsSwitch1];
-  settingsSwitchItem.text = @"This is a switch item";
+  settingsSwitchItem.text = @"This is a settings switch item";
   [model addItem:settingsSwitchItem
       toSectionWithIdentifier:SectionIdentifierSettings];
 
   SettingsSwitchItem* settingsSwitchItem2 =
       [[SettingsSwitchItem alloc] initWithType:ItemTypeSettingsSwitch2];
-  settingsSwitchItem2.text = @"This is a disabled switch item";
+  settingsSwitchItem2.text = @"This is a disabled settings switch item";
   settingsSwitchItem2.detailText = @"This is a switch item with detail text";
   settingsSwitchItem2.on = YES;
   settingsSwitchItem2.enabled = NO;
   [model addItem:settingsSwitchItem2
       toSectionWithIdentifier:SectionIdentifierSettings];
 
+  SyncSwitchItem* syncSwitchItem =
+      [[SyncSwitchItem alloc] initWithType:ItemTypeSyncSwitch];
+  syncSwitchItem.text = @"This is a sync switch item";
+  syncSwitchItem.detailText = @"This is a sync switch item with detail text";
+  syncSwitchItem.on = YES;
+  syncSwitchItem.enabled = NO;
+  [model addItem:syncSwitchItem
+      toSectionWithIdentifier:SectionIdentifierSettings];
+
   EncryptionItem* encryptionChecked =
       [[EncryptionItem alloc] initWithType:ItemTypeEncryption];
   encryptionChecked.text =
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn
index 6e5b9fa5..4ba52f6 100644
--- a/ios/web/BUILD.gn
+++ b/ios/web/BUILD.gn
@@ -51,6 +51,7 @@
     "//services/network:network_service",
     "//services/network/public/mojom",
     "//services/service_manager",
+    "//services/service_manager/embedder",
     "//services/service_manager/public/cpp",
   ]
 
diff --git a/ios/web/service_manager_context.mm b/ios/web/service_manager_context.mm
index df31e85..3f10f2b9 100644
--- a/ios/web/service_manager_context.mm
+++ b/ios/web/service_manager_context.mm
@@ -26,8 +26,10 @@
 #include "ios/web/public/web_task_traits.h"
 #include "ios/web/public/web_thread.h"
 #include "ios/web/service_manager_connection_impl.h"
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
 #include "services/catalog/public/mojom/constants.mojom.h"
 #include "services/service_manager/connect_params.h"
+#include "services/service_manager/embedder/manifest_utils.h"
 #include "services/service_manager/public/cpp/connector.h"
 #include "services/service_manager/public/cpp/constants.h"
 #include "services/service_manager/public/cpp/manifest.h"
diff --git a/jingle/glue/fake_ssl_client_socket.cc b/jingle/glue/fake_ssl_client_socket.cc
index 6f2a73f..cfc2f5a1 100644
--- a/jingle/glue/fake_ssl_client_socket.cc
+++ b/jingle/glue/fake_ssl_client_socket.cc
@@ -11,7 +11,7 @@
 
 #include "base/compiler_specific.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "net/base/io_buffer.h"
 #include "net/base/net_errors.h"
 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
@@ -73,12 +73,12 @@
 
 base::StringPiece FakeSSLClientSocket::GetSslClientHello() {
   return base::StringPiece(reinterpret_cast<const char*>(kSslClientHello),
-                           arraysize(kSslClientHello));
+                           base::size(kSslClientHello));
 }
 
 base::StringPiece FakeSSLClientSocket::GetSslServerHello() {
   return base::StringPiece(reinterpret_cast<const char*>(kSslServerHello),
-                           arraysize(kSslServerHello));
+                           base::size(kSslServerHello));
 }
 
 FakeSSLClientSocket::FakeSSLClientSocket(
@@ -86,10 +86,10 @@
     : transport_socket_(std::move(transport_socket)),
       next_handshake_state_(STATE_NONE),
       handshake_completed_(false),
-      write_buf_(NewDrainableIOBufferWithSize(arraysize(kSslClientHello))),
-      read_buf_(NewDrainableIOBufferWithSize(arraysize(kSslServerHello))) {
+      write_buf_(NewDrainableIOBufferWithSize(base::size(kSslClientHello))),
+      read_buf_(NewDrainableIOBufferWithSize(base::size(kSslServerHello))) {
   CHECK(transport_socket_.get());
-  std::memcpy(write_buf_->data(), kSslClientHello, arraysize(kSslClientHello));
+  std::memcpy(write_buf_->data(), kSslClientHello, base::size(kSslClientHello));
 }
 
 FakeSSLClientSocket::~FakeSSLClientSocket() {}
@@ -294,7 +294,7 @@
     return net::ERR_UNEXPECTED;
   }
   const uint8_t* expected_data_start =
-      &kSslServerHello[arraysize(kSslServerHello) -
+      &kSslServerHello[base::size(kSslServerHello) -
                        read_buf_->BytesRemaining()];
   if (std::memcmp(expected_data_start, read_buf_->data(), read) != 0) {
     return net::ERR_UNEXPECTED;
diff --git a/jingle/glue/fake_ssl_client_socket_unittest.cc b/jingle/glue/fake_ssl_client_socket_unittest.cc
index 706512d5..d86e760 100644
--- a/jingle/glue/fake_ssl_client_socket_unittest.cc
+++ b/jingle/glue/fake_ssl_client_socket_unittest.cc
@@ -13,9 +13,9 @@
 #include <vector>
 
 #include "base/callback_helpers.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "net/base/io_buffer.h"
 #include "net/base/ip_address.h"
 #include "net/base/test_completion_callback.h"
@@ -173,9 +173,9 @@
       AddChunkedOps(ssl_server_hello, read_chunk_size, mode, &reads);
       AddChunkedOps(ssl_client_hello, write_chunk_size, mode, &writes);
       reads.push_back(
-          net::MockRead(mode, kReadTestData, arraysize(kReadTestData)));
+          net::MockRead(mode, kReadTestData, base::size(kReadTestData)));
       writes.push_back(
-          net::MockWrite(mode, kWriteTestData, arraysize(kWriteTestData)));
+          net::MockWrite(mode, kWriteTestData, base::size(kWriteTestData)));
     }
     SetData(mock_connect, &reads, &writes);
 
@@ -191,7 +191,7 @@
       }
       ExpectStatus(mode, net::OK, status, &test_completion_callback);
       if (fake_ssl_client_socket.IsConnected()) {
-        int read_len = arraysize(kReadTestData);
+        int read_len = base::size(kReadTestData);
         int read_buf_len = 2 * read_len;
         auto read_buf = base::MakeRefCounted<net::IOBuffer>(read_buf_len);
         int read_status = fake_ssl_client_socket.Read(
@@ -201,9 +201,9 @@
         auto write_buf =
             base::MakeRefCounted<net::StringIOBuffer>(kWriteTestData);
         int write_status = fake_ssl_client_socket.Write(
-            write_buf.get(), arraysize(kWriteTestData),
+            write_buf.get(), base::size(kWriteTestData),
             test_completion_callback.callback(), TRAFFIC_ANNOTATION_FOR_TESTS);
-        ExpectStatus(mode, arraysize(kWriteTestData), write_status,
+        ExpectStatus(mode, base::size(kWriteTestData), write_status,
                      &test_completion_callback);
       } else {
         ADD_FAILURE();
@@ -251,7 +251,7 @@
         if (error == ERR_MALFORMED_SERVER_HELLO) {
           static const char kBadData[] = "BAD_DATA";
           reads[index].data = kBadData;
-          reads[index].data_len = arraysize(kBadData);
+          reads[index].data_len = base::size(kBadData);
         } else {
           reads[index].result = error;
           reads[index].data = NULL;
diff --git a/jingle/glue/network_service_async_socket_unittest.cc b/jingle/glue/network_service_async_socket_unittest.cc
index 39f7137..e40ccb0c 100644
--- a/jingle/glue/network_service_async_socket_unittest.cc
+++ b/jingle/glue/network_service_async_socket_unittest.cc
@@ -12,11 +12,11 @@
 
 #include "base/containers/circular_deque.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
 #include "base/message_loop/message_pump_default.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/strcat.h"
 #include "base/strings/string_number_conversions.h"
 #include "mojo/public/cpp/bindings/binding.h"
@@ -912,7 +912,7 @@
   async_socket_data_provider_.AddWrite(
       net::MockWrite(net::SYNCHRONOUS, kWriteData + 3, 5));
   async_socket_data_provider_.AddWrite(net::MockWrite(
-      net::SYNCHRONOUS, kWriteData + 8, arraysize(kWriteData) - 8));
+      net::SYNCHRONOUS, kWriteData + 8, base::size(kWriteData) - 8));
   DoOpenClosed();
 
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData, 3));
@@ -920,7 +920,7 @@
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData + 3, 5));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(
-      ns_async_socket_->Write(kWriteData + 8, arraysize(kWriteData) - 8));
+      ns_async_socket_->Write(kWriteData + 8, base::size(kWriteData) - 8));
   base::RunLoop().RunUntilIdle();
 
   ExpectNoSignal();
@@ -936,14 +936,14 @@
   async_socket_data_provider_.AddWrite(
       net::MockWrite(net::ASYNC, kWriteData + 3, 5));
   async_socket_data_provider_.AddWrite(
-      net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8));
+      net::MockWrite(net::ASYNC, kWriteData + 8, base::size(kWriteData) - 8));
 
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData, 3));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData + 3, 5));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(
-      ns_async_socket_->Write(kWriteData + 8, arraysize(kWriteData) - 8));
+      ns_async_socket_->Write(kWriteData + 8, base::size(kWriteData) - 8));
   base::RunLoop().RunUntilIdle();
 
   ExpectNoSignal();
@@ -966,7 +966,7 @@
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData + 3, 5));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(
-      ns_async_socket_->Write(kWriteData + 8, arraysize(kWriteData) - 8));
+      ns_async_socket_->Write(kWriteData + 8, base::size(kWriteData) - 8));
   base::RunLoop().RunUntilIdle();
 
   ExpectSignalSocketState(SignalSocketState(
@@ -1164,7 +1164,7 @@
   async_socket_data_provider_.AddWrite(
       net::MockWrite(net::SYNCHRONOUS, kWriteData + 3, 5));
   async_socket_data_provider_.AddWrite(net::MockWrite(
-      net::SYNCHRONOUS, kWriteData + 8, arraysize(kWriteData) - 8));
+      net::SYNCHRONOUS, kWriteData + 8, base::size(kWriteData) - 8));
   DoSSLOpenClosed();
 
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData, 3));
@@ -1172,7 +1172,7 @@
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData + 3, 5));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(
-      ns_async_socket_->Write(kWriteData + 8, arraysize(kWriteData) - 8));
+      ns_async_socket_->Write(kWriteData + 8, base::size(kWriteData) - 8));
   base::RunLoop().RunUntilIdle();
 
   ExpectNoSignal();
@@ -1188,14 +1188,14 @@
   async_socket_data_provider_.AddWrite(
       net::MockWrite(net::ASYNC, kWriteData + 3, 5));
   async_socket_data_provider_.AddWrite(
-      net::MockWrite(net::ASYNC, kWriteData + 8, arraysize(kWriteData) - 8));
+      net::MockWrite(net::ASYNC, kWriteData + 8, base::size(kWriteData) - 8));
 
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData, 3));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(ns_async_socket_->Write(kWriteData + 3, 5));
   base::RunLoop().RunUntilIdle();
   EXPECT_TRUE(
-      ns_async_socket_->Write(kWriteData + 8, arraysize(kWriteData) - 8));
+      ns_async_socket_->Write(kWriteData + 8, base::size(kWriteData) - 8));
   base::RunLoop().RunUntilIdle();
 
   ExpectNoSignal();
diff --git a/jingle/glue/thread_wrapper.cc b/jingle/glue/thread_wrapper.cc
index 28ee6a0..d63fe6b 100644
--- a/jingle/glue/thread_wrapper.cc
+++ b/jingle/glue/thread_wrapper.cc
@@ -10,7 +10,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/lazy_instance.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_local.h"
 #include "base/trace_event/trace_event.h"
 #include "third_party/webrtc/rtc_base/nullsocketserver.h"
@@ -200,7 +200,7 @@
   while (!pending_send.done_event.IsSignaled()) {
     base::WaitableEvent* events[] = {&pending_send.done_event,
                                      &current_thread->pending_send_event_};
-    size_t event = base::WaitableEvent::WaitMany(events, arraysize(events));
+    size_t event = base::WaitableEvent::WaitMany(events, base::size(events));
     DCHECK(event == 0 || event == 1);
 
     if (event == 1)
diff --git a/jingle/notifier/base/weak_xmpp_client_unittest.cc b/jingle/notifier/base/weak_xmpp_client_unittest.cc
index e67b572..b2701dc3 100644
--- a/jingle/notifier/base/weak_xmpp_client_unittest.cc
+++ b/jingle/notifier/base/weak_xmpp_client_unittest.cc
@@ -6,9 +6,9 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "jingle/glue/task_pump.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -49,15 +49,15 @@
   void ExpectSignalCalls() {
     EXPECT_CALL(mock_xmpp_delegate_, OnStateChange(kState));
     EXPECT_CALL(mock_xmpp_delegate_,
-                OnInputLog(kInputLog, arraysize(kInputLog)));
+                OnInputLog(kInputLog, base::size(kInputLog)));
     EXPECT_CALL(mock_xmpp_delegate_,
-                OnOutputLog(kOutputLog, arraysize(kOutputLog)));
+                OnOutputLog(kOutputLog, base::size(kOutputLog)));
   }
 
   void RaiseSignals(buzz::XmppClient* xmpp_client) {
     xmpp_client->SignalStateChange(kState);
-    xmpp_client->SignalLogInput(kInputLog, arraysize(kInputLog));
-    xmpp_client->SignalLogOutput(kOutputLog, arraysize(kOutputLog));
+    xmpp_client->SignalLogInput(kInputLog, base::size(kInputLog));
+    xmpp_client->SignalLogOutput(kOutputLog, base::size(kOutputLog));
   }
 
   // Needed by TaskPump.
diff --git a/mash/BUILD.gn b/mash/BUILD.gn
index d1773fbf..b9aa26a 100644
--- a/mash/BUILD.gn
+++ b/mash/BUILD.gn
@@ -13,6 +13,7 @@
   testonly = true
 
   deps = [
+    ":mash_catalog",
     "//components/services/leveldb",
     "//mash/catalog_viewer",
     "//mash/example",
@@ -35,14 +36,16 @@
   standalone_services = [
     "//components/services/leveldb:manifest",
     "//mash/catalog_viewer:manifest",
-    "//mash/example/views_examples:manifest",
-    "//mash/example/window_type_launcher:manifest",
     "//mash/session:manifest",
     "//mash/task_viewer:manifest",
     "//services/ws/ime/test_ime_driver:manifest",
     "//services/viz:manifest",
   ]
 
+  executable_overrides = [ "content_packaged_services:@EXE_DIR/chrome" ]
+
+  catalog_deps = [ "//mash/example:catalog" ]
+
   if (is_chromeos) {
     standalone_services += [
       "//ash:manifest",
@@ -62,8 +65,13 @@
   }
 }
 
-catalog_cpp_source("mash_catalog_source") {
+copy("mash_catalog") {
   testonly = true
-  catalog = ":catalog"
-  generated_function_name = "CreateMashCatalog"
+  sources = get_target_outputs(":catalog")
+  outputs = [
+    "$root_out_dir/mash_catalog.json",
+  ]
+  deps = [
+    ":catalog",
+  ]
 }
diff --git a/mash/example/BUILD.gn b/mash/example/BUILD.gn
index 1e772aae..a210a3c 100644
--- a/mash/example/BUILD.gn
+++ b/mash/example/BUILD.gn
@@ -18,3 +18,10 @@
     deps += [ "//ash:ash_service" ]
   }
 }
+
+catalog("catalog") {
+  standalone_services = [
+    "//mash/example/views_examples:manifest",
+    "//mash/example/window_type_launcher:manifest",
+  ]
+}
diff --git a/mash/example/window_type_launcher/window_type_launcher.cc b/mash/example/window_type_launcher/window_type_launcher.cc
index b6554153..eb58c4a 100644
--- a/mash/example/window_type_launcher/window_type_launcher.cc
+++ b/mash/example/window_type_launcher/window_type_launcher.cc
@@ -6,10 +6,10 @@
 
 #include <stdint.h>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/platform_thread.h"
@@ -97,7 +97,7 @@
       : modal_type_(modal_type),
         color_(g_colors[g_color_index]),
         open_button_(MdTextButton::Create(this, base::ASCIIToUTF16("Moar!"))) {
-    ++g_color_index %= arraysize(g_colors);
+    ++g_color_index %= base::size(g_colors);
     AddChildView(open_button_);
   }
   ~ModalWindow() override = default;
@@ -152,7 +152,7 @@
  public:
   NonModalTransient()
       : color_(g_colors[g_color_index]) {
-    ++g_color_index %= arraysize(g_colors);
+    ++g_color_index %= base::size(g_colors);
   }
   ~NonModalTransient() override = default;
 
diff --git a/mash/runner/BUILD.gn b/mash/runner/BUILD.gn
index a82a207..4cb3030c 100644
--- a/mash/runner/BUILD.gn
+++ b/mash/runner/BUILD.gn
@@ -13,10 +13,13 @@
     "//base",
     "//base:i18n",
     "//base/test:test_support",
-    "//mash:mash_catalog_source",
     "//mojo/core/embedder",
     "//services/service_manager",
     "//services/service_manager/runner:init",
     "//services/service_manager/standalone",
   ]
+
+  data_deps = [
+    "//mash:mash_catalog",
+  ]
 }
diff --git a/mash/runner/main.cc b/mash/runner/main.cc
index e08d303..68e56a3 100644
--- a/mash/runner/main.cc
+++ b/mash/runner/main.cc
@@ -25,13 +25,19 @@
 #include "base/threading/platform_thread.h"
 #include "base/threading/thread.h"
 #include "build/build_config.h"
-#include "mash/mash_catalog_source.h"
 #include "mojo/core/embedder/embedder.h"
 #include "mojo/core/embedder/scoped_ipc_support.h"
 #include "services/service_manager/runner/init.h"
 #include "services/service_manager/standalone/context.h"
 #include "services/service_manager/switches.h"
 
+namespace {
+
+const base::FilePath::CharType kMashCatalogFilename[] =
+    FILE_PATH_LITERAL("mash_catalog.json");
+
+}  // namespace
+
 int main(int argc, char** argv) {
   base::CommandLine::Init(argc, argv);
 
@@ -48,11 +54,19 @@
 #endif
   base::PlatformThread::SetName("service_manager");
 
+  std::string catalog_contents;
+  base::FilePath exe_path;
+  base::PathService::Get(base::DIR_EXE, &exe_path);
+  base::FilePath catalog_path = exe_path.Append(kMashCatalogFilename);
+  bool result = base::ReadFileToString(catalog_path, &catalog_contents);
+  DCHECK(result);
+  std::unique_ptr<base::Value> manifest_value =
+      base::JSONReader::Read(catalog_contents);
+  DCHECK(manifest_value);
+
 #if defined(OS_WIN) && defined(COMPONENT_BUILD)
   // In Windows component builds, ensure that loaded service binaries always
   // search this exe's dir for DLLs.
-  base::FilePath exe_path;
-  base::PathService::Get(base::DIR_EXE, &exe_path);
   SetDllDirectory(exe_path.value().c_str());
 #endif
 
@@ -72,7 +86,7 @@
 
   base::test::ScopedTaskEnvironment scoped_task_environment;
   service_manager::Context service_manager_context(nullptr,
-                                                   CreateMashCatalog());
+                                                   std::move(manifest_value));
   base::RunLoop loop;
   scoped_task_environment.GetMainThreadTaskRunner()->PostTask(
       FROM_HERE,
diff --git a/media/audio/alsa/alsa_input.cc b/media/audio/alsa/alsa_input.cc
index 28a0ed6b..a707482 100644
--- a/media/audio/alsa/alsa_input.cc
+++ b/media/audio/alsa/alsa_input.cc
@@ -9,8 +9,8 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "media/audio/alsa/alsa_output.h"
 #include "media/audio/alsa/alsa_util.h"
 #include "media/audio/alsa/alsa_wrapper.h"
@@ -64,7 +64,7 @@
 
   if (device_name_ == kAutoSelectDevice) {
     const char* device_names[] = { kDefaultDevice1, kDefaultDevice2 };
-    for (size_t i = 0; i < arraysize(device_names); ++i) {
+    for (size_t i = 0; i < base::size(device_names); ++i) {
       device_handle_ = alsa_util::OpenCaptureDevice(
           wrapper_, device_names[i], params_.channels(), params_.sample_rate(),
           kAlsaSampleFormat, buffer_us, packet_us);
diff --git a/media/audio/alsa/audio_manager_alsa.cc b/media/audio/alsa/audio_manager_alsa.cc
index 91108f0..3f0c60e 100644
--- a/media/audio/alsa/audio_manager_alsa.cc
+++ b/media/audio/alsa/audio_manager_alsa.cc
@@ -8,7 +8,6 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/free_deleter.h"
 #include "base/metrics/histogram.h"
 #include "base/stl_util.h"
@@ -175,7 +174,7 @@
   // it or not.
   if (type == kStreamCapture) {
     // Check if the device is in the list of invalid devices.
-    for (size_t i = 0; i < arraysize(kInvalidAudioInputDevices); ++i) {
+    for (size_t i = 0; i < base::size(kInvalidAudioInputDevices); ++i) {
       if (strncmp(kInvalidAudioInputDevices[i], device_name,
                   strlen(kInvalidAudioInputDevices[i])) == 0)
         return false;
@@ -190,7 +189,7 @@
   // TODO(joi): Should we prefer "hw" instead?
   static const char kDeviceTypeDesired[] = "plughw";
   return strncmp(kDeviceTypeDesired, device_name,
-                 arraysize(kDeviceTypeDesired) - 1) == 0;
+                 base::size(kDeviceTypeDesired) - 1) == 0;
 }
 
 // static
diff --git a/media/audio/android/opensles_input.cc b/media/audio/android/opensles_input.cc
index 5a06fd3..09edf52 100644
--- a/media/audio/android/opensles_input.cc
+++ b/media/audio/android/opensles_input.cc
@@ -5,7 +5,7 @@
 #include "media/audio/android/opensles_input.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "media/audio/android/audio_manager_android.h"
 #include "media/base/audio_bus.h"
@@ -237,13 +237,9 @@
 
   // Create AudioRecorder and specify SL_IID_ANDROIDCONFIGURATION.
   LOG_ON_FAILURE_AND_RETURN(
-      (*engine)->CreateAudioRecorder(engine,
-                                     recorder_object_.Receive(),
-                                     &audio_source,
-                                     &audio_sink,
-                                     arraysize(interface_id),
-                                     interface_id,
-                                     interface_required),
+      (*engine)->CreateAudioRecorder(
+          engine, recorder_object_.Receive(), &audio_source, &audio_sink,
+          base::size(interface_id), interface_id, interface_required),
       false);
 
   SLAndroidConfigurationItf recorder_config;
diff --git a/media/audio/android/opensles_output.cc b/media/audio/android/opensles_output.cc
index 61693f5..0c0a1c9 100644
--- a/media/audio/android/opensles_output.cc
+++ b/media/audio/android/opensles_output.cc
@@ -6,7 +6,7 @@
 
 #include "base/android/build_info.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
@@ -303,13 +303,9 @@
   const SLboolean interface_required[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE,
                                           SL_BOOLEAN_TRUE};
   LOG_ON_FAILURE_AND_RETURN(
-      (*engine)->CreateAudioPlayer(engine,
-                                   player_object_.Receive(),
-                                   &audio_source,
-                                   &audio_sink,
-                                   arraysize(interface_id),
-                                   interface_id,
-                                   interface_required),
+      (*engine)->CreateAudioPlayer(
+          engine, player_object_.Receive(), &audio_source, &audio_sink,
+          base::size(interface_id), interface_id, interface_required),
       false);
 
   // Create AudioPlayer and specify SL_IID_ANDROIDCONFIGURATION.
diff --git a/media/audio/cras/audio_manager_cras.cc b/media/audio/cras/audio_manager_cras.cc
index 38a0e4f..c974385a 100644
--- a/media/audio/cras/audio_manager_cras.cc
+++ b/media/audio/cras/audio_manager_cras.cc
@@ -560,7 +560,7 @@
 
 void AudioManagerCras::WaitEventOrShutdown(base::WaitableEvent* event) {
   base::WaitableEvent* waitables[] = {event, &on_shutdown_};
-  base::WaitableEvent::WaitMany(waitables, arraysize(waitables));
+  base::WaitableEvent::WaitMany(waitables, base::size(waitables));
 }
 
 }  // namespace media
diff --git a/media/audio/cras/cras_input.cc b/media/audio/cras/cras_input.cc
index 1fa221d..79b9e86 100644
--- a/media/audio/cras/cras_input.cc
+++ b/media/audio/cras/cras_input.cc
@@ -8,7 +8,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/time/time.h"
 #include "media/audio/audio_device_description.h"
@@ -145,7 +145,7 @@
     CRAS_CH_SL,
     CRAS_CH_SR
   };
-  static_assert(arraysize(kChannelMap) == CHANNELS_MAX + 1,
+  static_assert(base::size(kChannelMap) == CHANNELS_MAX + 1,
                 "kChannelMap array size should match");
 
   // If already playing, stop before re-starting.
@@ -170,12 +170,12 @@
   // Initialize channel layout to all -1 to indicate that none of
   // the channels is set in the layout.
   int8_t layout[CRAS_CH_MAX];
-  for (size_t i = 0; i < arraysize(layout); ++i)
+  for (size_t i = 0; i < base::size(layout); ++i)
     layout[i] = -1;
 
   // Converts to CRAS defined channels. ChannelOrder will return -1
   // for channels that are not present in params_.channel_layout().
-  for (size_t i = 0; i < arraysize(kChannelMap); ++i) {
+  for (size_t i = 0; i < base::size(kChannelMap); ++i) {
     layout[kChannelMap[i]] = ChannelOrder(params_.channel_layout(),
                                           static_cast<Channels>(i));
   }
diff --git a/media/audio/cras/cras_unified.cc b/media/audio/cras/cras_unified.cc
index 9687e63..2a8f92a 100644
--- a/media/audio/cras/cras_unified.cc
+++ b/media/audio/cras/cras_unified.cc
@@ -7,7 +7,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "media/audio/cras/audio_manager_cras.h"
 
@@ -172,7 +172,7 @@
 
   // Converts to CRAS defined channels. ChannelOrder will return -1
   // for channels that does not present in params_.channel_layout().
-  for (size_t i = 0; i < arraysize(kChannelMap); ++i)
+  for (size_t i = 0; i < base::size(kChannelMap); ++i)
     layout[kChannelMap[i]] = ChannelOrder(params_.channel_layout(),
                                           static_cast<Channels>(i));
 
diff --git a/media/audio/sounds/audio_stream_handler_unittest.cc b/media/audio/sounds/audio_stream_handler_unittest.cc
index 79073fe..a6555b9a 100644
--- a/media/audio/sounds/audio_stream_handler_unittest.cc
+++ b/media/audio/sounds/audio_stream_handler_unittest.cc
@@ -10,9 +10,9 @@
 #include "base/bind_helpers.h"
 #include "base/compiler_specific.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/test_message_loop.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "media/audio/audio_io.h"
@@ -35,7 +35,7 @@
         AudioManager::CreateForTesting(std::make_unique<TestAudioThread>());
     base::RunLoop().RunUntilIdle();
 
-    base::StringPiece data(kTestAudioData, arraysize(kTestAudioData));
+    base::StringPiece data(kTestAudioData, base::size(kTestAudioData));
     audio_stream_handler_.reset(new AudioStreamHandler(data));
   }
 
diff --git a/media/audio/sounds/sounds_manager_unittest.cc b/media/audio/sounds/sounds_manager_unittest.cc
index ddc433b..47f1474 100644
--- a/media/audio/sounds/sounds_manager_unittest.cc
+++ b/media/audio/sounds/sounds_manager_unittest.cc
@@ -6,8 +6,8 @@
 
 #include "base/compiler_specific.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/test/test_message_loop.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -63,7 +63,7 @@
 
   ASSERT_TRUE(SoundsManager::Get()->Initialize(
       kTestAudioKey,
-      base::StringPiece(kTestAudioData, arraysize(kTestAudioData))));
+      base::StringPiece(kTestAudioData, base::size(kTestAudioData))));
   ASSERT_EQ(20,
             SoundsManager::Get()->GetDuration(kTestAudioKey).InMicroseconds());
   ASSERT_TRUE(SoundsManager::Get()->Play(kTestAudioKey));
@@ -86,7 +86,7 @@
 
   ASSERT_TRUE(SoundsManager::Get()->Initialize(
       kTestAudioKey,
-      base::StringPiece(kTestAudioData, arraysize(kTestAudioData))));
+      base::StringPiece(kTestAudioData, base::size(kTestAudioData))));
 
   // This overrides the wav data set by kTestAudioData and results in
   // a never-ending sine wave being played.
diff --git a/media/audio/sounds/test_data.h b/media/audio/sounds/test_data.h
index 8e14076..b7b2966 100644
--- a/media/audio/sounds/test_data.h
+++ b/media/audio/sounds/test_data.h
@@ -9,9 +9,9 @@
 
 #include "base/callback.h"
 #include "base/compiler_specific.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "media/audio/sounds/audio_stream_handler.h"
 
 namespace media {
@@ -22,7 +22,7 @@
     "RIFF\x28\x00\x00\x00WAVEfmt \x10\x00\x00\x00"
     "\x01\x00\x02\x00\x80\xbb\x00\x00\x00\x77\x01\x00\x02\x00\x10\x00"
     "data\x04\x00\x00\x00\x01\x00\x01\x00";
-const size_t kTestAudioDataSize = arraysize(kTestAudioData) - 1;
+const size_t kTestAudioDataSize = base::size(kTestAudioData) - 1;
 
 class TestObserver : public AudioStreamHandler::TestObserver {
  public:
diff --git a/media/audio/sounds/wav_audio_handler_unittest.cc b/media/audio/sounds/wav_audio_handler_unittest.cc
index cc0018fb..21691cc 100644
--- a/media/audio/sounds/wav_audio_handler_unittest.cc
+++ b/media/audio/sounds/wav_audio_handler_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "media/audio/sounds/test_data.h"
 #include "media/base/audio_bus.h"
@@ -47,7 +47,7 @@
 
   ASSERT_EQ(4U, handler->data().size());
   const char kData[] = "\x01\x00\x01\x00";
-  ASSERT_EQ(base::StringPiece(kData, arraysize(kData) - 1), handler->data());
+  ASSERT_EQ(base::StringPiece(kData, base::size(kData) - 1), handler->data());
 
   std::unique_ptr<AudioBus> bus =
       AudioBus::Create(handler->num_channels(),
@@ -106,7 +106,7 @@
 
   ASSERT_EQ(4U, handler->data().size());
   const char kData[] = "\x01\x00\x01\x00";
-  ASSERT_EQ(base::StringPiece(kData, arraysize(kData) - 1), handler->data());
+  ASSERT_EQ(base::StringPiece(kData, base::size(kData) - 1), handler->data());
 }
 
 TEST(WavAudioHandlerTest, TestTooBigDataChunkSizeIsOkay) {
@@ -128,7 +128,7 @@
 
   ASSERT_EQ(4U, handler->data().size());
   const char kData[] = "\x01\x00\x01\x00";
-  ASSERT_EQ(base::StringPiece(kData, arraysize(kData) - 1), handler->data());
+  ASSERT_EQ(base::StringPiece(kData, base::size(kData) - 1), handler->data());
 }
 
 TEST(WavAudioHandlerTest, TestTooSmallFormatSizeIsNotValid) {
diff --git a/media/audio/win/audio_low_latency_output_win.cc b/media/audio/win/audio_low_latency_output_win.cc
index dfd700c7..4a3fa16 100644
--- a/media/audio/win/audio_low_latency_output_win.cc
+++ b/media/audio/win/audio_low_latency_output_win.cc
@@ -11,8 +11,8 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
@@ -407,10 +407,8 @@
   // is signaled. An error event can also break the main thread loop.
   while (playing && !error) {
     // Wait for a close-down event, stream-switch event or a new render event.
-    DWORD wait_result = WaitForMultipleObjects(arraysize(wait_array),
-                                               wait_array,
-                                               FALSE,
-                                               INFINITE);
+    DWORD wait_result = WaitForMultipleObjects(base::size(wait_array),
+                                               wait_array, FALSE, INFINITE);
 
     switch (wait_result) {
       case WAIT_OBJECT_0 + 0:
diff --git a/media/audio/win/avrt_wrapper_win.cc b/media/audio/win/avrt_wrapper_win.cc
index ace5cba6..2fb716fc 100644
--- a/media/audio/win/avrt_wrapper_win.cc
+++ b/media/audio/win/avrt_wrapper_win.cc
@@ -5,7 +5,7 @@
 #include "media/audio/win/avrt_wrapper_win.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace avrt {
 
@@ -24,7 +24,7 @@
     // The avrt.dll is available on Windows Vista and later.
     wchar_t path[MAX_PATH] = {0};
     ExpandEnvironmentStrings(L"%WINDIR%\\system32\\avrt.dll", path,
-        arraysize(path));
+                             base::size(path));
     g_avrt = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
     if (!g_avrt)
       return false;
diff --git a/media/base/android/media_drm_bridge.cc b/media/base/android/media_drm_bridge.cc
index efcde6a6..b63f8ff 100644
--- a/media/base/android/media_drm_bridge.cc
+++ b/media/base/android/media_drm_bridge.cc
@@ -18,9 +18,9 @@
 #include "base/feature_list.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/sys_byteorder.h"
@@ -162,7 +162,7 @@
 KeySystemManager::KeySystemManager() {
   // Widevine is always supported in Android.
   key_system_uuid_map_[kWidevineKeySystem] =
-      UUID(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid));
+      UUID(kWidevineUuid, kWidevineUuid + base::size(kWidevineUuid));
   MediaDrmBridgeClient* client = GetMediaDrmBridgeClient();
   if (client)
     client->AddKeySystemUUIDMappings(&key_system_uuid_map_);
diff --git a/media/base/audio_bus_unittest.cc b/media/base/audio_bus_unittest.cc
index 39f2f42..aacafb9 100644
--- a/media/base/audio_bus_unittest.cc
+++ b/media/base/audio_bus_unittest.cc
@@ -8,8 +8,8 @@
 #include <limits>
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/aligned_memory.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
 #include "build/build_config.h"
@@ -305,7 +305,7 @@
 static const float kTestVectorResult[][kTestVectorFrameCount] = {
     {-1.0f, 1.0f, 0.5f, 0.0f, 0.0f},
     {0.0f, -1.0f, -0.5f, 1.0f, 0.0f}};
-static const int kTestVectorChannelCount = arraysize(kTestVectorResult);
+static const int kTestVectorChannelCount = base::size(kTestVectorResult);
 
 // Verify FromInterleaved() deinterleaves audio in supported formats correctly.
 TEST_F(AudioBusTest, FromInterleaved) {
@@ -442,26 +442,26 @@
   // Test deprecated version that takes |bytes_per_sample| as an input.
   {
     SCOPED_TRACE("uint8_t");
-    uint8_t test_array[arraysize(kTestVectorUint8)];
+    uint8_t test_array[base::size(kTestVectorUint8)];
     bus->ToInterleaved(bus->frames(), sizeof(*kTestVectorUint8), test_array);
     ASSERT_EQ(0,
               memcmp(test_array, kTestVectorUint8, sizeof(kTestVectorUint8)));
   }
   {
     SCOPED_TRACE("int16_t");
-    int16_t test_array[arraysize(kTestVectorInt16)];
+    int16_t test_array[base::size(kTestVectorInt16)];
     bus->ToInterleaved(bus->frames(), sizeof(*kTestVectorInt16), test_array);
     ASSERT_EQ(0,
               memcmp(test_array, kTestVectorInt16, sizeof(kTestVectorInt16)));
   }
   {
     SCOPED_TRACE("int32_t");
-    int32_t test_array[arraysize(kTestVectorInt32)];
+    int32_t test_array[base::size(kTestVectorInt32)];
     bus->ToInterleaved(bus->frames(), sizeof(*kTestVectorInt32), test_array);
 
     // Some compilers get better precision than others on the half-max test, so
     // let the test pass with an off by one check on the half-max.
-    int32_t alternative_acceptable_result[arraysize(kTestVectorInt32)];
+    int32_t alternative_acceptable_result[base::size(kTestVectorInt32)];
     memcpy(alternative_acceptable_result, kTestVectorInt32,
            sizeof(kTestVectorInt32));
     ASSERT_EQ(alternative_acceptable_result[4],
@@ -478,26 +478,26 @@
   // parameter.
   {
     SCOPED_TRACE("UnsignedInt8SampleTypeTraits");
-    uint8_t test_array[arraysize(kTestVectorUint8)];
+    uint8_t test_array[base::size(kTestVectorUint8)];
     bus->ToInterleaved<UnsignedInt8SampleTypeTraits>(bus->frames(), test_array);
     ASSERT_EQ(0,
               memcmp(test_array, kTestVectorUint8, sizeof(kTestVectorUint8)));
   }
   {
     SCOPED_TRACE("SignedInt16SampleTypeTraits");
-    int16_t test_array[arraysize(kTestVectorInt16)];
+    int16_t test_array[base::size(kTestVectorInt16)];
     bus->ToInterleaved<SignedInt16SampleTypeTraits>(bus->frames(), test_array);
     ASSERT_EQ(0,
               memcmp(test_array, kTestVectorInt16, sizeof(kTestVectorInt16)));
   }
   {
     SCOPED_TRACE("SignedInt32SampleTypeTraits");
-    int32_t test_array[arraysize(kTestVectorInt32)];
+    int32_t test_array[base::size(kTestVectorInt32)];
     bus->ToInterleaved<SignedInt32SampleTypeTraits>(bus->frames(), test_array);
 
     // Some compilers get better precision than others on the half-max test, so
     // let the test pass with an off by one check on the half-max.
-    int32_t alternative_acceptable_result[arraysize(kTestVectorInt32)];
+    int32_t alternative_acceptable_result[base::size(kTestVectorInt32)];
     memcpy(alternative_acceptable_result, kTestVectorInt32,
            sizeof(kTestVectorInt32));
     ASSERT_EQ(alternative_acceptable_result[4],
@@ -511,7 +511,7 @@
   }
   {
     SCOPED_TRACE("Float32SampleTypeTraits");
-    float test_array[arraysize(kTestVectorFloat32)];
+    float test_array[base::size(kTestVectorFloat32)];
     bus->ToInterleaved<Float32SampleTypeTraits>(bus->frames(), test_array);
     ASSERT_EQ(
         0, memcmp(test_array, kTestVectorFloat32, sizeof(kTestVectorFloat32)));
@@ -538,7 +538,7 @@
                                                 bus->frames());
   // Verify FromInterleaved applied no sanity.
   ASSERT_EQ(bus->channel(0)[0], kTestVectorFloat32Invalid[0]);
-  float test_array[arraysize(kTestVectorFloat32)];
+  float test_array[base::size(kTestVectorFloat32)];
   bus->ToInterleaved<Float32SampleTypeTraits>(bus->frames(), test_array);
   ASSERT_EQ(0,
             memcmp(test_array, kTestVectorFloat32, sizeof(kTestVectorFloat32)));
@@ -561,7 +561,7 @@
   // Test deprecated version that takes |bytes_per_sample| as an input.
   {
     SCOPED_TRACE("int16_t");
-    int16_t test_array[arraysize(kTestVectorInt16)];
+    int16_t test_array[base::size(kTestVectorInt16)];
     expected->ToInterleavedPartial(kPartialStart, kPartialFrames,
                                    sizeof(*kTestVectorInt16), test_array);
     ASSERT_EQ(0, memcmp(test_array, kTestVectorInt16 +
@@ -574,7 +574,7 @@
   // parameter.
   {
     SCOPED_TRACE("Float32SampleTypeTraits");
-    float test_array[arraysize(kTestVectorFloat32)];
+    float test_array[base::size(kTestVectorFloat32)];
     expected->ToInterleavedPartial<Float32SampleTypeTraits>(
         kPartialStart, kPartialFrames, test_array);
     ASSERT_EQ(0, memcmp(test_array, kTestVectorFloat32 +
diff --git a/media/base/audio_hash.cc b/media/base/audio_hash.cc
index 404e6f4..9abafb3e 100644
--- a/media/base/audio_hash.cc
+++ b/media/base/audio_hash.cc
@@ -7,8 +7,8 @@
 
 #include "media/base/audio_hash.h"
 
-#include "base/macros.h"
 #include "base/numerics/math_constants.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "media/base/audio_bus.h"
 
@@ -29,7 +29,7 @@
     for (uint32_t i = 0; i < static_cast<uint32_t>(frames); ++i) {
       const uint32_t kSampleIndex = sample_count_ + i;
       const uint32_t kHashIndex =
-          (kSampleIndex * (ch + 1)) % arraysize(audio_hash_);
+          (kSampleIndex * (ch + 1)) % base::size(audio_hash_);
 
       // Mix in a sine wave with the result so we ensure that sequences of empty
       // buffers don't result in an empty hash.
@@ -48,7 +48,7 @@
 
 std::string AudioHash::ToString() const {
   std::string result;
-  for (size_t i = 0; i < arraysize(audio_hash_); ++i)
+  for (size_t i = 0; i < base::size(audio_hash_); ++i)
     result += base::StringPrintf("%.2f,", audio_hash_[i]);
   return result;
 }
@@ -58,7 +58,7 @@
   char comma;
 
   std::stringstream is(other);
-  for (size_t i = 0; i < arraysize(audio_hash_); ++i) {
+  for (size_t i = 0; i < base::size(audio_hash_); ++i) {
     is >> other_hash >> comma;
     if (std::fabs(audio_hash_[i] - other_hash) > tolerance)
       return false;
diff --git a/media/base/audio_parameters_unittest.cc b/media/base/audio_parameters_unittest.cc
index d3ecf4b..3d7684d3 100644
--- a/media/base/audio_parameters_unittest.cc
+++ b/media/base/audio_parameters_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "media/base/audio_parameters.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -129,8 +129,8 @@
                       CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 200),
   };
 
-  for (size_t i = 0; i < arraysize(values); ++i) {
-    for (size_t j = 0; j < arraysize(values); ++j) {
+  for (size_t i = 0; i < base::size(values); ++i) {
+    for (size_t j = 0; j < base::size(values); ++j) {
       SCOPED_TRACE("i=" + base::NumberToString(i) +
                    " j=" + base::NumberToString(j));
       EXPECT_EQ(i < j, values[i] < values[j]);
diff --git a/media/base/audio_renderer_mixer_unittest.cc b/media/base/audio_renderer_mixer_unittest.cc
index 1c00ec2..a29616a2 100644
--- a/media/base/audio_renderer_mixer_unittest.cc
+++ b/media/base/audio_renderer_mixer_unittest.cc
@@ -14,7 +14,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/platform_thread.h"
@@ -540,19 +540,19 @@
 
         // Downsampling, multuple input sample rates.
         std::make_tuple(static_cast<const int* const>(kTestInput3Rates),
-                        arraysize(kTestInput3Rates),
+                        base::size(kTestInput3Rates),
                         kTestInput3Rates[0],
                         0.01),
 
         // Upsampling, multiple sinput sample rates.
         std::make_tuple(static_cast<const int* const>(kTestInput3Rates),
-                        arraysize(kTestInput3Rates),
+                        base::size(kTestInput3Rates),
                         kTestInput3Rates[2],
                         0.01),
 
         // Both downsampling and upsampling, multiple input sample rates
         std::make_tuple(static_cast<const int* const>(kTestInput3Rates),
-                        arraysize(kTestInput3Rates),
+                        base::size(kTestInput3Rates),
                         kTestInput3Rates[1],
                         0.01)));
 
diff --git a/media/base/audio_timestamp_helper_unittest.cc b/media/base/audio_timestamp_helper_unittest.cc
index 0ae2ad5..7a06ee8f 100644
--- a/media/base/audio_timestamp_helper_unittest.cc
+++ b/media/base/audio_timestamp_helper_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/base/audio_timestamp_helper.h"
 #include "media/base/timestamp_constants.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -132,7 +132,7 @@
 
   int frame_count = 5;
   int64_t expected_durations[] = {113, 113, 114, 113, 113, 114};
-  for (size_t i = 0; i < arraysize(expected_durations); ++i) {
+  for (size_t i = 0; i < base::size(expected_durations); ++i) {
     base::TimeDelta duration = helper_.GetFrameDuration(frame_count);
     EXPECT_EQ(expected_durations[i], duration.InMicroseconds());
 
diff --git a/media/base/bit_reader_unittest.cc b/media/base/bit_reader_unittest.cc
index 491aaf2..01f35965 100644
--- a/media/base/bit_reader_unittest.cc
+++ b/media/base/bit_reader_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace media {
@@ -97,7 +97,7 @@
   // Set bits to one only for the first and last bit of each read
   // in the pattern.
   size_t pos = 0;
-  for (size_t k = 0; k < arraysize(pattern_read_skip); ++k) {
+  for (size_t k = 0; k < base::size(pattern_read_skip); ++k) {
     const size_t read_bit_count = pattern_read_skip[k][0];
     if (read_bit_count > 0) {
       SetBit(buffer, sizeof(buffer), pos);
@@ -110,7 +110,7 @@
   // Run the test.
   BitReader bit_reader(buffer, sizeof(buffer));
   EXPECT_EQ(bit_reader.bits_available(), static_cast<int>(sizeof(buffer) * 8));
-  for (size_t k = 0; k < arraysize(pattern_read_skip); ++k) {
+  for (size_t k = 0; k < base::size(pattern_read_skip); ++k) {
     const size_t read_bit_count = pattern_read_skip[k][0];
     if (read_bit_count > 0) {
       int value;
diff --git a/media/base/channel_layout.cc b/media/base/channel_layout.cc
index d0ba542e..d7378d2 100644
--- a/media/base/channel_layout.cc
+++ b/media/base/channel_layout.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace media {
 
@@ -163,7 +163,7 @@
 };
 
 int ChannelLayoutToChannelCount(ChannelLayout layout) {
-  DCHECK_LT(static_cast<size_t>(layout), arraysize(kLayoutToChannels));
+  DCHECK_LT(static_cast<size_t>(layout), base::size(kLayoutToChannels));
   DCHECK_LE(kLayoutToChannels[layout], kMaxConcurrentChannels);
   return kLayoutToChannels[layout];
 }
@@ -194,8 +194,8 @@
 }
 
 int ChannelOrder(ChannelLayout layout, Channels channel) {
-  DCHECK_LT(static_cast<size_t>(layout), arraysize(kChannelOrderings));
-  DCHECK_LT(static_cast<size_t>(channel), arraysize(kChannelOrderings[0]));
+  DCHECK_LT(static_cast<size_t>(layout), base::size(kChannelOrderings));
+  DCHECK_LT(static_cast<size_t>(channel), base::size(kChannelOrderings[0]));
   return kChannelOrderings[layout][channel];
 }
 
diff --git a/media/base/channel_mixer_unittest.cc b/media/base/channel_mixer_unittest.cc
index a4ea611b..d0a16b12 100644
--- a/media/base/channel_mixer_unittest.cc
+++ b/media/base/channel_mixer_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "media/base/audio_bus.h"
 #include "media/base/audio_parameters.h"
@@ -166,35 +166,35 @@
     testing::Values(ChannelMixerTestData(CHANNEL_LAYOUT_STEREO,
                                          CHANNEL_LAYOUT_MONO,
                                          kStereoToMonoValues,
-                                         arraysize(kStereoToMonoValues),
+                                         base::size(kStereoToMonoValues),
                                          0.5f),
                     ChannelMixerTestData(CHANNEL_LAYOUT_MONO,
                                          CHANNEL_LAYOUT_STEREO,
                                          kMonoToStereoValues,
-                                         arraysize(kMonoToStereoValues),
+                                         base::size(kMonoToStereoValues),
                                          1.0f),
                     ChannelMixerTestData(CHANNEL_LAYOUT_5_1,
                                          CHANNEL_LAYOUT_MONO,
                                          kFiveOneToMonoValues,
-                                         arraysize(kFiveOneToMonoValues),
+                                         base::size(kFiveOneToMonoValues),
                                          ChannelMixer::kHalfPower),
                     ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE,
                                          2,
                                          CHANNEL_LAYOUT_DISCRETE,
                                          2,
                                          kStereoToMonoValues,
-                                         arraysize(kStereoToMonoValues)),
+                                         base::size(kStereoToMonoValues)),
                     ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE,
                                          2,
                                          CHANNEL_LAYOUT_DISCRETE,
                                          5,
                                          kStereoToMonoValues,
-                                         arraysize(kStereoToMonoValues)),
+                                         base::size(kStereoToMonoValues)),
                     ChannelMixerTestData(CHANNEL_LAYOUT_DISCRETE,
                                          5,
                                          CHANNEL_LAYOUT_DISCRETE,
                                          2,
                                          kFiveDiscreteValues,
-                                         arraysize(kFiveDiscreteValues))));
+                                         base::size(kFiveDiscreteValues))));
 
 }  // namespace media
diff --git a/media/base/channel_mixing_matrix_unittest.cc b/media/base/channel_mixing_matrix_unittest.cc
index a64ae050..77a542f 100644
--- a/media/base/channel_mixing_matrix_unittest.cc
+++ b/media/base/channel_mixing_matrix_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "media/base/channel_mixer.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -131,7 +131,7 @@
     {2, 2}, {2, 5}, {5, 2},
   };
 
-  for (size_t n = 0; n < arraysize(test_case); n++) {
+  for (size_t n = 0; n < base::size(test_case); n++) {
     int input_channels = test_case[n].input_channels;
     int output_channels = test_case[n].output_channels;
     ChannelMixingMatrix matrix_builder(CHANNEL_LAYOUT_DISCRETE,
diff --git a/media/base/container_names.cc b/media/base/container_names.cc
index afa71ca..434aa0a 100644
--- a/media/base/container_names.cc
+++ b/media/base/container_names.cc
@@ -10,8 +10,8 @@
 #include <limits>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "media/base/bit_reader.h"
 
 namespace media {
@@ -375,7 +375,7 @@
       reader.SkipBits(3);
       RCHECK(ReadBits(&reader, 24) == 0xffffff);
       current_sequence_number = sequence_number;
-      for (size_t i = 0; i < arraysize(last_block_number); ++i)
+      for (size_t i = 0; i < base::size(last_block_number); ++i)
         last_block_number[i] = -1;
     } else {
       // Sequence number must match (this will also fail if no header seen).
diff --git a/media/base/data_buffer_unittest.cc b/media/base/data_buffer_unittest.cc
index 690b7ec3..102f20c 100644
--- a/media/base/data_buffer_unittest.cc
+++ b/media/base/data_buffer_unittest.cc
@@ -8,7 +8,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -49,7 +49,7 @@
 
 TEST(DataBufferTest, CopyFrom) {
   const uint8_t kTestData[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
-  const int kTestDataSize = arraysize(kTestData);
+  const int kTestDataSize = base::size(kTestData);
 
   scoped_refptr<DataBuffer> buffer =
       DataBuffer::CopyFrom(kTestData, kTestDataSize);
@@ -99,9 +99,9 @@
 
 TEST(DataBufferTest, ReadingWriting) {
   const char kData[] = "hello";
-  const int kDataSize = arraysize(kData);
+  const int kDataSize = base::size(kData);
   const char kNewData[] = "chromium";
-  const int kNewDataSize = arraysize(kNewData);
+  const int kNewDataSize = base::size(kNewData);
 
   // Create a DataBuffer.
   scoped_refptr<DataBuffer> buffer(new DataBuffer(kDataSize));
diff --git a/media/base/decoder_buffer_unittest.cc b/media/base/decoder_buffer_unittest.cc
index fb82496..d8a44442 100644
--- a/media/base/decoder_buffer_unittest.cc
+++ b/media/base/decoder_buffer_unittest.cc
@@ -9,8 +9,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -37,7 +37,7 @@
 
 TEST(DecoderBufferTest, CopyFrom) {
   const uint8_t kData[] = "hello";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
 
   scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom(
       reinterpret_cast<const uint8_t*>(&kData), kDataSize));
@@ -64,7 +64,7 @@
 
 TEST(DecoderBufferTest, FromSharedMemoryHandle) {
   const uint8_t kData[] = "hello";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
 
   base::SharedMemory mem;
   ASSERT_TRUE(mem.CreateAndMapAnonymous(kDataSize));
@@ -81,7 +81,7 @@
 
 TEST(DecoderBufferTest, FromSharedMemoryHandle_Unaligned) {
   const uint8_t kData[] = "XXXhello";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   const off_t kDataOffset = 3;
 
   base::SharedMemory mem;
@@ -100,7 +100,7 @@
 
 TEST(DecoderBufferTest, FromSharedMemoryHandle_ZeroSize) {
   const uint8_t kData[] = "hello";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
 
   base::SharedMemory mem;
   ASSERT_TRUE(mem.CreateAndMapAnonymous(kDataSize));
@@ -114,7 +114,7 @@
 #if !defined(OS_ANDROID)
 TEST(DecoderBufferTest, PaddingAlignment) {
   const uint8_t kData[] = "hello";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> buffer2(DecoderBuffer::CopyFrom(
       reinterpret_cast<const uint8_t*>(&kData), kDataSize));
   ASSERT_TRUE(buffer2.get());
@@ -142,7 +142,7 @@
 
 TEST(DecoderBufferTest, ReadingWriting) {
   const char kData[] = "hello";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
 
   scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(kDataSize));
   ASSERT_TRUE(buffer.get());
diff --git a/media/base/fake_demuxer_stream.cc b/media/base/fake_demuxer_stream.cc
index 0345ce1..736f694 100644
--- a/media/base/fake_demuxer_stream.cc
+++ b/media/base/fake_demuxer_stream.cc
@@ -13,8 +13,8 @@
 #include "base/callback_helpers.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "media/base/bind_to_current_loop.h"
 #include "media/base/decoder_buffer.h"
@@ -190,8 +190,9 @@
   // TODO(xhwang): Output out-of-order buffers if needed.
   if (is_encrypted_) {
     buffer->set_decrypt_config(DecryptConfig::CreateCencConfig(
-        std::string(kKeyId, kKeyId + arraysize(kKeyId)),
-        std::string(kIv, kIv + arraysize(kIv)), std::vector<SubsampleEntry>()));
+        std::string(kKeyId, kKeyId + base::size(kKeyId)),
+        std::string(kIv, kIv + base::size(kIv)),
+        std::vector<SubsampleEntry>()));
   }
   buffer->set_timestamp(current_timestamp_);
   buffer->set_duration(duration_);
diff --git a/media/base/key_systems.cc b/media/base/key_systems.cc
index 46cac7e..6543afdc 100644
--- a/media/base/key_systems.cc
+++ b/media/base/key_systems.cc
@@ -10,7 +10,7 @@
 
 #include "base/containers/hash_tables.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/threading/thread_checker.h"
 #include "base/time/time.h"
@@ -332,7 +332,7 @@
 KeySystemsImpl::KeySystemsImpl()
     : audio_codec_mask_(EME_CODEC_AUDIO_ALL),
       video_codec_mask_(EME_CODEC_VIDEO_ALL) {
-  for (size_t i = 0; i < arraysize(kMimeTypeToCodecsMap); ++i) {
+  for (size_t i = 0; i < base::size(kMimeTypeToCodecsMap); ++i) {
     RegisterMimeType(kMimeTypeToCodecsMap[i].mime_type,
                      kMimeTypeToCodecsMap[i].codecs);
   }
diff --git a/media/base/mime_util_unittest.cc b/media/base/mime_util_unittest.cc
index b66bbe1c..8042010 100644
--- a/media/base/mime_util_unittest.cc
+++ b/media/base/mime_util_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/scoped_command_line.h"
@@ -51,7 +51,8 @@
                                           bool single_value) {
   const bool kTestStates[] = {true, false};
   if (test_all_values)
-    return std::vector<bool>(kTestStates, kTestStates + arraysize(kTestStates));
+    return std::vector<bool>(kTestStates,
+                             kTestStates + base::size(kTestStates));
   return std::vector<bool>(1, single_value);
 }
 
@@ -229,7 +230,7 @@
       {",", 2, {"", ""}, {"", ""}},
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::vector<std::string> codecs_out;
 
     SplitCodecs(tests[i].original, &codecs_out);
diff --git a/media/base/seekable_buffer_unittest.cc b/media/base/seekable_buffer_unittest.cc
index f8178c3..e3895620 100644
--- a/media/base/seekable_buffer_unittest.cc
+++ b/media/base/seekable_buffer_unittest.cc
@@ -10,7 +10,7 @@
 #include <cstdlib>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "media/base/data_buffer.h"
 #include "media/base/timestamp_constants.h"
@@ -338,7 +338,7 @@
 
   scoped_refptr<DataBuffer> buffer = DataBuffer::CopyFrom(data_, kWriteSize);
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     buffer->set_timestamp(base::TimeDelta::FromMicroseconds(
         tests[i].first_time_useconds));
     buffer->set_duration(base::TimeDelta::FromMicroseconds(
diff --git a/media/base/test_data_util.cc b/media/base/test_data_util.cc
index 5670294..bb615c1 100644
--- a/media/base/test_data_util.cc
+++ b/media/base/test_data_util.cc
@@ -12,6 +12,7 @@
 #include "base/no_destructor.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "media/base/decoder_buffer.h"
 
 namespace media {
@@ -221,13 +222,13 @@
 bool LookupTestKeyVector(const std::vector<uint8_t>& key_id,
                          bool allow_rotation,
                          std::vector<uint8_t>* key) {
-  std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> starting_key_id(kKeyId, kKeyId + base::size(kKeyId));
   size_t rotate_limit = allow_rotation ? starting_key_id.size() : 1;
   for (size_t pos = 0; pos < rotate_limit; ++pos) {
     std::rotate(starting_key_id.begin(), starting_key_id.begin() + pos,
                 starting_key_id.end());
     if (key_id == starting_key_id) {
-      key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
+      key->assign(kSecretKey, kSecretKey + base::size(kSecretKey));
       std::rotate(key->begin(), key->begin() + pos, key->end());
       return true;
     }
diff --git a/media/base/unaligned_shared_memory_unittest.cc b/media/base/unaligned_shared_memory_unittest.cc
index 34b287e7..35c3010 100644
--- a/media/base/unaligned_shared_memory_unittest.cc
+++ b/media/base/unaligned_shared_memory_unittest.cc
@@ -10,8 +10,8 @@
 #include <limits>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace media {
@@ -19,11 +19,11 @@
 namespace {
 
 const uint8_t kUnalignedData[] = "XXXhello";
-const size_t kUnalignedDataSize = arraysize(kUnalignedData);
+const size_t kUnalignedDataSize = base::size(kUnalignedData);
 const off_t kUnalignedOffset = 3;
 
 const uint8_t kData[] = "hello";
-const size_t kDataSize = arraysize(kData);
+const size_t kDataSize = base::size(kData);
 
 base::SharedMemoryHandle CreateHandle(const uint8_t* data, size_t size) {
   base::SharedMemory shm;
diff --git a/media/base/video_frame.cc b/media/base/video_frame.cc
index e805109b..d9e3aaf 100644
--- a/media/base/video_frame.cc
+++ b/media/base/video_frame.cc
@@ -14,8 +14,8 @@
 #include "base/bits.h"
 #include "base/callback_helpers.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/aligned_memory.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/stringprintf.h"
 #include "build/build_config.h"
@@ -756,7 +756,7 @@
     case PIXEL_FORMAT_NV21:
     case PIXEL_FORMAT_MT21: {
       static const int bytes_per_element[] = {1, 2};
-      DCHECK_LT(plane, arraysize(bytes_per_element));
+      DCHECK_LT(plane, base::size(bytes_per_element));
       return bytes_per_element[plane];
     }
     case PIXEL_FORMAT_YV12:
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc
index 56576fc9..ecf9762 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -11,11 +11,11 @@
 #include "base/bind.h"
 #include "base/callback_helpers.h"
 #include "base/format_macros.h"
-#include "base/macros.h"
 #include "base/memory/aligned_memory.h"
 #include "base/memory/read_only_shared_memory_region.h"
 #include "base/memory/shared_memory.h"
 #include "base/memory/unsafe_shared_memory_region.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "build/build_config.h"
 #include "gpu/command_buffer/common/mailbox_holder.h"
@@ -244,15 +244,15 @@
   // Test frames themselves.
   uint8_t* y_plane = frame->data(VideoFrame::kYPlane);
   for (int y = 0; y < frame->coded_size().height(); ++y) {
-    EXPECT_EQ(0, memcmp(kExpectedYRow, y_plane, arraysize(kExpectedYRow)));
+    EXPECT_EQ(0, memcmp(kExpectedYRow, y_plane, base::size(kExpectedYRow)));
     y_plane += frame->stride(VideoFrame::kYPlane);
   }
 
   uint8_t* u_plane = frame->data(VideoFrame::kUPlane);
   uint8_t* v_plane = frame->data(VideoFrame::kVPlane);
   for (int y = 0; y < frame->coded_size().height() / 2; ++y) {
-    EXPECT_EQ(0, memcmp(kExpectedUVRow, u_plane, arraysize(kExpectedUVRow)));
-    EXPECT_EQ(0, memcmp(kExpectedUVRow, v_plane, arraysize(kExpectedUVRow)));
+    EXPECT_EQ(0, memcmp(kExpectedUVRow, u_plane, base::size(kExpectedUVRow)));
+    EXPECT_EQ(0, memcmp(kExpectedUVRow, v_plane, base::size(kExpectedUVRow)));
     u_plane += frame->stride(VideoFrame::kUPlane);
     v_plane += frame->stride(VideoFrame::kVPlane);
   }
diff --git a/media/blink/cache_util.cc b/media/blink/cache_util.cc
index d235c56..97618b302 100644
--- a/media/blink/cache_util.cc
+++ b/media/blink/cache_util.cc
@@ -8,7 +8,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/time/time.h"
@@ -65,7 +65,7 @@
       TimeDelta::FromSeconds(3600);  // Arbitrary value.
 
   const char kMaxAgePrefix[] = "max-age=";
-  const size_t kMaxAgePrefixLen = arraysize(kMaxAgePrefix) - 1;
+  const size_t kMaxAgePrefixLen = base::size(kMaxAgePrefix) - 1;
   if (cache_control_header.substr(0, kMaxAgePrefixLen) == kMaxAgePrefix) {
     int64_t max_age_seconds;
     base::StringToInt64(
@@ -101,7 +101,7 @@
   base::TimeDelta ret = base::TimeDelta::FromDays(30);
 
   const char kMaxAgePrefix[] = "max-age=";
-  const size_t kMaxAgePrefixLen = arraysize(kMaxAgePrefix) - 1;
+  const size_t kMaxAgePrefixLen = base::size(kMaxAgePrefix) - 1;
   if (cache_control_header.substr(0, kMaxAgePrefixLen) == kMaxAgePrefix) {
     int64_t max_age_seconds;
     base::StringToInt64(
diff --git a/media/blink/cache_util_unittest.cc b/media/blink/cache_util_unittest.cc
index ea9f8398..e7ef430d 100644
--- a/media/blink/cache_util_unittest.cc
+++ b/media/blink/cache_util_unittest.cc
@@ -10,7 +10,7 @@
 #include <string>
 
 #include "base/format_macros.h"
-#include "base/macros.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"
@@ -73,7 +73,7 @@
       {WebURLResponse::kHTTPVersion_1_1, 200,
        "cache-control: no-cache\ncache-control: no-store", kNoCache | kNoStore},
   };
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     SCOPED_TRACE(base::StringPrintf("case: %" PRIuS
                                     ", version: %d, code: %d, headers: %s",
                                     i, tests[i].version, tests[i].status_code,
diff --git a/media/blink/multibuffer_data_source_unittest.cc b/media/blink/multibuffer_data_source_unittest.cc
index c0a29e5..ea067d7 100644
--- a/media/blink/multibuffer_data_source_unittest.cc
+++ b/media/blink/multibuffer_data_source_unittest.cc
@@ -6,8 +6,8 @@
 #include <stdint.h>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/scoped_feature_list.h"
 #include "media/base/media_log.h"
@@ -887,7 +887,7 @@
   InitializeWith206Response();
 
   uint8_t buffer[256];
-  data_source_->Read(kDataSize, arraysize(buffer), buffer,
+  data_source_->Read(kDataSize, base::size(buffer), buffer,
                      base::Bind(&MultibufferDataSourceTest::ReadCallback,
                                 base::Unretained(this)));
 
diff --git a/media/capture/content/capture_resolution_chooser_unittest.cc b/media/capture/content/capture_resolution_chooser_unittest.cc
index 988756b..8b3e43e 100644
--- a/media/capture/content/capture_resolution_chooser_unittest.cc
+++ b/media/capture/content/capture_resolution_chooser_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/location.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/size.h"
 
@@ -88,7 +88,7 @@
 
   // Test the "find Nth lower size" logic.
   for (size_t skips = 1; skips < 4; ++skips) {
-    for (size_t i = skips; i < arraysize(kSizes); ++i) {
+    for (size_t i = skips; i < base::size(kSizes); ++i) {
       EXPECT_EQ(
           gfx::Size(kSizes[i][0], kSizes[i][1]),
           chooser->FindSmallerFrameSize(
@@ -99,7 +99,7 @@
 
   // Test the "find Nth higher size" logic.
   for (size_t skips = 1; skips < 4; ++skips) {
-    for (size_t i = skips; i < arraysize(kSizes); ++i) {
+    for (size_t i = skips; i < base::size(kSizes); ++i) {
       EXPECT_EQ(gfx::Size(kSizes[i - skips][0], kSizes[i - skips][1]),
                 chooser->FindLargerFrameSize(
                     gfx::Size(kSizes[i][0], kSizes[i][1]).GetArea(), skips));
@@ -107,7 +107,7 @@
   }
 
   // Test the "find nearest size" logic.
-  for (size_t i = 1; i < arraysize(kSizes) - 1; ++i) {
+  for (size_t i = 1; i < base::size(kSizes) - 1; ++i) {
     const gfx::Size size(kSizes[i][0], kSizes[i][1]);
     const int a_somewhat_smaller_area =
         gfx::Size((kSizes[i - 1][0] + 3 * kSizes[i][0]) / 4,
diff --git a/media/capture/content/smooth_event_sampler_unittest.cc b/media/capture/content/smooth_event_sampler_unittest.cc
index abd7d4cc..4de65f7d 100644
--- a/media/capture/content/smooth_event_sampler_unittest.cc
+++ b/media/capture/content/smooth_event_sampler_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -369,7 +369,8 @@
                                           {false, 0}};
 
   SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30);
-  ReplayCheckingSamplerDecisions(data_points, arraysize(data_points), &sampler);
+  ReplayCheckingSamplerDecisions(data_points, base::size(data_points),
+                                 &sampler);
 }
 
 TEST(SmoothEventSamplerTest, DrawingAt30FpsWith60HzVsyncSampledAt30Hertz) {
@@ -478,7 +479,8 @@
                                           {true, 33.44}};
 
   SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30);
-  ReplayCheckingSamplerDecisions(data_points, arraysize(data_points), &sampler);
+  ReplayCheckingSamplerDecisions(data_points, base::size(data_points),
+                                 &sampler);
 }
 
 TEST(SmoothEventSamplerTest, DrawingAt60FpsWith60HzVsyncSampledAt30Hertz) {
@@ -611,7 +613,8 @@
                                           {true, 50.16}};
 
   SmoothEventSampler sampler(base::TimeDelta::FromSeconds(1) / 30);
-  ReplayCheckingSamplerDecisions(data_points, arraysize(data_points), &sampler);
+  ReplayCheckingSamplerDecisions(data_points, base::size(data_points),
+                                 &sampler);
 }
 
 }  // namespace media
diff --git a/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc b/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc
index 202e420c..66d8ce3d 100644
--- a/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc
+++ b/media/capture/video/chromeos/camera_hal_dispatcher_impl.cc
@@ -16,6 +16,7 @@
 #include "base/posix/eintr_wrapper.h"
 #include "base/rand_util.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/trace_event/trace_event.h"
@@ -62,7 +63,7 @@
       {raw_socket_fd, POLLIN, 0}, {raw_cancel_fd, POLLIN, 0},
   };
 
-  if (HANDLE_EINTR(poll(fds, arraysize(fds), -1)) <= 0) {
+  if (HANDLE_EINTR(poll(fds, base::size(fds), -1)) <= 0) {
     PLOG(ERROR) << "poll()";
     return false;
   }
diff --git a/media/capture/video/mac/video_capture_device_factory_mac.mm b/media/capture/video/mac/video_capture_device_factory_mac.mm
index b9a79a7..3005578 100644
--- a/media/capture/video/mac/video_capture_device_factory_mac.mm
+++ b/media/capture/video/mac/video_capture_device_factory_mac.mm
@@ -11,8 +11,8 @@
 
 #include "base/bind.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/task_runner_util.h"
 #import "media/capture/video/mac/video_capture_device_avfoundation_mac.h"
@@ -45,7 +45,7 @@
     const VideoCaptureDeviceDescriptor& descriptor) {
   bool is_device_blacklisted = false;
   for (size_t i = 0;
-       !is_device_blacklisted && i < arraysize(kBlacklistedCamerasIdSignature);
+       !is_device_blacklisted && i < base::size(kBlacklistedCamerasIdSignature);
        ++i) {
     is_device_blacklisted =
         base::EndsWith(descriptor.device_id, kBlacklistedCamerasIdSignature[i],
diff --git a/media/capture/video/video_capture_device.cc b/media/capture/video/video_capture_device.cc
index d74830a0..1ecb05e 100644
--- a/media/capture/video/video_capture_device.cc
+++ b/media/capture/video/video_capture_device.cc
@@ -6,7 +6,7 @@
 
 #include "base/command_line.h"
 #include "base/i18n/timezone.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
 #include "media/base/media_switches.h"
@@ -55,7 +55,7 @@
       "KN", "KR", "KY", "MS", "MX", "NI", "PA", "PE", "PF", "PH", "PR",
       "PW", "SA", "SR", "SV", "TT", "TW", "UM", "US", "VG", "VI", "VE"};
   const char** countries_using_60Hz_end =
-      countries_using_60Hz + arraysize(countries_using_60Hz);
+      countries_using_60Hz + base::size(countries_using_60Hz);
   if (std::find(countries_using_60Hz, countries_using_60Hz_end,
                 current_country) == countries_using_60Hz_end) {
     return PowerLineFrequency::FREQUENCY_50HZ;
diff --git a/media/capture/video/win/sink_input_pin_win.cc b/media/capture/video/win/sink_input_pin_win.cc
index fa597f8..ed40946a 100644
--- a/media/capture/video/win/sink_input_pin_win.cc
+++ b/media/capture/video/win/sink_input_pin_win.cc
@@ -12,7 +12,7 @@
 #include <stdint.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/base/timestamp_constants.h"
 
 namespace media {
@@ -113,7 +113,7 @@
 
 #ifndef NDEBUG
   WCHAR guid_str[128];
-  StringFromGUID2(sub_type, guid_str, arraysize(guid_str));
+  StringFromGUID2(sub_type, guid_str, base::size(guid_str));
   DVLOG(2) << __func__ << " unsupported media type: " << guid_str;
 #endif
   return false;
diff --git a/media/capture/video/win/video_capture_device_factory_win.cc b/media/capture/video/win/video_capture_device_factory_win.cc
index 62628bf0..6462dfc 100644
--- a/media/capture/video/win/video_capture_device_factory_win.cc
+++ b/media/capture/video/win/video_capture_device_factory_win.cc
@@ -15,7 +15,6 @@
 
 #include "base/command_line.h"
 #include "base/feature_list.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/single_thread_task_runner.h"
 #include "base/stl_util.h"
@@ -75,7 +74,7 @@
     // The following software WebCams cause crashes.
     "IP Camera [JPEG/MJPEG]", "CyberLink Webcam Splitter", "EpocCam",
 };
-static_assert(arraysize(kBlacklistedCameraNames) == BLACKLISTED_CAMERA_MAX + 1,
+static_assert(base::size(kBlacklistedCameraNames) == BLACKLISTED_CAMERA_MAX + 1,
               "kBlacklistedCameraNames should be same size as "
               "BlacklistedCameraNames enum");
 
@@ -113,7 +112,7 @@
 
   for (const wchar_t* kMfDLL : kMfDLLs) {
     wchar_t path[MAX_PATH] = {0};
-    ExpandEnvironmentStringsW(kMfDLL, path, arraysize(path));
+    ExpandEnvironmentStringsW(kMfDLL, path, base::size(path));
     if (!LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH))
       return false;
   }
@@ -146,7 +145,7 @@
                                              IMFMediaSource** source) {
   ComPtr<IMFAttributes> attributes;
   static_assert(
-      arraysize(kMfAttributes) == 2,
+      base::size(kMfAttributes) == 2,
       "Implementation here asumes that kMfAttributes has size of two.");
   DCHECK_EQ(kMfAttributes[0].first, VideoCaptureApi::WIN_MEDIA_FOUNDATION);
   const auto& attributes_data =
@@ -168,8 +167,8 @@
 
 bool IsDeviceBlackListed(const std::string& name) {
   DCHECK_EQ(BLACKLISTED_CAMERA_MAX + 1,
-            static_cast<int>(arraysize(kBlacklistedCameraNames)));
-  for (size_t i = 0; i < arraysize(kBlacklistedCameraNames); ++i) {
+            static_cast<int>(base::size(kBlacklistedCameraNames)));
+  for (size_t i = 0; i < base::size(kBlacklistedCameraNames); ++i) {
     if (base::StartsWith(name, kBlacklistedCameraNames[i],
                          base::CompareCase::INSENSITIVE_ASCII)) {
       DVLOG(1) << "Enumerated blacklisted device: " << name;
diff --git a/media/capture/video/win/video_capture_device_win.cc b/media/capture/video/win/video_capture_device_win.cc
index 24e1eaf..ee71ff53 100644
--- a/media/capture/video/win/video_capture_device_win.cc
+++ b/media/capture/video/win/video_capture_device_win.cc
@@ -13,7 +13,7 @@
 #include <utility>
 
 #include "base/feature_list.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/win/scoped_co_mem.h"
 #include "base/win/scoped_variant.h"
@@ -340,7 +340,7 @@
   }
 #ifndef NDEBUG
   WCHAR guid_str[128];
-  StringFromGUID2(sub_type, guid_str, arraysize(guid_str));
+  StringFromGUID2(sub_type, guid_str, base::size(guid_str));
   DVLOG(2) << "Device (also) supports an unknown media type " << guid_str;
 #endif
   return PIXEL_FORMAT_UNKNOWN;
diff --git a/media/capture/video_capture_types.cc b/media/capture/video_capture_types.cc
index 323ef60..07a7b78c 100644
--- a/media/capture/video_capture_types.cc
+++ b/media/capture/video_capture_types.cc
@@ -5,7 +5,7 @@
 #include "media/capture/video_capture_types.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "media/base/limits.h"
 #include "media/base/video_frame.h"
@@ -60,11 +60,11 @@
     const VideoPixelFormat& rhs) {
   auto* format_lhs = std::find(
       kSupportedCapturePixelFormats,
-      kSupportedCapturePixelFormats + arraysize(kSupportedCapturePixelFormats),
+      kSupportedCapturePixelFormats + base::size(kSupportedCapturePixelFormats),
       lhs);
   auto* format_rhs = std::find(
       kSupportedCapturePixelFormats,
-      kSupportedCapturePixelFormats + arraysize(kSupportedCapturePixelFormats),
+      kSupportedCapturePixelFormats + base::size(kSupportedCapturePixelFormats),
       rhs);
   return format_lhs < format_rhs;
 }
diff --git a/media/cast/logging/serialize_deserialize_test.cc b/media/cast/logging/serialize_deserialize_test.cc
index abab1fb..9d78162f 100644
--- a/media/cast/logging/serialize_deserialize_test.cc
+++ b/media/cast/logging/serialize_deserialize_test.cc
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/cast/logging/log_deserializer.h"
 #include "media/cast/logging/log_serializer.h"
 #include "media/cast/logging/logging_defines.h"
@@ -64,23 +64,24 @@
     for (int i = 0; i < metadata_.num_frame_events(); i++) {
       auto frame_event = std::make_unique<AggregatedFrameEvent>();
       frame_event->set_relative_rtp_timestamp(i * 90);
-      for (uint32_t event_index = 0; event_index < arraysize(kVideoFrameEvents);
-           ++event_index) {
+      for (uint32_t event_index = 0;
+           event_index < base::size(kVideoFrameEvents); ++event_index) {
         frame_event->add_event_type(
             ToProtoEventType(kVideoFrameEvents[event_index]));
         frame_event->add_event_timestamp_ms(event_time_ms);
         event_time_ms += 1024;
       }
-      frame_event->set_width(kWidth[i % arraysize(kWidth)]);
-      frame_event->set_height(kHeight[i % arraysize(kHeight)]);
+      frame_event->set_width(kWidth[i % base::size(kWidth)]);
+      frame_event->set_height(kHeight[i % base::size(kHeight)]);
       frame_event->set_encoded_frame_size(
-          kEncodedFrameSize[i % arraysize(kEncodedFrameSize)]);
-      frame_event->set_delay_millis(kDelayMillis[i % arraysize(kDelayMillis)]);
-      frame_event->set_encoder_cpu_percent_utilized(kEncoderCPUPercentUtilized[
-              i % arraysize(kEncoderCPUPercentUtilized)]);
+          kEncodedFrameSize[i % base::size(kEncodedFrameSize)]);
+      frame_event->set_delay_millis(kDelayMillis[i % base::size(kDelayMillis)]);
+      frame_event->set_encoder_cpu_percent_utilized(
+          kEncoderCPUPercentUtilized[i %
+                                     base::size(kEncoderCPUPercentUtilized)]);
       frame_event->set_idealized_bitrate_percent_utilized(
-          kIdealizedBitratePercentUtilized[
-              i % arraysize(kIdealizedBitratePercentUtilized)]);
+          kIdealizedBitratePercentUtilized
+              [i % base::size(kIdealizedBitratePercentUtilized)]);
 
       frame_event_list_.push_back(std::move(frame_event));
     }
@@ -95,7 +96,7 @@
         base_event->set_packet_id(packet_id);
         packet_id++;
         for (uint32_t event_index = 0;
-             event_index < arraysize(kVideoPacketEvents); ++event_index) {
+             event_index < base::size(kVideoPacketEvents); ++event_index) {
           base_event->add_event_type(
               ToProtoEventType(kVideoPacketEvents[event_index]));
           base_event->add_event_timestamp_ms(event_time_ms);
diff --git a/media/cast/receiver/audio_decoder_unittest.cc b/media/cast/receiver/audio_decoder_unittest.cc
index ced088fd..16884b3 100644
--- a/media/cast/receiver/audio_decoder_unittest.cc
+++ b/media/cast/receiver/audio_decoder_unittest.cc
@@ -7,7 +7,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/synchronization/condition_variable.h"
 #include "base/synchronization/lock.h"
 #include "base/sys_byteorder.h"
@@ -213,7 +213,7 @@
   const int kFrameDurationMs[] = { 5, 10, 20, 40, 60 };
 
   const int kNumFrames = 10;
-  for (size_t i = 0; i < arraysize(kFrameDurationMs); ++i)
+  for (size_t i = 0; i < base::size(kFrameDurationMs); ++i)
     for (int j = 0; j < kNumFrames; ++j)
       FeedMoreAudio(base::TimeDelta::FromMilliseconds(kFrameDurationMs[i]), 0);
   WaitForAllAudioToBeDecoded();
diff --git a/media/cast/sender/audio_encoder_unittest.cc b/media/cast/sender/audio_encoder_unittest.cc
index 6a46f39..585ed713 100644
--- a/media/cast/sender/audio_encoder_unittest.cc
+++ b/media/cast/sender/audio_encoder_unittest.cc
@@ -13,7 +13,7 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "media/base/audio_bus.h"
 #include "media/base/fake_single_thread_task_runner.h"
@@ -229,26 +229,26 @@
     AudioEncoderTestScenarios,
     AudioEncoderTest,
     ::testing::Values(
-        TestScenario(kOneCall_3Millis, arraysize(kOneCall_3Millis)),
-        TestScenario(kOneCall_10Millis, arraysize(kOneCall_10Millis)),
-        TestScenario(kOneCall_13Millis, arraysize(kOneCall_13Millis)),
-        TestScenario(kOneCall_20Millis, arraysize(kOneCall_20Millis)),
-        TestScenario(kTwoCalls_3Millis, arraysize(kTwoCalls_3Millis)),
-        TestScenario(kTwoCalls_10Millis, arraysize(kTwoCalls_10Millis)),
-        TestScenario(kTwoCalls_Mixed1, arraysize(kTwoCalls_Mixed1)),
-        TestScenario(kTwoCalls_Mixed2, arraysize(kTwoCalls_Mixed2)),
-        TestScenario(kTwoCalls_Mixed3, arraysize(kTwoCalls_Mixed3)),
-        TestScenario(kTwoCalls_Mixed4, arraysize(kTwoCalls_Mixed4)),
-        TestScenario(kManyCalls_3Millis, arraysize(kManyCalls_3Millis)),
-        TestScenario(kManyCalls_10Millis, arraysize(kManyCalls_10Millis)),
-        TestScenario(kManyCalls_Mixed1, arraysize(kManyCalls_Mixed1)),
-        TestScenario(kManyCalls_Mixed2, arraysize(kManyCalls_Mixed2)),
-        TestScenario(kManyCalls_Mixed3, arraysize(kManyCalls_Mixed3)),
-        TestScenario(kManyCalls_Mixed4, arraysize(kManyCalls_Mixed4)),
-        TestScenario(kManyCalls_Mixed5, arraysize(kManyCalls_Mixed5)),
-        TestScenario(kOneBigUnderrun, arraysize(kOneBigUnderrun)),
-        TestScenario(kTwoBigUnderruns, arraysize(kTwoBigUnderruns)),
-        TestScenario(kMixedUnderruns, arraysize(kMixedUnderruns))));
+        TestScenario(kOneCall_3Millis, base::size(kOneCall_3Millis)),
+        TestScenario(kOneCall_10Millis, base::size(kOneCall_10Millis)),
+        TestScenario(kOneCall_13Millis, base::size(kOneCall_13Millis)),
+        TestScenario(kOneCall_20Millis, base::size(kOneCall_20Millis)),
+        TestScenario(kTwoCalls_3Millis, base::size(kTwoCalls_3Millis)),
+        TestScenario(kTwoCalls_10Millis, base::size(kTwoCalls_10Millis)),
+        TestScenario(kTwoCalls_Mixed1, base::size(kTwoCalls_Mixed1)),
+        TestScenario(kTwoCalls_Mixed2, base::size(kTwoCalls_Mixed2)),
+        TestScenario(kTwoCalls_Mixed3, base::size(kTwoCalls_Mixed3)),
+        TestScenario(kTwoCalls_Mixed4, base::size(kTwoCalls_Mixed4)),
+        TestScenario(kManyCalls_3Millis, base::size(kManyCalls_3Millis)),
+        TestScenario(kManyCalls_10Millis, base::size(kManyCalls_10Millis)),
+        TestScenario(kManyCalls_Mixed1, base::size(kManyCalls_Mixed1)),
+        TestScenario(kManyCalls_Mixed2, base::size(kManyCalls_Mixed2)),
+        TestScenario(kManyCalls_Mixed3, base::size(kManyCalls_Mixed3)),
+        TestScenario(kManyCalls_Mixed4, base::size(kManyCalls_Mixed4)),
+        TestScenario(kManyCalls_Mixed5, base::size(kManyCalls_Mixed5)),
+        TestScenario(kOneBigUnderrun, base::size(kOneBigUnderrun)),
+        TestScenario(kTwoBigUnderruns, base::size(kTwoBigUnderruns)),
+        TestScenario(kMixedUnderruns, base::size(kMixedUnderruns))));
 
 }  // namespace cast
 }  // namespace media
diff --git a/media/cast/sender/external_video_encoder.cc b/media/cast/sender/external_video_encoder.cc
index 5e11390..30e8ff9 100644
--- a/media/cast/sender/external_video_encoder.cc
+++ b/media/cast/sender/external_video_encoder.cc
@@ -10,9 +10,9 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
@@ -848,7 +848,7 @@
   // histogram and return it.
   const int num_samples = (size.width() - 1) * rows_in_subset;
   return ToQuantizerEstimate(ComputeEntropyFromHistogram(
-      histogram, arraysize(histogram), num_samples));
+      histogram, base::size(histogram), num_samples));
 }
 
 double QuantizerEstimator::EstimateForDeltaFrame(const VideoFrame& frame) {
@@ -893,7 +893,7 @@
   // histogram and return it.
   const int num_samples = size.width() * rows_in_subset;
   return ToQuantizerEstimate(ComputeEntropyFromHistogram(
-      histogram, arraysize(histogram), num_samples));
+      histogram, base::size(histogram), num_samples));
 }
 
 // static
diff --git a/media/cast/sender/h264_vt_encoder.cc b/media/cast/sender/h264_vt_encoder.cc
index bca0e52..e4dd235 100644
--- a/media/cast/sender/h264_vt_encoder.cc
+++ b/media/cast/sender/h264_vt_encoder.cc
@@ -14,8 +14,8 @@
 #include "base/bind_helpers.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/power_monitor/power_monitor.h"
+#include "base/stl_util.h"
 #include "base/synchronization/lock.h"
 #include "build/build_config.h"
 #include "media/base/mac/video_frame_mac.h"
@@ -241,14 +241,14 @@
   CFTypeRef buffer_attributes_keys[] = {kCVPixelBufferPixelFormatTypeKey,
                                         kCVBufferPropagatedAttachmentsKey};
   CFTypeRef buffer_attributes_values[] = {
-      video_toolbox::ArrayWithIntegers(format, arraysize(format)).release(),
+      video_toolbox::ArrayWithIntegers(format, base::size(format)).release(),
       video_toolbox::DictionaryWithKeysAndValues(
-          attachments_keys, attachments_values, arraysize(attachments_keys))
+          attachments_keys, attachments_values, base::size(attachments_keys))
           .release()};
   const base::ScopedCFTypeRef<CFDictionaryRef> buffer_attributes =
       video_toolbox::DictionaryWithKeysAndValues(
           buffer_attributes_keys, buffer_attributes_values,
-          arraysize(buffer_attributes_keys));
+          base::size(buffer_attributes_keys));
   for (auto* v : buffer_attributes_values)
     CFRelease(v);
 
diff --git a/media/cdm/aes_decryptor_unittest.cc b/media/cdm/aes_decryptor_unittest.cc
index efeaee1..a32323b7 100644
--- a/media/cdm/aes_decryptor_unittest.cc
+++ b/media/cdm/aes_decryptor_unittest.cc
@@ -13,8 +13,8 @@
 #include "base/bind.h"
 #include "base/debug/leak_annotations.h"
 #include "base/json/json_reader.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_feature_list.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/values.h"
@@ -237,15 +237,15 @@
                                base::Unretained(this))),
         original_data_(kOriginalData, kOriginalData + kOriginalDataSize),
         encrypted_data_(kEncryptedData,
-                        kEncryptedData + arraysize(kEncryptedData)),
+                        kEncryptedData + base::size(kEncryptedData)),
         subsample_encrypted_data_(
             kSubsampleEncryptedData,
-            kSubsampleEncryptedData + arraysize(kSubsampleEncryptedData)),
-        key_id_(kKeyId, kKeyId + arraysize(kKeyId)),
-        iv_(kIv, kIv + arraysize(kIv)),
+            kSubsampleEncryptedData + base::size(kSubsampleEncryptedData)),
+        key_id_(kKeyId, kKeyId + base::size(kKeyId)),
+        iv_(kIv, kIv + base::size(kIv)),
         normal_subsample_entries_(
             kSubsampleEntriesNormal,
-            kSubsampleEntriesNormal + arraysize(kSubsampleEntriesNormal)) {}
+            kSubsampleEntriesNormal + base::size(kSubsampleEntriesNormal)) {}
 
  protected:
   void SetUp() override {
@@ -591,7 +591,7 @@
   EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary()));
   cdm_->CreateSessionAndGenerateRequest(
       CdmSessionType::kTemporary, EmeInitDataType::CENC,
-      std::vector<uint8_t>(init_data, init_data + arraysize(init_data)),
+      std::vector<uint8_t>(init_data, init_data + base::size(init_data)),
       CreateSessionPromise(RESOLVED));
 }
 
@@ -602,7 +602,7 @@
   EXPECT_CALL(cdm_client_, OnSessionMessage(NotEmpty(), _, IsJSONDictionary()));
   cdm_->CreateSessionAndGenerateRequest(
       CdmSessionType::kTemporary, EmeInitDataType::KEYIDS,
-      std::vector<uint8_t>(init_data, init_data + arraysize(init_data) - 1),
+      std::vector<uint8_t>(init_data, init_data + base::size(init_data) - 1),
       CreateSessionPromise(RESOLVED));
 }
 
@@ -672,14 +672,14 @@
   // The second key is also available.
   encrypted_buffer = CreateEncryptedBuffer(
       std::vector<uint8_t>(kEncryptedData2,
-                           kEncryptedData2 + arraysize(kEncryptedData2)),
-      std::vector<uint8_t>(kKeyId2, kKeyId2 + arraysize(kKeyId2)),
-      std::vector<uint8_t>(kIv2, kIv2 + arraysize(kIv2)),
+                           kEncryptedData2 + base::size(kEncryptedData2)),
+      std::vector<uint8_t>(kKeyId2, kKeyId2 + base::size(kKeyId2)),
+      std::vector<uint8_t>(kIv2, kIv2 + base::size(kIv2)),
       no_subsample_entries_);
   ASSERT_NO_FATAL_FAILURE(DecryptAndExpect(
       encrypted_buffer,
       std::vector<uint8_t>(kOriginalData2,
-                           kOriginalData2 + arraysize(kOriginalData2) - 1),
+                           kOriginalData2 + base::size(kOriginalData2) - 1),
       SUCCESS));
 }
 
@@ -741,7 +741,7 @@
 
   std::vector<SubsampleEntry> subsample_entries_wrong_size(
       kSubsampleEntriesWrongSize,
-      kSubsampleEntriesWrongSize + arraysize(kSubsampleEntriesWrongSize));
+      kSubsampleEntriesWrongSize + base::size(kSubsampleEntriesWrongSize));
 
   scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
       subsample_encrypted_data_, key_id_, iv_, subsample_entries_wrong_size);
@@ -755,7 +755,7 @@
   std::vector<SubsampleEntry> subsample_entries_invalid_total_size(
       kSubsampleEntriesInvalidTotalSize,
       kSubsampleEntriesInvalidTotalSize +
-          arraysize(kSubsampleEntriesInvalidTotalSize));
+          base::size(kSubsampleEntriesInvalidTotalSize));
 
   scoped_refptr<DecoderBuffer> encrypted_buffer =
       CreateEncryptedBuffer(subsample_encrypted_data_, key_id_, iv_,
@@ -770,7 +770,7 @@
 
   std::vector<SubsampleEntry> clear_only_subsample_entries(
       kSubsampleEntriesClearOnly,
-      kSubsampleEntriesClearOnly + arraysize(kSubsampleEntriesClearOnly));
+      kSubsampleEntriesClearOnly + base::size(kSubsampleEntriesClearOnly));
 
   scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
       original_data_, key_id_, iv_, clear_only_subsample_entries);
@@ -784,7 +784,7 @@
 
   std::vector<SubsampleEntry> cypher_only_subsample_entries(
       kSubsampleEntriesCypherOnly,
-      kSubsampleEntriesCypherOnly + arraysize(kSubsampleEntriesCypherOnly));
+      kSubsampleEntriesCypherOnly + base::size(kSubsampleEntriesCypherOnly));
 
   scoped_refptr<DecoderBuffer> encrypted_buffer = CreateEncryptedBuffer(
       encrypted_data_, key_id_, iv_, cypher_only_subsample_entries);
@@ -1031,8 +1031,8 @@
 }
 
 TEST_P(AesDecryptorTest, GetKeyIds) {
-  std::vector<uint8_t> key_id1(kKeyId, kKeyId + arraysize(kKeyId));
-  std::vector<uint8_t> key_id2(kKeyId2, kKeyId2 + arraysize(kKeyId2));
+  std::vector<uint8_t> key_id1(kKeyId, kKeyId + base::size(kKeyId));
+  std::vector<uint8_t> key_id2(kKeyId2, kKeyId2 + base::size(kKeyId2));
 
   std::string session_id = CreateSession(key_id_);
   EXPECT_FALSE(KeysInfoContains(key_id1));
@@ -1050,7 +1050,7 @@
 }
 
 TEST_P(AesDecryptorTest, NoKeysChangeForSameKey) {
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
 
   std::string session_id = CreateSession(key_id_);
   EXPECT_FALSE(KeysInfoContains(key_id));
@@ -1069,7 +1069,7 @@
 }
 
 TEST_P(AesDecryptorTest, RandomSessionIDs) {
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
   const size_t kNumIterations = 25;
   std::set<std::string> seen_sessions;
 
diff --git a/media/cdm/cdm_adapter_unittest.cc b/media/cdm/cdm_adapter_unittest.cc
index 4ecc77c..771161fc 100644
--- a/media/cdm/cdm_adapter_unittest.cc
+++ b/media/cdm/cdm_adapter_unittest.cc
@@ -10,8 +10,8 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "media/base/cdm_callback_promise.h"
@@ -392,7 +392,7 @@
 TEST_P(CdmAdapterTestWithClearKeyCdm, CreateWebmSession) {
   InitializeAndExpect(SUCCESS);
 
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
   CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
 }
 
@@ -401,7 +401,7 @@
 
   // Don't include the trailing /0 from the string in the data passed in.
   std::vector<uint8_t> key_id(kKeyIdAsJWK,
-                              kKeyIdAsJWK + arraysize(kKeyIdAsJWK) - 1);
+                              kKeyIdAsJWK + base::size(kKeyIdAsJWK) - 1);
   CreateSessionAndExpect(EmeInitDataType::KEYIDS, key_id, SUCCESS);
 }
 
@@ -409,7 +409,7 @@
   InitializeAndExpect(SUCCESS);
 
   std::vector<uint8_t> key_id(kKeyIdAsPssh,
-                              kKeyIdAsPssh + arraysize(kKeyIdAsPssh));
+                              kKeyIdAsPssh + base::size(kKeyIdAsPssh));
   CreateSessionAndExpect(EmeInitDataType::CENC, key_id, SUCCESS);
 }
 
@@ -417,7 +417,7 @@
   InitializeAndExpect(SUCCESS);
 
   // Use |kKeyId| but specify KEYIDS format.
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
   CreateSessionAndExpect(EmeInitDataType::KEYIDS, key_id, FAILURE);
 }
 
@@ -425,14 +425,14 @@
   InitializeAndExpect(SUCCESS);
 
   // LoadSession() is not supported by AesDecryptor.
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
   CreateSessionAndExpect(EmeInitDataType::KEYIDS, key_id, FAILURE);
 }
 
 TEST_P(CdmAdapterTestWithClearKeyCdm, UpdateSession) {
   InitializeAndExpect(SUCCESS);
 
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
   CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
 
   UpdateSessionAndExpect(SessionId(), kKeyAsJWK, SUCCESS, true);
@@ -441,7 +441,7 @@
 TEST_P(CdmAdapterTestWithClearKeyCdm, UpdateSessionWithBadData) {
   InitializeAndExpect(SUCCESS);
 
-  std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
   CreateSessionAndExpect(EmeInitDataType::WEBM, key_id, SUCCESS);
 
   UpdateSessionAndExpect(SessionId(), "random data", FAILURE, true);
diff --git a/media/cdm/cenc_decryptor_unittest.cc b/media/cdm/cenc_decryptor_unittest.cc
index 3a8c383..adab4d8 100644
--- a/media/cdm/cenc_decryptor_unittest.cc
+++ b/media/cdm/cenc_decryptor_unittest.cc
@@ -11,6 +11,7 @@
 #include <vector>
 
 #include "base/containers/span.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "crypto/encryptor.h"
 #include "crypto/symmetric_key.h"
@@ -25,11 +26,11 @@
 // Keys and IVs have to be 128 bits.
 const uint8_t kKey[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
                         0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13};
-static_assert(arraysize(kKey) * 8 == 128, "kKey must be 128 bits");
+static_assert(base::size(kKey) * 8 == 128, "kKey must be 128 bits");
 
 const uint8_t kIv[] = {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
                        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-static_assert(arraysize(kIv) * 8 == 128, "kIv must be 128 bits");
+static_assert(base::size(kIv) * 8 == 128, "kIv must be 128 bits");
 
 const uint8_t kOneBlock[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
                              'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p'};
@@ -65,11 +66,11 @@
   CencDecryptorTest()
       : key_(crypto::SymmetricKey::Import(
             crypto::SymmetricKey::AES,
-            std::string(kKey, kKey + arraysize(kKey)))),
-        iv_(kIv, kIv + arraysize(kIv)),
-        one_block_(kOneBlock, kOneBlock + arraysize(kOneBlock)),
+            std::string(kKey, kKey + base::size(kKey)))),
+        iv_(kIv, kIv + base::size(kIv)),
+        one_block_(kOneBlock, kOneBlock + base::size(kOneBlock)),
         partial_block_(kPartialBlock,
-                       kPartialBlock + arraysize(kPartialBlock)) {}
+                       kPartialBlock + base::size(kPartialBlock)) {}
 
   // Excrypt |original| using AES-CTR encryption with |key| and |iv|.
   std::vector<uint8_t> Encrypt(const std::vector<uint8_t>& original,
@@ -207,7 +208,7 @@
 
 TEST_F(CencDecryptorTest, InvalidKey) {
   std::unique_ptr<crypto::SymmetricKey> bad_key = crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, std::string(arraysize(kKey), 'b'));
+      crypto::SymmetricKey::AES, std::string(base::size(kKey), 'b'));
   auto encrypted_block = Encrypt(one_block_, *key_, iv_);
 
   std::vector<SubsampleEntry> subsamples = {
diff --git a/media/cdm/cenc_utils.cc b/media/cdm/cenc_utils.cc
index f885061..edc481b0 100644
--- a/media/cdm/cenc_utils.cc
+++ b/media/cdm/cenc_utils.cc
@@ -6,7 +6,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/formats/mp4/box_definitions.h"
 #include "media/formats/mp4/box_reader.h"
 
@@ -94,7 +94,7 @@
   KeyIdList result;
   std::vector<uint8_t> common_system_id(
       kCencCommonSystemId,
-      kCencCommonSystemId + arraysize(kCencCommonSystemId));
+      kCencCommonSystemId + base::size(kCencCommonSystemId));
   for (const auto& child : children) {
     if (child.system_id == common_system_id) {
       key_ids->assign(child.key_ids.begin(), child.key_ids.end());
diff --git a/media/cdm/cenc_utils_unittest.cc b/media/cdm/cenc_utils_unittest.cc
index 1b038ff..d068c11b 100644
--- a/media/cdm/cenc_utils_unittest.cc
+++ b/media/cdm/cenc_utils_unittest.cc
@@ -10,7 +10,7 @@
 #include <limits>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace media {
@@ -39,13 +39,13 @@
 class CencUtilsTest : public testing::Test {
  public:
   CencUtilsTest()
-      : key1_(kKey1Data, kKey1Data + arraysize(kKey1Data)),
-        key2_(kKey2Data, kKey2Data + arraysize(kKey2Data)),
-        key3_(kKey3Data, kKey3Data + arraysize(kKey3Data)),
-        key4_(kKey4Data, kKey4Data + arraysize(kKey4Data)),
+      : key1_(kKey1Data, kKey1Data + base::size(kKey1Data)),
+        key2_(kKey2Data, kKey2Data + base::size(kKey2Data)),
+        key3_(kKey3Data, kKey3Data + base::size(kKey3Data)),
+        key4_(kKey4Data, kKey4Data + base::size(kKey4Data)),
         common_system_system_id_(
             kCommonSystemSystemId,
-            kCommonSystemSystemId + arraysize(kCommonSystemSystemId)) {}
+            kCommonSystemSystemId + base::size(kCommonSystemSystemId)) {}
 
  protected:
   // Initialize the start of the 'pssh' box (up to key_count)
@@ -337,9 +337,9 @@
 
   KeyIdList key_ids;
   EXPECT_TRUE(
-      ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
+      ValidatePsshInput(std::vector<uint8_t>(data, data + base::size(data))));
   EXPECT_TRUE(GetKeyIdsForCommonSystemId(
-      std::vector<uint8_t>(data, data + arraysize(data)), &key_ids));
+      std::vector<uint8_t>(data, data + base::size(data)), &key_ids));
   EXPECT_EQ(2u, key_ids.size());
 }
 
@@ -361,9 +361,9 @@
 
   KeyIdList key_ids;
   EXPECT_TRUE(
-      ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
+      ValidatePsshInput(std::vector<uint8_t>(data, data + base::size(data))));
   EXPECT_TRUE(GetKeyIdsForCommonSystemId(
-      std::vector<uint8_t>(data, data + arraysize(data)), &key_ids));
+      std::vector<uint8_t>(data, data + base::size(data)), &key_ids));
   EXPECT_EQ(2u, key_ids.size());
 }
 
@@ -388,9 +388,9 @@
   // These calls fail as the box size is huge (0xffffffffffffffff) and there
   // is not enough bytes in |data|.
   EXPECT_FALSE(
-      ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
+      ValidatePsshInput(std::vector<uint8_t>(data, data + base::size(data))));
   EXPECT_FALSE(GetKeyIdsForCommonSystemId(
-      std::vector<uint8_t>(data, data + arraysize(data)), &key_ids));
+      std::vector<uint8_t>(data, data + base::size(data)), &key_ids));
 }
 
 TEST_F(CencUtilsTest, GetPsshData_Version0) {
@@ -401,7 +401,7 @@
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
   EXPECT_EQ(0u, pssh_data.size());
 
-  std::vector<uint8_t> data(data_bytes, data_bytes + arraysize(data_bytes));
+  std::vector<uint8_t> data(data_bytes, data_bytes + base::size(data_bytes));
   AppendData(box, data);
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
   EXPECT_EQ(data, pssh_data);
@@ -415,7 +415,7 @@
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
   EXPECT_EQ(0u, pssh_data.size());
 
-  std::vector<uint8_t> data(data_bytes, data_bytes + arraysize(data_bytes));
+  std::vector<uint8_t> data(data_bytes, data_bytes + base::size(data_bytes));
   AppendData(box, data);
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
   EXPECT_EQ(data, pssh_data);
@@ -429,7 +429,7 @@
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
   EXPECT_EQ(0u, pssh_data.size());
 
-  std::vector<uint8_t> data(data_bytes, data_bytes + arraysize(data_bytes));
+  std::vector<uint8_t> data(data_bytes, data_bytes + base::size(data_bytes));
   AppendData(box, data);
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
   EXPECT_EQ(data, pssh_data);
@@ -488,7 +488,7 @@
 
 TEST_F(CencUtilsTest, GetPsshData_DifferentSystemID) {
   std::vector<uint8_t> unknown_system_id(kKey1Data,
-                                         kKey1Data + arraysize(kKey1Data));
+                                         kKey1Data + base::size(kKey1Data));
   std::vector<uint8_t> pssh_data;
 
   std::vector<uint8_t> box = MakePSSHBox(1, Key1());
@@ -501,7 +501,7 @@
   std::vector<uint8_t> pssh_data;
 
   std::vector<uint8_t> box = MakePSSHBox(1, Key1());
-  std::vector<uint8_t> data(data_bytes, data_bytes + arraysize(data_bytes));
+  std::vector<uint8_t> data(data_bytes, data_bytes + base::size(data_bytes));
   AppendData(box, data);
   EXPECT_TRUE(GetPsshData(box, CommonSystemSystemId(), &pssh_data));
 
@@ -517,11 +517,13 @@
   std::vector<uint8_t> pssh_data;
 
   std::vector<uint8_t> box1 = MakePSSHBox(1, Key1());
-  std::vector<uint8_t> data1(data1_bytes, data1_bytes + arraysize(data1_bytes));
+  std::vector<uint8_t> data1(data1_bytes,
+                             data1_bytes + base::size(data1_bytes));
   AppendData(box1, data1);
 
   std::vector<uint8_t> box2 = MakePSSHBox(0);
-  std::vector<uint8_t> data2(data2_bytes, data2_bytes + arraysize(data2_bytes));
+  std::vector<uint8_t> data2(data2_bytes,
+                             data2_bytes + base::size(data2_bytes));
   AppendData(box2, data2);
 
   box1.insert(box1.end(), box2.begin(), box2.end());
@@ -536,7 +538,7 @@
     0x00, 0x00, 0x00, 0x08,   // size = 8
     'p',  's',  's',  'g'
   };
-  std::vector<uint8_t> non_pssh_box(data, data + arraysize(data));
+  std::vector<uint8_t> non_pssh_box(data, data + base::size(data));
   EXPECT_FALSE(ValidatePsshInput(non_pssh_box));
 
   // Make a valid 'pssh' box.
diff --git a/media/cdm/json_web_key_unittest.cc b/media/cdm/json_web_key_unittest.cc
index f0c4de25..3c4ed4f 100644
--- a/media/cdm/json_web_key_unittest.cc
+++ b/media/cdm/json_web_key_unittest.cc
@@ -9,7 +9,7 @@
 
 #include "base/base64.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/base/content_decryption_module.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -93,35 +93,35 @@
                            0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
 
   EXPECT_EQ("{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}]}",
-            GenerateJWKSet(data1, arraysize(data1), data1, arraysize(data1)));
+            GenerateJWKSet(data1, base::size(data1), data1, base::size(data1)));
   EXPECT_EQ(
       "{\"keys\":[{\"k\":\"AQIDBA\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}]}",
-      GenerateJWKSet(data2, arraysize(data2), data2, arraysize(data2)));
+      GenerateJWKSet(data2, base::size(data2), data2, base::size(data2)));
   EXPECT_EQ("{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}]}",
-            GenerateJWKSet(data1, arraysize(data1), data2, arraysize(data2)));
+            GenerateJWKSet(data1, base::size(data1), data2, base::size(data2)));
   EXPECT_EQ("{\"keys\":[{\"k\":\"AQIDBA\",\"kid\":\"AQI\",\"kty\":\"oct\"}]}",
-            GenerateJWKSet(data2, arraysize(data2), data1, arraysize(data1)));
+            GenerateJWKSet(data2, base::size(data2), data1, base::size(data1)));
   EXPECT_EQ(
       "{\"keys\":[{\"k\":\"AQIDBAUGBwgJCgsMDQ4PEA\",\"kid\":"
       "\"AQIDBAUGBwgJCgsMDQ4PEA\",\"kty\":\"oct\"}]}",
-      GenerateJWKSet(data3, arraysize(data3), data3, arraysize(data3)));
+      GenerateJWKSet(data3, base::size(data3), data3, base::size(data3)));
 
   KeyIdAndKeyPairs keys;
   keys.push_back(
-      MakeKeyIdAndKeyPair(data1, arraysize(data1), data1, arraysize(data1)));
+      MakeKeyIdAndKeyPair(data1, base::size(data1), data1, base::size(data1)));
   EXPECT_EQ(
       "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"}],\"type\":"
       "\"temporary\"}",
       GenerateJWKSet(keys, CdmSessionType::kTemporary));
   keys.push_back(
-      MakeKeyIdAndKeyPair(data2, arraysize(data2), data2, arraysize(data2)));
+      MakeKeyIdAndKeyPair(data2, base::size(data2), data2, base::size(data2)));
   EXPECT_EQ(
       "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"},{\"k\":"
       "\"AQIDBA\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"}],\"type\":\"persistent-"
       "license\"}",
       GenerateJWKSet(keys, CdmSessionType::kPersistentLicense));
   keys.push_back(
-      MakeKeyIdAndKeyPair(data3, arraysize(data3), data3, arraysize(data3)));
+      MakeKeyIdAndKeyPair(data3, base::size(data3), data3, base::size(data3)));
   EXPECT_EQ(
       "{\"keys\":[{\"k\":\"AQI\",\"kid\":\"AQI\",\"kty\":\"oct\"},{\"k\":"
       "\"AQIDBA\",\"kid\":\"AQIDBA\",\"kty\":\"oct\"},{\"k\":"
@@ -426,17 +426,17 @@
   const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                            0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
 
-  CreateLicenseAndExpect(data1, arraysize(data1), CdmSessionType::kTemporary,
+  CreateLicenseAndExpect(data1, base::size(data1), CdmSessionType::kTemporary,
                          "{\"kids\":[\"AQI\"],\"type\":\"temporary\"}");
   CreateLicenseAndExpect(
-      data1, arraysize(data1), CdmSessionType::kPersistentLicense,
+      data1, base::size(data1), CdmSessionType::kPersistentLicense,
       "{\"kids\":[\"AQI\"],\"type\":\"persistent-license\"}");
   CreateLicenseAndExpect(
-      data1, arraysize(data1), CdmSessionType::kPersistentUsageRecord,
+      data1, base::size(data1), CdmSessionType::kPersistentUsageRecord,
       "{\"kids\":[\"AQI\"],\"type\":\"persistent-usage-record\"}");
-  CreateLicenseAndExpect(data2, arraysize(data2), CdmSessionType::kTemporary,
+  CreateLicenseAndExpect(data2, base::size(data2), CdmSessionType::kTemporary,
                          "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}");
-  CreateLicenseAndExpect(data3, arraysize(data3),
+  CreateLicenseAndExpect(data3, base::size(data3),
                          CdmSessionType::kPersistentLicense,
                          "{\"kids\":[\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":"
                          "\"persistent-license\"}");
@@ -448,21 +448,14 @@
   const uint8_t data3[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                            0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
 
+  ExtractKeyFromLicenseAndExpect("{\"kids\":[\"AQI\"],\"type\":\"temporary\"}",
+                                 true, data1, base::size(data1));
   ExtractKeyFromLicenseAndExpect(
-      "{\"kids\":[\"AQI\"],\"type\":\"temporary\"}",
-      true,
-      data1,
-      arraysize(data1));
+      "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}", true, data2,
+      base::size(data2));
   ExtractKeyFromLicenseAndExpect(
-      "{\"kids\":[\"AQIDBA\"],\"type\":\"temporary\"}",
-      true,
-      data2,
-      arraysize(data2));
-  ExtractKeyFromLicenseAndExpect(
-      "{\"kids\":[\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":\"persistent\"}",
-      true,
-      data3,
-      arraysize(data3));
+      "{\"kids\":[\"AQIDBAUGBwgJCgsMDQ4PEA\"],\"type\":\"persistent\"}", true,
+      data3, base::size(data3));
 
   // Try some incorrect JSON.
   ExtractKeyFromLicenseAndExpect("", false, NULL, 0);
@@ -492,7 +485,7 @@
   // and is padded with = when converted to base64.
   std::string encoded_text;
   base::Base64Encode(
-      std::string(reinterpret_cast<const char*>(&data1[0]), arraysize(data1)),
+      std::string(reinterpret_cast<const char*>(&data1[0]), base::size(data1)),
       &encoded_text);
   EXPECT_EQ(encoded_text, "+/37/fv9+w==");
   EXPECT_NE(encoded_text.find('+'), std::string::npos);
@@ -503,12 +496,12 @@
   EXPECT_EQ(encoded_text.find('-'), std::string::npos);
   EXPECT_EQ(encoded_text.find('_'), std::string::npos);
 
-  CreateLicenseAndExpect(data1, arraysize(data1), CdmSessionType::kTemporary,
+  CreateLicenseAndExpect(data1, base::size(data1), CdmSessionType::kTemporary,
                          "{\"kids\":[\"-_37_fv9-w\"],\"type\":\"temporary\"}");
 
   ExtractKeyFromLicenseAndExpect(
       "{\"kids\":[\"-_37_fv9-w\"],\"type\":\"temporary\"}", true, data1,
-      arraysize(data1));
+      base::size(data1));
 }
 
 TEST_F(JSONWebKeyTest, MultipleKeys) {
@@ -519,9 +512,9 @@
 
   std::vector<uint8_t> result;
   KeyIdList key_ids;
-  key_ids.push_back(std::vector<uint8_t>(data1, data1 + arraysize(data1)));
-  key_ids.push_back(std::vector<uint8_t>(data2, data2 + arraysize(data2)));
-  key_ids.push_back(std::vector<uint8_t>(data3, data3 + arraysize(data3)));
+  key_ids.push_back(std::vector<uint8_t>(data1, data1 + base::size(data1)));
+  key_ids.push_back(std::vector<uint8_t>(data2, data2 + base::size(data2)));
+  key_ids.push_back(std::vector<uint8_t>(data3, data3 + base::size(data3)));
   CreateLicenseRequest(key_ids, CdmSessionType::kTemporary, &result);
   std::string s(result.begin(), result.end());
   EXPECT_EQ(
@@ -543,16 +536,16 @@
                                               &error_message));
   EXPECT_EQ(1u, key_ids.size());
   EXPECT_EQ(0u, error_message.length());
-  VerifyKeyId(key_ids[0], data1, arraysize(data1));
+  VerifyKeyId(key_ids[0], data1, base::size(data1));
 
   EXPECT_TRUE(ExtractKeyIdsFromKeyIdsInitData(
       "{\"kids\":[\"AQI\",\"AQIDBA\",\"AQIDBAUGBwgJCgsMDQ4PEA\"]}", &key_ids,
       &error_message));
   EXPECT_EQ(3u, key_ids.size());
   EXPECT_EQ(0u, error_message.length());
-  VerifyKeyId(key_ids[0], data1, arraysize(data1));
-  VerifyKeyId(key_ids[1], data2, arraysize(data2));
-  VerifyKeyId(key_ids[2], data3, arraysize(data3));
+  VerifyKeyId(key_ids[0], data1, base::size(data1));
+  VerifyKeyId(key_ids[1], data2, base::size(data2));
+  VerifyKeyId(key_ids[2], data3, base::size(data3));
 
   // Expect failure when non-ascii.
   EXPECT_FALSE(ExtractKeyIdsFromKeyIdsInitData(
@@ -617,19 +610,19 @@
   KeyIdList key_ids;
   std::string error_message;
 
-  key_ids.push_back(std::vector<uint8_t>(data1, data1 + arraysize(data1)));
+  key_ids.push_back(std::vector<uint8_t>(data1, data1 + base::size(data1)));
   std::vector<uint8_t> init_data1;
   CreateKeyIdsInitData(key_ids, &init_data1);
   std::string result1(init_data1.begin(), init_data1.end());
   EXPECT_EQ(result1, "{\"kids\":[\"AQI\"]}");
 
-  key_ids.push_back(std::vector<uint8_t>(data2, data2 + arraysize(data2)));
+  key_ids.push_back(std::vector<uint8_t>(data2, data2 + base::size(data2)));
   std::vector<uint8_t> init_data2;
   CreateKeyIdsInitData(key_ids, &init_data2);
   std::string result2(init_data2.begin(), init_data2.end());
   EXPECT_EQ(result2, "{\"kids\":[\"AQI\",\"AQIDBA\"]}");
 
-  key_ids.push_back(std::vector<uint8_t>(data3, data3 + arraysize(data3)));
+  key_ids.push_back(std::vector<uint8_t>(data3, data3 + base::size(data3)));
   std::vector<uint8_t> init_data3;
   CreateKeyIdsInitData(key_ids, &init_data3);
   std::string result3(init_data3.begin(), init_data3.end());
diff --git a/media/cdm/library_cdm/clear_key_cdm/cdm_file_io_test.cc b/media/cdm/library_cdm/clear_key_cdm/cdm_file_io_test.cc
index 75d4c46a..477dc31c 100644
--- a/media/cdm/library_cdm/clear_key_cdm/cdm_file_io_test.cc
+++ b/media/cdm/library_cdm/clear_key_cdm/cdm_file_io_test.cc
@@ -9,7 +9,7 @@
 #include "base/bind.h"
 #include "base/callback_helpers.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace media {
 
@@ -17,13 +17,13 @@
 
 const uint8_t kData[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
                          0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
-const uint32_t kDataSize = arraysize(kData);
+const uint32_t kDataSize = base::size(kData);
 
 const uint8_t kBigData[] = {
     0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa,
     0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55,
     0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00};
-const uint32_t kBigDataSize = arraysize(kBigData);
+const uint32_t kBigDataSize = base::size(kBigData);
 
 // Must be > kReadSize in cdm_file_io_impl.cc.
 const uint32_t kLargeDataSize = 20 * 1024 + 7;
diff --git a/media/device_monitors/system_message_window_win.cc b/media/device_monitors/system_message_window_win.cc
index c90040b..b7bba16 100644
--- a/media/device_monitors/system_message_window_win.cc
+++ b/media/device_monitors/system_message_window_win.cc
@@ -8,7 +8,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/system/system_monitor.h"
 #include "base/win/wrapped_window_proc.h"
 #include "media/audio/win/core_audio_util_win.h"
@@ -43,7 +43,7 @@
     filter.dbcc_size = sizeof(filter);
     filter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
     bool core_audio_support = media::CoreAudioUtil::IsSupported();
-    for (size_t i = 0; i < arraysize(kDeviceCategoryMap); ++i) {
+    for (size_t i = 0; i < base::size(kDeviceCategoryMap); ++i) {
       // If CoreAudio is supported, AudioDeviceListenerWin will
       // take care of monitoring audio devices.
       if (core_audio_support &&
@@ -61,7 +61,7 @@
   }
 
   void Unregister() {
-    for (size_t i = 0; i < arraysize(notifications_); ++i) {
+    for (size_t i = 0; i < base::size(notifications_); ++i) {
       if (notifications_[i]) {
         UnregisterDeviceNotification(notifications_[i]);
         notifications_[i] = NULL;
@@ -70,7 +70,7 @@
   }
 
  private:
-  HDEVNOTIFY notifications_[arraysize(kDeviceCategoryMap)];
+  HDEVNOTIFY notifications_[base::size(kDeviceCategoryMap)];
 
   DISALLOW_IMPLICIT_CONSTRUCTORS(DeviceNotifications);
 };
diff --git a/media/ffmpeg/ffmpeg_common_unittest.cc b/media/ffmpeg/ffmpeg_common_unittest.cc
index 4f66dd1..d73fba3d 100644
--- a/media/ffmpeg/ffmpeg_common_unittest.cc
+++ b/media/ffmpeg/ffmpeg_common_unittest.cc
@@ -10,7 +10,7 @@
 #include "base/bind.h"
 #include "base/files/memory_mapped_file.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/base/audio_decoder_config.h"
 #include "media/base/media.h"
 #include "media/base/media_util.h"
@@ -53,7 +53,7 @@
 
   // Valid combination: extra_data = non-nullptr && size > 0.
   codec_parameters->extradata = &kExtraData[0];
-  codec_parameters->extradata_size = arraysize(kExtraData);
+  codec_parameters->extradata_size = base::size(kExtraData);
   EXPECT_TRUE(converter_fn.Run(stream, decoder_config));
   EXPECT_EQ(static_cast<size_t>(codec_parameters->extradata_size),
             decoder_config->extra_data().size());
@@ -196,7 +196,7 @@
       {1, 2, 1, 500000, 1}, {1, 3, 1, 333333, 1}, {1, 3, 2, 666667, 2},
   };
 
-  for (size_t i = 0; i < arraysize(test_data); ++i) {
+  for (size_t i = 0; i < base::size(test_data); ++i) {
     SCOPED_TRACE(i);
 
     AVRational time_base;
diff --git a/media/filters/audio_renderer_algorithm_unittest.cc b/media/filters/audio_renderer_algorithm_unittest.cc
index e496653d..7be7a989 100644
--- a/media/filters/audio_renderer_algorithm_unittest.cc
+++ b/media/filters/audio_renderer_algorithm_unittest.cc
@@ -20,7 +20,7 @@
 
 #include "base/bind.h"
 #include "base/callback.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/base/audio_buffer.h"
 #include "media/base/audio_bus.h"
 #include "media/base/channel_layout.h"
@@ -691,7 +691,7 @@
   // filled appropriately at normal, above normal, and below normal.
   const int kHalfSize = kFrameSize / 2;
   const float kAudibleRates[] = {1.0f, 2.0f, 0.5f, 5.0f, 0.25f};
-  for (size_t i = 0; i < arraysize(kAudibleRates); ++i) {
+  for (size_t i = 0; i < base::size(kAudibleRates); ++i) {
     SCOPED_TRACE(kAudibleRates[i]);
     bus->Zero();
 
diff --git a/media/filters/audio_timestamp_validator_unittest.cc b/media/filters/audio_timestamp_validator_unittest.cc
index b2b84afa..663bd1d 100644
--- a/media/filters/audio_timestamp_validator_unittest.cc
+++ b/media/filters/audio_timestamp_validator_unittest.cc
@@ -6,6 +6,7 @@
 
 #include <tuple>
 
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "media/base/audio_decoder_config.h"
 #include "media/base/media_util.h"
@@ -87,7 +88,7 @@
     // Ping-pong between two random offsets to prevent validator from
     // stabilizing timestamp pattern.
     base::TimeDelta randomOffset =
-        kRandomOffsets[i % arraysize(kRandomOffsets)];
+        kRandomOffsets[i % base::size(kRandomOffsets)];
     encoded_buffer->set_timestamp(i * kBufferDuration + randomOffset);
 
     if (i == 0) {
@@ -254,4 +255,4 @@
         ::testing::Values(base::TimeDelta(),  // front discard
                           base::TimeDelta::FromMilliseconds(65))));
 
-}  // namespace media
\ No newline at end of file
+}  // namespace media
diff --git a/media/filters/blocking_url_protocol.cc b/media/filters/blocking_url_protocol.cc
index 62b6673..93414f8 100644
--- a/media/filters/blocking_url_protocol.cc
+++ b/media/filters/blocking_url_protocol.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/bind.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_restrictions.h"
 #include "media/base/data_source.h"
 #include "media/ffmpeg/ffmpeg_common.h"
@@ -64,7 +64,7 @@
   size_t index;
   {
     base::ScopedAllowBaseSyncPrimitives allow_base_sync_primitives;
-    index = base::WaitableEvent::WaitMany(events, arraysize(events));
+    index = base::WaitableEvent::WaitMany(events, base::size(events));
   }
 
   if (events[index] == &aborted_)
diff --git a/media/filters/chunk_demuxer_unittest.cc b/media/filters/chunk_demuxer_unittest.cc
index a2d65876..2f11a8e 100644
--- a/media/filters/chunk_demuxer_unittest.cc
+++ b/media/filters/chunk_demuxer_unittest.cc
@@ -14,8 +14,8 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/run_loop.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"
@@ -734,7 +734,7 @@
                              std::vector<uint8_t>(
                                  kEncryptedMediaInitData,
                                  kEncryptedMediaInitData +
-                                     arraysize(kEncryptedMediaInitData))))
+                                     base::size(kEncryptedMediaInitData))))
           .Times(Exactly(need_key_count));
     }
 
@@ -2879,7 +2879,7 @@
       &host_, base::BindRepeating(&ChunkDemuxerTest::DemuxerInitialized,
                                   base::Unretained(this)));
 
-  for (size_t i = 0; i < arraysize(codec_ids); ++i) {
+  for (size_t i = 0; i < base::size(codec_ids); ++i) {
 #if BUILDFLAG(USE_PROPRIETARY_CODECS)
     expected = ChunkDemuxer::kOk;
 #else
@@ -3395,10 +3395,10 @@
       true, true, true, true, false,
   };
 
-  static_assert(arraysize(kBuffer) == arraysize(kExpectedReturnValues),
-      "test arrays out of sync");
-  static_assert(arraysize(kBuffer) == sizeof(kBuffer),
-      "there should be one byte per index");
+  static_assert(base::size(kBuffer) == base::size(kExpectedReturnValues),
+                "test arrays out of sync");
+  static_assert(base::size(kBuffer) == sizeof(kBuffer),
+                "there should be one byte per index");
 
   ASSERT_TRUE(InitDemuxer(HAS_AUDIO));
   EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(23)).Times(2);
diff --git a/media/filters/decrypting_audio_decoder_unittest.cc b/media/filters/decrypting_audio_decoder_unittest.cc
index 00819b3a..def5e26 100644
--- a/media/filters/decrypting_audio_decoder_unittest.cc
+++ b/media/filters/decrypting_audio_decoder_unittest.cc
@@ -9,9 +9,9 @@
 
 #include "base/bind.h"
 #include "base/callback_helpers.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "media/base/audio_buffer.h"
 #include "media/base/decoder_buffer.h"
 #include "media/base/decrypt_config.h"
@@ -46,8 +46,8 @@
   scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size));
   buffer->set_decrypt_config(DecryptConfig::CreateCencConfig(
       std::string(reinterpret_cast<const char*>(kFakeKeyId),
-                  arraysize(kFakeKeyId)),
-      std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)),
+                  base::size(kFakeKeyId)),
+      std::string(reinterpret_cast<const char*>(kFakeIv), base::size(kFakeIv)),
       std::vector<SubsampleEntry>()));
   return buffer;
 }
diff --git a/media/filters/decrypting_demuxer_stream_unittest.cc b/media/filters/decrypting_demuxer_stream_unittest.cc
index fa75350..d4f605b7 100644
--- a/media/filters/decrypting_demuxer_stream_unittest.cc
+++ b/media/filters/decrypting_demuxer_stream_unittest.cc
@@ -9,9 +9,9 @@
 
 #include "base/bind.h"
 #include "base/callback_helpers.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "media/base/decoder_buffer.h"
 #include "media/base/decrypt_config.h"
 #include "media/base/gmock_callback_support.h"
@@ -44,11 +44,11 @@
   std::string iv = is_clear
                        ? std::string()
                        : std::string(reinterpret_cast<const char*>(kFakeIv),
-                                     arraysize(kFakeIv));
+                                     base::size(kFakeIv));
   if (!is_clear) {
     buffer->set_decrypt_config(DecryptConfig::CreateCencConfig(
         std::string(reinterpret_cast<const char*>(kFakeKeyId),
-                    arraysize(kFakeKeyId)),
+                    base::size(kFakeKeyId)),
         iv, {}));
   }
   return buffer;
diff --git a/media/filters/decrypting_video_decoder_unittest.cc b/media/filters/decrypting_video_decoder_unittest.cc
index f58f20f..d372090f 100644
--- a/media/filters/decrypting_video_decoder_unittest.cc
+++ b/media/filters/decrypting_video_decoder_unittest.cc
@@ -9,9 +9,9 @@
 
 #include "base/bind.h"
 #include "base/callback_helpers.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "media/base/decoder_buffer.h"
 #include "media/base/decrypt_config.h"
 #include "media/base/gmock_callback_support.h"
@@ -39,8 +39,8 @@
   scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(buffer_size));
   buffer->set_decrypt_config(DecryptConfig::CreateCencConfig(
       std::string(reinterpret_cast<const char*>(kFakeKeyId),
-                  arraysize(kFakeKeyId)),
-      std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)),
+                  base::size(kFakeKeyId)),
+      std::string(reinterpret_cast<const char*>(kFakeIv), base::size(kFakeIv)),
       {}));
   return buffer;
 }
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index 4ff8ead..3843f19 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -12,10 +12,10 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/path_service.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/mock_callback.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread.h"
@@ -445,12 +445,12 @@
 #endif
 
 TEST_F(FFmpegDemuxerTest, Initialize_Encrypted) {
-  EXPECT_CALL(*this,
-              OnEncryptedMediaInitData(
-                  EmeInitDataType::WEBM,
-                  std::vector<uint8_t>(kEncryptedMediaInitData,
-                                       kEncryptedMediaInitData +
-                                           arraysize(kEncryptedMediaInitData))))
+  EXPECT_CALL(
+      *this, OnEncryptedMediaInitData(
+                 EmeInitDataType::WEBM,
+                 std::vector<uint8_t>(kEncryptedMediaInitData,
+                                      kEncryptedMediaInitData +
+                                          base::size(kEncryptedMediaInitData))))
       .Times(Exactly(2));
 
   CreateDemuxer("bear-320x240-av_enc-av.webm");
@@ -770,7 +770,7 @@
 
   // Run the test twice with a seek in between.
   for (int i = 0; i < 2; ++i) {
-    for (size_t j = 0; j < arraysize(kTestExpectations); ++j) {
+    for (size_t j = 0; j < base::size(kTestExpectations); ++j) {
       audio->Read(NewReadCB(FROM_HERE, kTestExpectations[j][0],
                             kTestExpectations[j][1], true));
       base::RunLoop().Run();
@@ -844,7 +844,7 @@
         FROM_HERE, 408, 0, base::TimeDelta::FromMicroseconds(6500), true));
     base::RunLoop().Run();
 
-    for (size_t j = 0; j < arraysize(kTestExpectations); ++j) {
+    for (size_t j = 0; j < base::size(kTestExpectations); ++j) {
       audio->Read(NewReadCB(FROM_HERE, kTestExpectations[j][0],
                             kTestExpectations[j][1], true));
       base::RunLoop().Run();
@@ -1255,7 +1255,7 @@
     "bear-1280x720-av_with-aud-nalus_frag.mp4"
   };
 
-  for (size_t i = 0; i < arraysize(files); ++i) {
+  for (size_t i = 0; i < base::size(files); ++i) {
     DVLOG(1) << "Testing " << files[i];
     CreateDemuxer(files[i]);
     InitializeDemuxer();
@@ -1549,7 +1549,7 @@
       "2012-11-1012:34:56",
   };
 
-  for (size_t i = 0; i < arraysize(invalid_date_strings); ++i) {
+  for (size_t i = 0; i < base::size(invalid_date_strings); ++i) {
     const char* date_string = invalid_date_strings[i];
     base::Time result;
     EXPECT_FALSE(base::Time::FromUTCString(date_string, &result))
diff --git a/media/filters/jpeg_parser.cc b/media/filters/jpeg_parser.cc
index f17f16b..009d449 100644
--- a/media/filters/jpeg_parser.cc
+++ b/media/filters/jpeg_parser.cc
@@ -6,7 +6,7 @@
 
 #include "base/big_endian.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 using base::BigEndianReader;
 
@@ -149,7 +149,7 @@
     return false;
   }
   if (!InRange(frame_header->num_components, 1,
-               arraysize(frame_header->components))) {
+               base::size(frame_header->components))) {
     DLOG(ERROR) << "num_components="
                 << static_cast<int>(frame_header->num_components)
                 << " is not supported";
@@ -268,7 +268,7 @@
     size_t count = 0;
     if (!reader.ReadBytes(&table->code_length, sizeof(table->code_length)))
       return false;
-    for (size_t i = 0; i < arraysize(table->code_length); i++)
+    for (size_t i = 0; i < base::size(table->code_length); i++)
       count += table->code_length[i];
 
     if (!InRange(count, 0, sizeof(table->code_value))) {
diff --git a/media/filters/stream_parser_factory.cc b/media/filters/stream_parser_factory.cc
index bf2199b..8e24981 100644
--- a/media/filters/stream_parser_factory.cc
+++ b/media/filters/stream_parser_factory.cc
@@ -7,8 +7,8 @@
 #include <stddef.h>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/pattern.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
@@ -446,7 +446,7 @@
     std::vector<CodecInfo::HistogramTag>* audio_codecs,
     std::vector<CodecInfo::HistogramTag>* video_codecs) {
   // Search for the SupportedTypeInfo for |type|.
-  for (size_t i = 0; i < arraysize(kSupportedTypeInfo); ++i) {
+  for (size_t i = 0; i < base::size(kSupportedTypeInfo); ++i) {
     const SupportedTypeInfo& type_info = kSupportedTypeInfo[i];
     if (type == type_info.type) {
       if (codecs.empty()) {
diff --git a/media/filters/video_renderer_algorithm_unittest.cc b/media/filters/video_renderer_algorithm_unittest.cc
index ee84f83d..e659a573 100644
--- a/media/filters/video_renderer_algorithm_unittest.cc
+++ b/media/filters/video_renderer_algorithm_unittest.cc
@@ -10,8 +10,8 @@
 
 #include "base/bind.h"
 #include "base/bind_helpers.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "build/build_config.h"
@@ -1389,10 +1389,10 @@
   TickGenerator display_tg(tick_clock_->NowTicks(), 60);
 
   const double kTestRates[] = {1.0, 2, 0.215, 0.5, 1.0, 3.15};
-  const bool kTestRateHasCadence[arraysize(kTestRates)] = {true, true, true,
-                                                           true, true, false};
+  const bool kTestRateHasCadence[base::size(kTestRates)] = {true, true, true,
+                                                            true, true, false};
 
-  for (size_t i = 0; i < arraysize(kTestRates); ++i) {
+  for (size_t i = 0; i < base::size(kTestRates); ++i) {
     const double playback_rate = kTestRates[i];
     SCOPED_TRACE(base::StringPrintf("Playback Rate: %.03f", playback_rate));
     time_source_.SetPlaybackRate(playback_rate);
@@ -1423,11 +1423,11 @@
   // Run throught ~1.6 seconds worth of frames.
   bool cadence_detected = false;
   base::TimeDelta timestamp;
-  for (size_t i = 0; i < arraysize(kBadTimestampsMs) * 2; ++i) {
+  for (size_t i = 0; i < base::size(kBadTimestampsMs) * 2; ++i) {
     while (EffectiveFramesQueued() < 3) {
       algorithm_.EnqueueFrame(CreateFrame(timestamp));
       timestamp += base::TimeDelta::FromMilliseconds(
-          kBadTimestampsMs[i % arraysize(kBadTimestampsMs)]);
+          kBadTimestampsMs[i % base::size(kBadTimestampsMs)]);
     }
 
     size_t frames_dropped = 0;
@@ -1458,11 +1458,11 @@
   bool cadence_detected = false;
   bool cadence_turned_off = false;
   base::TimeDelta timestamp;
-  for (size_t i = 0; i < arraysize(kBadTimestampsMs);) {
+  for (size_t i = 0; i < base::size(kBadTimestampsMs);) {
     while (EffectiveFramesQueued() < 3) {
       algorithm_.EnqueueFrame(CreateFrame(timestamp));
       timestamp += base::TimeDelta::FromMilliseconds(
-          kBadTimestampsMs[i % arraysize(kBadTimestampsMs)]);
+          kBadTimestampsMs[i % base::size(kBadTimestampsMs)]);
       ++i;
     }
 
diff --git a/media/filters/vp9_bool_decoder.cc b/media/filters/vp9_bool_decoder.cc
index 7700b98..28d4e53 100644
--- a/media/filters/vp9_bool_decoder.cc
+++ b/media/filters/vp9_bool_decoder.cc
@@ -7,6 +7,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "media/base/bit_reader.h"
 
 namespace media {
@@ -111,7 +112,7 @@
 
   // Need to fill |count| bits next time in order to make |bool_range_| >=
   // 128.
-  DCHECK_LT(bool_range_, arraysize(kCountToShiftTo128));
+  DCHECK_LT(bool_range_, base::size(kCountToShiftTo128));
   DCHECK_GT(bool_range_, 0u);
   int count = kCountToShiftTo128[bool_range_];
   bool_range_ <<= count;
diff --git a/media/filters/vp9_compressed_header_parser.cc b/media/filters/vp9_compressed_header_parser.cc
index 3fc72fd..4ce0843 100644
--- a/media/filters/vp9_compressed_header_parser.cc
+++ b/media/filters/vp9_compressed_header_parser.cc
@@ -5,6 +5,7 @@
 #include "media/filters/vp9_compressed_header_parser.h"
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 
 namespace media {
 
@@ -47,7 +48,7 @@
   uint8_t v = delta_prob;
   DCHECK_GE(m, 1);
   DCHECK_LE(m, kVp9MaxProb);
-  DCHECK_LT(v, arraysize(inv_map_table));
+  DCHECK_LT(v, base::size(inv_map_table));
   v = inv_map_table[v];
   m--;
   if ((m << 1) <= kVp9MaxProb) {
diff --git a/media/filters/vp9_parser.cc b/media/filters/vp9_parser.cc
index bff6007..b3f455b0 100644
--- a/media/filters/vp9_parser.cc
+++ b/media/filters/vp9_parser.cc
@@ -16,8 +16,8 @@
 #include "base/bind.h"
 #include "base/containers/circular_deque.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/sys_byteorder.h"
 #include "media/filters/vp9_compressed_header_parser.h"
 #include "media/filters/vp9_uncompressed_header_parser.h"
@@ -137,7 +137,7 @@
 };
 // clang-format on
 
-static_assert(arraysize(kDcQLookup[0]) == arraysize(kAcQLookup[0]),
+static_assert(base::size(kDcQLookup[0]) == base::size(kAcQLookup[0]),
               "quantizer lookup arrays of incorrect size");
 
 size_t ClampQ(size_t q) {
@@ -485,27 +485,27 @@
 }
 
 void Vp9Parser::Context::MarkFrameContextForUpdate(size_t frame_context_idx) {
-  DCHECK_LT(frame_context_idx, arraysize(frame_context_managers_));
+  DCHECK_LT(frame_context_idx, base::size(frame_context_managers_));
   frame_context_managers_[frame_context_idx].SetNeedsClientUpdate();
 }
 
 void Vp9Parser::Context::UpdateFrameContext(
     size_t frame_context_idx,
     const Vp9FrameContext& frame_context) {
-  DCHECK_LT(frame_context_idx, arraysize(frame_context_managers_));
+  DCHECK_LT(frame_context_idx, base::size(frame_context_managers_));
   frame_context_managers_[frame_context_idx].Update(frame_context);
 }
 
 const Vp9Parser::ReferenceSlot& Vp9Parser::Context::GetRefSlot(
     size_t ref_type) const {
-  DCHECK_LT(ref_type, arraysize(ref_slots_));
+  DCHECK_LT(ref_type, base::size(ref_slots_));
   return ref_slots_[ref_type];
 }
 
 void Vp9Parser::Context::UpdateRefSlot(
     size_t ref_type,
     const Vp9Parser::ReferenceSlot& ref_slot) {
-  DCHECK_LT(ref_type, arraysize(ref_slots_));
+  DCHECK_LT(ref_type, base::size(ref_slots_));
   ref_slots_[ref_type] = ref_slot;
 }
 
@@ -680,7 +680,7 @@
 
 Vp9Parser::ContextRefreshCallback Vp9Parser::GetContextRefreshCb(
     size_t frame_context_idx) {
-  DCHECK_LT(frame_context_idx, arraysize(context_.frame_context_managers_));
+  DCHECK_LT(frame_context_idx, base::size(context_.frame_context_managers_));
   auto& frame_context_manager =
       context_.frame_context_managers_[frame_context_idx];
 
diff --git a/media/formats/ac3/ac3_util.cc b/media/formats/ac3/ac3_util.cc
index 2c28262d..a9ffade2 100644
--- a/media/formats/ac3/ac3_util.cc
+++ b/media/formats/ac3/ac3_util.cc
@@ -5,7 +5,7 @@
 #include "media/formats/ac3/ac3_util.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/base/bit_reader.h"
 
 namespace media {
@@ -121,9 +121,9 @@
 
 // Returns the size in bytes of the given AC3 synchronization frame.
 int ParseAc3SyncFrameSize(Ac3Header& header) {
-  if (header.sample_rate_code() >= arraysize(kSampleRate) ||
+  if (header.sample_rate_code() >= base::size(kSampleRate) ||
       header.ac3_frame_size_code() >=
-          arraysize(kSyncFrameSizeInWordsFor44kHz)) {
+          base::size(kSyncFrameSizeInWordsFor44kHz)) {
     DVLOG(2) << __func__ << " Invalid frame header."
              << " fscod:" << header.sample_rate_code()
              << " frmsizecod:" << header.ac3_frame_size_code();
diff --git a/media/formats/mp2t/es_adapter_video_unittest.cc b/media/formats/mp2t/es_adapter_video_unittest.cc
index 7a6b97a..3c078a2 100644
--- a/media/formats/mp2t/es_adapter_video_unittest.cc
+++ b/media/formats/mp2t/es_adapter_video_unittest.cc
@@ -11,7 +11,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/time/time.h"
 #include "media/base/media_util.h"
@@ -45,9 +45,9 @@
 
   BufferQueue buffers(frame_count);
   for (size_t k = 0; k < frame_count; k++) {
-    buffers[k] = StreamParserBuffer::CopyFrom(
-        dummy_buffer, arraysize(dummy_buffer),
-        is_key_frame[k], DemuxerStream::VIDEO, 0);
+    buffers[k] =
+        StreamParserBuffer::CopyFrom(dummy_buffer, base::size(dummy_buffer),
+                                     is_key_frame[k], DemuxerStream::VIDEO, 0);
     if (frame_pts_ms[k] < 0) {
       buffers[k]->set_timestamp(kNoTimestamp);
     } else {
@@ -120,7 +120,7 @@
     true, false, false, false,
     false, false, false, false };
   BufferQueue buffer_queue =
-      GenerateFakeBuffers(pts_ms, is_key_frame, arraysize(pts_ms));
+      GenerateFakeBuffers(pts_ms, is_key_frame, base::size(pts_ms));
 
   EXPECT_EQ("(1,Y) (2,N) (3,N) (4,N) (5,N) (6,N) (7,N) (7,N)",
             RunAdapterTest(buffer_queue));
@@ -133,7 +133,7 @@
     true, false, false, false, false,
     false, false, false, false, false };
   BufferQueue buffer_queue =
-      GenerateFakeBuffers(pts_ms, is_key_frame, arraysize(pts_ms));
+      GenerateFakeBuffers(pts_ms, is_key_frame, base::size(pts_ms));
 
   EXPECT_EQ("(30,Y) (30,N) (30,N) (30,N) (30,N) "
             "(30,N) (30,N) (30,N) (30,N) (30,N)",
@@ -144,7 +144,7 @@
   int pts_ms[] = {30, 40, 50, 120, 150, 180};
   bool is_key_frame[] = {false, false, false, true, false, false};
   BufferQueue buffer_queue =
-      GenerateFakeBuffers(pts_ms, is_key_frame, arraysize(pts_ms));
+      GenerateFakeBuffers(pts_ms, is_key_frame, base::size(pts_ms));
 
   EXPECT_EQ("(30,Y) (30,Y) (30,Y) (30,Y) (30,N) (30,N)",
             RunAdapterTest(buffer_queue));
@@ -154,7 +154,7 @@
   int pts_ms[] = {-1, 40, 50, 120, 150, 180};
   bool is_key_frame[] = {true, false, false, true, false, false};
   BufferQueue buffer_queue =
-      GenerateFakeBuffers(pts_ms, is_key_frame, arraysize(pts_ms));
+      GenerateFakeBuffers(pts_ms, is_key_frame, base::size(pts_ms));
 
   EXPECT_EQ("(40,Y) (40,Y) (30,Y) (30,N) (30,N)",
             RunAdapterTest(buffer_queue));
@@ -164,7 +164,7 @@
   int pts_ms[] = {-1, -1, 50, 120, 150, 180};
   bool is_key_frame[] = {false, false, false, true, false, false};
   BufferQueue buffer_queue =
-      GenerateFakeBuffers(pts_ms, is_key_frame, arraysize(pts_ms));
+      GenerateFakeBuffers(pts_ms, is_key_frame, base::size(pts_ms));
 
   EXPECT_EQ("(70,Y) (30,Y) (30,N) (30,N)",
             RunAdapterTest(buffer_queue));
diff --git a/media/formats/mp2t/timestamp_unroller_unittest.cc b/media/formats/mp2t/timestamp_unroller_unittest.cc
index 952ab1c..8fd0e3f 100644
--- a/media/formats/mp2t/timestamp_unroller_unittest.cc
+++ b/media/formats/mp2t/timestamp_unroller_unittest.cc
@@ -7,7 +7,7 @@
 #include <vector>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/test/perf_test_suite.h"
 #include "media/formats/mp2t/timestamp_unroller.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -52,7 +52,7 @@
   };
 
   std::vector<int64_t> timestamps_vector(timestamps,
-                                         timestamps + arraysize(timestamps));
+                                         timestamps + base::size(timestamps));
   RunUnrollTest(timestamps_vector);
 }
 
diff --git a/media/formats/mp4/avc_unittest.cc b/media/formats/mp4/avc_unittest.cc
index 944ca1b..3fed74f 100644
--- a/media/formats/mp4/avc_unittest.cc
+++ b/media/formats/mp4/avc_unittest.cc
@@ -8,8 +8,8 @@
 
 #include <ostream>
 
-#include "base/macros.h"
 #include "base/optional.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "media/base/decrypt_config.h"
@@ -436,7 +436,7 @@
       {"SDC I", false},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::vector<uint8_t> buf;
     std::vector<SubsampleEntry> subsamples;
     StringToAnnexB(test_cases[i].case_string, &buf, NULL);
@@ -484,7 +484,7 @@
   BitstreamConverter::AnalysisResult expected;
   expected.is_conformant = false;
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::vector<uint8_t> buf;
     std::vector<SubsampleEntry> subsamples;
     StringToAnnexB(test_cases[i].case_string, &buf, NULL);
@@ -532,7 +532,7 @@
   expected.is_conformant = true;
   expected.is_keyframe = true;
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     std::vector<uint8_t> buf;
     std::vector<SubsampleEntry> subsamples;
 
diff --git a/media/formats/mp4/sample_to_group_iterator_unittest.cc b/media/formats/mp4/sample_to_group_iterator_unittest.cc
index 2c3e2fbef..92426e5 100644
--- a/media/formats/mp4/sample_to_group_iterator_unittest.cc
+++ b/media/formats/mp4/sample_to_group_iterator_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace media {
@@ -24,7 +24,7 @@
  public:
   SampleToGroupIteratorTest() {
     // Build sample group description index table from kSampleToGroupTable.
-    for (size_t i = 0; i < arraysize(kCompactSampleToGroupTable); ++i) {
+    for (size_t i = 0; i < base::size(kCompactSampleToGroupTable); ++i) {
       for (uint32_t j = 0; j < kCompactSampleToGroupTable[i].sample_count;
            ++j) {
         sample_to_group_table_.push_back(
@@ -34,7 +34,7 @@
 
     sample_to_group_.entries.assign(
         kCompactSampleToGroupTable,
-        kCompactSampleToGroupTable + arraysize(kCompactSampleToGroupTable));
+        kCompactSampleToGroupTable + base::size(kCompactSampleToGroupTable));
     sample_to_group_iterator_.reset(
         new SampleToGroupIterator(sample_to_group_));
   }
diff --git a/media/formats/mp4/track_run_iterator.cc b/media/formats/mp4/track_run_iterator.cc
index ffd7113..e3b059f 100644
--- a/media/formats/mp4/track_run_iterator.cc
+++ b/media/formats/mp4/track_run_iterator.cc
@@ -9,9 +9,9 @@
 #include <limits>
 #include <memory>
 
-#include "base/macros.h"
 #include "base/numerics/checked_math.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "media/base/demuxer_memory_limit.h"
 #include "media/base/encryption_scheme.h"
 #include "media/base/media_util.h"
@@ -721,7 +721,7 @@
     if (ApplyConstantIv(sample_idx, &sample_encryption_entry)) {
       std::string iv(reinterpret_cast<const char*>(
                          sample_encryption_entry.initialization_vector),
-                     arraysize(sample_encryption_entry.initialization_vector));
+                     base::size(sample_encryption_entry.initialization_vector));
       switch (run_itr_->encryption_scheme.mode()) {
         case EncryptionScheme::CIPHER_MODE_UNENCRYPTED:
           return nullptr;
@@ -744,7 +744,7 @@
       run_itr_->sample_encryption_entries[sample_idx];
   std::string iv(reinterpret_cast<const char*>(
                      sample_encryption_entry.initialization_vector),
-                 arraysize(sample_encryption_entry.initialization_vector));
+                 base::size(sample_encryption_entry.initialization_vector));
 
   size_t total_size = 0;
   if (!sample_encryption_entry.subsamples.empty() &&
diff --git a/media/formats/mp4/track_run_iterator_unittest.cc b/media/formats/mp4/track_run_iterator_unittest.cc
index 03f68b4..c06c1f47 100644
--- a/media/formats/mp4/track_run_iterator_unittest.cc
+++ b/media/formats/mp4/track_run_iterator_unittest.cc
@@ -10,7 +10,7 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "media/base/mock_media_log.h"
 #include "media/formats/mp4/box_definitions.h"
@@ -344,7 +344,7 @@
     sinf->info.track_encryption.is_encrypted = true;
     sinf->info.track_encryption.default_iv_size = 8;
     sinf->info.track_encryption.default_kid.assign(kKeyId,
-                                                   kKeyId + arraysize(kKeyId));
+                                                   kKeyId + base::size(kKeyId));
   }
 
   // Add SampleGroupDescription Box to track level sample table and to
@@ -361,7 +361,7 @@
     track_cenc_group.entries[0].iv_size = 8;
     track_cenc_group.entries[0].key_id.assign(
         kTrackCencSampleGroupKeyId,
-        kTrackCencSampleGroupKeyId + arraysize(kTrackCencSampleGroupKeyId));
+        kTrackCencSampleGroupKeyId + base::size(kTrackCencSampleGroupKeyId));
 
     frag->sample_group_description.grouping_type = FOURCC_SEIG;
     frag->sample_group_description.entries.resize(3);
@@ -372,11 +372,11 @@
     frag->sample_group_description.entries[1].key_id.assign(
         kFragmentCencSampleGroupKeyId,
         kFragmentCencSampleGroupKeyId +
-            arraysize(kFragmentCencSampleGroupKeyId));
+            base::size(kFragmentCencSampleGroupKeyId));
     frag->sample_group_description.entries[2].is_encrypted = true;
     frag->sample_group_description.entries[2].iv_size = 16;
     frag->sample_group_description.entries[2].key_id.assign(
-        kKeyId, kKeyId + arraysize(kKeyId));
+        kKeyId, kKeyId + base::size(kKeyId));
 
     frag->sample_to_group.grouping_type = FOURCC_SEIG;
     frag->sample_to_group.entries.assign(sample_to_group_entries,
@@ -400,12 +400,12 @@
       frag->sample_encryption.sample_encryption_data.assign(
           kSampleEncryptionDataWithSubsamples,
           kSampleEncryptionDataWithSubsamples +
-              arraysize(kSampleEncryptionDataWithSubsamples));
+              base::size(kSampleEncryptionDataWithSubsamples));
     } else {
       frag->sample_encryption.sample_encryption_data.assign(
           kSampleEncryptionDataWithoutSubsamples,
           kSampleEncryptionDataWithoutSubsamples +
-              arraysize(kSampleEncryptionDataWithoutSubsamples));
+              base::size(kSampleEncryptionDataWithoutSubsamples));
     }
 
     // Update sample sizes and aux info header.
@@ -438,7 +438,7 @@
     sinf->info.track_encryption.default_constant_iv_size = 16;
     memcpy(sinf->info.track_encryption.default_constant_iv, kIv3, 16);
     sinf->info.track_encryption.default_kid.assign(kKeyId,
-                                                   kKeyId + arraysize(kKeyId));
+                                                   kKeyId + base::size(kKeyId));
   }
 
   void AddConstantIvsToCencSampleGroup(Track* track, TrackFragment* frag) {
@@ -467,7 +467,7 @@
     frag->sample_encryption.sample_encryption_data.assign(
         kSampleEncryptionDataWithSubsamplesAndConstantIv,
         kSampleEncryptionDataWithSubsamplesAndConstantIv +
-            arraysize(kSampleEncryptionDataWithSubsamplesAndConstantIv));
+            base::size(kSampleEncryptionDataWithSubsamplesAndConstantIv));
 
     // Update sample sizes and aux info header.
     frag->runs.resize(1);
@@ -715,14 +715,14 @@
   EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[1].runs[0].data_offset);
   std::unique_ptr<DecryptConfig> config = iter_->GetDecryptConfig();
   EXPECT_EQ(
-      std::string(reinterpret_cast<const char*>(kKeyId), arraysize(kKeyId)),
+      std::string(reinterpret_cast<const char*>(kKeyId), base::size(kKeyId)),
       config->key_id());
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv1), arraysize(kIv1)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv1), base::size(kIv1)),
             config->iv());
   EXPECT_EQ(config->subsamples().size(), 0u);
   iter_->AdvanceSample();
   config = iter_->GetDecryptConfig();
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv2), arraysize(kIv2)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv2), base::size(kIv2)),
             config->iv());
   EXPECT_EQ(config->subsamples().size(), 0u);
 }
@@ -743,7 +743,7 @@
       // With Iv size 16 bytes.
       {1, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 3}};
   AddCencSampleGroup(&moov_.tracks[1], &moof.tracks[1], kSampleToGroupTable,
-                     arraysize(kSampleToGroupTable));
+                     base::size(kSampleToGroupTable));
 
   ASSERT_TRUE(iter_->Init(moof));
   // The run for track 2 will be the second, which is parsed according to
@@ -758,14 +758,14 @@
   EXPECT_EQ(iter_->sample_offset(), 200);
   EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[1].runs[0].data_offset);
   std::unique_ptr<DecryptConfig> config = iter_->GetDecryptConfig();
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv1), arraysize(kIv1)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv1), base::size(kIv1)),
             config->iv());
   EXPECT_EQ(config->subsamples().size(), 1u);
   EXPECT_EQ(config->subsamples()[0].clear_bytes, 1u);
   EXPECT_EQ(config->subsamples()[0].cypher_bytes, 2u);
   iter_->AdvanceSample();
   config = iter_->GetDecryptConfig();
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv3), arraysize(kIv3)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv3), base::size(kIv3)),
             config->iv());
   EXPECT_EQ(config->subsamples().size(), 2u);
   EXPECT_EQ(config->subsamples()[0].clear_bytes, 1u);
@@ -788,21 +788,22 @@
   EXPECT_EQ(iter_->track_id(), 2u);
   EXPECT_TRUE(iter_->is_encrypted());
   ASSERT_TRUE(iter_->AuxInfoNeedsToBeCached());
-  EXPECT_EQ(static_cast<uint32_t>(iter_->aux_info_size()), arraysize(kAuxInfo));
+  EXPECT_EQ(static_cast<uint32_t>(iter_->aux_info_size()),
+            base::size(kAuxInfo));
   EXPECT_EQ(iter_->aux_info_offset(), 50);
   EXPECT_EQ(iter_->GetMaxClearOffset(), 50);
   EXPECT_FALSE(iter_->CacheAuxInfo(NULL, 0));
   EXPECT_FALSE(iter_->CacheAuxInfo(kAuxInfo, 3));
   EXPECT_TRUE(iter_->AuxInfoNeedsToBeCached());
-  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo)));
+  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, base::size(kAuxInfo)));
   EXPECT_FALSE(iter_->AuxInfoNeedsToBeCached());
   EXPECT_EQ(iter_->sample_offset(), 200);
   EXPECT_EQ(iter_->GetMaxClearOffset(), moof.tracks[0].runs[0].data_offset);
   std::unique_ptr<DecryptConfig> config = iter_->GetDecryptConfig();
   EXPECT_EQ(
-      std::string(reinterpret_cast<const char*>(kKeyId), arraysize(kKeyId)),
+      std::string(reinterpret_cast<const char*>(kKeyId), base::size(kKeyId)),
       config->key_id());
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv1), arraysize(kIv1)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv1), base::size(kIv1)),
             config->iv());
   EXPECT_TRUE(config->subsamples().empty());
   iter_->AdvanceSample();
@@ -821,14 +822,15 @@
       // Associated with the first entry in SampleGroupDescription Box.
       {1, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 1}};
   AddCencSampleGroup(&moov_.tracks[0], &moof.tracks[0], kSampleToGroupTable,
-                     arraysize(kSampleToGroupTable));
+                     base::size(kSampleToGroupTable));
 
   iter_.reset(new TrackRunIterator(&moov_, &media_log_));
   ASSERT_TRUE(InitMoofWithArbitraryAuxInfo(&moof));
 
   std::string cenc_sample_group_key_id(
       kFragmentCencSampleGroupKeyId,
-      kFragmentCencSampleGroupKeyId + arraysize(kFragmentCencSampleGroupKeyId));
+      kFragmentCencSampleGroupKeyId +
+          base::size(kFragmentCencSampleGroupKeyId));
   // The first sample is encrypted and the second sample is unencrypted.
   EXPECT_TRUE(iter_->is_encrypted());
   EXPECT_EQ(cenc_sample_group_key_id, iter_->GetDecryptConfig()->key_id());
@@ -852,18 +854,19 @@
       // Associated with the 1st entry in track SampleGroupDescription Box.
       {2, 1}};
   AddCencSampleGroup(&moov_.tracks[0], &moof.tracks[0], kSampleToGroupTable,
-                     arraysize(kSampleToGroupTable));
+                     base::size(kSampleToGroupTable));
 
   iter_.reset(new TrackRunIterator(&moov_, &media_log_));
   ASSERT_TRUE(InitMoofWithArbitraryAuxInfo(&moof));
 
-  std::string track_encryption_key_id(kKeyId, kKeyId + arraysize(kKeyId));
+  std::string track_encryption_key_id(kKeyId, kKeyId + base::size(kKeyId));
   std::string track_cenc_sample_group_key_id(
       kTrackCencSampleGroupKeyId,
-      kTrackCencSampleGroupKeyId + arraysize(kTrackCencSampleGroupKeyId));
+      kTrackCencSampleGroupKeyId + base::size(kTrackCencSampleGroupKeyId));
   std::string fragment_cenc_sample_group_key_id(
       kFragmentCencSampleGroupKeyId,
-      kFragmentCencSampleGroupKeyId + arraysize(kFragmentCencSampleGroupKeyId));
+      kFragmentCencSampleGroupKeyId +
+          base::size(kFragmentCencSampleGroupKeyId));
 
   for (size_t i = 0; i < kSampleToGroupTable[0].sample_count; ++i) {
     EXPECT_TRUE(iter_->is_encrypted());
@@ -911,18 +914,18 @@
   ASSERT_TRUE(iter_->Init(moof));
   EXPECT_EQ(iter_->track_id(), 1u);
   EXPECT_EQ(iter_->aux_info_offset(), 50);
-  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo)));
+  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, base::size(kAuxInfo)));
   std::unique_ptr<DecryptConfig> config = iter_->GetDecryptConfig();
-  ASSERT_EQ(arraysize(kIv1), config->iv().size());
+  ASSERT_EQ(base::size(kIv1), config->iv().size());
   EXPECT_TRUE(!memcmp(kIv1, config->iv().data(), config->iv().size()));
   iter_->AdvanceSample();
   EXPECT_EQ(iter_->GetMaxClearOffset(), 50);
   iter_->AdvanceRun();
   EXPECT_EQ(iter_->GetMaxClearOffset(), 50);
   EXPECT_EQ(iter_->aux_info_offset(), 50);
-  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo)));
+  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, base::size(kAuxInfo)));
   EXPECT_EQ(iter_->GetMaxClearOffset(), 200);
-  ASSERT_EQ(arraysize(kIv1), config->iv().size());
+  ASSERT_EQ(base::size(kIv1), config->iv().size());
   EXPECT_TRUE(!memcmp(kIv1, config->iv().data(), config->iv().size()));
   iter_->AdvanceSample();
   EXPECT_EQ(iter_->GetMaxClearOffset(), 201);
@@ -957,13 +960,13 @@
   EXPECT_EQ(iter_->track_id(), 2u);
   EXPECT_EQ(iter_->aux_info_offset(), 50);
   EXPECT_EQ(iter_->sample_offset(), 200);
-  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo)));
+  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, base::size(kAuxInfo)));
   EXPECT_EQ(iter_->GetMaxClearOffset(), 100);
   iter_->AdvanceRun();
   EXPECT_EQ(iter_->track_id(), 1u);
   EXPECT_EQ(iter_->aux_info_offset(), 20000);
   EXPECT_EQ(iter_->sample_offset(), 100);
-  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo)));
+  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, base::size(kAuxInfo)));
   EXPECT_EQ(iter_->GetMaxClearOffset(), 100);
   iter_->AdvanceSample();
   EXPECT_EQ(iter_->GetMaxClearOffset(), 101);
@@ -972,7 +975,7 @@
   EXPECT_EQ(iter_->aux_info_offset(), 201);
   EXPECT_EQ(iter_->sample_offset(), 10000);
   EXPECT_EQ(iter_->GetMaxClearOffset(), 201);
-  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, arraysize(kAuxInfo)));
+  EXPECT_TRUE(iter_->CacheAuxInfo(kAuxInfo, base::size(kAuxInfo)));
   EXPECT_EQ(iter_->GetMaxClearOffset(), 10000);
 }
 
@@ -1031,17 +1034,17 @@
   EXPECT_EQ(iter_->sample_offset(), 200);
   std::unique_ptr<DecryptConfig> config = iter_->GetDecryptConfig();
   EXPECT_EQ(
-      std::string(reinterpret_cast<const char*>(kKeyId), arraysize(kKeyId)),
+      std::string(reinterpret_cast<const char*>(kKeyId), base::size(kKeyId)),
       config->key_id());
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv3), arraysize(kIv3)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv3), base::size(kIv3)),
             config->iv());
   EXPECT_TRUE(config->subsamples().empty());
   iter_->AdvanceSample();
   config = iter_->GetDecryptConfig();
   EXPECT_EQ(
-      std::string(reinterpret_cast<const char*>(kKeyId), arraysize(kKeyId)),
+      std::string(reinterpret_cast<const char*>(kKeyId), base::size(kKeyId)),
       config->key_id());
-  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv3), arraysize(kIv3)),
+  EXPECT_EQ(std::string(reinterpret_cast<const char*>(kIv3), base::size(kIv3)),
             config->iv());
   EXPECT_TRUE(config->subsamples().empty());
 }
@@ -1063,7 +1066,7 @@
       // Associated with the 1st entry in track SampleGroupDescription Box.
       {1, 1}};
   AddCencSampleGroup(&moov_.tracks[1], &moof.tracks[1], kSampleToGroupTable,
-                     arraysize(kSampleToGroupTable));
+                     base::size(kSampleToGroupTable));
   AddConstantIvsToCencSampleGroup(&moov_.tracks[1], &moof.tracks[1]);
   iter_.reset(new TrackRunIterator(&moov_, &media_log_));
   ASSERT_TRUE(iter_->Init(moof));
@@ -1071,9 +1074,9 @@
   // The run for track 2 will be the second.
   iter_->AdvanceRun();
 
-  std::string track_encryption_iv(kIv3, kIv3 + arraysize(kIv3));
-  std::string track_cenc_sample_group_iv(kIv4, kIv4 + arraysize(kIv4));
-  std::string fragment_cenc_sample_group_iv(kIv5, kIv5 + arraysize(kIv5));
+  std::string track_encryption_iv(kIv3, kIv3 + base::size(kIv3));
+  std::string track_cenc_sample_group_iv(kIv4, kIv4 + base::size(kIv4));
+  std::string fragment_cenc_sample_group_iv(kIv5, kIv5 + base::size(kIv5));
 
   for (size_t i = 0; i < kSampleToGroupTable[0].sample_count; ++i) {
     EXPECT_TRUE(iter_->is_encrypted());
diff --git a/media/formats/mpeg/adts_constants.cc b/media/formats/mpeg/adts_constants.cc
index bc898908..d868fccb 100644
--- a/media/formats/mpeg/adts_constants.cc
+++ b/media/formats/mpeg/adts_constants.cc
@@ -4,7 +4,7 @@
 
 #include "media/formats/mpeg/adts_constants.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace media {
 
@@ -13,7 +13,7 @@
 const int kADTSFrequencyTable[] = {96000, 88200, 64000, 48000, 44100,
                                    32000, 24000, 22050, 16000, 12000,
                                    11025, 8000,  7350};
-const size_t kADTSFrequencyTableSize = arraysize(kADTSFrequencyTable);
+const size_t kADTSFrequencyTableSize = base::size(kADTSFrequencyTable);
 
 // The following conversion table is extracted from ISO 14496 Part 3 -
 // Table 1.17 - Channel Configuration.
@@ -22,6 +22,6 @@
     media::CHANNEL_LAYOUT_STEREO,   media::CHANNEL_LAYOUT_SURROUND,
     media::CHANNEL_LAYOUT_4_0,      media::CHANNEL_LAYOUT_5_0_BACK,
     media::CHANNEL_LAYOUT_5_1_BACK, media::CHANNEL_LAYOUT_7_1};
-const size_t kADTSChannelLayoutTableSize = arraysize(kADTSChannelLayoutTable);
+const size_t kADTSChannelLayoutTableSize = base::size(kADTSChannelLayoutTable);
 
 }  // namespace media
diff --git a/media/formats/webm/webm_cluster_parser.cc b/media/formats/webm/webm_cluster_parser.cc
index f4aa78c7..297906c 100644
--- a/media/formats/webm/webm_cluster_parser.cc
+++ b/media/formats/webm/webm_cluster_parser.cc
@@ -9,8 +9,8 @@
 #include <vector>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/checked_math.h"
+#include "base/stl_util.h"
 #include "base/sys_byteorder.h"
 #include "media/base/decrypt_config.h"
 #include "media/base/timestamp_constants.h"
@@ -243,7 +243,7 @@
 
   int opusConfig = (data[0] & kTocConfigMask) >> 3;
   CHECK_GE(opusConfig, 0);
-  CHECK_LT(opusConfig, static_cast<int>(arraysize(kOpusFrameDurationsMu)));
+  CHECK_LT(opusConfig, static_cast<int>(base::size(kOpusFrameDurationsMu)));
 
   DCHECK_GT(frame_count, 0);
   base::TimeDelta duration = base::TimeDelta::FromMicroseconds(
diff --git a/media/formats/webm/webm_cluster_parser_unittest.cc b/media/formats/webm/webm_cluster_parser_unittest.cc
index 7ce98a5..ddacc0d5 100644
--- a/media/formats/webm/webm_cluster_parser_unittest.cc
+++ b/media/formats/webm/webm_cluster_parser_unittest.cc
@@ -15,7 +15,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "media/base/audio_decoder_config.h"
 #include "media/base/decrypt_config.h"
@@ -412,8 +412,9 @@
     9,  // Cluster end emits all buffers and 3rd video's duration is estimated
   };
 
-  ASSERT_EQ(arraysize(kBlockInfo), arraysize(kExpectedBuffersOnPartialCluster));
-  int block_count = arraysize(kBlockInfo);
+  ASSERT_EQ(base::size(kBlockInfo),
+            base::size(kExpectedBuffersOnPartialCluster));
+  int block_count = base::size(kBlockInfo);
 
   // Iteratively create a cluster containing the first N+1 blocks and parse all
   // but the last byte of the cluster (except when N==|block_count|, just parse
@@ -459,7 +460,7 @@
 TEST_F(WebMClusterParserTest, Reset) {
   InSequence s;
 
-  int block_count = arraysize(kDefaultBlockInfo);
+  int block_count = base::size(kDefaultBlockInfo);
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kDefaultBlockInfo, block_count));
 
@@ -479,7 +480,7 @@
 }
 
 TEST_F(WebMClusterParserTest, ParseClusterWithSingleCall) {
-  int block_count = arraysize(kDefaultBlockInfo);
+  int block_count = base::size(kDefaultBlockInfo);
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kDefaultBlockInfo, block_count));
 
@@ -489,7 +490,7 @@
 }
 
 TEST_F(WebMClusterParserTest, ParseClusterWithMultipleCalls) {
-  int block_count = arraysize(kDefaultBlockInfo);
+  int block_count = base::size(kDefaultBlockInfo);
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kDefaultBlockInfo, block_count));
 
@@ -535,7 +536,7 @@
       {kAudioTrackNum, 0, 23, false, NULL, 0, true},
       {kVideoTrackNum, 33, 34, false, NULL, 0, true},
   };
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
 
   const uint8_t kClusterData[] = {
     0x1F, 0x43, 0xB6, 0x75, 0x9B,  // Cluster(size=27)
@@ -564,7 +565,7 @@
       {kAudioTrackNum, 46, 23, false, NULL, 0, false},
       {kVideoTrackNum, 67, 33, false, NULL, 0, false},
   };
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
 
   int result = parser_->Parse(cluster->data(), cluster->size());
@@ -586,7 +587,7 @@
       {kAudioTrackNum, 46, 23, true, NULL, 0, false},
       {kVideoTrackNum, 67, 34, true, NULL, 0, false},
   };
-  int input_block_count = arraysize(kInputBlockInfo);
+  int input_block_count = base::size(kInputBlockInfo);
 
   const BlockInfo kOutputBlockInfo[] = {
       {kAudioTrackNum, 0, 23, true, NULL, 0, false},
@@ -595,7 +596,7 @@
       {kAudioTrackNum, 46, 23, true, NULL, 0, false},
       {kVideoTrackNum, 67, 34, true, NULL, 0, false},
   };
-  int output_block_count = arraysize(kOutputBlockInfo);
+  int output_block_count = base::size(kOutputBlockInfo);
 
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kInputBlockInfo, input_block_count));
@@ -626,7 +627,7 @@
       {kTextTrackNum, 55, 44, false, NULL, 0, true},
       {kVideoTrackNum, 67, 34, true, NULL, 0, false},
   };
-  int input_block_count = arraysize(kInputBlockInfo);
+  int input_block_count = base::size(kInputBlockInfo);
 
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kInputBlockInfo, input_block_count));
@@ -651,7 +652,7 @@
   const BlockInfo kInputBlockInfo[] = {
     { kTextTrackNum,  33, 42, true },
   };
-  int input_block_count = arraysize(kInputBlockInfo);
+  int input_block_count = base::size(kInputBlockInfo);
 
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kInputBlockInfo, input_block_count));
@@ -687,7 +688,7 @@
       {kVideoTrackNum, 67, 34, true, NULL, 0, false},
       {kSubtitleTextTrackNum, 67, 33, false, NULL, 0, false},
   };
-  int input_block_count = arraysize(kInputBlockInfo);
+  int input_block_count = base::size(kInputBlockInfo);
 
   std::unique_ptr<Cluster> cluster(
       CreateCluster(0, kInputBlockInfo, input_block_count));
@@ -771,7 +772,7 @@
   const BlockInfo kBlockInfo[] = {
       {kTextTrackNum, 33, -42, false, NULL, 0, false},
   };
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
   int result = parser_->Parse(cluster->data(), cluster->size());
   EXPECT_LT(result, 0);
@@ -801,7 +802,7 @@
        false},
   };
 
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
 
   // Send slightly less than the full cluster so all but the last block is
@@ -841,7 +842,7 @@
       {kVideoTrackNum, 100, kExpectedVideoEstimationInMs, true, NULL, 0, false},
   };
 
-  int block_count1 = arraysize(kBlockInfo1);
+  int block_count1 = base::size(kBlockInfo1);
   std::unique_ptr<Cluster> cluster1(
       CreateCluster(0, kBlockInfo1, block_count1));
 
@@ -879,7 +880,7 @@
       {kVideoTrackNum, 201, kExpectedVideoEstimationInMs, true, NULL, 0, false},
   };
 
-  int block_count2 = arraysize(kBlockInfo2);
+  int block_count2 = base::size(kBlockInfo2);
   std::unique_ptr<Cluster> cluster2(
       CreateCluster(0, kBlockInfo2, block_count2));
   EXPECT_MEDIA_LOG(
@@ -913,7 +914,7 @@
        false},
   };
 
-  int block_count1 = arraysize(kBlockInfo1);
+  int block_count1 = base::size(kBlockInfo1);
   std::unique_ptr<Cluster> cluster1(
       CreateCluster(0, kBlockInfo1, block_count1));
 
@@ -951,7 +952,7 @@
        false},
   };
 
-  int block_count2 = arraysize(kBlockInfo2);
+  int block_count2 = base::size(kBlockInfo2);
   std::unique_ptr<Cluster> cluster2(
       CreateCluster(0, kBlockInfo2, block_count2));
   EXPECT_MEDIA_LOG(
@@ -989,7 +990,7 @@
        false},
   };
 
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
 
   // Send slightly less than the full cluster so all but the last block is
@@ -1024,7 +1025,7 @@
     },
   };
 
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
   EXPECT_MEDIA_LOG(WebMSimpleBlockDurationEstimated(
       WebMClusterParser::kDefaultAudioBufferDurationInMs));
@@ -1044,7 +1045,7 @@
     { kVideoTrackNum, 0, kTestVideoFrameDefaultDurationInMs, true },
   };
 
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
   int result = parser_->Parse(cluster->data(), cluster->size());
   EXPECT_EQ(cluster->size(), result);
@@ -1067,7 +1068,7 @@
                                      packet_ptr->data(),
                                      packet_ptr->size()}};
 
-    int block_count = arraysize(kBlockInfo);
+    int block_count = base::size(kBlockInfo);
     std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
     int duration_ms = packet_ptr->duration_ms();  // Casts from double.
     if (duration_ms > 120) {
@@ -1113,7 +1114,7 @@
                                 packet_ptr->data(),
                                 packet_ptr->size()}};
 
-    int block_count = arraysize(block_infos);
+    int block_count = base::size(block_infos);
     std::unique_ptr<Cluster> cluster(
         CreateCluster(0, block_infos, block_count));
     int result = parser_->Parse(cluster->data(), cluster->size());
@@ -1147,14 +1148,13 @@
                                                     std::string(), kCodecOpus));
 
   // Single Block with BlockDuration and encrypted data.
-  const BlockInfo kBlockInfo[] = {{kAudioTrackNum,
-                                   0,
+  const BlockInfo kBlockInfo[] = {{kAudioTrackNum, 0,
                                    kTestAudioFrameDefaultDurationInMs,
                                    false,            // Not a SimpleBlock
                                    kEncryptedFrame,  // Encrypted frame data
-                                   arraysize(kEncryptedFrame)}};
+                                   base::size(kEncryptedFrame)}};
 
-  int block_count = arraysize(kBlockInfo);
+  int block_count = base::size(kBlockInfo);
   std::unique_ptr<Cluster> cluster(CreateCluster(0, kBlockInfo, block_count));
   int result = parser_->Parse(cluster->data(), cluster->size());
   EXPECT_EQ(cluster->size(), result);
diff --git a/media/formats/webm/webm_parser.cc b/media/formats/webm/webm_parser.cc
index fe6b72f..d28ac10 100644
--- a/media/formats/webm/webm_parser.cc
+++ b/media/formats/webm/webm_parser.cc
@@ -17,8 +17,8 @@
 #include <limits>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "media/formats/webm/webm_constants.h"
 
 namespace media {
@@ -388,7 +388,7 @@
 };
 
 #define LIST_ELEMENT_INFO(id, level, id_info) \
-    { (id), (level), (id_info), arraysize(id_info) }
+  { (id), (level), (id_info), base::size(id_info) }
 
 static const ListElementInfo kListElementInfo[] = {
     LIST_ELEMENT_INFO(kWebMIdCluster, 1, kClusterIds),
@@ -562,7 +562,7 @@
 
 // Finds ListElementInfo for a specific ID.
 static const ListElementInfo* FindListInfo(int id) {
-  for (size_t i = 0; i < arraysize(kListElementInfo); ++i) {
+  for (size_t i = 0; i < base::size(kListElementInfo); ++i) {
     if (id == kListElementInfo[i].id_)
       return &kListElementInfo[i];
   }
@@ -987,7 +987,7 @@
 bool WebMListParser::IsSiblingOrAncestor(int id_a, int id_b) const {
   if (id_a == kWebMIdCluster) {
     // kWebMIdCluster siblings.
-    for (size_t i = 0; i < arraysize(kSegmentIds); i++) {
+    for (size_t i = 0; i < base::size(kSegmentIds); i++) {
       if (kSegmentIds[i].id_ == id_b)
         return true;
     }
diff --git a/media/formats/webm/webm_parser_unittest.cc b/media/formats/webm/webm_parser_unittest.cc
index 11f3380..ae1f63f0 100644
--- a/media/formats/webm/webm_parser_unittest.cc
+++ b/media/formats/webm/webm_parser_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/formats/webm/cluster_builder.h"
 #include "media/formats/webm/webm_constants.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -346,7 +346,7 @@
   const uint8_t* kBuffers[] = {k1ByteReservedId, k2ByteReservedId,
                                k3ByteReservedId, k4ByteReservedId};
 
-  for (size_t i = 0; i < arraysize(kBuffers); i++) {
+  for (size_t i = 0; i < base::size(kBuffers); i++) {
     int id;
     int64_t element_size;
     int buffer_size = 2 + i;
@@ -374,7 +374,7 @@
                                k5ByteReservedSize, k6ByteReservedSize,
                                k7ByteReservedSize, k8ByteReservedSize};
 
-  for (size_t i = 0; i < arraysize(kBuffers); i++) {
+  for (size_t i = 0; i < base::size(kBuffers); i++) {
     int id;
     int64_t element_size;
     int buffer_size = 2 + i;
diff --git a/media/gpu/h264_decoder.cc b/media/gpu/h264_decoder.cc
index 9effde4..43ee2867 100644
--- a/media/gpu/h264_decoder.cc
+++ b/media/gpu/h264_decoder.cc
@@ -8,7 +8,6 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/callback_helpers.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/optional.h"
 #include "base/stl_util.h"
@@ -727,7 +726,7 @@
 
 bool H264Decoder::HandleMemoryManagementOps(scoped_refptr<H264Picture> pic) {
   // 8.2.5.4
-  for (size_t i = 0; i < arraysize(pic->ref_pic_marking); ++i) {
+  for (size_t i = 0; i < base::size(pic->ref_pic_marking); ++i) {
     // Code below does not support interlaced stream (per-field pictures).
     H264DecRefPicMarking* ref_pic_marking = &pic->ref_pic_marking[i];
     scoped_refptr<H264Picture> to_mark;
diff --git a/media/gpu/image_processor.h b/media/gpu/image_processor.h
index aa477e52..81bf062 100644
--- a/media/gpu/image_processor.h
+++ b/media/gpu/image_processor.h
@@ -50,8 +50,22 @@
   // Callback to be used to return the index of a processed image to the
   // client. After the client is done with the frame, call Process with the
   // index to return the output buffer to the image processor.
+  // FrameReadyCB shall be executed on the thread that creates ImageProcessor.
+  // ImageProcessor has to bind its weak pointer to the task to execute
+  // FrameReadyCB so that the task will not be called after ImageProcessor
+  // instance is destructed. Note that ImageProcessor client instance should
+  // have the same lifetime of or outlive ImageProcessor.
   using FrameReadyCB = base::OnceCallback<void(scoped_refptr<VideoFrame>)>;
 
+  // Callback to be used to notify client when ImageProcess encounters error.
+  // It should be assigned in subclass's factory method.
+  // ErrorCB shall be executed on the thread that creates ImageProcessor.
+  // ImageProcessor has to bind its weak pointer to the task to execute ErrorCB
+  // so that the task will not be called after ImageProcessor instance is
+  // destructed. Note that ImageProcessor client instance should have the same
+  // lifetime of or outlive ImageProcessor.
+  using ErrorCB = base::RepeatingClosure;
+
   // Called by client to process |frame|. The resulting processed frame will be
   // stored in |output_buffer_index| output buffer and notified via |cb|. The
   // processor will drop all its references to |frame| after it finishes
diff --git a/media/gpu/ipc/service/vda_video_decoder_unittest.cc b/media/gpu/ipc/service/vda_video_decoder_unittest.cc
index bad96f7..859e6e1 100644
--- a/media/gpu/ipc/service/vda_video_decoder_unittest.cc
+++ b/media/gpu/ipc/service/vda_video_decoder_unittest.cc
@@ -6,10 +6,10 @@
 
 #include <stdint.h>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/scoped_refptr.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/mock_callback.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread.h"
@@ -43,7 +43,7 @@
 namespace {
 
 constexpr uint8_t kData[] = "foo";
-constexpr size_t kDataSize = arraysize(kData);
+constexpr size_t kDataSize = base::size(kData);
 
 scoped_refptr<DecoderBuffer> CreateDecoderBuffer(base::TimeDelta timestamp) {
   scoped_refptr<DecoderBuffer> buffer =
diff --git a/media/gpu/test/rendering_helper.cc b/media/gpu/test/rendering_helper.cc
index e745e28..2664108 100644
--- a/media/gpu/test/rendering_helper.cc
+++ b/media/gpu/test/rendering_helper.cc
@@ -17,9 +17,9 @@
 #include "base/callback_helpers.h"
 #include "base/command_line.h"
 #include "base/mac/scoped_nsautorelease_pool.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringize_macros.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -50,7 +50,7 @@
   glGetShaderiv(shader, GL_COMPILE_STATUS, &result);
   if (!result) {
     char log[4096];
-    glGetShaderInfoLog(shader, arraysize(log), NULL, log);
+    glGetShaderInfoLog(shader, base::size(log), NULL, log);
     LOG(FATAL) << log;
   }
   glAttachShader(program, shader);
@@ -260,15 +260,15 @@
 #endif
   program_ = glCreateProgram();
   CreateShader(program_, GL_VERTEX_SHADER, kVertexShader,
-               arraysize(kVertexShader));
+               base::size(kVertexShader));
   CreateShader(program_, GL_FRAGMENT_SHADER, kFragmentShader,
-               arraysize(kFragmentShader));
+               base::size(kFragmentShader));
   glLinkProgram(program_);
   int result = GL_FALSE;
   glGetProgramiv(program_, GL_LINK_STATUS, &result);
   if (!result) {
     char log[4096];
-    glGetShaderInfoLog(program_, arraysize(log), NULL, log);
+    glGetShaderInfoLog(program_, base::size(log), NULL, log);
     LOG(FATAL) << log;
   }
   glUseProgram(program_);
diff --git a/media/gpu/v4l2/generic_v4l2_device.cc b/media/gpu/v4l2/generic_v4l2_device.cc
index 4292534..5ab4cec2 100644
--- a/media/gpu/v4l2/generic_v4l2_device.cc
+++ b/media/gpu/v4l2/generic_v4l2_device.cc
@@ -19,8 +19,8 @@
 #include <memory>
 
 #include "base/files/scoped_file.h"
-#include "base/macros.h"
 #include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/trace_event.h"
 #include "build/build_config.h"
@@ -208,9 +208,9 @@
 
   return std::find(
              kEGLImageDrmFmtsSupported,
-             kEGLImageDrmFmtsSupported + arraysize(kEGLImageDrmFmtsSupported),
+             kEGLImageDrmFmtsSupported + base::size(kEGLImageDrmFmtsSupported),
              V4L2PixFmtToDrmFormat(v4l2_pixfmt)) !=
-         kEGLImageDrmFmtsSupported + arraysize(kEGLImageDrmFmtsSupported);
+         kEGLImageDrmFmtsSupported + base::size(kEGLImageDrmFmtsSupported);
 }
 
 EGLImageKHR GenericV4L2Device::CreateEGLImage(
diff --git a/media/gpu/v4l2/v4l2_image_processor.cc b/media/gpu/v4l2/v4l2_image_processor.cc
index 6fc6db3..0b5e89c3 100644
--- a/media/gpu/v4l2/v4l2_image_processor.cc
+++ b/media/gpu/v4l2/v4l2_image_processor.cc
@@ -74,7 +74,7 @@
     gfx::Size input_visible_size,
     gfx::Size output_visible_size,
     size_t num_buffers,
-    const base::Closure& error_cb)
+    ErrorCB error_cb)
     : input_layout_(input_layout),
       input_visible_size_(input_visible_size),
       input_memory_type_(input_memory_type),
@@ -84,7 +84,7 @@
       output_memory_type_(output_memory_type),
       output_storage_type_(output_storage_type),
       output_mode_(output_mode),
-      child_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+      client_task_runner_(base::ThreadTaskRunnerHandle::Get()),
       device_(device),
       device_thread_("V4L2ImageProcessorThread"),
       device_poll_thread_("V4L2ImageProcessorDevicePollThread"),
@@ -99,7 +99,7 @@
 }
 
 V4L2ImageProcessor::~V4L2ImageProcessor() {
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
 
   Destroy();
 
@@ -112,15 +112,14 @@
 
 void V4L2ImageProcessor::NotifyError() {
   VLOGF(1);
-  DCHECK(!child_task_runner_->BelongsToCurrentThread());
-  child_task_runner_->PostTask(
-      FROM_HERE, base::BindOnce(&V4L2ImageProcessor::NotifyErrorOnChildThread,
-                                weak_this_, error_cb_));
+  DCHECK(!client_task_runner_->BelongsToCurrentThread());
+  client_task_runner_->PostTask(
+      FROM_HERE, base::BindOnce(&V4L2ImageProcessor::NotifyErrorOnClientThread,
+                                weak_this_));
 }
 
-void V4L2ImageProcessor::NotifyErrorOnChildThread(
-    const base::Closure& error_cb) {
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+void V4L2ImageProcessor::NotifyErrorOnClientThread() {
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   error_cb_.Run();
 }
 
@@ -144,16 +143,16 @@
 
 // static
 std::unique_ptr<V4L2ImageProcessor> V4L2ImageProcessor::Create(
-      scoped_refptr<V4L2Device> device,
-      VideoFrame::StorageType input_storage_type,
-      VideoFrame::StorageType output_storage_type,
-      OutputMode output_mode,
-      const VideoFrameLayout& input_layout,
-      const VideoFrameLayout& output_layout,
-      gfx::Size input_visible_size,
-      gfx::Size output_visible_size,
-      size_t num_buffers,
-      const base::Closure& error_cb) {
+    scoped_refptr<V4L2Device> device,
+    VideoFrame::StorageType input_storage_type,
+    VideoFrame::StorageType output_storage_type,
+    OutputMode output_mode,
+    const VideoFrameLayout& input_layout,
+    const VideoFrameLayout& output_layout,
+    gfx::Size input_visible_size,
+    gfx::Size output_visible_size,
+    size_t num_buffers,
+    ErrorCB error_cb) {
   VLOGF(2);
   DCHECK_GT(num_buffers, 0u);
   if (!device) {
@@ -450,7 +449,7 @@
 
 bool V4L2ImageProcessor::Reset() {
   VLOGF(2);
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   DCHECK(device_thread_.IsRunning());
 
   weak_this_factory_.InvalidateWeakPtrs();
@@ -472,7 +471,7 @@
 
 void V4L2ImageProcessor::Destroy() {
   VLOGF(2);
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
 
   weak_this_factory_.InvalidateWeakPtrs();
 
@@ -491,7 +490,7 @@
 
 bool V4L2ImageProcessor::CreateInputBuffers() {
   VLOGF(2);
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   DCHECK(!input_streamon_);
 
   struct v4l2_control control;
@@ -558,7 +557,7 @@
 
 bool V4L2ImageProcessor::CreateOutputBuffers() {
   VLOGF(2);
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   DCHECK(!output_streamon_);
 
   struct v4l2_rect visible_rect;
@@ -615,7 +614,7 @@
 
 void V4L2ImageProcessor::DestroyInputBuffers() {
   VLOGF(2);
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   DCHECK(!input_streamon_);
 
   struct v4l2_requestbuffers reqbufs;
@@ -631,7 +630,7 @@
 
 void V4L2ImageProcessor::DestroyOutputBuffers() {
   VLOGF(2);
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   DCHECK(!output_streamon_);
 
   output_buffer_map_.clear();
@@ -807,7 +806,7 @@
 
     DVLOGF(4) << "Processing finished, returning frame, index=" << dqbuf.index;
 
-    child_task_runner_->PostTask(
+    client_task_runner_->PostTask(
         FROM_HERE, base::BindOnce(&V4L2ImageProcessor::FrameReady, weak_this_,
                                   std::move(job_record->ready_cb),
                                   job_record->output_frame));
@@ -985,7 +984,7 @@
 
 void V4L2ImageProcessor::FrameReady(FrameReadyCB cb,
                                     scoped_refptr<VideoFrame> frame) {
-  DCHECK(child_task_runner_->BelongsToCurrentThread());
+  DCHECK(client_task_runner_->BelongsToCurrentThread());
   std::move(cb).Run(frame);
 }
 
diff --git a/media/gpu/v4l2/v4l2_image_processor.h b/media/gpu/v4l2/v4l2_image_processor.h
index 9550dda..cf89bb4 100644
--- a/media/gpu/v4l2/v4l2_image_processor.h
+++ b/media/gpu/v4l2/v4l2_image_processor.h
@@ -67,8 +67,8 @@
   // input_format to output_format. Caller shall provide input and output
   // storage type as well as output mode. The number of input buffers and output
   // buffers will be |num_buffers|. Provided |error_cb| will be posted to the
-  // child thread if an error occurs after initialization. Returns nullptr if
-  // V4L2ImageProcessor fails to create.
+  // same thread Create() is called if an error occurs after initialization.
+  // Returns nullptr if V4L2ImageProcessor fails to create.
   // Note: output_mode will be removed once all its clients use import mode.
   static std::unique_ptr<V4L2ImageProcessor> Create(
       scoped_refptr<V4L2Device> device,
@@ -80,7 +80,7 @@
       gfx::Size input_visible_size,
       gfx::Size output_visible_size,
       size_t num_buffers,
-      const base::Closure& error_cb);
+      ErrorCB error_cb);
 
  private:
   // Record for input buffers.
@@ -130,7 +130,7 @@
                      gfx::Size input_visible_size,
                      gfx::Size output_visible_size,
                      size_t num_buffers,
-                     const base::Closure& error_cb);
+                     ErrorCB error_cb);
 
   bool Initialize();
   void EnqueueInput();
@@ -143,8 +143,12 @@
   void DestroyInputBuffers();
   void DestroyOutputBuffers();
 
+  // Posts error on |client_task_runner_| thread. This must be called in a
+  // thread |client_task_runner_| doesn't belong to.
   void NotifyError();
-  void NotifyErrorOnChildThread(const base::Closure& error_cb);
+  // Invokes ErrorCB given by factory method. This must be called in
+  // |client_task_runner_|'s thread.
+  void NotifyErrorOnClientThread();
 
   void ProcessTask(std::unique_ptr<JobRecord> job_record);
   void ServiceDeviceTask();
@@ -176,8 +180,9 @@
   const VideoFrame::StorageType output_storage_type_;
   const OutputMode output_mode_;
 
-  // Our original calling task runner for the child thread.
-  const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
+  // The task runner which belongs to the thread where V4L2ImageProcessor is
+  // created.
+  const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner_;
 
   // V4L2 device in use.
   scoped_refptr<V4L2Device> device_;
@@ -211,17 +216,19 @@
   const size_t num_buffers_;
 
   // Error callback to the client.
-  base::Closure error_cb_;
+  ErrorCB error_cb_;
 
   // WeakPtr<> pointing to |this| for use in posting tasks from the device
-  // worker threads back to the child thread.  Because the worker threads
-  // are members of this class, any task running on those threads is guaranteed
-  // that this object is still alive.  As a result, tasks posted from the child
-  // thread to the device thread should use base::Unretained(this),
-  // and tasks posted the other way should use |weak_this_|.
+  // worker threads back to the the thread where V4L2ImageProcessor is created.
+  // Because the worker threads are members of this class, any task running on
+  // those threads is guaranteed that this object is still alive.  As a result,
+  // tasks posted from |client_task_runner_|'s thread to the device thread
+  // should use base::Unretained(this), and tasks posted the other way should
+  // use |weak_this_|.
   base::WeakPtr<V4L2ImageProcessor> weak_this_;
 
-  // Weak factory for producing weak pointers on the child thread.
+  // Weak factory for producing weak pointers on the |client_task_runner_|'s
+  // thread.
   base::WeakPtrFactory<V4L2ImageProcessor> weak_this_factory_;
 
   DISALLOW_COPY_AND_ASSIGN(V4L2ImageProcessor);
diff --git a/media/gpu/v4l2/v4l2_jpeg_decode_accelerator.cc b/media/gpu/v4l2/v4l2_jpeg_decode_accelerator.cc
index 4fafdea..984fd38 100644
--- a/media/gpu/v4l2/v4l2_jpeg_decode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_jpeg_decode_accelerator.cc
@@ -14,6 +14,7 @@
 #include "base/big_endian.h"
 #include "base/bind.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "media/filters/jpeg_parser.h"
 #include "media/gpu/macros.h"
@@ -389,7 +390,7 @@
     buffer.index = i;
     buffer.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
     buffer.m.planes = planes;
-    buffer.length = arraysize(planes);
+    buffer.length = base::size(planes);
     buffer.memory = V4L2_MEMORY_MMAP;
     IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
     if (buffer.length != kMaxInputPlanes) {
@@ -466,7 +467,7 @@
     buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
     buffer.memory = V4L2_MEMORY_MMAP;
     buffer.m.planes = planes;
-    buffer.length = arraysize(planes);
+    buffer.length = base::size(planes);
     IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
 
     if (output_buffer_num_planes_ != buffer.length) {
@@ -759,7 +760,7 @@
     memset(planes, 0, sizeof(planes));
     dqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
     dqbuf.memory = V4L2_MEMORY_MMAP;
-    dqbuf.length = arraysize(planes);
+    dqbuf.length = base::size(planes);
     dqbuf.m.planes = planes;
     if (device_->Ioctl(VIDIOC_DQBUF, &dqbuf) != 0) {
       if (errno == EAGAIN) {
@@ -796,7 +797,7 @@
     // USERPTR. Also, client doesn't need to consider the buffer alignment and
     // JpegDecodeAccelerator API will be simpler.
     dqbuf.memory = V4L2_MEMORY_MMAP;
-    dqbuf.length = arraysize(planes);
+    dqbuf.length = base::size(planes);
     dqbuf.m.planes = planes;
     if (device_->Ioctl(VIDIOC_DQBUF, &dqbuf) != 0) {
       if (errno == EAGAIN) {
@@ -943,7 +944,7 @@
   qbuf.index = index;
   qbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
   qbuf.memory = V4L2_MEMORY_MMAP;
-  qbuf.length = arraysize(planes);
+  qbuf.length = base::size(planes);
   // There is only one plane for V4L2_PIX_FMT_JPEG.
   planes[0].bytesused = input_record.length[0];
   qbuf.m.planes = planes;
@@ -972,7 +973,7 @@
   qbuf.index = index;
   qbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
   qbuf.memory = V4L2_MEMORY_MMAP;
-  qbuf.length = arraysize(planes);
+  qbuf.length = base::size(planes);
   qbuf.m.planes = planes;
   IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QBUF, &qbuf);
   output_record.at_device = true;
diff --git a/media/gpu/v4l2/v4l2_slice_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_slice_video_decode_accelerator.cc
index e82468b..42c56eb 100644
--- a/media/gpu/v4l2/v4l2_slice_video_decode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_slice_video_decode_accelerator.cc
@@ -20,10 +20,10 @@
 #include "base/callback.h"
 #include "base/callback_helpers.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -2015,8 +2015,8 @@
   if (!device)
     return SupportedProfiles();
 
-  return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_),
-                                            supported_input_fourccs_);
+  return device->GetSupportedDecodeProfiles(
+      base::size(supported_input_fourccs_), supported_input_fourccs_);
 }
 
 }  // namespace media
diff --git a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
index 896bd7ad..d8543adc 100644
--- a/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_video_decode_accelerator.cc
@@ -19,6 +19,7 @@
 #include "base/numerics/safe_conversions.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "base/trace_event/trace_event.h"
@@ -770,8 +771,8 @@
   if (!device)
     return SupportedProfiles();
 
-  return device->GetSupportedDecodeProfiles(arraysize(supported_input_fourccs_),
-                                            supported_input_fourccs_);
+  return device->GetSupportedDecodeProfiles(
+      base::size(supported_input_fourccs_), supported_input_fourccs_);
 }
 
 void V4L2VideoDecodeAccelerator::DecodeTask(scoped_refptr<DecoderBuffer> buffer,
@@ -2391,14 +2392,17 @@
     return false;
   }
 
-  // Unretained is safe because |this| owns image processor and there will be
-  // no callbacks after processor destroys.
+  // Unretained(this) is safe in creating ErrorCB because |image_processor_|
+  // is destructed by Destroy(), which posts DestroyTask() to |decoder_thread_|,
+  // which is the same thread ErrorCB being called. In DestroyTask(), it
+  // destructs |image_processor_| so no more ErrorCB is invoked after
+  // DestroyTask() is called.
   image_processor_ = V4L2ImageProcessor::Create(
       image_processor_device_, VideoFrame::STORAGE_DMABUFS,
       VideoFrame::STORAGE_DMABUFS, image_processor_output_mode, *input_layout,
       *output_layout, visible_size_, visible_size_, output_buffer_map_.size(),
-      base::Bind(&V4L2VideoDecodeAccelerator::ImageProcessorError,
-                 base::Unretained(this)));
+      base::BindRepeating(&V4L2VideoDecodeAccelerator::ImageProcessorError,
+                          base::Unretained(this)));
 
   if (!image_processor_) {
     VLOGF(1) << "Initialize image processor failed";
@@ -2450,8 +2454,13 @@
     if (output_fds.empty())
       return false;
   }
-  // Unretained is safe because |this| owns image processor and there will
-  // be no callbacks after processor destroys.
+  // Unretained(this) is safe in creating FrameReadyCB because
+  // |image_processor_| is destructed by Destroy(), which posts DestroyTask() to
+  // |decoder_thread_|, which is the same thread ErrorCB being called. In
+  // DestroyTask(), it destructs |image_processor_| so no more ErrorCB is
+  // invoked after DestroyTask() is called. Unretained is safe because |this|
+  // owns image processor and there will be no callbacks after processor
+  // destroys.
   image_processor_->Process(
       input_frame, output_buffer_index, std::move(output_fds),
       base::BindOnce(&V4L2VideoDecodeAccelerator::FrameProcessed,
diff --git a/media/gpu/v4l2/v4l2_video_encode_accelerator.cc b/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
index d855aef6..8f8a018 100644
--- a/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
+++ b/media/gpu/v4l2/v4l2_video_encode_accelerator.cc
@@ -16,9 +16,9 @@
 
 #include "base/callback.h"
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/trace_event/trace_event.h"
 #include "media/base/bind_to_current_loop.h"
@@ -223,8 +223,10 @@
     // Convert from |config.input_format| to |device_input_layout_->format()|,
     // keeping the size at |visible_size_| and requiring the output buffers to
     // be of at least |device_input_layout_->coded_size()|.
-    // Unretained is safe because |this| owns image processor and there will be
-    // no callbacks after processor destroys.
+    // Unretained(this) is safe in creating ErrorCB because |image_processor_|
+    // is destructed by Destroy() and Destroy() is posted in child_task_runner_,
+    // which is the same thread ErrorCB being called. So after Destroy() is
+    // called, no more ErrorCB will be invoked.
     // |input_storage_type| can be STORAGE_SHMEM and
     // STORAGE_MOJO_SHARED_BUFFER. However, it doesn't matter
     // VideoFrame::STORAGE_OWNED_MEMORY is specified for |input_storage_type|
@@ -235,8 +237,8 @@
         VideoFrame::STORAGE_DMABUFS, ImageProcessor::OutputMode::ALLOCATE,
         *input_layout, *device_input_layout_, visible_size_, visible_size_,
         kImageProcBufferCount,
-        base::Bind(&V4L2VideoEncodeAccelerator::ImageProcessorError,
-                   base::Unretained(this)));
+        base::BindRepeating(&V4L2VideoEncodeAccelerator::ImageProcessorError,
+                            base::Unretained(this)));
     if (!image_processor_) {
       VLOGF(1) << "Failed initializing image processor";
       return false;
@@ -315,8 +317,11 @@
     if (free_image_processor_output_buffers_.size() > 0) {
       int output_buffer_index = free_image_processor_output_buffers_.back();
       free_image_processor_output_buffers_.pop_back();
-      // Unretained is safe because |this| owns image processor and there will
-      // be no callbacks after processor destroys.
+      // Unretained(this) is safe in creating FrameReadyCB because
+      // |image_processor_| is destructed by Destroy() and Destroy() is posted
+      // in child_task_runner_, which is the same thread FrameReadyCB being
+      // called. So after Destroy() is called, no more FrameReadyCB will be
+      // invoked.
       if (!image_processor_->Process(
               frame, output_buffer_index, std::vector<base::ScopedFD>(),
               base::BindOnce(&V4L2VideoEncodeAccelerator::FrameProcessed,
@@ -1404,7 +1409,7 @@
     buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
     buffer.memory = V4L2_MEMORY_MMAP;
     buffer.m.planes = planes;
-    buffer.length = arraysize(planes);
+    buffer.length = base::size(planes);
     IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_QUERYBUF, &buffer);
     void* address = device_->Mmap(NULL,
                                   buffer.m.planes[0].length,
diff --git a/media/gpu/vaapi/vaapi_h264_accelerator.cc b/media/gpu/vaapi/vaapi_h264_accelerator.cc
index 7702731a..2775fdd 100644
--- a/media/gpu/vaapi/vaapi_h264_accelerator.cc
+++ b/media/gpu/vaapi/vaapi_h264_accelerator.cc
@@ -6,6 +6,7 @@
 
 #include <va/va.h>
 
+#include "base/stl_util.h"
 #include "media/gpu/decode_surface_handler.h"
 #include "media/gpu/h264_dpb.h"
 #include "media/gpu/macros.h"
@@ -138,7 +139,7 @@
 
   // And fill it with picture info from DPB.
   FillVARefFramesFromDPB(dpb, pic_param.ReferenceFrames,
-                         arraysize(pic_param.ReferenceFrames));
+                         base::size(pic_param.ReferenceFrames));
 
   pic_param.num_ref_frames = sps->max_num_ref_frames;
 
@@ -255,23 +256,23 @@
     }
   }
 
-  static_assert(
-      arraysize(slice_param.RefPicList0) == arraysize(slice_param.RefPicList1),
-      "Invalid RefPicList sizes");
+  static_assert(base::size(slice_param.RefPicList0) ==
+                    base::size(slice_param.RefPicList1),
+                "Invalid RefPicList sizes");
 
-  for (size_t i = 0; i < arraysize(slice_param.RefPicList0); ++i) {
+  for (size_t i = 0; i < base::size(slice_param.RefPicList0); ++i) {
     InitVAPicture(&slice_param.RefPicList0[i]);
     InitVAPicture(&slice_param.RefPicList1[i]);
   }
 
   for (size_t i = 0;
-       i < ref_pic_list0.size() && i < arraysize(slice_param.RefPicList0);
+       i < ref_pic_list0.size() && i < base::size(slice_param.RefPicList0);
        ++i) {
     if (ref_pic_list0[i])
       FillVAPicture(&slice_param.RefPicList0[i], ref_pic_list0[i]);
   }
   for (size_t i = 0;
-       i < ref_pic_list1.size() && i < arraysize(slice_param.RefPicList1);
+       i < ref_pic_list1.size() && i < base::size(slice_param.RefPicList1);
        ++i) {
     if (ref_pic_list1[i])
       FillVAPicture(&slice_param.RefPicList1[i], ref_pic_list1[i]);
diff --git a/media/gpu/vaapi/vaapi_jpeg_encoder.cc b/media/gpu/vaapi/vaapi_jpeg_encoder.cc
index 63b635e..18e49db 100644
--- a/media/gpu/vaapi/vaapi_jpeg_encoder.cc
+++ b/media/gpu/vaapi/vaapi_jpeg_encoder.cc
@@ -11,6 +11,7 @@
 #include "base/logging.h"
 #include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 #include "media/filters/jpeg_parser.h"
 #include "media/gpu/macros.h"
 #include "media/gpu/vaapi/vaapi_wrapper.h"
@@ -53,10 +54,10 @@
   static_assert(
       arraysize(luminance.value) == arraysize(q_matrix->lum_quantiser_matrix),
       "Luminance quantization table size mismatch.");
-  static_assert(arraysize(kZigZag8x8) == arraysize(luminance.value),
+  static_assert(base::size(kZigZag8x8) == base::size(luminance.value),
                 "Luminance quantization table size mismatch.");
   q_matrix->load_lum_quantiser_matrix = 1;
-  for (size_t i = 0; i < arraysize(kZigZag8x8); i++) {
+  for (size_t i = 0; i < base::size(kZigZag8x8); i++) {
     q_matrix->lum_quantiser_matrix[i] = luminance.value[kZigZag8x8[i]];
   }
 
@@ -64,23 +65,23 @@
   static_assert(arraysize(chrominance.value) ==
                     arraysize(q_matrix->chroma_quantiser_matrix),
                 "Chrominance quantization table size mismatch.");
-  static_assert(arraysize(kZigZag8x8) == arraysize(chrominance.value),
+  static_assert(base::size(kZigZag8x8) == base::size(chrominance.value),
                 "Chrominance quantization table size mismatch.");
   q_matrix->load_chroma_quantiser_matrix = 1;
-  for (size_t i = 0; i < arraysize(kZigZag8x8); i++) {
+  for (size_t i = 0; i < base::size(kZigZag8x8); i++) {
     q_matrix->chroma_quantiser_matrix[i] = chrominance.value[kZigZag8x8[i]];
   }
 }
 
 void FillHuffmanTableParameters(
     VAHuffmanTableBufferJPEGBaseline* huff_table_param) {
-  static_assert(arraysize(kDefaultDcTable) == arraysize(kDefaultAcTable),
+  static_assert(base::size(kDefaultDcTable) == base::size(kDefaultAcTable),
                 "DC table and AC table size mismatch.");
   static_assert(
       arraysize(kDefaultDcTable) == arraysize(huff_table_param->huffman_table),
       "DC table and destination table size mismatch.");
 
-  for (size_t i = 0; i < arraysize(kDefaultDcTable); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultDcTable); ++i) {
     const JpegHuffmanTable& dcTable = kDefaultDcTable[i];
     const JpegHuffmanTable& acTable = kDefaultAcTable[i];
     huff_table_param->load_huffman_table[i] = true;
diff --git a/media/gpu/vaapi/vaapi_vp9_accelerator.cc b/media/gpu/vaapi/vaapi_vp9_accelerator.cc
index 69b994f1..11c0b583 100644
--- a/media/gpu/vaapi/vaapi_vp9_accelerator.cc
+++ b/media/gpu/vaapi/vaapi_vp9_accelerator.cc
@@ -4,6 +4,7 @@
 
 #include "media/gpu/vaapi/vaapi_vp9_accelerator.h"
 
+#include "base/stl_util.h"
 #include "media/gpu/decode_surface_handler.h"
 #include "media/gpu/macros.h"
 #include "media/gpu/vaapi/vaapi_common.h"
@@ -55,8 +56,8 @@
   pic_param.frame_height =
       base::checked_cast<uint16_t>(frame_hdr->frame_height);
 
-  CHECK_EQ(ref_pictures.size(), arraysize(pic_param.reference_frames));
-  for (size_t i = 0; i < arraysize(pic_param.reference_frames); ++i) {
+  CHECK_EQ(ref_pictures.size(), base::size(pic_param.reference_frames));
+  for (size_t i = 0; i < base::size(pic_param.reference_frames); ++i) {
     if (ref_pictures[i]) {
       pic_param.reference_frames[i] =
           ref_pictures[i]->AsVaapiVP9Picture()->GetVASurfaceID();
@@ -122,7 +123,7 @@
   static_assert(arraysize(Vp9SegmentationParams::feature_enabled) ==
                     arraysize(slice_param.seg_param),
                 "seg_param array of incorrect size");
-  for (size_t i = 0; i < arraysize(slice_param.seg_param); ++i) {
+  for (size_t i = 0; i < base::size(slice_param.seg_param); ++i) {
     VASegmentParameterVP9& seg_param = slice_param.seg_param[i];
 #define SEG_TO_SP_SF(a, b) seg_param.segment_flags.fields.a = b
     SEG_TO_SP_SF(
diff --git a/media/gpu/vaapi/vaapi_wrapper.cc b/media/gpu/vaapi/vaapi_wrapper.cc
index 6daab8b..aa747385 100644
--- a/media/gpu/vaapi/vaapi_wrapper.cc
+++ b/media/gpu/vaapi/vaapi_wrapper.cc
@@ -699,7 +699,7 @@
 VAProfile ProfileToVAProfile(VideoCodecProfile profile,
                              VaapiWrapper::CodecMode mode) {
   VAProfile va_profile = VAProfileNone;
-  for (size_t i = 0; i < arraysize(kProfileMap); ++i) {
+  for (size_t i = 0; i < base::size(kProfileMap); ++i) {
     if (kProfileMap[i].profile == profile) {
       va_profile = kProfileMap[i].va_profile;
       break;
@@ -854,7 +854,7 @@
   const std::vector<VASupportedProfiles::ProfileInfo>& encode_profile_infos =
       VASupportedProfiles::Get().GetSupportedProfileInfosForCodecMode(kEncode);
 
-  for (size_t i = 0; i < arraysize(kProfileMap); ++i) {
+  for (size_t i = 0; i < base::size(kProfileMap); ++i) {
     VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kEncode);
     if (va_profile == VAProfileNone)
       continue;
@@ -880,7 +880,7 @@
   const std::vector<VASupportedProfiles::ProfileInfo>& decode_profile_infos =
       VASupportedProfiles::Get().GetSupportedProfileInfosForCodecMode(kDecode);
 
-  for (size_t i = 0; i < arraysize(kProfileMap); ++i) {
+  for (size_t i = 0; i < base::size(kProfileMap); ++i) {
     VAProfile va_profile = ProfileToVAProfile(kProfileMap[i].profile, kDecode);
     if (va_profile == VAProfileNone)
       continue;
diff --git a/media/gpu/vt_video_decode_accelerator_mac.cc b/media/gpu/vt_video_decode_accelerator_mac.cc
index 365a360..e09762f 100644
--- a/media/gpu/vt_video_decode_accelerator_mac.cc
+++ b/media/gpu/vt_video_decode_accelerator_mac.cc
@@ -17,7 +17,6 @@
 #include "base/bind.h"
 #include "base/logging.h"
 #include "base/mac/mac_logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
@@ -210,8 +209,8 @@
                                 0x3d, 0xa1, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00,
                                 0x00, 0x03, 0x00, 0x30, 0x8f, 0x16, 0x2d, 0x9a};
   const uint8_t pps_normal[] = {0x68, 0xe9, 0x7b, 0xcb};
-  if (!CreateVideoToolboxSession(sps_normal, arraysize(sps_normal), pps_normal,
-                                 arraysize(pps_normal), true)) {
+  if (!CreateVideoToolboxSession(sps_normal, base::size(sps_normal), pps_normal,
+                                 base::size(pps_normal), true)) {
     DVLOG(1) << "Hardware decoding with VideoToolbox is not supported";
     return false;
   }
@@ -222,8 +221,8 @@
                                0x22, 0x10, 0x00, 0x00, 0x3e, 0x90, 0x00, 0x0e,
                                0xa6, 0x08, 0xf1, 0x22, 0x59, 0xa0};
   const uint8_t pps_small[] = {0x68, 0xe9, 0x79, 0x72, 0xc0};
-  if (!CreateVideoToolboxSession(sps_small, arraysize(sps_small), pps_small,
-                                 arraysize(pps_small), false)) {
+  if (!CreateVideoToolboxSession(sps_small, base::size(sps_small), pps_small,
+                                 base::size(pps_small), false)) {
     DLOG(WARNING) << "Software decoding with VideoToolbox is not supported";
     return false;
   }
@@ -314,7 +313,7 @@
       },
   };
   if (!GetImageBufferProperty(image_buffer, kCVImageBufferColorPrimariesKey,
-                              primaries, arraysize(primaries), &primary_id)) {
+                              primaries, base::size(primaries), &primary_id)) {
     DLOG(ERROR) << "Filed to find CVImageBufferRef primaries.";
   }
 
@@ -339,7 +338,7 @@
       },
   };
   if (!GetImageBufferProperty(image_buffer, kCVImageBufferTransferFunctionKey,
-                              transfers, arraysize(transfers), &transfer_id)) {
+                              transfers, base::size(transfers), &transfer_id)) {
     DLOG(ERROR) << "Filed to find CVImageBufferRef transfer.";
   }
 
@@ -382,7 +381,7 @@
                       gfx::ColorSpace::MatrixID::SMPTE240M,
                   }};
   if (!GetImageBufferProperty(image_buffer, kCVImageBufferYCbCrMatrixKey,
-                              matrices, arraysize(matrices), &matrix_id)) {
+                              matrices, base::size(matrices), &matrix_id)) {
     DLOG(ERROR) << "Filed to find CVImageBufferRef YUV matrix.";
   }
 
diff --git a/media/gpu/windows/d3d11_cdm_proxy.cc b/media/gpu/windows/d3d11_cdm_proxy.cc
index 5b5dfba..b188fc5 100644
--- a/media/gpu/windows/d3d11_cdm_proxy.cc
+++ b/media/gpu/windows/d3d11_cdm_proxy.cc
@@ -11,6 +11,7 @@
 #include "base/logging.h"
 #include "base/power_monitor/power_monitor.h"
 #include "base/power_monitor/power_observer.h"
+#include "base/stl_util.h"
 #include "base/synchronization/waitable_event.h"
 #include "base/win/object_watcher.h"
 #include "media/base/callback_registry.h"
@@ -285,7 +286,7 @@
       nullptr,                            // No adapter.
       D3D_DRIVER_TYPE_HARDWARE, nullptr,  // No software rasterizer.
       0,                                  // flags, none.
-      feature_levels, arraysize(feature_levels), D3D11_SDK_VERSION,
+      feature_levels, base::size(feature_levels), D3D11_SDK_VERSION,
       device_.GetAddressOf(), nullptr, device_context_.GetAddressOf());
   if (FAILED(hresult)) {
     DLOG(ERROR) << "Failed to create the D3D11Device:" << hresult;
diff --git a/media/gpu/windows/dxva_video_decode_accelerator_win.cc b/media/gpu/windows/dxva_video_decode_accelerator_win.cc
index e56a533..7369c67 100644
--- a/media/gpu/windows/dxva_video_decode_accelerator_win.cc
+++ b/media/gpu/windows/dxva_video_decode_accelerator_win.cc
@@ -32,7 +32,6 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/shared_memory.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
@@ -1052,7 +1051,7 @@
     flags |= D3D11_CREATE_DEVICE_DEBUG;
 
     hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags,
-                           feature_levels, arraysize(feature_levels),
+                           feature_levels, base::size(feature_levels),
                            D3D11_SDK_VERSION, d3d11_device_.GetAddressOf(),
                            &feature_level_out,
                            d3d11_device_context_.GetAddressOf());
@@ -1066,7 +1065,7 @@
 #endif
     if (!d3d11_device_context_) {
       hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, flags,
-                             feature_levels, arraysize(feature_levels),
+                             feature_levels, base::size(feature_levels),
                              D3D11_SDK_VERSION, d3d11_device_.GetAddressOf(),
                              &feature_level_out,
                              d3d11_device_context_.GetAddressOf());
diff --git a/media/midi/message_util_unittest.cc b/media/midi/message_util_unittest.cc
index 91450ff..b143436 100644
--- a/media/midi/message_util_unittest.cc
+++ b/media/midi/message_util_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace midi {
@@ -51,10 +51,11 @@
 
 TEST(MidiMessageUtilTest, GetMessageLength) {
   // Check basic functionarity
-  EXPECT_EQ(arraysize(kNoteOn), GetMessageLength(kNoteOn[0]));
-  EXPECT_EQ(arraysize(kChannelPressure), GetMessageLength(kChannelPressure[0]));
-  EXPECT_EQ(arraysize(kTimingClock), GetMessageLength(kTimingClock[0]));
-  EXPECT_EQ(arraysize(kSystemCommonMessageTuneRequest),
+  EXPECT_EQ(base::size(kNoteOn), GetMessageLength(kNoteOn[0]));
+  EXPECT_EQ(base::size(kChannelPressure),
+            GetMessageLength(kChannelPressure[0]));
+  EXPECT_EQ(base::size(kTimingClock), GetMessageLength(kTimingClock[0]));
+  EXPECT_EQ(base::size(kSystemCommonMessageTuneRequest),
             GetMessageLength(kSystemCommonMessageTuneRequest[0]));
 
   // SysEx message should be mapped to 0-length
diff --git a/media/midi/midi_manager_alsa.cc b/media/midi/midi_manager_alsa.cc
index 85dc314..b13df63d 100644
--- a/media/midi/midi_manager_alsa.cc
+++ b/media/midi/midi_manager_alsa.cc
@@ -16,10 +16,10 @@
 #include "base/bind.h"
 #include "base/json/json_string_value_serializer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/posix/safe_strerror.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
@@ -847,7 +847,7 @@
   pfd[1].fd = device::udev_monitor_get_fd(udev_monitor_.get());
   pfd[1].events = POLLIN;
 
-  int err = HANDLE_EINTR(poll(pfd, arraysize(pfd), -1));
+  int err = HANDLE_EINTR(poll(pfd, base::size(pfd), -1));
   if (err < 0) {
     VLOG(1) << "poll fails: " << base::safe_strerror(errno);
     loop_again = false;
diff --git a/media/midi/midi_manager_usb_unittest.cc b/media/midi/midi_manager_usb_unittest.cc
index f7fe4a6..7161757 100644
--- a/media/midi/midi_manager_usb_unittest.cc
+++ b/media/midi/midi_manager_usb_unittest.cc
@@ -10,9 +10,9 @@
 #include <string>
 #include <utility>
 
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
 #include "media/midi/midi_service.h"
@@ -553,7 +553,7 @@
   RunCallbackUntilCallbackInvoked(true, &devices);
   EXPECT_EQ(Result::OK, GetInitializationResult());
 
-  manager()->ReceiveUsbMidiData(device_raw, 2, data, arraysize(data),
+  manager()->ReceiveUsbMidiData(device_raw, 2, data, base::size(data),
                                 base::TimeTicks());
   Finalize();
 
diff --git a/media/midi/midi_manager_win.cc b/media/midi/midi_manager_win.cc
index e21a853b..902399f0 100644
--- a/media/midi/midi_manager_win.cc
+++ b/media/midi/midi_manager_win.cc
@@ -18,6 +18,7 @@
 #include "base/callback.h"
 #include "base/logging.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -643,7 +644,7 @@
         static_cast<uint8_t>((param1 >> 16) & 0xff);
     const uint8_t kData[] = {status_byte, first_data_byte, second_data_byte};
     const size_t len = GetMessageLength(status_byte);
-    DCHECK_LE(len, arraysize(kData));
+    DCHECK_LE(len, base::size(kData));
     std::vector<uint8_t> data;
     data.assign(kData, kData + len);
     manager->PostReplyTask(base::BindOnce(
diff --git a/media/midi/usb_midi_descriptor_parser_unittest.cc b/media/midi/usb_midi_descriptor_parser_unittest.cc
index ac66be1..1f24a87b 100644
--- a/media/midi/usb_midi_descriptor_parser_unittest.cc
+++ b/media/midi/usb_midi_descriptor_parser_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace midi {
@@ -24,7 +24,7 @@
   UsbMidiDescriptorParser parser;
   std::vector<UsbMidiJack> jacks;
   uint8_t data[] = {0x04};
-  EXPECT_FALSE(parser.Parse(nullptr, data, arraysize(data), &jacks));
+  EXPECT_FALSE(parser.Parse(nullptr, data, base::size(data), &jacks));
   EXPECT_TRUE(jacks.empty());
 }
 
@@ -37,7 +37,7 @@
       0x09, 0x04, 0x01, 0x00, 0x02, 0x01, 0x03, 0x00, 0x00, 0x07, 0x24,
       0x01, 0x00, 0x01, 0x07, 0x00, 0x05, 0x25, 0x01, 0x01, 0x01,
   };
-  EXPECT_FALSE(parser.Parse(nullptr, data, arraysize(data), &jacks));
+  EXPECT_FALSE(parser.Parse(nullptr, data, base::size(data), &jacks));
   EXPECT_TRUE(jacks.empty());
 }
 
@@ -51,7 +51,7 @@
       0x09, 0x04, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x00, 0x07, 0x24,
       0x01, 0x00, 0x01, 0x07, 0x00, 0x05, 0x25, 0x01, 0x01, 0x01,
   };
-  EXPECT_TRUE(parser.Parse(nullptr, data, arraysize(data), &jacks));
+  EXPECT_TRUE(parser.Parse(nullptr, data, base::size(data), &jacks));
   EXPECT_TRUE(jacks.empty());
 }
 
@@ -73,7 +73,7 @@
       0x03, 0x09, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x05, 0x25,
       0x01, 0x01, 0x07,
   };
-  EXPECT_TRUE(parser.Parse(nullptr, data, arraysize(data), &jacks));
+  EXPECT_TRUE(parser.Parse(nullptr, data, base::size(data), &jacks));
   ASSERT_EQ(3u, jacks.size());
 
   EXPECT_EQ(2u, jacks[0].jack_id);
@@ -108,7 +108,7 @@
       0x12, 0x01, 0x10, 0x01, 0x00, 0x00, 0x00, 0x08, 0x01,
       0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x00, 0x0a,
   };
-  EXPECT_TRUE(parser.ParseDeviceInfo(data, arraysize(data), &info));
+  EXPECT_TRUE(parser.ParseDeviceInfo(data, base::size(data), &info));
 
   EXPECT_EQ(0x2301, info.vendor_id);
   EXPECT_EQ(0x6745, info.product_id);
diff --git a/media/midi/usb_midi_input_stream_unittest.cc b/media/midi/usb_midi_input_stream_unittest.cc
index a88489ba..ff0f3b8 100644
--- a/media/midi/usb_midi_input_stream_unittest.cc
+++ b/media/midi/usb_midi_input_stream_unittest.cc
@@ -11,7 +11,7 @@
 #include <string>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/time/time.h"
 #include "media/midi/usb_midi_device.h"
@@ -96,7 +96,7 @@
       0x40, 0xff, 0xff, 0xff, 0x41, 0xff, 0xff, 0xff,
   };
 
-  stream_->OnReceivedData(&device1_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device1_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("", delegate_.received_data());
 }
 
@@ -105,7 +105,7 @@
       0x45, 0xf8, 0x00, 0x00, 0x42, 0xf3, 0x22, 0x00, 0x43, 0xf2, 0x33, 0x44,
   };
 
-  stream_->OnReceivedData(&device1_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device1_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("0xf8 \n"
             "0xf3 0x22 \n"
             "0xf2 0x33 0x44 \n", delegate_.received_data());
@@ -117,7 +117,7 @@
       0x46, 0xf0, 0xf7, 0x00, 0x47, 0xf0, 0x33, 0xf7,
   };
 
-  stream_->OnReceivedData(&device1_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device1_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("0xf0 0x11 0x22 \n"
             "0xf7 \n"
             "0xf0 0xf7 \n"
@@ -131,7 +131,7 @@
       0x4d, 0xd0, 0xaa, 0x00, 0x4e, 0xe0, 0xbb, 0xcc,
   };
 
-  stream_->OnReceivedData(&device1_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device1_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("0x80 0x11 0x22 \n"
             "0x90 0x33 0x44 \n"
             "0xa0 0x55 0x66 \n"
@@ -146,7 +146,7 @@
       0x4f, 0xf8, 0x00, 0x00,
   };
 
-  stream_->OnReceivedData(&device1_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device1_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("0xf8 \n", delegate_.received_data());
 }
 
@@ -155,14 +155,14 @@
       0x4f, 0xf8, 0x00, 0x00, 0x5f, 0xfa, 0x00, 0x00, 0x6f, 0xfb, 0x00, 0x00,
   };
 
-  stream_->OnReceivedData(&device1_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device1_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("0xf8 \n0xfa \n", delegate_.received_data());
 }
 
 TEST_F(UsbMidiInputStreamTest, DispatchForDevice2) {
   uint8_t data[] = {0x4f, 0xf8, 0x00, 0x00};
 
-  stream_->OnReceivedData(&device2_, 7, data, arraysize(data), TimeTicks());
+  stream_->OnReceivedData(&device2_, 7, data, base::size(data), TimeTicks());
   EXPECT_EQ("0xf8 \n", delegate_.received_data());
 }
 
diff --git a/media/midi/usb_midi_output_stream.cc b/media/midi/usb_midi_output_stream.cc
index 6ec1194e..44def01c 100644
--- a/media/midi/usb_midi_output_stream.cc
+++ b/media/midi/usb_midi_output_stream.cc
@@ -5,7 +5,7 @@
 #include "media/midi/usb_midi_output_stream.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/midi/message_util.h"
 #include "media/midi/usb_midi_device.h"
 
@@ -83,9 +83,8 @@
       // We can't find the end-of-message mark in the three bytes.
       *current = index;
       data_to_send->push_back((jack_.cable_number << 4) | 0x4);
-      data_to_send->insert(data_to_send->end(),
-                           message,
-                           message + arraysize(message));
+      data_to_send->insert(data_to_send->end(), message,
+                           message + base::size(message));
       is_sending_sysex_ = true;
       return true;
     }
@@ -102,9 +101,8 @@
       uint8_t code_index = static_cast<uint8_t>(message_size) + 0x4;
       DCHECK(code_index == 0x5 || code_index == 0x6 || code_index == 0x7);
       data_to_send->push_back((jack_.cable_number << 4) | code_index);
-      data_to_send->insert(data_to_send->end(),
-                           message,
-                           message + arraysize(message));
+      data_to_send->insert(data_to_send->end(), message,
+                           message + base::size(message));
       *current = index + 1;
       is_sending_sysex_ = false;
       return true;
diff --git a/media/mojo/clients/mojo_cdm_unittest.cc b/media/mojo/clients/mojo_cdm_unittest.cc
index 36e7a20..72348ac 100644
--- a/media/mojo/clients/mojo_cdm_unittest.cc
+++ b/media/mojo/clients/mojo_cdm_unittest.cc
@@ -7,9 +7,9 @@
 #include <memory>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/test_message_loop.h"
 #include "base/time/time.h"
 #include "media/base/cdm_config.h"
@@ -163,7 +163,7 @@
     // order to verify that the data is passed properly.
     const CdmSessionType session_type = CdmSessionType::kTemporary;
     const EmeInitDataType data_type = EmeInitDataType::WEBM;
-    const std::vector<uint8_t> key_id(kKeyId, kKeyId + arraysize(kKeyId));
+    const std::vector<uint8_t> key_id(kKeyId, kKeyId + base::size(kKeyId));
     std::string created_session_id;
 
     if (expected_result == CONNECTION_ERROR_BEFORE) {
diff --git a/media/mojo/common/mojo_decoder_buffer_converter_unittest.cc b/media/mojo/common/mojo_decoder_buffer_converter_unittest.cc
index 2a798e8..afd0a87a 100644
--- a/media/mojo/common/mojo_decoder_buffer_converter_unittest.cc
+++ b/media/mojo/common/mojo_decoder_buffer_converter_unittest.cc
@@ -8,9 +8,9 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/mock_callback.h"
 #include "media/base/decoder_buffer.h"
 #include "media/base/decrypt_config.h"
@@ -62,8 +62,8 @@
   base::MessageLoop message_loop;
   const uint8_t kData[] = "hello, world";
   const uint8_t kSideData[] = "sideshow bob";
-  const size_t kDataSize = arraysize(kData);
-  const size_t kSideDataSize = arraysize(kSideData);
+  const size_t kDataSize = base::size(kData);
+  const size_t kSideDataSize = base::size(kSideData);
 
   scoped_refptr<DecoderBuffer> buffer(DecoderBuffer::CopyFrom(
       reinterpret_cast<const uint8_t*>(&kData), kDataSize,
@@ -99,7 +99,7 @@
 TEST(MojoDecoderBufferConverterTest, ConvertDecoderBuffer_KeyFrame) {
   base::MessageLoop message_loop;
   const uint8_t kData[] = "hello, world";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
 
   scoped_refptr<DecoderBuffer> buffer(DecoderBuffer::CopyFrom(
       reinterpret_cast<const uint8_t*>(&kData), kDataSize));
@@ -113,7 +113,7 @@
 TEST(MojoDecoderBufferConverterTest, ConvertDecoderBuffer_EncryptedBuffer) {
   base::MessageLoop message_loop;
   const uint8_t kData[] = "hello, world";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   const char kKeyId[] = "00112233445566778899aabbccddeeff";
   const char kIv[] = "0123456789abcdef";
 
@@ -152,7 +152,7 @@
 TEST(MojoDecoderBufferConverterTest, Chunked) {
   base::MessageLoop message_loop;
   const uint8_t kData[] = "Lorem ipsum dolor sit amet, consectetur cras amet";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> buffer =
       DecoderBuffer::CopyFrom(kData, kDataSize);
 
@@ -165,7 +165,7 @@
 TEST(MojoDecoderBufferConverterTest, WriterSidePipeError) {
   base::MessageLoop message_loop;
   const uint8_t kData[] = "Lorem ipsum dolor sit amet, consectetur cras amet";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> media_buffer =
       DecoderBuffer::CopyFrom(kData, kDataSize);
 
@@ -200,7 +200,7 @@
 
   // Three buffers: normal, EOS, normal.
   const uint8_t kData[] = "Hello, world";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> media_buffer1 =
       DecoderBuffer::CopyFrom(kData, kDataSize);
   scoped_refptr<DecoderBuffer> media_buffer2(DecoderBuffer::CreateEOSBuffer());
@@ -254,7 +254,7 @@
   base::RunLoop run_loop;
 
   const uint8_t kData[] = "Lorem ipsum dolor sit amet, consectetur cras amet";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> media_buffer =
       DecoderBuffer::CopyFrom(kData, kDataSize);
 
@@ -275,7 +275,7 @@
   base::RunLoop run_loop;
 
   const uint8_t kData[] = "Lorem ipsum dolor sit amet, consectetur cras amet";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> media_buffer =
       DecoderBuffer::CopyFrom(kData, kDataSize);
 
@@ -303,7 +303,7 @@
   base::RunLoop run_loop;
 
   const uint8_t kData[] = "Lorem ipsum dolor sit amet, consectetur cras amet";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> media_buffer =
       DecoderBuffer::CopyFrom(kData, kDataSize);
 
@@ -332,7 +332,7 @@
   base::RunLoop run_loop;
 
   const uint8_t kData[] = "Lorem ipsum dolor sit amet, consectetur cras amet";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   scoped_refptr<DecoderBuffer> media_buffer =
       DecoderBuffer::CopyFrom(kData, kDataSize);
 
@@ -368,7 +368,7 @@
 
   // Three buffers: normal, EOS, normal.
   const uint8_t kData[] = "Hello, world";
-  const size_t kDataSize = arraysize(kData);
+  const size_t kDataSize = base::size(kData);
   auto media_buffer1 = DecoderBuffer::CopyFrom(kData, kDataSize);
   auto media_buffer2 = DecoderBuffer::CreateEOSBuffer();
   auto media_buffer3 = DecoderBuffer::CopyFrom(kData, kDataSize);
diff --git a/media/mojo/test/mojo_video_decoder_integration_test.cc b/media/mojo/test/mojo_video_decoder_integration_test.cc
index 851d68a..eb129db 100644
--- a/media/mojo/test/mojo_video_decoder_integration_test.cc
+++ b/media/mojo/test/mojo_video_decoder_integration_test.cc
@@ -12,9 +12,9 @@
 #include "base/callback_forward.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/scoped_refptr.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/test/mock_callback.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/time/time.h"
@@ -281,8 +281,9 @@
     const uint8_t kFakeIv[DecryptConfig::kDecryptionKeySize] = {0};
     buffer->set_decrypt_config(DecryptConfig::CreateCencConfig(
         std::string(reinterpret_cast<const char*>(kFakeKeyId),
-                    arraysize(kFakeKeyId)),
-        std::string(reinterpret_cast<const char*>(kFakeIv), arraysize(kFakeIv)),
+                    base::size(kFakeKeyId)),
+        std::string(reinterpret_cast<const char*>(kFakeIv),
+                    base::size(kFakeIv)),
         {}));
 
     return buffer;
diff --git a/media/muxers/webm_muxer_fuzzertest.cc b/media/muxers/webm_muxer_fuzzertest.cc
index d92e7862..eff598f 100644
--- a/media/muxers/webm_muxer_fuzzertest.cc
+++ b/media/muxers/webm_muxer_fuzzertest.cc
@@ -12,6 +12,7 @@
 #include "base/logging.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "media/base/audio_parameters.h"
 #include "media/base/video_frame.h"
@@ -54,9 +55,9 @@
 
   for (const auto& input_type : kVideoAudioInputTypes) {
     const auto video_codec = static_cast<VideoCodec>(
-        kSupportedVideoCodecs[rng() % arraysize(kSupportedVideoCodecs)]);
+        kSupportedVideoCodecs[rng() % base::size(kSupportedVideoCodecs)]);
     const auto audio_codec = static_cast<AudioCodec>(
-        kSupportedAudioCodecs[rng() % arraysize(kSupportedAudioCodecs)]);
+        kSupportedAudioCodecs[rng() % base::size(kSupportedAudioCodecs)]);
     WebmMuxer muxer(video_codec, audio_codec, input_type.has_video,
                     input_type.has_audio, base::Bind(&OnWriteCallback));
     base::RunLoop run_loop;
@@ -83,7 +84,7 @@
         const ChannelLayout layout = rng() % 2 ? media::CHANNEL_LAYOUT_STEREO
                                                : media::CHANNEL_LAYOUT_MONO;
         const int sample_rate =
-            kSampleRatesInKHz[rng() % arraysize(kSampleRatesInKHz)];
+            kSampleRatesInKHz[rng() % base::size(kSampleRatesInKHz)];
 
         const AudioParameters params(
             media::AudioParameters::AUDIO_PCM_LOW_LATENCY, layout, sample_rate,
diff --git a/media/video/h264_parser.cc b/media/video/h264_parser.cc
index f786ee3..75d7196 100644
--- a/media/video/h264_parser.cc
+++ b/media/video/h264_parser.cc
@@ -8,8 +8,8 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 #include "media/base/subsample_entry.h"
 #include "ui/gfx/geometry/rect.h"
 #include "ui/gfx/geometry/size.h"
@@ -295,7 +295,7 @@
                                      80, 18, 15, 64, 160, 4,  3,  2};
 static const int kTableSarHeight[] = {0,  1,  11, 11, 11, 33, 11, 11, 11,
                                       33, 11, 11, 33, 99, 3,  2,  1};
-static_assert(arraysize(kTableSarWidth) == arraysize(kTableSarHeight),
+static_assert(base::size(kTableSarWidth) == base::size(kTableSarHeight),
               "sar tables must have the same size");
 
 H264Parser::H264Parser() {
@@ -809,7 +809,7 @@
     READ_BOOL_OR_RETURN(&seq_scaling_list_present_flag);
 
     if (seq_scaling_list_present_flag) {
-      res = ParseScalingList(arraysize(sps->scaling_list4x4[i]),
+      res = ParseScalingList(base::size(sps->scaling_list4x4[i]),
                              sps->scaling_list4x4[i], &use_default);
       if (res != kOk)
         return res;
@@ -828,7 +828,7 @@
     READ_BOOL_OR_RETURN(&seq_scaling_list_present_flag);
 
     if (seq_scaling_list_present_flag) {
-      res = ParseScalingList(arraysize(sps->scaling_list8x8[i]),
+      res = ParseScalingList(base::size(sps->scaling_list8x8[i]),
                              sps->scaling_list8x8[i], &use_default);
       if (res != kOk)
         return res;
@@ -856,7 +856,7 @@
     READ_BOOL_OR_RETURN(&pic_scaling_list_present_flag);
 
     if (pic_scaling_list_present_flag) {
-      res = ParseScalingList(arraysize(pps->scaling_list4x4[i]),
+      res = ParseScalingList(base::size(pps->scaling_list4x4[i]),
                              pps->scaling_list4x4[i], &use_default);
       if (res != kOk)
         return res;
@@ -882,7 +882,7 @@
       READ_BOOL_OR_RETURN(&pic_scaling_list_present_flag);
 
       if (pic_scaling_list_present_flag) {
-        res = ParseScalingList(arraysize(pps->scaling_list8x8[i]),
+        res = ParseScalingList(base::size(pps->scaling_list8x8[i]),
                                pps->scaling_list8x8[i], &use_default);
         if (res != kOk)
           return res;
@@ -939,7 +939,7 @@
       READ_BITS_OR_RETURN(16, &sps->sar_width);
       READ_BITS_OR_RETURN(16, &sps->sar_height);
     } else {
-      const int max_aspect_ratio_idc = arraysize(kTableSarWidth) - 1;
+      const int max_aspect_ratio_idc = base::size(kTableSarWidth) - 1;
       IN_RANGE_OR_RETURN(aspect_ratio_idc, 0, max_aspect_ratio_idc);
       sps->sar_width = kTableSarWidth[aspect_ratio_idc];
       sps->sar_height = kTableSarHeight[aspect_ratio_idc];
@@ -1373,7 +1373,7 @@
     H264DecRefPicMarking* marking;
     if (shdr->adaptive_ref_pic_marking_mode_flag) {
       size_t i;
-      for (i = 0; i < arraysize(shdr->ref_pic_marking); ++i) {
+      for (i = 0; i < base::size(shdr->ref_pic_marking); ++i) {
         marking = &shdr->ref_pic_marking[i];
 
         READ_UE_OR_RETURN(&marking->memory_mgmnt_control_operation);
@@ -1398,7 +1398,7 @@
           return kInvalidStream;
       }
 
-      if (i == arraysize(shdr->ref_pic_marking)) {
+      if (i == base::size(shdr->ref_pic_marking)) {
         DVLOG(1) << "Ran out of dec ref pic marking fields";
         return kUnsupportedStream;
       }
diff --git a/media/video/h264_poc.cc b/media/video/h264_poc.cc
index 8f6c619..59c0ae7b 100644
--- a/media/video/h264_poc.cc
+++ b/media/video/h264_poc.cc
@@ -7,7 +7,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "media/video/h264_parser.h"
 #include "media/video/h264_poc.h"
 
@@ -25,7 +25,7 @@
     return false;
   }
 
-  for (size_t i = 0; i < arraysize(slice_hdr.ref_pic_marking); i++) {
+  for (size_t i = 0; i < base::size(slice_hdr.ref_pic_marking); i++) {
     int32_t op = slice_hdr.ref_pic_marking[i].memory_mgmnt_control_operation;
     if (op == 5)
       return true;
diff --git a/ppapi/proxy/tcp_socket_resource_base.cc b/ppapi/proxy/tcp_socket_resource_base.cc
index 356a43e..eb67d1dd 100644
--- a/ppapi/proxy/tcp_socket_resource_base.cc
+++ b/ppapi/proxy/tcp_socket_resource_base.cc
@@ -8,7 +8,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ppapi/c/pp_bool.h"
 #include "ppapi/c/pp_errors.h"
 #include "ppapi/proxy/error_conversion.h"
@@ -36,10 +36,10 @@
       version_(version) {
   local_addr_.size = 0;
   memset(local_addr_.data, 0,
-         arraysize(local_addr_.data) * sizeof(*local_addr_.data));
+         base::size(local_addr_.data) * sizeof(*local_addr_.data));
   remote_addr_.size = 0;
   memset(remote_addr_.data, 0,
-         arraysize(remote_addr_.data) * sizeof(*remote_addr_.data));
+         base::size(remote_addr_.data) * sizeof(*remote_addr_.data));
 }
 
 TCPSocketResourceBase::TCPSocketResourceBase(
diff --git a/ppapi/shared_impl/flash_clipboard_format_registry.cc b/ppapi/shared_impl/flash_clipboard_format_registry.cc
index 16da30cc..6f01744 100644
--- a/ppapi/shared_impl/flash_clipboard_format_registry.cc
+++ b/ppapi/shared_impl/flash_clipboard_format_registry.cc
@@ -8,8 +8,8 @@
 
 #include <cctype>
 
-#include "base/macros.h"
 #include "base/numerics/safe_conversions.h"
+#include "base/stl_util.h"
 
 namespace ppapi {
 
@@ -27,7 +27,7 @@
 
 // The first custom format ID will be the ID after that max value in
 // PP_Flash_Clipboard_Format.
-const size_t kFirstCustomFormat = arraysize(kPredefinedFormats);
+const size_t kFirstCustomFormat = base::size(kPredefinedFormats);
 
 // Checks the validity of the given format name.
 bool IsValidFormatName(const std::string& format_name) {
diff --git a/remoting/base/breakpad_win.cc b/remoting/base/breakpad_win.cc
index c52d39d3..e68f332 100644
--- a/remoting/base/breakpad_win.cc
+++ b/remoting/base/breakpad_win.cc
@@ -19,7 +19,7 @@
 #include "base/file_version_info.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/current_module.h"
 #include "base/win/wrapped_window_proc.h"
@@ -164,8 +164,8 @@
       kBreakpadPlatformEntry, kBreakpadPlatformWin32);
   static google_breakpad::CustomInfoEntry entries[] = {
       ver_entry, prod_entry, plat_entry  };
-  static google_breakpad::CustomClientInfo custom_info = {
-      entries, arraysize(entries) };
+  static google_breakpad::CustomClientInfo custom_info = {entries,
+                                                          base::size(entries)};
   return &custom_info;
 }
 
diff --git a/remoting/base/capabilities_unittest.cc b/remoting/base/capabilities_unittest.cc
index e88a580..f7c3c78 100644
--- a/remoting/base/capabilities_unittest.cc
+++ b/remoting/base/capabilities_unittest.cc
@@ -7,7 +7,7 @@
 #include <algorithm>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
@@ -65,7 +65,7 @@
 
   // Verify that HasCapability(|capabilities|, |key|) returns |result|.
   // |result|.
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     std::vector<base::StringPiece> caps =
         base::SplitStringPiece(data[i].capabilities, " ", base::KEEP_WHITESPACE,
                                base::SPLIT_WANT_NONEMPTY);
@@ -97,7 +97,7 @@
 
   // Verify that intersection of |right| with all permutations of |left| yields
   // |result|.
-  for (size_t i = 0; i < arraysize(data); ++i) {
+  for (size_t i = 0; i < base::size(data); ++i) {
     std::vector<base::StringPiece> caps = base::SplitStringPiece(
         data[i].left, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
     do {
diff --git a/remoting/base/rate_counter_unittest.cc b/remoting/base/rate_counter_unittest.cc
index 8d4188e..74efd209 100644
--- a/remoting/base/rate_counter_unittest.cc
+++ b/remoting/base/rate_counter_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "remoting/base/rate_counter.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -22,7 +22,7 @@
   base::SimpleTestTickClock tick_clock;
   rate_counter.set_tick_clock_for_tests(&tick_clock);
 
-  for (size_t i = 0; i < arraysize(kTestValues); ++i) {
+  for (size_t i = 0; i < base::size(kTestValues); ++i) {
     tick_clock.Advance(base::TimeDelta::FromSeconds(1));
     rate_counter.Record(kTestValues[i]);
     EXPECT_EQ(static_cast<double>(kTestValues[i]), rate_counter.Rate());
@@ -38,7 +38,7 @@
   rate_counter.set_tick_clock_for_tests(&tick_clock);
 
   double expected = 0.0;
-  for (size_t i = 0; i < arraysize(kTestValues); ++i) {
+  for (size_t i = 0; i < base::size(kTestValues); ++i) {
     rate_counter.Record(kTestValues[i]);
     expected += kTestValues[i];
   }
@@ -56,7 +56,7 @@
   base::SimpleTestTickClock tick_clock;
   rate_counter.set_tick_clock_for_tests(&tick_clock);
 
-  for (size_t i = 0; i < arraysize(kTestValues); ++i) {
+  for (size_t i = 0; i < base::size(kTestValues); ++i) {
     tick_clock.Advance(base::TimeDelta::FromSeconds(1));
     rate_counter.Record(kTestValues[i]);
     double expected = kTestValues[i];
@@ -70,7 +70,7 @@
 // Sample over a window one second shorter than the number of samples.
 // Rate should be the average of all but the first sample.
 TEST(RateCounterTest, LongWindow) {
-  const size_t kWindowSeconds = arraysize(kTestValues) - 1;
+  const size_t kWindowSeconds = base::size(kTestValues) - 1;
 
   RateCounter rate_counter(base::TimeDelta::FromSeconds(kWindowSeconds));
   EXPECT_EQ(0, rate_counter.Rate());
@@ -79,7 +79,7 @@
   rate_counter.set_tick_clock_for_tests(&tick_clock);
 
   double expected = 0.0;
-  for (size_t i = 0; i < arraysize(kTestValues); ++i) {
+  for (size_t i = 0; i < base::size(kTestValues); ++i) {
     tick_clock.Advance(base::TimeDelta::FromSeconds(1));
     rate_counter.Record(kTestValues[i]);
     if (i != 0)
diff --git a/remoting/base/running_samples_unittest.cc b/remoting/base/running_samples_unittest.cc
index 2c2c7f5..a8922648 100644
--- a/remoting/base/running_samples_unittest.cc
+++ b/remoting/base/running_samples_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "remoting/base/running_samples.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -22,7 +22,7 @@
   EXPECT_EQ(0, samples.Average());
   EXPECT_EQ(0, samples.Max());
 
-  for (size_t i = 0; i < arraysize(kTestValues); ++i) {
+  for (size_t i = 0; i < base::size(kTestValues); ++i) {
     samples.Record(kTestValues[i]);
     testFn(i, samples);
   }
@@ -48,15 +48,15 @@
 
 // Average across all the elements if the window size exceeds the element count.
 TEST(RunningSamplesTest, AverageLongWindow) {
-  TestFramework(arraysize(kTestValues) + 1,
-      [](size_t i, RunningSamples& samples) {
-    double expected = 0.0;
-    for (size_t j = 0; j <= i; ++j)
-      expected += kTestValues[j];
-    expected /= i + 1;
+  TestFramework(base::size(kTestValues) + 1,
+                [](size_t i, RunningSamples& samples) {
+                  double expected = 0.0;
+                  for (size_t j = 0; j <= i; ++j)
+                    expected += kTestValues[j];
+                  expected /= i + 1;
 
-    EXPECT_EQ(expected, samples.Average());
-  });
+                  EXPECT_EQ(expected, samples.Average());
+                });
 }
 
 // Max of a single element, i.e. just return the most recent.
@@ -79,14 +79,14 @@
 
 // Max of all the elements if the window size exceeds the element count.
 TEST(RunningSamplesTest, MaxLongWindow) {
-  TestFramework(arraysize(kTestValues) + 1,
-      [](size_t i, RunningSamples& samples) {
-    int64_t expected = -1;
-    for (size_t j = 0; j <= i; ++j)
-      expected = expected > kTestValues[j] ? expected : kTestValues[j];
+  TestFramework(
+      base::size(kTestValues) + 1, [](size_t i, RunningSamples& samples) {
+        int64_t expected = -1;
+        for (size_t j = 0; j <= i; ++j)
+          expected = expected > kTestValues[j] ? expected : kTestValues[j];
 
-    EXPECT_EQ(expected, samples.Max());
-  });
+        EXPECT_EQ(expected, samples.Max());
+      });
 }
 
-}  // namespace remoting
\ No newline at end of file
+}  // namespace remoting
diff --git a/remoting/base/weighted_samples_unittest.cc b/remoting/base/weighted_samples_unittest.cc
index ef588a92..9d4cd708 100644
--- a/remoting/base/weighted_samples_unittest.cc
+++ b/remoting/base/weighted_samples_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "remoting/base/weighted_samples.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace remoting {
@@ -18,7 +18,7 @@
     2.6312881651642916,
   };
   WeightedSamples samples(kWeightFactor);
-  for (size_t i = 0; i < arraysize(kExpected); i++) {
+  for (size_t i = 0; i < base::size(kExpected); i++) {
     samples.Record(i + 1);
     EXPECT_DOUBLE_EQ(kExpected[i], samples.WeightedAverage());
   }
diff --git a/remoting/client/audio/audio_player_android.cc b/remoting/client/audio/audio_player_android.cc
index 3be4a37a..3dca60e 100644
--- a/remoting/client/audio/audio_player_android.cc
+++ b/remoting/client/audio/audio_player_android.cc
@@ -5,6 +5,7 @@
 #include "remoting/client/audio/audio_player_android.h"
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 
 namespace remoting {
@@ -80,7 +81,7 @@
   const SLboolean reqs[] = {SL_BOOLEAN_TRUE};
 
   if ((*engine_)->CreateAudioPlayer(engine_, &player_object_, &source, &sink,
-                                    arraysize(ids), ids,
+                                    base::size(ids), ids,
                                     reqs) != SL_RESULT_SUCCESS ||
       (*player_object_)->Realize(player_object_, SL_BOOLEAN_FALSE) !=
           SL_RESULT_SUCCESS ||
diff --git a/remoting/client/client_telemetry_logger.cc b/remoting/client/client_telemetry_logger.cc
index c015d89..2b9ea1ba 100644
--- a/remoting/client/client_telemetry_logger.cc
+++ b/remoting/client/client_telemetry_logger.cc
@@ -7,6 +7,7 @@
 #include "base/format_macros.h"
 #include "base/logging.h"
 #include "base/rand_util.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "remoting/base/telemetry_log_writer.h"
 
@@ -241,7 +242,7 @@
 void ClientTelemetryLogger::GenerateSessionId() {
   session_id_.resize(kSessionIdLength);
   for (int i = 0; i < kSessionIdLength; i++) {
-    const int alphabet_size = arraysize(kSessionIdAlphabet) - 1;
+    const int alphabet_size = base::size(kSessionIdAlphabet) - 1;
     session_id_[i] = kSessionIdAlphabet[base::RandGenerator(alphabet_size)];
   }
   session_id_generation_time_ = base::TimeTicks::Now();
diff --git a/remoting/codec/codec_test.cc b/remoting/codec/codec_test.cc
index f0c98140..b7118b0 100644
--- a/remoting/codec/codec_test.cc
+++ b/remoting/codec/codec_test.cc
@@ -13,7 +13,7 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "remoting/base/util.h"
 #include "remoting/codec/video_decoder.h"
 #include "remoting/codec/video_encoder.h"
@@ -225,8 +225,8 @@
 
   VideoEncoderTester tester;
 
-  for (size_t xi = 0; xi < arraysize(kSizes); ++xi) {
-    for (size_t yi = 0; yi < arraysize(kSizes); ++yi) {
+  for (size_t xi = 0; xi < base::size(kSizes); ++xi) {
+    for (size_t yi = 0; yi < base::size(kSizes); ++yi) {
       DesktopSize size(kSizes[xi], kSizes[yi]);
       std::unique_ptr<DesktopFrame> frame = PrepareFrame(size);
       for (const DesktopRegion& region : MakeTestRegionLists(size)) {
diff --git a/remoting/host/audio_silence_detector_unittest.cc b/remoting/host/audio_silence_detector_unittest.cc
index f1173f1..8086cc5 100644
--- a/remoting/host/audio_silence_detector_unittest.cc
+++ b/remoting/host/audio_silence_detector_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace remoting {
@@ -48,24 +48,24 @@
   const int16_t kSamples[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
   AudioSilenceDetector target(0);
-  TestSilenceDetector(&target, kSamples, arraysize(kSamples), true);
+  TestSilenceDetector(&target, kSamples, base::size(kSamples), true);
 }
 
 TEST(AudioSilenceDetectorTest, Sound) {
   const int16_t kSamples[] = {65, 73, 83, 89, 92, -1, 5, 9, 123, 0};
 
   AudioSilenceDetector target(0);
-  TestSilenceDetector(&target, kSamples, arraysize(kSamples), false);
+  TestSilenceDetector(&target, kSamples, base::size(kSamples), false);
 }
 
 TEST(AudioSilenceDetectorTest, Threshold) {
   const int16_t kSamples[] = {0, 0, 0, 0, 1, 0, 0, -1, 0, 0};
 
   AudioSilenceDetector target1(0);
-  TestSilenceDetector(&target1, kSamples, arraysize(kSamples), false);
+  TestSilenceDetector(&target1, kSamples, base::size(kSamples), false);
 
   AudioSilenceDetector target2(1);
-  TestSilenceDetector(&target2, kSamples, arraysize(kSamples), true);
+  TestSilenceDetector(&target2, kSamples, base::size(kSamples), true);
 }
 
 }  // namespace remoting
diff --git a/remoting/host/audio_volume_filter_unittest.cc b/remoting/host/audio_volume_filter_unittest.cc
index 94cc0a7..684e3686 100644
--- a/remoting/host/audio_volume_filter_unittest.cc
+++ b/remoting/host/audio_volume_filter_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "remoting/host/audio_volume_filter.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace remoting {
@@ -37,7 +37,7 @@
   // After applying the audio volume, the |samples| should still pass the
   // AudioSilenceDetector, AudioVolumeFilter::Apply() returns true under this
   // condition. Ditto.
-  ASSERT_TRUE(filter.Apply(samples, arraysize(samples) / 2));
+  ASSERT_TRUE(filter.Apply(samples, base::size(samples) / 2));
 }
 
 TEST(AudioVolumeFilterTest, ThreeChannels) {
@@ -46,7 +46,7 @@
   FakeAudioVolumeFilter filter(0);
   filter.set_audio_level(0.5f);
   filter.Initialize(6, 3);
-  ASSERT_TRUE(filter.Apply(samples, arraysize(samples) / 3));
+  ASSERT_TRUE(filter.Apply(samples, base::size(samples) / 3));
 }
 
 TEST(AudioVolumeFilterTest, SilentSamples) {
@@ -55,7 +55,7 @@
   FakeAudioVolumeFilter filter(0);
   filter.set_audio_level(0.5f);
   filter.Initialize(9, 2);
-  ASSERT_FALSE(filter.Apply(samples, arraysize(samples) / 2));
+  ASSERT_FALSE(filter.Apply(samples, base::size(samples) / 2));
 }
 
 TEST(AudioVolumeFilterTest, AudioLevel0) {
@@ -64,7 +64,7 @@
   FakeAudioVolumeFilter filter(0);
   filter.set_audio_level(0);
   filter.Initialize(9, 2);
-  ASSERT_FALSE(filter.Apply(samples, arraysize(samples) / 2));
+  ASSERT_FALSE(filter.Apply(samples, base::size(samples) / 2));
 }
 
 TEST(AudioVolumeFilterTest, SilentAfterApplying) {
@@ -73,7 +73,7 @@
   FakeAudioVolumeFilter filter(0);
   filter.set_audio_level(0.9f);
   filter.Initialize(9, 2);
-  ASSERT_TRUE(filter.Apply(samples, arraysize(samples) / 2));
+  ASSERT_TRUE(filter.Apply(samples, base::size(samples) / 2));
 }
 
 }  // namespace remoting
diff --git a/remoting/host/daemon_process_win.cc b/remoting/host/daemon_process_win.cc
index 67491f7..bacd0c1a 100644
--- a/remoting/host/daemon_process_win.cc
+++ b/remoting/host/daemon_process_win.cc
@@ -14,10 +14,10 @@
 #include "base/bind_helpers.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/process/process.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
 #include "base/win/registry.h"
@@ -220,7 +220,7 @@
   std::unique_ptr<base::CommandLine> target(new base::CommandLine(host_binary));
   target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeHost);
   target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
-                           kCopiedSwitchNames, arraysize(kCopiedSwitchNames));
+                           kCopiedSwitchNames, base::size(kCopiedSwitchNames));
 
   std::unique_ptr<UnprivilegedProcessDelegate> delegate(
       new UnprivilegedProcessDelegate(io_task_runner(), std::move(target)));
diff --git a/remoting/host/desktop_resizer_mac.cc b/remoting/host/desktop_resizer_mac.cc
index 82432ce..949d68b 100644
--- a/remoting/host/desktop_resizer_mac.cc
+++ b/remoting/host/desktop_resizer_mac.cc
@@ -10,8 +10,8 @@
 #include "base/mac/foundation_util.h"
 #include "base/mac/mac_util.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "remoting/base/logging.h"
 
 namespace {
@@ -159,8 +159,8 @@
   // to allow the multi-monitor case to be detected.
   CGDirectDisplayID displays[2];
   uint32_t num_displays;
-  CGError err = CGGetActiveDisplayList(arraysize(displays),
-                                       displays, &num_displays);
+  CGError err =
+      CGGetActiveDisplayList(base::size(displays), displays, &num_displays);
   if (err != kCGErrorSuccess || num_displays != 1) {
     return false;
   }
diff --git a/remoting/host/desktop_session_win.cc b/remoting/host/desktop_session_win.cc
index 1103b03..2d30afb 100644
--- a/remoting/host/desktop_session_win.cc
+++ b/remoting/host/desktop_session_win.cc
@@ -16,9 +16,9 @@
 #include "base/command_line.h"
 #include "base/files/file_path.h"
 #include "base/guid.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_checker.h"
@@ -638,7 +638,7 @@
   target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop);
   // Copy the command line switches enabling verbose logging.
   target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
-                           kCopiedSwitchNames, arraysize(kCopiedSwitchNames));
+                           kCopiedSwitchNames, base::size(kCopiedSwitchNames));
 
   // Create a delegate capable of launching a process in a different session.
   std::unique_ptr<WtsSessionProcessDelegate> delegate(
diff --git a/remoting/host/disconnect_window_win.cc b/remoting/host/disconnect_window_win.cc
index 468ad70..effba161 100644
--- a/remoting/host/disconnect_window_win.cc
+++ b/remoting/host/disconnect_window_win.cc
@@ -11,8 +11,8 @@
 #include "base/compiler_specific.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/time/time.h"
@@ -136,7 +136,7 @@
   // GetWindowText truncates the text if it is longer than can fit into
   // the buffer.
   WCHAR buffer[256];
-  int result = GetWindowText(control, buffer, arraysize(buffer));
+  int result = GetWindowText(control, buffer, base::size(buffer));
   if (!result)
     return false;
 
diff --git a/remoting/host/host_attributes.cc b/remoting/host/host_attributes.cc
index f1d5f29..f72e250 100644
--- a/remoting/host/host_attributes.cc
+++ b/remoting/host/host_attributes.cc
@@ -10,7 +10,7 @@
 
 #include "base/atomicops.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 #include "build/build_config.h"
@@ -68,7 +68,7 @@
   return !IsOfficialBuild();
 }
 
-// By using arraysize() macro in base/macros.h, it's illegal to have empty
+// By using base::size() macro in base/macros.h, it's illegal to have empty
 // arrays.
 //
 // error: no matching function for call to 'ArraySizeHelper'
@@ -95,7 +95,7 @@
   // By using ranged for-loop, MSVC throws error C3316:
   // 'const remoting::StaticAttribute [0]':
   // an array of unknown size cannot be used in a range-based for statement.
-  for (size_t i = 0; i < arraysize(kAttributes); i++) {
+  for (size_t i = 0; i < base::size(kAttributes); i++) {
     const auto& attribute = kAttributes[i];
     DCHECK_EQ(std::string(attribute.name).find(kSeparator), std::string::npos);
     if (attribute.get_value_func()) {
diff --git a/remoting/host/input_injector_win.cc b/remoting/host/input_injector_win.cc
index 6ddf99b..219b85ba 100644
--- a/remoting/host/input_injector_win.cc
+++ b/remoting/host/input_injector_win.cc
@@ -13,11 +13,11 @@
 #include "base/bind.h"
 #include "base/compiler_specific.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/ref_counted.h"
 #include "base/optional.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/windows_version.h"
@@ -178,7 +178,7 @@
     if (client_capslock_state != host_capslock_state) {
       input[0].ki.wVk = VK_CAPITAL;
       input[1].ki.wVk = VK_CAPITAL;
-      SendInput(arraysize(input), input, sizeof(INPUT));
+      SendInput(base::size(input), input, sizeof(INPUT));
     }
   }
 
@@ -189,7 +189,7 @@
     if (client_numlock_state != host_numlock_state) {
       input[0].ki.wVk = VK_NUMLOCK;
       input[1].ki.wVk = VK_NUMLOCK;
-      SendInput(arraysize(input), input, sizeof(INPUT));
+      SendInput(base::size(input), input, sizeof(INPUT));
     }
   }
 }
diff --git a/remoting/host/linux/remoting_user_session.cc b/remoting/host/linux/remoting_user_session.cc
index 8d4d59f..9e34c5f 100644
--- a/remoting/host/linux/remoting_user_session.cc
+++ b/remoting/host/linux/remoting_user_session.cc
@@ -43,9 +43,9 @@
 #include "base/files/file_path.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/optional.h"
 #include "base/process/launch.h"
+#include "base/stl_util.h"
 #include "base/strings/string_piece.h"
 #include "base/strings/string_util.h"
 
@@ -274,7 +274,7 @@
 // executable. Should be called at program start.
 void DetermineExecutablePath() {
   ssize_t path_size =
-      readlink(kExeSymlink, gExecutablePath, arraysize(gExecutablePath));
+      readlink(kExeSymlink, gExecutablePath, base::size(gExecutablePath));
   PCHECK(path_size >= 0) << "Failed to determine executable location";
   CHECK(path_size < PATH_MAX) << "Executable path too long";
   gExecutablePath[path_size] = '\0';
@@ -539,7 +539,7 @@
       "Interrupted. The daemon is still running in the background.\n";
   // Use write since fputs isn't async-signal-handler safe.
   ignore_result(write(STDERR_FILENO, kInterruptedMessage,
-                      arraysize(kInterruptedMessage) - 1));
+                      base::size(kInterruptedMessage) - 1));
   raise(signal);
 }
 
@@ -549,8 +549,8 @@
       "Timeout waiting for session to start. It may have crashed, or may still "
       "be running in the background.\n";
   // Use write since fputs isn't async-signal-handler safe.
-  ignore_result(write(STDERR_FILENO, kTimeoutMessage,
-                      arraysize(kTimeoutMessage) - 1));
+  ignore_result(
+      write(STDERR_FILENO, kTimeoutMessage, base::size(kTimeoutMessage) - 1));
   // A slow system or directory replication delay may cause the host to take
   // longer than expected to start. Since it may still succeed, optimistically
   // return success to prevent the host from being automatically unregistered.
diff --git a/remoting/host/linux/unicode_to_keysym.cc b/remoting/host/linux/unicode_to_keysym.cc
index 2048910..7d6e9638 100644
--- a/remoting/host/linux/unicode_to_keysym.cc
+++ b/remoting/host/linux/unicode_to_keysym.cc
@@ -6,7 +6,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/gfx/x/x11.h"
 
 namespace remoting {
@@ -811,7 +811,7 @@
     keysyms.push_back(unicode);
   }
 
-  const CodePair* map_end = kKeySymUnicodeMap + arraysize(kKeySymUnicodeMap);
+  const CodePair* map_end = kKeySymUnicodeMap + base::size(kKeySymUnicodeMap);
   const CodePair* pair =
       std::lower_bound(kKeySymUnicodeMap, map_end, unicode, &CompareCodePair);
   while (pair != map_end && pair->unicode == unicode) {
diff --git a/remoting/host/linux/unicode_to_keysym_unittest.cc b/remoting/host/linux/unicode_to_keysym_unittest.cc
index 80a3cdb..86d8ed7a 100644
--- a/remoting/host/linux/unicode_to_keysym_unittest.cc
+++ b/remoting/host/linux/unicode_to_keysym_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace remoting {
@@ -36,7 +36,7 @@
     { 0x4444, { 0x01004444, 0 } },
   };
 
-  for (size_t i = 0; i < arraysize(kTests); ++i) {
+  for (size_t i = 0; i < base::size(kTests); ++i) {
     std::vector<uint32_t> keysyms = GetKeySymsForUnicode(kTests[i].code_point);
 
     std::vector<uint32_t> expected(
diff --git a/remoting/host/linux/x11_keyboard_impl.cc b/remoting/host/linux/x11_keyboard_impl.cc
index 9d53957..d19f744 100644
--- a/remoting/host/linux/x11_keyboard_impl.cc
+++ b/remoting/host/linux/x11_keyboard_impl.cc
@@ -4,6 +4,7 @@
 
 #include "remoting/host/linux/x11_keyboard_impl.h"
 
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "remoting/host/linux/unicode_to_keysym.h"
 #include "ui/gfx/x/x11.h"
@@ -29,7 +30,7 @@
   };
 
   // TODO(sergeyu): Is there a better way to find modifiers state?
-  for (size_t i = 0; i < arraysize(kModifiersToTry); ++i) {
+  for (size_t i = 0; i < base::size(kModifiersToTry); ++i) {
     unsigned long key_sym_with_mods;
     if (XkbLookupKeySym(display, found_keycode, kModifiersToTry[i], nullptr,
                         &key_sym_with_mods) &&
diff --git a/remoting/host/linux/x_server_clipboard.cc b/remoting/host/linux/x_server_clipboard.cc
index 84488217..42ea680 100644
--- a/remoting/host/linux/x_server_clipboard.cc
+++ b/remoting/host/linux/x_server_clipboard.cc
@@ -5,7 +5,7 @@
 #include "remoting/host/linux/x_server_clipboard.h"
 
 #include "base/callback.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "remoting/base/constants.h"
 #include "remoting/base/logging.h"
 #include "remoting/base/util.h"
@@ -62,7 +62,7 @@
     "TIMESTAMP",
     "UTF8_STRING"
   };
-  static const int kNumAtomNames = arraysize(kAtomNames);
+  static const int kNumAtomNames = base::size(kAtomNames);
 
   Atom atoms[kNumAtomNames];
   if (XInternAtoms(display_, const_cast<char**>(kAtomNames), kNumAtomNames,
diff --git a/remoting/host/security_key/security_key_socket.cc b/remoting/host/security_key/security_key_socket.cc
index 4d345282..4d464a76 100644
--- a/remoting/host/security_key/security_key_socket.cc
+++ b/remoting/host/security_key/security_key_socket.cc
@@ -7,7 +7,7 @@
 #include <utility>
 
 #include "base/callback_helpers.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/timer/timer.h"
 #include "net/base/io_buffer.h"
 #include "net/base/net_errors.h"
@@ -74,7 +74,7 @@
 void SecurityKeySocket::SendSshError() {
   DCHECK(thread_checker_.CalledOnValidThread());
 
-  SendResponse(std::string(kSshError, arraysize(kSshError)));
+  SendResponse(std::string(kSshError, base::size(kSshError)));
 }
 
 void SecurityKeySocket::StartReadingRequest(
diff --git a/remoting/host/setup/daemon_controller_delegate_win.cc b/remoting/host/setup/daemon_controller_delegate_win.cc
index ce44a4b..eebc05ea 100644
--- a/remoting/host/setup/daemon_controller_delegate_win.cc
+++ b/remoting/host/setup/daemon_controller_delegate_win.cc
@@ -11,8 +11,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
 #include "base/win/scoped_bstr.h"
@@ -384,7 +384,7 @@
     std::unique_ptr<base::DictionaryValue> config,
     const DaemonController::CompletionCallback& done) {
   // Check for bad keys.
-  for (size_t i = 0; i < arraysize(kReadonlyKeys); ++i) {
+  for (size_t i = 0; i < base::size(kReadonlyKeys); ++i) {
     if (config->HasKey(kReadonlyKeys[i])) {
       LOG(ERROR) << "Cannot update config: '" << kReadonlyKeys[i]
                  << "' is read only.";
diff --git a/remoting/host/setup/me2me_native_messaging_host.cc b/remoting/host/setup/me2me_native_messaging_host.cc
index 2c4dd1de0..26343c3b 100644
--- a/remoting/host/setup/me2me_native_messaging_host.cc
+++ b/remoting/host/setup/me2me_native_messaging_host.cc
@@ -15,8 +15,8 @@
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/stringize_macros.h"
 #include "base/time/time.h"
 #include "base/values.h"
@@ -179,7 +179,7 @@
   std::unique_ptr<base::ListValue> supported_features_list(
       new base::ListValue());
   supported_features_list->AppendStrings(std::vector<std::string>(
-      kSupportedFeatures, kSupportedFeatures + arraysize(kSupportedFeatures)));
+      kSupportedFeatures, kSupportedFeatures + base::size(kSupportedFeatures)));
   response->Set("supportedFeatures", std::move(supported_features_list));
   SendMessageToClient(std::move(response));
 }
diff --git a/remoting/host/setup/me2me_native_messaging_host_unittest.cc b/remoting/host/setup/me2me_native_messaging_host_unittest.cc
index 1e4c010..c91e85e0 100644
--- a/remoting/host/setup/me2me_native_messaging_host_unittest.cc
+++ b/remoting/host/setup/me2me_native_messaging_host_unittest.cc
@@ -14,7 +14,6 @@
 #include "base/compiler_specific.h"
 #include "base/json/json_reader.h"
 #include "base/json/json_writer.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
@@ -542,7 +541,7 @@
       &VerifyStartDaemonResponse,
       &VerifyGetCredentialsFromAuthCodeResponse,
   };
-  ASSERT_EQ(arraysize(verify_routines), static_cast<size_t>(next_id));
+  ASSERT_EQ(base::size(verify_routines), static_cast<size_t>(next_id));
 
   // Read all responses from output pipe, and verify them.
   for (int i = 0; i < next_id; ++i) {
diff --git a/remoting/host/win/rdp_client_window.cc b/remoting/host/win/rdp_client_window.cc
index 56ad26f..d3caf7c 100644
--- a/remoting/host/win/rdp_client_window.cc
+++ b/remoting/host/win/rdp_client_window.cc
@@ -12,7 +12,7 @@
 #include "base/lazy_instance.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/thread_local.h"
@@ -76,7 +76,7 @@
     while (child != nullptr) {
       // See if the window class name matches |class_name|.
       WCHAR name[kMaxWindowClassLength];
-      int length = GetClassName(child, name, arraysize(name));
+      int length = GetClassName(child, name, base::size(name));
       if (base::string16(name, length)  == class_name)
         return child;
 
diff --git a/remoting/protocol/audio_pump_unittest.cc b/remoting/protocol/audio_pump_unittest.cc
index ebc94b4..0ff2567 100644
--- a/remoting/protocol/audio_pump_unittest.cc
+++ b/remoting/protocol/audio_pump_unittest.cc
@@ -10,10 +10,10 @@
 #include <utility>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "remoting/codec/audio_encoder.h"
 #include "remoting/proto/audio.pb.h"
 #include "remoting/protocol/audio_source.h"
@@ -170,7 +170,7 @@
     AudioPacket::CHANNELS_MONO,
   };
 
-  for (size_t i = 0; i < arraysize(kChannels); i++) {
+  for (size_t i = 0; i < base::size(kChannels); i++) {
     source_->callback().Run(MakeAudioPacket(kChannels[i]));
     // Run message loop to let the pump processes the audio packet and send it
     // to the encoder.
@@ -182,7 +182,7 @@
     base::RunLoop().RunUntilIdle();
   }
 
-  ASSERT_EQ(sent_packets_.size(), arraysize(kChannels));
+  ASSERT_EQ(sent_packets_.size(), base::size(kChannels));
 }
 
 }  // namespace protocol
diff --git a/remoting/protocol/capture_scheduler_unittest.cc b/remoting/protocol/capture_scheduler_unittest.cc
index 004a6a0..2cd416e3 100644
--- a/remoting/protocol/capture_scheduler_unittest.cc
+++ b/remoting/protocol/capture_scheduler_unittest.cc
@@ -8,9 +8,9 @@
 
 #include <utility>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "base/timer/mock_timer.h"
 #include "remoting/proto/video.pb.h"
@@ -85,15 +85,15 @@
 };
 
 TEST_F(CaptureSchedulerTest, SingleSampleSameTimes) {
-  const int kTestResults[][arraysize(kTestInputs)] = {
-    { 400, 200, 120, 80, 50, 120, 240, 320 }, // One core.
-    { 200, 100, 60, 50, 50, 60, 120, 160 },   // Two cores.
-    { 100, 50, 50, 50, 50, 50, 60, 80 },      // Four cores.
-    { 50, 50, 50, 50, 50, 50, 50, 50 }        // Eight cores.
+  const int kTestResults[][base::size(kTestInputs)] = {
+      {400, 200, 120, 80, 50, 120, 240, 320},  // One core.
+      {200, 100, 60, 50, 50, 60, 120, 160},    // Two cores.
+      {100, 50, 50, 50, 50, 50, 60, 80},       // Four cores.
+      {50, 50, 50, 50, 50, 50, 50, 50}         // Eight cores.
   };
 
-  for (size_t i = 0; i < arraysize(kTestResults); ++i) {
-    for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
+  for (size_t i = 0; i < base::size(kTestResults); ++i) {
+    for (size_t j = 0; j < base::size(kTestInputs); ++j) {
       InitScheduler();
       scheduler_->SetNumOfProcessorsForTest(1 << i);
 
@@ -106,43 +106,43 @@
 }
 
 TEST_F(CaptureSchedulerTest, SingleSampleDifferentTimes) {
-  const int kTestResults[][arraysize(kTestInputs)] = {
-    { 360, 220, 120, 60, 60, 120, 220, 360 }, // One core.
-    { 180, 110, 60, 50, 50, 60, 110, 180 },   // Two cores.
-    { 90, 55, 50, 50, 50, 50, 55, 90 },       // Four cores.
-    { 50, 50, 50, 50, 50, 50, 50, 50 }        // Eight cores.
+  const int kTestResults[][base::size(kTestInputs)] = {
+      {360, 220, 120, 60, 60, 120, 220, 360},  // One core.
+      {180, 110, 60, 50, 50, 60, 110, 180},    // Two cores.
+      {90, 55, 50, 50, 50, 50, 55, 90},        // Four cores.
+      {50, 50, 50, 50, 50, 50, 50, 50}         // Eight cores.
   };
 
-  for (size_t i = 0; i < arraysize(kTestResults); ++i) {
-    for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
+  for (size_t i = 0; i < base::size(kTestResults); ++i) {
+    for (size_t j = 0; j < base::size(kTestInputs); ++j) {
       InitScheduler();
       scheduler_->SetNumOfProcessorsForTest(1 << i);
 
       SimulateSingleFrameCapture(
           base::TimeDelta::FromMilliseconds(kTestInputs[j]),
           base::TimeDelta::FromMilliseconds(
-              kTestInputs[arraysize(kTestInputs) - 1 - j]),
+              kTestInputs[base::size(kTestInputs) - 1 - j]),
           base::TimeDelta::FromMilliseconds(kTestResults[i][j]));
     }
   }
 }
 
 TEST_F(CaptureSchedulerTest, RollingAverageDifferentTimes) {
-  const int kTestResults[][arraysize(kTestInputs)] = {
-    { 360, 290, 233, 133, 80, 80, 133, 233 }, // One core.
-    { 180, 145, 116, 66, 50, 50, 66, 116 },   // Two cores.
-    { 90, 72, 58, 50, 50, 50, 50, 58 },       // Four cores.
-    { 50, 50, 50, 50, 50, 50, 50, 50 }        // Eight cores.
+  const int kTestResults[][base::size(kTestInputs)] = {
+      {360, 290, 233, 133, 80, 80, 133, 233},  // One core.
+      {180, 145, 116, 66, 50, 50, 66, 116},    // Two cores.
+      {90, 72, 58, 50, 50, 50, 50, 58},        // Four cores.
+      {50, 50, 50, 50, 50, 50, 50, 50}         // Eight cores.
   };
 
-  for (size_t i = 0; i < arraysize(kTestResults); ++i) {
+  for (size_t i = 0; i < base::size(kTestResults); ++i) {
     InitScheduler();
     scheduler_->SetNumOfProcessorsForTest(1 << i);
-    for (size_t j = 0; j < arraysize(kTestInputs); ++j) {
+    for (size_t j = 0; j < base::size(kTestInputs); ++j) {
       SimulateSingleFrameCapture(
           base::TimeDelta::FromMilliseconds(kTestInputs[j]),
           base::TimeDelta::FromMilliseconds(
-              kTestInputs[arraysize(kTestInputs) - 1 - j]),
+              kTestInputs[base::size(kTestInputs) - 1 - j]),
           base::TimeDelta::FromMilliseconds(kTestResults[i][j]));
     }
   }
diff --git a/remoting/protocol/jingle_messages_unittest.cc b/remoting/protocol/jingle_messages_unittest.cc
index adb1623..76d96d68 100644
--- a/remoting/protocol/jingle_messages_unittest.cc
+++ b/remoting/protocol/jingle_messages_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "remoting/protocol/content_description.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -506,7 +506,7 @@
        kTestIncomingMessage2},
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     std::unique_ptr<XmlElement> incoming_message(
         XmlElement::ForStr(tests[i].incoming_message));
     ASSERT_TRUE(incoming_message.get());
diff --git a/remoting/protocol/message_decoder_unittest.cc b/remoting/protocol/message_decoder_unittest.cc
index 6f3d3aa8..f905ffc 100644
--- a/remoting/protocol/message_decoder_unittest.cc
+++ b/remoting/protocol/message_decoder_unittest.cc
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "remoting/proto/event.pb.h"
 #include "remoting/proto/internal.pb.h"
@@ -109,17 +109,17 @@
 
 TEST(MessageDecoderTest, SmallReads) {
   const int kReads[] = {1, 2, 3, 1};
-  SimulateReadSequence(kReads, arraysize(kReads));
+  SimulateReadSequence(kReads, base::size(kReads));
 }
 
 TEST(MessageDecoderTest, LargeReads) {
   const int kReads[] = {50, 50, 5};
-  SimulateReadSequence(kReads, arraysize(kReads));
+  SimulateReadSequence(kReads, base::size(kReads));
 }
 
 TEST(MessageDecoderTest, EmptyReads) {
   const int kReads[] = {4, 0, 50, 0};
-  SimulateReadSequence(kReads, arraysize(kReads));
+  SimulateReadSequence(kReads, base::size(kReads));
 }
 
 }  // namespace protocol
diff --git a/remoting/protocol/mouse_input_filter_unittest.cc b/remoting/protocol/mouse_input_filter_unittest.cc
index 42e3b89..f27eba70 100644
--- a/remoting/protocol/mouse_input_filter_unittest.cc
+++ b/remoting/protocol/mouse_input_filter_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "remoting/protocol/mouse_input_filter.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "remoting/proto/event.pb.h"
 #include "remoting/protocol/protocol_mock_objects.h"
 #include "remoting/protocol/test_event_matchers.h"
@@ -35,11 +35,11 @@
   static const Point input_sequence[] = {
     {-5, 10}, {0, 10}, {-1, 10}, {15, 40}, {15, 45}, {15, 39}, {15, 25}
   };
-  for (unsigned int i = 0; i < arraysize(input_sequence); ++i) {
+  for (unsigned int i = 0; i < base::size(input_sequence); ++i) {
     const Point& point = input_sequence[i];
     input_stub->InjectMouseEvent(MouseMoveEvent(point.x, point.y));
   }
-  for (unsigned int i = 0; i < arraysize(input_sequence); ++i) {
+  for (unsigned int i = 0; i < base::size(input_sequence); ++i) {
     const Point& point = input_sequence[i];
     input_stub->InjectMouseEvent(MouseMoveEvent(point.y, point.x));
   }
diff --git a/remoting/protocol/pairing_registry.cc b/remoting/protocol/pairing_registry.cc
index a8c8fbc..12dfa67 100644
--- a/remoting/protocol/pairing_registry.cc
+++ b/remoting/protocol/pairing_registry.cc
@@ -13,8 +13,8 @@
 #include "base/guid.h"
 #include "base/json/json_string_value_serializer.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/values.h"
@@ -53,8 +53,8 @@
   std::string client_id = base::GenerateGUID();
   std::string shared_secret;
   char buffer[kKeySize];
-  crypto::RandBytes(buffer, arraysize(buffer));
-  base::Base64Encode(base::StringPiece(buffer, arraysize(buffer)),
+  crypto::RandBytes(buffer, base::size(buffer));
+  base::Base64Encode(base::StringPiece(buffer, base::size(buffer)),
                      &shared_secret);
   return Pairing(created_time, client_name, client_id, shared_secret);
 }
diff --git a/rlz/chromeos/lib/rlz_value_store_chromeos.cc b/rlz/chromeos/lib/rlz_value_store_chromeos.cc
index cf35cb7..2a5e2fb 100644
--- a/rlz/chromeos/lib/rlz_value_store_chromeos.cc
+++ b/rlz/chromeos/lib/rlz_value_store_chromeos.cc
@@ -15,6 +15,7 @@
 #include "base/metrics/histogram_macros.h"
 #include "base/path_service.h"
 #include "base/sequenced_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_piece.h"
 #include "base/values.h"
@@ -173,7 +174,7 @@
   // contain both install and first search cohorts.  Ignoring the second
   // means the first search cohort will never be stored.
   char dummy[kMaxRlzLength + 1];
-  if (ReadAccessPointRlz(access_point, dummy, arraysize(dummy)) &&
+  if (ReadAccessPointRlz(access_point, dummy, base::size(dummy)) &&
       dummy[0] != 0) {
     return true;
   }
diff --git a/rlz/lib/financial_ping.cc b/rlz/lib/financial_ping.cc
index f170fcc..d4bd42e 100644
--- a/rlz/lib/financial_ping.cc
+++ b/rlz/lib/financial_ping.cc
@@ -12,8 +12,8 @@
 
 #include "base/atomicops.h"
 #include "base/location.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -124,7 +124,7 @@
   // Add the product events.
   char cgi[kMaxCgiLength + 1];
   cgi[0] = 0;
-  bool has_events = GetProductEventsAsCgi(product, cgi, arraysize(cgi));
+  bool has_events = GetProductEventsAsCgi(product, cgi, base::size(cgi));
   if (has_events)
     base::StringAppendF(request, "&%s", cgi);
 
@@ -138,8 +138,7 @@
     for (int ap = NO_ACCESS_POINT + 1; ap < LAST_ACCESS_POINT; ap++) {
       rlz[0] = 0;
       AccessPoint point = static_cast<AccessPoint>(ap);
-      if (GetAccessPointRlz(point, rlz, arraysize(rlz)) &&
-          rlz[0] != '\0')
+      if (GetAccessPointRlz(point, rlz, base::size(rlz)) && rlz[0] != '\0')
         all_points[idx++] = point;
     }
     all_points[idx] = NO_ACCESS_POINT;
@@ -148,8 +147,8 @@
   // Add the RLZ's and the DCC if needed. This is the same as get PingParams.
   // This will also include the RLZ Exchange Protocol CGI Argument.
   cgi[0] = 0;
-  if (GetPingParams(product, has_events ? access_points : all_points,
-                    cgi, arraysize(cgi)))
+  if (GetPingParams(product, has_events ? access_points : all_points, cgi,
+                    base::size(cgi)))
     base::StringAppendF(request, "&%s", cgi);
 
   if (has_events && !exclude_machine_id) {
@@ -446,7 +445,7 @@
   // Check if this product has any unreported events.
   char cgi[kMaxCgiLength + 1];
   cgi[0] = 0;
-  bool has_events = GetProductEventsAsCgi(product, cgi, arraysize(cgi));
+  bool has_events = GetProductEventsAsCgi(product, cgi, base::size(cgi));
   if (no_delay && has_events)
     return true;
 
diff --git a/rlz/lib/financial_ping_test.cc b/rlz/lib/financial_ping_test.cc
index b870784..ad3594f0 100644
--- a/rlz/lib/financial_ping_test.cc
+++ b/rlz/lib/financial_ping_test.cc
@@ -19,7 +19,7 @@
 #include <stdint.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -175,7 +175,7 @@
        ap < rlz_lib::LAST_ACCESS_POINT; ap++) {
     rlz[0] = 0;
     rlz_lib::AccessPoint point = static_cast<rlz_lib::AccessPoint>(ap);
-    if (rlz_lib::GetAccessPointRlz(point, rlz, arraysize(rlz)) && rlz[0]) {
+    if (rlz_lib::GetAccessPointRlz(point, rlz, base::size(rlz)) && rlz[0]) {
       rlz_lib::SetAccessPointRlz(point, "");
     }
   }
@@ -192,7 +192,7 @@
       "Q1:QsbRlzValue" DCC_PARAM, brand);
   EXPECT_STREQ(expected_response.c_str(), request.c_str());
 
-  if (!GetAccessPointRlz(rlz_lib::IE_HOME_PAGE, rlz, arraysize(rlz))) {
+  if (!GetAccessPointRlz(rlz_lib::IE_HOME_PAGE, rlz, base::size(rlz))) {
     points[2] = rlz_lib::IE_HOME_PAGE;
     EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
         points, "swg", brand, "MyId", "en-US", true, &request));
diff --git a/rlz/lib/rlz_lib.cc b/rlz/lib/rlz_lib.cc
index 512d869..bd487666 100644
--- a/rlz/lib/rlz_lib.cc
+++ b/rlz/lib/rlz_lib.cc
@@ -9,7 +9,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/syslog_logging.h"
@@ -619,7 +619,7 @@
     bool first_rlz = true;  // comma before every RLZ but the first.
     for (int i = 0; access_points[i] != NO_ACCESS_POINT; i++) {
       char rlz[kMaxRlzLength + 1];
-      if (GetAccessPointRlz(access_points[i], rlz, arraysize(rlz))) {
+      if (GetAccessPointRlz(access_points[i], rlz, base::size(rlz))) {
         const char* access_point = GetAccessPointName(access_points[i]);
         if (!access_point)
           continue;
@@ -635,7 +635,7 @@
     // Report the DCC too if not empty. DCCs are windows-only.
     char dcc[kMaxDccLength + 1];
     dcc[0] = 0;
-    if (GetMachineDealCode(dcc, arraysize(dcc)) && dcc[0])
+    if (GetMachineDealCode(dcc, base::size(dcc)) && dcc[0])
       base::StringAppendF(&cgi_string, "&%s=%s", kDccCgiVariable, dcc);
 #endif
   }
diff --git a/rlz/lib/rlz_lib_test.cc b/rlz/lib/rlz_lib_test.cc
index 810b7cd..00ce08b 100644
--- a/rlz/lib/rlz_lib_test.cc
+++ b/rlz/lib/rlz_lib_test.cc
@@ -50,6 +50,7 @@
 
 #if defined(OS_CHROMEOS)
 #include "base/files/important_file_writer.h"
+#include "base/stl_util.h"
 #include "chromeos/dbus/dbus_thread_manager.h"
 #include "chromeos/dbus/fake_debug_daemon_client.h"
 #include "rlz/chromeos/lib/rlz_value_store_chromeos.h"
@@ -1144,7 +1145,7 @@
                               rlz_lib::FIRST_SEARCH);
   char cgi[256];
   EXPECT_TRUE(
-      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)));
+      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi)));
   EXPECT_NE(nullptr, strstr(cgi, "CAF"));
 
   // Simulate another user on the machine sending the RLZ ping, so "should send
@@ -1156,7 +1157,7 @@
   // The first search event should no longer appear, so there are no events
   // to report.
   EXPECT_FALSE(
-      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)));
+      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi)));
 
   // The event should be permanently deleted, so setting the flag back to
   // true should still not return the event.
@@ -1164,7 +1165,7 @@
       chromeos::system::kShouldSendRlzPingKey,
       chromeos::system::kShouldSendRlzPingValueTrue);
   EXPECT_FALSE(
-      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)));
+      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi)));
 }
 
 TEST_F(RlzLibTest, NoRecordCAFEvent2) {
@@ -1180,7 +1181,7 @@
                               rlz_lib::FIRST_SEARCH);
   char cgi[256];
   EXPECT_TRUE(
-      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)));
+      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi)));
   EXPECT_NE(nullptr, strstr(cgi, "CAF"));
   EXPECT_NE(nullptr, strstr(cgi, "CAI"));
 
@@ -1192,7 +1193,7 @@
 
   // Only the "CAI" event should appear.
   EXPECT_TRUE(
-      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)));
+      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi)));
   EXPECT_NE(nullptr, strstr(cgi, "CAI"));
 
   // The event should be permanently deleted, so setting the flag back to
@@ -1201,7 +1202,7 @@
       chromeos::system::kShouldSendRlzPingKey,
       chromeos::system::kShouldSendRlzPingValueTrue);
   EXPECT_TRUE(
-      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)));
+      rlz_lib::GetProductEventsAsCgi(rlz_lib::CHROME, cgi, base::size(cgi)));
   EXPECT_NE(nullptr, strstr(cgi, "CAI"));
 }
 #endif
diff --git a/rlz/lib/string_utils_unittest.cc b/rlz/lib/string_utils_unittest.cc
index 349a3bcd..4fad24f2 100644
--- a/rlz/lib/string_utils_unittest.cc
+++ b/rlz/lib/string_utils_unittest.cc
@@ -9,7 +9,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "rlz/lib/assert.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -19,11 +19,11 @@
   rlz_lib::SetExpectedAssertion("");
 
   char bad_letters[] = {'\x80', '\xA0', '\xFF'};
-  for (size_t i = 0; i < arraysize(bad_letters); ++i)
+  for (size_t i = 0; i < base::size(bad_letters); ++i)
     EXPECT_FALSE(rlz_lib::IsAscii(bad_letters[i]));
 
   char good_letters[] = {'A', '~', '\n', 0x7F, 0x00};
-  for (size_t i = 0; i < arraysize(good_letters); ++i)
+  for (size_t i = 0; i < base::size(good_letters); ++i)
     EXPECT_TRUE(rlz_lib::IsAscii(good_letters[i]));
 }
 
diff --git a/rlz/win/lib/machine_deal.cc b/rlz/win/lib/machine_deal.cc
index 2a17be7..f8d140e 100644
--- a/rlz/win/lib/machine_deal.cc
+++ b/rlz/win/lib/machine_deal.cc
@@ -10,7 +10,7 @@
 #include <stddef.h>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -174,7 +174,7 @@
 
   // Get the current DCC value to compare to later)
   char stored_dcc[kMaxDccLength + 1];
-  if (!Get(stored_dcc, arraysize(stored_dcc)))
+  if (!Get(stored_dcc, base::size(stored_dcc)))
     stored_dcc[0] = 0;
 
   int search_index = 0;
@@ -217,7 +217,7 @@
   char new_dcc[kMaxDccLength + 1];
 
   bool response_valid = GetNewCodeFromPingResponse(
-      response, &has_new_dcc, new_dcc, arraysize(new_dcc));
+      response, &has_new_dcc, new_dcc, base::size(new_dcc));
 
   if (response_valid && has_new_dcc)
     return Set(new_dcc);
@@ -290,7 +290,7 @@
 
   // Verify deletion.
   wchar_t dcc[kMaxDccLength + 1];
-  DWORD dcc_size = arraysize(dcc);
+  DWORD dcc_size = base::size(dcc);
   if (dcc_key.ReadValue(kDccValueName, dcc, &dcc_size, NULL) == ERROR_SUCCESS) {
     ASSERT_STRING("MachineDealCode::Clear: Could not delete the DCC value.");
     return false;
diff --git a/rlz/win/lib/machine_id_win.cc b/rlz/win/lib/machine_id_win.cc
index 6c1f428..f2d5306d 100644
--- a/rlz/win/lib/machine_id_win.cc
+++ b/rlz/win/lib/machine_id_win.cc
@@ -8,7 +8,7 @@
 #include <memory>
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "rlz/lib/assert.h"
 
@@ -85,7 +85,7 @@
   // Calculate the Windows SID.
 
   wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {0};
-  DWORD size = arraysize(computer_name);
+  DWORD size = base::size(computer_name);
 
   if (GetComputerNameW(computer_name, &size)) {
     char sid_buffer[SECURITY_MAX_SID_SIZE];
diff --git a/rlz/win/lib/rlz_value_store_registry.cc b/rlz/win/lib/rlz_value_store_registry.cc
index 603f5137..d68bf2f2 100644
--- a/rlz/win/lib/rlz_value_store_registry.cc
+++ b/rlz/win/lib/rlz_value_store_registry.cc
@@ -4,7 +4,7 @@
 
 #include "rlz/win/lib/rlz_value_store_registry.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/registry.h"
@@ -287,7 +287,7 @@
     // Max 32767 bytes according to MSDN, but we never use that much.
     const size_t kMaxValueNameLength = 2048;
     char buffer[kMaxValueNameLength];
-    DWORD size = arraysize(buffer);
+    DWORD size = base::size(buffer);
 
     result = RegEnumValueA(events_key.Handle(), num_values, buffer, &size,
                            NULL, NULL, NULL, NULL);
@@ -355,7 +355,7 @@
     kPingTimesSubkeyName
   };
 
-  for (size_t i = 0; i < arraysize(subkeys); i++) {
+  for (size_t i = 0; i < base::size(subkeys); i++) {
     std::string subkey_name;
     base::StringAppendF(&subkey_name, "%s\\%s", kLibKeyName, subkeys[i]);
     AppendBrandToString(&subkey_name);
diff --git a/services/audio/BUILD.gn b/services/audio/BUILD.gn
index f6012237..575bcab 100644
--- a/services/audio/BUILD.gn
+++ b/services/audio/BUILD.gn
@@ -223,7 +223,6 @@
   service_manifest("standalone_unittest_manifest") {
     name = "audio_unittests"
     source = "test/service_unittest_manifest.json"
-    generated_namespace = "standalone_audio_unittest"
   }
 
   catalog("standalone_unittest_catalog") {
diff --git a/services/catalog/BUILD.gn b/services/catalog/BUILD.gn
index 07cfd90..c35b58a 100644
--- a/services/catalog/BUILD.gn
+++ b/services/catalog/BUILD.gn
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//services/service_manager/public/service_manifest.gni")
 import("//testing/test.gni")
 
 group("catalog") {
@@ -30,6 +31,7 @@
     "entry_cache.h",
     "instance.cc",
     "instance.h",
+    "manifest_provider.h",
     "service_options.h",
   ]
 
@@ -53,3 +55,24 @@
 
   defines = [ "IS_CATALOG_IMPL" ]
 }
+
+service_manifest("manifest") {
+  name = "catalog"
+  source = "manifest.json"
+}
+
+source_set("unittests") {
+  testonly = true
+  sources = [
+    "entry_unittest.cc",
+  ]
+  data = [
+    "//services/catalog/test_data/",
+  ]
+  deps = [
+    ":lib",
+    "//base",
+    "//services/service_manager/public/cpp",
+    "//testing/gtest",
+  ]
+}
diff --git a/services/catalog/catalog.cc b/services/catalog/catalog.cc
index 2d1d21ff..6931cf8 100644
--- a/services/catalog/catalog.cc
+++ b/services/catalog/catalog.cc
@@ -32,11 +32,87 @@
 
 namespace {
 
+const char kCatalogServicesKey[] = "services";
+const char kCatalogServiceEmbeddedKey[] = "embedded";
+const char kCatalogServiceExecutableKey[] = "executable";
+const char kCatalogServiceManifestKey[] = "manifest";
+
 std::vector<service_manager::Manifest>& GetDefaultManifests() {
   static base::NoDestructor<std::vector<service_manager::Manifest>> manifests;
   return *manifests;
 }
 
+void LoadCatalogManifestIntoCache(const base::Value* root, EntryCache* cache) {
+  DCHECK(root);
+  const base::DictionaryValue* catalog = nullptr;
+  if (!root->GetAsDictionary(&catalog)) {
+    LOG(ERROR) << "Catalog manifest is not a dictionary value.";
+    return;
+  }
+  DCHECK(catalog);
+
+  const base::DictionaryValue* services = nullptr;
+  if (!catalog->GetDictionary(kCatalogServicesKey, &services)) {
+    LOG(ERROR) << "Catalog manifest \"services\" is not a dictionary value.";
+    return;
+  }
+
+  for (base::DictionaryValue::Iterator it(*services); !it.IsAtEnd();
+       it.Advance()) {
+    const base::DictionaryValue* service_entry = nullptr;
+    if (!it.value().GetAsDictionary(&service_entry)) {
+      LOG(ERROR) << "Catalog service entry for \"" << it.key()
+                 << "\" is not a dictionary value.";
+      continue;
+    }
+
+    bool is_embedded = false;
+    service_entry->GetBoolean(kCatalogServiceEmbeddedKey, &is_embedded);
+
+    base::FilePath executable_path;
+    std::string executable_path_string;
+    if (service_entry->GetString(kCatalogServiceExecutableKey,
+                                 &executable_path_string)) {
+      base::FilePath exe_dir;
+      CHECK(base::PathService::Get(base::DIR_EXE, &exe_dir));
+#if defined(OS_WIN)
+      executable_path_string += ".exe";
+      base::ReplaceFirstSubstringAfterOffset(
+          &executable_path_string, 0, "@EXE_DIR",
+          base::UTF16ToUTF8(exe_dir.value()));
+      executable_path =
+          base::FilePath(base::UTF8ToUTF16(executable_path_string));
+#else
+      base::ReplaceFirstSubstringAfterOffset(
+          &executable_path_string, 0, "@EXE_DIR", exe_dir.value());
+      executable_path = base::FilePath(executable_path_string);
+#endif
+    }
+
+    const base::DictionaryValue* manifest = nullptr;
+    if (!service_entry->GetDictionary(kCatalogServiceManifestKey, &manifest)) {
+      LOG(ERROR) << "Catalog entry for \"" << it.key() << "\" has an invalid "
+                 << "\"manifest\" value.";
+      continue;
+    }
+
+    DCHECK(!(is_embedded && !executable_path.empty()));
+
+    if (is_embedded)
+      executable_path = base::CommandLine::ForCurrentProcess()->GetProgram();
+
+    auto entry = Entry::Deserialize(*manifest);
+    if (entry) {
+      if (!executable_path.empty())
+        entry->set_path(std::move(executable_path));
+      bool added = cache->AddRootEntry(std::move(entry));
+      DCHECK(added);
+    } else {
+      LOG(ERROR) << "Failed to read manifest entry for \"" << it.key() << "\".";
+    }
+  }
+}
+
 }  // namespace
 
 // Wraps state needed for servicing directory requests on a separate thread.
@@ -67,8 +143,13 @@
   DISALLOW_COPY_AND_ASSIGN(DirectoryThreadState);
 };
 
-Catalog::Catalog(const std::vector<service_manager::Manifest>& manifests) {
-  if (!manifests.empty()) {
+Catalog::Catalog(std::unique_ptr<base::Value> catalog_contents,
+                 const std::vector<service_manager::Manifest>& manifests,
+                 ManifestProvider* service_manifest_provider)
+    : service_manifest_provider_(service_manifest_provider) {
+  if (catalog_contents) {
+    LoadCatalogManifestIntoCache(catalog_contents.get(), &system_cache_);
+  } else if (!manifests.empty()) {
     for (const auto& manifest : manifests)
       system_cache_.AddRootEntryFromManifest(manifest);
   } else {
@@ -100,8 +181,9 @@
   if (it != instances_.end())
     return it->second.get();
 
-  auto result = instances_.emplace(instance_group,
-                                   std::make_unique<Instance>(&system_cache_));
+  auto result = instances_.emplace(
+      instance_group,
+      std::make_unique<Instance>(&system_cache_, service_manifest_provider_));
   return result.first->second.get();
 }
 
diff --git a/services/catalog/catalog.h b/services/catalog/catalog.h
index 728dd5a..daa3a42 100644
--- a/services/catalog/catalog.h
+++ b/services/catalog/catalog.h
@@ -26,18 +26,23 @@
 
 namespace base {
 class SequencedTaskRunner;
+class Value;
 }
 
 namespace catalog {
 
 class Instance;
+class ManifestProvider;
 
 // Creates and owns an instance of the catalog. Exposes a ServicePtr that
 // can be passed to the service manager, potentially in a different process.
 class COMPONENT_EXPORT(CATALOG) Catalog : public service_manager::Service {
  public:
-  // Constructs a catalog over a set of Manifests to use for lookup.
-  explicit Catalog(const std::vector<service_manager::Manifest>& manifests);
+  // Constructs a catalog over a set of Manifests and optionally a
+  // ManifestProvider for dynamic manifest lookup.
+  explicit Catalog(std::unique_ptr<base::Value> catalog_contents,
+                   const std::vector<service_manager::Manifest>& manifests,
+                   ManifestProvider* service_manifest_provider = nullptr);
   ~Catalog() override;
 
   void BindServiceRequest(service_manager::mojom::ServiceRequest request);
@@ -74,6 +79,7 @@
       const service_manager::BindSourceInfo&>
       registry_;
 
+  ManifestProvider* service_manifest_provider_;
   EntryCache system_cache_;
   std::map<base::Token, std::unique_ptr<Instance>> instances_;
 
diff --git a/services/catalog/entry.cc b/services/catalog/entry.cc
index c1d438d..f3884de 100644
--- a/services/catalog/entry.cc
+++ b/services/catalog/entry.cc
@@ -5,10 +5,113 @@
 #include "services/catalog/entry.h"
 
 #include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "base/values.h"
+#include "build/build_config.h"
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
 #include "services/catalog/store.h"
 #include "services/service_manager/public/mojom/interface_provider_spec.mojom.h"
 
 namespace catalog {
+namespace {
+
+#if defined(OS_WIN)
+const char kServiceExecutableExtension[] = ".service.exe";
+#else
+const char kServiceExecutableExtension[] = ".service";
+#endif
+
+bool ReadStringSet(const base::ListValue& list_value,
+                   std::set<std::string>* string_set) {
+  DCHECK(string_set);
+  for (const auto& value_value : list_value) {
+    std::string value;
+    if (!value_value.GetAsString(&value)) {
+      LOG(ERROR) << "Entry::Deserialize: list member must be a string";
+      return false;
+    }
+    string_set->insert(std::move(value));
+  }
+  return true;
+}
+
+bool ReadStringSetFromValue(const base::Value& value,
+                            std::set<std::string>* string_set) {
+  const base::ListValue* list_value = nullptr;
+  if (!value.GetAsList(&list_value)) {
+    LOG(ERROR) << "Entry::Deserialize: Value must be a list.";
+    return false;
+  }
+  return ReadStringSet(*list_value, string_set);
+}
+
+// If |key| refers to a dictionary value within |value|, |*out| is set to that
+// DictionaryValue. Returns true if either |key| is not present or the
+// corresponding value is a dictionary.
+bool GetDictionaryValue(const base::DictionaryValue& value,
+                        base::StringPiece key,
+                        const base::DictionaryValue** out) {
+  const base::Value* entry_value = nullptr;
+  return !value.Get(key, &entry_value) || entry_value->GetAsDictionary(out);
+}
+
+bool BuildInterfaceProviderSpec(
+    const base::DictionaryValue& value,
+    service_manager::InterfaceProviderSpec* interface_provider_specs) {
+  DCHECK(interface_provider_specs);
+  const base::DictionaryValue* provides_value = nullptr;
+  if (!GetDictionaryValue(value, Store::kInterfaceProviderSpecs_ProvidesKey,
+                          &provides_value)) {
+    LOG(ERROR) << "Entry::Deserialize: "
+               << Store::kInterfaceProviderSpecs_ProvidesKey
+               << " must be a dictionary.";
+    return false;
+  }
+  if (provides_value) {
+    base::DictionaryValue::Iterator it(*provides_value);
+    for(; !it.IsAtEnd(); it.Advance()) {
+      service_manager::InterfaceSet interfaces;
+      if (!ReadStringSetFromValue(it.value(), &interfaces)) {
+        LOG(ERROR) << "Entry::Deserialize: Invalid interface list in provided "
+                   << " capabilities dictionary";
+        return false;
+      }
+      interface_provider_specs->provides[it.key()] = std::move(interfaces);
+    }
+  }
+
+  const base::DictionaryValue* requires_value = nullptr;
+  if (!GetDictionaryValue(value, Store::kInterfaceProviderSpecs_RequiresKey,
+                          &requires_value)) {
+    LOG(ERROR) << "Entry::Deserialize: "
+               << Store::kInterfaceProviderSpecs_RequiresKey
+               << " must be a dictionary.";
+    return false;
+  }
+  if (requires_value) {
+    base::DictionaryValue::Iterator it(*requires_value);
+    for (; !it.IsAtEnd(); it.Advance()) {
+      service_manager::CapabilitySet capabilities;
+      const base::ListValue* entry_value = nullptr;
+      if (!it.value().GetAsList(&entry_value)) {
+        LOG(ERROR) << "Entry::Deserialize: "
+                   << Store::kInterfaceProviderSpecs_RequiresKey
+                   << " entry must be a list.";
+        return false;
+      }
+      if (!ReadStringSet(*entry_value, &capabilities)) {
+        LOG(ERROR) << "Entry::Deserialize: Invalid capabilities list in "
+                   << "requires dictionary.";
+        return false;
+      }
+
+      interface_provider_specs->requires[it.key()] = std::move(capabilities);
+    }
+  }
+  return true;
+}
+
+}  // namespace
 
 Entry::Entry() {}
 Entry::Entry(const std::string& name)
@@ -16,6 +119,147 @@
       display_name_(name) {}
 Entry::~Entry() {}
 
+// static
+std::unique_ptr<Entry> Entry::Deserialize(const base::Value& manifest_root) {
+  const base::DictionaryValue* dictionary_value = nullptr;
+  if (!manifest_root.GetAsDictionary(&dictionary_value))
+    return nullptr;
+  const base::DictionaryValue& value = *dictionary_value;
+
+  auto entry = std::make_unique<Entry>();
+
+  // Name.
+  std::string name;
+  if (!value.GetString(Store::kNameKey, &name)) {
+    LOG(ERROR) << "Entry::Deserialize: dictionary has no "
+               << Store::kNameKey << " key";
+    return nullptr;
+  }
+  if (name.empty()) {
+    LOG(ERROR) << "Entry::Deserialize: empty service name.";
+    return nullptr;
+  }
+  entry->set_name(std::move(name));
+
+  // By default we assume a standalone service executable. The catalog may
+  // override this layer based on configuration external to the service's own
+  // manifest.
+  base::FilePath service_exe_root;
+  CHECK(base::PathService::Get(base::DIR_ASSETS, &service_exe_root));
+  entry->set_path(service_exe_root.AppendASCII(entry->name() +
+                                               kServiceExecutableExtension));
+
+  // Human-readable name.
+  std::string display_name;
+  if (!value.GetString(Store::kDisplayNameKey, &display_name)) {
+    LOG(ERROR) << "Entry::Deserialize: dictionary has no "
+               << Store::kDisplayNameKey << " key";
+    return nullptr;
+  }
+  entry->set_display_name(std::move(display_name));
+
+  // Sandbox type, optional.
+  std::string sandbox_type;
+  if (value.GetString(Store::kSandboxTypeKey, &sandbox_type))
+    entry->set_sandbox_type(std::move(sandbox_type));
+
+  // Options, optional.
+  if (const base::Value* options = value.FindKey(Store::kOptionsKey)) {
+    ServiceOptions options_struct;
+
+    if (const base::Value* instance_sharing_value =
+            options->FindKey("instance_sharing")) {
+      const std::string& instance_sharing = instance_sharing_value->GetString();
+      if (instance_sharing == "none") {
+        options_struct.instance_sharing =
+            ServiceOptions::InstanceSharingType::NONE;
+      } else if (instance_sharing == "singleton") {
+        options_struct.instance_sharing =
+            ServiceOptions::InstanceSharingType::SINGLETON;
+      } else if (instance_sharing == "shared_instance_across_users" ||
+                 instance_sharing == "shared_across_instance_groups") {
+        options_struct.instance_sharing =
+            ServiceOptions::InstanceSharingType::SHARED_ACROSS_INSTANCE_GROUPS;
+      } else {
+        LOG(ERROR) << "Entry::Deserialize invalid instance sharing type: "
+                   << instance_sharing;
+      }
+    }
+
+    if (const base::Value* can_connect_to_instances_in_any_group =
+            options->FindKey("can_connect_to_other_services_as_any_user")) {
+      options_struct.can_connect_to_instances_in_any_group =
+          can_connect_to_instances_in_any_group->GetBool();
+    }
+
+    if (const base::Value*
+            can_connect_to_other_services_with_any_instance_name_value =
+                options->FindKey(
+                    "can_connect_to_other_services_with_any_instance_name")) {
+      options_struct.can_connect_to_other_services_with_any_instance_name =
+          can_connect_to_other_services_with_any_instance_name_value->GetBool();
+    }
+
+    if (const base::Value* can_create_other_service_instances_value =
+            options->FindKey("can_create_other_service_instances")) {
+      options_struct.can_create_other_service_instances =
+          can_create_other_service_instances_value->GetBool();
+    }
+
+    entry->AddOptions(std::move(options_struct));
+  }
+
+  // InterfaceProvider specs.
+  const base::DictionaryValue* interface_provider_specs = nullptr;
+  if (!value.GetDictionary(Store::kInterfaceProviderSpecsKey,
+                           &interface_provider_specs)) {
+    LOG(ERROR) << "Entry::Deserialize: dictionary has no "
+               << Store::kInterfaceProviderSpecsKey << " key";
+    return nullptr;
+  }
+
+  base::DictionaryValue::Iterator it(*interface_provider_specs);
+  for (; !it.IsAtEnd(); it.Advance()) {
+    const base::DictionaryValue* spec_value = nullptr;
+    if (!interface_provider_specs->GetDictionary(it.key(), &spec_value)) {
+      LOG(ERROR) << "Entry::Deserialize: value of InterfaceProvider map for "
+                 << "key: " << it.key() << " not a dictionary.";
+      return nullptr;
+    }
+
+    service_manager::InterfaceProviderSpec spec;
+    if (!BuildInterfaceProviderSpec(*spec_value, &spec)) {
+      LOG(ERROR) << "Entry::Deserialize: failed to build InterfaceProvider "
+                 << "spec for key: " << it.key();
+      return nullptr;
+    }
+    entry->AddInterfaceProviderSpec(it.key(), std::move(spec));
+  }
+
+  // Required files.
+  base::Optional<RequiredFileMap> required_files =
+      catalog::RetrieveRequiredFiles(value);
+  DCHECK(required_files);
+  for (auto& iter : *required_files) {
+    entry->AddRequiredFilePath(iter.first, std::move(iter.second));
+  }
+
+  const base::ListValue* services = nullptr;
+  if (value.GetList(Store::kServicesKey, &services)) {
+    for (size_t i = 0; i < services->GetSize(); ++i) {
+      const base::DictionaryValue* service = nullptr;
+      services->GetDictionary(i, &service);
+      std::unique_ptr<Entry> child = Entry::Deserialize(*service);
+      if (child) {
+        child->set_parent(entry.get());
+        entry->children().emplace_back(std::move(child));
+      }
+    }
+  }
+
+  return entry;
+}
+
 bool Entry::ProvidesCapability(const std::string& capability) const {
   auto it = interface_provider_specs_.find(
       service_manager::mojom::kServiceManager_ConnectorSpec);
diff --git a/services/catalog/entry.h b/services/catalog/entry.h
index 46de570..86a29e3 100644
--- a/services/catalog/entry.h
+++ b/services/catalog/entry.h
@@ -16,6 +16,10 @@
 #include "services/catalog/service_options.h"
 #include "services/service_manager/public/cpp/interface_provider_spec.h"
 
+namespace base {
+class Value;
+}
+
 namespace catalog {
 
 // Static information about a service package known to the Catalog.
@@ -25,6 +29,8 @@
   explicit Entry(const std::string& name);
   ~Entry();
 
+  static std::unique_ptr<Entry> Deserialize(const base::Value& manifest_root);
+
   bool ProvidesCapability(const std::string& capability) const;
 
   bool operator==(const Entry& other) const;
diff --git a/services/catalog/entry_unittest.cc b/services/catalog/entry_unittest.cc
new file mode 100644
index 0000000..f89668b4
--- /dev/null
+++ b/services/catalog/entry_unittest.cc
@@ -0,0 +1,149 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/catalog/entry.h"
+
+#include "base/files/file_path.h"
+#include "base/json/json_file_value_serializer.h"
+#include "base/macros.h"
+#include "base/path_service.h"
+#include "base/values.h"
+#include "build/build_config.h"
+#include "services/service_manager/public/cpp/interface_provider_spec.h"
+#include "services/service_manager/public/mojom/interface_provider_spec.mojom.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace catalog {
+
+class EntryTest : public testing::Test {
+ public:
+  EntryTest() {}
+  ~EntryTest() override {}
+
+ protected:
+  std::unique_ptr<Entry> ReadEntry(const std::string& manifest,
+                                   std::unique_ptr<base::Value>* out_value) {
+    std::unique_ptr<base::Value> value = ReadManifest(manifest);
+    base::DictionaryValue* dictionary = nullptr;
+    CHECK(value->GetAsDictionary(&dictionary));
+    if (out_value)
+      *out_value = std::move(value);
+    return Entry::Deserialize(*dictionary);
+  }
+
+  std::unique_ptr<base::Value> ReadManifest(const std::string& manifest) {
+    base::FilePath manifest_path;
+    base::PathService::Get(base::DIR_SOURCE_ROOT, &manifest_path);
+    manifest_path =
+        manifest_path.AppendASCII("services/catalog/test_data/" + manifest);
+
+    JSONFileValueDeserializer deserializer(manifest_path);
+    int error = 0;
+    std::string message;
+    // TODO(beng): probably want to do more detailed error checking. This should
+    //             be done when figuring out if to unblock connection
+    //             completion.
+    return deserializer.Deserialize(&error, &message);
+  }
+
+ private:
+  void SetUp() override {}
+  void TearDown() override {}
+
+  DISALLOW_COPY_AND_ASSIGN(EntryTest);
+};
+
+TEST_F(EntryTest, Simple) {
+  std::unique_ptr<Entry> entry = ReadEntry("simple", nullptr);
+  EXPECT_EQ("foo", entry->name());
+  EXPECT_EQ("Foo", entry->display_name());
+  EXPECT_EQ("none", entry->sandbox_type());
+}
+
+TEST_F(EntryTest, Instance) {
+  std::unique_ptr<Entry> entry = ReadEntry("instance", nullptr);
+  EXPECT_EQ("foo", entry->name());
+  EXPECT_EQ("Foo", entry->display_name());
+  EXPECT_EQ("", entry->sandbox_type());
+}
+
+TEST_F(EntryTest, Options) {
+  std::unique_ptr<Entry> entry = ReadEntry("options", nullptr);
+  EXPECT_EQ("foo", entry->name());
+  EXPECT_EQ("Foo", entry->display_name());
+
+  EXPECT_EQ(ServiceOptions::InstanceSharingType::SINGLETON,
+            entry->options().instance_sharing);
+  EXPECT_TRUE(entry->options().can_connect_to_instances_in_any_group);
+  EXPECT_TRUE(
+      entry->options().can_connect_to_other_services_with_any_instance_name);
+  EXPECT_TRUE(entry->options().can_create_other_service_instances);
+
+  EXPECT_EQ("", entry->sandbox_type());
+}
+
+TEST_F(EntryTest, ConnectionSpec) {
+  std::unique_ptr<Entry> entry = ReadEntry("connection_spec", nullptr);
+
+  EXPECT_EQ("foo", entry->name());
+  EXPECT_EQ("Foo", entry->display_name());
+  service_manager::InterfaceProviderSpec spec;
+  service_manager::CapabilitySet capabilities;
+  capabilities.insert("bar:bar");
+  spec.requires["bar"] = capabilities;
+  service_manager::InterfaceProviderSpecMap specs;
+  specs[service_manager::mojom::kServiceManager_ConnectorSpec] = spec;
+  EXPECT_EQ(specs, entry->interface_provider_specs());
+}
+
+TEST_F(EntryTest, RequiredFiles) {
+  std::unique_ptr<Entry> entry = ReadEntry("required_files", nullptr);
+  EXPECT_EQ("foo", entry->name());
+  EXPECT_EQ("Foo", entry->display_name());
+  auto required_files = entry->required_file_paths();
+  EXPECT_EQ(2U, required_files.size());
+  auto iter = required_files.find("all_platforms");
+  ASSERT_NE(required_files.end(), iter);
+  bool checked_platform_specific_file = false;
+#if defined(OS_WIN)
+  EXPECT_EQ(base::FilePath(L"/all/platforms/windows"), iter->second);
+  iter = required_files.find("windows_only");
+  ASSERT_NE(required_files.end(), iter);
+  EXPECT_EQ(base::FilePath(L"/windows/only"), iter->second);
+  checked_platform_specific_file = true;
+#elif defined(OS_FUCHSIA)
+  EXPECT_EQ(base::FilePath("/all/platforms/fuchsia"), iter->second);
+  iter = required_files.find("fuchsia_only");
+  ASSERT_NE(required_files.end(), iter);
+  EXPECT_EQ(base::FilePath("/fuchsia/only"), iter->second);
+  checked_platform_specific_file = true;
+#elif defined(OS_LINUX)
+  EXPECT_EQ(base::FilePath("/all/platforms/linux"), iter->second);
+  iter = required_files.find("linux_only");
+  ASSERT_NE(required_files.end(), iter);
+  EXPECT_EQ(base::FilePath("/linux/only"), iter->second);
+  checked_platform_specific_file = true;
+#elif defined(OS_MACOSX)
+  EXPECT_EQ(base::FilePath("/all/platforms/macosx"), iter->second);
+  iter = required_files.find("macosx_only");
+  ASSERT_NE(required_files.end(), iter);
+  EXPECT_EQ(base::FilePath("/macosx/only"), iter->second);
+  checked_platform_specific_file = true;
+#elif defined(OS_ANDROID)
+  EXPECT_EQ(base::FilePath("/all/platforms/android"), iter->second);
+  iter = required_files.find("android_only");
+  ASSERT_NE(required_files.end(), iter);
+  EXPECT_EQ(base::FilePath("/android/only"), iter->second);
+  checked_platform_specific_file = true;
+#endif
+  EXPECT_TRUE(checked_platform_specific_file);
+}
+
+TEST_F(EntryTest, Malformed) {
+  std::unique_ptr<base::Value> value = ReadManifest("malformed");
+  EXPECT_FALSE(value.get());
+}
+
+
+}  // namespace catalog
diff --git a/services/catalog/instance.cc b/services/catalog/instance.cc
index 8cc1422..7dcbb76 100644
--- a/services/catalog/instance.cc
+++ b/services/catalog/instance.cc
@@ -10,6 +10,7 @@
 #include "base/values.h"
 #include "services/catalog/entry.h"
 #include "services/catalog/entry_cache.h"
+#include "services/catalog/manifest_provider.h"
 
 namespace catalog {
 namespace {
@@ -23,9 +24,12 @@
 
 }  // namespace
 
-Instance::Instance(EntryCache* system_cache) : system_cache_(system_cache) {}
+Instance::Instance(EntryCache* system_cache,
+                   ManifestProvider* service_manifest_provider)
+    : system_cache_(system_cache),
+      service_manifest_provider_(service_manifest_provider) {}
 
-Instance::~Instance() = default;
+Instance::~Instance() {}
 
 void Instance::BindCatalog(mojom::CatalogRequest request) {
   catalog_bindings_.AddBinding(this, std::move(request));
@@ -37,8 +41,25 @@
   if (cached_entry)
     return cached_entry;
 
-  LOG(ERROR) << "Unable to locate service manifest for " << service_name;
-  return nullptr;
+  std::unique_ptr<base::Value> new_manifest;
+  if (service_manifest_provider_)
+    new_manifest = service_manifest_provider_->GetManifest(service_name);
+
+  if (!new_manifest) {
+    LOG(ERROR) << "Unable to locate service manifest for " << service_name;
+    return nullptr;
+  }
+
+  auto new_entry = Entry::Deserialize(*new_manifest);
+  if (!new_entry) {
+    LOG(ERROR) << "Malformed manifest for " << service_name;
+    return nullptr;
+  }
+
+  cached_entry = const_cast<const Entry*>(new_entry.get());
+  bool added = system_cache_->AddRootEntry(std::move(new_entry));
+  DCHECK(added);
+  return cached_entry;
 }
 
 void Instance::GetEntries(const base::Optional<std::vector<std::string>>& names,
diff --git a/services/catalog/instance.h b/services/catalog/instance.h
index 14faa9d3..ad7d05c 100644
--- a/services/catalog/instance.h
+++ b/services/catalog/instance.h
@@ -17,11 +17,14 @@
 namespace catalog {
 
 class EntryCache;
+class ManifestProvider;
 
 class COMPONENT_EXPORT(CATALOG) Instance : public mojom::Catalog {
  public:
-  // |system_cache| is not owned.
-  explicit Instance(EntryCache* system_cache);
+  // Neither |system_cache| nor |service_manifest_provider| is owned.
+  // |service_manifest_provider| may be null
+  Instance(EntryCache* system_cache,
+           ManifestProvider* service_manifest_provider);
   ~Instance() override;
 
   void BindCatalog(mojom::CatalogRequest request);
@@ -43,6 +46,10 @@
   // TODO(beng): eventually add per-user applications.
   EntryCache* const system_cache_;
 
+  // A runtime interface the embedder can use to provide dynamic manifest data
+  // to be queried on-demand if something can't be found in |system_cache_|.
+  ManifestProvider* const service_manifest_provider_;
+
   DISALLOW_COPY_AND_ASSIGN(Instance);
 };
 
diff --git a/services/catalog/manifest.json b/services/catalog/manifest.json
new file mode 100644
index 0000000..0a5c2d2
--- /dev/null
+++ b/services/catalog/manifest.json
@@ -0,0 +1,20 @@
+{
+  "name": "catalog",
+  "display_name": "Application Resolver",
+  "options" : {
+    "instance_sharing" : "shared_instance_across_users"
+  },
+  "interface_provider_specs": {
+    // NOTE: This manifest is for documentation purposes only. Relevant
+    // capability spec is defined inline in the ServiceManager implementation.
+    //
+    // TODO(rockot): Fix this. We can bake this file into ServiceManager at
+    // build time or something. Same with service:service_manager.
+    "service_manager:connector": {
+      "provides": {
+        "directory": [ "filesystem.mojom.Directory" ],
+        "control": [ "catalog.mojom.CatalogControl" ]
+      }
+    }
+  }
+}
diff --git a/services/catalog/manifest_provider.h b/services/catalog/manifest_provider.h
new file mode 100644
index 0000000..f1caa225
--- /dev/null
+++ b/services/catalog/manifest_provider.h
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_CATALOG_MANIFEST_PROVIDER_H_
+#define SERVICES_CATALOG_MANIFEST_PROVIDER_H_
+
+#include <string>
+
+#include "base/component_export.h"
+
+namespace base {
+class Value;
+}
+
+namespace catalog {
+
+// An interface which can be implemented by a catalog embedder to override
+// manifest fetching behavior.
+class COMPONENT_EXPORT(CATALOG) ManifestProvider {
+ public:
+  virtual ~ManifestProvider() {}
+
+  // Retrieves the raw contents of the manifest for application named |name|.
+  // Returns true if |name| is known and |*manifest_contents| is populated.
+  // returns false otherwise.
+  virtual std::unique_ptr<base::Value> GetManifest(const std::string& name) = 0;
+};
+
+}  // namespace catalog
+
+#endif  // SERVICES_CATALOG_MANIFEST_PROVIDER_H_
diff --git a/services/catalog/public/cpp/BUILD.gn b/services/catalog/public/cpp/BUILD.gn
index 1b61a04..7eb6bda 100644
--- a/services/catalog/public/cpp/BUILD.gn
+++ b/services/catalog/public/cpp/BUILD.gn
@@ -4,6 +4,8 @@
 
 source_set("cpp") {
   sources = [
+    "manifest_parsing_util.cc",
+    "manifest_parsing_util.h",
     "resource_loader.cc",
     "resource_loader.h",
   ]
diff --git a/services/catalog/public/cpp/manifest_parsing_util.cc b/services/catalog/public/cpp/manifest_parsing_util.cc
new file mode 100644
index 0000000..4a19ec6
--- /dev/null
+++ b/services/catalog/public/cpp/manifest_parsing_util.cc
@@ -0,0 +1,111 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/catalog/public/cpp/manifest_parsing_util.h"
+
+#include "base/values.h"
+#include "build/build_config.h"
+#include "services/catalog/store.h"
+
+namespace catalog {
+
+namespace {
+
+bool IsValidPlatformName(const std::string& name) {
+  return name == Store::kRequiredFilesKey_PlatformValue_Windows ||
+         name == Store::kRequiredFilesKey_PlatformValue_Linux ||
+         name == Store::kRequiredFilesKey_PlatformValue_MacOSX ||
+         name == Store::kRequiredFilesKey_PlatformValue_Android ||
+         name == Store::kRequiredFilesKey_PlatformValue_Fuchsia;
+}
+
+bool IsCurrentPlatform(const std::string& name) {
+#if defined(OS_WIN)
+  return name == Store::kRequiredFilesKey_PlatformValue_Windows;
+#elif defined(OS_LINUX)
+  return name == Store::kRequiredFilesKey_PlatformValue_Linux;
+#elif defined(OS_MACOSX)
+  return name == Store::kRequiredFilesKey_PlatformValue_MacOSX;
+#elif defined(OS_ANDROID)
+  return name == Store::kRequiredFilesKey_PlatformValue_Android;
+#elif defined(OS_FUCHSIA)
+  return name == Store::kRequiredFilesKey_PlatformValue_Fuchsia;
+#else
+#error This architecture is not supported.
+#endif
+}
+
+}  // namespace
+
+base::Optional<RequiredFileMap> RetrieveRequiredFiles(
+    const base::Value& manifest_value) {
+  const base::DictionaryValue* manifest_dictionary = nullptr;
+  if (!manifest_value.GetAsDictionary(&manifest_dictionary)) {
+    DLOG(ERROR) << "Entry::Deserialize: manifest node is not a dictionary.";
+    return base::nullopt;
+  }
+
+  RequiredFileMap required_files;
+  if (!manifest_dictionary->HasKey(Store::kRequiredFilesKey))
+    return {required_files};
+
+  const base::DictionaryValue* required_files_value = nullptr;
+  if (!manifest_dictionary->GetDictionary(Store::kRequiredFilesKey,
+                                          &required_files_value)) {
+    DLOG(ERROR) << "Entry::Deserialize: RequiredFiles not a dictionary.";
+    return base::nullopt;
+  }
+
+  base::DictionaryValue::Iterator it(*required_files_value);
+  for (; !it.IsAtEnd(); it.Advance()) {
+    const std::string& entry_name = it.key();
+    const base::ListValue* all_platform_values = nullptr;
+    if (!it.value().GetAsList(&all_platform_values)) {
+      DLOG(ERROR) << "Entry::Deserialize: value of RequiredFiles for key: "
+                  << entry_name << " not a list.";
+      return base::nullopt;
+    }
+
+    for (size_t i = 0; i < all_platform_values->GetSize(); i++) {
+      const base::DictionaryValue* file_descriptor_value = nullptr;
+      if (!all_platform_values->GetDictionary(i, &file_descriptor_value)) {
+        DLOG(ERROR) << "Entry::Deserialize: value of entry at index " << i
+                    << " of RequiredFiles for key: " << entry_name
+                    << " not a dictionary.";
+        return base::nullopt;
+      }
+      std::string platform;
+      if (file_descriptor_value->GetString(Store::kRequiredFilesKey_PlatformKey,
+                                           &platform)) {
+        if (!IsValidPlatformName(platform)) {
+          DLOG(ERROR) << "Entry::Deserialize: value of platform for "
+                      << "required file entry entry is invalid " << platform;
+          return base::nullopt;
+        }
+      }
+      if (!IsCurrentPlatform(platform)) {
+        continue;
+      }
+      base::FilePath::StringType path;
+      if (!file_descriptor_value->GetString(Store::kRequiredFilesKey_PathKey,
+                                            &path)) {
+        DLOG(ERROR) << "Entry::Deserialize: value of RequiredFiles entry for "
+                    << "key: " << entry_name
+                    << " missing: " << Store::kRequiredFilesKey_PathKey
+                    << " value.";
+        return base::nullopt;
+      }
+      if (required_files.count(entry_name) > 0) {
+        DLOG(ERROR) << "Entry::Deserialize: value of RequiredFiles entry for "
+                    << "key: " << entry_name << " has more than one value for "
+                    << "platform: " << platform;
+        return base::nullopt;
+      }
+      required_files[entry_name] = base::FilePath(path);
+    }
+  }
+  return base::make_optional(std::move(required_files));
+}
+
+}  // namespace content
diff --git a/services/catalog/public/cpp/manifest_parsing_util.h b/services/catalog/public/cpp/manifest_parsing_util.h
new file mode 100644
index 0000000..f76c156
--- /dev/null
+++ b/services/catalog/public/cpp/manifest_parsing_util.h
@@ -0,0 +1,29 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_CATALOG_PUBLIC_CPP_MANIFEST_PARSING_UTIL_H_
+#define SERVICES_CATALOG_PUBLIC_CPP_MANIFEST_PARSING_UTIL_H_
+
+#include <map>
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/optional.h"
+
+namespace base {
+class Value;
+}
+
+// TODO(jcivelli): http://crbug.com/687250 Remove this file and inline
+//                 PopulateRequiredFiles() in Entry::Deserialize.
+namespace catalog {
+
+using RequiredFileMap = std::map<std::string, base::FilePath>;
+
+base::Optional<RequiredFileMap> RetrieveRequiredFiles(
+    const base::Value& manifest);
+
+}  // namespace content
+
+#endif  // SERVICES_CATALOG_PUBLIC_CPP_MANIFEST_PARSING_UTIL_H_
diff --git a/services/catalog/public/tools/catalog.cc.tmpl b/services/catalog/public/tools/catalog.cc.tmpl
index 85ebc0c..06327c5 100644
--- a/services/catalog/public/tools/catalog.cc.tmpl
+++ b/services/catalog/public/tools/catalog.cc.tmpl
@@ -2,8 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// This is a generated file. Please see the "service_manifest" template in
-// src/services/service_manager/public/service_manifest.gni for more details.
+// This is a generated file. Please see the "catalog_cpp_source" template in
+// src/services/catalog/public/tools/catalog.gni for more details.
 
 #include "{{path}}.h"
 
@@ -13,15 +13,8 @@
 #include "base/no_destructor.h"
 #include "build/build_config.h"
 #include "services/service_manager/public/cpp/manifest_builder.h"
-{%  for info in packaged_services %}
-#include "{{info.header}}"
-{%- endfor %}
-{%  for info in overlays %}
-#include "{{info.header}}"
-{%- endfor %}
 
-{%- macro generate_manifest_builder(manifest, packaged_services=[],
-                                    overlays=[]) -%}
+{%- macro generate_manifest_builder(manifest) -%}
 service_manager::ManifestBuilder()
     .WithServiceName("{{manifest['name']}}")
 {%-   if 'display_name' in manifest %}
@@ -109,36 +102,21 @@
     .PackageService(
         {{generate_manifest_builder(packaged_service_manifest)|indent(8)}})
 {%-  endfor %}
-{%-  for info in packaged_services %}
-    .PackageService({{info.namespace}}::GetManifest())
-{%-  endfor %}
     .Build()
-{%-  for info in overlays %}
-        .Amend({{info.namespace}}::GetManifest())
-{%-  endfor %}
 {%- endmacro %}
 
 {% for namespace in namespaces %}
 namespace {{namespace}} {
 {%- endfor %}
 
-{%  if root_manifest %}
-const service_manager::Manifest& {{function_name}}() {
-  static base::NoDestructor<service_manager::Manifest> manifest{
-      {{generate_manifest_builder(root_manifest,
-            packaged_services=packaged_services, overlays=overlays)
-            |indent(6)}} };
-  return *manifest;
-}
-{%  else %}
 const std::vector<service_manager::Manifest>& {{function_name}}() {
-  static base::NoDestructor<std::vector<service_manager::Manifest>> manifests{ {
-{%- for info in packaged_services %}
-      {{info.namespace}}::GetManifest(){%- if not loop.last %},{%- endif %}
-{%- endfor -%} }};
-  return *manifests;
+  static base::NoDestructor<std::vector<service_manager::Manifest>> catalog{ {
+{%- for entry in catalog['services'].itervalues() %}
+      {{generate_manifest_builder(entry['manifest'])|indent(6)}}
+{%- if not loop.last %},{% endif %}
+{%- endfor %} } };
+  return *catalog;
 }
-{%  endif %}
 
 {%- for namespace in namespaces|reverse %}
 }  // namespace {{namespace}}
diff --git a/services/catalog/public/tools/catalog.gni b/services/catalog/public/tools/catalog.gni
index ca11a734..212d28c 100644
--- a/services/catalog/public/tools/catalog.gni
+++ b/services/catalog/public/tools/catalog.gni
@@ -4,53 +4,173 @@
 
 import("//build/config/dcheck_always_on.gni")
 
-# Generates code to produce a list service_manager::Manifest objects given a set
-# of service_manager targets to include in the list.
+# Generates a static catalog manifest to be loaded at runtime. This manifest
+# contains the union of all individual service manifests specified by the
+# template parameters.
 #
-# This is a temporary helper to transition away from JSON manifests. The catalog
-# target always has a companion catalog_cpp_source target, which yields a
-# source_set defining the generated function.
+# The output of a catalog rule is always a file named:
 #
-# No new uses of these targets should be introduced.
+#     ${target_gen_dir}/${target_name}.json
+#
+# A Service Manager embedder uses a catalog manifest as its singular source of
+# truth regarding available services in the system.
+#
+# Parameters:
+#
+#   embedded_services (optional)
+#       A list of service manifest targets whose outputs correspond to services
+#       embedded by the Service Manager embedder's binary. Outputs of targets
+#       listed here will be embedded in the catalog within its
+#       "embedded_services" list.
+#
+#   standalone_services (optional)
+#       A list of service manifest targets whose outputs correspond to services
+#       with standalone binaries which must be available to the Service Manager
+#       at runtime. Outputs of targets listed here will be embedded in the
+#       catalog within its "standalone_services" list.
+#
+#       Typically a standalone service binary is expected to live next to
+#       the Service Manager embedder's binary, with the name
+#       "${service_name}.service", with an additional ".exe" suffix on Windows.
+#       Binaries following this naming scheme are typically output by
+#       service_executable targets. See
+#       //services/service_manager/public/cpp/service_executable.gni.
+#
+#    executable_overrides (optional)
+#       A list of overrides to apply in catalog metadata for individual
+#       services. An override string must be of the form
+#
+#           "<service_name>:<executable_path>"
+#
+#       The special token @EXE_DIR may be used in |executable_path| to denote
+#       a path relative to the Service Manager embedder's binary, substituted
+#       at runtime. For example:
+#
+#           "content_browser:@EXE_DIR/chrome"
+#
+#       would indicate to the Service Manager embedder that the
+#       "content_browser" service can be started by running the "chrome"
+#       executable in the embedder's own directory.
+#
+#       This overrides the default binary name expectation described in
+#       |standalone_services| above.
+#
+#    catalog_deps (optional)
+#       A list of other catalog targets whose outputs will be included within
+#       this catalog. Targets in this list
+#
 template("catalog") {
-  group(target_name) {
+  output_filename = "$target_gen_dir/${target_name}.json"
+  action(target_name) {
     testonly = defined(invoker.testonly) && invoker.testonly
-  }
 
-  # NOTE: There is no longer a practical difference between embedded and
-  # standalone services in terms of manifest data. Some targets use one or the
-  # other or both.
-  submanifests = []
-  if (defined(invoker.embedded_services)) {
-    submanifests += invoker.embedded_services
-  }
-  if (defined(invoker.standalone_services)) {
-    submanifests += invoker.standalone_services
-  }
+    script = "//services/catalog/public/tools/generate_manifest.py"
 
-  write_file("$target_gen_dir/${target_name}.submanifests", submanifests)
+    inputs = []
+    outputs = [
+      output_filename,
+    ]
+
+    args = [ "--output=" + rebase_path(output_filename, root_build_dir) ]
+
+    if (is_debug || dcheck_always_on) {
+      args += [ "--pretty" ]
+    }
+
+    deps = []
+    if (defined(invoker.deps)) {
+      deps += invoker.deps
+    }
+
+    if (defined(invoker.embedded_services)) {
+      args += [ "--embedded-services" ]
+      foreach(manifest_target, invoker.embedded_services) {
+        manifest_target_dir = get_label_info(manifest_target, "target_gen_dir")
+        manifest_target_name = get_label_info(manifest_target, "name")
+        manifest_filename = "$manifest_target_dir/${manifest_target_name}.json"
+
+        inputs += [ "$manifest_filename" ]
+        deps += [ manifest_target ]
+        args += [ rebase_path(manifest_filename, root_build_dir) ]
+
+        # Ensure that each entry does in fact reference a service manifest rule.
+        label_no_toolchain =
+            get_label_info(manifest_target, "label_no_toolchain")
+        toolchain = get_label_info(manifest_target, "toolchain")
+        deps += [ "${label_no_toolchain}__is_service_manifest(${toolchain})" ]
+      }
+    }
+
+    if (defined(invoker.standalone_services)) {
+      args += [ "--standalone-services" ]
+      foreach(manifest_target, invoker.standalone_services) {
+        manifest_target_dir = get_label_info(manifest_target, "target_gen_dir")
+        manifest_target_name = get_label_info(manifest_target, "name")
+        manifest_filename = "$manifest_target_dir/${manifest_target_name}.json"
+
+        inputs += [ "$manifest_filename" ]
+        deps += [ manifest_target ]
+        args += [ rebase_path(manifest_filename, root_build_dir) ]
+
+        # Ensure that each entry does in fact reference a service manifest rule.
+        label_no_toolchain =
+            get_label_info(manifest_target, "label_no_toolchain")
+        toolchain = get_label_info(manifest_target, "toolchain")
+        deps += [ "${label_no_toolchain}__is_service_manifest(${toolchain})" ]
+      }
+    }
+
+    if (defined(invoker.executable_overrides)) {
+      args +=
+          [ "--override-service-executables" ] + invoker.executable_overrides
+    }
+
+    if (defined(invoker.catalog_deps)) {
+      args += [ "--include-catalogs" ]
+      foreach(catalog_target, invoker.catalog_deps) {
+        catalog_target_dir = get_label_info(catalog_target, "target_gen_dir")
+        catalog_target_name = get_label_info(catalog_target, "name")
+        catalog_filename = "$catalog_target_dir/${catalog_target_name}.json"
+
+        inputs += [ "$catalog_filename" ]
+        deps += [ catalog_target ]
+        args += [ rebase_path(catalog_filename, root_build_dir) ]
+      }
+    }
+  }
 }
 
+# Generates a source_set target which defines a single string constant
+# containing the contents of a compiled catalog manifest.
+#
+# Parameters:
+#
+#   catalog
+#       The catalog target whose output should be stringified.
+#
+#   generated_function_name
+#       The fully qualified symbol name of the C++ string constant to define in
+#       the generate source_set.
+#
 template("catalog_cpp_source") {
   assert(defined(invoker.catalog), "catalog is required")
   assert(defined(invoker.generated_function_name),
          "generated_function_name is required")
 
-  generator_target_name = "${target_name}__generator"
-  generated_filename_base = "${target_gen_dir}/${target_name}"
-
   catalog_target = invoker.catalog
   catalog_target_dir = get_label_info(catalog_target, "target_gen_dir")
   catalog_target_name = get_label_info(catalog_target, "name")
+  catalog_filename = "$catalog_target_dir/${catalog_target_name}.json"
 
-  submanifests =
-      read_file("$catalog_target_dir/${catalog_target_name}.submanifests",
-                "list lines")
+  generator_target_name = "${target_name}__generator"
+  generated_filename_base = "${target_gen_dir}/${target_name}"
 
   action(generator_target_name) {
     testonly = defined(invoker.testonly) && invoker.testonly
     script = "//services/catalog/public/tools/sourcify_manifest.py"
     inputs = [
+      catalog_filename,
+
       "//services/catalog/public/tools/catalog.cc.tmpl",
       "//services/catalog/public/tools/catalog.h.tmpl",
     ]
@@ -58,42 +178,28 @@
       "${generated_filename_base}.cc",
       "${generated_filename_base}.h",
     ]
-
-    submanifest_info = []
-    foreach(submanifest, submanifests) {
-      manifest_dir = get_label_info(submanifest, "target_gen_dir")
-      manifest_target_name = get_label_info(submanifest, "name")
-      manifest_namespace_input =
-          "$manifest_dir/${manifest_target_name}.namespace"
-      manifest_namespace_path =
-          rebase_path(manifest_namespace_input, root_build_dir)
-      manifest_header_base =
-          rebase_path(manifest_dir, root_gen_dir) + "/${manifest_target_name}"
-      submanifest_info +=
-          [ "packaged@$manifest_namespace_path@$manifest_header_base" ]
-    }
-
-    submanifest_info_file =
-        "$target_gen_dir/${invoker.target_name}.submanifest_info"
-    write_file(submanifest_info_file, submanifest_info)
-
     args = [
-      "--submanifest-info=" +
-          rebase_path(submanifest_info_file, root_build_dir),
+      "--input=" + rebase_path(catalog_filename, root_build_dir),
       "--output-filename-base=" +
           rebase_path(generated_filename_base, root_build_dir),
       "--output-function-name=" + invoker.generated_function_name,
       "--module-path=" + rebase_path(generated_filename_base, root_gen_dir),
     ]
+    if (is_debug || dcheck_always_on) {
+      args += [ "--pretty" ]
+    }
+    deps = [
+      catalog_target,
+    ]
   }
 
   source_set(target_name) {
     testonly = defined(invoker.testonly) && invoker.testonly
     sources = get_target_outputs(":$generator_target_name")
     deps = [
-             ":$generator_target_name",
-             "//base",
-             "//services/service_manager/public/cpp",
-           ] + submanifests
+      ":$generator_target_name",
+      "//base",
+      "//services/service_manager/public/cpp",
+    ]
   }
 }
diff --git a/services/catalog/public/tools/catalog.h.tmpl b/services/catalog/public/tools/catalog.h.tmpl
index aed4b1d..402a877b 100644
--- a/services/catalog/public/tools/catalog.h.tmpl
+++ b/services/catalog/public/tools/catalog.h.tmpl
@@ -2,9 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// This is a generated file. Please see the "service_manifest" template in
-// src/services/service_manager/public/service_manifest.gni for more details.
-
+// This is a generated file. Please see the "catalog_cpp_source" template in
+// src/services/catalog/public/tools/catalog.gni for more details.
 {%- set header_guard = "%s_H_"|format(path)|upper|replace("/", "_")|
         replace(".", "_")|replace("-", "_") %}
 
@@ -19,11 +18,7 @@
 namespace {{namespace}} {
 {%- endfor %}
 
-{% if root_manifest -%}
-const service_manager::Manifest& {{function_name}}();
-{% else -%}
 const std::vector<service_manager::Manifest>& {{function_name}}();
-{%- endif %}
 
 {% for namespace in namespaces|reverse %}
 }  // namespace {{namespace}}
diff --git a/services/catalog/public/tools/sourcify_manifest.py b/services/catalog/public/tools/sourcify_manifest.py
index acfc971d..1bcfc6ae 100755
--- a/services/catalog/public/tools/sourcify_manifest.py
+++ b/services/catalog/public/tools/sourcify_manifest.py
@@ -18,20 +18,10 @@
     "build", "android", "gyp"))
 from util import build_utils
 
-
 _H_FILE_TEMPLATE = "catalog.h.tmpl"
 _CC_FILE_TEMPLATE = "catalog.cc.tmpl"
 
 
-eater_relative = "../../../../../tools/json_comment_eater"
-eater_relative = os.path.join(os.path.abspath(__file__), eater_relative)
-sys.path.insert(0, os.path.normpath(eater_relative))
-try:
-  import json_comment_eater
-finally:
-  sys.path.pop(0)
-
-
 # Disable lint check for finding modules:
 # pylint: disable=F0401
 
@@ -54,38 +44,49 @@
 
 
 def ApplyTemplate(path_to_template, output_path, global_vars, **kwargs):
+  def make_ascii(maybe_unicode):
+    if type(maybe_unicode) is str:
+      return maybe_unicode
+    assert type(maybe_unicode) is unicode
+    return maybe_unicode.encode("ascii", "ignore")
+
   with build_utils.AtomicOutput(output_path) as output_file:
     jinja_env = jinja2.Environment(
         loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
         keep_trailing_newline=True, **kwargs)
     jinja_env.globals.update(global_vars)
+    jinja_env.filters.update({
+      "is_dict": lambda x : type(x) is dict,
+      "is_list": lambda x : type(x) is list,
+      "is_number": lambda x : type(x) is int or type(x) is float,
+      "is_bool": lambda x: type(x) is bool,
+      "is_string": lambda x: type(x) is str,
+      "is_unicode": lambda x: type(x) is unicode,
+      "make_ascii": make_ascii,
+    })
     output_file.write(jinja_env.get_template(path_to_template).render())
 
 
 def main():
   parser = argparse.ArgumentParser(
       description="Generates a C++ constant containing a catalog manifest.")
-  parser.add_argument("--root-manifest")
-  parser.add_argument("--submanifest-info")
+  parser.add_argument("--input")
   parser.add_argument("--output-filename-base")
   parser.add_argument("--output-function-name")
   parser.add_argument("--module-path")
   args, _ = parser.parse_known_args()
 
-  if args.submanifest_info is None:
-    raise Exception("--submanifest-info required")
+  if args.input is None:
+    raise Exception("--input is required")
   if args.output_filename_base is None:
     raise Exception("--output-filename-base is required")
   if args.output_function_name is None:
     raise Exception("--output-function-name is required")
   if args.module_path is None:
-    args.module_path = args.output_filename_base
+    raise Exception("--module-path is required")
 
-  if args.root_manifest:
-    with open(args.root_manifest, "r") as input_file:
-      root_manifest = json.loads(json_comment_eater.Nom(input_file.read()))
-  else:
-    root_manifest = None
+  with open(args.input, "r") as input_file:
+    catalog = json.load(input_file)
 
   qualified_function_name = args.output_function_name.split("::")
   namespaces = qualified_function_name[0:-1]
@@ -94,23 +95,8 @@
   def raise_error(error, value):
     raise Exception(error)
 
-  overlays = []
-  packaged_services = []
-  with open(args.submanifest_info, "r") as info_file:
-    for line in info_file.readlines():
-      submanifest_type, namespace_file, header_base = line.strip().split("@", 3)
-      with open(namespace_file, "r") as namespace_file:
-        namespace = namespace_file.readline().strip()
-      info = { "namespace": namespace, "header": header_base + ".h" }
-      if submanifest_type == "overlay":
-        overlays.append(info)
-      else:
-        packaged_services.append(info)
-
   global_vars = {
-    "root_manifest": root_manifest,
-    "overlays": overlays,
-    "packaged_services": packaged_services,
+    "catalog": catalog,
     "function_name": function_name,
     "namespaces": namespaces,
     "path": args.module_path,
diff --git a/services/catalog/test_data/connection_spec b/services/catalog/test_data/connection_spec
new file mode 100644
index 0000000..80da172
--- /dev/null
+++ b/services/catalog/test_data/connection_spec
@@ -0,0 +1,11 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
+  "interface_provider_specs": {
+    "service_manager:connector": {
+      "requires": {
+        "bar": [ "bar:bar" ]
+      }
+    }
+  }
+}
diff --git a/services/catalog/test_data/instance b/services/catalog/test_data/instance
new file mode 100644
index 0000000..3fa31be
--- /dev/null
+++ b/services/catalog/test_data/instance
@@ -0,0 +1,5 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
+  "interface_provider_specs": { }
+}
diff --git a/services/catalog/test_data/malformed b/services/catalog/test_data/malformed
new file mode 100644
index 0000000..28a269c
--- /dev/null
+++ b/services/catalog/test_data/malformed
@@ -0,0 +1,3 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
diff --git a/services/catalog/test_data/options b/services/catalog/test_data/options
new file mode 100644
index 0000000..203a4e6
--- /dev/null
+++ b/services/catalog/test_data/options
@@ -0,0 +1,11 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
+  "options": {
+    "instance_sharing": "singleton",
+    "can_connect_to_other_services_as_any_user": true,
+    "can_connect_to_other_services_with_any_instance_name": true,
+    "can_create_other_service_instances": true
+  },
+  "interface_provider_specs": { }
+}
diff --git a/services/catalog/test_data/required_files b/services/catalog/test_data/required_files
new file mode 100644
index 0000000..2e45d97e
--- /dev/null
+++ b/services/catalog/test_data/required_files
@@ -0,0 +1,19 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
+  "interface_provider_specs": { },
+  "required_files": {
+    "all_platforms": [
+      { "path": "/all/platforms/fuchsia", "platform": "fuchsia" },
+      { "path": "/all/platforms/linux", "platform": "linux" },
+      { "path": "/all/platforms/windows", "platform": "windows" },
+      { "path": "/all/platforms/macosx", "platform": "macosx" },
+      { "path": "/all/platforms/android", "platform": "android" }
+    ],
+    "fuchsia_only": [{ "path": "/fuchsia/only", "platform": "fuchsia" }],
+    "linux_only": [{ "path": "/linux/only", "platform": "linux" }],
+    "windows_only": [{ "path" : "/windows/only", "platform": "windows" }],
+    "macosx_only": [{ "path" : "/macosx/only", "platform": "macosx" }],
+    "android_only": [{ "path" : "/android/only", "platform": "android" }]
+  }
+}
diff --git a/services/catalog/test_data/serialization b/services/catalog/test_data/serialization
new file mode 100644
index 0000000..10fe188
--- /dev/null
+++ b/services/catalog/test_data/serialization
@@ -0,0 +1,15 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
+  "interface_provider_specs": {
+    "service_manager:connector": {
+      "provides": {
+        "foo": [ "mojo::Bar", "mojo::Baz" ],
+        "bar": [ "mojo::Bork" ]
+      },
+      "requires": {
+        "bar": [ "a", "b" ]
+      }
+    }
+  }
+}
diff --git a/services/catalog/test_data/simple b/services/catalog/test_data/simple
new file mode 100644
index 0000000..04cd6fe
--- /dev/null
+++ b/services/catalog/test_data/simple
@@ -0,0 +1,6 @@
+{
+  "name": "foo",
+  "display_name": "Foo",
+  "sandbox_type": "none",
+  "interface_provider_specs": { }
+}
diff --git a/services/data_decoder/image_decoder_impl_unittest.cc b/services/data_decoder/image_decoder_impl_unittest.cc
index 5a43370..4d3fe88 100644
--- a/services/data_decoder/image_decoder_impl_unittest.cc
+++ b/services/data_decoder/image_decoder_impl_unittest.cc
@@ -8,6 +8,7 @@
 #include "base/bind.h"
 #include "base/lazy_instance.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "gin/array_buffer.h"
 #include "gin/public/isolate_holder.h"
 #include "services/data_decoder/image_decoder_impl.h"
@@ -124,7 +125,7 @@
   int heights[] = {max_height_for_msg - 10, max_height_for_msg + 10,
                    2 * max_height_for_msg + 10};
   int widths[] = {heights[0] * 3 / 2, heights[1] * 3 / 2, heights[2] * 3 / 2};
-  for (size_t i = 0; i < arraysize(heights); i++) {
+  for (size_t i = 0; i < base::size(heights); i++) {
     std::vector<unsigned char> jpg;
     ASSERT_TRUE(CreateJPEGImage(widths[i], heights[i], SK_ColorRED, &jpg));
 
diff --git a/services/device/generic_sensor/platform_sensor_reader_linux.cc b/services/device/generic_sensor/platform_sensor_reader_linux.cc
index 7c3dae6..5ecff6cae 100644
--- a/services/device/generic_sensor/platform_sensor_reader_linux.cc
+++ b/services/device/generic_sensor/platform_sensor_reader_linux.cc
@@ -6,6 +6,7 @@
 
 #include "base/files/file_util.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/threading/thread_restrictions.h"
@@ -97,7 +98,7 @@
   DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
 
   SensorReading readings;
-  DCHECK_LE(sensor_file_paths_.size(), arraysize(readings.raw.values));
+  DCHECK_LE(sensor_file_paths_.size(), base::size(readings.raw.values));
   int i = 0;
   for (const auto& path : sensor_file_paths_) {
     std::string new_read_value;
diff --git a/services/device/generic_sensor/platform_sensor_reader_win.cc b/services/device/generic_sensor/platform_sensor_reader_win.cc
index 93c9e059..c5fbb36d 100644
--- a/services/device/generic_sensor/platform_sensor_reader_win.cc
+++ b/services/device/generic_sensor/platform_sensor_reader_win.cc
@@ -11,6 +11,7 @@
 #include <iomanip>
 
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
 #include "base/win/iunknown_impl.h"
@@ -370,7 +371,7 @@
     params->min_reporting_interval_ms = min_interval.get().ulVal;
 
   GUID interests[] = {SENSOR_EVENT_STATE_CHANGED, SENSOR_EVENT_DATA_UPDATED};
-  hr = sensor->SetEventInterest(interests, arraysize(interests));
+  hr = sensor->SetEventInterest(interests, base::size(interests));
   if (FAILED(hr))
     return nullptr;
 
diff --git a/services/device/geolocation/wifi_data_provider_linux_unittest.cc b/services/device/geolocation/wifi_data_provider_linux_unittest.cc
index 81415ff..5098e38 100644
--- a/services/device/geolocation/wifi_data_provider_linux_unittest.cc
+++ b/services/device/geolocation/wifi_data_provider_linux_unittest.cc
@@ -8,8 +8,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/scoped_task_environment.h"
 #include "dbus/message.h"
@@ -189,7 +189,7 @@
           const uint8_t kSsid[] = {0x74, 0x65, 0x73, 0x74};  // "test"
           dbus::MessageWriter variant_writer(response.get());
           writer.OpenVariant("ay", &variant_writer);
-          variant_writer.AppendArrayOfBytes(kSsid, arraysize(kSsid));
+          variant_writer.AppendArrayOfBytes(kSsid, base::size(kSsid));
           writer.CloseContainer(&variant_writer);
         } else if (property_name == "HwAddress") {
           // This will be converted to "00-11-22-33-44-55".
diff --git a/services/device/geolocation/wifi_data_provider_win.cc b/services/device/geolocation/wifi_data_provider_win.cc
index 764bfaf..b5a8adeb 100644
--- a/services/device/geolocation/wifi_data_provider_win.cc
+++ b/services/device/geolocation/wifi_data_provider_win.cc
@@ -11,6 +11,7 @@
 #include "base/memory/free_deleter.h"
 #include "base/memory/ptr_util.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/timer/elapsed_timer.h"
 #include "base/win/windows_version.h"
@@ -113,7 +114,7 @@
   // Use an absolute path to load the DLL to avoid DLL preloading attacks.
   static const wchar_t* const kDLL = L"%WINDIR%\\system32\\wlanapi.dll";
   wchar_t path[MAX_PATH] = {0};
-  ExpandEnvironmentStrings(kDLL, path, arraysize(path));
+  ExpandEnvironmentStrings(kDLL, path, base::size(path));
   HINSTANCE library = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
   if (!library)
     return nullptr;
diff --git a/services/device/time_zone_monitor/time_zone_monitor_linux.cc b/services/device/time_zone_monitor/time_zone_monitor_linux.cc
index bceb85f..bb43da3 100644
--- a/services/device/time_zone_monitor/time_zone_monitor_linux.cc
+++ b/services/device/time_zone_monitor/time_zone_monitor_linux.cc
@@ -13,7 +13,6 @@
 #include "base/bind.h"
 #include "base/files/file_path.h"
 #include "base/files/file_path_watcher.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/sequenced_task_runner.h"
 #include "base/stl_util.h"
@@ -107,7 +106,7 @@
     const char* const kFilesToWatch[] = {
         "/etc/localtime", "/etc/timezone", "/etc/TZ",
     };
-    for (size_t index = 0; index < arraysize(kFilesToWatch); ++index) {
+    for (size_t index = 0; index < base::size(kFilesToWatch); ++index) {
       file_path_watchers_.push_back(std::make_unique<base::FilePathWatcher>());
       file_path_watchers_.back()->Watch(base::FilePath(kFilesToWatch[index]),
                                         false, callback);
diff --git a/services/network/cookie_manager_unittest.cc b/services/network/cookie_manager_unittest.cc
index 9dd9751..f891141 100644
--- a/services/network/cookie_manager_unittest.cc
+++ b/services/network/cookie_manager_unittest.cc
@@ -7,9 +7,9 @@
 #include <algorithm>
 
 #include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/strcat.h"
 #include "base/task/post_task.h"
 #include "base/task/task_scheduler/task_scheduler.h"
@@ -1152,7 +1152,7 @@
   };
   mojom::CookieDeletionFilter test_filter;
   test_filter.including_domains = std::vector<std::string>();
-  for (int i = 0; i < static_cast<int>(arraysize(filter_domains)); ++i)
+  for (int i = 0; i < static_cast<int>(base::size(filter_domains)); ++i)
     test_filter.including_domains->push_back(filter_domains[i]);
 
   struct TestCase {
@@ -1189,7 +1189,7 @@
   };
 
   mojom::CookieDeletionFilter clear_filter;
-  for (int i = 0; i < static_cast<int>(arraysize(test_cases)); ++i) {
+  for (int i = 0; i < static_cast<int>(base::size(test_cases)); ++i) {
     TestCase& test_case(test_cases[i]);
 
     // Clear store.
diff --git a/services/network/cross_origin_read_blocking.cc b/services/network/cross_origin_read_blocking.cc
index b508cf94..939a841 100644
--- a/services/network/cross_origin_read_blocking.cc
+++ b/services/network/cross_origin_read_blocking.cc
@@ -14,7 +14,6 @@
 #include "base/command_line.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
 #include "base/no_destructor.h"
 #include "base/stl_util.h"
@@ -302,7 +301,7 @@
     AdvancePastWhitespace(&data);
 
     SniffingResult signature_match =
-        MatchesSignature(&data, kHtmlSignatures, arraysize(kHtmlSignatures),
+        MatchesSignature(&data, kHtmlSignatures, base::size(kHtmlSignatures),
                          base::CompareCase::INSENSITIVE_ASCII);
     if (signature_match != kNo)
       return signature_match;
@@ -322,7 +321,7 @@
   // initializer.
   AdvancePastWhitespace(&data);
   static const StringPiece kXmlSignatures[] = {StringPiece("<?xml")};
-  return MatchesSignature(&data, kXmlSignatures, arraysize(kXmlSignatures),
+  return MatchesSignature(&data, kXmlSignatures, base::size(kXmlSignatures),
                           base::CompareCase::SENSITIVE);
 }
 
@@ -427,7 +426,7 @@
       StringPiece("while (1);"),
   };
   SniffingResult has_parser_breaker = MatchesSignature(
-      &data, kScriptBreakingPrefixes, arraysize(kScriptBreakingPrefixes),
+      &data, kScriptBreakingPrefixes, base::size(kScriptBreakingPrefixes),
       base::CompareCase::SENSITIVE);
   if (has_parser_breaker != kNo)
     return has_parser_breaker;
diff --git a/services/network/http_cache_data_remover_unittest.cc b/services/network/http_cache_data_remover_unittest.cc
index 529f06c..be140cf 100644
--- a/services/network/http_cache_data_remover_unittest.cc
+++ b/services/network/http_cache_data_remover_unittest.cc
@@ -10,6 +10,7 @@
 #include "base/files/file_util.h"
 #include "base/location.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "mojo/public/cpp/bindings/interface_request.h"
@@ -100,7 +101,7 @@
       entry->Close();
       scoped_task_environment_.RunUntilIdle();
     }
-    ASSERT_EQ(arraysize(kCacheEntries),
+    ASSERT_EQ(base::size(kCacheEntries),
               static_cast<size_t>(backend_->GetEntryCount()));
   }
 
diff --git a/services/network/p2p/socket_tcp_unittest.cc b/services/network/p2p/socket_tcp_unittest.cc
index 0935e1d..12501897 100644
--- a/services/network/p2p/socket_tcp_unittest.cc
+++ b/services/network/p2p/socket_tcp_unittest.cc
@@ -7,8 +7,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/sys_byteorder.h"
 #include "base/test/bind_test_util.h"
 #include "base/test/scoped_task_environment.h"
@@ -178,7 +178,7 @@
     size_t step_size = std::min(step_sizes[step], received_data.size() - pos);
     socket_->AppendInputData(&received_data[pos], step_size);
     pos += step_size;
-    if (++step >= arraysize(step_sizes))
+    if (++step >= base::size(step_sizes))
       step = 0;
   }
 
@@ -406,7 +406,7 @@
     size_t step_size = std::min(step_sizes[step], received_data.size() - pos);
     socket_->AppendInputData(&received_data[pos], step_size);
     pos += step_size;
-    if (++step >= arraysize(step_sizes))
+    if (++step >= base::size(step_sizes))
       step = 0;
   }
 
diff --git a/services/network/public/cpp/server/http_server_unittest.cc b/services/network/public/cpp/server/http_server_unittest.cc
index 23c06a3..2af5ec40 100644
--- a/services/network/public/cpp/server/http_server_unittest.cc
+++ b/services/network/public/cpp/server/http_server_unittest.cc
@@ -12,6 +12,7 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/scoped_task_environment.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/time/time.h"
@@ -346,7 +347,7 @@
       {"HeaderWithNonASCII", ":  ", "\xf7"},
   };
   std::string headers;
-  for (size_t i = 0; i < arraysize(kHeaders); ++i) {
+  for (size_t i = 0; i < base::size(kHeaders); ++i) {
     headers +=
         std::string(kHeaders[i][0]) + kHeaders[i][1] + kHeaders[i][2] + "\r\n";
   }
@@ -355,7 +356,7 @@
   RunUntilRequestsReceived(1);
   ASSERT_EQ("", GetRequest(0).data);
 
-  for (size_t i = 0; i < arraysize(kHeaders); ++i) {
+  for (size_t i = 0; i < base::size(kHeaders); ++i) {
     std::string field = base::ToLowerASCII(std::string(kHeaders[i][0]));
     std::string value = kHeaders[i][2];
     ASSERT_EQ(1u, GetRequest(0).headers.count(field)) << field;
@@ -372,7 +373,7 @@
       {"LastHeader", ": ", "5"},
   };
   std::string headers;
-  for (size_t i = 0; i < arraysize(kHeaders); ++i) {
+  for (size_t i = 0; i < base::size(kHeaders); ++i) {
     headers +=
         std::string(kHeaders[i][0]) + kHeaders[i][1] + kHeaders[i][2] + "\r\n";
   }
@@ -381,7 +382,7 @@
   RunUntilRequestsReceived(1);
   ASSERT_EQ("", GetRequest(0).data);
 
-  for (size_t i = 0; i < arraysize(kHeaders); ++i) {
+  for (size_t i = 0; i < base::size(kHeaders); ++i) {
     std::string field = base::ToLowerASCII(std::string(kHeaders[i][0]));
     std::string value = (field == "duplicateheader") ? "2,4" : kHeaders[i][2];
     ASSERT_EQ(1u, GetRequest(0).headers.count(field)) << field;
@@ -404,7 +405,7 @@
       "HeaderWithNonASCII:  \xf7",
   };
   std::string headers;
-  for (size_t i = 0; i < arraysize(kHeaders); ++i) {
+  for (size_t i = 0; i < base::size(kHeaders); ++i) {
     headers += std::string(kHeaders[i]) + "\r\n";
   }
 
@@ -591,7 +592,7 @@
       "GET /test \r\n\r\n",
   };
 
-  for (size_t i = 0; i < arraysize(kBadProtocolRequests); ++i) {
+  for (size_t i = 0; i < base::size(kBadProtocolRequests); ++i) {
     TestHttpClient client;
     ASSERT_THAT(client.ConnectAndWait(server_address_), IsOk());
 
diff --git a/services/network/throttling/throttling_controller_unittest.cc b/services/network/throttling/throttling_controller_unittest.cc
index 1f7b1e5..0eedd555 100644
--- a/services/network/throttling/throttling_controller_unittest.cc
+++ b/services/network/throttling/throttling_controller_unittest.cc
@@ -11,10 +11,10 @@
 #include <utility>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/test/test_mock_time_task_runner.h"
 #include "net/base/chunked_upload_data_stream.h"
 #include "net/base/completion_repeating_callback.h"
@@ -100,7 +100,7 @@
     if (with_upload) {
       upload_data_stream_.reset(
           new net::ChunkedUploadDataStream(kUploadIdentifier));
-      upload_data_stream_->AppendData(kUploadData, arraysize(kUploadData),
+      upload_data_stream_->AppendData(kUploadData, base::size(kUploadData),
                                       true);
       request_->upload_data_stream = upload_data_stream_.get();
     }
@@ -292,7 +292,7 @@
   int rv = helper.Start(true);
   EXPECT_EQ(rv, net::ERR_INTERNET_DISCONNECTED);
   rv = helper.ReadUploadData();
-  EXPECT_EQ(rv, static_cast<int>(arraysize(kUploadData)));
+  EXPECT_EQ(rv, static_cast<int>(base::size(kUploadData)));
 }
 
 TEST(ThrottlingControllerTest, DownloadOnly) {
@@ -336,7 +336,7 @@
   EXPECT_EQ(callback->run_count(), 1);
   helper.FastForwardUntilNoTasksRemain();
   EXPECT_EQ(callback->run_count(), 2);
-  EXPECT_EQ(callback->value(), static_cast<int>(arraysize(kUploadData)));
+  EXPECT_EQ(callback->value(), static_cast<int>(base::size(kUploadData)));
 }
 
 }  // namespace network
diff --git a/services/preferences/tracked/device_id_win.cc b/services/preferences/tracked/device_id_win.cc
index 9dbd110..ff7fbb6 100644
--- a/services/preferences/tracked/device_id_win.cc
+++ b/services/preferences/tracked/device_id_win.cc
@@ -11,13 +11,13 @@
 #include <memory>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id) {
   DCHECK(machine_id);
 
   wchar_t computer_name[MAX_COMPUTERNAME_LENGTH + 1] = {};
-  DWORD computer_name_size = arraysize(computer_name);
+  DWORD computer_name_size = base::size(computer_name);
 
   if (!::GetComputerNameW(computer_name, &computer_name_size))
     return MachineIdStatus::FAILURE;
diff --git a/services/preferences/tracked/pref_hash_filter.cc b/services/preferences/tracked/pref_hash_filter.cc
index 594c319..f2c334a 100644
--- a/services/preferences/tracked/pref_hash_filter.cc
+++ b/services/preferences/tracked/pref_hash_filter.cc
@@ -10,8 +10,8 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/time/time.h"
 #include "base/values.h"
@@ -36,7 +36,7 @@
       "default_search_provider.search_url", "default_search_provider.name",
       "default_search_provider.keyword"};
 
-  for (size_t i = 0; i < arraysize(kDeprecatedTrackedPreferences); ++i) {
+  for (size_t i = 0; i < base::size(kDeprecatedTrackedPreferences); ++i) {
     const char* key = kDeprecatedTrackedPreferences[i];
     pref_store_contents->Remove(key, NULL);
     hash_store_transaction->ClearHash(key);
diff --git a/services/preferences/tracked/pref_hash_filter_unittest.cc b/services/preferences/tracked/pref_hash_filter_unittest.cc
index 9e3a6a8..6ac980c3 100644
--- a/services/preferences/tracked/pref_hash_filter_unittest.cc
+++ b/services/preferences/tracked/pref_hash_filter_unittest.cc
@@ -17,12 +17,12 @@
 #include "base/callback_forward.h"
 #include "base/compiler_specific.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/metrics/histogram_base.h"
 #include "base/metrics/histogram_samples.h"
 #include "base/metrics/statistics_recorder.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "components/prefs/testing_pref_store.h"
 #include "mojo/public/cpp/bindings/binding_set.h"
@@ -586,7 +586,7 @@
             std::move(temp_mock_external_validation_pref_hash_store),
             std::move(temp_mock_external_validation_hash_store_contents)),
         std::move(configuration), std::move(reset_on_load_observer),
-        &mock_validation_delegate_, arraysize(kTestTrackedPrefs), true));
+        &mock_validation_delegate_, base::size(kTestTrackedPrefs), true));
   }
 
   // Verifies whether a reset was reported by the PrefHashFiler. Also verifies
@@ -646,13 +646,13 @@
 TEST_P(PrefHashFilterTest, EmptyAndUnchanged) {
   DoFilterOnLoad(false);
   // All paths checked.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   // No paths stored, since they all return |UNCHANGED|.
   ASSERT_EQ(0u, mock_pref_hash_store_->stored_paths_count());
   // Since there was nothing in |pref_store_contents_| the checked value should
   // have been NULL for all tracked preferences.
-  for (size_t i = 0; i < arraysize(kTestTrackedPrefs); ++i) {
+  for (size_t i = 0; i < base::size(kTestTrackedPrefs); ++i) {
     ASSERT_EQ(
         NULL,
         mock_pref_hash_store_->checked_value(kTestTrackedPrefs[i].name).first);
@@ -661,9 +661,9 @@
   VerifyRecordedReset(false);
 
   // Delegate saw all paths, and all unchanged.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 }
@@ -864,7 +864,7 @@
   mock_pref_hash_store_->SetCheckResult(kSplitPref,
                                         ValueState::TRUSTED_NULL_VALUE);
   DoFilterOnLoad(false);
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(2u, mock_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
@@ -880,11 +880,11 @@
   ASSERT_EQ(PrefTrackingStrategy::SPLIT, stored_split_value.second);
 
   // Delegate saw all prefs, two of which had the expected value_state.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
   ASSERT_EQ(2u, mock_validation_delegate_record_->CountValidationsOfState(
                     ValueState::TRUSTED_NULL_VALUE));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 2u,
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -916,17 +916,17 @@
                                         ValueState::UNTRUSTED_UNKNOWN_VALUE);
   // If we are enforcing, expect this to report changes.
   DoFilterOnLoad(GetParam() >= EnforcementLevel::ENFORCE_ON_LOAD);
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(2u, mock_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
 
   // Delegate saw all prefs, two of which had the expected value_state.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
   ASSERT_EQ(2u, mock_validation_delegate_record_->CountValidationsOfState(
                     ValueState::UNTRUSTED_UNKNOWN_VALUE));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 2u,
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -980,17 +980,17 @@
   mock_pref_hash_store_->SetCheckResult(kSplitPref,
                                         ValueState::TRUSTED_UNKNOWN_VALUE);
   DoFilterOnLoad(false);
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(2u, mock_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
 
   // Delegate saw all prefs, two of which had the expected value_state.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
   ASSERT_EQ(2u, mock_validation_delegate_record_->CountValidationsOfState(
                     ValueState::TRUSTED_UNKNOWN_VALUE));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 2u,
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -1034,7 +1034,7 @@
   mock_pref_hash_store_->SetInvalidKeysResult(kSplitPref, mock_invalid_keys);
 
   DoFilterOnLoad(GetParam() >= EnforcementLevel::ENFORCE_ON_LOAD);
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(2u, mock_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
@@ -1091,17 +1091,17 @@
   mock_pref_hash_store_->SetCheckResult(kAtomicPref, ValueState::CLEARED);
   mock_pref_hash_store_->SetCheckResult(kSplitPref, ValueState::CLEARED);
   DoFilterOnLoad(false);
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(2u, mock_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
 
   // Delegate saw all prefs, two of which had the expected value_state.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
   ASSERT_EQ(2u, mock_validation_delegate_record_->CountValidationsOfState(
                     ValueState::CLEARED));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 2u,
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -1135,16 +1135,16 @@
   mock_pref_hash_store_->SetCheckResult(kAtomicPref, ValueState::SECURE_LEGACY);
   mock_pref_hash_store_->SetCheckResult(kSplitPref, ValueState::SECURE_LEGACY);
   DoFilterOnLoad(false);
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
 
   // Delegate saw all prefs, two of which had the expected value_state.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
   ASSERT_EQ(2u, mock_validation_delegate_record_->CountValidationsOfState(
                     ValueState::SECURE_LEGACY));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 2u,
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -1197,17 +1197,17 @@
   DoFilterOnLoad(GetParam() >= EnforcementLevel::ENFORCE_ON_LOAD);
   // All prefs should be checked and a new hash should be stored for each tested
   // pref.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(4u, mock_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(1u, mock_pref_hash_store_->transactions_performed());
 
   // Delegate saw all prefs, four of which had the expected value_state.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
   ASSERT_EQ(4u, mock_validation_delegate_record_->CountValidationsOfState(
                     ValueState::CHANGED));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 4u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 4u,
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -1340,18 +1340,18 @@
 
   DoFilterOnLoad(false);
 
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_external_validation_pref_hash_store_->checked_paths_count());
   ASSERT_EQ(2u,
             mock_external_validation_pref_hash_store_->stored_paths_count());
   ASSERT_EQ(
       1u, mock_external_validation_pref_hash_store_->transactions_performed());
 
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->recorded_validations_count());
 
   // Regular validation should not have any CHANGED prefs.
-  ASSERT_EQ(arraysize(kTestTrackedPrefs),
+  ASSERT_EQ(base::size(kTestTrackedPrefs),
             mock_validation_delegate_record_->CountValidationsOfState(
                 ValueState::UNCHANGED));
 
@@ -1359,7 +1359,7 @@
   ASSERT_EQ(2u,
             mock_validation_delegate_record_->CountExternalValidationsOfState(
                 ValueState::CHANGED));
-  ASSERT_EQ(arraysize(kTestTrackedPrefs) - 2u,
+  ASSERT_EQ(base::size(kTestTrackedPrefs) - 2u,
             mock_validation_delegate_record_->CountExternalValidationsOfState(
                 ValueState::UNCHANGED));
 }
diff --git a/services/service_manager/BUILD.gn b/services/service_manager/BUILD.gn
index e55963d..efd375a 100644
--- a/services/service_manager/BUILD.gn
+++ b/services/service_manager/BUILD.gn
@@ -28,6 +28,8 @@
     "connect_params.h",
     "service_manager.cc",
     "service_manager.h",
+    "service_overrides.cc",
+    "service_overrides.h",
     "switches.cc",
     "switches.h",
   ]
diff --git a/services/service_manager/background/background_service_manager.cc b/services/service_manager/background/background_service_manager.cc
index 6e718c4..c887ea7 100644
--- a/services/service_manager/background/background_service_manager.cc
+++ b/services/service_manager/background/background_service_manager.cc
@@ -26,13 +26,26 @@
 
 BackgroundServiceManager::BackgroundServiceManager(
     ServiceProcessLauncherDelegate* launcher_delegate,
+    std::unique_ptr<base::Value> catalog_contents)
+    : background_thread_("service_manager") {
+  background_thread_.Start();
+  background_thread_.task_runner()->PostTask(
+      FROM_HERE,
+      base::BindOnce(&BackgroundServiceManager::InitializeOnBackgroundThread,
+                     base::Unretained(this), launcher_delegate,
+                     std::move(catalog_contents), std::vector<Manifest>()));
+}
+
+BackgroundServiceManager::BackgroundServiceManager(
+    ServiceProcessLauncherDelegate* launcher_delegate,
     const std::vector<Manifest>& manifests)
     : background_thread_("service_manager") {
   background_thread_.Start();
   background_thread_.task_runner()->PostTask(
       FROM_HERE,
       base::BindOnce(&BackgroundServiceManager::InitializeOnBackgroundThread,
-                     base::Unretained(this), launcher_delegate, manifests));
+                     base::Unretained(this), launcher_delegate, nullptr,
+                     manifests));
 }
 
 BackgroundServiceManager::~BackgroundServiceManager() {
@@ -61,8 +74,14 @@
 
 void BackgroundServiceManager::InitializeOnBackgroundThread(
     ServiceProcessLauncherDelegate* launcher_delegate,
+    std::unique_ptr<base::Value> catalog_contents,
     const std::vector<Manifest>& manifests) {
-  context_ = std::make_unique<Context>(launcher_delegate, manifests);
+  if (!manifests.empty()) {
+    context_ = std::make_unique<Context>(launcher_delegate, manifests);
+  } else {
+    context_ = std::make_unique<Context>(launcher_delegate,
+                                         std::move(catalog_contents));
+  }
 }
 
 void BackgroundServiceManager::ShutDownOnBackgroundThread(
diff --git a/services/service_manager/background/background_service_manager.h b/services/service_manager/background/background_service_manager.h
index 8260d0c..d614f5b 100644
--- a/services/service_manager/background/background_service_manager.h
+++ b/services/service_manager/background/background_service_manager.h
@@ -10,6 +10,7 @@
 
 #include "base/macros.h"
 #include "base/threading/thread.h"
+#include "base/values.h"
 #include "build/build_config.h"
 #include "services/service_manager/public/cpp/manifest.h"
 #include "services/service_manager/public/mojom/connector.mojom.h"
@@ -31,6 +32,8 @@
 class BackgroundServiceManager {
  public:
   BackgroundServiceManager(ServiceProcessLauncherDelegate* launcher_delegate,
+                           std::unique_ptr<base::Value> catalog_contents);
+  BackgroundServiceManager(ServiceProcessLauncherDelegate* launcher_delegate,
                            const std::vector<Manifest>& manifests);
   ~BackgroundServiceManager();
 
@@ -47,6 +50,7 @@
  private:
   void InitializeOnBackgroundThread(
       ServiceProcessLauncherDelegate* launcher_delegate,
+      std::unique_ptr<base::Value> catalog_contents,
       const std::vector<Manifest>& manifests);
   void ShutDownOnBackgroundThread(base::WaitableEvent* done_event);
   void RegisterServiceOnBackgroundThread(
diff --git a/services/service_manager/embedder/BUILD.gn b/services/service_manager/embedder/BUILD.gn
index feeac1e2..df6fb926 100644
--- a/services/service_manager/embedder/BUILD.gn
+++ b/services/service_manager/embedder/BUILD.gn
@@ -2,12 +2,19 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-if (!is_ios) {
-  # iOS embeds the Service Manager but does not use anything in this library.
-  # This avoids having an empty component library target, which can otherwise be
-  # problematic.
-  component("embedder") {
-    public = [
+component("embedder") {
+  public = [
+    "manifest_utils.h",
+  ]
+
+  sources = [
+    "manifest_utils.cc",
+  ]
+
+  # iOS embeds the Service Manager but does not use service_manager::Main() (and
+  # cannot use or even build it as-is).
+  if (!is_ios) {
+    public += [
       "main.h",
       "main_delegate.h",
       "process_type.h",
@@ -15,42 +22,41 @@
       "set_process_title_linux.h",
       "shared_file_util.h",
     ]
-
-    sources = [
+    sources += [
       "main.cc",
       "main_delegate.cc",
       "set_process_title.cc",
       "set_process_title_linux.cc",
       "shared_file_util.cc",
     ]
+  }
 
-    if (is_mac) {
-      sources += [
-        "mac_init.h",
-        "mac_init.mm",
-      ]
-
-      libs = [ "Foundation.framework" ]
-    }
-
-    deps = [
-      "//base:base_static",
-      "//base:i18n",
-      "//base/allocator:buildflags",
-      "//components/tracing:startup_tracing",
+  if (is_mac) {
+    sources += [
+      "mac_init.h",
+      "mac_init.mm",
     ]
 
-    public_deps = [
-      ":embedder_result_codes",
-      ":embedder_switches",
-      "//base",
-      "//mojo/core/embedder",
-      "//services/service_manager/background:lib",
-      "//services/service_manager/public/cpp",
-      "//services/service_manager/public/cpp/service_executable:support",
-      "//services/service_manager/public/mojom",
-      "//services/service_manager/runner:init",
-      "//services/service_manager/runner/common",
+    libs = [ "Foundation.framework" ]
+  }
+
+  deps = [
+    "//base:base_static",
+    "//base:i18n",
+  ]
+
+  public_deps = [
+    ":embedder_result_codes",
+    "//base",
+    "//services/service_manager/public/cpp",
+    "//services/service_manager/public/mojom",
+  ]
+
+  if (!is_ios) {
+    # deps of ServiceManager::Main and related functionality.
+    deps += [
+      "//base/allocator:buildflags",
+      "//components/tracing:startup_tracing",
     ]
 
     if (!is_nacl) {
@@ -59,8 +65,17 @@
       deps += [ "//ui/base" ]
     }
 
-    defines = [ "IS_SERVICE_MANAGER_EMBEDDER_IMPL" ]
+    public_deps += [
+      ":embedder_switches",
+      "//mojo/core/embedder",
+      "//services/service_manager/background:lib",
+      "//services/service_manager/public/cpp/service_executable:support",
+      "//services/service_manager/runner:init",
+      "//services/service_manager/runner/common",
+    ]
   }
+
+  defines = [ "IS_SERVICE_MANAGER_EMBEDDER_IMPL" ]
 }
 
 component("embedder_switches") {
@@ -79,3 +94,18 @@
     "result_codes.h",
   ]
 }
+
+source_set("unittests") {
+  testonly = true
+
+  sources = [
+    "manifest_utils_unittest.cc",
+  ]
+
+  deps = [
+    ":embedder",
+    "//base",
+    "//base/test:test_support",
+    "//testing/gtest",
+  ]
+}
diff --git a/services/service_manager/embedder/main.cc b/services/service_manager/embedder/main.cc
index 329b86e0..938469b 100644
--- a/services/service_manager/embedder/main.cc
+++ b/services/service_manager/embedder/main.cc
@@ -19,6 +19,7 @@
 #include "base/process/memory.h"
 #include "base/process/process.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/task/task_scheduler/task_scheduler.h"
 #include "base/threading/thread.h"
 #include "base/trace_event/trace_config.h"
@@ -125,7 +126,7 @@
   static const int signals_to_reset[] = {
       SIGHUP,  SIGINT,  SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV,
       SIGALRM, SIGTERM, SIGCHLD, SIGBUS, SIGTRAP};  // SIGPIPE is set below.
-  for (unsigned i = 0; i < arraysize(signals_to_reset); i++) {
+  for (unsigned i = 0; i < base::size(signals_to_reset); i++) {
     CHECK_EQ(0, sigaction(signals_to_reset[i], &sigact, NULL));
   }
 
@@ -234,7 +235,7 @@
   ServiceProcessLauncherDelegateImpl service_process_launcher_delegate(
       delegate);
   service_manager::BackgroundServiceManager background_service_manager(
-      &service_process_launcher_delegate, delegate->GetServiceManifests());
+      &service_process_launcher_delegate, delegate->CreateServiceCatalog());
 
   base::RunLoop run_loop;
   delegate->OnServiceManagerInitialized(run_loop.QuitClosure(),
diff --git a/services/service_manager/embedder/main_delegate.cc b/services/service_manager/embedder/main_delegate.cc
index ea4c1d7..1501a97b 100644
--- a/services/service_manager/embedder/main_delegate.cc
+++ b/services/service_manager/embedder/main_delegate.cc
@@ -27,8 +27,8 @@
 void MainDelegate::OverrideMojoConfiguration(
     mojo::core::Configuration* config) {}
 
-std::vector<Manifest> MainDelegate::GetServiceManifests() {
-  return std::vector<Manifest>();
+std::unique_ptr<base::Value> MainDelegate::CreateServiceCatalog() {
+  return nullptr;
 }
 
 bool MainDelegate::ShouldLaunchAsServiceProcess(const Identity& identity) {
diff --git a/services/service_manager/embedder/main_delegate.h b/services/service_manager/embedder/main_delegate.h
index ba3589a5..d373d708 100644
--- a/services/service_manager/embedder/main_delegate.h
+++ b/services/service_manager/embedder/main_delegate.h
@@ -6,7 +6,6 @@
 #define SERVICES_SERVICE_MANAGER_EMBEDDER_MAIN_DELEGATE_H_
 
 #include <memory>
-#include <vector>
 
 #include "base/callback_forward.h"
 #include "base/component_export.h"
@@ -16,12 +15,12 @@
 #include "services/service_manager/background/background_service_manager.h"
 #include "services/service_manager/embedder/process_type.h"
 #include "services/service_manager/public/cpp/identity.h"
-#include "services/service_manager/public/cpp/manifest.h"
 #include "services/service_manager/public/cpp/service.h"
 #include "services/service_manager/public/mojom/service.mojom.h"
 
 namespace base {
 class CommandLine;
+class Value;
 namespace mac {
 class ScopedNSAutoreleasePool;
 }
@@ -74,10 +73,9 @@
   // Allows the embedder to override the process-wide Mojop configuration.
   virtual void OverrideMojoConfiguration(mojo::core::Configuration* config);
 
-  // Gets the list of service manifests with which to initialize the Service
-  // Manager. This list must describe the complete set of usable services in
-  // the system and remains fixed for the lifetime of the Service Manager.
-  virtual std::vector<Manifest> GetServiceManifests();
+  // Create the service catalog to be used by the Service Manager. May return
+  // null to use the default (empty) catalog, if you're into that.
+  virtual std::unique_ptr<base::Value> CreateServiceCatalog();
 
   // Indicates whether a process started by the service manager for a given
   // target service identity should be run as a real service process (|true|)
diff --git a/services/service_manager/embedder/manifest_utils.cc b/services/service_manager/embedder/manifest_utils.cc
new file mode 100644
index 0000000..a43c152
--- /dev/null
+++ b/services/service_manager/embedder/manifest_utils.cc
@@ -0,0 +1,63 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/service_manager/embedder/manifest_utils.h"
+
+
+namespace service_manager {
+
+namespace {
+
+// Similar to base::DictionaryValue::MergeDictionary(), except concatenates
+// ListValue contents.
+// This is explicitly not part of base::DictionaryValue at brettw's request.
+void MergeDictionary(base::DictionaryValue* target,
+                     const base::DictionaryValue* source) {
+  for (base::DictionaryValue::Iterator it(*source); !it.IsAtEnd();
+       it.Advance()) {
+    const base::Value* merge_value = &it.value();
+    // Check whether we have to merge dictionaries.
+    if (merge_value->is_dict()) {
+      base::DictionaryValue* sub_dict;
+      if (target->GetDictionaryWithoutPathExpansion(it.key(), &sub_dict)) {
+        MergeDictionary(sub_dict,
+                        static_cast<const base::DictionaryValue*>(merge_value));
+        continue;
+      }
+    }
+    if (merge_value->is_list()) {
+      const base::ListValue* merge_list = nullptr;
+      if (merge_value->GetAsList(&merge_list)) {
+        base::ListValue* target_list = nullptr;
+        if (target->GetListWithoutPathExpansion(it.key(), &target_list)) {
+          for (size_t i = 0; i < merge_list->GetSize(); ++i) {
+            const base::Value* element = nullptr;
+            CHECK(merge_list->Get(i, &element));
+            target_list->Append(element->CreateDeepCopy());
+          }
+          continue;
+        }
+      }
+    }
+    // All other cases: Make a copy and hook it up.
+    target->SetKey(it.key(), merge_value->Clone());
+  }
+}
+
+}  // namespace
+
+void MergeManifestWithOverlay(base::Value* manifest, base::Value* overlay) {
+  if (!overlay)
+    return;
+
+  base::DictionaryValue* manifest_dictionary = nullptr;
+  bool result = manifest->GetAsDictionary(&manifest_dictionary);
+  DCHECK(result);
+  base::DictionaryValue* overlay_dictionary = nullptr;
+  result = overlay->GetAsDictionary(&overlay_dictionary);
+  DCHECK(result);
+  MergeDictionary(manifest_dictionary, overlay_dictionary);
+}
+
+}  // namespace service_manager
diff --git a/services/service_manager/embedder/manifest_utils.h b/services/service_manager/embedder/manifest_utils.h
new file mode 100644
index 0000000..a6af881
--- /dev/null
+++ b/services/service_manager/embedder/manifest_utils.h
@@ -0,0 +1,20 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_SERVICE_MANAGER_EMBEDDER_MANIFEST_UTILS_H_
+#define SERVICES_SERVICE_MANAGER_EMBEDDER_MANIFEST_UTILS_H_
+
+#include "base/component_export.h"
+#include "base/values.h"
+
+namespace service_manager {
+
+// Merges |overlay| (if not null) into |manifest|.
+// Uses a strategy similar to base::DictionaryValue::MergeDictionary(), except
+// concatenates ListValue contents.
+void COMPONENT_EXPORT(SERVICE_MANAGER_EMBEDDER)
+    MergeManifestWithOverlay(base::Value* manifest, base::Value* overlay);
+}  // namespace service_manager
+
+#endif  // SERVICES_SERVICE_MANAGER_EMBEDDER_MANIFEST_UTILS_H_
diff --git a/services/service_manager/embedder/manifest_utils_unittest.cc b/services/service_manager/embedder/manifest_utils_unittest.cc
new file mode 100644
index 0000000..9d8e46ac
--- /dev/null
+++ b/services/service_manager/embedder/manifest_utils_unittest.cc
@@ -0,0 +1,70 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/service_manager/embedder/manifest_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace service_manager {
+
+TEST(MergeManifestWithOverlayTest, Merge) {
+  // |manifest| & |overlay| have three properties, "string", "list" and
+  // "dictionary", which are then merged.
+  base::DictionaryValue manifest;
+  manifest.SetString("string", "Hello, ");
+  std::unique_ptr<base::DictionaryValue> dict_value_original(
+      std::make_unique<base::DictionaryValue>());
+  dict_value_original->SetString("key1", "original");
+  dict_value_original->SetString("key3", "original");
+  manifest.Set("dictionary", std::move(dict_value_original));
+  std::unique_ptr<base::ListValue> list(std::make_unique<base::ListValue>());
+  list->AppendString("A");
+  list->AppendString("B");
+  manifest.Set("list", std::move(list));
+
+  base::DictionaryValue overlay;
+  overlay.SetString("string", "World!");
+  std::unique_ptr<base::DictionaryValue> dict_value_replacement(
+      std::make_unique<base::DictionaryValue>());
+  dict_value_replacement->SetString("key1", "new");
+  dict_value_replacement->SetString("key2", "new");
+  overlay.Set("dictionary", std::move(dict_value_replacement));
+  list = std::make_unique<base::ListValue>();
+  list->AppendString("C");
+  overlay.Set("list", std::move(list));
+
+  MergeManifestWithOverlay(&manifest, &overlay);
+
+  // Simple string value should have been clobbered.
+  std::string out_string;
+  EXPECT_TRUE(manifest.GetString("string", &out_string));
+  EXPECT_EQ(out_string, "World!");
+
+  // Dictionary should have been merged, with key1 being clobbered, key2 added
+  // and key3 preserved.
+  base::DictionaryValue* out_dictionary = nullptr;
+  EXPECT_TRUE(manifest.GetDictionary("dictionary", &out_dictionary));
+  EXPECT_EQ(3u, out_dictionary->size());
+  std::string value1, value2, value3;
+  EXPECT_TRUE(out_dictionary->GetString("key1", &value1));
+  EXPECT_TRUE(out_dictionary->GetString("key2", &value2));
+  EXPECT_TRUE(out_dictionary->GetString("key3", &value3));
+  EXPECT_EQ(value1, "new");
+  EXPECT_EQ(value2, "new");
+  EXPECT_EQ(value3, "original");
+
+  // List should have been merged, with the items from overlay appended to the
+  // items from manifest.
+  base::ListValue* out_list = nullptr;
+  EXPECT_TRUE(manifest.GetList("list", &out_list));
+  EXPECT_EQ(3u, out_list->GetSize());
+  std::string a, b, c;
+  EXPECT_TRUE(out_list->GetString(0, &a));
+  EXPECT_TRUE(out_list->GetString(1, &b));
+  EXPECT_TRUE(out_list->GetString(2, &c));
+  EXPECT_EQ("A", a);
+  EXPECT_EQ("B", b);
+  EXPECT_EQ("C", c);
+}
+
+}  // namespace service_manager
diff --git a/services/service_manager/public/cpp/manifest.cc b/services/service_manager/public/cpp/manifest.cc
index 464ad43..e018583d 100644
--- a/services/service_manager/public/cpp/manifest.cc
+++ b/services/service_manager/public/cpp/manifest.cc
@@ -230,7 +230,7 @@
   return manifest;
 }
 
-Manifest& Manifest::Amend(Manifest other) {
+void Manifest::Amend(Manifest other) {
   for (auto& other_capability : other.exposed_capabilities) {
     auto it = std::find_if(
         exposed_capabilities.begin(), exposed_capabilities.end(),
@@ -272,8 +272,6 @@
     packaged_services.emplace_back(std::move(manifest));
   for (auto& file_info : other.preloaded_files)
     preloaded_files.emplace_back(std::move(file_info));
-
-  return *this;
 }
 
 }  // namespace service_manager
diff --git a/services/service_manager/public/cpp/manifest.h b/services/service_manager/public/cpp/manifest.h
index 12294aa..684a60eb 100644
--- a/services/service_manager/public/cpp/manifest.h
+++ b/services/service_manager/public/cpp/manifest.h
@@ -267,7 +267,7 @@
   // Amends this Manifest with a subset of |other|. Namely, exposed and required
   // capabilities, exposed and required interface filter capabilities, packaged
   // services, and preloaded files are all added from |other| if present.
-  Manifest& Amend(Manifest other);
+  void Amend(Manifest other);
 
   std::string service_name;
   DisplayName display_name;
diff --git a/services/service_manager/public/service_manifest.gni b/services/service_manager/public/service_manifest.gni
index b797200e..1bf9463 100644
--- a/services/service_manager/public/service_manifest.gni
+++ b/services/service_manager/public/service_manifest.gni
@@ -4,129 +4,65 @@
 
 import("//build/config/dcheck_always_on.gni")
 
-# Generates code to produce a compiled service_manager::Manifest from a JSON
-# description at build time.
+# Used to produce a Service Manifest for a Service.
 #
-# This is a temporary helper for the transition away from JSON manifests. Do not
-# introduce new service_manifest targets.
+# Service manifests may be subsequently aggregated into one or more catalog
+# manifests (see //services/catalog/public/tools/catalog.gni). A catalog
+# manifest provides the Service Manager at runtime with a static service layout
+# configuration to dictate which services are supported by the runtime
+# environment as well as how individual services may be launched and
+# interconnected.
 #
-# This template yields a source_set target which defines a symbol named
-# "${name}::GetManifest()" where ${name} is the service name given in the
-# target.
+# Note that this target may be used to produce partial manifests, and partial
+# manifests may be aggregated by using one service_manifest target as the
+# |source_manifest| of another (see below.)
 #
-# All service_manifest targets should be replaced with in-tree C++ sources.
+# Parameters:
+#
+#   source (optional**)
+#       The manifest template for this service. Must be the name of a valid JSON
+#       file.
+#
+#   source_manifest (optional**)
+#       The manifest template for this service. Must be the name of another
+#       service_manifest target.
+#
+#       ** NOTE: Either |source| OR |source_manifest| MUST be specified.
+#
+#   name (optional)
+#       The name of the service whose manifest is to be generated. A script
+#       validates that the value of this parameter matches the name set in the
+#       source manifest and raises an error if it does not match.
+#
+#   overlays (optional)
+#       A list of other manifest targets whose outputs should be overlayed onto
+#       the source manifest before emitting the final output. Overlays are
+#       applied in-order as the last step of output generation, after any
+#       |packaged_services| manifests are embedded.
+#
+#   packaged_services (optional)
+#       A list of other manifest targets whose outputs should be packaged
+#       within this output manifest, specifically within a toplevel "services"
+#       list.
+#
+#   testonly (optional)
+#
+# Outputs:
+#
+#   An instantiation of this template produces a meta manifest from the source
+#   template and the output manifests of all its |overlay| and
+#   |packaged_services|dependencies. The output file is always
+#   "$target_gen_dir/${target_name}.json".
+#
 template("service_manifest") {
-  assert(defined(invoker.source),
-         "\"source\" must be defined for the $target_name target")
+  assert(
+      defined(invoker.source) || defined(invoker.source_manifest),
+      "\"source\" or \"source_manifest\" must be defined for the $target_name target")
+  assert(
+      !defined(invoker.source) || !defined(invoker.source_manifest),
+      "Only one of \"source\" or \"source_manifest\" must be defined for the $target_name target")
 
-  generator_target_name = "${target_name}__generator"
-  generated_sources = [
-    "$target_gen_dir/${target_name}.cc",
-    "$target_gen_dir/${target_name}.h",
-  ]
-
-  # We prefer to use |name| for the generated function's namespace if a
-  # |generated_namespace| isn't explicitly defined. It turns out that we also
-  # have a few targets which don't specify a |name| though; they all have unique
-  # target names, so we fall back on that if necessary. The important detail is
-  # that all generated GetManifest() functions should live in their own
-  # namespace, and with the current (and final) set of service_manifest targets
-  # in the tree, these rules accomplish that.
-  if (defined(invoker.generated_namespace)) {
-    output_namespace = invoker.generated_namespace
-  } else if (defined(invoker.name)) {
-    output_namespace = invoker.name
-  } else {
-    output_namespace = invoker.target_name
-  }
-
-  write_file("$target_gen_dir/${target_name}.namespace", output_namespace)
-
-  source_set(target_name) {
-    testonly = defined(invoker.testonly) && invoker.testonly
-    sources = generated_sources
-    public_deps = [
-      ":$generator_target_name",
-    ]
-
-    deps = []
-    if (defined(invoker.packaged_services)) {
-      deps += invoker.packaged_services
-    }
-    if (defined(invoker.overlays)) {
-      deps += invoker.overlays
-    }
-  }
-
-  collator_target_name = "${target_name}__collator"
-
-  action(generator_target_name) {
-    testonly = defined(invoker.testonly) && invoker.testonly
-    script = "//services/catalog/public/tools/sourcify_manifest.py"
-
-    inputs = [
-      "//services/catalog/public/tools/catalog.cc.tmpl",
-      "//services/catalog/public/tools/catalog.h.tmpl",
-      invoker.source,
-    ]
-    outputs = generated_sources
-
-    submanifest_info = []
-    if (defined(invoker.packaged_services)) {
-      foreach(submanifest, invoker.packaged_services) {
-        manifest_dir = get_label_info(submanifest, "target_gen_dir")
-        manifest_target_name = get_label_info(submanifest, "name")
-        manifest_namespace_input =
-            "$manifest_dir/${manifest_target_name}.namespace"
-        manifest_namespace_path =
-            rebase_path(manifest_namespace_input, root_build_dir)
-        manifest_header_base =
-            rebase_path(manifest_dir, root_gen_dir) + "/${manifest_target_name}"
-        submanifest_info +=
-            [ "packaged@$manifest_namespace_path@$manifest_header_base" ]
-      }
-    }
-    if (defined(invoker.overlays)) {
-      foreach(submanifest, invoker.overlays) {
-        manifest_dir = get_label_info(submanifest, "target_gen_dir")
-        manifest_target_name = get_label_info(submanifest, "name")
-        manifest_namespace_input =
-            "$manifest_dir/${manifest_target_name}.namespace"
-        manifest_namespace_path =
-            rebase_path(manifest_namespace_input, root_build_dir)
-        manifest_header_base =
-            rebase_path(manifest_dir, root_gen_dir) + "/${manifest_target_name}"
-        submanifest_info +=
-            [ "overlay@$manifest_namespace_path@$manifest_header_base" ]
-      }
-    }
-
-    submanifest_info_file =
-        "${target_gen_dir}/${invoker.target_name}.submanifest_info"
-    write_file(submanifest_info_file, submanifest_info)
-
-    args = [
-      "--root-manifest=" + rebase_path(invoker.source, root_build_dir),
-      "--submanifest-info=" +
-          rebase_path(submanifest_info_file, root_build_dir),
-      "--output-function-name=${output_namespace}::GetManifest",
-      "--output-filename-base=" +
-          rebase_path("$target_gen_dir/${invoker.target_name}", root_build_dir),
-      "--module-path=" +
-          rebase_path("$target_gen_dir/${invoker.target_name}", root_gen_dir),
-    ]
-
-    # We inherit a public dependency on the collator because service_manifest
-    # dependents still expect to use its generated JSON output. We don't
-    # actually depend on the collated JSON at all here, since packaged services
-    # and overlays are added in the generated C++ code by referring to other
-    # generated C++ code.
-    public_deps = [
-      ":$collator_target_name",
-    ]
-  }
-
-  action(collator_target_name) {
+  action(target_name) {
     testonly = defined(invoker.testonly) && invoker.testonly
 
     script =
@@ -137,16 +73,25 @@
       deps += invoker.deps
     }
 
+    if (defined(invoker.source)) {
+      source = invoker.source
+    } else {
+      source_target_dir =
+          get_label_info(invoker.source_manifest, "target_gen_dir")
+      source_target_name = get_label_info(invoker.source_manifest, "name")
+      source = "$source_target_dir/${source_target_name}.json"
+      deps += [ invoker.source_manifest ]
+    }
     inputs = [
-      invoker.source,
+      source,
     ]
 
-    output = "$target_gen_dir/${invoker.target_name}.json"
+    output = "$target_gen_dir/${target_name}.json"
     outputs = [
       output,
     ]
 
-    rebase_parent = rebase_path(invoker.source, root_build_dir)
+    rebase_parent = rebase_path(source, root_build_dir)
     rebase_output = rebase_path(output, root_build_dir)
 
     args = [
diff --git a/services/service_manager/service_manager.cc b/services/service_manager/service_manager.cc
index c42fa2a..a169c130 100644
--- a/services/service_manager/service_manager.cc
+++ b/services/service_manager/service_manager.cc
@@ -946,42 +946,24 @@
 
 ServiceManager::ServiceManager(std::unique_ptr<ServiceProcessLauncherFactory>
                                    service_process_launcher_factory,
-                               const std::vector<Manifest>& manifests)
-    : catalog_(manifests),
+                               const std::vector<Manifest>& manifests,
+                               catalog::ManifestProvider* manifest_provider)
+    : catalog_(nullptr, manifests, manifest_provider),
       identity_to_instance_(std::make_unique<IdentityToInstanceMap>()),
       service_process_launcher_factory_(
           std::move(service_process_launcher_factory)) {
-  InterfaceProviderSpec spec;
-  spec.provides[kCapability_ServiceManager].insert(
-      "service_manager.mojom.ServiceManager");
-  spec.requires["*"].insert("service_manager:service_factory");
-  InterfaceProviderSpecMap specs;
-  specs[mojom::kServiceManager_ConnectorSpec] = std::move(spec);
+  InitBuiltinServices();
+}
 
-  service_manager_instance_ = CreateInstance(
-      GetServiceManagerInstanceIdentity(), InstanceType::kSingleton,
-      std::move(specs), catalog::ServiceOptions());
-
-  mojom::ServicePtr service;
-  service_binding_.Bind(mojo::MakeRequest(&service));
-  service_manager_instance_->StartWithService(std::move(service));
-
-  InterfaceProviderSpec catalog_spec;
-  catalog_spec.provides["directory"].insert("filesystem.mojom.Directory");
-  catalog_spec.provides["catalog:catalog"].insert("catalog.mojom.Catalog");
-  catalog_spec.provides["control"].insert("catalog.mojom.CatalogControl");
-  InterfaceProviderSpecMap catalog_specs;
-  catalog_specs[mojom::kServiceManager_ConnectorSpec] = std::move(catalog_spec);
-
-  Identity id{catalog::mojom::kServiceName, kSystemInstanceGroup, base::Token{},
-              base::Token::CreateRandom()};
-  Instance* instance =
-      CreateInstance(id, InstanceType::kSingleton, std::move(catalog_specs),
-                     catalog::ServiceOptions());
-
-  mojom::ServicePtr catalog_service;
-  catalog_.BindServiceRequest(mojo::MakeRequest(&catalog_service));
-  instance->StartWithService(std::move(catalog_service));
+ServiceManager::ServiceManager(std::unique_ptr<ServiceProcessLauncherFactory>
+                                   service_process_launcher_factory,
+                               std::unique_ptr<base::Value> catalog_contents,
+                               catalog::ManifestProvider* manifest_provider)
+    : catalog_(std::move(catalog_contents), {}, manifest_provider),
+      identity_to_instance_(std::make_unique<IdentityToInstanceMap>()),
+      service_process_launcher_factory_(
+          std::move(service_process_launcher_factory)) {
+  InitBuiltinServices();
 }
 
 ServiceManager::~ServiceManager() {
@@ -1236,6 +1218,43 @@
   Connect(std::move(params));
 }
 
+////////////////////////////////////////////////////////////////////////////////
+// ServiceManager, private:
+
+void ServiceManager::InitBuiltinServices() {
+  InterfaceProviderSpec spec;
+  spec.provides[kCapability_ServiceManager].insert(
+      "service_manager.mojom.ServiceManager");
+  spec.requires["*"].insert("service_manager:service_factory");
+  InterfaceProviderSpecMap specs;
+  specs[mojom::kServiceManager_ConnectorSpec] = std::move(spec);
+
+  service_manager_instance_ = CreateInstance(
+      GetServiceManagerInstanceIdentity(), InstanceType::kSingleton,
+      std::move(specs), catalog::ServiceOptions());
+
+  mojom::ServicePtr service;
+  service_binding_.Bind(mojo::MakeRequest(&service));
+  service_manager_instance_->StartWithService(std::move(service));
+
+  InterfaceProviderSpec catalog_spec;
+  catalog_spec.provides["directory"].insert("filesystem.mojom.Directory");
+  catalog_spec.provides["catalog:catalog"].insert("catalog.mojom.Catalog");
+  catalog_spec.provides["control"].insert("catalog.mojom.CatalogControl");
+  InterfaceProviderSpecMap catalog_specs;
+  catalog_specs[mojom::kServiceManager_ConnectorSpec] = std::move(catalog_spec);
+
+  Identity id{catalog::mojom::kServiceName, kSystemInstanceGroup, base::Token{},
+              base::Token::CreateRandom()};
+  Instance* instance =
+      CreateInstance(id, InstanceType::kSingleton, std::move(catalog_specs),
+                     catalog::ServiceOptions());
+
+  mojom::ServicePtr catalog_service;
+  catalog_.BindServiceRequest(mojo::MakeRequest(&catalog_service));
+  instance->StartWithService(std::move(catalog_service));
+}
+
 void ServiceManager::OnInstanceError(Instance* instance) {
   // We never clean up the ServiceManager's own instance.
   if (instance == service_manager_instance_)
diff --git a/services/service_manager/service_manager.h b/services/service_manager/service_manager.h
index 8bf2428..2a046f9 100644
--- a/services/service_manager/service_manager.h
+++ b/services/service_manager/service_manager.h
@@ -12,6 +12,7 @@
 #include "base/macros.h"
 #include "base/memory/weak_ptr.h"
 #include "base/process/process.h"
+#include "base/values.h"
 #include "mojo/public/cpp/bindings/binding_set.h"
 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
 #include "services/catalog/catalog.h"
@@ -28,6 +29,11 @@
 #include "services/service_manager/public/mojom/service_factory.mojom.h"
 #include "services/service_manager/public/mojom/service_manager.mojom.h"
 #include "services/service_manager/runner/host/service_process_launcher_factory.h"
+#include "services/service_manager/service_overrides.h"
+
+namespace catalog {
+class ManifestProvider;
+}
 
 namespace service_manager {
 
@@ -44,9 +50,25 @@
   // |service_process_launcher_factory| is an instance of an object capable of
   // vending implementations of ServiceProcessLauncher, e.g. for out-of-process
   // execution.
-  explicit ServiceManager(std::unique_ptr<ServiceProcessLauncherFactory>
-                              service_process_launcher_factory,
-                          const std::vector<Manifest>& manifests);
+  explicit ServiceManager(
+      std::unique_ptr<ServiceProcessLauncherFactory>
+          service_process_launcher_factory,
+      const std::vector<Manifest>& manifests,
+      catalog::ManifestProvider* manifest_provider = nullptr);
+
+  // |service_process_launcher_factory| is an instance of an object capable of
+  // vending implementations of ServiceProcessLauncher, e.g. for out-of-process
+  // execution.
+  //
+  // |catalog_contents|, if not null, will be used to prepoulate the service
+  // manager catalog with a fixed data set. |manifest_provider|, if not null,
+  // will be consulted for dynamic manifest resolution if a manifest is not
+  // found within the catalog; if used, |manifest_provider| is not owned and
+  // must outlive this ServiceManager.
+  ServiceManager(std::unique_ptr<ServiceProcessLauncherFactory>
+                     service_process_launcher_factory,
+                 std::unique_ptr<base::Value> catalog_contents,
+                 catalog::ManifestProvider* manifest_provider);
   ~ServiceManager() override;
 
   // Provide a callback to be notified whenever an instance is destroyed.
@@ -106,6 +128,8 @@
     kSingleton,
   };
 
+  void InitBuiltinServices();
+
   // Called when |instance| encounters an error. Deletes |instance|.
   void OnInstanceError(Instance* instance);
 
diff --git a/services/service_manager/service_overrides.cc b/services/service_manager/service_overrides.cc
new file mode 100644
index 0000000..2dfa8b5
--- /dev/null
+++ b/services/service_manager/service_overrides.cc
@@ -0,0 +1,78 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/service_manager/service_overrides.h"
+
+#include "base/base_paths.h"
+#include "base/path_service.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+
+namespace service_manager {
+
+namespace {
+
+const char kExecutablePathKey[] = "executable_path";
+const char kPackageNameKey[] = "package_name";
+
+}  // namespace
+
+ServiceOverrides::Entry::Entry() {}
+
+ServiceOverrides::Entry::~Entry() {}
+
+ServiceOverrides::ServiceOverrides(std::unique_ptr<base::Value> overrides) {
+  const base::DictionaryValue* services;
+  if (!overrides->GetAsDictionary(&services)) {
+    LOG(ERROR) << "Expected top-level dictionary.";
+    return;
+  }
+
+  base::DictionaryValue::Iterator service_iter(*services);
+  for (; !service_iter.IsAtEnd(); service_iter.Advance()) {
+    Entry& new_entry = entries_[service_iter.key()];
+
+    const base::DictionaryValue* value;
+    if (!service_iter.value().GetAsDictionary(&value)) {
+      LOG(ERROR) << "Expected service entry to be a dictionary.";
+      return;
+    }
+
+    std::string executable_path_value;
+    if (value->GetString(kExecutablePathKey, &executable_path_value)) {
+      base::FilePath exe_dir;
+      CHECK(base::PathService::Get(base::DIR_EXE, &exe_dir));
+#if defined(OS_WIN)
+      executable_path_value += ".exe";
+      base::ReplaceFirstSubstringAfterOffset(
+          &executable_path_value, 0, "@EXE_DIR",
+          base::UTF16ToUTF8(exe_dir.value()));
+      new_entry.executable_path =
+          base::FilePath(base::UTF8ToUTF16(executable_path_value));
+#else
+      base::ReplaceFirstSubstringAfterOffset(
+          &executable_path_value, 0, "@EXE_DIR",
+          exe_dir.value());
+      new_entry.executable_path = base::FilePath(executable_path_value);
+#endif
+    }
+
+    value->GetString(kPackageNameKey, &new_entry.package_name);
+  }
+}
+
+ServiceOverrides::~ServiceOverrides() {}
+
+bool ServiceOverrides::GetExecutablePathOverride(
+    const std::string& service_name,
+    base::FilePath* path) const {
+  auto iter = entries_.find(service_name);
+  if (iter == entries_.end() || iter->second.executable_path.empty())
+    return false;
+
+  *path = iter->second.executable_path;
+  return true;
+}
+
+}  // namespace service_manager
diff --git a/services/service_manager/service_overrides.h b/services/service_manager/service_overrides.h
new file mode 100644
index 0000000..1478ef76
--- /dev/null
+++ b/services/service_manager/service_overrides.h
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_SERVICE_MANAGER_SERVICE_OVERRIDES_H_
+#define SERVICES_SERVICE_MANAGER_SERVICE_OVERRIDES_H_
+
+#include <map>
+#include <memory>
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "base/values.h"
+
+namespace service_manager {
+
+class ServiceOverrides {
+ public:
+  struct Entry {
+    Entry();
+    ~Entry();
+
+    base::FilePath executable_path;
+    std::string package_name;
+  };
+
+  explicit ServiceOverrides(std::unique_ptr<base::Value> overrides);
+  ~ServiceOverrides();
+
+  bool GetExecutablePathOverride(const std::string& service_name,
+                                 base::FilePath* path) const;
+
+  const std::map<std::string, Entry>& entries() const { return entries_; }
+
+ private:
+  std::map<std::string, Entry> entries_;
+
+  DISALLOW_COPY_AND_ASSIGN(ServiceOverrides);
+};
+
+}  // namespace service_manager
+
+#endif  // SERVICES_SERVICE_MANAGER_SERVICE_OVERRIDES_H_
diff --git a/services/service_manager/standalone/context.cc b/services/service_manager/standalone/context.cc
index 12594f8..b7908da 100644
--- a/services/service_manager/standalone/context.cc
+++ b/services/service_manager/standalone/context.cc
@@ -70,7 +70,21 @@
 
 Context::Context(
     ServiceProcessLauncherDelegate* service_process_launcher_delegate,
-    const std::vector<Manifest>& manifests) {
+    const std::vector<Manifest>& manifests)
+    : Context(service_process_launcher_delegate, nullptr, manifests) {}
+
+Context::Context(
+    ServiceProcessLauncherDelegate* service_process_launcher_delegate,
+    std::unique_ptr<base::Value> catalog_contents)
+    : Context(service_process_launcher_delegate,
+              std::move(catalog_contents),
+              std::vector<Manifest>()) {}
+
+Context::Context(
+    ServiceProcessLauncherDelegate* service_process_launcher_delegate,
+    std::unique_ptr<base::Value> catalog_contents,
+    const std::vector<Manifest>& manifests)
+    : main_entry_time_(base::Time::Now()) {
   TRACE_EVENT0("service_manager", "Context::Context");
 
   std::unique_ptr<ServiceProcessLauncherFactory>
@@ -83,8 +97,14 @@
       std::make_unique<ServiceProcessLauncherFactoryImpl>(
           service_process_launcher_delegate);
 #endif
-  service_manager_ = std::make_unique<ServiceManager>(
-      std::move(service_process_launcher_factory), manifests);
+  if (!manifests.empty()) {
+    service_manager_ = std::make_unique<ServiceManager>(
+        std::move(service_process_launcher_factory), manifests, nullptr);
+  } else {
+    service_manager_ = std::make_unique<ServiceManager>(
+        std::move(service_process_launcher_factory),
+        std::move(catalog_contents), nullptr);
+  }
 }
 
 Context::~Context() = default;
diff --git a/services/service_manager/standalone/context.h b/services/service_manager/standalone/context.h
index 234a9aa..2fc0c97aa 100644
--- a/services/service_manager/standalone/context.h
+++ b/services/service_manager/standalone/context.h
@@ -11,6 +11,7 @@
 #include "base/callback.h"
 #include "base/macros.h"
 #include "base/time/time.h"
+#include "base/values.h"
 #include "services/service_manager/public/cpp/manifest.h"
 #include "services/service_manager/runner/host/service_process_launcher_delegate.h"
 
@@ -23,6 +24,11 @@
  public:
   Context(ServiceProcessLauncherDelegate* launcher_delegate,
           const std::vector<Manifest>& manifests);
+  Context(ServiceProcessLauncherDelegate* launcher_delegate,
+          std::unique_ptr<base::Value> catalog_contents);
+  Context(ServiceProcessLauncherDelegate* launcher_delegate,
+          std::unique_ptr<base::Value> catalog_contents,
+          const std::vector<Manifest>& manifests);
   ~Context();
 
   // Run the application specified on the command line, and run |on_quit| when
diff --git a/services/service_manager/tests/BUILD.gn b/services/service_manager/tests/BUILD.gn
index db89a4b..b3cc60a 100644
--- a/services/service_manager/tests/BUILD.gn
+++ b/services/service_manager/tests/BUILD.gn
@@ -26,9 +26,11 @@
     "//mojo/public/cpp/bindings",
     "//mojo/public/cpp/system",
     "//services/catalog:lib",
+    "//services/catalog:unittests",
     "//services/service_manager",
     "//services/service_manager/background:lib",
     "//services/service_manager/background/tests:unittests",
+    "//services/service_manager/embedder:unittests",
     "//services/service_manager/public/cpp",
     "//services/service_manager/public/cpp:unittests",
     "//services/service_manager/public/cpp/test:test_support",
diff --git a/services/service_manager/tests/service_manager/service_manager_listener_unittest.cc b/services/service_manager/tests/service_manager/service_manager_listener_unittest.cc
index 6927e6c8..e922c84 100644
--- a/services/service_manager/tests/service_manager/service_manager_listener_unittest.cc
+++ b/services/service_manager/tests/service_manager/service_manager_listener_unittest.cc
@@ -103,8 +103,7 @@
 class ServiceManagerListenerTest : public testing::Test, public Service {
  public:
   ServiceManagerListenerTest()
-      : service_manager_(nullptr, GetTestManifests()) {}
-
+      : service_manager_(nullptr, GetTestManifests(), nullptr) {}
   ~ServiceManagerListenerTest() override = default;
 
   Connector* connector() { return service_binding_.GetConnector(); }
diff --git a/services/service_manager/zygote/host/zygote_communication_linux.cc b/services/service_manager/zygote/host/zygote_communication_linux.cc
index 9d27af2..9e6a5fa 100644
--- a/services/service_manager/zygote/host/zygote_communication_linux.cc
+++ b/services/service_manager/zygote/host/zygote_communication_linux.cc
@@ -16,6 +16,7 @@
 #include "base/pickle.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/posix/unix_domain_socket.h"
+#include "base/stl_util.h"
 #include "services/service_manager/embedder/result_codes.h"
 #include "services/service_manager/embedder/switches.h"
 #include "services/service_manager/sandbox/switches.h"
@@ -244,7 +245,7 @@
       service_manager::switches::kNoSandbox,
   };
   cmd_line.CopySwitchesFrom(browser_command_line, kForwardSwitches,
-                            arraysize(kForwardSwitches));
+                            base::size(kForwardSwitches));
 
   pid_ = std::move(launcher).Run(&cmd_line, &control_fd_);
 
diff --git a/skia/ext/convolver_unittest.cc b/skia/ext/convolver_unittest.cc
index 626b9a9..9518c15 100644
--- a/skia/ext/convolver_unittest.cc
+++ b/skia/ext/convolver_unittest.cc
@@ -10,7 +10,7 @@
 #include <vector>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "skia/ext/convolver.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -146,7 +146,7 @@
 
   // An all-zero filter is handled correctly, all factors ignored
   static const float factors1[] = { 0.0f, 0.0f, 0.0f };
-  filter.AddFilter(11, factors1, arraysize(factors1));
+  filter.AddFilter(11, factors1, base::size(factors1));
   ASSERT_EQ(0, filter.max_filter());
   ASSERT_EQ(1, filter.num_values());
 
@@ -157,7 +157,7 @@
 
   // Zeroes on the left are ignored
   static const float factors2[] = { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f };
-  filter.AddFilter(22, factors2, arraysize(factors2));
+  filter.AddFilter(22, factors2, base::size(factors2));
   ASSERT_EQ(4, filter.max_filter());
   ASSERT_EQ(2, filter.num_values());
 
@@ -168,7 +168,7 @@
 
   // Zeroes on the right are ignored
   static const float factors3[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f };
-  filter.AddFilter(33, factors3, arraysize(factors3));
+  filter.AddFilter(33, factors3, base::size(factors3));
   ASSERT_EQ(5, filter.max_filter());
   ASSERT_EQ(3, filter.num_values());
 
@@ -179,7 +179,7 @@
 
   // Zeroes in leading & trailing positions
   static const float factors4[] = { 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f };
-  filter.AddFilter(44, factors4, arraysize(factors4));
+  filter.AddFilter(44, factors4, base::size(factors4));
   ASSERT_EQ(5, filter.max_filter());  // No change from existing value.
   ASSERT_EQ(4, filter.num_values());
 
@@ -192,7 +192,7 @@
   static const float factors5[] = { 0.0f, 0.0f,
                                     1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
                                     0.0f };
-  filter.AddFilter(55, factors5, arraysize(factors5));
+  filter.AddFilter(55, factors5, base::size(factors5));
   ASSERT_EQ(6, filter.max_filter());
   ASSERT_EQ(5, filter.num_values());
 
@@ -203,7 +203,7 @@
 
   // All-zero filters after the first one also work
   static const float factors6[] = { 0.0f };
-  filter.AddFilter(66, factors6, arraysize(factors6));
+  filter.AddFilter(66, factors6, base::size(factors6));
   ASSERT_EQ(6, filter.max_filter());
   ASSERT_EQ(6, filter.num_values());
 
@@ -223,16 +223,16 @@
   for (unsigned int p = 0; p < dest_width; ++p) {
     unsigned int offset = source_width * p / dest_width;
     EXPECT_LT(offset, source_width);
-    x_filter.AddFilter(offset, filter,
-                       std::min<int>(arraysize(filter),
-                                     source_width - offset));
+    x_filter.AddFilter(
+        offset, filter,
+        std::min<int>(base::size(filter), source_width - offset));
   }
   x_filter.PaddingForSIMD();
   for (unsigned int p = 0; p < dest_height; ++p) {
     unsigned int offset = source_height * p / dest_height;
-    y_filter.AddFilter(offset, filter,
-                       std::min<int>(arraysize(filter),
-                                     source_height - offset));
+    y_filter.AddFilter(
+        offset, filter,
+        std::min<int>(base::size(filter), source_height - offset));
   }
   y_filter.PaddingForSIMD();
 
@@ -317,10 +317,10 @@
   srand(static_cast<unsigned int>(time(0)));
 
   // Loop over some specific source and destination dimensions.
-  for (unsigned int i = 0; i < arraysize(source_sizes); ++i) {
+  for (unsigned int i = 0; i < base::size(source_sizes); ++i) {
     unsigned int source_width = source_sizes[i][0];
     unsigned int source_height = source_sizes[i][1];
-    for (unsigned int j = 0; j < arraysize(dest_sizes); ++j) {
+    for (unsigned int j = 0; j < base::size(dest_sizes); ++j) {
       unsigned int dest_width = dest_sizes[j][0];
       unsigned int dest_height = dest_sizes[j][1];
       VerifySIMD(source_width, source_height, dest_width, dest_height);
diff --git a/skia/ext/image_operations_bench.cc b/skia/ext/image_operations_bench.cc
index 2c1c167..9433a73 100644
--- a/skia/ext/image_operations_bench.cc
+++ b/skia/ext/image_operations_bench.cc
@@ -20,7 +20,7 @@
 
 #include "base/command_line.h"
 #include "base/format_macros.h"
-#include "base/macros.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"
@@ -51,7 +51,7 @@
 // Returns true on success, false otherwise.
 bool StringToMethod(const std::string& arg,
                     skia::ImageOperations::ResizeMethod* method) {
-  for (size_t i = 0; i < arraysize(resize_methods); ++i) {
+  for (size_t i = 0; i < base::size(resize_methods); ++i) {
     if (base::EqualsCaseInsensitiveASCII(arg, resize_methods[i].name)) {
       *method = resize_methods[i].method;
       return true;
@@ -61,7 +61,7 @@
 }
 
 const char* MethodToString(skia::ImageOperations::ResizeMethod method) {
-  for (size_t i = 0; i < arraysize(resize_methods); ++i) {
+  for (size_t i = 0; i < base::size(resize_methods); ++i) {
     if (method == resize_methods[i].method) {
       return resize_methods[i].name;
     }
@@ -72,7 +72,7 @@
 // Prints all supported resize methods
 void PrintMethods() {
   bool print_comma = false;
-  for (size_t i = 0; i < arraysize(resize_methods); ++i) {
+  for (size_t i = 0; i < base::size(resize_methods); ++i) {
     if (print_comma) {
       printf(",");
     } else {
diff --git a/skia/ext/image_operations_unittest.cc b/skia/ext/image_operations_unittest.cc
index 3e2ce90e..8970955 100644
--- a/skia/ext/image_operations_unittest.cc
+++ b/skia/ext/image_operations_unittest.cc
@@ -12,8 +12,8 @@
 
 #include "base/compiler_specific.h"
 #include "base/files/file_util.h"
-#include "base/macros.h"
 #include "base/numerics/math_constants.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "skia/ext/image_operations.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -206,7 +206,7 @@
 }
 
 // Types defined outside of the ResizeShouldAverageColors test to allow
-// use of the arraysize() macro.
+// use of the base::size() macro.
 //
 // 'max_color_distance_override' is used in a max() call together with
 // the value of 'max_color_distance' defined in a TestedPixel instance.
@@ -263,8 +263,7 @@
   float max_observed_distance = 0.0f;
   bool all_pixels_ok = true;
 
-  for (size_t pixel_index = 0;
-       pixel_index < arraysize(tested_pixels);
+  for (size_t pixel_index = 0; pixel_index < base::size(tested_pixels);
        ++pixel_index) {
     const TestedPixel& tested_pixel = tested_pixels[pixel_index];
 
@@ -465,7 +464,7 @@
 
   // Compute the expected (average) color
   const SkColor colors[] = { checker_color1, checker_color2 };
-  const SkColor average_color = AveragePixel(colors, arraysize(colors));
+  const SkColor average_color = AveragePixel(colors, base::size(colors));
 
   static const TestedResizeMethod tested_methods[] = {
     { skia::ImageOperations::RESIZE_GOOD,     "GOOD",     0.0f },
@@ -487,8 +486,7 @@
   // and check each tested pixel against the expected average color.
   bool all_methods_ok = true;
 
-  for (size_t method_index = 0;
-       method_index < arraysize(tested_methods);
+  for (size_t method_index = 0; method_index < base::size(tested_methods);
        ++method_index) {
     bool pass = true;
     CheckResizeMethodShouldAverageGrid(src,
diff --git a/skia/ext/skia_utils_ios.mm b/skia/ext/skia_utils_ios.mm
index 33a6f244..a234f55c 100644
--- a/skia/ext/skia_utils_ios.mm
+++ b/skia/ext/skia_utils_ios.mm
@@ -12,7 +12,7 @@
 #include "base/ios/ios_util.h"
 #include "base/logging.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "third_party/skia/include/utils/mac/SkCGUtils.h"
 
 namespace {
@@ -21,10 +21,10 @@
 
 // Returns whether the data encodes an ico image.
 bool EncodesIcoImage(NSData* image_data) {
-  if (image_data.length < arraysize(kICOHeaderMagic))
+  if (image_data.length < base::size(kICOHeaderMagic))
     return false;
   return memcmp(kICOHeaderMagic, image_data.bytes,
-                arraysize(kICOHeaderMagic)) == 0;
+                base::size(kICOHeaderMagic)) == 0;
 }
 
 }  // namespace
diff --git a/testing/android/native_test/native_test_launcher.cc b/testing/android/native_test/native_test_launcher.cc
index ce12df8..441422b 100644
--- a/testing/android/native_test/native_test_launcher.cc
+++ b/testing/android/native_test/native_test_launcher.cc
@@ -22,6 +22,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/stringprintf.h"
 #include "base/test/test_support_android.h"
 #include "gtest/gtest.h"
@@ -77,7 +78,7 @@
     const JavaParamRef<jstring>& jtest_data_dir) {
   // Command line initialized basically, will be fully initialized later.
   static const char* const kInitialArgv[] = { "ChromeTestActivity" };
-  base::CommandLine::Init(arraysize(kInitialArgv), kInitialArgv);
+  base::CommandLine::Init(base::size(kInitialArgv), kInitialArgv);
 
   std::vector<std::string> args;
 
diff --git a/testing/buildbot/chromium.chromiumos.json b/testing/buildbot/chromium.chromiumos.json
index 386b696..424d0099 100644
--- a/testing/buildbot/chromium.chromiumos.json
+++ b/testing/buildbot/chromium.chromiumos.json
@@ -1060,6 +1060,18 @@
         "swarming": {
           "can_use_on_swarming_builders": true
         },
+        "test": "views_mus_interactive_ui_tests"
+      },
+      {
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "views_mus_unittests"
+      },
+      {
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
         "test": "views_unittests"
       },
       {
@@ -1753,6 +1765,18 @@
         "swarming": {
           "can_use_on_swarming_builders": true
         },
+        "test": "views_mus_interactive_ui_tests"
+      },
+      {
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "views_mus_unittests"
+      },
+      {
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
         "test": "views_unittests"
       },
       {
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json
index cce41ad7..d6324176 100644
--- a/testing/buildbot/chromium.memory.json
+++ b/testing/buildbot/chromium.memory.json
@@ -5035,6 +5035,24 @@
         "swarming": {
           "can_use_on_swarming_builders": true
         },
+        "test": "views_mus_interactive_ui_tests"
+      },
+      {
+        "args": [
+          "--test-launcher-print-test-stdio=always"
+        ],
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
+        "test": "views_mus_unittests"
+      },
+      {
+        "args": [
+          "--test-launcher-print-test-stdio=always"
+        ],
+        "swarming": {
+          "can_use_on_swarming_builders": true
+        },
         "test": "views_unittests"
       },
       {
@@ -6559,6 +6577,36 @@
             }
           ]
         },
+        "test": "views_mus_interactive_ui_tests"
+      },
+      {
+        "args": [
+          "--test-launcher-print-test-stdio=always"
+        ],
+        "swarming": {
+          "can_use_on_swarming_builders": true,
+          "dimension_sets": [
+            {
+              "cpu": "x86-64",
+              "os": "Ubuntu-14.04"
+            }
+          ]
+        },
+        "test": "views_mus_unittests"
+      },
+      {
+        "args": [
+          "--test-launcher-print-test-stdio=always"
+        ],
+        "swarming": {
+          "can_use_on_swarming_builders": true,
+          "dimension_sets": [
+            {
+              "cpu": "x86-64",
+              "os": "Ubuntu-14.04"
+            }
+          ]
+        },
         "test": "views_unittests"
       },
       {
diff --git a/testing/buildbot/gn_isolate_map.pyl b/testing/buildbot/gn_isolate_map.pyl
index b8683ce..8c8679aa 100644
--- a/testing/buildbot/gn_isolate_map.pyl
+++ b/testing/buildbot/gn_isolate_map.pyl
@@ -2560,6 +2560,14 @@
     "label": "//media/gpu:video_decode_accelerator_unittest",
     "type": "raw",
   },
+  "views_mus_interactive_ui_tests": {
+    "label": "//ui/views/mus:views_mus_interactive_ui_tests",
+    "type": "windowed_test_launcher",
+  },
+  "views_mus_unittests": {
+    "label": "//ui/views/mus:views_mus_unittests",
+    "type": "windowed_test_launcher",
+  },
   "views_perftests": {
     "args": [
       "--xvfb",
diff --git a/testing/buildbot/test_suites.pyl b/testing/buildbot/test_suites.pyl
index 8a64d7d..c2a972d2 100644
--- a/testing/buildbot/test_suites.pyl
+++ b/testing/buildbot/test_suites.pyl
@@ -3560,6 +3560,8 @@
         ],
       },
       'ui_chromeos_unittests': {},
+      'views_mus_unittests': {},
+      'views_mus_interactive_ui_tests': {},
       'wayland_client_perftests': {},
     },
 
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
index adf0713..bfc4a95f 100644
--- a/third_party/blink/public/platform/platform.h
+++ b/third_party/blink/public/platform/platform.h
@@ -378,7 +378,7 @@
   virtual void CacheMetadata(blink::mojom::CodeCacheType cache_type,
                              const WebURL&,
                              base::Time response_time,
-                             const char* data,
+                             const uint8_t* data,
                              size_t data_size) {}
 
   // A request to fetch contents associated with this URL from metadata cache.
@@ -394,7 +394,7 @@
   virtual void CacheMetadataInCacheStorage(
       const WebURL&,
       base::Time response_time,
-      const char* data,
+      const uint8_t* data,
       size_t data_size,
       const blink::WebSecurityOrigin& cache_storage_origin,
       const WebString& cache_storage_cache_name) {}
diff --git a/third_party/blink/renderer/bindings/core/v8/script_streamer_test.cc b/third_party/blink/renderer/bindings/core/v8/script_streamer_test.cc
index e2bcccb..061729c 100644
--- a/third_party/blink/renderer/bindings/core/v8/script_streamer_test.cc
+++ b/third_party/blink/renderer/bindings/core/v8/script_streamer_test.cc
@@ -311,7 +311,7 @@
   SingleCachedMetadataHandler* cache_handler = GetResource()->CacheHandler();
   EXPECT_TRUE(cache_handler);
   cache_handler->SetCachedMetadata(V8CodeCache::TagForCodeCache(cache_handler),
-                                   "X", 1,
+                                   reinterpret_cast<const uint8_t*>("X"), 1,
                                    CachedMetadataHandler::kCacheLocally);
 
   AppendPadding();
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc b/third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc
index 9faae3c..84209a8 100644
--- a/third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc
+++ b/third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc
@@ -77,11 +77,10 @@
   scoped_refptr<CachedMetadata> cached_metadata =
       cache_handler->GetCachedMetadata(code_cache_tag);
   DCHECK(cached_metadata);
-  const char* data = cached_metadata->Data();
+  const uint8_t* data = cached_metadata->Data();
   int length = cached_metadata->size();
   return new v8::ScriptCompiler::CachedData(
-      reinterpret_cast<const uint8_t*>(data), length,
-      v8::ScriptCompiler::CachedData::BufferNotOwned);
+      data, length, v8::ScriptCompiler::CachedData::BufferNotOwned);
 }
 
 std::tuple<v8::ScriptCompiler::CompileOptions,
@@ -202,7 +201,7 @@
       std::unique_ptr<v8::ScriptCompiler::CachedData> cached_data(
           v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript()));
       if (cached_data) {
-        const char* data = reinterpret_cast<const char*>(cached_data->data);
+        const uint8_t* data = cached_data->data;
         int length = cached_data->length;
         if (length > 1024) {
           // Omit histogram samples for small cache data to avoid outliers.
@@ -253,9 +252,9 @@
     SingleCachedMetadataHandler* cache_handler) {
   double now = WTF::CurrentTime();
   cache_handler->ClearCachedMetadata(CachedMetadataHandler::kCacheLocally);
-  cache_handler->SetCachedMetadata(TagForTimeStamp(cache_handler),
-                                   reinterpret_cast<char*>(&now), sizeof(now),
-                                   CachedMetadataHandler::kSendToPlatform);
+  cache_handler->SetCachedMetadata(
+      TagForTimeStamp(cache_handler), reinterpret_cast<uint8_t*>(&now),
+      sizeof(now), CachedMetadataHandler::kSendToPlatform);
 }
 
 // static
@@ -302,10 +301,9 @@
           .ToLocal(&unbound_script)) {
     cached_data.reset(v8::ScriptCompiler::CreateCodeCache(unbound_script));
     if (cached_data && cached_data->length) {
-      cached_metadata = CachedMetadata::Create(
-          CacheTag(kCacheTagCode, encoding.GetName()),
-          reinterpret_cast<const char*>(cached_data->data),
-          cached_data->length);
+      cached_metadata =
+          CachedMetadata::Create(CacheTag(kCacheTagCode, encoding.GetName()),
+                                 cached_data->data, cached_data->length);
     }
   }
 
diff --git a/third_party/blink/renderer/core/display_lock/display_lock_context.cc b/third_party/blink/renderer/core/display_lock/display_lock_context.cc
index d58b177..5e631a67 100644
--- a/third_party/blink/renderer/core/display_lock/display_lock_context.cc
+++ b/third_party/blink/renderer/core/display_lock/display_lock_context.cc
@@ -139,8 +139,8 @@
 }
 
 ScriptPromise DisplayLockContext::update(ScriptState* script_state) {
-  // Reject if we're unlocked or disconnected.
-  if (state_ == kUnlocked || !element_->isConnected())
+  // Reject if we're unlocked.
+  if (state_ == kUnlocked)
     return GetRejectedPromise(script_state);
 
   // If we have a resolver, then we're at least updating already, just return
@@ -151,13 +151,16 @@
   }
 
   update_resolver_ = ScriptPromiseResolver::Create(script_state);
-  StartUpdateIfNeeded();
+  // We only need to kick off an Update if we're in a locked state, all other
+  // states are already updating.
+  if (state_ == kLocked)
+    StartUpdate();
   return update_resolver_->Promise();
 }
 
 ScriptPromise DisplayLockContext::commit(ScriptState* script_state) {
-  // Reject if we're unlocked or disonnected.
-  if (state_ == kUnlocked || !element_->isConnected())
+  // Reject if we're unlocked.
+  if (state_ == kUnlocked)
     return GetRejectedPromise(script_state);
 
   // If we have a resolver, we must be committing already, just return the same
@@ -388,19 +391,12 @@
       layout_invalidation_reason::kDisplayLockCommitting);
 }
 
-void DisplayLockContext::StartUpdateIfNeeded() {
-  // We should not be calling this if we're unlocked.
-  DCHECK_NE(state_, kUnlocked);
-  // Any state other than kLocked means that we are already in the process of
-  // updating/committing, so we can piggy back on that process without kicking
-  // off any new updates.
-  if (state_ != kLocked)
-    return;
-
+void DisplayLockContext::StartUpdate() {
+  DCHECK_EQ(state_, kLocked);
+  state_ = kUpdating;
   // We don't need to mark anything dirty since the budget will take care of
   // that for us.
   update_budget_ = CreateNewBudget();
-  state_ = kUpdating;
   ScheduleAnimation();
 }
 
@@ -513,8 +509,6 @@
 }
 
 void DisplayLockContext::ScheduleAnimation() {
-  DCHECK(element_->isConnected());
-
   // Schedule an animation to perform the lifecycle phases.
   element_->GetDocument().GetPage()->Animator().ScheduleVisualUpdate(
       element_->GetDocument().GetFrame());
diff --git a/third_party/blink/renderer/core/display_lock/display_lock_context.h b/third_party/blink/renderer/core/display_lock/display_lock_context.h
index 06c767c..b8956f9 100644
--- a/third_party/blink/renderer/core/display_lock/display_lock_context.h
+++ b/third_party/blink/renderer/core/display_lock/display_lock_context.h
@@ -149,7 +149,7 @@
   // Initiate a commit.
   void StartCommit();
   // Initiate an update.
-  void StartUpdateIfNeeded();
+  void StartUpdate();
 
   // The following functions propagate dirty bits from the locked element up to
   // the ancestors in order to be reached. They return true if the element or
diff --git a/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc b/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc
index cca943f..52ec30b 100644
--- a/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc
+++ b/third_party/blink/renderer/core/exported/web_meaningful_layouts_test.cc
@@ -18,8 +18,6 @@
 
   LoadURL("https://example.com/index.html");
 
-  main_resource.Start();
-
   // Write 201 characters.
   const char* ten_characters = "0123456789";
   for (int i = 0; i < 20; ++i)
@@ -38,8 +36,6 @@
 
   LoadURL("https://example.com/index.html");
 
-  main_resource.Start();
-
   // Write 200 characters.
   const char* ten_characters = "0123456789";
   for (int i = 0; i < 20; ++i)
@@ -69,8 +65,6 @@
 
   LoadURL("https://example.com/index.html");
 
-  main_resource.Start();
-
   // Write <200 characters.
   main_resource.Write("less than 200 characters.");
 
@@ -118,7 +112,8 @@
 
 TEST_F(WebMeaningfulLayoutsTest, FinishedParsingThenLoading) {
   SimRequest main_resource("https://example.com/index.html", "text/html");
-  SimRequest image_resource("https://example.com/cat.png", "image/png");
+  SimSubresourceRequest image_resource("https://example.com/cat.png",
+                                       "image/png");
 
   LoadURL("https://example.com/index.html");
 
@@ -172,11 +167,11 @@
 TEST_F(WebMeaningfulLayoutsTest,
        NoOverflowInIncrementVisuallyNonEmptyPixelCount) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest svg_resource("https://example.com/test.svg", "image/svg+xml");
+  SimSubresourceRequest svg_resource("https://example.com/test.svg",
+                                     "image/svg+xml");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
   main_resource.Write("<DOCTYPE html><body><img src=\"test.svg\">");
   // Run pending tasks to initiate the request to test.svg.
   test::RunPendingTasks();
@@ -201,7 +196,8 @@
 // a pending stylesheet if a layout is triggered before it loads.
 TEST_F(WebMeaningfulLayoutsTest, LayoutWithPendingRenderBlockingStylesheet) {
   SimRequest main_resource("https://example.com/index.html", "text/html");
-  SimRequest style_resource("https://example.com/style.css", "text/css");
+  SimSubresourceRequest style_resource("https://example.com/style.css",
+                                       "text/css");
 
   LoadURL("https://example.com/index.html");
 
@@ -221,7 +217,8 @@
 // be considered a pending stylesheet if a layout is triggered before it loads.
 TEST_F(WebMeaningfulLayoutsTest, LayoutWithPendingScriptBlockingStylesheet) {
   SimRequest main_resource("https://example.com/index.html", "text/html");
-  SimRequest style_resource("https://example.com/style.css", "text/css");
+  SimSubresourceRequest style_resource("https://example.com/style.css",
+                                       "text/css");
 
   LoadURL("https://example.com/index.html");
 
@@ -240,7 +237,8 @@
 // a pending stylesheet if a layout is triggered before it loads.
 TEST_F(WebMeaningfulLayoutsTest, LayoutWithPendingImportInHead) {
   SimRequest main_resource("https://example.com/index.html", "text/html");
-  SimRequest import_resource("https://example.com/import.html", "text/html");
+  SimSubresourceRequest import_resource("https://example.com/import.html",
+                                        "text/html");
 
   LoadURL("https://example.com/index.html");
 
@@ -262,7 +260,8 @@
 // a pending stylesheet if a layout is triggered before it loads.
 TEST_F(WebMeaningfulLayoutsTest, LayoutWithPendingImportInBody) {
   SimRequest main_resource("https://example.com/index.html", "text/html");
-  SimRequest import_resource("https://example.com/import.html", "text/html");
+  SimSubresourceRequest import_resource("https://example.com/import.html",
+                                        "text/html");
 
   LoadURL("https://example.com/index.html");
 
diff --git a/third_party/blink/renderer/core/exported/web_node_test.cc b/third_party/blink/renderer/core/exported/web_node_test.cc
index 90573e49..0e034621 100644
--- a/third_party/blink/renderer/core/exported/web_node_test.cc
+++ b/third_party/blink/renderer/core/exported/web_node_test.cc
@@ -62,12 +62,12 @@
 
 TEST_F(WebNodeSimTest, IsFocused) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_resource("https://example.com/style.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/style.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.html");
   WebView().MainFrameWidget()->Resize(WebSize(800, 600));
 
-  main_resource.Start();
   main_resource.Write(R"HTML(
     <!DOCTYPE html>
     <link rel=stylesheet href=style.css>
diff --git a/third_party/blink/renderer/core/frame/ad_tracker_test.cc b/third_party/blink/renderer/core/frame/ad_tracker_test.cc
index baeb1734d..bb5bf78 100644
--- a/third_party/blink/renderer/core/frame/ad_tracker_test.cc
+++ b/third_party/blink/renderer/core/frame/ad_tracker_test.cc
@@ -204,7 +204,6 @@
         "https://example.com/test.html", "text/html");
 
     LoadURL("https://example.com/test.html");
-    main_resource_->Start();
     ad_tracker_ = MakeGarbageCollected<TestAdTracker>(GetDocument().GetFrame());
     GetDocument().GetFrame()->SetAdTrackerForTesting(ad_tracker_);
   }
@@ -226,8 +225,8 @@
 TEST_F(AdTrackerSimTest, ScriptLoadedWhileExecutingAdScript) {
   const char kAdUrl[] = "https://example.com/ad_script.js";
   const char kVanillaUrl[] = "https://example.com/vanilla_script.js";
-  SimRequest ad_resource(kAdUrl, "text/javascript");
-  SimRequest vanilla_script(kVanillaUrl, "text/javascript");
+  SimSubresourceRequest ad_resource(kAdUrl, "text/javascript");
+  SimSubresourceRequest vanilla_script(kVanillaUrl, "text/javascript");
 
   ad_tracker_->SetAdSuffix("ad_script.js");
 
@@ -249,7 +248,7 @@
 // Unknown script running in an ad context should be labeled as ad script.
 TEST_F(AdTrackerSimTest, ScriptDetectedByContext) {
   const char kAdScriptUrl[] = "https://example.com/ad_script.js";
-  SimRequest ad_script(kAdScriptUrl, "text/javascript");
+  SimSubresourceRequest ad_script(kAdScriptUrl, "text/javascript");
 
   ad_tracker_->SetAdSuffix("ad_script.js");
 
@@ -273,9 +272,10 @@
 }
 
 TEST_F(AdTrackerSimTest, AdResourceDetectedByContext) {
-  SimRequest ad_script("https://example.com/ad_script.js", "text/javascript");
+  SimSubresourceRequest ad_script("https://example.com/ad_script.js",
+                                  "text/javascript");
   SimRequest ad_frame("https://example.com/ad_frame.html", "text/html");
-  SimRequest foo_css("https://example.com/foo.css", "text/style");
+  SimSubresourceRequest foo_css("https://example.com/foo.css", "text/style");
   ad_tracker_->SetAdSuffix("ad_script.js");
 
   // Create an iframe that's considered an ad.
@@ -306,7 +306,8 @@
 // When inline script in an ad frame inserts an iframe into a non-ad frame, the
 // new frame should be considered an ad.
 TEST_F(AdTrackerSimTest, InlineAdScriptRunningInNonAdContext) {
-  SimRequest ad_script("https://example.com/ad_script.js", "text/javascript");
+  SimSubresourceRequest ad_script("https://example.com/ad_script.js",
+                                  "text/javascript");
   SimRequest ad_iframe("https://example.com/ad_frame.html", "text/html");
   ad_tracker_->SetAdSuffix("ad_script.js");
 
@@ -340,8 +341,8 @@
 TEST_F(AdTrackerSimTest, ImageLoadedWhileExecutingAdScript) {
   const char kAdUrl[] = "https://example.com/ad_script.js";
   const char kVanillaUrl[] = "https://example.com/vanilla_image.jpg";
-  SimRequest ad_resource(kAdUrl, "text/javascript");
-  SimRequest vanilla_image(kVanillaUrl, "image/jpeg");
+  SimSubresourceRequest ad_resource(kAdUrl, "text/javascript");
+  SimSubresourceRequest vanilla_image(kVanillaUrl, "image/jpeg");
 
   ad_tracker_->SetAdSuffix("ad_script.js");
 
@@ -364,8 +365,8 @@
 TEST_F(AdTrackerSimTest, FrameLoadedWhileExecutingAdScript) {
   const char kAdUrl[] = "https://example.com/ad_script.js";
   const char kVanillaUrl[] = "https://example.com/vanilla_page.html";
-  SimRequest ad_resource(kAdUrl, "text/javascript");
-  SimRequest vanilla_page(kVanillaUrl, "text/html");
+  SimSubresourceRequest ad_resource(kAdUrl, "text/javascript");
+  SimSubresourceRequest vanilla_page(kVanillaUrl, "text/html");
 
   ad_tracker_->SetAdSuffix("ad_script.js");
 
@@ -391,8 +392,8 @@
   // gets tagged as an ad script in the subframe, that shouldn't cause it to
   // be treated as an ad in the main frame.
   SimRequest iframe_resource("https://example.com/iframe.html", "text/html");
-  SimRequest library_resource("https://example.com/library.js",
-                              "text/javascript");
+  SimSubresourceRequest library_resource("https://example.com/library.js",
+                                         "text/javascript");
 
   main_resource_->Complete(R"HTML(
     <script src=library.js></script>
@@ -404,8 +405,8 @@
 
   // The library script is loaded for a second time, this time in the
   // subframe. Mark it as an ad.
-  SimRequest library_resource_for_subframe("https://example.com/library.js",
-                                           "text/javascript");
+  SimSubresourceRequest library_resource_for_subframe(
+      "https://example.com/library.js", "text/javascript");
   ad_tracker_->SetAdSuffix("library.js");
 
   iframe_resource.Complete(R"HTML(
@@ -426,7 +427,8 @@
 }
 
 TEST_F(AdTrackerSimTest, SameOriginSubframeFromAdScript) {
-  SimRequest ad_resource("https://example.com/ad_script.js", "text/javascript");
+  SimSubresourceRequest ad_resource("https://example.com/ad_script.js",
+                                    "text/javascript");
   SimRequest iframe_resource("https://example.com/iframe.html", "text/html");
   ad_tracker_->SetAdSuffix("ad_script.js");
 
@@ -448,7 +450,8 @@
 }
 
 TEST_F(AdTrackerSimTest, SameOriginDocWrittenSubframeFromAdScript) {
-  SimRequest ad_resource("https://example.com/ad_script.js", "text/javascript");
+  SimSubresourceRequest ad_resource("https://example.com/ad_script.js",
+                                    "text/javascript");
   ad_tracker_->SetAdSuffix("ad_script.js");
 
   main_resource_->Complete(R"HTML(
@@ -479,7 +482,6 @@
         "https://example.com/test.html", "text/html");
 
     LoadURL("https://example.com/test.html");
-    main_resource_->Start();
   }
 
   std::unique_ptr<SimRequest> main_resource_;
diff --git a/third_party/blink/renderer/core/frame/document_loading_rendering_test.cc b/third_party/blink/renderer/core/frame/document_loading_rendering_test.cc
index fa4bf503..2b4e3f2 100644
--- a/third_party/blink/renderer/core/frame/document_loading_rendering_test.cc
+++ b/third_party/blink/renderer/core/frame/document_loading_rendering_test.cc
@@ -25,8 +25,6 @@
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
-
   // Still in the head, should not resume commits.
   main_resource.Write("<!DOCTYPE html>");
   EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
@@ -46,12 +44,11 @@
 TEST_F(DocumentLoadingRenderingTest,
        ShouldResumeCommitsAfterBodyIfSheetsLoaded) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
-
   // Still in the head, should not resume commits.
   main_resource.Write("<!DOCTYPE html><link rel=stylesheet href=test.css>");
   EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
@@ -76,12 +73,11 @@
 
 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterSheetsLoaded) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
-
   // Still in the head, should not resume commits.
   main_resource.Write("<!DOCTYPE html><link rel=stylesheet href=test.css>");
   EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
@@ -107,12 +103,11 @@
 TEST_F(DocumentLoadingRenderingTest,
        ShouldResumeCommitsAfterDocumentElementWithNoSheets) {
   SimRequest main_resource("https://example.com/test.svg", "image/svg+xml");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.svg");
 
-  main_resource.Start();
-
   // Sheet loading and no documentElement, so don't resume.
   main_resource.Write("<?xml-stylesheet type='text/css' href='test.css'?>");
   EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
@@ -132,12 +127,11 @@
 
 TEST_F(DocumentLoadingRenderingTest, ShouldResumeCommitsAfterSheetsLoadForXml) {
   SimRequest main_resource("https://example.com/test.svg", "image/svg+xml");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.svg");
 
-  main_resource.Start();
-
   // Not done parsing.
   main_resource.Write("<?xml-stylesheet type='text/css' href='test.css'?>");
   EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
@@ -165,8 +159,6 @@
 
   LoadURL("https://example.com/test.svg");
 
-  main_resource.Start();
-
   // Finish parsing, no sheets loading so resume.
   main_resource.Finish();
   EXPECT_FALSE(Compositor().DeferMainFrameUpdate());
@@ -177,7 +169,6 @@
 
   LoadURL("https://example.com/test.png");
 
-  main_resource.Start();
   EXPECT_TRUE(Compositor().DeferMainFrameUpdate());
 
   // Not really a valid image but enough for the test. ImageDocuments should
@@ -191,13 +182,13 @@
 
 TEST_F(DocumentLoadingRenderingTest, ShouldScheduleFrameAfterSheetsLoaded) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest first_css_resource("https://example.com/first.css", "text/css");
-  SimRequest second_css_resource("https://example.com/second.css", "text/css");
+  SimSubresourceRequest first_css_resource("https://example.com/first.css",
+                                           "text/css");
+  SimSubresourceRequest second_css_resource("https://example.com/second.css",
+                                            "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
-
   // Load a stylesheet.
   main_resource.Write(
       "<!DOCTYPE html><link id=link rel=stylesheet href=first.css>");
@@ -228,7 +219,8 @@
        ShouldNotPaintIframeContentWithPendingSheets) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
   SimRequest frame_resource("https://example.com/frame.html", "text/html");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -313,7 +305,8 @@
        ShouldThrottleIframeLifecycleUntilPendingSheetsLoaded) {
   SimRequest main_resource("https://example.com/main.html", "text/html");
   SimRequest frame_resource("https://example.com/frame.html", "text/html");
-  SimRequest css_resource("https://example.com/frame.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/frame.css",
+                                     "text/css");
 
   LoadURL("https://example.com/main.html");
 
@@ -359,13 +352,13 @@
 TEST_F(DocumentLoadingRenderingTest,
        ShouldContinuePaintingWhenSheetsStartedAfterBody) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
-  SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
+  SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
-
   // Still in the head, should not paint.
   main_resource.Write("<!DOCTYPE html><link rel=stylesheet href=testHead.css>");
   EXPECT_FALSE(GetDocument().IsRenderingReady());
@@ -399,14 +392,13 @@
 TEST_F(DocumentLoadingRenderingTest,
        returnBoundingClientRectCorrectlyWhileLoadingImport) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest import_resource("https://example.com/import.css", "text/css");
+  SimSubresourceRequest import_resource("https://example.com/import.css",
+                                        "text/css");
 
   LoadURL("https://example.com/test.html");
 
   WebView().MainFrameWidget()->Resize(WebSize(800, 600));
 
-  main_resource.Start();
-
   main_resource.Write(R"HTML(
     <html><body>
       <div id='test' style='font-size: 16px'>test</div>
@@ -436,12 +428,11 @@
 
 TEST_F(DocumentLoadingRenderingTest, StableSVGStopStylingWhileLoadingImport) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest import_resource("https://example.com/import.css", "text/css");
+  SimSubresourceRequest import_resource("https://example.com/import.css",
+                                        "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
-
   main_resource.Write(R"HTML(
     <html><body>
       <svg>
diff --git a/third_party/blink/renderer/core/frame/local_frame_view_test.cc b/third_party/blink/renderer/core/frame/local_frame_view_test.cc
index 014270e..731bafc 100644
--- a/third_party/blink/renderer/core/frame/local_frame_view_test.cc
+++ b/third_party/blink/renderer/core/frame/local_frame_view_test.cc
@@ -273,7 +273,8 @@
 // See https://crbug.com/851338.
 TEST_F(LocalFrameViewSimTest, FragmentNavChangesFocusWhileRenderingBlocked) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_resource("https://example.com/sheet.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/sheet.css",
+                                     "text/css");
   LoadURL("https://example.com/test.html");
 
   main_resource.Complete(R"HTML(
diff --git a/third_party/blink/renderer/core/html/anchor_element_metrics_test.cc b/third_party/blink/renderer/core/html/anchor_element_metrics_test.cc
index 2f9e521..9969e82 100644
--- a/third_party/blink/renderer/core/html/anchor_element_metrics_test.cc
+++ b/third_party/blink/renderer/core/html/anchor_element_metrics_test.cc
@@ -241,7 +241,8 @@
 TEST_F(AnchorElementMetricsTest, AnchorFeatureInIframe) {
   SimRequest main_resource("https://example.com/page1", "text/html");
   SimRequest iframe_resource("https://example.com/iframe.html", "text/html");
-  SimRequest image_resource("https://example.com/cat.png", "image/png");
+  SimSubresourceRequest image_resource("https://example.com/cat.png",
+                                       "image/png");
 
   LoadURL("https://example.com/page1");
 
@@ -314,7 +315,8 @@
 TEST_F(AnchorElementMetricsTest, AnchorFeatureInIframeNonHttp) {
   SimRequest main_resource("content://example.com/page1", "text/html");
   SimRequest iframe_resource("https://example.com/iframe.html", "text/html");
-  SimRequest image_resource("https://example.com/cat.png", "image/png");
+  SimSubresourceRequest image_resource("https://example.com/cat.png",
+                                       "image/png");
 
   LoadURL("content://example.com/page1");
 
diff --git a/third_party/blink/renderer/core/html/imports/html_import_sheets_test.cc b/third_party/blink/renderer/core/html/imports/html_import_sheets_test.cc
index 3f20a86d..a7fc505 100644
--- a/third_party/blink/renderer/core/html/imports/html_import_sheets_test.cc
+++ b/third_party/blink/renderer/core/html/imports/html_import_sheets_test.cc
@@ -22,7 +22,8 @@
 
 TEST_F(HTMLImportSheetsTest, NeedsActiveStyleUpdate) {
   SimRequest main_resource("https://example.com/", "text/html");
-  SimRequest import_resource("https://example.com/import.html", "text/html");
+  SimSubresourceRequest import_resource("https://example.com/import.html",
+                                        "text/html");
 
   LoadURL("https://example.com/");
   main_resource.Complete("<link id=link rel=import href=import.html>");
@@ -42,7 +43,8 @@
 
 TEST_F(HTMLImportSheetsTest, UpdateStyleSheetList) {
   SimRequest main_resource("https://example.com/", "text/html");
-  SimRequest import_resource("https://example.com/import.html", "text/html");
+  SimSubresourceRequest import_resource("https://example.com/import.html",
+                                        "text/html");
 
   LoadURL("https://example.com/");
   main_resource.Complete("<link id=link rel=import href=import.html>");
diff --git a/third_party/blink/renderer/core/html/link_element_loading_test.cc b/third_party/blink/renderer/core/html/link_element_loading_test.cc
index c82c759..027810f 100644
--- a/third_party/blink/renderer/core/html/link_element_loading_test.cc
+++ b/third_party/blink/renderer/core/html/link_element_loading_test.cc
@@ -15,11 +15,11 @@
 TEST_F(LinkElementLoadingTest,
        ShouldCancelLoadingStyleSheetIfLinkElementIsDisconnected) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
   main_resource.Write(
       "<!DOCTYPE html><link id=link rel=stylesheet href=test.css>");
 
diff --git a/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc b/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc
index 2c95e30..586cfc4 100644
--- a/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc
+++ b/third_party/blink/renderer/core/html/parser/html_document_parser_loading_test.cc
@@ -39,7 +39,8 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldNotPauseParsingForExternalStylesheetsInHead) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -62,7 +63,8 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldNotPauseParsingForExternalStylesheetsImportedInHead) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -87,8 +89,10 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldPauseParsingForExternalStylesheetsInBody) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
-  SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
+  SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -124,17 +128,17 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldPauseParsingForExternalStylesheetsInBodyIncremental) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
-  SimRequest css_body_resource1("https://example.com/testBody1.css",
-                                "text/css");
-  SimRequest css_body_resource2("https://example.com/testBody2.css",
-                                "text/css");
-  SimRequest css_body_resource3("https://example.com/testBody3.css",
-                                "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
+  SimSubresourceRequest css_body_resource1("https://example.com/testBody1.css",
+                                           "text/css");
+  SimSubresourceRequest css_body_resource2("https://example.com/testBody2.css",
+                                           "text/css");
+  SimSubresourceRequest css_body_resource3("https://example.com/testBody3.css",
+                                           "text/css");
 
   LoadURL("https://example.com/test.html");
 
-  main_resource.Start();
   main_resource.Write(R"HTML(
     <!DOCTYPE html>
     <html><head>
@@ -211,7 +215,8 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldNotPauseParsingForExternalNonMatchingStylesheetsInBody) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -237,8 +242,10 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldPauseParsingForExternalStylesheetsImportedInBody) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
-  SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
+  SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -276,8 +283,10 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldPauseParsingForExternalStylesheetsWrittenInBody) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
-  SimRequest css_body_resource("https://example.com/testBody.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
+  SimSubresourceRequest css_body_resource("https://example.com/testBody.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -315,7 +324,8 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        PendingHeadStylesheetShouldNotBlockParserForBodyInlineStyle) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -340,7 +350,8 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        PendingHeadStylesheetShouldNotBlockParserForBodyShadowDom) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_head_resource("https://example.com/testHead.css", "text/css");
+  SimSubresourceRequest css_head_resource("https://example.com/testHead.css",
+                                          "text/css");
 
   LoadURL("https://example.com/test.html");
 
@@ -365,8 +376,8 @@
 TEST_P(HTMLDocumentParserLoadingTest,
        ShouldNotPauseParsingForExternalStylesheetsAttachedInBody) {
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_async_resource("https://example.com/testAsync.css",
-                                "text/css");
+  SimSubresourceRequest css_async_resource("https://example.com/testAsync.css",
+                                           "text/css");
 
   LoadURL("https://example.com/test.html");
 
diff --git a/third_party/blink/renderer/core/loader/programmatic_scroll_test.cc b/third_party/blink/renderer/core/loader/programmatic_scroll_test.cc
index 229a829..9ec575f 100644
--- a/third_party/blink/renderer/core/loader/programmatic_scroll_test.cc
+++ b/third_party/blink/renderer/core/loader/programmatic_scroll_test.cc
@@ -143,14 +143,14 @@
 TEST_F(ProgrammaticScrollSimTest, NavigateToHash) {
   WebView().MainFrameWidget()->Resize(WebSize(800, 600));
   SimRequest main_resource("https://example.com/test.html#target", "text/html");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   LoadURL("https://example.com/test.html#target");
 
   // Finish loading the main document before the stylesheet is loaded so that
   // rendering is blocked when parsing finishes. This will delay closing the
   // document until the load event.
-  main_resource.Start();
   main_resource.Write(
       "<!DOCTYPE html><link id=link rel=stylesheet href=test.css>");
   css_resource.Start();
diff --git a/third_party/blink/renderer/core/loader/resource/script_resource.cc b/third_party/blink/renderer/core/loader/resource/script_resource.cc
index 2c8da582..c560fee0 100644
--- a/third_party/blink/renderer/core/loader/resource/script_resource.cc
+++ b/third_party/blink/renderer/core/loader/resource/script_resource.cc
@@ -194,7 +194,7 @@
       Encoding(), std::move(send_callback));
 }
 
-void ScriptResource::SetSerializedCachedMetadata(const char* data,
+void ScriptResource::SetSerializedCachedMetadata(const uint8_t* data,
                                                  size_t size) {
   Resource::SetSerializedCachedMetadata(data, size);
   ScriptCachedMetadataHandler* cache_handler =
diff --git a/third_party/blink/renderer/core/loader/resource/script_resource.h b/third_party/blink/renderer/core/loader/resource/script_resource.h
index 6c4759b..ab73c8f 100644
--- a/third_party/blink/renderer/core/loader/resource/script_resource.h
+++ b/third_party/blink/renderer/core/loader/resource/script_resource.h
@@ -95,7 +95,7 @@
   void OnMemoryDump(WebMemoryDumpLevelOfDetail,
                     WebProcessMemoryDump*) const override;
 
-  void SetSerializedCachedMetadata(const char*, size_t) override;
+  void SetSerializedCachedMetadata(const uint8_t*, size_t) override;
 
   // Returns true if streaming was successfully started (or if an active
   // streamer is already running)
diff --git a/third_party/blink/renderer/core/loader/threadable_loader.cc b/third_party/blink/renderer/core/loader/threadable_loader.cc
index 289de9bb2..d450340 100644
--- a/third_party/blink/renderer/core/loader/threadable_loader.cc
+++ b/third_party/blink/renderer/core/loader/threadable_loader.cc
@@ -912,13 +912,14 @@
 }
 
 void ThreadableLoader::SetSerializedCachedMetadata(Resource*,
-                                                   const char* data,
+                                                   const uint8_t* data,
                                                    size_t size) {
   checker_.SetSerializedCachedMetadata();
 
   if (!actual_request_.IsNull())
     return;
-  client_->DidReceiveCachedMetadata(data, SafeCast<int>(size));
+  client_->DidReceiveCachedMetadata(reinterpret_cast<const char*>(data),
+                                    SafeCast<int>(size));
 }
 
 void ThreadableLoader::DataReceived(Resource* resource,
diff --git a/third_party/blink/renderer/core/loader/threadable_loader.h b/third_party/blink/renderer/core/loader/threadable_loader.h
index b9dee0a..78c9c47 100644
--- a/third_party/blink/renderer/core/loader/threadable_loader.h
+++ b/third_party/blink/renderer/core/loader/threadable_loader.h
@@ -156,7 +156,7 @@
   void ResponseReceived(Resource*,
                         const ResourceResponse&,
                         std::unique_ptr<WebDataConsumerHandle>) override;
-  void SetSerializedCachedMetadata(Resource*, const char*, size_t) override;
+  void SetSerializedCachedMetadata(Resource*, const uint8_t*, size_t) override;
   void DataReceived(Resource*, const char* data, size_t data_length) override;
   bool RedirectReceived(Resource*,
                         const ResourceRequest&,
diff --git a/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc b/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc
index 4a7dbdc..92fa8695 100644
--- a/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc
+++ b/third_party/blink/renderer/core/page/scrolling/root_scroller_test.cc
@@ -1463,7 +1463,6 @@
   WebView().MainFrameWidget()->Resize(WebSize(800, 600));
   SimRequest request("https://example.com/test.html", "text/html");
   LoadURL("https://example.com/test.html");
-  request.Start();
   request.Write(R"HTML(
           <!DOCTYPE html>
           <style>
@@ -1525,7 +1524,6 @@
   WebView().MainFrameWidget()->Resize(WebSize(800, 600));
   SimRequest request("https://example.com/test.html", "text/html");
   LoadURL("https://example.com/test.html");
-  request.Start();
   request.Write(R"HTML(
           <!DOCTYPE html>
           <style>
@@ -2268,7 +2266,6 @@
   WebView().MainFrameImpl()->FirstChild()->ToWebLocalFrame()->StartNavigation(
       request);
 
-  child_request2.Start();
   child_request2.Write(R"HTML(
         <!DOCTYPE html>
   )HTML");
diff --git a/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc b/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc
index 74d5ac3..19eb930 100644
--- a/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc
+++ b/third_party/blink/renderer/core/resize_observer/resize_observer_test.cc
@@ -59,7 +59,6 @@
   SimRequest main_resource("https://example.com/", "text/html");
   LoadURL("https://example.com/");
 
-  main_resource.Start();
   main_resource.Write(R"HTML(
     <div id='domTarget' style='width:100px;height:100px'>yo</div>
     <svg height='200' width='200'>
diff --git a/third_party/blink/renderer/core/scheduler/virtual_time_test.cc b/third_party/blink/renderer/core/scheduler/virtual_time_test.cc
index 6ee40db..56df3ae 100644
--- a/third_party/blink/renderer/core/scheduler/virtual_time_test.cc
+++ b/third_party/blink/renderer/core/scheduler/virtual_time_test.cc
@@ -149,14 +149,13 @@
   EXPECT_TRUE(WebView().Scheduler()->VirtualTimeAllowedToAdvance());
 
   SimRequest main_resource("https://example.com/test.html", "text/html");
-  SimRequest css_resource("https://example.com/test.css", "text/css");
+  SimSubresourceRequest css_resource("https://example.com/test.css",
+                                     "text/css");
 
   // Loading, virtual time should not advance.
   LoadURL("https://example.com/test.html");
   EXPECT_FALSE(WebView().Scheduler()->VirtualTimeAllowedToAdvance());
 
-  main_resource.Start();
-
   // Still Loading, virtual time should not advance.
   main_resource.Write("<!DOCTYPE html><link rel=stylesheet href=test.css>");
   EXPECT_FALSE(WebView().Scheduler()->VirtualTimeAllowedToAdvance());
diff --git a/third_party/blink/renderer/core/style/shadow_data.cc b/third_party/blink/renderer/core/style/shadow_data.cc
index acb6c05..ea0d0c0 100644
--- a/third_party/blink/renderer/core/style/shadow_data.cc
+++ b/third_party/blink/renderer/core/style/shadow_data.cc
@@ -50,9 +50,11 @@
 }
 
 FloatRectOutsets ShadowData::RectOutsets() const {
-  // 3 * skBlurRadiusToSigma(blur()) is how Skia implements the radius of a
-  // blur. See also https://crbug.com/624175.
-  float blur_and_spread = ceil(3 * SkBlurRadiusToSigma(Blur())) + Spread();
+  // 3 * sigma is how Skia computes the box blur extent.
+  // See also https://crbug.com/624175.
+  // TODO(fmalita): since the blur extent must reflect rasterization bounds,
+  // its value should be queried from Skia (pending API availability).
+  float blur_and_spread = ceil(3 * BlurRadiusToStdDev(Blur())) + Spread();
   return FloatRectOutsets(
       blur_and_spread - Y() /* top */, blur_and_spread + X() /* right */,
       blur_and_spread + Y() /* bottom */, blur_and_spread - X() /* left */);
diff --git a/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc b/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc
index b9bc178..b5687e943 100644
--- a/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc
+++ b/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc
@@ -201,7 +201,8 @@
 
 TEST_F(SVGImagePageVisibilityTest, PageVisibilityHiddenToVisible) {
   SimRequest main_resource("https://example.com/", "text/html");
-  SimRequest image_resource("https://example.com/image.svg", "image/svg+xml");
+  SimSubresourceRequest image_resource("https://example.com/image.svg",
+                                       "image/svg+xml");
   LoadURL("https://example.com/");
   main_resource.Complete("<img src='image.svg' width='100' id='image'>");
   image_resource.Complete(kAnimatedDocument);
diff --git a/third_party/blink/renderer/core/testing/sim/sim_network.cc b/third_party/blink/renderer/core/testing/sim/sim_network.cc
index cd1d48b7..5980e819 100644
--- a/third_party/blink/renderer/core/testing/sim/sim_network.cc
+++ b/third_party/blink/renderer/core/testing/sim/sim_network.cc
@@ -86,12 +86,12 @@
   current_request_ = nullptr;
 }
 
-void SimNetwork::AddRequest(SimRequest& request) {
-  requests_.insert(request.Url(), &request);
+void SimNetwork::AddRequest(SimRequestBase& request) {
+  requests_.insert(request.url_, &request);
 }
 
-void SimNetwork::RemoveRequest(SimRequest& request) {
-  requests_.erase(request.Url());
+void SimNetwork::RemoveRequest(SimRequestBase& request) {
+  requests_.erase(request.url_);
 }
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_network.h b/third_party/blink/renderer/core/testing/sim/sim_network.h
index aadd07b..bce0ac075 100644
--- a/third_party/blink/renderer/core/testing/sim/sim_network.h
+++ b/third_party/blink/renderer/core/testing/sim/sim_network.h
@@ -13,26 +13,27 @@
 
 namespace blink {
 
-class SimRequest;
+class SimRequestBase;
 class WebURLLoaderClient;
 class WebURLResponse;
 
 // Simulates a network with precise flow control so you can make requests
 // return, write data, and finish in a specific order in a unit test. One of
-// these must be created before using the SimRequest to issue requests.
+// these must be created before using the SimRequestBase to issue requests.
 class SimNetwork final : public WebURLLoaderTestDelegate {
  public:
   SimNetwork();
   ~SimNetwork() override;
 
  private:
-  friend class SimRequest;
+  friend class SimRequestBase;
+  friend class SimSubresourceRequest;
 
   static SimNetwork& Current();
 
   void ServePendingRequests();
-  void AddRequest(SimRequest&);
-  void RemoveRequest(SimRequest&);
+  void AddRequest(SimRequestBase&);
+  void RemoveRequest(SimRequestBase&);
 
   // WebURLLoaderTestDelegate
   void DidReceiveResponse(WebURLLoaderClient*, const WebURLResponse&) override;
@@ -50,8 +51,8 @@
                         int64_t total_encoded_body_length,
                         int64_t total_decoded_body_length) override;
 
-  SimRequest* current_request_;
-  HashMap<String, SimRequest*> requests_;
+  SimRequestBase* current_request_;
+  HashMap<String, SimRequestBase*> requests_;
 };
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_request.cc b/third_party/blink/renderer/core/testing/sim/sim_request.cc
index 29db248..bed57b7 100644
--- a/third_party/blink/renderer/core/testing/sim/sim_request.cc
+++ b/third_party/blink/renderer/core/testing/sim/sim_request.cc
@@ -12,11 +12,14 @@
 
 namespace blink {
 
-SimRequest::SimRequest(String url, String mime_type)
+SimRequestBase::SimRequestBase(String url,
+                               String mime_type,
+                               bool start_immediately)
     : url_(url),
+      start_immediately_(start_immediately),
+      started_(false),
       client_(nullptr),
-      total_encoded_data_length_(0),
-      is_ready_(false) {
+      total_encoded_data_length_(0) {
   KURL full_url(url);
   WebURLResponse response(full_url);
   response.SetMIMEType(mime_type);
@@ -26,43 +29,51 @@
   SimNetwork::Current().AddRequest(*this);
 }
 
-SimRequest::~SimRequest() {
-  DCHECK(!is_ready_);
+SimRequestBase::~SimRequestBase() {
+  DCHECK(!client_);
 }
 
-void SimRequest::DidReceiveResponse(WebURLLoaderClient* client,
-                                    const WebURLResponse& response) {
+void SimRequestBase::DidReceiveResponse(WebURLLoaderClient* client,
+                                        const WebURLResponse& response) {
   client_ = client;
   response_ = response;
-  is_ready_ = true;
+  started_ = false;
+  if (start_immediately_)
+    StartInternal();
 }
 
-void SimRequest::DidFail(const WebURLError& error) {
+void SimRequestBase::DidFail(const WebURLError& error) {
   error_ = error;
 }
 
-void SimRequest::Start() {
-  SimNetwork::Current().ServePendingRequests();
-  DCHECK(is_ready_);
+void SimRequestBase::StartInternal() {
+  DCHECK(!started_);
+  started_ = true;
   client_->DidReceiveResponse(response_);
 }
 
-void SimRequest::Write(const String& data) {
-  DCHECK(is_ready_);
+void SimRequestBase::Write(const String& data) {
+  if (!started_)
+    ServePending();
+  DCHECK(started_);
   DCHECK(!error_);
   total_encoded_data_length_ += data.length();
   client_->DidReceiveData(data.Utf8().data(), data.length());
 }
 
-void SimRequest::Write(const Vector<char>& data) {
-  DCHECK(is_ready_);
+void SimRequestBase::Write(const Vector<char>& data) {
+  if (!started_)
+    ServePending();
+  DCHECK(started_);
   DCHECK(!error_);
   total_encoded_data_length_ += data.size();
   client_->DidReceiveData(data.data(), data.size());
 }
 
-void SimRequest::Finish() {
-  DCHECK(is_ready_);
+void SimRequestBase::Finish() {
+  if (!started_)
+    ServePending();
+  DCHECK(started_);
   if (error_) {
     client_->DidFail(*error_, total_encoded_data_length_,
                      total_encoded_data_length_, total_encoded_data_length_);
@@ -76,26 +87,50 @@
   Reset();
 }
 
-void SimRequest::Complete(const String& data) {
-  Start();
+void SimRequestBase::Complete(const String& data) {
+  if (!started_)
+    ServePending();
+  if (!started_)
+    StartInternal();
   if (!data.IsEmpty())
     Write(data);
   Finish();
 }
 
-void SimRequest::Complete(const Vector<char>& data) {
-  Start();
+void SimRequestBase::Complete(const Vector<char>& data) {
+  if (!started_)
+    ServePending();
+  if (!started_)
+    StartInternal();
   if (!data.IsEmpty())
     Write(data);
   Finish();
 }
 
-void SimRequest::Reset() {
-  is_ready_ = false;
+void SimRequestBase::Reset() {
+  started_ = false;
   client_ = nullptr;
   Platform::Current()->GetURLLoaderMockFactory()->UnregisterURL(KURL(url_));
-
   SimNetwork::Current().RemoveRequest(*this);
 }
 
+void SimRequestBase::ServePending() {
+  SimNetwork::Current().ServePendingRequests();
+}
+
+SimRequest::SimRequest(String url, String mime_type)
+    : SimRequestBase(url, mime_type, true /* start_immediately */) {}
+
+SimRequest::~SimRequest() = default;
+
+SimSubresourceRequest::SimSubresourceRequest(String url, String mime_type)
+    : SimRequestBase(url, mime_type, false /* start_immediately */) {}
+
+SimSubresourceRequest::~SimSubresourceRequest() = default;
+
+void SimSubresourceRequest::Start() {
+  ServePending();
+  StartInternal();
+}
+
 }  // namespace blink
diff --git a/third_party/blink/renderer/core/testing/sim/sim_request.h b/third_party/blink/renderer/core/testing/sim/sim_request.h
index 073d0dcc..436d4e2 100644
--- a/third_party/blink/renderer/core/testing/sim/sim_request.h
+++ b/third_party/blink/renderer/core/testing/sim/sim_request.h
@@ -17,18 +17,11 @@
 class WebURLLoaderClient;
 
 // Simulates a single request for a resource from the server. Requires a
-// SimNetwork to have been created first. Use the start(), write() and finish()
-// methods to simulate the response from the server. Note that all started
-// requests must be finished.
-class SimRequest final {
+// SimNetwork to have been created first. Use the Write(), Finish() and
+// Complete() methods to simulate the response from the server.
+// Note that all requests must be finished.
+class SimRequestBase {
  public:
-  SimRequest(String url, String mime_type);
-  ~SimRequest();
-
-  // Starts the response from the server, this is as if the headers and 200 OK
-  // reply had been received but no response body yet.
-  void Start();
-
   // Write a chunk of the response body.
   void Write(const String& data);
   void Write(const Vector<char>& data);
@@ -40,8 +33,12 @@
   void Complete(const String& data = String());
   void Complete(const Vector<char>& data);
 
-  const String& Url() const { return url_; }
-  const WebURLResponse& GetResponse() const { return response_; }
+ protected:
+  SimRequestBase(String url, String mime_type, bool start_immediately);
+  ~SimRequestBase();
+
+  void StartInternal();
+  void ServePending();
 
  private:
   friend class SimNetwork;
@@ -53,11 +50,34 @@
   void DidFail(const WebURLError&);
 
   String url_;
+  bool start_immediately_;
+  bool started_;
   WebURLResponse response_;
   base::Optional<WebURLError> error_;
   WebURLLoaderClient* client_;
   unsigned total_encoded_data_length_;
-  bool is_ready_;
+};
+
+// This request can be used as a main resource request for navigation.
+// It does not allow starting asynchronously, because that's not how
+// navigations work in reality.
+// TODO(dgozman): rename this to SimNavigationRequest or something.
+class SimRequest final : public SimRequestBase {
+ public:
+  SimRequest(String url, String mime_type);
+  ~SimRequest();
+};
+
+// This request can be started asynchronously, suited for simulating
+// delayed load of subresources.
+class SimSubresourceRequest final : public SimRequestBase {
+ public:
+  SimSubresourceRequest(String url, String mime_type);
+  ~SimSubresourceRequest();
+
+  // Starts the response from the server, this is as if the headers and 200 OK
+  // reply had been received but no response body yet.
+  void Start();
 };
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/core/workers/installed_scripts_manager.cc b/third_party/blink/renderer/core/workers/installed_scripts_manager.cc
index 6e9e5b9d..9231b4d 100644
--- a/third_party/blink/renderer/core/workers/installed_scripts_manager.cc
+++ b/third_party/blink/renderer/core/workers/installed_scripts_manager.cc
@@ -13,7 +13,7 @@
 InstalledScriptsManager::ScriptData::ScriptData(
     const KURL& script_url,
     String source_text,
-    std::unique_ptr<Vector<char>> meta_data,
+    std::unique_ptr<Vector<uint8_t>> meta_data,
     std::unique_ptr<CrossThreadHTTPHeaderMapData> header_data)
     : script_url_(script_url),
       source_text_(std::move(source_text)),
diff --git a/third_party/blink/renderer/core/workers/installed_scripts_manager.h b/third_party/blink/renderer/core/workers/installed_scripts_manager.h
index 6e267a0..6aa7363b 100644
--- a/third_party/blink/renderer/core/workers/installed_scripts_manager.h
+++ b/third_party/blink/renderer/core/workers/installed_scripts_manager.h
@@ -25,13 +25,13 @@
     ScriptData() = default;
     ScriptData(const KURL& script_url,
                String source_text,
-               std::unique_ptr<Vector<char>> meta_data,
+               std::unique_ptr<Vector<uint8_t>> meta_data,
                std::unique_ptr<CrossThreadHTTPHeaderMapData>);
     ScriptData(ScriptData&& other) = default;
     ScriptData& operator=(ScriptData&& other) = default;
 
     String TakeSourceText() { return std::move(source_text_); }
-    std::unique_ptr<Vector<char>> TakeMetaData() {
+    std::unique_ptr<Vector<uint8_t>> TakeMetaData() {
       return std::move(meta_data_);
     }
 
@@ -43,7 +43,7 @@
    private:
     KURL script_url_;
     String source_text_;
-    std::unique_ptr<Vector<char>> meta_data_;
+    std::unique_ptr<Vector<uint8_t>> meta_data_;
     HTTPHeaderMap headers_;
 
     DISALLOW_COPY_AND_ASSIGN(ScriptData);
diff --git a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
index 2c9a82e..833466a 100644
--- a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
+++ b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc
@@ -236,7 +236,7 @@
 
 void WorkerClassicScriptLoader::DidReceiveCachedMetadata(const char* data,
                                                          int size) {
-  cached_metadata_ = std::make_unique<Vector<char>>(size);
+  cached_metadata_ = std::make_unique<Vector<uint8_t>>(size);
   memcpy(cached_metadata_->data(), data, size);
 }
 
diff --git a/third_party/blink/renderer/core/workers/worker_classic_script_loader.h b/third_party/blink/renderer/core/workers/worker_classic_script_loader.h
index 20a8e71..c12b7dd 100644
--- a/third_party/blink/renderer/core/workers/worker_classic_script_loader.h
+++ b/third_party/blink/renderer/core/workers/worker_classic_script_loader.h
@@ -95,7 +95,7 @@
   unsigned long Identifier() const { return identifier_; }
   long long AppCacheID() const { return app_cache_id_; }
 
-  std::unique_ptr<Vector<char>> ReleaseCachedMetadata() {
+  std::unique_ptr<Vector<uint8_t>> ReleaseCachedMetadata() {
     return std::move(cached_metadata_);
   }
 
@@ -153,7 +153,7 @@
 
   unsigned long identifier_ = 0;
   long long app_cache_id_ = 0;
-  std::unique_ptr<Vector<char>> cached_metadata_;
+  std::unique_ptr<Vector<uint8_t>> cached_metadata_;
   Member<ContentSecurityPolicy> content_security_policy_;
   mojom::IPAddressSpace response_address_space_;
   std::unique_ptr<Vector<String>> origin_trial_tokens_;
diff --git a/third_party/blink/renderer/core/workers/worker_global_scope.cc b/third_party/blink/renderer/core/workers/worker_global_scope.cc
index baff3a7f..cb0855e1 100644
--- a/third_party/blink/renderer/core/workers/worker_global_scope.cc
+++ b/third_party/blink/renderer/core/workers/worker_global_scope.cc
@@ -200,7 +200,7 @@
   for (const KURL& complete_url : completed_urls) {
     KURL response_url;
     String source_code;
-    std::unique_ptr<Vector<char>> cached_meta_data;
+    std::unique_ptr<Vector<uint8_t>> cached_meta_data;
     LoadResult result = LoadResult::kNotHandled;
     result = LoadScriptFromInstalledScriptsManager(
         complete_url, &response_url, &source_code, &cached_meta_data);
@@ -254,7 +254,7 @@
     const KURL& script_url,
     KURL* out_response_url,
     String* out_source_code,
-    std::unique_ptr<Vector<char>>* out_cached_meta_data) {
+    std::unique_ptr<Vector<uint8_t>>* out_cached_meta_data) {
   if (!GetThread()->GetInstalledScriptsManager() ||
       !GetThread()->GetInstalledScriptsManager()->IsScriptInstalled(
           script_url)) {
@@ -276,7 +276,7 @@
     const KURL& script_url,
     KURL* out_response_url,
     String* out_source_code,
-    std::unique_ptr<Vector<char>>* out_cached_meta_data) {
+    std::unique_ptr<Vector<uint8_t>>* out_cached_meta_data) {
   ExecutionContext* execution_context = GetExecutionContext();
   WorkerClassicScriptLoader* classic_script_loader =
       MakeGarbageCollected<WorkerClassicScriptLoader>();
@@ -345,7 +345,7 @@
 void WorkerGlobalScope::EvaluateClassicScript(
     const KURL& script_url,
     String source_code,
-    std::unique_ptr<Vector<char>> cached_meta_data,
+    std::unique_ptr<Vector<uint8_t>> cached_meta_data,
     const v8_inspector::V8StackTraceId& stack_id) {
   DCHECK(!IsContextPaused());
   ThreadDebugger* debugger = ThreadDebugger::From(GetThread()->GetIsolate());
@@ -464,7 +464,7 @@
 void WorkerGlobalScope::EvaluateClassicScriptInternal(
     const KURL& script_url,
     String source_code,
-    std::unique_ptr<Vector<char>> cached_meta_data) {
+    std::unique_ptr<Vector<uint8_t>> cached_meta_data) {
   DCHECK(IsContextThread());
   SingleCachedMetadataHandler* handler =
       CreateWorkerScriptCachedMetadataHandler(script_url,
diff --git a/third_party/blink/renderer/core/workers/worker_global_scope.h b/third_party/blink/renderer/core/workers/worker_global_scope.h
index 458aaf5..f0d0c98b 100644
--- a/third_party/blink/renderer/core/workers/worker_global_scope.h
+++ b/third_party/blink/renderer/core/workers/worker_global_scope.h
@@ -81,7 +81,7 @@
   // Returns null if caching is not supported.
   virtual SingleCachedMetadataHandler* CreateWorkerScriptCachedMetadataHandler(
       const KURL& script_url,
-      const Vector<char>* meta_data) {
+      const Vector<uint8_t>* meta_data) {
     return nullptr;
   }
 
@@ -146,7 +146,7 @@
   // is paused.
   void EvaluateClassicScript(const KURL& script_url,
                              String source_code,
-                             std::unique_ptr<Vector<char>> cached_meta_data,
+                             std::unique_ptr<Vector<uint8_t>> cached_meta_data,
                              const v8_inspector::V8StackTraceId& stack_id);
   void ImportClassicScript(
       const KURL& script_url,
@@ -195,7 +195,7 @@
   virtual void EvaluateClassicScriptInternal(
       const KURL& script_url,
       String source_code,
-      std::unique_ptr<Vector<char>> cached_meta_data);
+      std::unique_ptr<Vector<uint8_t>> cached_meta_data);
 
   mojom::ScriptType GetScriptType() const { return script_type_; }
 
@@ -230,7 +230,7 @@
       const KURL& script_url,
       KURL* out_response_url,
       String* out_source_code,
-      std::unique_ptr<Vector<char>>* out_cached_meta_data);
+      std::unique_ptr<Vector<uint8_t>>* out_cached_meta_data);
 
   // Tries to load the script synchronously from the WorkerClassicScriptLoader,
   // which requests the script from the browser. This blocks until the script is
@@ -239,7 +239,7 @@
       const KURL& script_url,
       KURL* out_response_url,
       String* out_source_code,
-      std::unique_ptr<Vector<char>>* out_cached_meta_data);
+      std::unique_ptr<Vector<uint8_t>>* out_cached_meta_data);
 
   // ExecutionContext
   EventTarget* ErrorEventTarget() final { return this; }
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc
index 000219f..d4549ef 100644
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
@@ -156,7 +156,7 @@
 void WorkerThread::EvaluateClassicScript(
     const KURL& script_url,
     const String& source_code,
-    std::unique_ptr<Vector<char>> cached_meta_data,
+    std::unique_ptr<Vector<uint8_t>> cached_meta_data,
     const v8_inspector::V8StackTraceId& stack_id) {
   DCHECK_CALLED_ON_VALID_THREAD(parent_thread_checker_);
   PostCrossThreadTask(
@@ -497,7 +497,7 @@
 void WorkerThread::EvaluateClassicScriptOnWorkerThread(
     const KURL& script_url,
     String source_code,
-    std::unique_ptr<Vector<char>> cached_meta_data,
+    std::unique_ptr<Vector<uint8_t>> cached_meta_data,
     const v8_inspector::V8StackTraceId& stack_id) {
   To<WorkerGlobalScope>(GlobalScope())
       ->EvaluateClassicScript(script_url, std::move(source_code),
diff --git a/third_party/blink/renderer/core/workers/worker_thread.h b/third_party/blink/renderer/core/workers/worker_thread.h
index 20c8624..a0f4ec2e 100644
--- a/third_party/blink/renderer/core/workers/worker_thread.h
+++ b/third_party/blink/renderer/core/workers/worker_thread.h
@@ -109,7 +109,7 @@
   // Called on the main thread after Start().
   void EvaluateClassicScript(const KURL& script_url,
                              const String& source_code,
-                             std::unique_ptr<Vector<char>> cached_meta_data,
+                             std::unique_ptr<Vector<uint8_t>> cached_meta_data,
                              const v8_inspector::V8StackTraceId& stack_id);
 
   // Posts a task to import a top-level classic script on the worker thread.
@@ -292,7 +292,7 @@
   void EvaluateClassicScriptOnWorkerThread(
       const KURL& script_url,
       String source_code,
-      std::unique_ptr<Vector<char>> cached_meta_data,
+      std::unique_ptr<Vector<uint8_t>> cached_meta_data,
       const v8_inspector::V8StackTraceId& stack_id);
   void ImportClassicScriptOnWorkerThread(
       const KURL& script_url,
diff --git a/third_party/blink/renderer/modules/cache_storage/cache.cc b/third_party/blink/renderer/modules/cache_storage/cache.cc
index c7485ab..d202439 100644
--- a/third_party/blink/renderer/modules/cache_storage/cache.cc
+++ b/third_party/blink/renderer/modules/cache_storage/cache.cc
@@ -409,7 +409,7 @@
       barrier_callback_->OnSuccess(index_, std::move(batch_operation));
       return;
     }
-    const Vector<char>& serialized_data = cached_metadata->SerializedData();
+    const Vector<uint8_t>& serialized_data = cached_metadata->SerializedData();
     std::unique_ptr<BlobData> side_data_blob_data = BlobData::Create();
     side_data_blob_data->AppendBytes(serialized_data.data(),
                                      serialized_data.size());
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc
index fd6dd2a4..d840e5182 100644
--- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc
+++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.cc
@@ -432,7 +432,7 @@
 sk_sp<PaintFilter> CanvasRenderingContext2DState::ShadowOnlyImageFilter()
     const {
   if (!shadow_only_image_filter_) {
-    double sigma = SkBlurRadiusToSigma(shadow_blur_);
+    const auto sigma = BlurRadiusToStdDev(shadow_blur_);
     shadow_only_image_filter_ = sk_make_sp<DropShadowPaintFilter>(
         shadow_offset_.Width(), shadow_offset_.Height(), sigma, sigma,
         shadow_color_, SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode,
@@ -444,7 +444,7 @@
 sk_sp<PaintFilter>
 CanvasRenderingContext2DState::ShadowAndForegroundImageFilter() const {
   if (!shadow_and_foreground_image_filter_) {
-    double sigma = SkBlurRadiusToSigma(shadow_blur_);
+    const auto sigma = BlurRadiusToStdDev(shadow_blur_);
     shadow_and_foreground_image_filter_ = sk_make_sp<DropShadowPaintFilter>(
         shadow_offset_.Width(), shadow_offset_.Height(), sigma, sigma,
         shadow_color_,
diff --git a/third_party/blink/renderer/modules/exported/web_embedded_worker_impl.cc b/third_party/blink/renderer/modules/exported/web_embedded_worker_impl.cc
index 6047bd6b..ef33aee 100644
--- a/third_party/blink/renderer/modules/exported/web_embedded_worker_impl.cc
+++ b/third_party/blink/renderer/modules/exported/web_embedded_worker_impl.cc
@@ -394,7 +394,7 @@
 
   std::unique_ptr<GlobalScopeCreationParams> global_scope_creation_params;
   String source_code;
-  std::unique_ptr<Vector<char>> cached_meta_data;
+  std::unique_ptr<Vector<uint8_t>> cached_meta_data;
 
   // |main_script_loader_| isn't created if the InstalledScriptsManager had the
   // script.
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc
index fa9b6dd..b73b338 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc
@@ -298,7 +298,7 @@
 void ServiceWorkerGlobalScope::EvaluateClassicScriptInternal(
     const KURL& script_url,
     String source_code,
-    std::unique_ptr<Vector<char>> cached_meta_data) {
+    std::unique_ptr<Vector<uint8_t>> cached_meta_data) {
   DCHECK(IsContextThread());
 
   if (!evaluate_script_ready_) {
@@ -419,7 +419,7 @@
 SingleCachedMetadataHandler*
 ServiceWorkerGlobalScope::CreateWorkerScriptCachedMetadataHandler(
     const KURL& script_url,
-    const Vector<char>* meta_data) {
+    const Vector<uint8_t>* meta_data) {
   return ServiceWorkerScriptCachedMetadataHandler::Create(this, script_url,
                                                           meta_data);
 }
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h
index 130b8f87..b2497b79 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h
@@ -158,14 +158,14 @@
   void EvaluateClassicScriptInternal(
       const KURL& script_url,
       String source_code,
-      std::unique_ptr<Vector<char>> cached_meta_data) override;
+      std::unique_ptr<Vector<uint8_t>> cached_meta_data) override;
 
  private:
   void importScripts(const HeapVector<StringOrTrustedScriptURL>& urls,
                      ExceptionState&) override;
   SingleCachedMetadataHandler* CreateWorkerScriptCachedMetadataHandler(
       const KURL& script_url,
-      const Vector<char>* meta_data) override;
+      const Vector<uint8_t>* meta_data) override;
   void ExceptionThrown(ErrorEvent*) override;
 
   // Counts the |script_size| and |cached_metadata_size| for UMA to measure the
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.cc
index 99444af33..e52b59d 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.cc
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.cc
@@ -109,7 +109,7 @@
 }
 
 void ServiceWorkerGlobalScopeClient::SetCachedMetadata(const KURL& url,
-                                                       const char* data,
+                                                       const uint8_t* data,
                                                        size_t size) {
   Vector<uint8_t> meta_data;
   meta_data.Append(data, SafeCast<wtf_size_t>(size));
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.h b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.h
index c6c8f0c..6649b7c0f3 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.h
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope_client.h
@@ -79,7 +79,7 @@
                   GetClientsCallback);
   void OpenWindowForClients(const KURL&, ScriptPromiseResolver*);
   void OpenWindowForPaymentHandler(const KURL&, ScriptPromiseResolver*);
-  void SetCachedMetadata(const KURL&, const char*, size_t);
+  void SetCachedMetadata(const KURL&, const uint8_t*, size_t);
   void ClearCachedMetadata(const KURL&);
   void PostMessageToClient(const String& client_uuid, BlinkTransferableMessage);
   void SkipWaiting(SkipWaitingCallback);
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_installed_scripts_manager.cc b/third_party/blink/renderer/modules/service_worker/service_worker_installed_scripts_manager.cc
index 6f42d50..0725ddcc 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_installed_scripts_manager.cc
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_installed_scripts_manager.cc
@@ -284,12 +284,12 @@
   for (const auto& chunk : raw_script_data->ScriptTextChunks())
     source_text_builder.Append(decoder->Decode(chunk.data(), chunk.size()));
 
-  std::unique_ptr<Vector<char>> meta_data;
+  std::unique_ptr<Vector<uint8_t>> meta_data;
   if (raw_script_data->MetaDataChunks().size() > 0) {
     size_t total_metadata_size = 0;
     for (const auto& chunk : raw_script_data->MetaDataChunks())
       total_metadata_size += chunk.size();
-    meta_data = std::make_unique<Vector<char>>();
+    meta_data = std::make_unique<Vector<uint8_t>>();
     meta_data->ReserveInitialCapacity(
         SafeCast<wtf_size_t>(total_metadata_size));
     for (const auto& chunk : raw_script_data->MetaDataChunks())
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.cc b/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.cc
index 5d06b1c..bc9029d 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.cc
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.cc
@@ -14,7 +14,7 @@
     ServiceWorkerScriptCachedMetadataHandler(
         WorkerGlobalScope* worker_global_scope,
         const KURL& script_url,
-        const Vector<char>* meta_data)
+        const Vector<uint8_t>* meta_data)
     : worker_global_scope_(worker_global_scope), script_url_(script_url) {
   if (meta_data)
     cached_metadata_ = CachedMetadata::CreateFromSerializedData(
@@ -31,13 +31,13 @@
 
 void ServiceWorkerScriptCachedMetadataHandler::SetCachedMetadata(
     uint32_t data_type_id,
-    const char* data,
+    const uint8_t* data,
     size_t size,
     CacheType type) {
   if (type != kSendToPlatform)
     return;
   cached_metadata_ = CachedMetadata::Create(data_type_id, data, size);
-  const Vector<char>& serialized_data = cached_metadata_->SerializedData();
+  const Vector<uint8_t>& serialized_data = cached_metadata_->SerializedData();
   ServiceWorkerGlobalScopeClient::From(worker_global_scope_)
       ->SetCachedMetadata(script_url_, serialized_data.data(),
                           serialized_data.size());
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.h b/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.h
index cd9325e..2eb8432 100644
--- a/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.h
+++ b/third_party/blink/renderer/modules/service_worker/service_worker_script_cached_metadata_handler.h
@@ -22,18 +22,18 @@
   static ServiceWorkerScriptCachedMetadataHandler* Create(
       WorkerGlobalScope* worker_global_scope,
       const KURL& script_url,
-      const Vector<char>* meta_data) {
+      const Vector<uint8_t>* meta_data) {
     return MakeGarbageCollected<ServiceWorkerScriptCachedMetadataHandler>(
         worker_global_scope, script_url, meta_data);
   }
 
   ServiceWorkerScriptCachedMetadataHandler(WorkerGlobalScope*,
                                            const KURL& script_url,
-                                           const Vector<char>* meta_data);
+                                           const Vector<uint8_t>* meta_data);
   ~ServiceWorkerScriptCachedMetadataHandler() override;
   void Trace(blink::Visitor*) override;
   void SetCachedMetadata(uint32_t data_type_id,
-                         const char*,
+                         const uint8_t*,
                          size_t,
                          CacheType) override;
   void ClearCachedMetadata(CacheType) override;
diff --git a/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc b/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc
index ca469f0..edb90d9 100644
--- a/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc
+++ b/third_party/blink/renderer/platform/graphics/draw_looper_builder.cc
@@ -91,7 +91,7 @@
   SkPaint* paint = sk_draw_looper_builder_.addLayerOnTop(info);
 
   if (blur) {
-    const SkScalar sigma = SkBlurRadiusToSigma(blur);
+    const auto sigma = BlurRadiusToStdDev(blur);
     const bool respectCTM = shadow_transform_mode != kShadowIgnoresTransforms;
     paint->setMaskFilter(
         SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, respectCTM));
diff --git a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
index 57546ef..dcc05e2 100644
--- a/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
+++ b/third_party/blink/renderer/platform/graphics/skia/skia_utils.h
@@ -129,13 +129,18 @@
                                                  float dest_height,
                                                  bool is_data_complete = true);
 
-// This replicates the old skia behavior when it used to take radius for blur.
-// Now it takes sigma.
-inline SkScalar SkBlurRadiusToSigma(SkScalar radius) {
-  SkASSERT(radius >= 0);
-  if (radius == 0)
-    return 0.0f;
-  return 0.288675f * radius + 0.5f;
+// Technically, this is driven by the CSS/Canvas2D specs and unrelated to Skia.
+// It should probably live in the CSS layer, but the notion of a "blur radius"
+// leaks into platform/graphics currently (ideally we should only deal with
+// sigma at this level).
+// TODO(fmalita): find a better home for this helper.
+inline float BlurRadiusToStdDev(float radius) {
+  DCHECK_GE(radius, 0);
+
+  // Per spec, sigma is exactly half the blur radius:
+  // https://www.w3.org/TR/css-backgrounds-3/#shadow-blur
+  // https://html.spec.whatwg.org/multipage/canvas.html#when-shadows-are-drawn
+  return radius * 0.5f;
 }
 
 template <typename PrimitiveType>
diff --git a/third_party/blink/renderer/platform/heap/heap_compact.cc b/third_party/blink/renderer/platform/heap/heap_compact.cc
index 551e005..53eb750 100644
--- a/third_party/blink/renderer/platform/heap/heap_compact.cc
+++ b/third_party/blink/renderer/platform/heap/heap_compact.cc
@@ -512,6 +512,16 @@
   do_compact_ = false;
 }
 
+void HeapCompact::CancelCompaction() {
+  if (!do_compact_)
+    return;
+
+  last_fixup_count_for_testing_ = 0;
+  traced_slots_.clear();
+  fixups_.reset();
+  do_compact_ = false;
+}
+
 void HeapCompact::AddCompactingPage(BasePage* page) {
   DCHECK(do_compact_);
   DCHECK(IsCompactingArena(page->Arena()->ArenaIndex()));
diff --git a/third_party/blink/renderer/platform/heap/heap_compact.h b/third_party/blink/renderer/platform/heap/heap_compact.h
index a41c5d3..ec0ef44 100644
--- a/third_party/blink/renderer/platform/heap/heap_compact.h
+++ b/third_party/blink/renderer/platform/heap/heap_compact.h
@@ -105,6 +105,8 @@
   void StartThreadCompaction();
   void FinishThreadCompaction();
 
+  void CancelCompaction();
+
   // Perform any relocation post-processing after having completed compacting
   // the given arena. The number of pages that were freed together with the
   // total size (in bytes) of freed heap storage, are passed in as arguments.
diff --git a/third_party/blink/renderer/platform/heap/incremental_marking_test.cc b/third_party/blink/renderer/platform/heap/incremental_marking_test.cc
index 05b02458..69587d14 100644
--- a/third_party/blink/renderer/platform/heap/incremental_marking_test.cc
+++ b/third_party/blink/renderer/platform/heap/incremental_marking_test.cc
@@ -1730,10 +1730,28 @@
   persistent->insert(Object::Create());
   driver.FinishGC();
 
-  // Weak caallback should register the slot.
+  // Weak callback should register the slot.
   EXPECT_EQ(driver.GetHeapCompactLastFixupCount(), 1u);
 }
 
+TEST(IncrementalMarkingTest, ConservativeGCWhileCompactionScheduled) {
+  using Store = HeapVector<Member<Object>>;
+  Persistent<Store> persistent(MakeGarbageCollected<Store>());
+  persistent->push_back(Object::Create());
+
+  IncrementalMarkingTestDriver driver(ThreadState::Current());
+  HeapCompact::ScheduleCompactionGCForTesting(true);
+  driver.Start();
+  driver.FinishSteps();
+  ThreadState::Current()->CollectGarbage(
+      BlinkGC::kHeapPointersOnStack, BlinkGC::kAtomicMarking,
+      BlinkGC::kLazySweeping, BlinkGC::GCReason::kConservativeGC);
+
+  // Heap compaction should be canceled if incremental marking finishes with a
+  // conservative GC.
+  EXPECT_EQ(driver.GetHeapCompactLastFixupCount(), 0u);
+}
+
 namespace {
 
 class ObjectWithWeakMember : public GarbageCollected<ObjectWithWeakMember> {
diff --git a/third_party/blink/renderer/platform/heap/thread_state.cc b/third_party/blink/renderer/platform/heap/thread_state.cc
index 82226a9..1e7ffa8 100644
--- a/third_party/blink/renderer/platform/heap/thread_state.cc
+++ b/third_party/blink/renderer/platform/heap/thread_state.cc
@@ -1700,6 +1700,11 @@
 void ThreadState::AtomicPausePrologue(BlinkGC::StackState stack_state,
                                       BlinkGC::MarkingType marking_type,
                                       BlinkGC::GCReason reason) {
+  // Compaction needs to be canceled when incremental marking ends with a
+  // conservative GC.
+  if (stack_state == BlinkGC::kHeapPointersOnStack)
+    Heap().Compaction()->CancelCompaction();
+
   if (IsMarkingInProgress()) {
     // Incremental marking is already in progress. Only update the state
     // that is necessary to update.
diff --git a/third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc b/third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc
index 1edafd9..0da3bd5 100644
--- a/third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/cached_metadata.cc
@@ -9,7 +9,7 @@
 namespace blink {
 
 scoped_refptr<CachedMetadata> CachedMetadata::CreateFromSerializedData(
-    const char* data,
+    const uint8_t* data,
     size_t size) {
   // Ensure the data is big enough, otherwise discard the data.
   if (size < kCachedMetaDataStart ||
@@ -24,7 +24,7 @@
   return base::AdoptRef(
       new CachedMetadata(data, static_cast<wtf_size_t>(size)));
 }
-CachedMetadata::CachedMetadata(const char* data, wtf_size_t size) {
+CachedMetadata::CachedMetadata(const uint8_t* data, wtf_size_t size) {
   // Serialized metadata should have non-empty data.
   DCHECK_GT(size, kCachedMetaDataStart);
   DCHECK(data);
@@ -37,7 +37,7 @@
 }
 
 CachedMetadata::CachedMetadata(uint32_t data_type_id,
-                               const char* data,
+                               const uint8_t* data,
                                wtf_size_t size) {
   // Don't allow an ID of 0, it is used internally to indicate errors.
   DCHECK(data_type_id);
@@ -45,9 +45,9 @@
 
   serialized_data_.ReserveInitialCapacity(kCachedMetaDataStart + size);
   uint32_t marker = CachedMetadataHandler::kSingleEntry;
-  serialized_data_.Append(reinterpret_cast<const char*>(&marker),
+  serialized_data_.Append(reinterpret_cast<const uint8_t*>(&marker),
                           sizeof(uint32_t));
-  serialized_data_.Append(reinterpret_cast<const char*>(&data_type_id),
+  serialized_data_.Append(reinterpret_cast<const uint8_t*>(&data_type_id),
                           sizeof(uint32_t));
   serialized_data_.Append(data, size);
 }
diff --git a/third_party/blink/renderer/platform/loader/fetch/cached_metadata.h b/third_party/blink/renderer/platform/loader/fetch/cached_metadata.h
index 2657ea09..474c560 100644
--- a/third_party/blink/renderer/platform/loader/fetch/cached_metadata.h
+++ b/third_party/blink/renderer/platform/loader/fetch/cached_metadata.h
@@ -53,27 +53,27 @@
 class PLATFORM_EXPORT CachedMetadata : public RefCounted<CachedMetadata> {
  public:
   static scoped_refptr<CachedMetadata> Create(uint32_t data_type_id,
-                                              const char* data,
+                                              const uint8_t* data,
                                               size_t size) {
     return base::AdoptRef(
         new CachedMetadata(data_type_id, data, SafeCast<wtf_size_t>(size)));
   }
 
   static scoped_refptr<CachedMetadata> CreateFromSerializedData(
-      const char* data,
+      const uint8_t* data,
       size_t);
 
   ~CachedMetadata() = default;
 
-  const Vector<char>& SerializedData() const { return serialized_data_; }
+  const Vector<uint8_t>& SerializedData() const { return serialized_data_; }
 
   uint32_t DataTypeID() const {
     DCHECK_GE(serialized_data_.size(), kCachedMetaDataStart);
     return *reinterpret_cast_ptr<uint32_t*>(
-        const_cast<char*>(serialized_data_.data() + kCacheDataTypeStart));
+        const_cast<uint8_t*>(serialized_data_.data() + kCacheDataTypeStart));
   }
 
-  const char* Data() const {
+  const uint8_t* Data() const {
     DCHECK_GE(serialized_data_.size(), kCachedMetaDataStart);
     return serialized_data_.data() + kCachedMetaDataStart;
   }
@@ -84,12 +84,12 @@
   }
 
  private:
-  CachedMetadata(const char* data, wtf_size_t);
-  CachedMetadata(uint32_t data_type_id, const char* data, wtf_size_t);
+  CachedMetadata(const uint8_t* data, wtf_size_t);
+  CachedMetadata(uint32_t data_type_id, const uint8_t* data, wtf_size_t);
 
   // Since the serialization format supports random access, storing it in
   // serialized form avoids need for a copy during serialization.
-  Vector<char> serialized_data_;
+  Vector<uint8_t> serialized_data_;
 };
 
 }  // namespace blink
diff --git a/third_party/blink/renderer/platform/loader/fetch/cached_metadata_handler.h b/third_party/blink/renderer/platform/loader/fetch/cached_metadata_handler.h
index 626544f..0deaf66 100644
--- a/third_party/blink/renderer/platform/loader/fetch/cached_metadata_handler.h
+++ b/third_party/blink/renderer/platform/loader/fetch/cached_metadata_handler.h
@@ -52,7 +52,7 @@
   // that the platform persist it. The dataTypeID is a pseudo-randomly chosen
   // identifier that is used to distinguish data generated by the caller.
   virtual void SetCachedMetadata(uint32_t data_type_id,
-                                 const char*,
+                                 const uint8_t*,
                                  size_t,
                                  CacheType = kSendToPlatform) = 0;
 
diff --git a/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc b/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc
index dd77e103..68ffca2 100644
--- a/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/raw_resource.cc
@@ -250,7 +250,8 @@
   return Resource::CreateCachedMetadataHandler(std::move(send_callback));
 }
 
-void RawResource::SetSerializedCachedMetadata(const char* data, size_t size) {
+void RawResource::SetSerializedCachedMetadata(const uint8_t* data,
+                                              size_t size) {
   Resource::SetSerializedCachedMetadata(data, size);
 
   if (GetType() == ResourceType::kMainResource) {
diff --git a/third_party/blink/renderer/platform/loader/fetch/raw_resource.h b/third_party/blink/renderer/platform/loader/fetch/raw_resource.h
index 500ba00..09f7ea1 100644
--- a/third_party/blink/renderer/platform/loader/fetch/raw_resource.h
+++ b/third_party/blink/renderer/platform/loader/fetch/raw_resource.h
@@ -90,7 +90,7 @@
   bool WillFollowRedirect(const ResourceRequest&,
                           const ResourceResponse&) override;
 
-  void SetSerializedCachedMetadata(const char*, size_t) override;
+  void SetSerializedCachedMetadata(const uint8_t*, size_t) override;
 
   // Used for code caching of scripts with source code inline in the HTML.
   // Returns a cache handler which can store multiple cache metadata entries,
@@ -191,7 +191,7 @@
   virtual void ResponseReceived(Resource*,
                                 const ResourceResponse&,
                                 std::unique_ptr<WebDataConsumerHandle>) {}
-  virtual void SetSerializedCachedMetadata(Resource*, const char*, size_t) {}
+  virtual void SetSerializedCachedMetadata(Resource*, const uint8_t*, size_t) {}
   virtual bool RedirectReceived(Resource*,
                                 const ResourceRequest&,
                                 const ResourceResponse&) {
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource.cc b/third_party/blink/renderer/platform/loader/fetch/resource.cc
index 66a3b99..ee30703 100644
--- a/third_party/blink/renderer/platform/loader/fetch/resource.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/resource.cc
@@ -119,7 +119,7 @@
   CachedMetadataSenderImpl(const Resource*);
   ~CachedMetadataSenderImpl() override = default;
 
-  void Send(const char*, size_t) override;
+  void Send(const uint8_t*, size_t) override;
   bool IsServedFromCacheStorage() override { return false; }
 
  private:
@@ -135,7 +135,7 @@
   DCHECK(resource->GetResponse().CacheStorageCacheName().IsNull());
 }
 
-void CachedMetadataSenderImpl::Send(const char* data, size_t size) {
+void CachedMetadataSenderImpl::Send(const uint8_t* data, size_t size) {
   Platform::Current()->CacheMetadata(
       Resource::ResourceTypeToCodeCacheType(resource_type_), response_url_,
       response_time_, data, size);
@@ -147,7 +147,7 @@
   NullCachedMetadataSender() = default;
   ~NullCachedMetadataSender() override = default;
 
-  void Send(const char*, size_t) override {}
+  void Send(const uint8_t*, size_t) override {}
   bool IsServedFromCacheStorage() override { return false; }
 };
 
@@ -158,7 +158,7 @@
   ServiceWorkerCachedMetadataSender(const Resource*, const SecurityOrigin*);
   ~ServiceWorkerCachedMetadataSender() override = default;
 
-  void Send(const char*, size_t) override;
+  void Send(const uint8_t*, size_t) override;
   bool IsServedFromCacheStorage() override { return true; }
 
  private:
@@ -179,7 +179,7 @@
   DCHECK(!cache_storage_cache_name_.IsNull());
 }
 
-void ServiceWorkerCachedMetadataSender::Send(const char* data, size_t size) {
+void ServiceWorkerCachedMetadataSender::Send(const uint8_t* data, size_t size) {
   Platform::Current()->CacheMetadataInCacheStorage(
       response_url_, response_time_, data, size,
       WebSecurityOrigin(security_origin_), cache_storage_cache_name_);
@@ -578,7 +578,7 @@
     SetEncoding(encoding);
 }
 
-void Resource::SetSerializedCachedMetadata(const char* data, size_t size) {
+void Resource::SetSerializedCachedMetadata(const uint8_t* data, size_t size) {
   DCHECK(!is_revalidating_);
   DCHECK(!GetResponse().IsNull());
 }
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource.h b/third_party/blink/renderer/platform/loader/fetch/resource.h
index 232d399..6648e2e 100644
--- a/third_party/blink/renderer/platform/loader/fetch/resource.h
+++ b/third_party/blink/renderer/platform/loader/fetch/resource.h
@@ -92,7 +92,7 @@
 class CachedMetadataSender {
  public:
   virtual ~CachedMetadataSender() = default;
-  virtual void Send(const char*, size_t) = 0;
+  virtual void Send(const uint8_t*, size_t) = 0;
 
   // IsServedFromCacheStorage is used to alter caching strategy to be more
   // aggressive. See ScriptController.cpp CacheOptions() for an example.
@@ -283,7 +283,7 @@
   // Sets the serialized metadata retrieved from the platform's cache.
   // Subclasses of Resource that support cached metadata should override this
   // method with one that fills the current CachedMetadataHandler.
-  virtual void SetSerializedCachedMetadata(const char*, size_t);
+  virtual void SetSerializedCachedMetadata(const uint8_t*, size_t);
 
   AtomicString HttpContentType() const;
 
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher_test.cc b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher_test.cc
index 3a9bbee..4156ab2 100644
--- a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher_test.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher_test.cc
@@ -419,7 +419,7 @@
                         std::unique_ptr<WebDataConsumerHandle>) override {
     ASSERT_TRUE(false);
   }
-  void SetSerializedCachedMetadata(Resource*, const char*, size_t) override {
+  void SetSerializedCachedMetadata(Resource*, const uint8_t*, size_t) override {
     ASSERT_TRUE(false);
   }
   void DataReceived(Resource*, const char*, size_t) override {
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc b/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
index 4a2d35c..3b26ad9e 100644
--- a/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/resource_loader.cc
@@ -754,7 +754,8 @@
 
 void ResourceLoader::DidReceiveCachedMetadata(const char* data, int length) {
   DCHECK(!should_use_isolated_code_cache_);
-  resource_->SetSerializedCachedMetadata(data, length);
+  resource_->SetSerializedCachedMetadata(reinterpret_cast<const uint8_t*>(data),
+                                         length);
 }
 
 blink::mojom::CodeCacheType ResourceLoader::GetCodeCacheType() const {
@@ -762,7 +763,8 @@
 }
 
 void ResourceLoader::SendCachedCodeToResource(const char* data, int length) {
-  resource_->SetSerializedCachedMetadata(data, length);
+  resource_->SetSerializedCachedMetadata(reinterpret_cast<const uint8_t*>(data),
+                                         length);
 }
 
 void ResourceLoader::ClearCachedCode() {
diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_test.cc b/third_party/blink/renderer/platform/loader/fetch/resource_test.cc
index fc6a395..091e95d0 100644
--- a/third_party/blink/renderer/platform/loader/fetch/resource_test.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/resource_test.cc
@@ -30,7 +30,7 @@
   void CacheMetadata(blink::mojom::CodeCacheType cache_type,
                      const WebURL& url,
                      Time,
-                     const char*,
+                     const uint8_t*,
                      size_t) override {
     cached_urls_.push_back(url);
   }
@@ -48,7 +48,7 @@
 }
 
 void CreateTestResourceAndSetCachedMetadata(const ResourceResponse& response) {
-  const char kTestData[] = "test data";
+  const uint8_t kTestData[] = {1, 2, 3, 4, 5};
   MockResource* resource = MockResource::Create(response.CurrentRequestUrl());
   resource->SetResponse(response);
   resource->SendCachedMetadata(kTestData, sizeof(kTestData));
diff --git a/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc b/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc
index db7ad35c..d160b14 100644
--- a/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.cc
@@ -20,7 +20,7 @@
 
 void ScriptCachedMetadataHandler::SetCachedMetadata(
     uint32_t data_type_id,
-    const char* data,
+    const uint8_t* data,
     size_t size,
     CachedMetadataHandler::CacheType cache_type) {
   // Currently, only one type of cached metadata per resource is supported. If
@@ -46,8 +46,9 @@
   return cached_metadata_;
 }
 
-void ScriptCachedMetadataHandler::SetSerializedCachedMetadata(const char* data,
-                                                              size_t size) {
+void ScriptCachedMetadataHandler::SetSerializedCachedMetadata(
+    const uint8_t* data,
+    size_t size) {
   // We only expect to receive cached metadata from the platform once. If this
   // triggers, it indicates an efficiency problem which is most likely
   // unexpected in code designed to improve performance.
@@ -65,7 +66,7 @@
 
 void ScriptCachedMetadataHandler::SendToPlatform() {
   if (cached_metadata_) {
-    const Vector<char>& serialized_data = cached_metadata_->SerializedData();
+    const Vector<uint8_t>& serialized_data = cached_metadata_->SerializedData();
     sender_->Send(serialized_data.data(), serialized_data.size());
   } else {
     sender_->Send(nullptr, 0);
diff --git a/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h b/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h
index a30fb19..5fd43aa 100644
--- a/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h
+++ b/third_party/blink/renderer/platform/loader/fetch/script_cached_metadata_handler.h
@@ -34,7 +34,7 @@
                               std::unique_ptr<CachedMetadataSender>);
   ~ScriptCachedMetadataHandler() override = default;
   void Trace(blink::Visitor*) override;
-  void SetCachedMetadata(uint32_t, const char*, size_t, CacheType) override;
+  void SetCachedMetadata(uint32_t, const uint8_t*, size_t, CacheType) override;
   void ClearCachedMetadata(CacheType) override;
   scoped_refptr<CachedMetadata> GetCachedMetadata(uint32_t) const override;
 
@@ -49,7 +49,7 @@
   bool IsServedFromCacheStorage() const override;
 
   // Sets the serialized metadata retrieved from the platform's cache.
-  void SetSerializedCachedMetadata(const char*, size_t);
+  void SetSerializedCachedMetadata(const uint8_t*, size_t);
 
  private:
   void SendToPlatform();
diff --git a/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.cc b/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.cc
index d1d3c7b..2be718f 100644
--- a/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.cc
@@ -27,7 +27,7 @@
       : parent_(parent), key_(key) {}
 
   void SetCachedMetadata(uint32_t data_type_id,
-                         const char* data,
+                         const uint8_t* data,
                          size_t size,
                          CacheType cache_type) override {
     DCHECK(!parent_->cached_metadata_map_.Contains(key_));
@@ -120,7 +120,7 @@
 // should inline and optimize to the same code as *reinterpret_cast<T>(data),
 // but without the risk of undefined behaviour.
 template <typename T>
-T ReadVal(const char* data) {
+T ReadVal(const uint8_t* data) {
   static_assert(base::is_trivially_copyable<T>::value,
                 "ReadVal requires the value type to be copyable");
   T ret;
@@ -130,7 +130,7 @@
 }  // namespace
 
 void SourceKeyedCachedMetadataHandler::SetSerializedCachedMetadata(
-    const char* data,
+    const uint8_t* data,
     size_t size) {
   // We only expect to receive cached metadata from the platform once. If this
   // triggers, it indicates an efficiency problem which is most likely
@@ -199,16 +199,16 @@
   if (cached_metadata_map_.IsEmpty()) {
     sender_->Send(nullptr, 0);
   } else {
-    Vector<char> serialized_data;
+    Vector<uint8_t> serialized_data;
     uint32_t marker = CachedMetadataHandler::kSourceKeyedMap;
-    serialized_data.Append(reinterpret_cast<char*>(&marker), sizeof(marker));
+    serialized_data.Append(reinterpret_cast<uint8_t*>(&marker), sizeof(marker));
     int num_entries = cached_metadata_map_.size();
-    serialized_data.Append(reinterpret_cast<char*>(&num_entries),
+    serialized_data.Append(reinterpret_cast<uint8_t*>(&num_entries),
                            sizeof(num_entries));
     for (const auto& metadata : cached_metadata_map_) {
       serialized_data.Append(metadata.key.data(), kKeySize);
       size_t entry_size = metadata.value->SerializedData().size();
-      serialized_data.Append(reinterpret_cast<const char*>(&entry_size),
+      serialized_data.Append(reinterpret_cast<const uint8_t*>(&entry_size),
                              sizeof(entry_size));
       serialized_data.AppendVector(metadata.value->SerializedData());
     }
diff --git a/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.h b/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.h
index b9b7b83a..44df319 100644
--- a/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.h
+++ b/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler.h
@@ -38,7 +38,7 @@
     return sender_->IsServedFromCacheStorage();
   }
 
-  void SetSerializedCachedMetadata(const char*, size_t);
+  void SetSerializedCachedMetadata(const uint8_t*, size_t);
 
  private:
   // Keys are SHA-256, which are 256/8 = 32 bytes.
diff --git a/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler_test.cc b/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler_test.cc
index 61a489c..c2f4782 100644
--- a/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler_test.cc
+++ b/third_party/blink/renderer/platform/loader/fetch/source_keyed_cached_metadata_handler_test.cc
@@ -69,7 +69,7 @@
 struct CacheMetadataEntry {
   CacheMetadataEntry(const WebURL& url,
                      base::Time response_time,
-                     const char* data,
+                     const uint8_t* data,
                      wtf_size_t data_size)
       : url(url), response_time(response_time) {
     this->data.Append(data, data_size);
@@ -77,7 +77,7 @@
 
   WebURL url;
   base::Time response_time;
-  Vector<char> data;
+  Vector<uint8_t> data;
 };
 
 // Mock Platform implementation that provides basic crypto and caching.
@@ -92,7 +92,7 @@
   void CacheMetadata(blink::mojom::CodeCacheType cache_type,
                      const WebURL& url,
                      base::Time response_time,
-                     const char* data,
+                     const uint8_t* data,
                      size_t data_size) override {
     cache_entries_.emplace_back(url, response_time, data,
                                 SafeCast<wtf_size_t>(data_size));
@@ -127,7 +127,7 @@
  public:
   MockCachedMetadataSender(KURL response_url) : response_url_(response_url) {}
 
-  void Send(const char* data, size_t size) override {
+  void Send(const uint8_t* data, size_t size) override {
     Platform::Current()->CacheMetadata(blink::mojom::CodeCacheType::kJavascript,
                                        response_url_, response_time_, data,
                                        size);
@@ -144,7 +144,7 @@
 ::testing::AssertionResult CachedMetadataFailure(
     const char* failure_msg,
     const char* actual_expression,
-    const std::array<char, N>& expected,
+    const std::array<uint8_t, N>& expected,
     const scoped_refptr<CachedMetadata>& actual) {
   ::testing::Message msg;
   msg << failure_msg << " for " << actual_expression;
@@ -174,7 +174,7 @@
 ::testing::AssertionResult CachedMetadataEqual(
     const char* expected_expression,
     const char* actual_expression,
-    const std::array<char, N>& expected,
+    const std::array<uint8_t, N>& expected,
     const scoped_refptr<CachedMetadata>& actual) {
   if (!actual) {
     return CachedMetadataFailure("Expected non-null data", actual_expression,
@@ -184,7 +184,7 @@
     return CachedMetadataFailure("Wrong size", actual_expression, expected,
                                  actual);
   }
-  const char* actual_data = actual->Data();
+  const uint8_t* actual_data = actual->Data();
   for (size_t i = 0; i < N; ++i) {
     if (actual_data[i] != expected[i]) {
       return CachedMetadataFailure("Wrong data", actual_expression, expected,
@@ -242,7 +242,7 @@
   SingleCachedMetadataHandler* source2_handler =
       handler->HandlerForSource(source2);
 
-  std::array<char, 3> data1 = {1, 2, 3};
+  std::array<uint8_t, 3> data1 = {1, 2, 3};
   source1_handler->SetCachedMetadata(0xbeef, data1.data(), data1.size());
 
   EXPECT_NE(nullptr, source1_handler);
@@ -269,10 +269,10 @@
   SingleCachedMetadataHandler* source2_handler =
       handler->HandlerForSource(source2);
 
-  std::array<char, 3> data1 = {1, 2, 3};
+  std::array<uint8_t, 3> data1 = {1, 2, 3};
   source1_handler->SetCachedMetadata(0xbeef, data1.data(), data1.size());
 
-  std::array<char, 4> data2 = {3, 4, 5, 6};
+  std::array<uint8_t, 4> data2 = {3, 4, 5, 6};
   source2_handler->SetCachedMetadata(0x5eed, data2.data(), data2.size());
 
   EXPECT_NE(nullptr, source1_handler);
@@ -318,10 +318,10 @@
   SingleCachedMetadataHandler* source2_handler =
       handler->HandlerForSource(source2);
 
-  std::array<char, 3> data1 = {1, 2, 3};
+  std::array<uint8_t, 3> data1 = {1, 2, 3};
   source1_handler->SetCachedMetadata(0xbeef, data1.data(), data1.size());
 
-  std::array<char, 4> data2 = {3, 4, 5, 6};
+  std::array<uint8_t, 4> data2 = {3, 4, 5, 6};
   source2_handler->SetCachedMetadata(0x5eed, data2.data(), data2.size());
 
   // Load from platform
@@ -348,11 +348,11 @@
   SingleCachedMetadataHandler* source2_handler =
       handler->HandlerForSource(source2);
 
-  std::array<char, 3> data1 = {1, 2, 3};
+  std::array<uint8_t, 3> data1 = {1, 2, 3};
   source1_handler->SetCachedMetadata(0xbeef, data1.data(), data1.size(),
                                      CachedMetadataHandler::kCacheLocally);
 
-  std::array<char, 4> data2 = {3, 4, 5, 6};
+  std::array<uint8_t, 4> data2 = {3, 4, 5, 6};
   source2_handler->SetCachedMetadata(0x5eed, data2.data(), data2.size());
 
   // Load from platform
@@ -416,8 +416,8 @@
   KURL url("http://SourceKeyedCachedMetadataHandlerTest.com");
   WTF::String source1("source1");
   WTF::String source2("source2");
-  std::array<char, 3> data1 = {1, 2, 3};
-  std::array<char, 4> data2 = {3, 4, 5, 6};
+  std::array<uint8_t, 3> data1 = {1, 2, 3};
+  std::array<uint8_t, 4> data2 = {3, 4, 5, 6};
   {
     SourceKeyedCachedMetadataHandler* handler =
         MakeGarbageCollected<SourceKeyedCachedMetadataHandler>(
diff --git a/third_party/blink/renderer/platform/loader/testing/mock_resource.cc b/third_party/blink/renderer/platform/loader/testing/mock_resource.cc
index 57de25a..7648bfa 100644
--- a/third_party/blink/renderer/platform/loader/testing/mock_resource.cc
+++ b/third_party/blink/renderer/platform/loader/testing/mock_resource.cc
@@ -54,7 +54,8 @@
   return MakeGarbageCollected<MockCacheHandler>(std::move(send_callback));
 }
 
-void MockResource::SetSerializedCachedMetadata(const char* data, size_t size) {
+void MockResource::SetSerializedCachedMetadata(const uint8_t* data,
+                                               size_t size) {
   Resource::SetSerializedCachedMetadata(data, size);
   MockCacheHandler* cache_handler =
       static_cast<MockCacheHandler*>(Resource::CacheHandler());
@@ -63,7 +64,7 @@
   }
 }
 
-void MockResource::SendCachedMetadata(const char* data, size_t size) {
+void MockResource::SendCachedMetadata(const uint8_t* data, size_t size) {
   MockCacheHandler* cache_handler =
       static_cast<MockCacheHandler*>(Resource::CacheHandler());
   if (cache_handler) {
@@ -80,7 +81,7 @@
     std::unique_ptr<CachedMetadataSender> send_callback)
     : send_callback_(std::move(send_callback)) {}
 
-void MockCacheHandler::Set(const char* data, size_t size) {
+void MockCacheHandler::Set(const uint8_t* data, size_t size) {
   data_.emplace();
   data_->Append(data, SafeCast<wtf_size_t>(size));
 }
diff --git a/third_party/blink/renderer/platform/loader/testing/mock_resource.h b/third_party/blink/renderer/platform/loader/testing/mock_resource.h
index 69e307ef..c54228b5 100644
--- a/third_party/blink/renderer/platform/loader/testing/mock_resource.h
+++ b/third_party/blink/renderer/platform/loader/testing/mock_resource.h
@@ -21,7 +21,7 @@
  public:
   MockCacheHandler(std::unique_ptr<CachedMetadataSender> send_callback);
 
-  void Set(const char* data, size_t);
+  void Set(const uint8_t* data, size_t);
   void ClearCachedMetadata(CachedMetadataHandler::CacheType) override;
   void Send();
 
@@ -30,7 +30,7 @@
 
  private:
   std::unique_ptr<CachedMetadataSender> send_callback_;
-  base::Optional<Vector<char>> data_;
+  base::Optional<Vector<uint8_t>> data_;
 };
 
 // Mocked Resource sub-class for testing. MockResource class can pretend a type
@@ -48,11 +48,11 @@
 
   CachedMetadataHandler* CreateCachedMetadataHandler(
       std::unique_ptr<CachedMetadataSender> send_callback) override;
-  void SetSerializedCachedMetadata(const char*, size_t) override;
+  void SetSerializedCachedMetadata(const uint8_t*, size_t) override;
 
   MockCacheHandler* CacheHandler();
 
-  void SendCachedMetadata(const char*, size_t);
+  void SendCachedMetadata(const uint8_t*, size_t);
 };
 
 }  // namespace blink
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations
index 647417a..aa04cf8 100644
--- a/third_party/blink/web_tests/TestExpectations
+++ b/third_party/blink/web_tests/TestExpectations
@@ -1820,9 +1820,6 @@
 
 ### True failures start from here
 
-### virtual/bidi-caret-affinity/editing/inserting/
-crbug.com/894651 virtual/bidi-caret-affinity/editing/inserting/caret-position.html [ Failure ]
-
 ### virtual/bidi-caret-affinity/editing/selection/
 crbug.com/894651 virtual/bidi-caret-affinity/editing/selection/caret-bidi-first-and-last-letters.html [ Failure ]
 crbug.com/894651 virtual/bidi-caret-affinity/editing/selection/css-pseudo-element.html [ Failure ]
diff --git a/third_party/blink/web_tests/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt b/third_party/blink/web_tests/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt
index 6606743..04ed9d0 100644
--- a/third_party/blink/web_tests/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt
+++ b/third_party/blink/web_tests/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt
@@ -19,7 +19,7 @@
     },
     {
       "name": "LayoutBlockFlow DIV class='box'",
-      "bounds": [138, 138],
+      "bounds": [160, 160],
       "backgroundColor": "#0000FF",
       "transform": 1
     }
@@ -31,7 +31,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [39, 31, 0, 1]
+        [28, 20, 0, 1]
       ]
     }
   ]
diff --git a/third_party/blink/web_tests/compositing/culling/scrolled-within-boxshadow-expected.png b/third_party/blink/web_tests/compositing/culling/scrolled-within-boxshadow-expected.png
index 7ca11fd..82aeb43 100644
--- a/third_party/blink/web_tests/compositing/culling/scrolled-within-boxshadow-expected.png
+++ b/third_party/blink/web_tests/compositing/culling/scrolled-within-boxshadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/culling/translated-boxshadow-expected.png b/third_party/blink/web_tests/compositing/culling/translated-boxshadow-expected.png
index a9d548ca..1bfed036 100644
--- a/third_party/blink/web_tests/compositing/culling/translated-boxshadow-expected.png
+++ b/third_party/blink/web_tests/compositing/culling/translated-boxshadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/culling/unscrolled-within-boxshadow-expected.png b/third_party/blink/web_tests/compositing/culling/unscrolled-within-boxshadow-expected.png
index 7ca11fd..82aeb43 100644
--- a/third_party/blink/web_tests/compositing/culling/unscrolled-within-boxshadow-expected.png
+++ b/third_party/blink/web_tests/compositing/culling/unscrolled-within-boxshadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.png b/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.png
index 8df504fe..b741cb1 100644
--- a/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.png
+++ b/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.txt b/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.txt
index 6b6d8611..a88c074 100644
--- a/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.txt
+++ b/third_party/blink/web_tests/compositing/geometry/foreground-layer-expected.txt
@@ -20,7 +20,7 @@
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='main box'",
-      "bounds": [318, 318],
+      "bounds": [340, 340],
       "backgroundColor": "#FF0000",
       "transform": 1
     },
@@ -32,12 +32,12 @@
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='main box' (foreground) Layer",
-      "bounds": [318, 318],
+      "bounds": [340, 340],
       "transform": 1
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='main box'",
-      "bounds": [318, 318],
+      "bounds": [340, 340],
       "backgroundColor": "#FF0000",
       "transform": 4
     },
@@ -49,7 +49,7 @@
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='main box' (foreground) Layer",
-      "bounds": [318, 318],
+      "bounds": [340, 340],
       "transform": 4
     }
   ],
@@ -60,7 +60,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [19, 89, 0, 1]
+        [8, 78, 0, 1]
       ]
     },
     {
@@ -70,7 +70,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [59, 59, 0, 1]
+        [70, 70, 0, 1]
       ]
     },
     {
@@ -89,7 +89,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [363, 19, 0, 1]
+        [352, 8, 0, 1]
       ]
     },
     {
@@ -99,7 +99,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [59, 59, 0, 1]
+        [70, 70, 0, 1]
       ]
     },
     {
diff --git a/third_party/blink/web_tests/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png b/third_party/blink/web_tests/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
deleted file mode 100644
index 123207e..0000000
--- a/third_party/blink/web_tests/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/iframes/composited-parent-iframe-expected.txt b/third_party/blink/web_tests/compositing/iframes/composited-parent-iframe-expected.txt
index 6ef835a7..088c48c 100644
--- a/third_party/blink/web_tests/compositing/iframes/composited-parent-iframe-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/composited-parent-iframe-expected.txt
@@ -19,12 +19,12 @@
     },
     {
       "name": "LayoutIFrame IFRAME",
-      "bounds": [368, 218],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
       "name": "LayoutView #document",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "backgroundColor": "#C0C0C0",
@@ -32,14 +32,14 @@
     },
     {
       "name": "Scrolling Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Scrolling Contents Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 230],
       "backgroundColor": "#C0C0C0",
       "transform": 1
@@ -53,14 +53,14 @@
     },
     {
       "name": "Overflow Controls Host Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Vertical Scrollbar Layer",
-      "position": [319, 34],
+      "position": [330, 45],
       "bounds": [15, 150],
       "drawsContent": false,
       "transform": 1
@@ -73,7 +73,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [-11, -11, 0, 1]
+        [-22, -22, 0, 1]
       ]
     },
     {
@@ -83,7 +83,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [52, 44, 0, 1]
+        [63, 55, 0, 1]
       ]
     }
   ]
diff --git a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-delayed-expected.txt b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-delayed-expected.txt
index 2b0056f..8a29d61 100644
--- a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-delayed-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-delayed-expected.txt
@@ -21,8 +21,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='iframe'",
-      "position": [9, 109],
-      "bounds": [368, 218]
+      "position": [-2, 98],
+      "bounds": [390, 240]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-expected.txt b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-expected.txt
index 4761343..654aa81 100644
--- a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe-expected.txt
@@ -19,12 +19,12 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='parent-iframe'",
-      "bounds": [368, 218],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
       "name": "LayoutView #document",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "backgroundColor": "#C0C0C0",
@@ -32,14 +32,14 @@
     },
     {
       "name": "Scrolling Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Scrolling Contents Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 230],
       "backgroundColor": "#C0C0C0",
       "transform": 1
@@ -53,14 +53,14 @@
     },
     {
       "name": "Overflow Controls Host Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Vertical Scrollbar Layer",
-      "position": [319, 34],
+      "position": [330, 45],
       "bounds": [15, 150],
       "drawsContent": false,
       "transform": 1
@@ -79,7 +79,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [9, 9, 0, 1]
+        [-2, -2, 0, 1]
       ]
     },
     {
@@ -89,7 +89,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [52, 44, 0, 1]
+        [63, 55, 0, 1]
       ]
     }
   ]
diff --git a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe2-expected.txt b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe2-expected.txt
index 749f12a..3af93b37 100644
--- a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe2-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe2-expected.txt
@@ -19,12 +19,12 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='iframe' class='composited'",
-      "bounds": [368, 218],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
       "name": "LayoutView #document",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "backgroundColor": "#C0C0C0",
@@ -32,14 +32,14 @@
     },
     {
       "name": "Scrolling Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Scrolling Contents Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 230],
       "backgroundColor": "#C0C0C0",
       "transform": 1
@@ -53,14 +53,14 @@
     },
     {
       "name": "Overflow Controls Host Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Vertical Scrollbar Layer",
-      "position": [319, 34],
+      "position": [330, 45],
       "bounds": [15, 150],
       "drawsContent": false,
       "transform": 1
@@ -79,7 +79,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [9, 9, 0, 1]
+        [-2, -2, 0, 1]
       ]
     },
     {
@@ -89,7 +89,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [52, 44, 0, 1]
+        [63, 55, 0, 1]
       ]
     }
   ]
diff --git a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe3-expected.txt b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe3-expected.txt
index 94d4b5b..a466eb95 100644
--- a/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe3-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/connect-compositing-iframe3-expected.txt
@@ -19,12 +19,12 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='iframe' class='composited'",
-      "bounds": [368, 218],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
       "name": "LayoutView #document",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "backgroundColor": "#C0C0C0",
@@ -32,14 +32,14 @@
     },
     {
       "name": "Scrolling Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Scrolling Contents Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [285, 230],
       "backgroundColor": "#C0C0C0",
       "transform": 1
@@ -53,14 +53,14 @@
     },
     {
       "name": "Overflow Controls Host Layer",
-      "position": [34, 34],
+      "position": [45, 45],
       "bounds": [300, 150],
       "drawsContent": false,
       "transform": 1
     },
     {
       "name": "Vertical Scrollbar Layer",
-      "position": [319, 34],
+      "position": [330, 45],
       "bounds": [15, 150],
       "drawsContent": false,
       "transform": 1
@@ -73,7 +73,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [9, 9, 0, 1]
+        [-2, -2, 0, 1]
       ]
     },
     {
@@ -83,7 +83,7 @@
         [1, 0, 0, 0],
         [0, 1, 0, 0],
         [0, 0, 1, 0],
-        [52, 44, 0, 1]
+        [63, 55, 0, 1]
       ]
     }
   ]
diff --git a/third_party/blink/web_tests/compositing/iframes/enter-compositing-iframe-expected.txt b/third_party/blink/web_tests/compositing/iframes/enter-compositing-iframe-expected.txt
index 6740182..966b36e 100644
--- a/third_party/blink/web_tests/compositing/iframes/enter-compositing-iframe-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/enter-compositing-iframe-expected.txt
@@ -19,8 +19,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='parent-iframe'",
-      "position": [9, 9],
-      "bounds": [368, 218]
+      "position": [-2, -2],
+      "bounds": [390, 240]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/compositing/iframes/iframe-resize-expected.txt b/third_party/blink/web_tests/compositing/iframes/iframe-resize-expected.txt
index d0bbba2..5aedefb 100644
--- a/third_party/blink/web_tests/compositing/iframes/iframe-resize-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/iframe-resize-expected.txt
@@ -19,8 +19,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='parent-iframe' class='bigger'",
-      "position": [9, 9],
-      "bounds": [468, 188]
+      "position": [-2, -2],
+      "bounds": [490, 210]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/compositing/iframes/overlapped-iframe-expected.txt b/third_party/blink/web_tests/compositing/iframes/overlapped-iframe-expected.txt
index f76bbad9..329f002 100644
--- a/third_party/blink/web_tests/compositing/iframes/overlapped-iframe-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/overlapped-iframe-expected.txt
@@ -19,8 +19,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='parent-iframe'",
-      "position": [9, 9],
-      "bounds": [368, 218]
+      "position": [-2, -2],
+      "bounds": [390, 240]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/compositing/iframes/scrolling-iframe-expected.txt b/third_party/blink/web_tests/compositing/iframes/scrolling-iframe-expected.txt
index b3aefc4..34b2b39 100644
--- a/third_party/blink/web_tests/compositing/iframes/scrolling-iframe-expected.txt
+++ b/third_party/blink/web_tests/compositing/iframes/scrolling-iframe-expected.txt
@@ -19,8 +19,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='parent-iframe'",
-      "position": [9, 9],
-      "bounds": [368, 218]
+      "position": [-2, -2],
+      "bounds": [390, 240]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/compositing/overflow/border-radius-above-composited-subframe-expected.png b/third_party/blink/web_tests/compositing/overflow/border-radius-above-composited-subframe-expected.png
index 1a941fc1..b2e1c50 100644
--- a/third_party/blink/web_tests/compositing/overflow/border-radius-above-composited-subframe-expected.png
+++ b/third_party/blink/web_tests/compositing/overflow/border-radius-above-composited-subframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/overflow/border-radius-composited-subframe-expected.png b/third_party/blink/web_tests/compositing/overflow/border-radius-composited-subframe-expected.png
index d0ef886..40a7c91 100644
--- a/third_party/blink/web_tests/compositing/overflow/border-radius-composited-subframe-expected.png
+++ b/third_party/blink/web_tests/compositing/overflow/border-radius-composited-subframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.png b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.png
index e354a92..0c8b2c5 100644
--- a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.png
+++ b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.txt b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.txt
index b5a628c..7059b2e 100644
--- a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.txt
+++ b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-expected.txt
@@ -19,13 +19,12 @@
     },
     {
       "name": "LayoutBlockFlow (positioned) DIV class='outer A'",
-      "position": [6, 6],
-      "bounds": [340, 282]
+      "bounds": [352, 294]
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='scroller'",
-      "position": [38, 38],
-      "bounds": [278, 218],
+      "position": [32, 32],
+      "bounds": [290, 230],
       "backgroundColor": "#FFFFFF"
     },
     {
@@ -54,13 +53,13 @@
     },
     {
       "name": "LayoutBlockFlow (positioned) DIV class='outer B'",
-      "position": [355, 6],
-      "bounds": [340, 282]
+      "position": [349, 0],
+      "bounds": [352, 294]
     },
     {
       "name": "LayoutBlockFlow DIV class='scroller'",
-      "position": [387, 38],
-      "bounds": [278, 218],
+      "position": [381, 32],
+      "bounds": [290, 230],
       "backgroundColor": "#FFFFFF"
     },
     {
@@ -96,13 +95,13 @@
     },
     {
       "name": "LayoutBlockFlow (positioned) DIV class='outer C'",
-      "position": [6, 297],
-      "bounds": [340, 282]
+      "position": [0, 291],
+      "bounds": [352, 294]
     },
     {
       "name": "LayoutBlockFlow DIV class='scroller'",
-      "position": [37, 328],
-      "bounds": [278, 218],
+      "position": [31, 322],
+      "bounds": [290, 230],
       "backgroundColor": "#FFFFFF"
     },
     {
@@ -138,8 +137,8 @@
     },
     {
       "name": "LayoutBlockFlow (positioned) DIV class='outer D'",
-      "position": [355, 297],
-      "bounds": [340, 282]
+      "position": [349, 291],
+      "bounds": [352, 294]
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='clipper'",
@@ -148,8 +147,8 @@
     },
     {
       "name": "LayoutBlockFlow DIV class='scroller'",
-      "position": [386, 328],
-      "bounds": [278, 218],
+      "position": [380, 322],
+      "bounds": [290, 230],
       "backgroundColor": "#FFFFFF"
     },
     {
diff --git a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.png b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.png
index 86f7a203..d3100be 100644
--- a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.png
+++ b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.txt b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.txt
index 4a17d69..d9661e2e 100644
--- a/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.txt
+++ b/third_party/blink/web_tests/compositing/overflow/scrollbar-layer-placement-negative-z-index-child-positioned-expected.txt
@@ -19,8 +19,7 @@
     },
     {
       "name": "LayoutBlockFlow (positioned) DIV class='outer'",
-      "position": [6, 6],
-      "bounds": [340, 282]
+      "bounds": [352, 294]
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='content'",
@@ -31,13 +30,12 @@
     },
     {
       "name": "LayoutBlockFlow (positioned) DIV class='outer' (foreground) Layer",
-      "position": [6, 6],
-      "bounds": [340, 282]
+      "bounds": [352, 294]
     },
     {
       "name": "LayoutBlockFlow (relative positioned) DIV class='scroller'",
-      "position": [38, 38],
-      "bounds": [278, 218],
+      "position": [32, 32],
+      "bounds": [290, 230],
       "backgroundColor": "#FFFFFF"
     },
     {
diff --git a/third_party/blink/web_tests/display-lock/lock-before-append/commit-while-disconnected-expected.html b/third_party/blink/web_tests/display-lock/lock-before-append/commit-while-disconnected-expected.html
deleted file mode 100644
index 1333caeb..0000000
--- a/third_party/blink/web_tests/display-lock/lock-before-append/commit-while-disconnected-expected.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!doctype HTML>
-
-<div id="log">PASS</div>
-
diff --git a/third_party/blink/web_tests/display-lock/lock-before-append/commit-while-disconnected.html b/third_party/blink/web_tests/display-lock/lock-before-append/commit-while-disconnected.html
deleted file mode 100644
index a5643b93..0000000
--- a/third_party/blink/web_tests/display-lock/lock-before-append/commit-while-disconnected.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!doctype HTML>
-
-<!--
-Runs an acquire(), then commits without connecting the element.
--->
-
-<div id="log"></div>
-
-<script>
-// TODO(vmpstr): In WPT this needs to be replaced with reftest-wait.
-if (window.testRunner)
-  window.testRunner.waitUntilDone();
-
-function finishTest(status_string) {
-  if (document.getElementById("log").innerHTML === "")
-    document.getElementById("log").innerHTML = status_string;
-  if (window.testRunner)
-    window.testRunner.notifyDone();
-}
-
-function runTest() {
-  let container = document.createElement("div");
-  container.id = "container";
-
-  container.getDisplayLock().acquire({ timeout: Infinity }).then(() => {
-    container.getDisplayLock().commit().then(
-      () => { finishTest("FAIL"); },
-      () => { finishTest("PASS"); });
-  });
-}
-
-window.onload = runTest;
-</script>
diff --git a/third_party/blink/web_tests/display-lock/lock-before-append/update-while-disconnected-expected.html b/third_party/blink/web_tests/display-lock/lock-before-append/update-while-disconnected-expected.html
deleted file mode 100644
index 1333caeb..0000000
--- a/third_party/blink/web_tests/display-lock/lock-before-append/update-while-disconnected-expected.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<!doctype HTML>
-
-<div id="log">PASS</div>
-
diff --git a/third_party/blink/web_tests/display-lock/lock-before-append/update-while-disconnected.html b/third_party/blink/web_tests/display-lock/lock-before-append/update-while-disconnected.html
deleted file mode 100644
index 9f0e4ed..0000000
--- a/third_party/blink/web_tests/display-lock/lock-before-append/update-while-disconnected.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!doctype HTML>
-
-<!--
-Runs an acquire(), then updates without connecting the element.
--->
-
-<div id="log"></div>
-
-<script>
-// TODO(vmpstr): In WPT this needs to be replaced with reftest-wait.
-if (window.testRunner)
-  window.testRunner.waitUntilDone();
-
-function finishTest(status_string) {
-  if (document.getElementById("log").innerHTML === "")
-    document.getElementById("log").innerHTML = status_string;
-  if (window.testRunner)
-    window.testRunner.notifyDone();
-}
-
-function runTest() {
-  let container = document.createElement("div");
-  container.id = "container";
-
-  container.getDisplayLock().acquire({ timeout: Infinity }).then(() => {
-    container.getDisplayLock().update().then(
-      () => { finishTest("FAIL"); },
-      () => { finishTest("PASS"); });
-  });
-}
-
-window.onload = runTest;
-</script>
diff --git a/third_party/blink/web_tests/editing/inserting/caret-position.html b/third_party/blink/web_tests/editing/inserting/caret-position.html
index d8246ab..36668f19 100644
--- a/third_party/blink/web_tests/editing/inserting/caret-position.html
+++ b/third_party/blink/web_tests/editing/inserting/caret-position.html
@@ -4,7 +4,7 @@
 <script src="../../resources/testharnessreport.js"></script>
 <script>
 
-function testCaretPosition(elementId, caretPosition) {
+function testLtrCaretPosition(elementId, caretPosition) {
   test(() => {
     assert_own_property(window, 'textInputController');
     e = document.getElementById(elementId);
@@ -14,6 +14,19 @@
   }, `${elementId} ${caretPosition}`);
 }
 
+function testRtlCaretPosition(elementId, caretPosition) {
+  test(() => {
+    assert_own_property(window, 'textInputController');
+    e = document.getElementById(elementId);
+    e.focus();
+    // Asserts the visual location of the text's right edge, whose logical
+    // offset differs with the bidi caret affinity flag.
+    var caretOffset = internals.runtimeFlags.bidiCaretAffinityEnabled ? 1 : 0;
+    var caretRect = textInputController.firstRectForCharacterRange(caretOffset, 0);
+    assert_equals(caretRect[0], caretPosition);
+  }, `${elementId} ${caretPosition}`);
+}
+
 function runTest() {
   test(() => {
     assert_own_property(window, 'textInputController');
@@ -25,15 +38,15 @@
     assert_equals(caretRect[0], 208);
   }, 'right-align-div 208 after typing');
 
-  testCaretPosition("rtl-div", 208);
-  testCaretPosition("0-right-padding-rtl-textarea", 206);
-  testCaretPosition("ltr-div", 9);
-  testCaretPosition("ltr-textarea", 10);
-  testCaretPosition("no-wrapping-right-align-div", 208);
-  testCaretPosition("no-wrapping-rtl-div", 208);
-  testCaretPosition("no-wrapping-0-right-padding-rtl-textarea", 206);
-  testCaretPosition("no-wrapping-ltr-div", 9);
-  testCaretPosition("no-wrapping-ltr-textarea", 10);
+  testRtlCaretPosition("rtl-div", 208);
+  testRtlCaretPosition("0-right-padding-rtl-textarea", 206);
+  testLtrCaretPosition("ltr-div", 9);
+  testLtrCaretPosition("ltr-textarea", 10);
+  testLtrCaretPosition("no-wrapping-right-align-div", 208);
+  testRtlCaretPosition("no-wrapping-rtl-div", 208);
+  testRtlCaretPosition("no-wrapping-0-right-padding-rtl-textarea", 206);
+  testLtrCaretPosition("no-wrapping-ltr-div", 9);
+  testLtrCaretPosition("no-wrapping-ltr-textarea", 10);
 }
 
 </script>
diff --git a/third_party/blink/web_tests/editing/selection/caret-bidi-first-and-last-letters.html b/third_party/blink/web_tests/editing/selection/caret-bidi-first-and-last-letters.html
index 55ec3f45..849fe75d 100644
--- a/third_party/blink/web_tests/editing/selection/caret-bidi-first-and-last-letters.html
+++ b/third_party/blink/web_tests/editing/selection/caret-bidi-first-and-last-letters.html
@@ -65,10 +65,11 @@
     div.innerHTML = message;
 }
 
-runTest(document.getElementById('rtl-in-ltr-first'), 'first', 0);
-runTest(document.getElementById('rtl-in-ltr-last'), 'last', 7);
-runTest(document.getElementById('ltr-in-rtl-first'), 'first', 7);
-runTest(document.getElementById('ltr-in-rtl-last'), 'last', 0);
+const usesBidiAffinity = window.internals && internals.runtimeFlags.bidiCaretAffinityEnabled;
+runTest(document.getElementById('rtl-in-ltr-first'), 'first', usesBidiAffinity ? 7 : 0);
+runTest(document.getElementById('rtl-in-ltr-last'), 'last', usesBidiAffinity ? 0 : 7);
+runTest(document.getElementById('ltr-in-rtl-first'), 'first', usesBidiAffinity ? 0 : 7);
+runTest(document.getElementById('ltr-in-rtl-last'), 'last', usesBidiAffinity ? 7 : 0);
 
 </script>
 </body>
diff --git a/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/events/compile-event-handler-lexical-scopes.html b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/events/compile-event-handler-lexical-scopes.html
new file mode 100644
index 0000000..ed6c006
--- /dev/null
+++ b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/events/compile-event-handler-lexical-scopes.html
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Lexical scopes when compiling an inline event handler</title>
+<link rel="help" href="https://html.spec.whatwg.org/C/#getting-the-current-value-of-the-event-handler">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<script>
+setup({allow_uncaught_exception: true});
+</script>
+
+<!-- test case 1: element, document, and window -->
+
+<table>
+  <tr id="test1_outer">
+    <td id="test1_target" onclick="
+window.testResults.complete = typeof(complete);
+window.testResults.cellIndex = typeof(cellIndex);
+window.testResults.cells = typeof(cells);
+window.testResults.domain = typeof(domain);
+window.testResults.print = typeof(print);
+window.testResults.testResults = typeof(testResults);
+window.testResults.target_own_property = typeof(target_own_property);
+window.testResults.inner_own_property = typeof(inner_own_property);
+window.testResults.outer_own_property = typeof(outer_own_property);
+window.testResults.event = typeof(event);
+">
+      <img id="test1_inner">
+    </td>
+  </tr>
+</table>
+
+<script>
+"use strict";
+
+test(() => {
+  const target_element = document.getElementById("test1_target");
+  const inner_element = document.getElementById("test1_inner");
+  const outer_element = document.getElementById("test1_outer");
+
+  target_element.target_own_property = {};
+  inner_element.inner_own_property = {};
+  outer_element.outer_own_property = {};
+
+  const results = window.testResults = {};
+  // Clicking an inner element makes the event target where the event handler is
+  // registered doesn't match the event target that the event is fired.  From a
+  // point of view |target_element|, event.target != event.currentTarget.
+  inner_element.click();
+  // Expected scopes are: |target_element|, document, and window.
+  assert_equals(results.complete, "undefined", "HTMLImageElement.prototype.complete");
+  assert_equals(results.cellIndex, "number", "HTMLTableCellElement.prototype.cellIndex");
+  assert_equals(results.cells, "undefined", "HTMLTableRowElement.prototype.cellIndex");
+  assert_equals(results.domain, "string", "Document.prototype.domain");
+  assert_equals(results.print, "function", "window.print");
+  assert_equals(results.testResults, "object");
+  assert_equals(results.target_own_property, "object");
+  assert_equals(results.inner_own_property, "undefined");
+  assert_equals(results.outer_own_property, "undefined");
+  assert_equals(results.event, "object", "The argument of event handler");
+}, "The EventHandler is an element's event handler and has no form owner.");
+</script>
+
+
+<!-- test case 2: element, form owner, document, and window -->
+
+<form id="test2_form_owner" onsubmit="return false;">
+  <!-- 'button' is a form-associated element and has a form owner.
+       https://html.spec.whatwg.org/C/#form-associated-element
+    -->
+  <button id="test2_target" onclick="
+window.testResults.cite = typeof(cite);
+window.testResults.autofocus = typeof(autofocus);
+window.testResults.form = typeof(form);
+window.testResults.encoding = typeof(encoding);
+window.testResults.domain = typeof(domain);
+window.testResults.print = typeof(print);
+window.testResults.testResults = typeof(testResults);
+window.testResults.target_own_property = typeof(target_own_property);
+window.testResults.inner_own_property = typeof(inner_own_property);
+window.testResults.form_owner_own_property = typeof(form_owner_own_property);
+window.testResults.event = typeof(event);
+">
+    <q id="test2_inner"></q>
+  </button>
+</form>
+
+<script>
+"use strict";
+
+test(() => {
+  const target_element = document.getElementById("test2_target");
+  const inner_element = document.getElementById("test2_inner");
+  const form_owner_element = document.getElementById("test2_form_owner");
+
+  target_element.target_own_property = {};
+  inner_element.inner_own_property = {};
+  form_owner_element.form_owner_own_property = {};
+
+  const results = window.testResults = {};
+  // Clicking an inner element makes the event target where the event handler is
+  // registered doesn't match the event target that the event is fired.  From a
+  // point of view |target_element|, event.target != event.currentTarget.
+  inner_element.click();
+  // Expected scopes are: |target_element|, form owner, document, and window.
+  assert_equals(results.cite, "undefined", "HTMLQuoteElement.prototype.cite");
+  assert_equals(results.autofocus, "boolean", "HTMLButtonElement.prototype.autofocus");
+  assert_equals(results.form, "object", "HTMLButtonElement.prototype.form");
+  assert_equals(results.encoding, "string", "HTMLFormElement.prototype.encoding");
+  assert_equals(results.domain, "string", "Document.prototype.domain");
+  assert_equals(results.print, "function", "window.print");
+  assert_equals(results.testResults, "object");
+  assert_equals(results.target_own_property, "object");
+  assert_equals(results.inner_own_property, "undefined");
+  assert_equals(results.form_owner_own_property, "object");
+  assert_equals(results.event, "object", "The argument of event handler");
+}, "The EventHandler is an element's event handler and has a form owner.");
+</script>
+
+
+<!-- test case 3: element and window -->
+
+<a id="test3_inner"></a>
+
+<script>
+"use strict";
+
+// This test is placed at last so that it can safely use a global variable
+// without conflicting other tests.  Only this test is asynchronous.
+async_test(t => {
+  const target_element = window;
+  const inner_element = document.getElementById("test3_inner");
+
+  target_element.target_own_property = {};
+  inner_element.inner_own_property = {};
+  document.body.body_own_property = {};
+
+  // "onerror" is one of the Window-reflecting body element event handler set.
+  // https://html.spec.whatwg.org/C/#window-reflecting-body-element-event-handler-set
+  // So, the EventHandler is treated as a Window's event handler.
+  document.body.setAttribute("onerror", "\
+window.testResults.ping = typeof(ping);  \
+window.testResults.domain = typeof(domain);  \
+window.testResults.print = typeof(print);  \
+window.testResults.testResults = typeof(testResults);  \
+window.testResults.target_own_property = typeof(target_own_property);  \
+window.testResults.inner_own_property = typeof(inner_own_property);  \
+window.testResults.body_own_property = typeof(body_own_property);  \
+window.testResults.event = typeof(event);  \
+");
+
+  const results = window.testResults = {};
+  window.addEventListener("error", t.step_func_done(() => {
+    // Expected scopes are: |target_element| and window only.
+    assert_equals(results.domain, "undefined", "Document.prototype.domain");
+    assert_equals(results.print, "function", "window.print");
+    assert_equals(results.testResults, "object");
+    assert_equals(results.target_own_property, "object");
+    assert_equals(results.inner_own_property, "undefined");
+    assert_in_array(results.event, ["object", "string"], "The first argument of onerror event handler");
+  }));
+
+  // Make a compilation error happen in order to invoke onerror event handler.
+  inner_element.setAttribute("onclick", "cause a compilation error");
+  inner_element.click();
+}, "The EventHandler is not an element's event handler (i.e. Window's event handler) and has no form owner.");
+</script>
diff --git a/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-01-expected.png b/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-01-expected.png
index 23ceb1f..a5b617f 100644
--- a/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-01-expected.png
+++ b/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-01-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-expected.png b/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-expected.png
index 6899c1f..7c02ce3 100644
--- a/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-expected.png
+++ b/third_party/blink/web_tests/fast/borders/border-radius-with-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/box-shadow/box-shadow-clipped-slices-expected.png b/third_party/blink/web_tests/fast/box-shadow/box-shadow-clipped-slices-expected.png
index 2142969..0af4668 100644
--- a/third_party/blink/web_tests/fast/box-shadow/box-shadow-clipped-slices-expected.png
+++ b/third_party/blink/web_tests/fast/box-shadow/box-shadow-clipped-slices-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/box-shadow/box-shadow-radius-expected.png b/third_party/blink/web_tests/fast/box-shadow/box-shadow-radius-expected.png
index 8ff353b3..714afdb 100644
--- a/third_party/blink/web_tests/fast/box-shadow/box-shadow-radius-expected.png
+++ b/third_party/blink/web_tests/fast/box-shadow/box-shadow-radius-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/box-shadow/scaled-box-shadow-expected.png b/third_party/blink/web_tests/fast/box-shadow/scaled-box-shadow-expected.png
index 8020f43c..607dd3d 100644
--- a/third_party/blink/web_tests/fast/box-shadow/scaled-box-shadow-expected.png
+++ b/third_party/blink/web_tests/fast/box-shadow/scaled-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/box-shadow/shadow-buffer-partial-expected.png b/third_party/blink/web_tests/fast/box-shadow/shadow-buffer-partial-expected.png
index 9d520acb..a8f0136 100644
--- a/third_party/blink/web_tests/fast/box-shadow/shadow-buffer-partial-expected.png
+++ b/third_party/blink/web_tests/fast/box-shadow/shadow-buffer-partial-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/box-shadow/shadow-tiling-artifact-expected.png b/third_party/blink/web_tests/fast/box-shadow/shadow-tiling-artifact-expected.png
index 33ac08c..d356a861 100644
--- a/third_party/blink/web_tests/fast/box-shadow/shadow-tiling-artifact-expected.png
+++ b/third_party/blink/web_tests/fast/box-shadow/shadow-tiling-artifact-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/box-shadow/single-pixel-shadow-expected.png b/third_party/blink/web_tests/fast/box-shadow/single-pixel-shadow-expected.png
index b3811c74..c06b49d 100644
--- a/third_party/blink/web_tests/fast/box-shadow/single-pixel-shadow-expected.png
+++ b/third_party/blink/web_tests/fast/box-shadow/single-pixel-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/fast/canvas/canvas-scale-shadowBlur.html b/third_party/blink/web_tests/fast/canvas/canvas-scale-shadowBlur.html
index 024b45ab..a8704493 100644
--- a/third_party/blink/web_tests/fast/canvas/canvas-scale-shadowBlur.html
+++ b/third_party/blink/web_tests/fast/canvas/canvas-scale-shadowBlur.html
@@ -50,29 +50,29 @@
 
 var testPixelShadowBlurScenarios = [
     ['Verify top left 1', 250, 250, [255, 0, 0, 255]],
-    ['Verify top left 2', 250, 175, [0, 0, 0, 0]],
-    ['Verify top left 3', 250, 325, [0, 0, 0, 0]],
-    ['Verify top left 4', 175, 250, [0, 0, 0, 0]],
-    ['Verify top left 5', 325, 250, [0, 0, 0, 0]],
+    ['Verify top left 2', 250, 160, [0, 0, 0, 0]],
+    ['Verify top left 3', 250, 340, [0, 0, 0, 0]],
+    ['Verify top left 4', 160, 250, [0, 0, 0, 0]],
+    ['Verify top left 5', 340, 250, [0, 0, 0, 0]],
 
     ['Verify bottom left 1', 250, 450, [255, 0, 0, 126, 20]],
-    ['Verify bottom left 2', 250, 375, [0, 0, 0, 0]],
-    ['Verify bottom left 3', 250, 525, [0, 0, 0, 0]],
-    ['Verify bottom left 4', 175, 450, [0, 0, 0, 0]],
-    ['Verify bottom left 5', 325, 450, [0, 0, 0, 0]],
+    ['Verify bottom left 2', 250, 360, [0, 0, 0, 0]],
+    ['Verify bottom left 3', 250, 540, [0, 0, 0, 0]],
+    ['Verify bottom left 4', 160, 450, [0, 0, 0, 0]],
+    ['Verify bottom left 5', 340, 450, [0, 0, 0, 0]],
     ['Verify bottom left 6', 250, 250, [255, 0, 0, 255, 20]],
 
     ['Verify top right 1', 450, 250, [255, 0, 0, 255, 20]],
-    ['Verify top right 2', 450, 175, [0, 0, 0, 0]],
-    ['Verify top right 3', 450, 325, [0, 0, 0, 0]],
-    ['Verify top right 4', 375, 250, [0, 0, 0, 0]],
-    ['Verify top right 5', 525, 250, [0, 0, 0, 0]],
+    ['Verify top right 2', 450, 160, [0, 0, 0, 0]],
+    ['Verify top right 3', 450, 340, [0, 0, 0, 0]],
+    ['Verify top right 4', 360, 250, [0, 0, 0, 0]],
+    ['Verify top right 5', 540, 250, [0, 0, 0, 0]],
 
     ['Verify bottom right 1', 450, 450, [255, 0, 0, 126, 20]],
-    ['Verify bottom right 2', 450, 375, [0, 0, 0, 0]],
-    ['Verify bottom right 3', 450, 525, [0, 0, 0, 0]],
-    ['Verify bottom right 4', 375, 450, [0, 0, 0, 0]],
-    ['Verify bottom right 5', 525, 450, [0, 0, 0, 0]],
+    ['Verify bottom right 2', 450, 360, [0, 0, 0, 0]],
+    ['Verify bottom right 3', 450, 540, [0, 0, 0, 0]],
+    ['Verify bottom right 4', 360, 450, [0, 0, 0, 0]],
+    ['Verify bottom right 5', 540, 450, [0, 0, 0, 0]],
 ];
 
 generate_tests(testPixelShadowBlur, testPixelShadowBlurScenarios);
diff --git a/third_party/blink/web_tests/fast/canvas/canvas-scale-strokePath-shadow.html b/third_party/blink/web_tests/fast/canvas/canvas-scale-strokePath-shadow.html
index ea50df6b..fb40e1fb 100644
--- a/third_party/blink/web_tests/fast/canvas/canvas-scale-strokePath-shadow.html
+++ b/third_party/blink/web_tests/fast/canvas/canvas-scale-strokePath-shadow.html
@@ -75,7 +75,7 @@
 
     ['Verify blurry shadow 1', 398, 210, [255, 0, 0, 200, 20]],
     ['Verify blurry shadow 2', 508, 250, [255, 0, 0, 49, 20]],
-    ['Verify blurry shadow 3', 450, 198, [255, 0, 0, 199, 20]],
+    ['Verify blurry shadow 3', 450, 198, [255, 0, 0, 178, 20]],
     
     ['Verify blurry alpha shadow 1', 505, 450, [255, 0, 0, 70, 20]],
     ['Verify blurry alpha shadow 2', 450, 405, [255, 0, 0, 70, 20]],
diff --git a/third_party/blink/web_tests/fast/canvas/canvas-transforms-fillRect-shadow.html b/third_party/blink/web_tests/fast/canvas/canvas-transforms-fillRect-shadow.html
index 3ef44bf..6a174963 100644
--- a/third_party/blink/web_tests/fast/canvas/canvas-transforms-fillRect-shadow.html
+++ b/third_party/blink/web_tests/fast/canvas/canvas-transforms-fillRect-shadow.html
@@ -54,7 +54,7 @@
 
     ['Verify blurry shadow 1', 399, 205, [255, 0, 0, 106, alphaTolerance]],
     ['Verify blurry shadow 2', 500, 205, [255, 0, 0, 106, alphaTolerance]],
-    ['Verify blurry shadow 3', 499, 299, [255, 0, 0, 106, alphaTolerance]],
+    ['Verify blurry shadow 3', 499, 299, [255, 0, 0,  85, alphaTolerance]],
     
     ['Verify blurry alpha shadow 1', 398, 405, [255, 0, 0, 36, alphaTolerance]],
     ['Verify blurry alpha shadow 2', 405, 501, [255, 0, 0, 36, alphaTolerance]],
diff --git a/third_party/blink/web_tests/fast/css/box-shadow-and-border-radius-expected.png b/third_party/blink/web_tests/fast/css/box-shadow-and-border-radius-expected.png
index d73c4a9..2f9552f 100644
--- a/third_party/blink/web_tests/fast/css/box-shadow-and-border-radius-expected.png
+++ b/third_party/blink/web_tests/fast/css/box-shadow-and-border-radius-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt
index 69c0c9c..84c3d4e7 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/contents-opaque/overflow-hidden-child-layers-expected.txt
@@ -8,8 +8,8 @@
     },
     {
       "name": "LayoutBlockFlow DIV class='box'",
-      "position": [-19, -19],
-      "bounds": [138, 138],
+      "position": [-30, -30],
+      "bounds": [160, 160],
       "backgroundColor": "#0000FF",
       "transform": 1
     }
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
index 27c7382..fe37bf2 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/composited-parent-iframe-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/composited-parent-iframe-expected.txt
index df3bda0..195f98e 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/composited-parent-iframe-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/composited-parent-iframe-expected.txt
@@ -8,8 +8,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME",
-      "position": [-19, -19],
-      "bounds": [368, 218],
+      "position": [-30, -30],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe-expected.txt
index d5eb622..aa66ce7 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe-expected.txt
@@ -8,8 +8,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='parent-iframe'",
-      "position": [-19, -19],
-      "bounds": [368, 218],
+      "position": [-30, -30],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe2-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe2-expected.txt
index 6504cec..813ea080 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe2-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe2-expected.txt
@@ -8,8 +8,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='iframe' class='composited'",
-      "position": [-19, -19],
-      "bounds": [368, 218],
+      "position": [-30, -30],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe3-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe3-expected.txt
index 124b482..c64b3b6 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe3-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/iframes/connect-compositing-iframe3-expected.txt
@@ -8,8 +8,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME id='iframe' class='composited'",
-      "position": [-19, -19],
-      "bounds": [368, 218],
+      "position": [-30, -30],
+      "bounds": [390, 240],
       "transform": 1
     },
     {
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/masks/masked-ancestor-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/masks/masked-ancestor-expected.png
index 3483bf76..cea55ad7 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/masks/masked-ancestor-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/masks/masked-ancestor-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-above-composited-subframe-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-above-composited-subframe-expected.png
index 1a941fc1..b2e1c50 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-above-composited-subframe-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-above-composited-subframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-composited-subframe-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-composited-subframe-expected.png
index 9dc62ee..3689c37 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-composited-subframe-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/overflow/border-radius-composited-subframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/video/video-controls-layer-creation-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/video/video-controls-layer-creation-expected.png
index 48f0744..7f05b3a 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/video/video-controls-layer-creation-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/compositing/video/video-controls-layer-creation-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-canvas-with-shadow-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
index 42ee4528..724d267 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-video-shadow-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-video-shadow-expected.png
index 7e26cf82..8cd050d6 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-video-shadow-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/fast/borders/border-radius-mask-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-add-repaint-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-add-repaint-expected.txt
index 5f56171..42d73cc7 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-add-repaint-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-add-repaint-expected.txt
@@ -8,7 +8,7 @@
       "paintInvalidations": [
         {
           "object": "LayoutBlockFlow DIV id='test'",
-          "rect": [7, 7, 112, 112],
+          "rect": [5, 5, 116, 116],
           "reason": "style change"
         }
       ]
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-change-repaint-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-change-repaint-expected.txt
index 67d544b9..e823a23 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-change-repaint-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/box/box-shadow-change-repaint-expected.txt
@@ -8,7 +8,7 @@
       "paintInvalidations": [
         {
           "object": "LayoutBlockFlow DIV id='test'",
-          "rect": [7, 7, 122, 122],
+          "rect": [3, 3, 130, 130],
           "reason": "style change"
         }
       ]
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/transform/transform-replaced-shadows-expected.txt b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/transform/transform-replaced-shadows-expected.txt
index 764cc954..f7f5bcb 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/transform/transform-replaced-shadows-expected.txt
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/paint/invalidation/transform/transform-replaced-shadows-expected.txt
@@ -8,12 +8,12 @@
       "paintInvalidations": [
         {
           "object": "LayoutImage IMG id='box' class='smaller'",
-          "rect": [0, 28, 266, 278],
+          "rect": [0, 8, 288, 320],
           "reason": "paint property change"
         },
         {
           "object": "LayoutImage IMG id='box' class='smaller'",
-          "rect": [9, 28, 138, 139],
+          "rect": [0, 18, 158, 160],
           "reason": "paint property change"
         }
       ]
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 3113eba..e3b3b9b7 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 4644409..40d4675 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 4644409..40d4675 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=CompositeAfterPaint/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/box-shadow/box-shadow-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/box-shadow/box-shadow-expected.png
deleted file mode 100644
index 415c0eb..0000000
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/box-shadow/box-shadow-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index 4b87079..8bef501 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/writing-mode/english-lr-text-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/writing-mode/english-lr-text-expected.png
index 8af26237..4f68f49 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/writing-mode/english-lr-text-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/fast/writing-mode/english-lr-text-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/ietestcenter/css3/text/textshadow-002-expected.png b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/ietestcenter/css3/text/textshadow-002-expected.png
index be893eb..3937cc9 100644
--- a/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/ietestcenter/css3/text/textshadow-002-expected.png
+++ b/third_party/blink/web_tests/flag-specific/enable-blink-features=LayoutNG/ietestcenter/css3/text/textshadow-002-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/paint/invalidation/box/box-shadow-add-repaint-expected.txt b/third_party/blink/web_tests/paint/invalidation/box/box-shadow-add-repaint-expected.txt
index 6158fba..7942d46 100644
--- a/third_party/blink/web_tests/paint/invalidation/box/box-shadow-add-repaint-expected.txt
+++ b/third_party/blink/web_tests/paint/invalidation/box/box-shadow-add-repaint-expected.txt
@@ -19,7 +19,7 @@
       "paintInvalidations": [
         {
           "object": "LayoutBlockFlow DIV id='test'",
-          "rect": [7, 7, 112, 112],
+          "rect": [5, 5, 116, 116],
           "reason": "style change"
         }
       ]
diff --git a/third_party/blink/web_tests/paint/invalidation/box/box-shadow-change-repaint-expected.txt b/third_party/blink/web_tests/paint/invalidation/box/box-shadow-change-repaint-expected.txt
index b0b6479..7716114 100644
--- a/third_party/blink/web_tests/paint/invalidation/box/box-shadow-change-repaint-expected.txt
+++ b/third_party/blink/web_tests/paint/invalidation/box/box-shadow-change-repaint-expected.txt
@@ -19,7 +19,7 @@
       "paintInvalidations": [
         {
           "object": "LayoutBlockFlow DIV id='test'",
-          "rect": [7, 7, 122, 122],
+          "rect": [3, 3, 130, 130],
           "reason": "style change"
         }
       ]
diff --git a/third_party/blink/web_tests/paint/invalidation/svg/repaint-shadow-expected.png b/third_party/blink/web_tests/paint/invalidation/svg/repaint-shadow-expected.png
index beeac34..df5cece 100644
--- a/third_party/blink/web_tests/paint/invalidation/svg/repaint-shadow-expected.png
+++ b/third_party/blink/web_tests/paint/invalidation/svg/repaint-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/paint/invalidation/transform/transform-replaced-shadows-expected.txt b/third_party/blink/web_tests/paint/invalidation/transform/transform-replaced-shadows-expected.txt
index 8361ae35..ebed4235 100644
--- a/third_party/blink/web_tests/paint/invalidation/transform/transform-replaced-shadows-expected.txt
+++ b/third_party/blink/web_tests/paint/invalidation/transform/transform-replaced-shadows-expected.txt
@@ -19,12 +19,12 @@
       "paintInvalidations": [
         {
           "object": "LayoutImage IMG id='box' class='smaller'",
-          "rect": [0, 28, 266, 278],
+          "rect": [0, 8, 288, 320],
           "reason": "paint property change"
         },
         {
           "object": "LayoutImage IMG id='box' class='smaller'",
-          "rect": [9, 28, 138, 139],
+          "rect": [0, 18, 158, 160],
           "reason": "paint property change"
         }
       ]
diff --git a/third_party/blink/web_tests/paint/printing/print-box-shadow-expected.png b/third_party/blink/web_tests/paint/printing/print-box-shadow-expected.png
index cf765e8..3fa9c8c 100644
--- a/third_party/blink/web_tests/paint/printing/print-box-shadow-expected.png
+++ b/third_party/blink/web_tests/paint/printing/print-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/android/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/android/fast/text/stroking-decorations-expected.png
new file mode 100644
index 0000000..7f5d136
--- /dev/null
+++ b/third_party/blink/web_tests/platform/android/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/compositing/geometry/clipping-foreground-expected.png b/third_party/blink/web_tests/platform/linux/compositing/geometry/clipping-foreground-expected.png
index aa9c7fcc..ae465db 100644
--- a/third_party/blink/web_tests/platform/linux/compositing/geometry/clipping-foreground-expected.png
+++ b/third_party/blink/web_tests/platform/linux/compositing/geometry/clipping-foreground-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png b/third_party/blink/web_tests/platform/linux/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
index f9adb9c..8b26ca8 100644
--- a/third_party/blink/web_tests/platform/linux/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/compositing/iframes/composited-iframe-alignment-expected.png b/third_party/blink/web_tests/platform/linux/compositing/iframes/composited-iframe-alignment-expected.png
index b357b2eb..907211c 100644
--- a/third_party/blink/web_tests/platform/linux/compositing/iframes/composited-iframe-alignment-expected.png
+++ b/third_party/blink/web_tests/platform/linux/compositing/iframes/composited-iframe-alignment-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/compositing/masks/masked-ancestor-expected.png b/third_party/blink/web_tests/platform/linux/compositing/masks/masked-ancestor-expected.png
index a204713..6a1a25d 100644
--- a/third_party/blink/web_tests/platform/linux/compositing/masks/masked-ancestor-expected.png
+++ b/third_party/blink/web_tests/platform/linux/compositing/masks/masked-ancestor-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/compositing/shadows/shadow-drawing-expected.png b/third_party/blink/web_tests/platform/linux/compositing/shadows/shadow-drawing-expected.png
index 85512f0..8f3b3e5e 100644
--- a/third_party/blink/web_tests/platform/linux/compositing/shadows/shadow-drawing-expected.png
+++ b/third_party/blink/web_tests/platform/linux/compositing/shadows/shadow-drawing-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/compositing/video/video-controls-layer-creation-expected.png b/third_party/blink/web_tests/platform/linux/compositing/video/video-controls-layer-creation-expected.png
index 4f5be9b..169fb45 100644
--- a/third_party/blink/web_tests/platform/linux/compositing/video/video-controls-layer-creation-expected.png
+++ b/third_party/blink/web_tests/platform/linux/compositing/video/video-controls-layer-creation-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/linux/custom-elements/form-validation-bubble-appearance-expected.png
index 6d6b8882..56bb5229 100644
--- a/third_party/blink/web_tests/platform/linux/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-canvas-with-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
index e1f0237..203853c 100644
--- a/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-video-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-video-shadow-expected.png
index 7e26cf82..8cd050d6 100644
--- a/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-mask-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-split-inline-expected.png b/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-split-inline-expected.png
index b2230d8d..ab412391 100644
--- a/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-split-inline-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/borders/border-radius-split-inline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/box-shadow/basic-shadows-expected.png b/third_party/blink/web_tests/platform/linux/fast/box-shadow/basic-shadows-expected.png
index 1d2b22369..380839d 100644
--- a/third_party/blink/web_tests/platform/linux/fast/box-shadow/basic-shadows-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/box-shadow/basic-shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-expected.png
index 415c0eb..2bc81ee9 100644
--- a/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-transformed-expected.png b/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-transformed-expected.png
index 0038ee7..cd1266b1 100644
--- a/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-transformed-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/box-shadow/box-shadow-transformed-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-expected.png b/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-expected.png
index 2508343..1e7e6e9 100644
--- a/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-subpixel-expected.png b/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-subpixel-expected.png
index 3aea724..029fc0be 100644
--- a/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-subpixel-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/box-shadow/inset-subpixel-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-shadow-expected.png
index 9925c65e..bef4d76 100644
--- a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-video-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-video-shadow-expected.png
index 0056ccf..fc7db0b 100644
--- a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-composite-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-incremental-repaint-expected.png b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-incremental-repaint-expected.png
index 8dfbb2b1..6367aaba 100644
--- a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-incremental-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-incremental-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-shadow-source-in-expected.png b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-shadow-source-in-expected.png
index 4daf80e..b49882c 100644
--- a/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-shadow-source-in-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/canvas/canvas-shadow-source-in-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-box-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-box-shadow-expected.png
index d265f09e..aa24a4b3 100644
--- a/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-text-shadow-expected.png b/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-text-shadow-expected.png
index c308f05..f55b253 100644
--- a/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-text-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/css/color-correction-on-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/css/shadow-multiple-expected.png b/third_party/blink/web_tests/platform/linux/fast/css/shadow-multiple-expected.png
index 94a34823..577fa8e 100644
--- a/third_party/blink/web_tests/platform/linux/fast/css/shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/css/shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/dom/HTMLMeterElement/meter-styles-expected.png b/third_party/blink/web_tests/platform/linux/fast/dom/HTMLMeterElement/meter-styles-expected.png
index 5dbde07..4fa33dd4 100644
--- a/third_party/blink/web_tests/platform/linux/fast/dom/HTMLMeterElement/meter-styles-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/dom/HTMLMeterElement/meter-styles-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
index ab2f970..c0ae62a 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
index 674a20a2..aedc047 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
index 2bb9162..779262c 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
index 6f7a67fc..608be7d4 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
index 267dc54..e1a473b 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index e5e09b6..c56ef04 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png
index 156d03b18..1775374e 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
index 03b875b7..790d560 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index 6a1b8001..f9f798c 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
index 3944378..c427233 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png
index 620e9a0..6bbadcd 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
index a5916745..371d0a2 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-expected.png
index 613385d..2ecad2b 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index 4f9759d..4399fff5 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-expected.png
index 7966113a..32ea43ef 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
index df742fe..e6522979 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
index 095cbaa..4a3b53a 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
index 374f26f..84c9d68 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
index faaa2ab2..b2816e6 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/select/listbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/select/listbox-appearance-basic-expected.png
index f7130adc..5e71b72 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/select/listbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/select/listbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/select/menulist-appearance-basic-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/select/menulist-appearance-basic-expected.png
index ccbbaae..0dfee98 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/select/menulist-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/select/menulist-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/submit/submit-appearance-basic-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/submit/submit-appearance-basic-expected.png
index 10ce8172..8f10353a 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/submit/submit-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/submit/submit-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/text/text-appearance-basic-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/text/text-appearance-basic-expected.png
index 05ef1329..9adf2a13 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/text/text-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/text/text-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/textarea/textarea-appearance-basic-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/textarea/textarea-appearance-basic-expected.png
index 9afc3c8..a2ae028 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/textarea/textarea-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/textarea/textarea-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-edge-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-edge-expected.png
index 3e1cbe9..17d136b3 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-edge-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-edge-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-iframe-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-iframe-expected.png
index 3042287..8a0e0e2c 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-iframe-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-iframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index aa39663a..8a3c8f9e 100644
--- a/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/overflow/overflow-of-video-outline-expected.png b/third_party/blink/web_tests/platform/linux/fast/overflow/overflow-of-video-outline-expected.png
index 8d98b38..548ea5ad 100644
--- a/third_party/blink/web_tests/platform/linux/fast/overflow/overflow-of-video-outline-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/overflow/overflow-of-video-outline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/text/shadow-translucent-fill-expected.png b/third_party/blink/web_tests/platform/linux/fast/text/shadow-translucent-fill-expected.png
index 3f3096f..587ac8c3 100644
--- a/third_party/blink/web_tests/platform/linux/fast/text/shadow-translucent-fill-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/text/shadow-translucent-fill-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/linux/fast/text/stroking-decorations-expected.png
index 7f5d136..9c73bcd 100644
--- a/third_party/blink/web_tests/platform/linux/fast/text/stroking-decorations-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/text/stroking-expected.png b/third_party/blink/web_tests/platform/linux/fast/text/stroking-expected.png
index ff2b44f9..68b0646 100644
--- a/third_party/blink/web_tests/platform/linux/fast/text/stroking-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/text/stroking-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/fast/writing-mode/english-lr-text-expected.png b/third_party/blink/web_tests/platform/linux/fast/writing-mode/english-lr-text-expected.png
index a44672a..0bc0566a 100644
--- a/third_party/blink/web_tests/platform/linux/fast/writing-mode/english-lr-text-expected.png
+++ b/third_party/blink/web_tests/platform/linux/fast/writing-mode/english-lr-text-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/http/tests/media/video-buffered-range-contains-currentTime-expected.png b/third_party/blink/web_tests/platform/linux/http/tests/media/video-buffered-range-contains-currentTime-expected.png
index 6a09d7c..4c974e10 100644
--- a/third_party/blink/web_tests/platform/linux/http/tests/media/video-buffered-range-contains-currentTime-expected.png
+++ b/third_party/blink/web_tests/platform/linux/http/tests/media/video-buffered-range-contains-currentTime-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-001-expected.png b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-001-expected.png
index 885fa2e..19733716 100644
--- a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-001-expected.png
+++ b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-001-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-002-expected.png b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-002-expected.png
index 9e5cdfa..76d9d3a 100644
--- a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-002-expected.png
+++ b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-002-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-003-expected.png b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-003-expected.png
index d308fc7..73e8dc7 100644
--- a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-003-expected.png
+++ b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-003-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-004-expected.png b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-004-expected.png
index 011c07e..4a39e531 100644
--- a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-004-expected.png
+++ b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-004-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-010-expected.png b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-010-expected.png
index cc58f92c..fd2deb9 100644
--- a/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-010-expected.png
+++ b/third_party/blink/web_tests/platform/linux/ietestcenter/css3/text/textshadow-010-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/audio-controls-rendering-expected.png b/third_party/blink/web_tests/platform/linux/media/audio-controls-rendering-expected.png
index a272b20..c4a37c04 100644
--- a/third_party/blink/web_tests/platform/linux/media/audio-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/audio-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/linux/media/controls-after-reload-expected.png
index b805516..1f0f2fd 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls-after-reload-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls-after-reload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls-layout-direction-expected.png b/third_party/blink/web_tests/platform/linux/media/controls-layout-direction-expected.png
index 8307e65..799df38 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls-layout-direction-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls-layout-direction-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/linux/media/controls-strict-expected.png
index fca4441..ff1352c 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls-strict-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/linux/media/controls-styling-expected.png
index a9db566..c25af16 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls-styling-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls-styling-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/linux/media/controls-styling-strict-expected.png
index a2cdbded..3110727 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls-styling-strict-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls-styling-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/linux/media/controls-without-preload-expected.png
index 16a2b350..5090190 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls-without-preload-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls-without-preload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png b/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
index df723158..4d75bd6 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-expected.png b/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-expected.png
index 2b25f10..71aef90 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls/paint-controls-webkit-appearance-none-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/controls/video-controls-with-cast-rendering-expected.png b/third_party/blink/web_tests/platform/linux/media/controls/video-controls-with-cast-rendering-expected.png
index dc28245..a850240 100644
--- a/third_party/blink/web_tests/platform/linux/media/controls/video-controls-with-cast-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/controls/video-controls-with-cast-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/media-controls-clone-expected.png b/third_party/blink/web_tests/platform/linux/media/media-controls-clone-expected.png
index 138bbbf50..a9c6fe24 100644
--- a/third_party/blink/web_tests/platform/linux/media/media-controls-clone-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/media-controls-clone-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/media-controls-grey-scrubber-expected.png b/third_party/blink/web_tests/platform/linux/media/media-controls-grey-scrubber-expected.png
index a9868aa..f4e6e83 100644
--- a/third_party/blink/web_tests/platform/linux/media/media-controls-grey-scrubber-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/media-controls-grey-scrubber-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/media-document-audio-repaint-expected.png b/third_party/blink/web_tests/platform/linux/media/media-document-audio-repaint-expected.png
index 9d1dd316..bd2ffafe 100644
--- a/third_party/blink/web_tests/platform/linux/media/media-document-audio-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/media-document-audio-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/linux/media/video-controls-rendering-expected.png
index 6feaffe6..0de3153 100644
--- a/third_party/blink/web_tests/platform/linux/media/video-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/video-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/linux/media/video-display-toggle-expected.png
index e53564fe..28c4d10 100644
--- a/third_party/blink/web_tests/platform/linux/media/video-display-toggle-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/video-display-toggle-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/video-empty-source-expected.png b/third_party/blink/web_tests/platform/linux/media/video-empty-source-expected.png
index 8e2e3c1..10689fa 100644
--- a/third_party/blink/web_tests/platform/linux/media/video-empty-source-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/video-empty-source-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/video-no-audio-expected.png b/third_party/blink/web_tests/platform/linux/media/video-no-audio-expected.png
index 64a762c..61e384d 100644
--- a/third_party/blink/web_tests/platform/linux/media/video-no-audio-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/video-no-audio-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/media/video-zoom-controls-expected.png b/third_party/blink/web_tests/platform/linux/media/video-zoom-controls-expected.png
index 88a4bf83..5a8764d5 100644
--- a/third_party/blink/web_tests/platform/linux/media/video-zoom-controls-expected.png
+++ b/third_party/blink/web_tests/platform/linux/media/video-zoom-controls-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/paint/invalidation/shadow-multiple-expected.png b/third_party/blink/web_tests/platform/linux/paint/invalidation/shadow-multiple-expected.png
index 2f02cd9b..6754254 100644
--- a/third_party/blink/web_tests/platform/linux/paint/invalidation/shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/linux/paint/invalidation/shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/paint/printing/print-text-shadow-expected.png b/third_party/blink/web_tests/platform/linux/paint/printing/print-text-shadow-expected.png
index 2336f99a..83a021bd 100644
--- a/third_party/blink/web_tests/platform/linux/paint/printing/print-text-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/paint/printing/print-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/paint/roundedrects/circle-with-shadow-expected.png b/third_party/blink/web_tests/platform/linux/paint/roundedrects/circle-with-shadow-expected.png
index c243e2f5..819b720 100644
--- a/third_party/blink/web_tests/platform/linux/paint/roundedrects/circle-with-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/paint/roundedrects/circle-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png b/third_party/blink/web_tests/platform/linux/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
index e80d5b6..fa36380 100644
--- a/third_party/blink/web_tests/platform/linux/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/svg/css/text-gradient-shadow-expected.png b/third_party/blink/web_tests/platform/linux/svg/css/text-gradient-shadow-expected.png
index 6b197ab..52751eaf 100644
--- a/third_party/blink/web_tests/platform/linux/svg/css/text-gradient-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/svg/css/text-gradient-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/svg/css/text-shadow-multiple-expected.png b/third_party/blink/web_tests/platform/linux/svg/css/text-shadow-multiple-expected.png
index d2194752..fe46de9 100644
--- a/third_party/blink/web_tests/platform/linux/svg/css/text-shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/linux/svg/css/text-shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/transforms/shadows-expected.png b/third_party/blink/web_tests/platform/linux/transforms/shadows-expected.png
index fbe26b9..647e3c7 100644
--- a/third_party/blink/web_tests/platform/linux/transforms/shadows-expected.png
+++ b/third_party/blink/web_tests/platform/linux/transforms/shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png b/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
index 0f7ac87..f6456f60a 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png b/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
index 351b6f6..a3d1c3c6 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png b/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
index 08ab262f..623926f 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/layout_ng/fast/writing-mode/english-lr-text-expected.png b/third_party/blink/web_tests/platform/linux/virtual/layout_ng/fast/writing-mode/english-lr-text-expected.png
new file mode 100644
index 0000000..4f68f49
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/layout_ng/fast/writing-mode/english-lr-text-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png b/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
index df723158..4d75bd6 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png b/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png
index 2b25f10..71aef90 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/video-controls-with-cast-rendering-expected.png b/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/video-controls-with-cast-rendering-expected.png
index dc28245..a850240 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/video-controls-with-cast-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/new-remote-playback-pipeline/media/controls/video-controls-with-cast-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
index 82a30b0..6171219 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 954d9c3d..f685608 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
index 9e952c6..3480c30 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index a835d920..c2fe331 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
index 9e952c6..3480c30 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index a835d920..c2fe331 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/geometry/clipping-foreground-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/geometry/clipping-foreground-expected.png
new file mode 100644
index 0000000..ae465db
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/geometry/clipping-foreground-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/geometry/foreground-layer-expected.txt b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/geometry/foreground-layer-expected.txt
new file mode 100644
index 0000000..2b54597
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/geometry/foreground-layer-expected.txt
@@ -0,0 +1,125 @@
+ 
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 600],
+      "drawsContent": false,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "bounds": [800, 600],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "bounds": [800, 600],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='main box'",
+      "bounds": [340, 340],
+      "backgroundColor": "#FF0000",
+      "transform": 1
+    },
+    {
+      "name": "LayoutBlockFlow (positioned) DIV class='negative child'",
+      "bounds": [50, 50],
+      "drawsContent": false,
+      "transform": 3
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='main box' (foreground) Layer",
+      "bounds": [340, 340],
+      "transform": 1
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='main box'",
+      "bounds": [340, 340],
+      "backgroundColor": "#FF0000",
+      "transform": 4
+    },
+    {
+      "name": "Child Containment Layer",
+      "position": [70, 70],
+      "bounds": [200, 200],
+      "drawsContent": false,
+      "transform": 4
+    },
+    {
+      "name": "LayoutBlockFlow (positioned) DIV class='negative child'",
+      "bounds": [50, 50],
+      "drawsContent": false,
+      "transform": 6
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='main box' (foreground) Layer",
+      "position": [70, 70],
+      "bounds": [200, 200],
+      "transform": 4
+    }
+  ],
+  "transforms": [
+    {
+      "id": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [8, 78, 0, 1]
+      ]
+    },
+    {
+      "id": 2,
+      "parent": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [70, 70, 0, 1]
+      ]
+    },
+    {
+      "id": 3,
+      "parent": 2,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [0, 0, 1, 1]
+      ]
+    },
+    {
+      "id": 4,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [352, 8, 0, 1]
+      ]
+    },
+    {
+      "id": 5,
+      "parent": 4,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [70, 70, 0, 1]
+      ]
+    },
+    {
+      "id": 6,
+      "parent": 5,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [0, 0, 1, 1]
+      ]
+    }
+  ]
+}
+
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
new file mode 100644
index 0000000..8b26ca8
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/iframes/composited-iframe-alignment-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/iframes/composited-iframe-alignment-expected.png
new file mode 100644
index 0000000..907211c
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/iframes/composited-iframe-alignment-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/iframes/invisible-nested-iframe-show-expected.txt b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/iframes/invisible-nested-iframe-show-expected.txt
new file mode 100644
index 0000000..7403391
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/iframes/invisible-nested-iframe-show-expected.txt
@@ -0,0 +1,117 @@
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 600],
+      "drawsContent": false,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "bounds": [800, 600],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "bounds": [800, 600],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutIFrame IFRAME",
+      "position": [-22, -22],
+      "bounds": [390, 240]
+    },
+    {
+      "name": "LayoutView #document",
+      "position": [23, 23],
+      "bounds": [300, 150],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Layer",
+      "position": [23, 23],
+      "bounds": [285, 150],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "position": [23, 23],
+      "bounds": [285, 193]
+    },
+    {
+      "name": "LayoutIFrame IFRAME",
+      "position": [31, 31],
+      "bounds": [252, 172]
+    },
+    {
+      "name": "LayoutView #document",
+      "position": [32, 32],
+      "bounds": [250, 170],
+      "backgroundColor": "#C0C0C0"
+    },
+    {
+      "name": "Child Containment Layer",
+      "position": [32, 32],
+      "bounds": [250, 170],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow DIV id='iframe-content' class='box'",
+      "bounds": [210, 210],
+      "contentsOpaque": true,
+      "backgroundColor": "#0000FF",
+      "transform": 1
+    },
+    {
+      "name": "Overflow Controls Host Layer",
+      "position": [23, 23],
+      "bounds": [300, 150],
+      "drawsContent": false
+    },
+    {
+      "name": "Vertical Scrollbar Layer",
+      "position": [308, 23],
+      "bounds": [15, 150],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow DIV class='box'",
+      "bounds": [210, 210],
+      "contentsOpaque": true,
+      "backgroundColor": "#0000FF",
+      "transform": 3
+    }
+  ],
+  "transforms": [
+    {
+      "id": 1,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [50, 42, 0, 1]
+      ]
+    },
+    {
+      "id": 2,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [18, 203, 0, 1]
+      ]
+    },
+    {
+      "id": 3,
+      "parent": 2,
+      "transform": [
+        [1, 0, 0, 0],
+        [0, 1, 0, 0],
+        [0, 0, 1, 0],
+        [0, 0, 1, 1]
+      ]
+    }
+  ]
+}
+
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/masks/masked-ancestor-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/masks/masked-ancestor-expected.png
new file mode 100644
index 0000000..651e08a
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/masks/masked-ancestor-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/border-radius-above-composited-subframe-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/border-radius-above-composited-subframe-expected.png
new file mode 100644
index 0000000..982ca5a
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/border-radius-above-composited-subframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/border-radius-composited-subframe-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/border-radius-composited-subframe-expected.png
new file mode 100644
index 0000000..c024ba35
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/border-radius-composited-subframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/scrollbar-layer-placement-expected.txt b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/scrollbar-layer-placement-expected.txt
new file mode 100644
index 0000000..224eee29
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/overflow/scrollbar-layer-placement-expected.txt
@@ -0,0 +1,217 @@
+{
+  "layers": [
+    {
+      "name": "LayoutView #document",
+      "bounds": [800, 600],
+      "drawsContent": false,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "bounds": [800, 600],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "bounds": [800, 600],
+      "contentsOpaque": true,
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutBlockFlow (positioned) DIV class='outer A'",
+      "bounds": [352, 294]
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='scroller'",
+      "position": [32, 32],
+      "bounds": [290, 230],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "position": [67, 67],
+      "bounds": [220, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "position": [67, 67],
+      "bounds": [220, 236],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Overflow Controls Host Layer",
+      "position": [62, 62],
+      "bounds": [230, 170],
+      "drawsContent": false
+    },
+    {
+      "name": "Vertical Scrollbar Layer",
+      "position": [280, 67],
+      "bounds": [7, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow (positioned) DIV class='outer B'",
+      "position": [349, 0],
+      "bounds": [352, 294]
+    },
+    {
+      "name": "LayoutBlockFlow DIV class='scroller'",
+      "position": [381, 32],
+      "bounds": [290, 230],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "position": [416, 67],
+      "bounds": [220, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "position": [416, 67],
+      "bounds": [220, 236],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='content'",
+      "position": [428, 79],
+      "bounds": [196, 212],
+      "contentsOpaque": true,
+      "backgroundColor": "#DDDDDD"
+    },
+    {
+      "name": "Overflow Controls Host Layer",
+      "position": [411, 62],
+      "bounds": [230, 170],
+      "drawsContent": false
+    },
+    {
+      "name": "Vertical Scrollbar Layer",
+      "position": [629, 67],
+      "bounds": [7, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow (positioned) DIV class='outer C'",
+      "position": [0, 291],
+      "bounds": [352, 294]
+    },
+    {
+      "name": "Ancestor Clipping Layer",
+      "position": [46, 337],
+      "bounds": [260, 100],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow DIV class='scroller'",
+      "position": [31, 322],
+      "bounds": [290, 230],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "position": [66, 357],
+      "bounds": [220, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "position": [66, 357],
+      "bounds": [220, 236],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='content'",
+      "position": [78, 369],
+      "bounds": [196, 212],
+      "contentsOpaque": true,
+      "backgroundColor": "#DDDDDD"
+    },
+    {
+      "name": "Overflow Controls Ancestor Clipping Layer",
+      "position": [46, 337],
+      "bounds": [260, 100],
+      "drawsContent": false
+    },
+    {
+      "name": "Overflow Controls Host Layer",
+      "position": [61, 352],
+      "bounds": [230, 170],
+      "drawsContent": false
+    },
+    {
+      "name": "Vertical Scrollbar Layer",
+      "position": [279, 357],
+      "bounds": [7, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow (positioned) DIV class='outer D'",
+      "position": [349, 291],
+      "bounds": [352, 294]
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='clipper'",
+      "position": [379, 321],
+      "bounds": [292, 200]
+    },
+    {
+      "name": "Child Containment Layer",
+      "position": [389, 331],
+      "bounds": [272, 180],
+      "drawsContent": false
+    },
+    {
+      "name": "Ancestor Clipping Layer",
+      "position": [395, 337],
+      "bounds": [260, 100],
+      "drawsContent": false
+    },
+    {
+      "name": "LayoutBlockFlow DIV class='scroller'",
+      "position": [380, 322],
+      "bounds": [290, 230],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "Scrolling Layer",
+      "position": [415, 357],
+      "bounds": [220, 160],
+      "drawsContent": false
+    },
+    {
+      "name": "Scrolling Contents Layer",
+      "position": [415, 357],
+      "bounds": [220, 236],
+      "backgroundColor": "#FFFFFF"
+    },
+    {
+      "name": "LayoutBlockFlow (relative positioned) DIV class='content'",
+      "position": [427, 369],
+      "bounds": [196, 212],
+      "contentsOpaque": true,
+      "backgroundColor": "#DDDDDD"
+    },
+    {
+      "name": "Overflow Controls Ancestor Clipping Layer",
+      "position": [395, 337],
+      "bounds": [260, 100],
+      "drawsContent": false
+    },
+    {
+      "name": "Overflow Controls Host Layer",
+      "position": [410, 352],
+      "bounds": [230, 170],
+      "drawsContent": false
+    },
+    {
+      "name": "Vertical Scrollbar Layer",
+      "position": [628, 357],
+      "bounds": [7, 160],
+      "drawsContent": false
+    }
+  ]
+}
+
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/shadows/shadow-drawing-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/shadows/shadow-drawing-expected.png
new file mode 100644
index 0000000..8f3b3e5e
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/shadows/shadow-drawing-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/video/video-controls-layer-creation-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/video/video-controls-layer-creation-expected.png
new file mode 100644
index 0000000..169fb45
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/compositing/video/video-controls-layer-creation-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/paint/printing/print-text-shadow-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/paint/printing/print-text-shadow-expected.png
new file mode 100644
index 0000000..83a021bd
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/paint/printing/print-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/paint/roundedrects/circle-with-shadow-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/paint/roundedrects/circle-with-shadow-expected.png
new file mode 100644
index 0000000..819b720
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/paint/roundedrects/circle-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/stable/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png b/third_party/blink/web_tests/platform/linux/virtual/stable/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
new file mode 100644
index 0000000..fa36380
--- /dev/null
+++ b/third_party/blink/web_tests/platform/linux/virtual/stable/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/audio-controls-rendering-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/audio-controls-rendering-expected.png
index a272b20..c4a37c04 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/audio-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/audio-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-after-reload-expected.png
index b805516..1f0f2fd 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-after-reload-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-after-reload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-layout-direction-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-layout-direction-expected.png
index 8307e65..799df38 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-layout-direction-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-layout-direction-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-strict-expected.png
index fca4441..ff1352c 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-strict-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-expected.png
index a9db566..c25af16 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-strict-expected.png
index a2cdbded..3110727 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-strict-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-styling-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-without-preload-expected.png
index 16a2b350..5090190 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-without-preload-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls-without-preload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls/video-controls-with-cast-rendering-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls/video-controls-with-cast-rendering-expected.png
index dc28245..a850240 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls/video-controls-with-cast-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/controls/video-controls-with-cast-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-clone-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-clone-expected.png
index 138bbbf50..a9c6fe24 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-clone-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-clone-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png
index a9868aa..f4e6e83 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png
index 9d1dd316..bd2ffafe 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-controls-rendering-expected.png
index 6feaffe6..0de3153 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-display-toggle-expected.png
index e53564fe..28c4d10 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-display-toggle-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-display-toggle-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-empty-source-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-empty-source-expected.png
index 8e2e3c1..10689fa 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-empty-source-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-empty-source-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-no-audio-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-no-audio-expected.png
index 64a762c..61e384d 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-no-audio-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-no-audio-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-zoom-controls-expected.png b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-zoom-controls-expected.png
index 88a4bf83..5a8764d5 100644
--- a/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-zoom-controls-expected.png
+++ b/third_party/blink/web_tests/platform/linux/virtual/video-surface-layer/media/video-zoom-controls-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/custom-elements/form-validation-bubble-appearance-expected.png
index d86617d..f948ab3 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index 5aa518cb..290a620 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index 76e047f..cf05e36 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index bbb7aeb..c3508b5b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-expected.png
index 6e46825..e2e4972 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
index 12e9862..d9a13cd 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
index bcf6852..1670011 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
index 108f11e..60d9fbe2 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
index 22a5e5a..64c09a19 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
index a47275cb..bb4ed15c 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/input-appearance-height-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/input-appearance-height-expected.png
index 29d8f13..bab74cd 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/input-appearance-height-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/input-appearance-height-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/search/search-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/search/search-appearance-basic-expected.png
index da3de11..1e536d7 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/search/search-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/search/search-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/listbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/listbox-appearance-basic-expected.png
index afa704fb..02e63946 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/listbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/listbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/menulist-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/menulist-appearance-basic-expected.png
index 6c49808..7a08f43e 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/menulist-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/select/menulist-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/submit/submit-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/submit/submit-appearance-basic-expected.png
index 8d99f5b6..1c97908 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/submit/submit-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/submit/submit-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/text-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/text-appearance-basic-expected.png
index 53b471d..eccdb6de 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/text-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/text/text-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/textarea/textarea-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/textarea/textarea-appearance-basic-expected.png
index e9e17c5..46660ef 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/textarea/textarea-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/textarea/textarea-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-edge-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-edge-expected.png
index f56c9d6..1578180 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-edge-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-edge-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-iframe-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-iframe-expected.png
index 5aa44550..41cfbee9 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-iframe-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-iframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index 8fcc8a8c..f1f69034 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/shadow-translucent-fill-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/shadow-translucent-fill-expected.png
index ff226a4f..c055588e 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/shadow-translucent-fill-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/shadow-translucent-fill-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-decorations-expected.png
index 960cf6e..5c82ef2 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-decorations-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-expected.png
index 6858d46..f519b311 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/fast/text/stroking-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/bidi-caret-affinity/editing/caret/caret-painting-low-dpi-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/bidi-caret-affinity/editing/caret/caret-painting-low-dpi-expected.png
new file mode 100644
index 0000000..d313333
--- /dev/null
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/bidi-caret-affinity/editing/caret/caret-painting-low-dpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 62388e37..f2dcde5 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/custom-elements/form-validation-bubble-appearance-expected.png
index 94cc585..e7866c2b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index c6e3e7f7..3492b49 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index 9a2a9a8d..59b28aba 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index 0b10eaa..da6f4f5 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-expected.png
index d042ad1..9fc7b10 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
index 11d0ad8..0b42cea 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
index 84fc050..7d9d30d6 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
index 3736e95..ad0afc2 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
index 096e87de..353824ec 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
index 374d332..32ec03b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/input-appearance-height-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/input-appearance-height-expected.png
index a2ea8b0..580c6ce 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/input-appearance-height-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/input-appearance-height-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/search/search-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/search/search-appearance-basic-expected.png
index 87d45be..c2401050 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/search/search-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/search/search-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/listbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/listbox-appearance-basic-expected.png
index d00a893..8cb9583 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/listbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/listbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/menulist-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/menulist-appearance-basic-expected.png
index 6aafc35..24bcd2f 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/menulist-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/select/menulist-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/submit/submit-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/submit/submit-appearance-basic-expected.png
index 9094779..14d1da2 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/submit/submit-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/submit/submit-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/text-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/text-appearance-basic-expected.png
index b1d45bdc..e57d7e0d 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/text-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/text/text-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/textarea/textarea-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/textarea/textarea-appearance-basic-expected.png
index b006732..1cf5d20 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/textarea/textarea-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/textarea/textarea-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-edge-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-edge-expected.png
index e79d79e..8bfd745c8 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-edge-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-edge-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-iframe-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-iframe-expected.png
index 1ec9720..698dec6 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-iframe-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-iframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index 0e7536a..140946e 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/virtual/bidi-caret-affinity/editing/caret/caret-painting-low-dpi-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/bidi-caret-affinity/editing/caret/caret-painting-low-dpi-expected.png
new file mode 100644
index 0000000..777b8932
--- /dev/null
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/bidi-caret-affinity/editing/caret/caret-painting-low-dpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 4d4de28f..3e78ed8 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.11/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/compositing/geometry/clipping-foreground-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/compositing/geometry/clipping-foreground-expected.png
index a4275c3b..703fbbed 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/compositing/geometry/clipping-foreground-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/compositing/geometry/clipping-foreground-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/compositing/video/video-controls-layer-creation-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/compositing/video/video-controls-layer-creation-expected.png
index e7d3ff7..f95e915 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/compositing/video/video-controls-layer-creation-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/compositing/video/video-controls-layer-creation-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/custom-elements/form-validation-bubble-appearance-expected.png
index 75eb01d..b2812ea 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index 8bb4582a..d2af5c0 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index ae9210a3..c212b1c 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index 6336ae65..deccecc 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
index d844740..9837ae7 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/search/search-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/search/search-appearance-basic-expected.png
index a5f4082..62e9812 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/search/search-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/search/search-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/listbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/listbox-appearance-basic-expected.png
index 685616d..f320b5c 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/listbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/listbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/menulist-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/menulist-appearance-basic-expected.png
index 8ba71fd..95f3e2c 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/menulist-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/select/menulist-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/submit/submit-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/submit/submit-appearance-basic-expected.png
index 7d505a93..81f456ba 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/submit/submit-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/submit/submit-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/text-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/text-appearance-basic-expected.png
index 6d572280..9a68702 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/text-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/text/text-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/textarea/textarea-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/textarea/textarea-appearance-basic-expected.png
index 6e01aa59..258c97b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/textarea/textarea-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/textarea/textarea-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-edge-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-edge-expected.png
index 6c0b4a7..84c06f9 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-edge-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-edge-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-iframe-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-iframe-expected.png
index 470225ae..b2c5eb3 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-iframe-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-iframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index f0885ec1..5e6d9b1 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/overflow/overflow-of-video-outline-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/overflow/overflow-of-video-outline-expected.png
index c59ff35..0913b7b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/overflow/overflow-of-video-outline-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/overflow/overflow-of-video-outline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/shadow-translucent-fill-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/shadow-translucent-fill-expected.png
index 1c54733a..52338e76 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/shadow-translucent-fill-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/shadow-translucent-fill-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-decorations-expected.png
index 22efceb..745887f 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-decorations-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-expected.png
index 10a43c3..035d11d 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/fast/text/stroking-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/http/tests/media/video-buffered-range-contains-currentTime-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/http/tests/media/video-buffered-range-contains-currentTime-expected.png
index 41f94c3b..40f74c7 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/http/tests/media/video-buffered-range-contains-currentTime-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/http/tests/media/video-buffered-range-contains-currentTime-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/audio-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/audio-controls-rendering-expected.png
index 48e2c70..21f8844b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/audio-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/audio-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-after-reload-expected.png
index bc86a51bc..61982ea 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-after-reload-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-after-reload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-layout-direction-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-layout-direction-expected.png
index ee415f0..87dfe34 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-layout-direction-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-layout-direction-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-strict-expected.png
index a7dcd69..bb6d7cf 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-strict-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-expected.png
index 2fce9b0..39b54c76 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-strict-expected.png
index b55884d..3a124ac 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-strict-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-styling-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-without-preload-expected.png
index 96294b9..689e55b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-without-preload-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls-without-preload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
index 19de90d3..9ca1ee4b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-expected.png
index 36f6c1a..6f9d858 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/controls/paint-controls-webkit-appearance-none-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-clone-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-clone-expected.png
index b907545..2314f4a4 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-clone-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-clone-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-grey-scrubber-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-grey-scrubber-expected.png
index 69170764..d83f658 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-grey-scrubber-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/media-controls-grey-scrubber-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/media-document-audio-repaint-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/media-document-audio-repaint-expected.png
index d3317d4..3bc85467 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/media-document-audio-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/media-document-audio-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-controls-rendering-expected.png
index 2d5c5b1..d0d456c 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-display-toggle-expected.png
index 0af2bac..0fea1c3 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-display-toggle-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-display-toggle-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-empty-source-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-empty-source-expected.png
index 2550ff8..6e34eff 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-empty-source-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-empty-source-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-no-audio-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-no-audio-expected.png
index 1a13c8b..bd38c383 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-no-audio-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-no-audio-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-zoom-controls-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-zoom-controls-expected.png
index c7a8133..765b7a43 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/media/video-zoom-controls-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/media/video-zoom-controls-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
index 19de90d3..9ca1ee4b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png
index 36f6c1a..6f9d858 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/new-remote-playback-pipeline/media/controls/paint-controls-webkit-appearance-none-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 6212ef2..ea27feb3 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/audio-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/audio-controls-rendering-expected.png
index 48e2c70..21f8844b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/audio-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/audio-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-after-reload-expected.png
index bc86a51bc..61982ea 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-after-reload-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-after-reload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-layout-direction-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-layout-direction-expected.png
index ee415f0..87dfe34 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-layout-direction-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-layout-direction-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-strict-expected.png
index a7dcd69..bb6d7cf 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-strict-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-expected.png
index 2fce9b0..39b54c76 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-strict-expected.png
index b55884d..3a124ac 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-strict-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-styling-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-without-preload-expected.png
index 96294b9..689e55b 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-without-preload-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/controls-without-preload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-clone-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-clone-expected.png
index b907545..2314f4a4 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-clone-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-clone-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png
index 69170764..d83f658 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-controls-grey-scrubber-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png
index d3317d4..3bc85467 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/media-document-audio-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-controls-rendering-expected.png
index 2d5c5b1..d0d456c 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-display-toggle-expected.png
index 0af2bac..0fea1c3 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-display-toggle-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-display-toggle-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-empty-source-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-empty-source-expected.png
index 2550ff8..6e34eff 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-empty-source-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-empty-source-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-zoom-controls-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-zoom-controls-expected.png
index c7a8133..765b7a43 100644
--- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-zoom-controls-expected.png
+++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/video-surface-layer/media/video-zoom-controls-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/compositing/geometry/clipping-foreground-expected.png b/third_party/blink/web_tests/platform/mac/compositing/geometry/clipping-foreground-expected.png
index 72147529..27a3a75 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/geometry/clipping-foreground-expected.png
+++ b/third_party/blink/web_tests/platform/mac/compositing/geometry/clipping-foreground-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png b/third_party/blink/web_tests/platform/mac/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
index e254387..c32f8b5 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/compositing/iframes/composited-iframe-alignment-expected.png b/third_party/blink/web_tests/platform/mac/compositing/iframes/composited-iframe-alignment-expected.png
index 933601ac..6b7fded 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/iframes/composited-iframe-alignment-expected.png
+++ b/third_party/blink/web_tests/platform/mac/compositing/iframes/composited-iframe-alignment-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/compositing/iframes/invisible-nested-iframe-show-expected.txt b/third_party/blink/web_tests/platform/mac/compositing/iframes/invisible-nested-iframe-show-expected.txt
index f3fc8de..bdf7d987 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/iframes/invisible-nested-iframe-show-expected.txt
+++ b/third_party/blink/web_tests/platform/mac/compositing/iframes/invisible-nested-iframe-show-expected.txt
@@ -19,8 +19,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME",
-      "position": [-11, -11],
-      "bounds": [368, 218]
+      "position": [-22, -22],
+      "bounds": [390, 240]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/platform/mac/compositing/masks/masked-ancestor-expected.png b/third_party/blink/web_tests/platform/mac/compositing/masks/masked-ancestor-expected.png
index 2b7ccd8..a2f62e48 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/masks/masked-ancestor-expected.png
+++ b/third_party/blink/web_tests/platform/mac/compositing/masks/masked-ancestor-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/compositing/shadows/shadow-drawing-expected.png b/third_party/blink/web_tests/platform/mac/compositing/shadows/shadow-drawing-expected.png
index 4983b94..a000cd3 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/shadows/shadow-drawing-expected.png
+++ b/third_party/blink/web_tests/platform/mac/compositing/shadows/shadow-drawing-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/compositing/video/video-controls-layer-creation-expected.png b/third_party/blink/web_tests/platform/mac/compositing/video/video-controls-layer-creation-expected.png
index 6f1d074..25a0811 100644
--- a/third_party/blink/web_tests/platform/mac/compositing/video/video-controls-layer-creation-expected.png
+++ b/third_party/blink/web_tests/platform/mac/compositing/video/video-controls-layer-creation-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/mac/custom-elements/form-validation-bubble-appearance-expected.png
index d3abce0..bb5b848 100644
--- a/third_party/blink/web_tests/platform/mac/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-canvas-with-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
index 4054d1b..0864d15 100644
--- a/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-video-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-video-shadow-expected.png
index 173da9ca..fb1e142 100644
--- a/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-mask-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-split-inline-expected.png b/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-split-inline-expected.png
index 73b2bb4..503a8709 100644
--- a/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-split-inline-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/borders/border-radius-split-inline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/basic-shadows-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/basic-shadows-expected.png
index df6f3b9f..23f1412 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/basic-shadows-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/basic-shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-expected.png
index 41bcec9b..f34462d 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png
index b2d3bf8..c2a209f7 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/box-shadow-transformed-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadow-radius-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadow-radius-expected.png
index 927fa51..5a6250f 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadow-radius-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadow-radius-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadows-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadows-expected.png
index 3eec1c3..542c06de 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadows-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-box-shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-expected.png
index c0492008..28e6869 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-subpixel-expected.png b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-subpixel-expected.png
index e98c89c2..9decaebb 100644
--- a/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-subpixel-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/box-shadow/inset-subpixel-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-shadow-expected.png
index 7b7db41..0a76b42 100644
--- a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-video-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-video-shadow-expected.png
index 3ffa645..8778bfd 100644
--- a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-composite-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-incremental-repaint-expected.png b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-incremental-repaint-expected.png
index 6a5ce6ab..e753ec1 100644
--- a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-incremental-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-incremental-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-shadow-source-in-expected.png b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-shadow-source-in-expected.png
index 7ed103a..f16d618 100644
--- a/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-shadow-source-in-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/canvas/canvas-shadow-source-in-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-box-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-box-shadow-expected.png
index 772308a1..eff94dd 100644
--- a/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-text-shadow-expected.png b/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-text-shadow-expected.png
index 6108f5b..8cc2730 100644
--- a/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-text-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/css/color-correction-on-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/css/shadow-multiple-expected.png b/third_party/blink/web_tests/platform/mac/fast/css/shadow-multiple-expected.png
index f16b8a8..c985202 100644
--- a/third_party/blink/web_tests/platform/mac/fast/css/shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/css/shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png b/third_party/blink/web_tests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png
index 1183615..c96601d 100644
--- a/third_party/blink/web_tests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/dom/HTMLMeterElement/meter-styles-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index 123763b..9e6fec0 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index d4fa9a40..942ffc6 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index b714b2e..bec89a6 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/checkbox/checkbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/checkbox/checkbox-appearance-basic-expected.png
index 904c270a..ddb564d 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/checkbox/checkbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/checkbox/checkbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-expected.png
index 97d82d7..18f1070 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
index e12ea66..aeabbff 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
index 51a0d70..f67df0b 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
index 0f6feb1..9520e6f1 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
index 80ac5f6..5afe27ba 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
index b97222f..5315538 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-expected.png
index e36f1ce..5fc730a 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-zoomed-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-zoomed-expected.png
index d2a8d08..cdd830d 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-zoomed-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-datalist-zoomed-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-padding-with-datalist-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-padding-with-datalist-expected.png
index e598b5b5..ac28478 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-padding-with-datalist-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/datalist/input-appearance-range-with-padding-with-datalist-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/input-appearance-height-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/input-appearance-height-expected.png
index 5e896631..00abdc1e 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/input-appearance-height-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/input-appearance-height-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/radio/radio-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/radio/radio-appearance-basic-expected.png
index 4af4a30..fac0e3c8 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/radio/radio-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/radio/radio-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/range/input-appearance-range-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/range/input-appearance-range-expected.png
index cf39c18..d00598a61 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/range/input-appearance-range-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/range/input-appearance-range-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/range/range-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/range/range-appearance-basic-expected.png
index c32616f..b9a3e6b 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/range/range-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/range/range-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/range/range-update-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/range/range-update-expected.png
index 41b71a8..52bc305 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/range/range-update-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/range/range-update-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-padding-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-padding-expected.png
index 2cda1aaf..e754c66d 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-padding-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-padding-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-thumb-shared-style-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-thumb-shared-style-expected.png
index a0188cb..b0fd10dc 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-thumb-shared-style-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/range/slider-thumb-shared-style-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/range/thumbslider-no-parent-slider-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/range/thumbslider-no-parent-slider-expected.png
index 4da5e14..8be02db4 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/range/thumbslider-no-parent-slider-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/range/thumbslider-no-parent-slider-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/search/search-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/search/search-appearance-basic-expected.png
index 02b11d7..89c73b4 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/search/search-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/search/search-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/select/listbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/select/listbox-appearance-basic-expected.png
index e4088b4c4..7a8e320 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/select/listbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/select/listbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/select/menulist-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/select/menulist-appearance-basic-expected.png
index e89bdf1..5e1fafb 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/select/menulist-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/select/menulist-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/submit/submit-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/submit/submit-appearance-basic-expected.png
index 3aaaf5d5..a440217 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/submit/submit-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/submit/submit-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/text/text-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/text/text-appearance-basic-expected.png
index 27abc50b..e66cab9 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/text/text-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/text/text-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/textarea/textarea-appearance-basic-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/textarea/textarea-appearance-basic-expected.png
index 25a2267..8ad5ae99 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/textarea/textarea-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/textarea/textarea-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-edge-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-edge-expected.png
index 16d86d76..dd46a70 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-edge-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-edge-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-iframe-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-iframe-expected.png
index 442b640..d496573 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-iframe-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-iframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index 717dcd5..5e7a24f 100644
--- a/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/overflow/overflow-of-video-outline-expected.png b/third_party/blink/web_tests/platform/mac/fast/overflow/overflow-of-video-outline-expected.png
index 676354f2..4a655ef 100644
--- a/third_party/blink/web_tests/platform/mac/fast/overflow/overflow-of-video-outline-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/overflow/overflow-of-video-outline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/text/shadow-translucent-fill-expected.png b/third_party/blink/web_tests/platform/mac/fast/text/shadow-translucent-fill-expected.png
index d71ccb5..073777f 100644
--- a/third_party/blink/web_tests/platform/mac/fast/text/shadow-translucent-fill-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/text/shadow-translucent-fill-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/mac/fast/text/stroking-decorations-expected.png
index e60a517..7afd4707 100644
--- a/third_party/blink/web_tests/platform/mac/fast/text/stroking-decorations-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/text/stroking-expected.png b/third_party/blink/web_tests/platform/mac/fast/text/stroking-expected.png
index 86fc5cb..411a38f68 100644
--- a/third_party/blink/web_tests/platform/mac/fast/text/stroking-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/text/stroking-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/fast/writing-mode/english-lr-text-expected.png b/third_party/blink/web_tests/platform/mac/fast/writing-mode/english-lr-text-expected.png
index dc37ba6..ad1b4e2 100644
--- a/third_party/blink/web_tests/platform/mac/fast/writing-mode/english-lr-text-expected.png
+++ b/third_party/blink/web_tests/platform/mac/fast/writing-mode/english-lr-text-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/http/tests/media/video-buffered-range-contains-currentTime-expected.png b/third_party/blink/web_tests/platform/mac/http/tests/media/video-buffered-range-contains-currentTime-expected.png
index 1d593fbc7..55b6de8 100644
--- a/third_party/blink/web_tests/platform/mac/http/tests/media/video-buffered-range-contains-currentTime-expected.png
+++ b/third_party/blink/web_tests/platform/mac/http/tests/media/video-buffered-range-contains-currentTime-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-001-expected.png b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-001-expected.png
index 11f42d3..d9f8adaf 100644
--- a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-001-expected.png
+++ b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-001-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-002-expected.png b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-002-expected.png
index 22c5830..7001b91 100644
--- a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-002-expected.png
+++ b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-002-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-003-expected.png b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-003-expected.png
index a5bbbb1..95c5986 100644
--- a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-003-expected.png
+++ b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-003-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-004-expected.png b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-004-expected.png
index 507a2cc..027981d 100644
--- a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-004-expected.png
+++ b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-004-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-010-expected.png b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-010-expected.png
index 82301b1..bc37cc1 100644
--- a/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-010-expected.png
+++ b/third_party/blink/web_tests/platform/mac/ietestcenter/css3/text/textshadow-010-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/audio-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac/media/audio-controls-rendering-expected.png
index d578ae1..a0d277db 100644
--- a/third_party/blink/web_tests/platform/mac/media/audio-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/audio-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/mac/media/controls-after-reload-expected.png
index 44c64cd..f44ddac 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls-after-reload-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls-after-reload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls-layout-direction-expected.png b/third_party/blink/web_tests/platform/mac/media/controls-layout-direction-expected.png
index 41f88b6e..f0b437c 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls-layout-direction-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls-layout-direction-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/mac/media/controls-strict-expected.png
index 7939add5..0293e0c7 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls-strict-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/mac/media/controls-styling-expected.png
index 776ad4d..0f48bff4 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls-styling-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls-styling-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/mac/media/controls-styling-strict-expected.png
index 032e640..738a22d 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls-styling-strict-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls-styling-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/mac/media/controls-without-preload-expected.png
index e761cf9c..754df1e 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls-without-preload-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls-without-preload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png b/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
index 86eaabb..ee1d0d6 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-expected.png b/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-expected.png
index 4a08f5d..1aa826b 100644
--- a/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/controls/paint-controls-webkit-appearance-none-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/media-controls-clone-expected.png b/third_party/blink/web_tests/platform/mac/media/media-controls-clone-expected.png
index 6fae8377..e7693e4 100644
--- a/third_party/blink/web_tests/platform/mac/media/media-controls-clone-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/media-controls-clone-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/media-controls-grey-scrubber-expected.png b/third_party/blink/web_tests/platform/mac/media/media-controls-grey-scrubber-expected.png
index 5cc4966..7c251075 100644
--- a/third_party/blink/web_tests/platform/mac/media/media-controls-grey-scrubber-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/media-controls-grey-scrubber-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/media-document-audio-repaint-expected.png b/third_party/blink/web_tests/platform/mac/media/media-document-audio-repaint-expected.png
index 2f29279..afa82e4 100644
--- a/third_party/blink/web_tests/platform/mac/media/media-document-audio-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/media-document-audio-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac/media/video-controls-rendering-expected.png
index be2ea72..cad74b0 100644
--- a/third_party/blink/web_tests/platform/mac/media/video-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/video-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/mac/media/video-display-toggle-expected.png
index f5b9495..ed3931f 100644
--- a/third_party/blink/web_tests/platform/mac/media/video-display-toggle-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/video-display-toggle-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/video-empty-source-expected.png b/third_party/blink/web_tests/platform/mac/media/video-empty-source-expected.png
index 1d9f54a..13bfab9 100644
--- a/third_party/blink/web_tests/platform/mac/media/video-empty-source-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/video-empty-source-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/video-no-audio-expected.png b/third_party/blink/web_tests/platform/mac/media/video-no-audio-expected.png
index 4b264d5c..905f1b7 100644
--- a/third_party/blink/web_tests/platform/mac/media/video-no-audio-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/video-no-audio-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/media/video-zoom-controls-expected.png b/third_party/blink/web_tests/platform/mac/media/video-zoom-controls-expected.png
index d38f7e7e..da9efe88 100644
--- a/third_party/blink/web_tests/platform/mac/media/video-zoom-controls-expected.png
+++ b/third_party/blink/web_tests/platform/mac/media/video-zoom-controls-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/range-focus-by-mouse-then-keydown-expected.png b/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/range-focus-by-mouse-then-keydown-expected.png
index 42c80609..bac8256 100644
--- a/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/range-focus-by-mouse-then-keydown-expected.png
+++ b/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/range-focus-by-mouse-then-keydown-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/slider-thumb-drag-release-expected.png b/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/slider-thumb-drag-release-expected.png
index 41b71a8..52bc305 100644
--- a/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/slider-thumb-drag-release-expected.png
+++ b/third_party/blink/web_tests/platform/mac/paint/invalidation/forms/slider-thumb-drag-release-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/paint/invalidation/shadow-multiple-expected.png b/third_party/blink/web_tests/platform/mac/paint/invalidation/shadow-multiple-expected.png
index 82c4cb6c95..9580f98 100644
--- a/third_party/blink/web_tests/platform/mac/paint/invalidation/shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/mac/paint/invalidation/shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/paint/printing/print-text-shadow-expected.png b/third_party/blink/web_tests/platform/mac/paint/printing/print-text-shadow-expected.png
index a59b900..a20ed7b 100644
--- a/third_party/blink/web_tests/platform/mac/paint/printing/print-text-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/paint/printing/print-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/paint/roundedrects/circle-with-shadow-expected.png b/third_party/blink/web_tests/platform/mac/paint/roundedrects/circle-with-shadow-expected.png
index 910d8265..186ed96 100644
--- a/third_party/blink/web_tests/platform/mac/paint/roundedrects/circle-with-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/paint/roundedrects/circle-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png b/third_party/blink/web_tests/platform/mac/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
index ea26f98..730dbde 100644
--- a/third_party/blink/web_tests/platform/mac/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/svg/css/text-gradient-shadow-expected.png b/third_party/blink/web_tests/platform/mac/svg/css/text-gradient-shadow-expected.png
index 734f55c..65b96fc 100644
--- a/third_party/blink/web_tests/platform/mac/svg/css/text-gradient-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/svg/css/text-gradient-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/svg/css/text-shadow-multiple-expected.png b/third_party/blink/web_tests/platform/mac/svg/css/text-shadow-multiple-expected.png
index 666baed3..202e267 100644
--- a/third_party/blink/web_tests/platform/mac/svg/css/text-shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/mac/svg/css/text-shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png b/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
index b2466a4..3f0dc202 100644
--- a/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png b/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
index d41650cc..0730721 100644
--- a/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png b/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
index 201bbd38..3f829a1 100644
--- a/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
+++ b/third_party/blink/web_tests/platform/mac/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/mac/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 3d7f36b..8418d14c 100644
--- a/third_party/blink/web_tests/platform/mac/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/mac/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-after-reload-expected.png
deleted file mode 100644
index 44c64cd..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-after-reload-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-strict-expected.png
deleted file mode 100644
index 7939add5..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-strict-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-styling-expected.png
deleted file mode 100644
index 776ad4d..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-styling-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-styling-strict-expected.png
deleted file mode 100644
index 032e640..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-styling-strict-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-without-preload-expected.png
deleted file mode 100644
index e761cf9c..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/controls-without-preload-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/video-controls-rendering-expected.png
deleted file mode 100644
index be2ea72..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/video-controls-rendering-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/video-display-toggle-expected.png
deleted file mode 100644
index f5b9495..0000000
--- a/third_party/blink/web_tests/platform/mac/virtual/video-surface-layer/media/video-display-toggle-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/compositing/geometry/clipping-foreground-expected.png b/third_party/blink/web_tests/platform/win/compositing/geometry/clipping-foreground-expected.png
index a1fe009..2343f16 100644
--- a/third_party/blink/web_tests/platform/win/compositing/geometry/clipping-foreground-expected.png
+++ b/third_party/blink/web_tests/platform/win/compositing/geometry/clipping-foreground-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png b/third_party/blink/web_tests/platform/win/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
index 0b1ac12b..9edac7b 100644
--- a/third_party/blink/web_tests/platform/win/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/compositing/gestures/gesture-tapHighlight-with-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/compositing/iframes/composited-iframe-alignment-expected.png b/third_party/blink/web_tests/platform/win/compositing/iframes/composited-iframe-alignment-expected.png
index 183be3f..20bc69a 100644
--- a/third_party/blink/web_tests/platform/win/compositing/iframes/composited-iframe-alignment-expected.png
+++ b/third_party/blink/web_tests/platform/win/compositing/iframes/composited-iframe-alignment-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/compositing/iframes/invisible-nested-iframe-show-expected.txt b/third_party/blink/web_tests/platform/win/compositing/iframes/invisible-nested-iframe-show-expected.txt
index 1dc93089..ea14233 100644
--- a/third_party/blink/web_tests/platform/win/compositing/iframes/invisible-nested-iframe-show-expected.txt
+++ b/third_party/blink/web_tests/platform/win/compositing/iframes/invisible-nested-iframe-show-expected.txt
@@ -19,8 +19,8 @@
     },
     {
       "name": "LayoutIFrame IFRAME",
-      "position": [-11, -11],
-      "bounds": [368, 218]
+      "position": [-22, -22],
+      "bounds": [390, 240]
     },
     {
       "name": "LayoutView #document",
diff --git a/third_party/blink/web_tests/platform/win/compositing/masks/masked-ancestor-expected.png b/third_party/blink/web_tests/platform/win/compositing/masks/masked-ancestor-expected.png
index 9d839d7..26bb7b56 100644
--- a/third_party/blink/web_tests/platform/win/compositing/masks/masked-ancestor-expected.png
+++ b/third_party/blink/web_tests/platform/win/compositing/masks/masked-ancestor-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/compositing/shadows/shadow-drawing-expected.png b/third_party/blink/web_tests/platform/win/compositing/shadows/shadow-drawing-expected.png
index 6072329a..9e2ab0f 100644
--- a/third_party/blink/web_tests/platform/win/compositing/shadows/shadow-drawing-expected.png
+++ b/third_party/blink/web_tests/platform/win/compositing/shadows/shadow-drawing-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/win/custom-elements/form-validation-bubble-appearance-expected.png
index a97540f..78556d5 100644
--- a/third_party/blink/web_tests/platform/win/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-canvas-with-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
index f7cc6b8..9d50d3367 100644
--- a/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-canvas-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-video-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-video-shadow-expected.png
index c2818b3..2623ca2 100644
--- a/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/borders/border-radius-mask-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/borders/border-radius-split-inline-expected.png b/third_party/blink/web_tests/platform/win/fast/borders/border-radius-split-inline-expected.png
index 986520dc..4297ad0 100644
--- a/third_party/blink/web_tests/platform/win/fast/borders/border-radius-split-inline-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/borders/border-radius-split-inline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/basic-shadows-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/basic-shadows-expected.png
index 11b1a99..6b7b6a27 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/basic-shadows-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/basic-shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-expected.png
index 427acdd..209f0d5 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-transformed-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-transformed-expected.png
index 4999113..09a4008 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-transformed-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/box-shadow-transformed-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadow-radius-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadow-radius-expected.png
index 760ea30..a7e4952 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadow-radius-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadow-radius-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadows-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadows-expected.png
index 7178f5b1..3018749 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadows-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-box-shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-expected.png
index 596ad0d..edca436 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-subpixel-expected.png b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-subpixel-expected.png
index a243a128..5fcb889 100644
--- a/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-subpixel-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/box-shadow/inset-subpixel-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-shadow-expected.png
index 896d81af..0025881d 100644
--- a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-video-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-video-shadow-expected.png
index e88967a..cbbdf17 100644
--- a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-composite-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-incremental-repaint-expected.png b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-incremental-repaint-expected.png
index 3fc6e9b..ce96862 100644
--- a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-incremental-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-incremental-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-shadow-source-in-expected.png b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-shadow-source-in-expected.png
index e5ed879..3316633 100644
--- a/third_party/blink/web_tests/platform/win/fast/canvas/canvas-shadow-source-in-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/canvas/canvas-shadow-source-in-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-box-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-box-shadow-expected.png
index 9d71047..ef83fc8 100644
--- a/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-box-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-box-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-text-shadow-expected.png b/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-text-shadow-expected.png
index 58f8b8f..fa4b112 100644
--- a/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-text-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/css/color-correction-on-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/css/shadow-multiple-expected.png b/third_party/blink/web_tests/platform/win/fast/css/shadow-multiple-expected.png
index 5554c722..2cde9042 100644
--- a/third_party/blink/web_tests/platform/win/fast/css/shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/css/shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/dom/HTMLMeterElement/meter-styles-expected.png b/third_party/blink/web_tests/platform/win/fast/dom/HTMLMeterElement/meter-styles-expected.png
index 2987660a..d17cfdef 100644
--- a/third_party/blink/web_tests/platform/win/fast/dom/HTMLMeterElement/meter-styles-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/dom/HTMLMeterElement/meter-styles-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
index 3d98c5b3..93ce3d0 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
index 0fa56ac..5bb71de 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
index e7b51dca..f595e44 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
index b9f1b257..17f2e93 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
index 0b13347d..ac39ef2 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index d7fc43f..ed29df5 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png
index b12aa79..f69ca20 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-ru-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
index 09a0e26..cbd7699 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index f8017fa..b216f77 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
index ed2542c..ddc1bf6 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png
index de910c90..d3c4004 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
index 73ab916..d6b79df6 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-expected.png
index 13dbee7..63d3a7f 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index a8f00e6..191bbbcc 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/checkbox/checkbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/checkbox/checkbox-appearance-basic-expected.png
index 79380b1..bd1cc9c 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/checkbox/checkbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/checkbox/checkbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-expected.png
index 559f966..63605ab 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
index 9368cc5e..48cf6775 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
index 5ebccd7d..a95d8ba 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-one-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
index 1378e47e..b2198c6 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-two-row-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
index 6bb571d7..9ab3bc9 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/color/color-suggestion-picker-with-scrollbar-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/radio/radio-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/radio/radio-appearance-basic-expected.png
index fa1f371..47474be7 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/radio/radio-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/radio/radio-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/range/range-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/range/range-appearance-basic-expected.png
index 432b76a84..cfc3f46 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/range/range-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/range/range-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/select/listbox-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/select/listbox-appearance-basic-expected.png
index f28d87d..be22a0f 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/select/listbox-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/select/listbox-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/select/menulist-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/select/menulist-appearance-basic-expected.png
index a545ad2..29fb86c 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/select/menulist-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/select/menulist-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/submit/submit-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/submit/submit-appearance-basic-expected.png
index 20c04ab..5b8caec 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/submit/submit-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/submit/submit-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/text/text-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/text/text-appearance-basic-expected.png
index ad99abb..8a75ed6 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/text/text-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/text/text-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/textarea/textarea-appearance-basic-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/textarea/textarea-appearance-basic-expected.png
index 53adf2a..a3fd5ce 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/textarea/textarea-appearance-basic-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/textarea/textarea-appearance-basic-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-edge-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-edge-expected.png
index a12d654..3fffe77 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-edge-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-edge-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-iframe-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-iframe-expected.png
index 909fbf0..d0c88f8 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-iframe-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-iframe-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-rtl-ui-expected.png b/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
index 54d1d10..f6f78d6 100644
--- a/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/forms/validation-bubble-appearance-rtl-ui-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/overflow/overflow-of-video-outline-expected.png b/third_party/blink/web_tests/platform/win/fast/overflow/overflow-of-video-outline-expected.png
index 641dbb8a..317786b 100644
--- a/third_party/blink/web_tests/platform/win/fast/overflow/overflow-of-video-outline-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/overflow/overflow-of-video-outline-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/text/shadow-translucent-fill-expected.png b/third_party/blink/web_tests/platform/win/fast/text/shadow-translucent-fill-expected.png
index d8dc1ef..e1555b0 100644
--- a/third_party/blink/web_tests/platform/win/fast/text/shadow-translucent-fill-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/text/shadow-translucent-fill-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/win/fast/text/stroking-decorations-expected.png
index 1afb13f85..5164cb9b1 100644
--- a/third_party/blink/web_tests/platform/win/fast/text/stroking-decorations-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/text/stroking-expected.png b/third_party/blink/web_tests/platform/win/fast/text/stroking-expected.png
index 84001f7..6c50e9c 100644
--- a/third_party/blink/web_tests/platform/win/fast/text/stroking-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/text/stroking-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/fast/writing-mode/english-lr-text-expected.png b/third_party/blink/web_tests/platform/win/fast/writing-mode/english-lr-text-expected.png
index ff47cab..1618fdb0 100644
--- a/third_party/blink/web_tests/platform/win/fast/writing-mode/english-lr-text-expected.png
+++ b/third_party/blink/web_tests/platform/win/fast/writing-mode/english-lr-text-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/http/tests/media/video-buffered-range-contains-currentTime-expected.png b/third_party/blink/web_tests/platform/win/http/tests/media/video-buffered-range-contains-currentTime-expected.png
index dd6a5bde..3c4ab59 100644
--- a/third_party/blink/web_tests/platform/win/http/tests/media/video-buffered-range-contains-currentTime-expected.png
+++ b/third_party/blink/web_tests/platform/win/http/tests/media/video-buffered-range-contains-currentTime-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-001-expected.png b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-001-expected.png
index 7de4aed..d55d9e1 100644
--- a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-001-expected.png
+++ b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-001-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-002-expected.png b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-002-expected.png
index 5906a3e..a654a93 100644
--- a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-002-expected.png
+++ b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-002-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-003-expected.png b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-003-expected.png
index 531867a7..2979ad6 100644
--- a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-003-expected.png
+++ b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-003-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-004-expected.png b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-004-expected.png
index 76b4049..03c48c31 100644
--- a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-004-expected.png
+++ b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-004-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-010-expected.png b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-010-expected.png
index d2c4307..cda2b0a 100644
--- a/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-010-expected.png
+++ b/third_party/blink/web_tests/platform/win/ietestcenter/css3/text/textshadow-010-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/audio-controls-rendering-expected.png b/third_party/blink/web_tests/platform/win/media/audio-controls-rendering-expected.png
index c7a5749..2f5c88f 100644
--- a/third_party/blink/web_tests/platform/win/media/audio-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/audio-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/win/media/controls-after-reload-expected.png
index 560ede0..b586e0b17a 100644
--- a/third_party/blink/web_tests/platform/win/media/controls-after-reload-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls-after-reload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls-layout-direction-expected.png b/third_party/blink/web_tests/platform/win/media/controls-layout-direction-expected.png
index e3be6c2..6be687e 100644
--- a/third_party/blink/web_tests/platform/win/media/controls-layout-direction-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls-layout-direction-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/win/media/controls-strict-expected.png
index 801ffeb..1010dec 100644
--- a/third_party/blink/web_tests/platform/win/media/controls-strict-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/win/media/controls-styling-expected.png
index 9053a0944..1968a6f 100644
--- a/third_party/blink/web_tests/platform/win/media/controls-styling-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls-styling-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/win/media/controls-styling-strict-expected.png
index 27bb09ae..65632c78 100644
--- a/third_party/blink/web_tests/platform/win/media/controls-styling-strict-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls-styling-strict-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/win/media/controls-without-preload-expected.png
index d41ef4a..08acf1c 100644
--- a/third_party/blink/web_tests/platform/win/media/controls-without-preload-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls-without-preload-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png b/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
index e677877..7ad34ea 100644
--- a/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-custom-bg-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-expected.png b/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-expected.png
index 63a0399d..aacdb6c 100644
--- a/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/controls/paint-controls-webkit-appearance-none-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/media-controls-clone-expected.png b/third_party/blink/web_tests/platform/win/media/media-controls-clone-expected.png
index 7f91881a..74fa058 100644
--- a/third_party/blink/web_tests/platform/win/media/media-controls-clone-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/media-controls-clone-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/media-controls-grey-scrubber-expected.png b/third_party/blink/web_tests/platform/win/media/media-controls-grey-scrubber-expected.png
index 15961277..bad7e5c 100644
--- a/third_party/blink/web_tests/platform/win/media/media-controls-grey-scrubber-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/media-controls-grey-scrubber-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/media-document-audio-repaint-expected.png b/third_party/blink/web_tests/platform/win/media/media-document-audio-repaint-expected.png
index 99f13f1..ced8aec 100644
--- a/third_party/blink/web_tests/platform/win/media/media-document-audio-repaint-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/media-document-audio-repaint-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/win/media/video-controls-rendering-expected.png
index c030883..e7e2630 100644
--- a/third_party/blink/web_tests/platform/win/media/video-controls-rendering-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/video-controls-rendering-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/win/media/video-display-toggle-expected.png
index fb91e2c..cf9b1226 100644
--- a/third_party/blink/web_tests/platform/win/media/video-display-toggle-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/video-display-toggle-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/video-empty-source-expected.png b/third_party/blink/web_tests/platform/win/media/video-empty-source-expected.png
index c5e9eec..fde2ceab 100644
--- a/third_party/blink/web_tests/platform/win/media/video-empty-source-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/video-empty-source-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/video-no-audio-expected.png b/third_party/blink/web_tests/platform/win/media/video-no-audio-expected.png
index bbe1ca4d7..af32434 100644
--- a/third_party/blink/web_tests/platform/win/media/video-no-audio-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/video-no-audio-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/media/video-zoom-controls-expected.png b/third_party/blink/web_tests/platform/win/media/video-zoom-controls-expected.png
index a59d59f..ba6ec137d 100644
--- a/third_party/blink/web_tests/platform/win/media/video-zoom-controls-expected.png
+++ b/third_party/blink/web_tests/platform/win/media/video-zoom-controls-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/paint/invalidation/shadow-multiple-expected.png b/third_party/blink/web_tests/platform/win/paint/invalidation/shadow-multiple-expected.png
index 49b5a83..29013a45 100644
--- a/third_party/blink/web_tests/platform/win/paint/invalidation/shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/win/paint/invalidation/shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/paint/printing/print-text-shadow-expected.png b/third_party/blink/web_tests/platform/win/paint/printing/print-text-shadow-expected.png
index a33159d..a4be7231 100644
--- a/third_party/blink/web_tests/platform/win/paint/printing/print-text-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/paint/printing/print-text-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/paint/roundedrects/circle-with-shadow-expected.png b/third_party/blink/web_tests/platform/win/paint/roundedrects/circle-with-shadow-expected.png
index 0615c80..1853cbe 100644
--- a/third_party/blink/web_tests/platform/win/paint/roundedrects/circle-with-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/paint/roundedrects/circle-with-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png b/third_party/blink/web_tests/platform/win/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
index 19806856..a7bf498 100644
--- a/third_party/blink/web_tests/platform/win/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/paint/roundedrects/input-with-rounded-rect-and-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/svg/css/text-gradient-shadow-expected.png b/third_party/blink/web_tests/platform/win/svg/css/text-gradient-shadow-expected.png
index 22e18b8..6311347 100644
--- a/third_party/blink/web_tests/platform/win/svg/css/text-gradient-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/svg/css/text-gradient-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/svg/css/text-shadow-multiple-expected.png b/third_party/blink/web_tests/platform/win/svg/css/text-shadow-multiple-expected.png
index c92c987..dfb4366 100644
--- a/third_party/blink/web_tests/platform/win/svg/css/text-shadow-multiple-expected.png
+++ b/third_party/blink/web_tests/platform/win/svg/css/text-shadow-multiple-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/transforms/shadows-expected.png b/third_party/blink/web_tests/platform/win/transforms/shadows-expected.png
index 53b8523e..37dd8b1 100644
--- a/third_party/blink/web_tests/platform/win/transforms/shadows-expected.png
+++ b/third_party/blink/web_tests/platform/win/transforms/shadows-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png b/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
index 2ba9f0b..0d104c00 100644
--- a/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png b/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
index c82dc763..949f909c 100644
--- a/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-composite-video-shadow-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png b/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
index 5c70bbd..21da250 100644
--- a/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/gpu/fast/canvas/canvas-shadow-source-in-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
index 8134583..fc4a2458 100644
--- a/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index c898f21d..d0a3843 100644
--- a/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/scalefactor150/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
index aa5bbf0..62e8096 100644
--- a/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 412ad62..c54b4fc 100644
--- a/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/scalefactor200/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
index aa5bbf0..62e8096 100644
--- a/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png b/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
index 412ad62..c54b4fc 100644
--- a/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
+++ b/third_party/blink/web_tests/platform/win/virtual/scalefactor200withzoom/fast/hidpi/static/validation-bubble-appearance-hidpi-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-after-reload-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-after-reload-expected.png
deleted file mode 100644
index 560ede0..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-after-reload-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-strict-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-strict-expected.png
deleted file mode 100644
index 801ffeb..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-strict-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-styling-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-styling-expected.png
deleted file mode 100644
index 9053a0944..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-styling-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-styling-strict-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-styling-strict-expected.png
deleted file mode 100644
index 27bb09ae..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-styling-strict-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-without-preload-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-without-preload-expected.png
deleted file mode 100644
index d41ef4a..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/controls-without-preload-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-controls-rendering-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-controls-rendering-expected.png
deleted file mode 100644
index c030883..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-controls-rendering-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-display-toggle-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-display-toggle-expected.png
deleted file mode 100644
index fb91e2c..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-display-toggle-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-no-audio-expected.png b/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-no-audio-expected.png
deleted file mode 100644
index bbe1ca4d7..0000000
--- a/third_party/blink/web_tests/platform/win/virtual/video-surface-layer/media/video-no-audio-expected.png
+++ /dev/null
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/custom-elements/form-validation-bubble-appearance-expected.png b/third_party/blink/web_tests/platform/win7/custom-elements/form-validation-bubble-appearance-expected.png
index 1f00461..8d193c6 100644
--- a/third_party/blink/web_tests/platform/win7/custom-elements/form-validation-bubble-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/custom-elements/form-validation-bubble-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
index fa3dc60..86b8904 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-ar-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
index 8a1f2d7..10a0bb2a 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-coarse-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
index 0dc3c30..a52e4a2 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
index 6aa77ad..9271158 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-minimum-date-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
index 5fea888..426edd79 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-ar-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
index eda4b8f..acafee4 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-required-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
index 7106cbc..e617c9d 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
index b685e97..76ae44b6 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom125-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
index dffc86a..320bc0a 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/calendar-picker-appearance-zoom200-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png
index e3ed0f04..d6ca59b7 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
index e922d58..0263b95 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/month-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-expected.png
index bfc6e6d..76d340e 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-step-expected.png b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
index db4c8c8..0701bfe 100644
--- a/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/forms/calendar-picker/week-picker-appearance-step-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/text/shadow-translucent-fill-expected.png b/third_party/blink/web_tests/platform/win7/fast/text/shadow-translucent-fill-expected.png
index 5ece414..79fea6da 100644
--- a/third_party/blink/web_tests/platform/win7/fast/text/shadow-translucent-fill-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/text/shadow-translucent-fill-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/text/stroking-decorations-expected.png b/third_party/blink/web_tests/platform/win7/fast/text/stroking-decorations-expected.png
index 9652bd2..22477f5 100644
--- a/third_party/blink/web_tests/platform/win7/fast/text/stroking-decorations-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/text/stroking-decorations-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/fast/text/stroking-expected.png b/third_party/blink/web_tests/platform/win7/fast/text/stroking-expected.png
index b29c9e5..1893b1a 100644
--- a/third_party/blink/web_tests/platform/win7/fast/text/stroking-expected.png
+++ b/third_party/blink/web_tests/platform/win7/fast/text/stroking-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
index 8e5e335..4f890e9 100644
--- a/third_party/blink/web_tests/platform/win7/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/virtual/scalefactor150/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
index 0193fb3..4f5fb27 100644
--- a/third_party/blink/web_tests/platform/win7/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/virtual/scalefactor200/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
index 0193fb3..4f5fb27 100644
--- a/third_party/blink/web_tests/platform/win7/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
+++ b/third_party/blink/web_tests/platform/win7/virtual/scalefactor200withzoom/fast/hidpi/static/calendar-picker-appearance-expected.png
Binary files differ
diff --git a/third_party/blink/web_tests/scrollbars/custom-scrollbar-display-expected.png b/third_party/blink/web_tests/scrollbars/custom-scrollbar-display-expected.png
index 588d0bc..0371ae6 100644
--- a/third_party/blink/web_tests/scrollbars/custom-scrollbar-display-expected.png
+++ b/third_party/blink/web_tests/scrollbars/custom-scrollbar-display-expected.png
Binary files differ
diff --git a/third_party/libaom/README.chromium b/third_party/libaom/README.chromium
index f2ac10e7..7eaa1e4 100644
--- a/third_party/libaom/README.chromium
+++ b/third_party/libaom/README.chromium
@@ -4,7 +4,7 @@
 Version: 0
 Date: Friday December 21 2018
 Branch: master
-Commit: f90004a14ea8c2990e6cdb0961517760a6a2ffa9
+Commit: 20a747b9ce5ec99ad2f78dd206a3fc1b8abf6850
 License: BSD
 License File: source/libaom/LICENSE
 Security Critical: yes
diff --git a/third_party/libaom/source/config/config/aom_version.h b/third_party/libaom/source/config/config/aom_version.h
index f12e53b..ef1f078 100644
--- a/third_party/libaom/source/config/config/aom_version.h
+++ b/third_party/libaom/source/config/config/aom_version.h
@@ -12,8 +12,8 @@
 #define VERSION_MAJOR 1
 #define VERSION_MINOR 0
 #define VERSION_PATCH 0
-#define VERSION_EXTRA "1092-gf90004a14"
+#define VERSION_EXTRA "1101-g20a747b9c"
 #define VERSION_PACKED \
   ((VERSION_MAJOR << 16) | (VERSION_MINOR << 8) | (VERSION_PATCH))
-#define VERSION_STRING_NOSP "1.0.0-1092-gf90004a14"
-#define VERSION_STRING " 1.0.0-1092-gf90004a14"
+#define VERSION_STRING_NOSP "1.0.0-1101-g20a747b9c"
+#define VERSION_STRING " 1.0.0-1101-g20a747b9c"
diff --git a/tools/android/common/adb_connection.cc b/tools/android/common/adb_connection.cc
index 9b4b8eb..8b0c549c 100644
--- a/tools/android/common/adb_connection.cc
+++ b/tools/android/common/adb_connection.cc
@@ -15,8 +15,8 @@
 #include <unistd.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
 #include "tools/android/common/net.h"
 
 namespace tools {
@@ -39,19 +39,19 @@
   const size_t kLengthOfLength = 4;
 
   const char kAddressPrefix[] = { 't', 'c', 'p', ':' };
-  size_t address_length = arraysize(kAddressPrefix) + strlen(forward_to);
+  size_t address_length = base::size(kAddressPrefix) + strlen(forward_to);
   if (address_length > kBufferMaxLength - kLengthOfLength) {
     LOG(ERROR) << "Forward to address is too long: " << forward_to;
     return -1;
   }
 
   char request[kBufferMaxLength];
-  memcpy(request + kLengthOfLength, kAddressPrefix, arraysize(kAddressPrefix));
-  memcpy(request + kLengthOfLength + arraysize(kAddressPrefix),
-         forward_to, strlen(forward_to));
+  memcpy(request + kLengthOfLength, kAddressPrefix, base::size(kAddressPrefix));
+  memcpy(request + kLengthOfLength + base::size(kAddressPrefix), forward_to,
+         strlen(forward_to));
 
   char length_buffer[kLengthOfLength + 1];
-  snprintf(length_buffer, arraysize(length_buffer), "%04X",
+  snprintf(length_buffer, base::size(length_buffer), "%04X",
            static_cast<int>(address_length));
   memcpy(request, length_buffer, kLengthOfLength);
 
diff --git a/tools/android/forwarder2/forwarders_manager.cc b/tools/android/forwarder2/forwarders_manager.cc
index f97e0e8b..6ab8ed5 100644
--- a/tools/android/forwarder2/forwarders_manager.cc
+++ b/tools/android/forwarder2/forwarders_manager.cc
@@ -14,9 +14,9 @@
 #include "base/callback_helpers.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/posix/eintr_wrapper.h"
+#include "base/stl_util.h"
 #include "tools/android/forwarder2/forwarder.h"
 #include "tools/android/forwarder2/socket.h"
 
@@ -81,7 +81,7 @@
     deletion_notifier_.receiver_fd(),
   };
 
-  for (size_t i = 0; i < arraysize(notifier_fds); ++i) {
+  for (size_t i = 0; i < base::size(notifier_fds); ++i) {
     const int notifier_fd = notifier_fds[i];
     DCHECK_GT(notifier_fd, -1);
     FD_SET(notifier_fd, &read_fds);
diff --git a/tools/grit/grit/format/resource_map.py b/tools/grit/grit/format/resource_map.py
index aa39c50..b9c0130 100644
--- a/tools/grit/grit/format/resource_map.py
+++ b/tools/grit/grit/format/resource_map.py
@@ -97,7 +97,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 #include "%(rc_header_file)s"
 
@@ -114,7 +114,7 @@
   return '''\
 };
 
-const size_t %(map_name)sSize = arraysize(%(map_name)s);
+const size_t %(map_name)sSize = base::size(%(map_name)s);
 ''' % { 'map_name': GetMapName(root) }
 
 
diff --git a/tools/grit/grit/format/resource_map_unittest.py b/tools/grit/grit/format/resource_map_unittest.py
index f82b6ab..74ea11a 100755
--- a/tools/grit/grit/format/resource_map_unittest.py
+++ b/tools/grit/grit/format/resource_map_unittest.py
@@ -64,7 +64,7 @@
     self.assertEqual('''\
 #include "the_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"IDC_KLONKMENU", IDC_KLONKMENU},
@@ -72,13 +72,13 @@
   {"IDS_LANGUAGESPECIFIC", IDS_LANGUAGESPECIFIC},
   {"IDS_THIRDPRESENT", IDS_THIRDPRESENT},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
     output = util.StripBlankLinesAndComments(''.join(
         resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.')))
     self.assertEqual('''\
 #include "the_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"grit/testdata/klonk.rc", IDC_KLONKMENU},
@@ -86,7 +86,7 @@
   {"ghi", IDS_LANGUAGESPECIFIC},
   {"mno", IDS_THIRDPRESENT},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
 
   def testGzippedMapHeaderAndFileSource(self):
     grd = util.ParseGrdForUnittest('''\
@@ -128,13 +128,13 @@
     self.assertEqual('''\
 #include "gzipped_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GzippedGritResourceMap kTheRcHeader[] = {
   {"grit/testdata/klonk.rc", IDC_KLONKMENU, true},
   {"abc", IDS_FIRSTPRESENT, false},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
 
   def testFormatResourceMapWithOutputAllEqualsFalseForStructures(self):
     grd = util.ParseGrdForUnittest('''
@@ -195,7 +195,7 @@
     self.assertEqual('''\
 #include "the_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"IDR_KLONKMENU", IDR_KLONKMENU},
@@ -203,13 +203,13 @@
   {"IDR_METEOR", IDR_METEOR},
   {"IDR_LAST", IDR_LAST},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
     output = util.StripBlankLinesAndComments(''.join(
         resource_map.GetFormatter('resource_map_source')(grd, 'en', '.')))
     self.assertEqual('''\
 #include "the_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"IDR_KLONKMENU", IDR_KLONKMENU},
@@ -217,7 +217,7 @@
   {"IDR_METEOR", IDR_METEOR},
   {"IDR_LAST", IDR_LAST},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
 
   def testFormatResourceMapWithOutputAllEqualsFalseForIncludes(self):
     grd = util.ParseGrdForUnittest('''
@@ -274,7 +274,7 @@
     self.assertEqual('''\
 #include "the_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"IDC_KLONKMENU", IDC_KLONKMENU},
@@ -284,13 +284,13 @@
   {"IDS_METEOR", IDS_METEOR},
   {"IDS_LAST", IDS_LAST},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
     output = util.StripBlankLinesAndComments(''.join(
         resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.')))
     self.assertEqual('''\
 #include "the_resource_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"grit/testdata/klonk.rc", IDC_KLONKMENU},
@@ -300,7 +300,7 @@
   {"meteor", IDS_METEOR},
   {"xyz", IDS_LAST},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
 
   def testFormatStringResourceMap(self):
     grd = util.ParseGrdForUnittest('''
@@ -347,13 +347,13 @@
     self.assertEqual('''\
 #include "the_rc_map_header.h"
 #include <stddef.h>
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "the_rc_header.h"
 const GritResourceMap kTheRcHeader[] = {
   {"IDS_PRODUCT_NAME", IDS_PRODUCT_NAME},
   {"IDS_DEFAULT_TAB_TITLE_TITLE_CASE", IDS_DEFAULT_TAB_TITLE_TITLE_CASE},
 };
-const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output)
+const size_t kTheRcHeaderSize = base::size(kTheRcHeader);''', output)
 
 
 if __name__ == '__main__':
diff --git a/tools/ipc_fuzzer/fuzzer/fuzzer.cc b/tools/ipc_fuzzer/fuzzer/fuzzer.cc
index f7ff720..76d8c6f2 100644
--- a/tools/ipc_fuzzer/fuzzer/fuzzer.cc
+++ b/tools/ipc_fuzzer/fuzzer/fuzzer.cc
@@ -10,9 +10,9 @@
 #include <vector>
 
 #include "base/compiler_specific.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/memory/shared_memory_handle.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/unguessable_token.h"
 #include "base/values.h"
@@ -907,10 +907,10 @@
 struct FuzzTraits<gfx::Transform> {
   static bool Fuzz(gfx::Transform* p, Fuzzer* fuzzer) {
     SkMScalar matrix[16];
-    for (size_t i = 0; i < arraysize(matrix); i++) {
+    for (size_t i = 0; i < base::size(matrix); i++) {
       matrix[i] = p->matrix().get(i / 4, i % 4);
     }
-    if (!FuzzParamArray(&matrix[0], arraysize(matrix), fuzzer))
+    if (!FuzzParamArray(&matrix[0], base::size(matrix), fuzzer))
       return false;
     *p = gfx::Transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4],
                         matrix[5], matrix[6], matrix[7], matrix[8], matrix[9],
diff --git a/tools/json_schema_compiler/test/arrays_unittest.cc b/tools/json_schema_compiler/test/arrays_unittest.cc
index aa00402c..cc76e02 100644
--- a/tools/json_schema_compiler/test/arrays_unittest.cc
+++ b/tools/json_schema_compiler/test/arrays_unittest.cc
@@ -9,7 +9,7 @@
 #include <memory>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "tools/json_schema_compiler/test/enums.h"
@@ -77,7 +77,7 @@
   Enumeration expected_types[] = {ENUMERATION_ONE, ENUMERATION_TWO,
                                   ENUMERATION_THREE};
   EXPECT_EQ(std::vector<Enumeration>(
-                expected_types, expected_types + arraysize(expected_types)),
+                expected_types, expected_types + base::size(expected_types)),
             enum_array_reference.types);
 
   // Test ToValue.
@@ -110,7 +110,7 @@
                                          ENUMERATION_THREE};
   EXPECT_EQ(std::vector<Enumeration>(
                 expected_infile_types,
-                expected_infile_types + arraysize(expected_infile_types)),
+                expected_infile_types + base::size(expected_infile_types)),
             enum_array_mixed.infile_enums);
 
   test::api::enums::Enumeration expected_external_types[] = {
@@ -118,7 +118,7 @@
       test::api::enums::ENUMERATION_THREE};
   EXPECT_EQ(std::vector<test::api::enums::Enumeration>(
                 expected_external_types,
-                expected_external_types + arraysize(expected_external_types)),
+                expected_external_types + base::size(expected_external_types)),
             enum_array_mixed.external_enums);
 
   // Test ToValue.
diff --git a/tools/traffic_annotation/auditor/traffic_annotation_auditor_unittest.cc b/tools/traffic_annotation/auditor/traffic_annotation_auditor_unittest.cc
index dba6d0f8..e6191414 100644
--- a/tools/traffic_annotation/auditor/traffic_annotation_auditor_unittest.cc
+++ b/tools/traffic_annotation/auditor/traffic_annotation_auditor_unittest.cc
@@ -201,7 +201,7 @@
 
   const std::vector<std::string> git_files = filter.git_files();
 
-  EXPECT_EQ(git_files.size(), arraysize(kRelevantFiles));
+  EXPECT_EQ(git_files.size(), base::size(kRelevantFiles));
   for (const char* filepath : kRelevantFiles) {
     EXPECT_TRUE(base::ContainsValue(git_files, filepath));
   }
diff --git a/ui/accessibility/ax_generated_tree_unittest.cc b/ui/accessibility/ax_generated_tree_unittest.cc
index 3c58c9b4..8ec2979 100644
--- a/ui/accessibility/ax_generated_tree_unittest.cc
+++ b/ui/accessibility/ax_generated_tree_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/accessibility/ax_node.h"
@@ -62,7 +62,7 @@
   };
 
   int n = generator.UniqueTreeCount();
-  ASSERT_EQ(static_cast<int>(arraysize(EXPECTED_TREES)), n);
+  ASSERT_EQ(static_cast<int>(base::size(EXPECTED_TREES)), n);
 
   for (int i = 0; i < n; ++i) {
     AXTree tree;
@@ -96,7 +96,7 @@
   };
 
   int n = generator.UniqueTreeCount();
-  ASSERT_EQ(static_cast<int>(arraysize(EXPECTED_TREES)), n);
+  ASSERT_EQ(static_cast<int>(base::size(EXPECTED_TREES)), n);
 
   for (int i = 0; i < n; i++) {
     AXTree tree;
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc
index 43116d0..dc9a291 100644
--- a/ui/aura/mus/window_tree_client_unittest.cc
+++ b/ui/aura/mus/window_tree_client_unittest.cc
@@ -8,8 +8,8 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "cc/base/switches.h"
@@ -2307,7 +2307,7 @@
   // MODAL_TYPE_NONE, and make sure it succeeds each time.
   ui::ModalType kModalTypes[] = {ui::MODAL_TYPE_WINDOW, ui::MODAL_TYPE_SYSTEM,
                                  ui::MODAL_TYPE_NONE};
-  for (size_t i = 0; i < arraysize(kModalTypes); i++) {
+  for (size_t i = 0; i < base::size(kModalTypes); i++) {
     window.SetProperty(client::kModalKey, kModalTypes[i]);
     // Ack change as succeeding.
     ASSERT_TRUE(window_tree()->AckSingleChangeOfType(
diff --git a/ui/base/accelerators/accelerator_manager_unittest.cc b/ui/base/accelerators/accelerator_manager_unittest.cc
index 4711295..76681ea1 100644
--- a/ui/base/accelerators/accelerator_manager_unittest.cc
+++ b/ui/base/accelerators/accelerator_manager_unittest.cc
@@ -4,7 +4,7 @@
 
 #include "ui/base/accelerators/accelerator_manager.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/base/accelerators/test_accelerator_target.h"
 #include "ui/events/event_constants.h"
@@ -26,7 +26,7 @@
 // kAcceleratorModifiers used to determine which flags are set.
 int BuildAcceleratorModifier(int id) {
   int result = 0;
-  for (size_t i = 0; i < arraysize(kAcceleratorModifiers); ++i) {
+  for (size_t i = 0; i < base::size(kAcceleratorModifiers); ++i) {
     if (((1 << i) & id) != 0)
       result |= kAcceleratorModifiers[i];
   }
@@ -124,7 +124,7 @@
   TestAcceleratorTarget target;
 
   // Test all cases of possible modifiers.
-  for (size_t i = 0; i < (1 << arraysize(kAcceleratorModifiers)); ++i) {
+  for (size_t i = 0; i < (1 << base::size(kAcceleratorModifiers)); ++i) {
     const int modifiers = BuildAcceleratorModifier(i);
     Accelerator accelerator(GetAccelerator(VKEY_A, modifiers));
     manager_.Register({accelerator}, AcceleratorManager::kNormalPriority,
@@ -146,7 +146,7 @@
     EXPECT_FALSE(manager_.Process(GetAccelerator(VKEY_SHIFT, modifiers)))
         << i;  // different vkey
 
-    for (size_t test_i = 0; test_i < (1 << arraysize(kAcceleratorModifiers));
+    for (size_t test_i = 0; test_i < (1 << base::size(kAcceleratorModifiers));
          ++test_i) {
       if (test_i == i)
         continue;
diff --git a/ui/base/accelerators/menu_label_accelerator_util_linux_unittest.cc b/ui/base/accelerators/menu_label_accelerator_util_linux_unittest.cc
index 969b524..3b9a42f 100644
--- a/ui/base/accelerators/menu_label_accelerator_util_linux_unittest.cc
+++ b/ui/base/accelerators/menu_label_accelerator_util_linux_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace ui {
@@ -24,7 +24,7 @@
     { "&foo &&bar", "_foo &bar" },
     { "&foo &bar", "_foo _bar" },
   };
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::string result = ConvertAcceleratorsFromWindowsStyle(cases[i].input);
     EXPECT_EQ(cases[i].output, result);
   }
@@ -43,7 +43,7 @@
     { "&foo &&bar", "foo &bar" },
     { "&foo &bar", "foo bar" },
   };
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::string result = RemoveWindowsStyleAccelerators(cases[i].input);
     EXPECT_EQ(cases[i].output, result);
   }
diff --git a/ui/base/clipboard/clipboard_test_template.h b/ui/base/clipboard/clipboard_test_template.h
index 1d8d3834..fd0dcc6 100644
--- a/ui/base/clipboard/clipboard_test_template.h
+++ b/ui/base/clipboard/clipboard_test_template.h
@@ -17,7 +17,6 @@
 
 #include <stdint.h>
 
-#include <array>
 #include <memory>
 #include <string>
 
@@ -25,6 +24,7 @@
 #include "base/run_loop.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_task_environment.h"
 #include "build/build_config.h"
 #include "testing/gmock/include/gmock/gmock-matchers.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -58,22 +58,20 @@
 template <typename ClipboardTraits>
 class ClipboardTest : public PlatformTest {
  public:
-  ClipboardTest() {}
-  ~ClipboardTest() override = default;
-
-  // PlatformTest:
-  void SetUp() override {
-    PlatformTest::SetUp();
 #if defined(USE_AURA)
-    event_source_ = ClipboardTraits::GetEventSource();
+  ClipboardTest()
+      : scoped_task_environment_(
+            base::test::ScopedTaskEnvironment::MainThreadType::UI),
+        event_source_(ClipboardTraits::GetEventSource()),
+        clipboard_(ClipboardTraits::Create()) {}
+#else
+  ClipboardTest()
+      : scoped_task_environment_(
+            base::test::ScopedTaskEnvironment::MainThreadType::UI),
+        clipboard_(ClipboardTraits::Create()) {}
 #endif
-    clipboard_ = ClipboardTraits::Create();
-  }
 
-  void TearDown() override {
-    ClipboardTraits::Destroy(clipboard_);
-    PlatformTest::TearDown();
-  }
+  ~ClipboardTest() override { ClipboardTraits::Destroy(clipboard_); }
 
  protected:
   Clipboard& clipboard() { return *clipboard_; }
@@ -86,11 +84,12 @@
   }
 
  private:
+  base::test::ScopedTaskEnvironment scoped_task_environment_;
 #if defined(USE_AURA)
   std::unique_ptr<PlatformEventSource> event_source_;
 #endif
   // ui::Clipboard has a protected destructor, so scoped_ptr doesn't work here.
-  Clipboard* clipboard_ = nullptr;
+  Clipboard* const clipboard_;
 };
 
 // Hack for tests that need to call static methods of ClipboardTest.
@@ -99,9 +98,7 @@
   static void Destroy(Clipboard*) {}
 };
 
-// |NamesOfTypesToTest| provides a way to differentiate between different
-// clipboard tests that include this file. See docs in gtest-typed-test.h
-TYPED_TEST_CASE(ClipboardTest, TypesToTest, NamesOfTypesToTest);
+TYPED_TEST_CASE(ClipboardTest, TypesToTest);
 
 TYPED_TEST(ClipboardTest, ClearTest) {
   {
@@ -765,4 +762,4 @@
 
 }  // namespace ui
 
-#endif  // UI_BASE_CLIPBOARD_CLIPBOARD_TEST_TEMPLATE_H_
+#endif  // UI_BASE_CLIPBOARD_CLIPBOARD_TEST_TEMPLATE_H_
\ No newline at end of file
diff --git a/ui/base/clipboard/clipboard_unittest.cc b/ui/base/clipboard/clipboard_unittest.cc
index 6aa5db3..08b2c17 100644
--- a/ui/base/clipboard/clipboard_unittest.cc
+++ b/ui/base/clipboard/clipboard_unittest.cc
@@ -4,7 +4,6 @@
 
 #include "ui/base/clipboard/clipboard.h"
 
-#include "base/test/scoped_task_environment.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 #if defined(USE_AURA)
@@ -13,12 +12,6 @@
 
 namespace ui {
 
-namespace {
-
-base::test::ScopedTaskEnvironment* g_task_environment = nullptr;
-
-}  // namespace
-
 struct PlatformClipboardTraits {
 #if defined(USE_AURA)
   static std::unique_ptr<PlatformEventSource> GetEventSource() {
@@ -26,30 +19,15 @@
   }
 #endif
 
-  static Clipboard* Create() {
-    DCHECK(!g_task_environment);
-    g_task_environment = new base::test::ScopedTaskEnvironment(
-        base::test::ScopedTaskEnvironment::MainThreadType::UI);
-    return Clipboard::GetForCurrentThread();
-  }
+  static Clipboard* Create() { return Clipboard::GetForCurrentThread(); }
 
   static void Destroy(Clipboard* clipboard) {
     ASSERT_EQ(Clipboard::GetForCurrentThread(), clipboard);
     Clipboard::DestroyClipboardForCurrentThread();
-    delete g_task_environment;
-    g_task_environment = nullptr;
   }
 };
 
-using TypesToTest = PlatformClipboardTraits;
-
-class NamesOfTypesToTest {
- public:
-  template <typename T>
-  static std::string GetName(int index) {
-    return "BaseClipboardTest";
-  }
-};
+typedef PlatformClipboardTraits TypesToTest;
 
 }  // namespace ui
 
diff --git a/ui/base/clipboard/clipboard_util_win.cc b/ui/base/clipboard/clipboard_util_win.cc
index 5d16a369..d589e1bc 100644
--- a/ui/base/clipboard/clipboard_util_win.cc
+++ b/ui/base/clipboard/clipboard_util_win.cc
@@ -9,7 +9,7 @@
 
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/sys_string_conversions.h"
@@ -54,15 +54,11 @@
       return false;
 
     wchar_t filename[MAX_PATH];
-    if (DragQueryFileW(hdrop.get(), 0, filename, arraysize(filename))) {
+    if (DragQueryFileW(hdrop.get(), 0, filename, base::size(filename))) {
       wchar_t url_buffer[INTERNET_MAX_URL_LENGTH];
       if (0 == _wcsicmp(PathFindExtensionW(filename), L".url") &&
-          GetPrivateProfileStringW(L"InternetShortcut",
-                                   L"url",
-                                   0,
-                                   url_buffer,
-                                   arraysize(url_buffer),
-                                   filename)) {
+          GetPrivateProfileStringW(L"InternetShortcut", L"url", 0, url_buffer,
+                                   base::size(url_buffer), filename)) {
         *url = GURL(url_buffer);
         PathRemoveExtension(filename);
         title->assign(PathFindFileName(filename));
diff --git a/ui/base/cocoa/constrained_window/constrained_window_animation.mm b/ui/base/cocoa/constrained_window/constrained_window_animation.mm
index c755c4f..bb39146 100644
--- a/ui/base/cocoa/constrained_window/constrained_window_animation.mm
+++ b/ui/base/cocoa/constrained_window/constrained_window_animation.mm
@@ -10,8 +10,8 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #import "base/mac/foundation_util.h"
-#include "base/macros.h"
 #include "base/native_library.h"
+#include "base/stl_util.h"
 #include "ui/gfx/animation/tween.h"
 
 // The window animations in this file use private APIs as described here:
@@ -325,7 +325,7 @@
   };
 
   CGFloat scale = 1;
-  for (int i = arraysize(frames) - 1; i >= 0; --i) {
+  for (int i = base::size(frames) - 1; i >= 0; --i) {
     if (value >= frames[i].value) {
       CGFloat delta = frames[i + 1].value - frames[i].value;
       CGFloat frame_progress = (value - frames[i].value) / delta;
diff --git a/ui/base/cursor/cursors_aura.cc b/ui/base/cursor/cursors_aura.cc
index 1ceda419..63a5d53 100644
--- a/ui/base/cursor/cursors_aura.cc
+++ b/ui/base/cursor/cursors_aura.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "third_party/skia/include/core/SkBitmap.h"
 #include "ui/base/resource/resource_bundle.h"
@@ -204,16 +204,16 @@
 };
 
 const CursorSizeData kCursorSizes[] = {
-    {CursorSize::kNormal, kNormalCursors, arraysize(kNormalCursors),
-     kAnimatedCursors, arraysize(kAnimatedCursors)},
-    {CursorSize::kLarge, kLargeCursors, arraysize(kLargeCursors),
+    {CursorSize::kNormal, kNormalCursors, base::size(kNormalCursors),
+     kAnimatedCursors, base::size(kAnimatedCursors)},
+    {CursorSize::kLarge, kLargeCursors, base::size(kLargeCursors),
      // TODO(yoshiki): Replace animated cursors with big assets.
      // crbug.com/247254
-     kAnimatedCursors, arraysize(kAnimatedCursors)},
+     kAnimatedCursors, base::size(kAnimatedCursors)},
 };
 
 const CursorSizeData* GetCursorSizeByType(CursorSize cursor_size) {
-  for (size_t i = 0; i < arraysize(kCursorSizes); ++i) {
+  for (size_t i = 0; i < base::size(kCursorSizes); ++i) {
     if (kCursorSizes[i].id == cursor_size)
       return &kCursorSizes[i];
   }
diff --git a/ui/base/cursor/image_cursors.cc b/ui/base/cursor/image_cursors.cc
index 435fa5a..f41fcf9 100644
--- a/ui/base/cursor/image_cursors.cc
+++ b/ui/base/cursor/image_cursors.cc
@@ -8,7 +8,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "ui/base/cursor/cursor.h"
 #include "ui/base/cursor/cursor_loader.h"
@@ -111,7 +111,7 @@
 
   cursor_loader_->UnloadAll();
 
-  for (size_t i = 0; i < arraysize(kImageCursorIds); ++i) {
+  for (size_t i = 0; i < base::size(kImageCursorIds); ++i) {
     int resource_id = -1;
     gfx::Point hot_point;
     bool success =
@@ -120,7 +120,7 @@
     DCHECK(success);
     cursor_loader_->LoadImageCursor(kImageCursorIds[i], resource_id, hot_point);
   }
-  for (size_t i = 0; i < arraysize(kAnimatedCursorIds); ++i) {
+  for (size_t i = 0; i < base::size(kAnimatedCursorIds); ++i) {
     int resource_id = -1;
     gfx::Point hot_point;
     bool success =
diff --git a/ui/base/dragdrop/os_exchange_data_provider_win.cc b/ui/base/dragdrop/os_exchange_data_provider_win.cc
index 83f6da00..f843a65 100644
--- a/ui/base/dragdrop/os_exchange_data_provider_win.cc
+++ b/ui/base/dragdrop/os_exchange_data_provider_win.cc
@@ -17,9 +17,9 @@
 #include "base/files/file_path.h"
 #include "base/i18n/file_util_icu.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/no_destructor.h"
 #include "base/pickle.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/scoped_hdc.h"
 #include "base/win/scoped_hglobal.h"
@@ -1000,7 +1000,7 @@
     base::i18n::ReplaceIllegalCharactersInPath(validated, '-');
   }
   static const wchar_t extension[] = L".url";
-  static const size_t max_length = MAX_PATH - arraysize(extension);
+  static const size_t max_length = MAX_PATH - base::size(extension);
   if (validated->size() > max_length)
     validated->erase(max_length);
   *validated += extension;
diff --git a/ui/base/ime/chromeos/character_composer_unittest.cc b/ui/base/ime/chromeos/character_composer_unittest.cc
index b15abe3..6ea0a0f 100644
--- a/ui/base/ime/chromeos/character_composer_unittest.cc
+++ b/ui/base/ime/chromeos/character_composer_unittest.cc
@@ -8,7 +8,6 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -313,7 +312,7 @@
   ExpectUnicodeKeyComposed(
       VKEY_RETURN, DomCode::ENTER, EF_NONE, '\r',
       base::string16(kMusicalKeyboard,
-                     kMusicalKeyboard + arraysize(kMusicalKeyboard)));
+                     kMusicalKeyboard + base::size(kMusicalKeyboard)));
 }
 
 TEST_F(CharacterComposerTest, HexadecimalCompositionPreedit) {
diff --git a/ui/base/ime/chromeos/component_extension_ime_manager.cc b/ui/base/ime/chromeos/component_extension_ime_manager.cc
index ad5c791f..eac9a52 100644
--- a/ui/base/ime/chromeos/component_extension_ime_manager.cc
+++ b/ui/base/ime/chromeos/component_extension_ime_manager.cc
@@ -9,7 +9,7 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "chromeos/chromeos_switches.h"
 #include "ui/base/ime/chromeos/extension_ime_util.h"
@@ -116,7 +116,7 @@
 }
 
 ComponentExtensionIMEManager::ComponentExtensionIMEManager() {
-  for (size_t i = 0; i < arraysize(kLoginLayoutWhitelist); ++i) {
+  for (size_t i = 0; i < base::size(kLoginLayoutWhitelist); ++i) {
     login_layout_set_.insert(kLoginLayoutWhitelist[i]);
   }
 }
diff --git a/ui/base/ime/chromeos/ime_keyboard.cc b/ui/base/ime/chromeos/ime_keyboard.cc
index 455a61f..f028f39 100644
--- a/ui/base/ime/chromeos/ime_keyboard.cc
+++ b/ui/base/ime/chromeos/ime_keyboard.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/base/ime/chromeos/ime_keyboard.h"
 
 namespace chromeos {
@@ -96,7 +96,7 @@
 }
 
 bool ImeKeyboard::IsISOLevel5ShiftAvailable() const {
-  for (size_t i = 0; i < arraysize(kISOLevel5ShiftLayoutIds); ++i) {
+  for (size_t i = 0; i < base::size(kISOLevel5ShiftLayoutIds); ++i) {
     if (last_layout_ == kISOLevel5ShiftLayoutIds[i])
       return true;
   }
@@ -104,7 +104,7 @@
 }
 
 bool ImeKeyboard::IsAltGrAvailable() const {
-  for (size_t i = 0; i < arraysize(kAltGrLayoutIds); ++i) {
+  for (size_t i = 0; i < base::size(kAltGrLayoutIds); ++i) {
     if (last_layout_ == kAltGrLayoutIds[i])
       return true;
   }
diff --git a/ui/base/ime/chromeos/ime_keymap.cc b/ui/base/ime/chromeos/ime_keymap.cc
index 4b5dbde..c639df8 100644
--- a/ui/base/ime/chromeos/ime_keymap.cc
+++ b/ui/base/ime/chromeos/ime_keymap.cc
@@ -9,7 +9,7 @@
 #include <map>
 
 #include "base/lazy_instance.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ui {
 
@@ -160,7 +160,7 @@
 class KeyCodeMap {
  public:
   KeyCodeMap() {
-    for (size_t i = 0; i < arraysize(kKeyCodeTable); ++i) {
+    for (size_t i = 0; i < base::size(kKeyCodeTable); ++i) {
       map_dom_key_[kKeyCodeTable[i].dom_code] = kKeyCodeTable[i].keyboard_code;
       map_key_dom_[kKeyCodeTable[i].keyboard_code] = kKeyCodeTable[i].dom_code;
     }
diff --git a/ui/base/ime/chromeos/input_method_util.cc b/ui/base/ime/chromeos/input_method_util.cc
index ed09916..a1c4b94f4 100644
--- a/ui/base/ime/chromeos/input_method_util.cc
+++ b/ui/base/ime/chromeos/input_method_util.cc
@@ -13,7 +13,7 @@
 #include <unordered_set>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -52,7 +52,7 @@
     IDS_LANGUAGES_MEDIUM_LEN_NAME_BRAILLE },
 };
 const size_t kMappingImeIdToMediumLenNameResourceIdLen =
-    arraysize(kMappingImeIdToMediumLenNameResourceId);
+    base::size(kMappingImeIdToMediumLenNameResourceId);
 
 // Due to asynchronous initialization of component extension manager,
 // GetFirstLoginInputMethodIds may miss component extension IMEs. To enable
@@ -194,7 +194,7 @@
     {"xkb:us:workman:eng", IDS_STATUSBAR_LAYOUT_USA_WORKMAN},
 };
 const size_t kEnglishToResourceIdArraySize =
-    arraysize(kEnglishToResourceIdArray);
+    base::size(kEnglishToResourceIdArray);
 
 const struct InputMethodNameMap {
   const char* message_name;
@@ -408,7 +408,7 @@
   const std::string& disp = descriptor.name();
   if (base::StartsWith(disp, "__MSG_", base::CompareCase::SENSITIVE)) {
     const InputMethodNameMap* map = kInputMethodNameMap;
-    size_t map_size = arraysize(kInputMethodNameMap);
+    size_t map_size = base::size(kInputMethodNameMap);
     std::string name = base::ToUpperASCII(disp);
     const InputMethodNameMap map_key = {name.c_str(), 0};
     const InputMethodNameMap* p =
@@ -607,7 +607,7 @@
 
   const std::string current_layout =
       preferred_input_method.GetPreferredKeyboardLayout();
-  for (size_t i = 0; i < arraysize(kDefaultInputMethodRecommendation); ++i) {
+  for (size_t i = 0; i < base::size(kDefaultInputMethodRecommendation); ++i) {
     if (kDefaultInputMethodRecommendation[i].locale == language_code &&
         (!kDefaultInputMethodRecommendation[i].layout[0] ||
          kDefaultInputMethodRecommendation[i].layout == current_layout)) {
@@ -666,7 +666,7 @@
     const std::string& input_method_id) {
   std::string engine_id = input_method_id;
   // Migrates some Engine IDs from VPD.
-  for (size_t j = 0; j < arraysize(kEngineIdMigrationMap); ++j) {
+  for (size_t j = 0; j < base::size(kEngineIdMigrationMap); ++j) {
     size_t pos = engine_id.find(kEngineIdMigrationMap[j][0]);
     if (pos == 0) {
       engine_id.replace(0,
diff --git a/ui/base/ime/chromeos/input_method_util_unittest.cc b/ui/base/ime/chromeos/input_method_util_unittest.cc
index cc132e1..92d13947 100644
--- a/ui/base/ime/chromeos/input_method_util_unittest.cc
+++ b/ui/base/ime/chromeos/input_method_util_unittest.cc
@@ -10,7 +10,7 @@
 #include <string>
 
 #include "base/bind.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/base/ime/chromeos/extension_ime_util.h"
@@ -182,7 +182,7 @@
         "xkb:us:colemak:eng",    "xkb:de:neo:ger",    "xkb:es:cat:cat",
         "xkb:gb:dvorak:eng",
     };
-    const int len = arraysize(input_method_id);
+    const int len = base::size(input_method_id);
     for (int i = 0; i < len; ++i) {
       InputMethodDescriptor desc = GetDesc(input_method_id[i], "", "", "");
       base::string16 medium_name = util_.GetInputMethodMediumName(desc);
@@ -195,7 +195,7 @@
     const char* const input_method_id[] = {
         pinyin_ime_id, zhuyin_ime_id,
     };
-    const int len = arraysize(input_method_id);
+    const int len = base::size(input_method_id);
     for (int i = 0; i < len; ++i) {
       InputMethodDescriptor desc = GetDesc(input_method_id[i], "", "", "");
       base::string16 medium_name = util_.GetInputMethodMediumName(desc);
@@ -495,15 +495,15 @@
       {"unknown", "unknown"},
   };
   std::vector<std::string> input_method_ids;
-  for (size_t i = 0; i < arraysize(migration_cases); ++i)
+  for (size_t i = 0; i < base::size(migration_cases); ++i)
     input_method_ids.push_back(migration_cases[i][0]);
   // Duplicated hangul_2set.
   input_method_ids.push_back("ime:ko:hangul_2set");
 
   util_.MigrateInputMethods(&input_method_ids);
 
-  EXPECT_EQ(arraysize(migration_cases), input_method_ids.size());
-  for (size_t i = 0; i < arraysize(migration_cases); ++i) {
+  EXPECT_EQ(base::size(migration_cases), input_method_ids.size());
+  for (size_t i = 0; i < base::size(migration_cases); ++i) {
     EXPECT_EQ(
         extension_ime_util::GetInputMethodIDByEngineID(migration_cases[i][1]),
         input_method_ids[i]);
diff --git a/ui/base/ime/chromeos/input_method_whitelist.cc b/ui/base/ime/chromeos/input_method_whitelist.cc
index 3995ba1..e3078069 100644
--- a/ui/base/ime/chromeos/input_method_whitelist.cc
+++ b/ui/base/ime/chromeos/input_method_whitelist.cc
@@ -8,7 +8,7 @@
 
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "chromeos/ime/input_methods.h"
@@ -21,7 +21,7 @@
 const char kLanguageDelimiter[] = ",";
 
 InputMethodWhitelist::InputMethodWhitelist() {
-  for (size_t i = 0; i < arraysize(kInputMethods); ++i) {
+  for (size_t i = 0; i < base::size(kInputMethods); ++i) {
     supported_input_methods_.insert(kInputMethods[i].input_method_id);
   }
 }
@@ -38,8 +38,8 @@
 InputMethodWhitelist::GetSupportedInputMethods() const {
   std::unique_ptr<InputMethodDescriptors> input_methods(
       new InputMethodDescriptors);
-  input_methods->reserve(arraysize(kInputMethods));
-  for (size_t i = 0; i < arraysize(kInputMethods); ++i) {
+  input_methods->reserve(base::size(kInputMethods));
+  for (size_t i = 0; i < base::size(kInputMethods); ++i) {
     std::vector<std::string> layouts;
     layouts.push_back(kInputMethods[i].xkb_layout_id);
 
diff --git a/ui/base/ime/composition_text_util_pango_unittest.cc b/ui/base/ime/composition_text_util_pango_unittest.cc
index 26e34395..e097575 100644
--- a/ui/base/ime/composition_text_util_pango_unittest.cc
+++ b/ui/base/ime/composition_text_util_pango_unittest.cc
@@ -12,7 +12,7 @@
 #include <utility>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/base/ime/composition_text.h"
 
@@ -118,7 +118,7 @@
 }
 
 TEST(CompositionTextUtilPangoTest, ExtractCompositionText) {
-  for (size_t i = 0; i < arraysize(kTestData); ++i) {
+  for (size_t i = 0; i < base::size(kTestData); ++i) {
     const char* text = kTestData[i].text;
     const AttributeInfo* attrs = kTestData[i].attrs;
     SCOPED_TRACE(testing::Message() << "Testing:" << i
diff --git a/ui/base/ime/win/tsf_bridge.cc b/ui/base/ime/win/tsf_bridge.cc
index eab3ad63..f3f094c 100644
--- a/ui/base/ime/win/tsf_bridge.cc
+++ b/ui/base/ime/win/tsf_bridge.cc
@@ -10,6 +10,7 @@
 #include "base/memory/ref_counted.h"
 #include "base/message_loop/message_loop.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_local_storage.h"
 #include "base/win/scoped_variant.h"
 #include "ui/base/ime/text_input_client.h"
@@ -354,7 +355,7 @@
       TEXT_INPUT_TYPE_EMAIL,     TEXT_INPUT_TYPE_NUMBER,
       TEXT_INPUT_TYPE_TELEPHONE, TEXT_INPUT_TYPE_URL,
   };
-  for (size_t i = 0; i < arraysize(kTextInputTypes); ++i) {
+  for (size_t i = 0; i < base::size(kTextInputTypes); ++i) {
     const TextInputType input_type = kTextInputTypes[i];
     Microsoft::WRL::ComPtr<ITfContext> context;
     Microsoft::WRL::ComPtr<ITfDocumentMgr> document_manager;
diff --git a/ui/base/ime/win/tsf_text_store_unittest.cc b/ui/base/ime/win/tsf_text_store_unittest.cc
index ed22f58..4238043 100644
--- a/ui/base/ime/win/tsf_text_store_unittest.cc
+++ b/ui/base/ime/win/tsf_text_store_unittest.cc
@@ -10,8 +10,8 @@
 #include <OleCtl.h>
 #include <wrl/client.h>
 
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/win/scoped_com_initializer.h"
 #include "base/win/scoped_variant.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -1239,11 +1239,11 @@
 
   const TS_ATTRID kUnknownAttributes[] = {GUID_NULL};
   EXPECT_HRESULT_FAILED(text_store_->RequestSupportedAttrs(
-      0, arraysize(kUnknownAttributes), kUnknownAttributes))
+      0, base::size(kUnknownAttributes), kUnknownAttributes))
       << "Must fail for unknown attributes";
 
   const TS_ATTRID kAttributes[] = {GUID_NULL, GUID_PROP_INPUTSCOPE, GUID_NULL};
-  EXPECT_EQ(S_OK, text_store_->RequestSupportedAttrs(0, arraysize(kAttributes),
+  EXPECT_EQ(S_OK, text_store_->RequestSupportedAttrs(0, base::size(kAttributes),
                                                      kAttributes))
       << "InputScope must be supported";
 
@@ -1253,7 +1253,7 @@
     text_store_->SetFocusedTextInputClient(nullptr, nullptr);
     EXPECT_HRESULT_FAILED(text_store_->RequestSupportedAttrs(0, 0, nullptr));
     EXPECT_HRESULT_FAILED(text_store_->RequestSupportedAttrs(
-        0, arraysize(kAttributes), kAttributes));
+        0, base::size(kAttributes), kAttributes));
   }
 }
 
@@ -1271,7 +1271,7 @@
     SCOPED_TRACE("Make sure if InputScope is supported");
     TS_ATTRVAL buffer[2] = {};
     num_copied = 0xfffffff;
-    ASSERT_EQ(S_OK, text_store_->RetrieveRequestedAttrs(arraysize(buffer),
+    ASSERT_EQ(S_OK, text_store_->RetrieveRequestedAttrs(base::size(buffer),
                                                         buffer, &num_copied));
     bool input_scope_found = false;
     for (size_t i = 0; i < num_copied; ++i) {
@@ -1296,7 +1296,7 @@
     num_copied = 0xfffffff;
     TS_ATTRVAL buffer[2] = {};
     EXPECT_HRESULT_FAILED(text_store_->RetrieveRequestedAttrs(
-        arraysize(buffer), buffer, &num_copied));
+        base::size(buffer), buffer, &num_copied));
   }
 }
 
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 1eef9c2..3672fe4 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -19,7 +19,7 @@
 #include "base/i18n/rtl.h"
 #include "base/i18n/string_compare.h"
 #include "base/lazy_instance.h"
-#include "base/macros.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"
@@ -918,7 +918,7 @@
 }
 
 size_t GetAcceptLanguageListSizeForTesting() {
-  return arraysize(kAcceptLanguageList);
+  return base::size(kAcceptLanguageList);
 }
 
 }  // namespace l10n_util
diff --git a/ui/base/l10n/l10n_util_mac_unittest.mm b/ui/base/l10n/l10n_util_mac_unittest.mm
index c760425a..4ae224c 100644
--- a/ui/base/l10n/l10n_util_mac_unittest.mm
+++ b/ui/base/l10n/l10n_util_mac_unittest.mm
@@ -5,7 +5,7 @@
 #import <Foundation/Foundation.h>
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/platform_test.h"
@@ -38,7 +38,7 @@
     { @"foo(&b)...", @"foo\u2026" },
     { @"(&b)foo", @"foo" },
   };
-  for (size_t idx = 0; idx < arraysize(data); ++idx) {
+  for (size_t idx = 0; idx < base::size(data); ++idx) {
     base::string16 input16(base::SysNSStringToUTF16(data[idx].input));
 
     NSString* result = l10n_util::FixUpWindowsStyleLabel(input16);
diff --git a/ui/base/l10n/l10n_util_posix.cc b/ui/base/l10n/l10n_util_posix.cc
index b57e78d..3f75f32 100644
--- a/ui/base/l10n/l10n_util_posix.cc
+++ b/ui/base/l10n/l10n_util_posix.cc
@@ -6,7 +6,7 @@
 
 #include <string>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 
 #if defined(OS_CHROMEOS)
@@ -21,7 +21,7 @@
   // TODO(jungshik): Once the above issues are resolved, change this back
   // to return true.
   static const char kUnsupportedLocales[][3] = {"am", "sw"};
-  for (size_t i = 0; i < arraysize(kUnsupportedLocales); ++i) {
+  for (size_t i = 0; i < base::size(kUnsupportedLocales); ++i) {
     if (base::LowerCaseEqualsASCII(locale, kUnsupportedLocales[i]))
       return false;
   }
diff --git a/ui/base/l10n/l10n_util_unittest.cc b/ui/base/l10n/l10n_util_unittest.cc
index 167b32c..ba9a3ea7 100644
--- a/ui/base/l10n/l10n_util_unittest.cc
+++ b/ui/base/l10n/l10n_util_unittest.cc
@@ -11,8 +11,8 @@
 #include "base/i18n/case_conversion.h"
 #include "base/i18n/rtl.h"
 #include "base/i18n/time_formatting.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/icu_test_util.h"
@@ -111,7 +111,7 @@
       "fr", "he", "nb",          "pt-BR", "pt-PT", "zh-CN", "zh-TW",
   };
 
-  for (size_t i = 0; i < arraysize(filenames); ++i) {
+  for (size_t i = 0; i < base::size(filenames); ++i) {
     base::FilePath filename = new_locale_dir.AppendASCII(
         filenames[i] + ".pak");
     base::WriteFile(filename, "", 0);
diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
index c371212e..ffbb5fa 100644
--- a/ui/base/resource/resource_bundle.cc
+++ b/ui/base/resource/resource_bundle.cc
@@ -15,7 +15,6 @@
 #include "base/files/file.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
 #include "base/path_service.h"
 #include "base/stl_util.h"
@@ -940,12 +939,12 @@
 // static
 bool ResourceBundle::PNGContainsFallbackMarker(const unsigned char* buf,
                                                size_t size) {
-  if (size < arraysize(kPngMagic) ||
-      memcmp(buf, kPngMagic, arraysize(kPngMagic)) != 0) {
+  if (size < base::size(kPngMagic) ||
+      memcmp(buf, kPngMagic, base::size(kPngMagic)) != 0) {
     // Data invalid or a JPEG.
     return false;
   }
-  size_t pos = arraysize(kPngMagic);
+  size_t pos = base::size(kPngMagic);
 
   // Scan for custom chunks until we find one, find the IDAT chunk, or run out
   // of chunks.
@@ -956,13 +955,12 @@
     base::ReadBigEndian(reinterpret_cast<const char*>(buf + pos), &length);
     if (size - pos - kPngChunkMetadataSize < length)
       break;
-    if (length == 0 &&
-        memcmp(buf + pos + sizeof(uint32_t), kPngScaleChunkType,
-               arraysize(kPngScaleChunkType)) == 0) {
+    if (length == 0 && memcmp(buf + pos + sizeof(uint32_t), kPngScaleChunkType,
+                              base::size(kPngScaleChunkType)) == 0) {
       return true;
     }
     if (memcmp(buf + pos + sizeof(uint32_t), kPngDataChunkType,
-               arraysize(kPngDataChunkType)) == 0) {
+               base::size(kPngDataChunkType)) == 0) {
       // Stop looking for custom chunks, any custom chunks should be before an
       // IDAT chunk.
       break;
diff --git a/ui/base/resource/resource_bundle_unittest.cc b/ui/base/resource/resource_bundle_unittest.cc
index 710b274e..e2e69d3 100644
--- a/ui/base/resource/resource_bundle_unittest.cc
+++ b/ui/base/resource/resource_bundle_unittest.cc
@@ -14,8 +14,8 @@
 #include "base/files/file_util.h"
 #include "base/files/scoped_temp_dir.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted_memory.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "testing/gmock/include/gmock/gmock.h"
@@ -87,12 +87,11 @@
 // Returns |bitmap_data| with |custom_chunk| inserted after the IHDR chunk.
 void AddCustomChunk(const base::StringPiece& custom_chunk,
                     std::vector<unsigned char>* bitmap_data) {
-  EXPECT_LT(arraysize(kPngMagic) + kPngChunkMetadataSize, bitmap_data->size());
-  EXPECT_TRUE(std::equal(
-      bitmap_data->begin(),
-      bitmap_data->begin() + arraysize(kPngMagic),
-      kPngMagic));
-  auto ihdr_start = bitmap_data->begin() + arraysize(kPngMagic);
+  EXPECT_LT(base::size(kPngMagic) + kPngChunkMetadataSize, bitmap_data->size());
+  EXPECT_TRUE(std::equal(bitmap_data->begin(),
+                         bitmap_data->begin() + base::size(kPngMagic),
+                         kPngMagic));
+  auto ihdr_start = bitmap_data->begin() + base::size(kPngMagic);
   char ihdr_length_data[sizeof(uint32_t)];
   for (size_t i = 0; i < sizeof(uint32_t); ++i)
     ihdr_length_data[i] = *(ihdr_start + i);
@@ -516,9 +515,10 @@
   CreateDataPackWithSingleBitmap(data_path, 10, base::StringPiece());
   // 2x data pack bitmap has custom chunk to indicate that the 2x bitmap is not
   // available and that GRIT fell back to 1x.
-  CreateDataPackWithSingleBitmap(data_2x_path, 10, base::StringPiece(
-      reinterpret_cast<const char*>(kPngScaleChunk),
-      arraysize(kPngScaleChunk)));
+  CreateDataPackWithSingleBitmap(
+      data_2x_path, 10,
+      base::StringPiece(reinterpret_cast<const char*>(kPngScaleChunk),
+                        base::size(kPngScaleChunk)));
 
   // Load the regular and 2x pak files.
   ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
@@ -554,12 +554,14 @@
 
   CreateDataPackWithSingleBitmap(data_path, 8, base::StringPiece());
   // Mark 140% and 180% images as requiring 1x fallback.
-  CreateDataPackWithSingleBitmap(data_140P_path, 8, base::StringPiece(
-    reinterpret_cast<const char*>(kPngScaleChunk),
-    arraysize(kPngScaleChunk)));
-  CreateDataPackWithSingleBitmap(data_180P_path, 8, base::StringPiece(
-    reinterpret_cast<const char*>(kPngScaleChunk),
-    arraysize(kPngScaleChunk)));
+  CreateDataPackWithSingleBitmap(
+      data_140P_path, 8,
+      base::StringPiece(reinterpret_cast<const char*>(kPngScaleChunk),
+                        base::size(kPngScaleChunk)));
+  CreateDataPackWithSingleBitmap(
+      data_180P_path, 8,
+      base::StringPiece(reinterpret_cast<const char*>(kPngScaleChunk),
+                        base::size(kPngScaleChunk)));
 
   ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
   resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_100P);
diff --git a/ui/base/resource/scale_factor.cc b/ui/base/resource/scale_factor.cc
index dceffaec..aa52f48 100644
--- a/ui/base/resource/scale_factor.cc
+++ b/ui/base/resource/scale_factor.cc
@@ -4,7 +4,7 @@
 
 #include "ui/base/resource/scale_factor.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ui {
 
@@ -12,7 +12,7 @@
 
 const float kScaleFactorScales[] = {1.0f, 1.0f, 1.25f, 1.33f, 1.4f, 1.5f, 1.8f,
                                     2.0f, 2.5f, 3.0f};
-static_assert(NUM_SCALE_FACTORS == arraysize(kScaleFactorScales),
+static_assert(NUM_SCALE_FACTORS == base::size(kScaleFactorScales),
               "kScaleFactorScales has incorrect size");
 
 }  // namespace
diff --git a/ui/base/template_expressions.cc b/ui/base/template_expressions.cc
index 1aec20c..fbbeb320 100644
--- a/ui/base/template_expressions.cc
+++ b/ui/base/template_expressions.cc
@@ -7,12 +7,13 @@
 #include <stddef.h>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/values.h"
 #include "net/base/escape.h"
 
 namespace {
 const char kLeader[] = "$i18n";
-const size_t kLeaderSize = arraysize(kLeader) - 1;
+const size_t kLeaderSize = base::size(kLeader) - 1;
 const char kKeyOpen = '{';
 const char kKeyClose = '}';
 
diff --git a/ui/base/test/test_clipboard_unittest.cc b/ui/base/test/test_clipboard_unittest.cc
index 01ac029..0901969 100644
--- a/ui/base/test/test_clipboard_unittest.cc
+++ b/ui/base/test/test_clipboard_unittest.cc
@@ -4,7 +4,6 @@
 
 #include "ui/base/test/test_clipboard.h"
 
-#include "base/test/scoped_task_environment.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 #if defined(USE_AURA)
@@ -13,12 +12,6 @@
 
 namespace ui {
 
-namespace {
-
-base::test::ScopedTaskEnvironment* g_task_environment = nullptr;
-
-}  // namespace
-
 struct TestClipboardTraits {
 #if defined(USE_AURA)
   static std::unique_ptr<PlatformEventSource> GetEventSource() {
@@ -26,32 +19,16 @@
   }
 #endif
 
-  static Clipboard* Create() {
-    DCHECK(!g_task_environment);
-    g_task_environment = new base::test::ScopedTaskEnvironment(
-        base::test::ScopedTaskEnvironment::MainThreadType::UI);
-    return TestClipboard::CreateForCurrentThread();
-  }
+  static Clipboard* Create() { return TestClipboard::CreateForCurrentThread(); }
 
   static void Destroy(Clipboard* clipboard) {
     ASSERT_EQ(Clipboard::GetForCurrentThread(), clipboard);
     Clipboard::DestroyClipboardForCurrentThread();
-
-    delete g_task_environment;
-    g_task_environment = nullptr;
   }
 };
 
 typedef TestClipboardTraits TypesToTest;
 
-class NamesOfTypesToTest {
- public:
-  template <typename T>
-  static std::string GetName(int index) {
-    return "TestClipboardTest";
-  }
-};
-
 }  // namespace ui
 
 #include "ui/base/clipboard/clipboard_test_template.h"
diff --git a/ui/base/test/ui_controls_mac.mm b/ui/base/test/ui_controls_mac.mm
index 34f3ef9..8f25b5b 100644
--- a/ui/base/test/ui_controls_mac.mm
+++ b/ui/base/test/ui_controls_mac.mm
@@ -12,6 +12,7 @@
 #import "base/mac/foundation_util.h"
 #import "base/mac/scoped_objc_class_swizzler.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "ui/base/cocoa/cocoa_base_utils.h"
 #include "ui/events/keycodes/keyboard_code_conversion_mac.h"
@@ -194,7 +195,7 @@
   NSUInteger result = 0;
   const int buttons[3] = {
       ui_controls::LEFT, ui_controls::RIGHT, ui_controls::MIDDLE};
-  for (size_t i = 0; i < arraysize(buttons); ++i) {
+  for (size_t i = 0; i < base::size(buttons); ++i) {
     if (g_mouse_button_down[buttons[i]])
       result |= (1 << i);
   }
diff --git a/ui/base/text/bytes_formatting.cc b/ui/base/text/bytes_formatting.cc
index aff188c..4596414 100644
--- a/ui/base/text/bytes_formatting.cc
+++ b/ui/base/text/bytes_formatting.cc
@@ -6,7 +6,7 @@
 
 #include "base/i18n/number_formatting.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/base/l10n/l10n_util.h"
@@ -82,7 +82,7 @@
     return DATA_UNITS_BYTE;
   }
 
-  int unit_index = arraysize(kUnitThresholds);
+  int unit_index = base::size(kUnitThresholds);
   while (--unit_index > 0) {
     if (bytes >= kUnitThresholds[unit_index])
       break;
diff --git a/ui/base/text/bytes_formatting_unittest.cc b/ui/base/text/bytes_formatting_unittest.cc
index b2c2a41..eba17547 100644
--- a/ui/base/text/bytes_formatting_unittest.cc
+++ b/ui/base/text/bytes_formatting_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/base/text/bytes_formatting.h"
@@ -29,7 +29,7 @@
 #endif
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i)
+  for (size_t i = 0; i < base::size(cases); ++i)
     EXPECT_EQ(cases[i].expected, GetByteDisplayUnits(cases[i].bytes));
 }
 
@@ -72,7 +72,7 @@
 #endif
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     EXPECT_EQ(base::ASCIIToUTF16(cases[i].expected),
               FormatBytesWithUnits(cases[i].bytes, cases[i].units, false));
     EXPECT_EQ(base::ASCIIToUTF16(cases[i].expected_with_units),
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 9dfd9e0..3bcb620 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -22,7 +22,6 @@
 #include "base/command_line.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
 #include "base/message_loop/message_loop_current.h"
 #include "base/metrics/histogram_macros.h"
@@ -627,8 +626,7 @@
   // included in both the default input region and the client bounding region
   // will not be included in the effective input region on the screen.
   int rectangle_kind[] = {ShapeInput, ShapeBounding};
-  for (size_t kind_index = 0;
-       kind_index < arraysize(rectangle_kind);
+  for (size_t kind_index = 0; kind_index < base::size(rectangle_kind);
        kind_index++) {
     int dummy;
     int shape_rects_size = 0;
@@ -1002,7 +1000,7 @@
 
 std::string GetX11ErrorString(XDisplay* display, int err) {
   char buffer[256];
-  XGetErrorText(display, err, buffer, arraysize(buffer));
+  XGetErrorText(display, err, buffer, base::size(buffer));
   return buffer;
 }
 
diff --git a/ui/chromeos/events/event_rewriter_chromeos.cc b/ui/chromeos/events/event_rewriter_chromeos.cc
index cbfa559..7ffd17f 100644
--- a/ui/chromeos/events/event_rewriter_chromeos.cc
+++ b/ui/chromeos/events/event_rewriter_chromeos.cc
@@ -10,7 +10,7 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.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"
@@ -479,7 +479,7 @@
                                                     int original_flags) const {
   int unmodified_flags = original_flags;
   int rewritten_flags = pressed_modifier_latches_ | latched_modifier_latches_;
-  for (size_t i = 0; unmodified_flags && (i < arraysize(kModifierRemappings));
+  for (size_t i = 0; unmodified_flags && (i < base::size(kModifierRemappings));
        ++i) {
     const ModifierRemapping* remapped_key = nullptr;
     if (!(unmodified_flags & kModifierRemappings[i].flag))
@@ -977,8 +977,9 @@
     bool skip_search_key_remapping =
         delegate_ && delegate_->IsSearchKeyAcceleratorReserved();
     if (!skip_search_key_remapping &&
-        RewriteWithKeyboardRemappings(
-            kSearchRemappings, arraysize(kSearchRemappings), incoming, state)) {
+        RewriteWithKeyboardRemappings(kSearchRemappings,
+                                      base::size(kSearchRemappings), incoming,
+                                      state)) {
       return;
     }
   }
@@ -1003,8 +1004,8 @@
          {ui::EF_NONE, ui::DomCode::PAGE_DOWN, ui::DomKey::PAGE_DOWN,
           ui::VKEY_NEXT}}};
     if (RewriteWithKeyboardRemappings(kNonSearchRemappings,
-                                      arraysize(kNonSearchRemappings), incoming,
-                                      state)) {
+                                      base::size(kNonSearchRemappings),
+                                      incoming, state)) {
       return;
     }
   }
@@ -1108,12 +1109,12 @@
       switch (layout) {
         case kKbdTopRowLayout2:
           mapping = kFkeysToSystemKeys2;
-          mappingSize = arraysize(kFkeysToSystemKeys2);
+          mappingSize = base::size(kFkeysToSystemKeys2);
           break;
         case kKbdTopRowLayout1:
         default:
           mapping = kFkeysToSystemKeys1;
-          mappingSize = arraysize(kFkeysToSystemKeys1);
+          mappingSize = base::size(kFkeysToSystemKeys1);
           break;
       }
 
diff --git a/ui/chromeos/ime/candidate_view_unittest.cc b/ui/chromeos/ime/candidate_view_unittest.cc
index cc6c716..5fa5ec95 100644
--- a/ui/chromeos/ime/candidate_view_unittest.cc
+++ b/ui/chromeos/ime/candidate_view_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/aura/window.h"
 #include "ui/events/test/event_generator.h"
@@ -47,7 +47,7 @@
     container_ = init_params.delegate->GetContentsView();
     container_->SetLayoutManager(
         std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
-    for (size_t i = 0; i < arraysize(kDummyCandidates); ++i) {
+    for (size_t i = 0; i < base::size(kDummyCandidates); ++i) {
       CandidateView* candidate = new CandidateView(
           this, ui::CandidateWindow::VERTICAL);
       ui::CandidateWindow::Entry entry;
diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm
index ff92b9fa..96f1713 100644
--- a/ui/display/mac/screen_mac.mm
+++ b/ui/display/mac/screen_mac.mm
@@ -16,7 +16,7 @@
 #include "base/mac/scoped_cftyperef.h"
 #include "base/mac/scoped_nsobject.h"
 #include "base/mac/sdk_forward_declarations.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/timer/timer.h"
 #include "ui/display/display.h"
 #include "ui/display/display_change_notifier.h"
@@ -312,7 +312,7 @@
     // doesn't hurt.
     CGDirectDisplayID online_displays[128];
     CGDisplayCount online_display_count = 0;
-    if (CGGetOnlineDisplayList(arraysize(online_displays), online_displays,
+    if (CGGetOnlineDisplayList(base::size(online_displays), online_displays,
                                &online_display_count) != kCGErrorSuccess) {
       return std::vector<Display>(1, BuildPrimaryDisplay());
     }
diff --git a/ui/display/manager/configure_displays_task_unittest.cc b/ui/display/manager/configure_displays_task_unittest.cc
index a3e478c..72ad4fe 100644
--- a/ui/display/manager/configure_displays_task_unittest.cc
+++ b/ui/display/manager/configure_displays_task_unittest.cc
@@ -5,9 +5,9 @@
 #include <stddef.h>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/display/manager/configure_displays_task.h"
 #include "ui/display/manager/fake_display_snapshot.h"
@@ -101,7 +101,7 @@
       &ConfigureDisplaysTaskTest::ConfigureCallback, base::Unretained(this));
 
   std::vector<DisplayConfigureRequest> requests;
-  for (size_t i = 0; i < arraysize(displays_); ++i) {
+  for (size_t i = 0; i < base::size(displays_); ++i) {
     requests.push_back(DisplayConfigureRequest(
         displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
   }
@@ -166,7 +166,7 @@
   delegate_.set_max_configurable_pixels(1);
 
   std::vector<DisplayConfigureRequest> requests;
-  for (size_t i = 0; i < arraysize(displays_); ++i) {
+  for (size_t i = 0; i < base::size(displays_); ++i) {
     requests.push_back(DisplayConfigureRequest(
         displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
   }
@@ -192,7 +192,7 @@
   delegate_.set_max_configurable_pixels(small_mode_.size().GetArea());
 
   std::vector<DisplayConfigureRequest> requests;
-  for (size_t i = 0; i < arraysize(displays_); ++i) {
+  for (size_t i = 0; i < base::size(displays_); ++i) {
     requests.push_back(DisplayConfigureRequest(
         displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
   }
@@ -219,7 +219,7 @@
   delegate_.set_max_configurable_pixels(small_mode_.size().GetArea());
 
   std::vector<DisplayConfigureRequest> requests;
-  for (size_t i = 0; i < arraysize(displays_); ++i) {
+  for (size_t i = 0; i < base::size(displays_); ++i) {
     requests.push_back(DisplayConfigureRequest(
         displays_[i].get(), displays_[i]->native_mode(), gfx::Point()));
   }
diff --git a/ui/display/manager/display_change_observer.cc b/ui/display/manager/display_change_observer.cc
index bc4b86e..e99d15e4 100644
--- a/ui/display/manager/display_change_observer.cc
+++ b/ui/display/manager/display_change_observer.cc
@@ -12,6 +12,7 @@
 #include <vector>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/user_activity/user_activity_detector.h"
 #include "ui/display/display.h"
@@ -316,7 +317,7 @@
 
 // static
 float DisplayChangeObserver::FindDeviceScaleFactor(float dpi) {
-  for (size_t i = 0; i < arraysize(kThresholdTableForInternal); ++i) {
+  for (size_t i = 0; i < base::size(kThresholdTableForInternal); ++i) {
     if (dpi > kThresholdTableForInternal[i].dpi)
       return kThresholdTableForInternal[i].device_scale_factor;
   }
diff --git a/ui/display/manager/display_configurator_unittest.cc b/ui/display/manager/display_configurator_unittest.cc
index cde72cc..8f0d743 100644
--- a/ui/display/manager/display_configurator_unittest.cc
+++ b/ui/display/manager/display_configurator_unittest.cc
@@ -8,9 +8,9 @@
 #include <stdint.h>
 
 #include "base/command_line.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "chromeos/chromeos_switches.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/display/manager/fake_display_snapshot.h"
@@ -287,7 +287,7 @@
   // output-change events to |configurator_| and triggers the configure
   // timeout if one was scheduled.
   void UpdateOutputs(size_t num_outputs, bool send_events) {
-    ASSERT_LE(num_outputs, arraysize(outputs_));
+    ASSERT_LE(num_outputs, base::size(outputs_));
     std::vector<DisplaySnapshot*> outputs;
     for (size_t i = 0; i < num_outputs; ++i)
       outputs.push_back(outputs_[i].get());
diff --git a/ui/display/util/display_util.cc b/ui/display/util/display_util.cc
index ffb9cd1..f68e408b 100644
--- a/ui/display/util/display_util.cc
+++ b/ui/display/util/display_util.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace display {
 
@@ -32,7 +32,7 @@
     VLOG(1) << "Smaller than minimum display size";
     return true;
   }
-  for (size_t i = 1; i < arraysize(kInvalidDisplaySizeList); ++i) {
+  for (size_t i = 1; i < base::size(kInvalidDisplaySizeList); ++i) {
     const gfx::Size size(kInvalidDisplaySizeList[i][0],
                          kInvalidDisplaySizeList[i][1]);
     if (physical_size == size) {
diff --git a/ui/display/util/edid_parser_unittest.cc b/ui/display/util/edid_parser_unittest.cc
index d113317..500e4a4 100644
--- a/ui/display/util/edid_parser_unittest.cc
+++ b/ui/display/util/edid_parser_unittest.cc
@@ -8,8 +8,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/numerics/ranges.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkColorSpace.h"
 #include "ui/display/types/display_constants.h"
@@ -34,7 +34,7 @@
     "\x30\x20\x36\x00\x81\x90\x21\x00\x00\x1a\x00\x00\x00\xfc\x00\x48"
     "\x50\x20\x5a\x52\x33\x30\x77\x0a\x20\x20\x20\x20\x00\x00\x00\xff"
     "\x00\x43\x4e\x34\x32\x30\x32\x31\x33\x37\x51\x0a\x20\x20\x00\x71";
-constexpr size_t kNormalDisplayLength = arraysize(kNormalDisplay);
+constexpr size_t kNormalDisplayLength = base::size(kNormalDisplay);
 
 constexpr unsigned char kInternalDisplay[] =
     "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\xa3\x42\x31\x00\x00\x00\x00"
@@ -45,7 +45,7 @@
     "\x00\x00\x00\x00\x00\x23\x87\x02\x64\x00\x00\x00\x00\xfe\x00\x53"
     "\x41\x4d\x53\x55\x4e\x47\x0a\x20\x20\x20\x20\x20\x00\x00\x00\xfe"
     "\x00\x31\x32\x31\x41\x54\x31\x31\x2d\x38\x30\x31\x0a\x20\x00\x45";
-constexpr size_t kInternalDisplayLength = arraysize(kInternalDisplay);
+constexpr size_t kInternalDisplayLength = base::size(kInternalDisplay);
 
 constexpr unsigned char kOverscanDisplay[] =
     "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\x2d\xfe\x08\x00\x00\x00\x00"
@@ -64,7 +64,7 @@
     "\x5a\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc6";
-constexpr size_t kOverscanDisplayLength = arraysize(kOverscanDisplay);
+constexpr size_t kOverscanDisplayLength = base::size(kOverscanDisplay);
 
 // The EDID info misdetecting overscan once. see crbug.com/226318
 constexpr unsigned char kMisdetectedDisplay[] =
@@ -84,7 +84,7 @@
     "\x72\x51\xd0\x1e\x20\x6e\x28\x55\x00\x81\x91\x21\x00\x00\x1e\x8c"
     "\x0a\xd0\x8a\x20\xe0\x2d\x10\x10\x3e\x96\x00\x81\x91\x21\x00\x00"
     "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x94";
-constexpr size_t kMisdetectedDisplayLength = arraysize(kMisdetectedDisplay);
+constexpr size_t kMisdetectedDisplayLength = base::size(kMisdetectedDisplay);
 
 constexpr unsigned char kLP2565A[] =
     "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00\x22\xF0\x76\x26\x01\x01\x01\x01"
@@ -95,7 +95,7 @@
     "\x5E\x11\x00\x0A\x20\x20\x20\x20\x20\x20\x00\x00\x00\xFC\x00\x48"
     "\x50\x20\x4C\x50\x32\x34\x36\x35\x0A\x20\x20\x20\x00\x00\x00\xFF"
     "\x00\x43\x4E\x4B\x38\x30\x32\x30\x34\x48\x4D\x0A\x20\x20\x00\xA4";
-constexpr size_t kLP2565ALength = arraysize(kLP2565A);
+constexpr size_t kLP2565ALength = base::size(kLP2565A);
 
 constexpr unsigned char kLP2565B[] =
     "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00\x22\xF0\x75\x26\x01\x01\x01\x01"
@@ -106,7 +106,7 @@
     "\x5E\x15\x00\x0A\x20\x20\x20\x20\x20\x20\x00\x00\x00\xFC\x00\x48"
     "\x50\x20\x4C\x50\x32\x34\x36\x35\x0A\x20\x20\x20\x00\x00\x00\xFF"
     "\x00\x43\x4E\x4B\x38\x30\x32\x30\x34\x48\x4D\x0A\x20\x20\x00\x45";
-constexpr size_t kLP2565BLength = arraysize(kLP2565B);
+constexpr size_t kLP2565BLength = base::size(kLP2565B);
 
 // HP z32x monitor.
 constexpr unsigned char kHPz32x[] =
@@ -126,7 +126,7 @@
     "\x00\xA0\xA0\x40\x2E\x60\x20\x30\x63\x00\xB9\x88\x21\x00\x00\x1C"
     "\x28\x3C\x80\xA0\x70\xB0\x23\x40\x30\x20\x36\x00\xB9\x88\x21\x00"
     "\x00\x1A\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E";
-constexpr size_t kHPz32xLength = arraysize(kHPz32x);
+constexpr size_t kHPz32xLength = base::size(kHPz32x);
 
 // Chromebook Samus internal display.
 constexpr unsigned char kSamus[] =
@@ -138,7 +138,7 @@
     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\x00\x4c"
     "\x47\x20\x44\x69\x73\x70\x6c\x61\x79\x0a\x20\x20\x00\x00\x00\xfe"
     "\x00\x4c\x50\x31\x32\x39\x51\x45\x32\x2d\x53\x50\x41\x31\x00\x6c";
-constexpr size_t kSamusLength = arraysize(kSamus);
+constexpr size_t kSamusLength = base::size(kSamus);
 
 // Chromebook Eve internal display.
 constexpr unsigned char kEve[] =
@@ -150,7 +150,7 @@
     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00"
     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc"
     "\x00\x4c\x51\x31\x32\x33\x50\x31\x4a\x58\x33\x32\x0a\x20\x00\xb6";
-constexpr size_t kEveLength = arraysize(kEve);
+constexpr size_t kEveLength = base::size(kEve);
 
 // Primaries coordinates ({RX, RY, GX, GY, BX, BY, WX, WY}) calculated by hand
 // and rounded to 4 decimal places.
diff --git a/ui/events/blink/web_input_event_unittest.cc b/ui/events/blink/web_input_event_unittest.cc
index c304c99..2fb4ebf 100644
--- a/ui/events/blink/web_input_event_unittest.cc
+++ b/ui/events/blink/web_input_event_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/base_event_utils.h"
@@ -206,7 +206,7 @@
   }
 #if defined(USE_X11)
   ScopedXI2Event xev;
-  for (size_t i = 0; i < arraysize(kTesCases); ++i) {
+  for (size_t i = 0; i < base::size(kTesCases); ++i) {
     const TestCase& test_case = kTesCases[i];
 
     // TODO: re-enable the two cases excluded here once all trybots
@@ -472,7 +472,7 @@
       {ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_C, ui::EF_ALT_DOWN),
        blink::WebInputEvent::kKeyUp, blink::WebInputEvent::kAltKey}};
 
-  for (size_t i = 0; i < arraysize(tests); i++) {
+  for (size_t i = 0; i < base::size(tests); i++) {
     blink::WebKeyboardEvent web_event = MakeWebKeyboardEvent(tests[i].event);
     ASSERT_TRUE(blink::WebInputEvent::IsKeyboardEventType(web_event.GetType()));
     ASSERT_EQ(tests[i].web_type, web_event.GetType());
@@ -517,7 +517,7 @@
        gfx::Point(13, 3), gfx::Point(53, 3)},
   };
 
-  for (size_t i = 0; i < arraysize(tests); i++) {
+  for (size_t i = 0; i < base::size(tests); i++) {
     ui::MouseEvent ui_event(tests[i].ui_type, tests[i].location,
                             tests[i].screen_location, base::TimeTicks(),
                             tests[i].ui_modifiers, 0);
diff --git a/ui/events/devices/x11/device_data_manager_x11.cc b/ui/events/devices/x11/device_data_manager_x11.cc
index fbf372f..9b52d3ae 100644
--- a/ui/events/devices/x11/device_data_manager_x11.cc
+++ b/ui/events/devices/x11/device_data_manager_x11.cc
@@ -12,8 +12,8 @@
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "base/system/sys_info.h"
 #include "build/build_config.h"
 #include "ui/display/display.h"
@@ -102,7 +102,7 @@
 };
 
 // Make sure the sizes of enum and |kCachedAtoms| are aligned.
-static_assert(arraysize(kCachedAtoms) ==
+static_assert(base::size(kCachedAtoms) ==
                   ui::DeviceDataManagerX11::DT_LAST_ENTRY,
               "kCachedAtoms count / enum mismatch");
 
@@ -635,9 +635,8 @@
 }
 
 void DeviceDataManagerX11::UpdateButtonMap() {
-  button_map_count_ = XGetPointerMapping(gfx::GetXDisplay(),
-                                         button_map_,
-                                         arraysize(button_map_));
+  button_map_count_ = XGetPointerMapping(gfx::GetXDisplay(), button_map_,
+                                         base::size(button_map_));
 }
 
 void DeviceDataManagerX11::GetGestureTimes(const XEvent& xev,
diff --git a/ui/events/event_processor_unittest.cc b/ui/events/event_processor_unittest.cc
index 1c51a24..db597f93 100644
--- a/ui/events/event_processor_unittest.cc
+++ b/ui/events/event_processor_unittest.cc
@@ -5,8 +5,8 @@
 #include <utility>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/event.h"
 #include "ui/events/event_target_iterator.h"
@@ -403,8 +403,8 @@
 
   std::string expected[] = { "PreR", "PreC", "PreG", "G", "PostG", "PostC",
       "PostR", "PreR", "PreC", "C", "PostC", "PostR", "PreR", "R", "PostR" };
-  EXPECT_EQ(std::vector<std::string>(
-      expected, expected + arraysize(expected)), recorder);
+  EXPECT_EQ(std::vector<std::string>(expected, expected + base::size(expected)),
+            recorder);
 
   root()->RemovePreTargetHandler(&pre_root);
   child_r->RemovePreTargetHandler(&pre_child);
diff --git a/ui/events/event_unittest.cc b/ui/events/event_unittest.cc
index fee9fc13..f0f342890 100644
--- a/ui/events/event_unittest.cc
+++ b/ui/events/event_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "base/test/scoped_feature_list.h"
 #include "build/build_config.h"
@@ -269,7 +269,7 @@
     { VKEY_OEM_3, EF_SHIFT_DOWN, '~' },
   };
 
-  for (size_t i = 0; i < arraysize(kTestData); ++i) {
+  for (size_t i = 0; i < base::size(kTestData); ++i) {
     KeyEvent key(ET_KEY_PRESSED,
                  kTestData[i].key_code,
                  kTestData[i].flags);
diff --git a/ui/events/keycodes/dom/keycode_converter.cc b/ui/events/keycodes/dom/keycode_converter.cc
index dcb997be..df479d0 100644
--- a/ui/events/keycodes/dom/keycode_converter.cc
+++ b/ui/events/keycodes/dom/keycode_converter.cc
@@ -5,7 +5,6 @@
 #include "ui/events/keycodes/dom/keycode_converter.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "base/strings/utf_string_conversion_utils.h"
 #include "build/build_config.h"
@@ -34,7 +33,7 @@
 #undef USB_KEYMAP
 #undef USB_KEYMAP_DECLARATION
 
-const size_t kKeycodeMapEntries = arraysize(usb_keycode_map);
+const size_t kKeycodeMapEntries = base::size(usb_keycode_map);
 
 // Table of DomKey enum values and DOM Level 3 |key| strings.
 struct DomKeyMapEntry {
@@ -50,7 +49,7 @@
 #undef DOM_KEY_MAP
 #undef DOM_KEY_UNI
 
-const size_t kDomKeyMapEntries = arraysize(dom_key_map);
+const size_t kDomKeyMapEntries = base::size(dom_key_map);
 
 }  // namespace
 
diff --git a/ui/events/keycodes/dom/keycode_converter_unittest.cc b/ui/events/keycodes/dom/keycode_converter_unittest.cc
index 2fa7249..d3e51aa3 100644
--- a/ui/events/keycodes/dom/keycode_converter_unittest.cc
+++ b/ui/events/keycodes/dom/keycode_converter_unittest.cc
@@ -10,6 +10,7 @@
 #include <map>
 #include <set>
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/keycodes/dom/dom_code.h"
@@ -29,7 +30,7 @@
   118, // mac
 };
 
-const size_t kNativeColumns = arraysize(expected_mapped_key_count);
+const size_t kNativeColumns = base::size(expected_mapped_key_count);
 
 struct KeycodeConverterData {
   uint32_t usb_keycode;
diff --git a/ui/events/keycodes/keyboard_code_conversion.cc b/ui/events/keycodes/keyboard_code_conversion.cc
index c112545..deceb48 100644
--- a/ui/events/keycodes/keyboard_code_conversion.cc
+++ b/ui/events/keycodes/keyboard_code_conversion.cc
@@ -6,7 +6,7 @@
 
 #include <algorithm>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/events/event_constants.h"
 #include "ui/events/keycodes/dom/dom_code.h"
 #include "ui/events/keycodes/dom/dom_key.h"
@@ -254,7 +254,7 @@
 
 KeyboardCode DomCodeToUsLayoutKeyboardCode(DomCode dom_code) {
   const DomCodeToKeyboardCodeEntry* end =
-      kDomCodeToKeyboardCodeMap + arraysize(kDomCodeToKeyboardCodeMap);
+      kDomCodeToKeyboardCodeMap + base::size(kDomCodeToKeyboardCodeMap);
   const DomCodeToKeyboardCodeEntry* found = std::lower_bound(
       kDomCodeToKeyboardCodeMap, end, dom_code,
       [](const DomCodeToKeyboardCodeEntry& a, DomCode b) {
diff --git a/ui/events/keycodes/keyboard_code_conversion_mac.mm b/ui/events/keycodes/keyboard_code_conversion_mac.mm
index 873c4ce..d6b01cc1 100644
--- a/ui/events/keycodes/keyboard_code_conversion_mac.mm
+++ b/ui/events/keycodes/keyboard_code_conversion_mac.mm
@@ -11,8 +11,8 @@
 #include "base/logging.h"
 #include "base/mac/mac_logging.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
 #include "base/memory/scoped_policy.h"
+#include "base/stl_util.h"
 #include "ui/events/keycodes/dom/keycode_converter.h"
 
 namespace ui {
@@ -573,9 +573,9 @@
   from.keycode = keycode;
 
   const KeyCodeMap* ptr = std::lower_bound(
-      kKeyCodesMap, kKeyCodesMap + arraysize(kKeyCodesMap), from);
+      kKeyCodesMap, kKeyCodesMap + base::size(kKeyCodesMap), from);
 
-  if (ptr >= kKeyCodesMap + arraysize(kKeyCodesMap) ||
+  if (ptr >= kKeyCodesMap + base::size(kKeyCodesMap) ||
       ptr->keycode != keycode || ptr->macKeycode == -1)
     return -1;
 
diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc
index b1e1e3f..581e0b2b 100644
--- a/ui/events/keycodes/keyboard_code_conversion_x.cc
+++ b/ui/events/keycodes/keyboard_code_conversion_x.cc
@@ -9,7 +9,7 @@
 #include <algorithm>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -556,7 +556,7 @@
     XK_space
   };
 
-  for (size_t i = 0; i < arraysize(keysyms); ++i) {
+  for (size_t i = 0; i < base::size(keysyms); ++i) {
     if (keysyms[i] == keysym)
       return true;
   }
@@ -620,12 +620,12 @@
       !IsCursorKey(keysym) && !IsPFKey(keysym) && !IsFunctionKey(keysym) &&
       !IsModifierKey(keysym)) {
     MAP0 key0 = {keysym & 0xFFFF, 0};
-    keycode = FindVK(key0, map0, arraysize(map0));
+    keycode = FindVK(key0, map0, base::size(map0));
     if (keycode != VKEY_UNKNOWN)
       return keycode;
 
     MAP1 key1 = {keysym & 0xFFFF, xkey->keycode, 0};
-    keycode = FindVK(key1, map1, arraysize(map1));
+    keycode = FindVK(key1, map1, base::size(map1));
     if (keycode != VKEY_UNKNOWN)
       return keycode;
 
@@ -633,7 +633,7 @@
     xkey->state |= ShiftMask;
     XLookupString(xkey, NULL, 0, &keysym_shift, NULL);
     MAP2 key2 = {keysym & 0xFFFF, xkey->keycode, keysym_shift & 0xFFFF, 0};
-    keycode = FindVK(key2, map2, arraysize(map2));
+    keycode = FindVK(key2, map2, base::size(map2));
     if (keycode != VKEY_UNKNOWN)
       return keycode;
 
@@ -643,7 +643,7 @@
     XLookupString(xkey, NULL, 0, &keysym_altgr, NULL);
     MAP3 key3 = {keysym & 0xFFFF, xkey->keycode, keysym_shift & 0xFFFF,
                  keysym_altgr & 0xFFFF, 0};
-    keycode = FindVK(key3, map3, arraysize(map3));
+    keycode = FindVK(key3, map3, base::size(map3));
     if (keycode != VKEY_UNKNOWN)
       return keycode;
 
@@ -653,9 +653,9 @@
     MAP3 key4 = {keysym & 0xFFFF, xkey->keycode, keysym_shift & 0xFFFF, 0,
                  0};
     const MAP3* p =
-        std::lower_bound(map3, map3 + arraysize(map3), key4, MAP3());
-    if (p != map3 + arraysize(map3) && p->ch0 == key4.ch0 && p->sc == key4.sc &&
-        p->ch1 == key4.ch1)
+        std::lower_bound(map3, map3 + base::size(map3), key4, MAP3());
+    if (p != map3 + base::size(map3) && p->ch0 == key4.ch0 &&
+        p->sc == key4.sc && p->ch1 == key4.ch1)
       return static_cast<KeyboardCode>(p->vk);
   }
 
@@ -1150,7 +1150,7 @@
       VKEY_COMPOSE,            // 0x87: KEY_COMPOSE          Menu
   };
 
-  if (hardware_code >= arraysize(kHardwareKeycodeMap)) {
+  if (hardware_code >= base::size(kHardwareKeycodeMap)) {
     // Additional keycodes used by the Chrome OS top row special function keys.
     switch (hardware_code) {
       case 0xA6:  // KEY_BACK
diff --git a/ui/events/keycodes/keysym_to_unicode.cc b/ui/events/keycodes/keysym_to_unicode.cc
index 9413e97d..d58059cf 100644
--- a/ui/events/keycodes/keysym_to_unicode.cc
+++ b/ui/events/keycodes/keysym_to_unicode.cc
@@ -8,7 +8,7 @@
 
 #include "base/containers/hash_tables.h"
 #include "base/lazy_instance.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/gfx/x/x11.h"
 
 namespace ui {
@@ -812,8 +812,8 @@
 class KeySymToUnicode {
  public:
   KeySymToUnicode()
-      : keysym_to_unicode_map_(arraysize(g_keysym_to_unicode_table)) {
-    for (size_t i = 0; i < arraysize(g_keysym_to_unicode_table); ++i) {
+      : keysym_to_unicode_map_(base::size(g_keysym_to_unicode_table)) {
+    for (size_t i = 0; i < base::size(g_keysym_to_unicode_table); ++i) {
       keysym_to_unicode_map_[g_keysym_to_unicode_table[i].keysym] =
           g_keysym_to_unicode_table[i].unicode;
     }
diff --git a/ui/events/keycodes/platform_key_map_win.cc b/ui/events/keycodes/platform_key_map_win.cc
index c803dc47..e58c529 100644
--- a/ui/events/keycodes/platform_key_map_win.cc
+++ b/ui/events/keycodes/platform_key_map_win.cc
@@ -10,7 +10,7 @@
 #include "base/feature_list.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_local_storage.h"
 
 #include "ui/events/event_constants.h"
@@ -71,11 +71,11 @@
              : flags;
 }
 
-const int kModifierFlagsCombinations = (1 << arraysize(modifier_flags)) - 1;
+const int kModifierFlagsCombinations = (1 << base::size(modifier_flags)) - 1;
 
 int GetModifierFlags(int combination) {
   int flags = EF_NONE;
-  for (size_t i = 0; i < arraysize(modifier_flags); ++i) {
+  for (size_t i = 0; i < base::size(modifier_flags); ++i) {
     if (combination & (1 << i))
       flags |= modifier_flags[i];
   }
@@ -405,14 +405,14 @@
     for (int key_code = 0; key_code <= 0xFF; ++key_code) {
       wchar_t translated_chars[5];
       int rv = ::ToUnicodeEx(key_code, 0, keyboard_state, translated_chars,
-                             arraysize(translated_chars), 0, keyboard_layout_);
+                             base::size(translated_chars), 0, keyboard_layout_);
 
       if (rv == -1) {
         // Dead key, injecting VK_SPACE to get character representation.
         BYTE empty_state[256];
         memset(empty_state, 0, sizeof(empty_state));
         rv = ::ToUnicodeEx(VK_SPACE, 0, empty_state, translated_chars,
-                           arraysize(translated_chars), 0, keyboard_layout_);
+                           base::size(translated_chars), 0, keyboard_layout_);
         // Expecting a dead key character (not followed by a space).
         if (rv == 1) {
           printable_keycode_to_key_[std::make_pair(static_cast<int>(key_code),
diff --git a/ui/events/ozone/device/udev/device_manager_udev.cc b/ui/events/ozone/device/udev/device_manager_udev.cc
index 52ac57c..895a4d4 100644
--- a/ui/events/ozone/device/udev/device_manager_udev.cc
+++ b/ui/events/ozone/device/udev/device_manager_udev.cc
@@ -6,8 +6,8 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/message_loop/message_loop_current.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/trace_event/trace_event.h"
 #include "ui/events/ozone/device/device_event.h"
@@ -66,7 +66,7 @@
   struct udev_monitor* monitor =
       device::udev_monitor_new_from_netlink(udev, "udev");
   if (monitor) {
-    for (size_t i = 0; i < arraysize(kSubsystems); ++i)
+    for (size_t i = 0; i < base::size(kSubsystems); ++i)
       device::udev_monitor_filter_add_match_subsystem_devtype(
           monitor, kSubsystems[i], NULL);
 
@@ -107,7 +107,7 @@
   if (!enumerate)
     return;
 
-  for (size_t i = 0; i < arraysize(kSubsystems); ++i)
+  for (size_t i = 0; i < base::size(kSubsystems); ++i)
     device::udev_enumerate_add_match_subsystem(enumerate.get(), kSubsystems[i]);
   device::udev_enumerate_scan_devices(enumerate.get());
 
diff --git a/ui/events/ozone/evdev/capture_device_capabilities.py b/ui/events/ozone/evdev/capture_device_capabilities.py
index fd7aeee..e45d3d0 100755
--- a/ui/events/ozone/evdev/capture_device_capabilities.py
+++ b/ui/events/ozone/evdev/capture_device_capabilities.py
@@ -118,7 +118,7 @@
 
   if has_abs:
     out.write('    %s,\n' % absinfo_identifier)
-    out.write('    arraysize(%s),\n' % absinfo_identifier)
+    out.write('    base::size(%s),\n' % absinfo_identifier)
 
   out.write('};\n')
 
diff --git a/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc b/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
index 44ee043..20658488 100644
--- a/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
+++ b/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
@@ -11,8 +11,8 @@
 
 #include "base/bind.h"
 #include "base/files/scoped_file.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/event.h"
 #include "ui/events/keycodes/dom/dom_code.h"
@@ -187,7 +187,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::KeyEvent* event;
@@ -224,7 +224,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::KeyEvent* event;
@@ -267,7 +267,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(4u, size());
 
   ui::KeyEvent* event;
@@ -322,7 +322,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(6u, size());
 
   ui::KeyEvent* event;
@@ -371,7 +371,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::KeyEvent* event;
@@ -398,7 +398,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::MouseEvent* event;
@@ -430,7 +430,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0}
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::MouseEvent* event = nullptr;
@@ -462,7 +462,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0}
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::MouseEvent* event = nullptr;
@@ -485,7 +485,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   ui::MouseEvent* event;
@@ -506,7 +506,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(0u, size());
 }
 
@@ -518,7 +518,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   DestroyDevice();
@@ -543,7 +543,7 @@
       {{0, 0}, EV_SYN, SYN_DROPPED, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(2u, size());
 
   ui::KeyEvent* event = dispatched_event(0);
@@ -563,7 +563,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   dev->SetEnabled(false);
@@ -596,7 +596,7 @@
     {{0, 0}, EV_KEY, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
 
   ASSERT_EQ(4u, size());
   ui::KeyEvent* event = dispatched_event(0);
@@ -616,7 +616,7 @@
   std::vector<ui::DomCode> allowed_keys;
   allowed_keys.push_back(ui::DomCode::POWER);
   dev->SetKeyFilter(true /* enable_filter */, allowed_keys);
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
 
   ASSERT_EQ(2u, size());
   event = dispatched_event(0);
@@ -628,7 +628,7 @@
 
   ClearDispatchedEvents();
   dev->SetKeyFilter(false /* enable_filter */, std::vector<ui::DomCode>());
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
 
   event = dispatched_event(0);
   EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
@@ -658,7 +658,7 @@
     {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(key_press, arraysize(key_press));
+  dev->ProcessEvents(key_press, base::size(key_press));
   ASSERT_EQ(1u, size());
   ui::KeyEvent* event = dispatched_event(0);
   EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
@@ -674,7 +674,7 @@
 
   // The real key release should be dropped, whenever it comes.
   ClearDispatchedEvents();
-  dev->ProcessEvents(key_release, arraysize(key_release));
+  dev->ProcessEvents(key_release, base::size(key_release));
   ASSERT_EQ(0u, size());
 }
 
@@ -701,7 +701,7 @@
   SetTestNowSeconds(1510019415);
   ClearDispatchedEvents();
   GetInputController()->SetPrimaryButtonRight(false);
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(4u, size());
 
   ui::MouseEvent* event;
@@ -741,7 +741,7 @@
 
   ClearDispatchedEvents();
   GetInputController()->SetPrimaryButtonRight(true);
-  dev->ProcessEvents(mock_kernel_queue2, arraysize(mock_kernel_queue2));
+  dev->ProcessEvents(mock_kernel_queue2, base::size(mock_kernel_queue2));
   EXPECT_EQ(4u, size());
 
   event = dispatched_mouse_event(0);
diff --git a/ui/events/ozone/evdev/event_device_info.cc b/ui/events/ozone/evdev/event_device_info.cc
index 60e1d52..7b89ebe 100644
--- a/ui/events/ozone/evdev/event_device_info.cc
+++ b/ui/events/ozone/evdev/event_device_info.cc
@@ -8,7 +8,7 @@
 
 #include "base/files/file_path.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_restrictions.h"
 #include "ui/events/devices/device_util_linux.h"
 
@@ -198,35 +198,35 @@
 }
 
 void EventDeviceInfo::SetEventTypes(const unsigned long* ev_bits, size_t len) {
-  AssignBitset(ev_bits, len, ev_bits_, arraysize(ev_bits_));
+  AssignBitset(ev_bits, len, ev_bits_, base::size(ev_bits_));
 }
 
 void EventDeviceInfo::SetKeyEvents(const unsigned long* key_bits, size_t len) {
-  AssignBitset(key_bits, len, key_bits_, arraysize(key_bits_));
+  AssignBitset(key_bits, len, key_bits_, base::size(key_bits_));
 }
 
 void EventDeviceInfo::SetRelEvents(const unsigned long* rel_bits, size_t len) {
-  AssignBitset(rel_bits, len, rel_bits_, arraysize(rel_bits_));
+  AssignBitset(rel_bits, len, rel_bits_, base::size(rel_bits_));
 }
 
 void EventDeviceInfo::SetAbsEvents(const unsigned long* abs_bits, size_t len) {
-  AssignBitset(abs_bits, len, abs_bits_, arraysize(abs_bits_));
+  AssignBitset(abs_bits, len, abs_bits_, base::size(abs_bits_));
 }
 
 void EventDeviceInfo::SetMscEvents(const unsigned long* msc_bits, size_t len) {
-  AssignBitset(msc_bits, len, msc_bits_, arraysize(msc_bits_));
+  AssignBitset(msc_bits, len, msc_bits_, base::size(msc_bits_));
 }
 
 void EventDeviceInfo::SetSwEvents(const unsigned long* sw_bits, size_t len) {
-  AssignBitset(sw_bits, len, sw_bits_, arraysize(sw_bits_));
+  AssignBitset(sw_bits, len, sw_bits_, base::size(sw_bits_));
 }
 
 void EventDeviceInfo::SetLedEvents(const unsigned long* led_bits, size_t len) {
-  AssignBitset(led_bits, len, led_bits_, arraysize(led_bits_));
+  AssignBitset(led_bits, len, led_bits_, base::size(led_bits_));
 }
 
 void EventDeviceInfo::SetProps(const unsigned long* prop_bits, size_t len) {
-  AssignBitset(prop_bits, len, prop_bits_, arraysize(prop_bits_));
+  AssignBitset(prop_bits, len, prop_bits_, base::size(prop_bits_));
 }
 
 void EventDeviceInfo::SetAbsInfo(unsigned int code,
diff --git a/ui/events/ozone/evdev/event_device_test_util.cc b/ui/events/ozone/evdev/event_device_test_util.cc
index 0d08e6a..1172b98 100644
--- a/ui/events/ozone/evdev/event_device_test_util.cc
+++ b/ui/events/ozone/evdev/event_device_test_util.cc
@@ -7,7 +7,7 @@
 #include <stdint.h>
 
 #include "base/format_macros.h"
-#include "base/macros.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"
@@ -106,7 +106,7 @@
     /* led */ "0",
     /* ff */ "0",
     kHJCGamepadAbsAxes,
-    arraysize(kHJCGamepadAbsAxes),
+    base::size(kHJCGamepadAbsAxes),
 };
 
 // Captured from Xbox 360 gamepad.
@@ -140,7 +140,7 @@
     /* led */ "0",
     /* ff */ "107030000 0",
     kXboxGamepadAbsAxes,
-    arraysize(kXboxGamepadAbsAxes),
+    base::size(kXboxGamepadAbsAxes),
 };
 
 // Captured from iBuffalo gamepad.
@@ -169,7 +169,7 @@
     /* led */ "0",
     /* ff */ "0",
     kiBuffaloGamepadAbsAxes,
-    arraysize(kiBuffaloGamepadAbsAxes),
+    base::size(kiBuffaloGamepadAbsAxes),
 };
 
 // Captured from Pixelbook.
@@ -208,7 +208,7 @@
     /* led */ "0",
     /* ff */ "0",
     kEveTouchScreenAbsAxes,
-    arraysize(kEveTouchScreenAbsAxes),
+    base::size(kEveTouchScreenAbsAxes),
 };
 
 // Captured from Chromebook Pixel.
@@ -246,8 +246,9 @@
     {ABS_MT_PRESSURE, {0, 0, 255, 0, 0, 0}},
 };
 const DeviceCapabilities kLinkTouchscreen = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:02.0/i2c-2/2-004a/"
-               "input/input7/event7",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:02.0/i2c-2/2-004a/"
+    "input/input7/event7",
     /* name */ "Atmel maXTouch Touchscreen",
     /* phys */ "i2c-2-004a/input0",
     /* uniq */ "",
@@ -265,7 +266,7 @@
     /* led */ "0",
     /* ff */ "0",
     kLinkTouchscreenAbsAxes,
-    arraysize(kLinkTouchscreenAbsAxes),
+    base::size(kLinkTouchscreenAbsAxes),
 };
 
 // Fake Atmel touchscreen based on real device from Chromebook Pixel,
@@ -304,7 +305,7 @@
     /* led */ "0",
     /* ff */ "0",
     kLinkWithToolTypeTouchscreenAbsAxes,
-    arraysize(kLinkWithToolTypeTouchscreenAbsAxes),
+    base::size(kLinkWithToolTypeTouchscreenAbsAxes),
 };
 
 // Captured from Chromebook Pixel.
@@ -321,8 +322,9 @@
     {ABS_MT_PRESSURE, {0, 0, 255, 0, 0, 0}},
 };
 const DeviceCapabilities kLinkTouchpad = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:02.0/i2c-1/1-004b/"
-               "input/input8/event8",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:02.0/i2c-1/1-004b/"
+    "input/input8/event8",
     /* name */ "Atmel maXTouch Touchpad",
     /* phys */ "i2c-1-004b/input0",
     /* uniq */ "",
@@ -340,7 +342,7 @@
     /* led */ "0",
     /* ff */ "0",
     kLinkTouchpadAbsAxes,
-    arraysize(kLinkTouchpadAbsAxes),
+    base::size(kLinkTouchpadAbsAxes),
 };
 
 // Captured from generic HP KU-1156 USB keyboard.
@@ -371,8 +373,9 @@
     {ABS_VOLUME, {0, 0, 767, 0, 0, 0}},
 };
 const DeviceCapabilities kHpUsbKeyboard_Extra = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/"
-               "input/input18/event16",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.1/"
+    "input/input18/event16",
     /* name */ "Chicony HP Elite USB Keyboard",
     /* phys */ "usb-0000:00:1d.0-1.3/input1",
     /* uniq */ "",
@@ -382,8 +385,9 @@
     /* version */ "0110",
     /* prop */ "0",
     /* ev */ "1f",
-    /* key */ "3007f 0 0 483ffff17aff32d bf54444600000000 1 120f938b17c000 "
-              "677bfad941dfed 9ed68000004400 10000002",
+    /* key */
+    "3007f 0 0 483ffff17aff32d bf54444600000000 1 120f938b17c000 "
+    "677bfad941dfed 9ed68000004400 10000002",
     /* rel */ "40",
     /* abs */ "100000000",
     /* msc */ "10",
@@ -391,7 +395,7 @@
     /* led */ "0",
     /* ff */ "0",
     kHpUsbKeyboard_ExtraAbsAxes,
-    arraysize(kHpUsbKeyboard_ExtraAbsAxes),
+    base::size(kHpUsbKeyboard_ExtraAbsAxes),
 };
 
 // Captured from Dell MS111-L 3-Button Optical USB Mouse.
@@ -422,8 +426,9 @@
     {ABS_Y, {0, 0, 2047, 0, 0, 0}},
 };
 const DeviceCapabilities kMimoTouch2Touchscreen = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3.2/"
-               "2-1.3.2:1.0/input/input15/event14",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3.2/"
+    "2-1.3.2:1.0/input/input15/event14",
     /* name */ "eGalax Inc. USB TouchController",
     /* phys */ "usb-0000:00:1d.0-1.3.2/input0",
     /* uniq */ "",
@@ -441,7 +446,7 @@
     /* led */ "0",
     /* ff */ "0",
     kMimoTouch2TouchscreenAbsAxes,
-    arraysize(kMimoTouch2TouchscreenAbsAxes),
+    base::size(kMimoTouch2TouchscreenAbsAxes),
 };
 
 // Captured from Wacom Intuos Pen and Touch Small Tablet.
@@ -452,8 +457,9 @@
     {ABS_DISTANCE, {0, 0, 31, 0, 0, 0}},
 };
 const DeviceCapabilities kWacomIntuosPtS_Pen = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.3/"
-               "2-1.2.3:1.0/input/input9/event9",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.3/"
+    "2-1.2.3:1.0/input/input9/event9",
     /* name */ "Wacom Intuos PT S Pen",
     /* phys */ "",
     /* uniq */ "",
@@ -471,7 +477,7 @@
     /* led */ "0",
     /* ff */ "0",
     kWacomIntuosPtS_PenAbsAxes,
-    arraysize(kWacomIntuosPtS_PenAbsAxes),
+    base::size(kWacomIntuosPtS_PenAbsAxes),
 };
 
 // Captured from Wacom Intuos Pen and Touch Small Tablet.
@@ -486,8 +492,9 @@
     {ABS_MT_TRACKING_ID, {0, 0, 65535, 0, 0, 0}},
 };
 const DeviceCapabilities kWacomIntuosPtS_Finger = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.3/"
-               "2-1.2.3:1.1/input/input10/event10",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.3/"
+    "2-1.2.3:1.1/input/input10/event10",
     /* name */ "Wacom Intuos PT S Finger",
     /* phys */ "",
     /* uniq */ "",
@@ -505,7 +512,7 @@
     /* led */ "0",
     /* ff */ "0",
     kWacomIntuosPtS_FingerAbsAxes,
-    arraysize(kWacomIntuosPtS_FingerAbsAxes),
+    base::size(kWacomIntuosPtS_FingerAbsAxes),
 };
 
 // Captured from Logitech Wireless Touch Keyboard K400.
@@ -513,8 +520,9 @@
     {ABS_VOLUME, {0, 1, 652, 0, 0, 0}},
 };
 const DeviceCapabilities kLogitechTouchKeyboardK400 = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.3/"
-               "2-1.2.3:1.2/0003:046D:C52B.0006/input/input19/event17",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2.3/"
+    "2-1.2.3:1.2/0003:046D:C52B.0006/input/input19/event17",
     /* name */ "Logitech Unifying Device. Wireless PID:4024",
     /* phys */ "usb-0000:00:1d.0-1.2.3:1",
     /* uniq */ "",
@@ -524,9 +532,10 @@
     /* version */ "0111",
     /* prop */ "0",
     /* ev */ "12001f",
-    /* key */ "3007f 0 0 483ffff17aff32d bf54444600000000 ffff0001 "
-              "130f938b17c007 ffff7bfad9415fff febeffdfffefffff "
-              "fffffffffffffffe",
+    /* key */
+    "3007f 0 0 483ffff17aff32d bf54444600000000 ffff0001 "
+    "130f938b17c007 ffff7bfad9415fff febeffdfffefffff "
+    "fffffffffffffffe",
     /* rel */ "1c3",
     /* abs */ "100000000",
     /* msc */ "10",
@@ -534,7 +543,7 @@
     /* led */ "1f",
     /* ff */ "0",
     kLogitechTouchKeyboardK400AbsAxes,
-    arraysize(kLogitechTouchKeyboardK400AbsAxes),
+    base::size(kLogitechTouchKeyboardK400AbsAxes),
 };
 
 // Captured from Elo TouchSystems 2700 touchscreen.
@@ -544,10 +553,12 @@
     {ABS_MISC, {0, 0, 256, 0, 0, 0}},
 };
 const DeviceCapabilities kElo_TouchSystems_2700 = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/"
-               "input/input9/event9",
-    /* name */ "Elo TouchSystems, Inc. Elo TouchSystems 2700 IntelliTouch(r) "
-               "USB Touchmonitor Interface",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/"
+    "input/input9/event9",
+    /* name */
+    "Elo TouchSystems, Inc. Elo TouchSystems 2700 IntelliTouch(r) "
+    "USB Touchmonitor Interface",
     /* phys */ "usb-0000:00:1d.0-1.3/input0",
     /* uniq */ "20A01347",
     /* bustype */ "0003",
@@ -564,7 +575,7 @@
     /* led */ "0",
     /* ff */ "0",
     kElo_TouchSystems_2700AbsAxes,
-    arraysize(kElo_TouchSystems_2700AbsAxes),
+    base::size(kElo_TouchSystems_2700AbsAxes),
 };
 
 // Captured from Intel reference design: "Wilson Beach".
@@ -574,27 +585,28 @@
     {ABS_PRESSURE, {0, 0, 1024, 0, 0, 0}},
 };
 const DeviceCapabilities kWilsonBeachActiveStylus = {
-  /* path */ "/sys/devices/pci0000:00/INT3433:00/i2c-1/"
+    /* path */
+    "/sys/devices/pci0000:00/INT3433:00/i2c-1/"
     "i2c-NTRG0001:00/0018:1B96:0D03.0004/input/"
     "input11/event10",
-  /* name */ "NTRG0001:00 1B96:0D03 Pen",
-  /* phys */ "",
-  /* uniq */ "",
-  /* bustype */ "0018",
-  /* vendor */ "1b96",
-  /* product */ "0d03",
-  /* version */ "0100",
-  /* prop */ "0",
-  /* ev */ "1b",
-  /* key */ "c03 1 0 0 0 0",
-  /* rel */ "0",
-  /* abs */ "1000003",
-  /* msc */ "10",
-  /* sw */ "0",
-  /* led */ "0",
-  /* ff */ "0",
-  kWilsonBeachActiveStylusAbsAxes,
-  arraysize(kWilsonBeachActiveStylusAbsAxes),
+    /* name */ "NTRG0001:00 1B96:0D03 Pen",
+    /* phys */ "",
+    /* uniq */ "",
+    /* bustype */ "0018",
+    /* vendor */ "1b96",
+    /* product */ "0d03",
+    /* version */ "0100",
+    /* prop */ "0",
+    /* ev */ "1b",
+    /* key */ "c03 1 0 0 0 0",
+    /* rel */ "0",
+    /* abs */ "1000003",
+    /* msc */ "10",
+    /* sw */ "0",
+    /* led */ "0",
+    /* ff */ "0",
+    kWilsonBeachActiveStylusAbsAxes,
+    base::size(kWilsonBeachActiveStylusAbsAxes),
 };
 
 // Captured from Eve Chromebook
@@ -624,7 +636,7 @@
     /* led */ "0",
     /* ff */ "0",
     kEveStylusAbsAxes,
-    arraysize(kEveStylusAbsAxes),
+    base::size(kEveStylusAbsAxes),
 };
 
 const DeviceCapabilities kHammerKeyboard = {
@@ -685,7 +697,7 @@
     /* led */ "0",
     /* ff */ "0",
     kHammerTouchpadAbsAxes,
-    arraysize(kHammerTouchpadAbsAxes),
+    base::size(kHammerTouchpadAbsAxes),
 };
 
 // NB: Please use the capture_device_capabilities.py script to add more
diff --git a/ui/events/ozone/evdev/gamepad_event_converter_evdev_unittest.cc b/ui/events/ozone/evdev/gamepad_event_converter_evdev_unittest.cc
index 3cb9f5d..787848f 100644
--- a/ui/events/ozone/evdev/gamepad_event_converter_evdev_unittest.cc
+++ b/ui/events/ozone/evdev/gamepad_event_converter_evdev_unittest.cc
@@ -17,9 +17,9 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_file.h"
-#include "base/macros.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -169,7 +169,7 @@
       {GamepadEventType::BUTTON, 1, 0},      {GamepadEventType::FRAME, 0, 0},
       {GamepadEventType::BUTTON, 2, 1},      {GamepadEventType::FRAME, 0, 0}};
 
-  for (unsigned i = 0; i < arraysize(mock_kernel_queue); ++i) {
+  for (unsigned i = 0; i < base::size(mock_kernel_queue); ++i) {
     dev->ProcessEvent(mock_kernel_queue[i]);
   }
 
@@ -306,7 +306,7 @@
       {GamepadEventType::BUTTON, 12, 0}, {GamepadEventType::FRAME, 0, 0},
       {GamepadEventType::BUTTON, 13, 1}, {GamepadEventType::FRAME, 0, 0}};
 
-  for (unsigned i = 0; i < arraysize(mock_kernel_queue); ++i) {
+  for (unsigned i = 0; i < base::size(mock_kernel_queue); ++i) {
     dev->ProcessEvent(mock_kernel_queue[i]);
   }
 
diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc b/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
index f7597bb4..bbfdf552 100644
--- a/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
+++ b/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
@@ -8,7 +8,7 @@
 #include <libevdev/libevdev.h>
 #include <linux/input.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/timer/timer.h"
 #include "ui/events/base_event_utils.h"
@@ -462,7 +462,7 @@
   unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)];
 
   // Find changed keys.
-  for (unsigned long i = 0; i < arraysize(key_state_diff); ++i)
+  for (unsigned long i = 0; i < base::size(key_state_diff); ++i)
     key_state_diff[i] = new_key_state[i] ^ prev_key_state_[i];
 
   // Dispatch events for changed keys.
diff --git a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc
index d925222..bc8fd80 100644
--- a/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc
+++ b/ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.cc
@@ -17,8 +17,8 @@
 #include "base/files/file_enumerator.h"
 #include "base/files/file_util.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_tokenizer.h"
@@ -487,10 +487,10 @@
 // Check if a match criteria is currently implemented. Note that we didn't
 // implemented all of them as some are inapplicable in the non-X world.
 bool IsMatchTypeSupported(const std::string& match_type) {
-  for (size_t i = 0; i < arraysize(kSupportedMatchTypes); ++i)
+  for (size_t i = 0; i < base::size(kSupportedMatchTypes); ++i)
     if (match_type == kSupportedMatchTypes[i])
       return true;
-  for (size_t i = 0; i < arraysize(kUnsupportedMatchTypes); ++i) {
+  for (size_t i = 0; i < base::size(kUnsupportedMatchTypes); ++i) {
     if (match_type == kUnsupportedMatchTypes[i]) {
       LOG(ERROR) << "Unsupported gestures input class match type: "
                  << match_type;
@@ -507,11 +507,11 @@
 
 // Parse a boolean value keyword (e.g., on/off, true/false).
 int ParseBooleanKeyword(const std::string& value) {
-  for (size_t i = 0; i < arraysize(kTrue); ++i) {
+  for (size_t i = 0; i < base::size(kTrue); ++i) {
     if (base::LowerCaseEqualsASCII(value, kTrue[i]))
       return 1;
   }
-  for (size_t i = 0; i < arraysize(kFalse); ++i) {
+  for (size_t i = 0; i < base::size(kFalse); ++i) {
     if (base::LowerCaseEqualsASCII(value, kFalse[i]))
       return -1;
   }
diff --git a/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc b/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc
index 9018791e..e3cc487 100644
--- a/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc
+++ b/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc
@@ -16,10 +16,10 @@
 #include "base/bind.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_file.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/event.h"
@@ -51,8 +51,9 @@
 };
 
 const ui::DeviceCapabilities kWacomIntuos5SPen = {
-    /* path */ "/sys/devices/pci0000:00/0000:00:14.0/usb1/"
-               "1-1/1-1:1.0/input/input19/event5",
+    /* path */
+    "/sys/devices/pci0000:00/0000:00:14.0/usb1/"
+    "1-1/1-1:1.0/input/input19/event5",
     /* name */ "Wacom Intuos5 touch S Pen",
     /* phys */ "",
     /* uniq */ "",
@@ -70,10 +71,9 @@
     /* led */ "0",
     /* ff */ "0",
     kWacomIntuos5SPenAbsAxes,
-    arraysize(kWacomIntuos5SPenAbsAxes),
+    base::size(kWacomIntuos5SPenAbsAxes),
 };
 
-
 const ui::DeviceAbsoluteAxis EpsonBrightLink1430AbsAxes[] = {
     {ABS_X, {0, 0, 32767, 0, 0, 200}},
     {ABS_Y, {0, 0, 32767, 0, 0, 200}},
@@ -83,9 +83,10 @@
 };
 
 const ui::DeviceCapabilities EpsonBrightLink1430 = {
-    /* path */ "/sys/devices/ff580000.usb/usb3/3-1/"
-               "3-1.1/3-1.1.3/3-1.1.3:1.1/0003:04B8:061B.0006/"
-               "input/input12/event6",
+    /* path */
+    "/sys/devices/ff580000.usb/usb3/3-1/"
+    "3-1.1/3-1.1.3/3-1.1.3:1.1/0003:04B8:061B.0006/"
+    "input/input12/event6",
     /* name */ "EPSON EPSON EPSON 1430",
     /* phys */ "USB-ff580000.USB-1.1.3/input1",
     /* uniq */ "2.04",
@@ -103,7 +104,7 @@
     /* led */ "0",
     /* ff */ "0",
     EpsonBrightLink1430AbsAxes,
-    arraysize(EpsonBrightLink1430AbsAxes),
+    base::size(EpsonBrightLink1430AbsAxes),
 };
 
 }  // namespace
@@ -295,7 +296,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
@@ -329,7 +330,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
@@ -364,7 +365,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
@@ -400,7 +401,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(1u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
@@ -451,7 +452,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(3u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
@@ -513,7 +514,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(3u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
@@ -537,7 +538,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(0u, size());
 }
 
@@ -584,7 +585,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
+  dev->ProcessEvents(mock_kernel_queue, base::size(mock_kernel_queue));
   EXPECT_EQ(3u, size());
 
   ui::MouseEvent* event = dispatched_event(0);
diff --git a/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc b/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
index 3a59c13e2..4b04146 100644
--- a/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
+++ b/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
@@ -16,10 +16,10 @@
 #include "base/command_line.h"
 #include "base/files/file_util.h"
 #include "base/files/scoped_file.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/posix/eintr_wrapper.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/devices/device_data_manager.h"
@@ -345,7 +345,7 @@
 
   // Press.
   dev->ConfigureReadMock(mock_kernel_queue_press,
-                         arraysize(mock_kernel_queue_press), 0);
+                         base::size(mock_kernel_queue_press), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
   ui::TouchEventParams event = dispatched_touch_event(0);
@@ -361,7 +361,7 @@
 
   // Move.
   dev->ConfigureReadMock(mock_kernel_queue_move,
-                         arraysize(mock_kernel_queue_move), 0);
+                         base::size(mock_kernel_queue_move), 0);
   dev->ReadNow();
   EXPECT_EQ(2u, size());
   event = dispatched_touch_event(1);
@@ -377,7 +377,7 @@
 
   // Release.
   dev->ConfigureReadMock(mock_kernel_queue_release,
-                         arraysize(mock_kernel_queue_release), 0);
+                         base::size(mock_kernel_queue_release), 0);
   dev->ReadNow();
   EXPECT_EQ(3u, size());
   event = dispatched_touch_event(2);
@@ -583,7 +583,7 @@
   };
 
   dev->ConfigureReadMock(mock_kernel_queue_empty_report,
-                         arraysize(mock_kernel_queue_empty_report), 0);
+                         base::size(mock_kernel_queue_empty_report), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
 
@@ -620,7 +620,7 @@
   SetTestNowTime(time);
 
   dev->ConfigureReadMock(mock_kernel_queue_press,
-                         arraysize(mock_kernel_queue_press), 0);
+                         base::size(mock_kernel_queue_press), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
 
@@ -665,7 +665,7 @@
   dev->Initialize(devinfo);
 
   dev->ConfigureReadMock(mock_kernel_queue_press,
-                         arraysize(mock_kernel_queue_press), 0);
+                         base::size(mock_kernel_queue_press), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
 
@@ -697,7 +697,7 @@
 
   // Send updates to touch (touch is cancelled, should not come back)
   dev->ConfigureReadMock(mock_kernel_queue_press,
-                         arraysize(mock_kernel_queue_press), 0);
+                         base::size(mock_kernel_queue_press), 0);
   dev->ReadNow();
   EXPECT_EQ(2u, size());
 }
@@ -773,7 +773,7 @@
   dev->Initialize(devinfo);
 
   dev->ConfigureReadMock(mock_kernel_queue_max_major,
-                         arraysize(mock_kernel_queue_max_major), 0);
+                         base::size(mock_kernel_queue_max_major), 0);
   dev->ReadNow();
   EXPECT_EQ(4u, size());
 
@@ -800,7 +800,7 @@
   EXPECT_EQ(1, ev1_4.slot);
 
   dev->ConfigureReadMock(mock_kernel_queue_tool_palm,
-                         arraysize(mock_kernel_queue_tool_palm), 0);
+                         base::size(mock_kernel_queue_tool_palm), 0);
   dev->ReadNow();
   EXPECT_EQ(8u, size());
 
@@ -934,7 +934,7 @@
   dev->Initialize(devinfo);
 
   dev->ConfigureReadMock(mock_kernel_queue_max_major,
-                         arraysize(mock_kernel_queue_max_major), 0);
+                         base::size(mock_kernel_queue_max_major), 0);
   dev->ReadNow();
   EXPECT_EQ(4u, size());
 
@@ -961,12 +961,13 @@
   EXPECT_EQ(1, ev1_4.slot);
 
   dev->ConfigureReadMock(mock_kernel_new_touch_without_new_major,
-                         arraysize(mock_kernel_new_touch_without_new_major), 0);
+                         base::size(mock_kernel_new_touch_without_new_major),
+                         0);
   dev->ReadNow();
   EXPECT_EQ(4u, size());
 
   dev->ConfigureReadMock(mock_kernel_queue_tool_palm,
-                         arraysize(mock_kernel_queue_tool_palm), 0);
+                         base::size(mock_kernel_queue_tool_palm), 0);
   dev->ReadNow();
   EXPECT_EQ(8u, size());
 
@@ -1034,7 +1035,7 @@
 
   // Press.
   dev->ConfigureReadMock(mock_kernel_queue_press,
-                         arraysize(mock_kernel_queue_press), 0);
+                         base::size(mock_kernel_queue_press), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
   ui::TouchEventParams event = dispatched_touch_event(0);
@@ -1048,7 +1049,7 @@
 
   // Move.
   dev->ConfigureReadMock(mock_kernel_queue_move,
-                         arraysize(mock_kernel_queue_move), 0);
+                         base::size(mock_kernel_queue_move), 0);
   dev->ReadNow();
   EXPECT_EQ(2u, size());
   event = dispatched_touch_event(1);
@@ -1062,7 +1063,7 @@
 
   // Release.
   dev->ConfigureReadMock(mock_kernel_queue_release,
-                         arraysize(mock_kernel_queue_release), 0);
+                         base::size(mock_kernel_queue_release), 0);
   dev->ReadNow();
   EXPECT_EQ(3u, size());
   event = dispatched_touch_event(2);
@@ -1104,7 +1105,7 @@
   };
 
   // Check that two events are generated.
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
 
   const unsigned int kExpectedEventCount = 2;
@@ -1145,7 +1146,7 @@
   };
 
   // Check that one 1 event is generated
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
 }
@@ -1251,14 +1252,14 @@
   MockTouchEventConverterEvdev* dev = device();
   SetTouchNoiseFilter(std::unique_ptr<TouchFilter>(
       new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED)));
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   ASSERT_EQ(0u, size());
 
   ClearDispatchedEvents();
   SetTouchNoiseFilter(std::unique_ptr<TouchFilter>(
       new EventTypeTouchNoiseFilter(ET_TOUCH_MOVED)));
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   ASSERT_EQ(2u, size());
   TouchEventParams event0 = dispatched_touch_event(0);
@@ -1270,7 +1271,7 @@
   ClearDispatchedEvents();
   SetTouchNoiseFilter(std::unique_ptr<TouchFilter>(
       new EventTypeTouchNoiseFilter(ET_TOUCH_RELEASED)));
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   ASSERT_EQ(3u, size());
   event0 = dispatched_touch_event(0);
@@ -1309,7 +1310,7 @@
   MockTouchEventConverterEvdev* dev = device();
   SetTouchNoiseFilter(std::unique_ptr<TouchFilter>(
       new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED)));
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   ASSERT_EQ(0u, size());
 
@@ -1343,7 +1344,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   EXPECT_EQ(2u, size());
 
@@ -1393,7 +1394,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   EXPECT_EQ(4u, size());
 
@@ -1462,7 +1463,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   EXPECT_EQ(2u, size());
 
@@ -1511,7 +1512,7 @@
       {{0, 0}, EV_SYN, SYN_REPORT, 0},
   };
 
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   EXPECT_EQ(4u, size());
 
@@ -1569,7 +1570,7 @@
   SetTestNowTime(time);
 
   // Finger pressed with major/minor reported.
-  dev->ConfigureReadMock(mock_kernel_queue, arraysize(mock_kernel_queue), 0);
+  dev->ConfigureReadMock(mock_kernel_queue, base::size(mock_kernel_queue), 0);
   dev->ReadNow();
   EXPECT_EQ(1u, size());
   ui::TouchEventParams event = dispatched_touch_event(0);
diff --git a/ui/events/ozone/evdev/touch_filter/false_touch_finder_unittest.cc b/ui/events/ozone/evdev/touch_filter/false_touch_finder_unittest.cc
index e0df4ec..8c9fec6 100644
--- a/ui/events/ozone/evdev/touch_filter/false_touch_finder_unittest.cc
+++ b/ui/events/ozone/evdev/touch_filter/false_touch_finder_unittest.cc
@@ -11,7 +11,7 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/event_switches.h"
@@ -110,7 +110,7 @@
       {50, 1, true, gfx::PointF(10, 14), 0.35, true, false},
       {50, 2, false, gfx::PointF(2500, 1002), 0.35, true, false},
       {60, 1, false, gfx::PointF(10, 15), 0.35, true, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that taps which are far apart but do not occur in quick succession are
@@ -125,7 +125,7 @@
       {3000, 1, true, gfx::PointF(10, 14), 0.35, false, false},
       {3000, 2, false, gfx::PointF(2500, 1001), 0.35, false, false},
       {3500, 1, false, gfx::PointF(10, 15), 0.35, false, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that touches which are horizontally aligned are considered noise.
@@ -137,7 +137,7 @@
       {30, 1, false, gfx::PointF(10, 10), 0.35, false, false},
       {30, 2, true, gfx::PointF(10, 25), 0.35, true, false},
       {40, 2, false, gfx::PointF(10, 25), 0.35, true, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that touches in the same position are considered noise.
@@ -154,7 +154,7 @@
       {4000, 2, false, gfx::PointF(10, 10), 0.35, true, false},
       {4500, 1, true, gfx::PointF(10, 10), 0.35, true, false},
       {5000, 1, false, gfx::PointF(10, 10), 0.35, true, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that a multi-second touch is considered noise.
@@ -166,7 +166,7 @@
       {4000, 1, true, gfx::PointF(10, 11), 0.35, true, false},
       {5000, 1, true, gfx::PointF(10, 10), 0.35, true, false},
       {6000, 1, true, gfx::PointF(10, 11), 0.35, true, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that a touch on the edge which never leaves is delayed and never
@@ -187,7 +187,7 @@
       {100, 4, true, gfx::PointF(100, ts_height - 1), 0.35, false, true},
       {110, 4, true, gfx::PointF(100, ts_height - 1), 0.35, false, true},
       {120, 4, false, gfx::PointF(100, ts_height - 1), 0.35, false, true}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that a touch on the edge which starts at an edge is delayed but released
@@ -202,7 +202,7 @@
       {60, 1, true, gfx::PointF(0, 100), 0.35, false, true},
       {70, 1, true, gfx::PointF(0, 101), 0.35, false, false},
       {80, 1, false, gfx::PointF(0, 101), 0.35, false, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that a touch on the edge which starts away from the edge is not
@@ -213,7 +213,7 @@
       {20, 1, true, gfx::PointF(100, 100), 0.35, false, false},
       {30, 1, true, gfx::PointF(0, 100), 0.35, false, false},
       {40, 1, false, gfx::PointF(0, 100), 0.35, false, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that a pencil with a wide tip should be filtered out. Based on real
@@ -225,7 +225,7 @@
       {30, 1, true, gfx::PointF(10, 10), 0.180392, false, true},
       {40, 1, true, gfx::PointF(10, 10), 0.164706, false, true},
       {50, 1, true, gfx::PointF(10, 10), 0.101961, false, true}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 // Test that a pinky finger lightly pressed is not filtered out. Based on real
@@ -237,7 +237,7 @@
       {30, 1, true, gfx::PointF(10, 10), 0.215686, false, false},
       {40, 1, true, gfx::PointF(10, 10), 0.211765, false, false},
       {50, 1, true, gfx::PointF(10, 10), 0.203922, false, false}};
-  EXPECT_TRUE(FilterAndCheck(kTestData, arraysize(kTestData)));
+  EXPECT_TRUE(FilterAndCheck(kTestData, base::size(kTestData)));
 }
 
 }  // namespace ui
diff --git a/ui/events/ozone/evdev/touch_filter/far_apart_taps_touch_noise_filter.cc b/ui/events/ozone/evdev/touch_filter/far_apart_taps_touch_noise_filter.cc
index 6e8b0752..9078fbde 100644
--- a/ui/events/ozone/evdev/touch_filter/far_apart_taps_touch_noise_filter.cc
+++ b/ui/events/ozone/evdev/touch_filter/far_apart_taps_touch_noise_filter.cc
@@ -9,8 +9,8 @@
 #include <cmath>
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 
 namespace ui {
@@ -48,7 +48,7 @@
   // Remove old taps.
   base::TimeTicks tap_cutoff =
       time - base::TimeDelta::FromMilliseconds(kMaxTapDeltaMs);
-  for (size_t i = 0; i < arraysize(tracked_taps_); ++i) {
+  for (size_t i = 0; i < base::size(tracked_taps_); ++i) {
     if (tracked_taps_[i].start < tap_cutoff)
       tracked_taps_[i].Invalidate();
   }
@@ -73,7 +73,7 @@
     if (tracked_taps_[slot].is_valid()) {
       // Check distance from other tracked taps.
       int min_distance2 = -1;
-      for (size_t i = 0; i < arraysize(tracked_taps_); ++i) {
+      for (size_t i = 0; i < base::size(tracked_taps_); ++i) {
         if (i == slot || !tracked_taps_[i].is_valid())
           continue;
 
diff --git a/ui/events/ozone/gamepad/static_gamepad_mapping.cc b/ui/events/ozone/gamepad/static_gamepad_mapping.cc
index 79f699a..6cf8dcca 100644
--- a/ui/events/ozone/gamepad/static_gamepad_mapping.cc
+++ b/ui/events/ozone/gamepad/static_gamepad_mapping.cc
@@ -8,7 +8,7 @@
 #include <map>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/events/ozone/evdev/event_device_info.h"
 #include "ui/events/ozone/gamepad/static_gamepad_mapping.h"
 #include "ui/events/ozone/gamepad/webgamepad_constants.h"
@@ -20,9 +20,9 @@
                                       GamepadEventType* mapped_type,
                                       uint16_t* mapped_code);
 
-#define DO_MAPPING                                                   \
-  DoGamepadMapping(key_mapping, arraysize(key_mapping), abs_mapping, \
-                   arraysize(abs_mapping), type, code, mapped_type,  \
+#define DO_MAPPING                                                    \
+  DoGamepadMapping(key_mapping, base::size(key_mapping), abs_mapping, \
+                   base::size(abs_mapping), type, code, mapped_type,  \
                    mapped_code)
 
 bool DoGamepadMapping(const KeyMapEntry* key_mapping,
@@ -523,7 +523,7 @@
 };
 
 GamepadMapper* GetStaticGamepadMapper(uint16_t vendor_id, uint16_t product_id) {
-  for (size_t i = 0; i < arraysize(AvailableMappings); i++) {
+  for (size_t i = 0; i < base::size(AvailableMappings); i++) {
     if (AvailableMappings[i].vendor_id == vendor_id &&
         AvailableMappings[i].product_id == product_id) {
       return new StaticGamepadMapper(AvailableMappings[i].mapper);
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
index afeec925..d8185a02 100644
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
@@ -12,9 +12,9 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/free_deleter.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/task/post_task.h"
 #include "base/task_runner.h"
 #include "base/threading/thread_task_runner_handle.h"
@@ -487,64 +487,64 @@
 
 // Entries are ordered by character value.
 const PrintableMultiEntry kMultiMap[] = {
-    {0x0021, kU0021, arraysize(kU0021)},  // exclamation mark
-    {0x0022, kU0022, arraysize(kU0022)},  // quotation mark
-    {0x0023, kU0023, arraysize(kU0023)},  // number sign
-    {0x0024, kU0024, arraysize(kU0024)},  // dollar sign
-    {0x0027, kU0027, arraysize(kU0027)},  // apostrophe
-    {0x0028, kU0028, arraysize(kU0028)},  // left parenthesis
-    {0x0029, kU0029, arraysize(kU0029)},  // right parenthesis
-    {0x002A, kU002A, arraysize(kU002A)},  // asterisk
-    {0x002B, kU002B, arraysize(kU002B)},  // plus sign
-    {0x002C, kU002C, arraysize(kU002C)},  // comma
-    {0x002D, kU002D, arraysize(kU002D)},  // hyphen-minus
-    {0x002E, kU002E, arraysize(kU002E)},  // full stop
-    {0x002F, kU002F, arraysize(kU002F)},  // solidus
-    {0x003A, kU003A, arraysize(kU003A)},  // colon
-    {0x003B, kU003B, arraysize(kU003B)},  // semicolon
-    {0x003D, kU003D, arraysize(kU003D)},  // equals sign
-    {0x003F, kU003F, arraysize(kU003F)},  // question mark
-    {0x0040, kU0040, arraysize(kU0040)},  // commercial at
-    {0x005B, kU005B, arraysize(kU005B)},  // left square bracket
-    {0x005C, kU005C, arraysize(kU005C)},  // reverse solidus
-    {0x005D, kU005D, arraysize(kU005D)},  // right square bracket
-    {0x005F, kU005F, arraysize(kU005F)},  // low line
-    {0x0060, kU0060, arraysize(kU0060)},  // grave accent
-    {0x00A7, kU00A7, arraysize(kU00A7)},  // section sign
-    {0x00AB, kU00AB, arraysize(kU00AB)},  // left double angle quotation mark
-    {0x00B0, kU00B0, arraysize(kU00B0)},  // degree sign
-    {0x00BA, kU00BA, arraysize(kU00BA)},  // masculine ordinal indicator
-    {0x00E0, kU00E0, arraysize(kU00E0)},  // a grave
-    {0x00E1, kU00E1, arraysize(kU00E1)},  // a acute
-    {0x00E2, kU00E2, arraysize(kU00E2)},  // a circumflex
-    {0x00E4, kU00E4, arraysize(kU00E4)},  // a diaeresis
-    {0x00E6, kU00E6, arraysize(kU00E6)},  // ae
-    {0x00E7, kU00E7, arraysize(kU00E7)},  // c cedilla
-    {0x00E8, kU00E8, arraysize(kU00E8)},  // e grave
-    {0x00E9, kU00E9, arraysize(kU00E9)},  // e acute
-    {0x00ED, kU00ED, arraysize(kU00ED)},  // i acute
-    {0x00F0, kU00F0, arraysize(kU00F0)},  // eth
-    {0x00F3, kU00F3, arraysize(kU00F3)},  // o acute
-    {0x00F4, kU00F4, arraysize(kU00F4)},  // o circumflex
-    {0x00F6, kU00F6, arraysize(kU00F6)},  // o diaeresis
-    {0x00F8, kU00F8, arraysize(kU00F8)},  // o stroke
-    {0x00F9, kU00F9, arraysize(kU00F9)},  // u grave
-    {0x00FA, kU00FA, arraysize(kU00FA)},  // u acute
-    {0x00FC, kU00FC, arraysize(kU00FC)},  // u diaeresis
-    {0x0103, kU0103, arraysize(kU0103)},  // a breve
-    {0x0105, kU0105, arraysize(kU0105)},  // a ogonek
-    {0x010D, kU010D, arraysize(kU010D)},  // c caron
-    {0x0111, kU0111, arraysize(kU0111)},  // d stroke
-    {0x0117, kU0117, arraysize(kU0117)},  // e dot above
-    {0x0119, kU0119, arraysize(kU0119)},  // e ogonek
-    {0x012F, kU012F, arraysize(kU012F)},  // i ogonek
-    {0x0142, kU0142, arraysize(kU0142)},  // l stroke
-    {0x015F, kU015F, arraysize(kU015F)},  // s cedilla
-    {0x0161, kU0161, arraysize(kU0161)},  // s caron
-    {0x016B, kU016B, arraysize(kU016B)},  // u macron
-    {0x0173, kU0173, arraysize(kU0173)},  // u ogonek
-    {0x017C, kU017C, arraysize(kU017C)},  // z dot above
-    {0x017E, kU017E, arraysize(kU017E)},  // z caron
+    {0x0021, kU0021, base::size(kU0021)},  // exclamation mark
+    {0x0022, kU0022, base::size(kU0022)},  // quotation mark
+    {0x0023, kU0023, base::size(kU0023)},  // number sign
+    {0x0024, kU0024, base::size(kU0024)},  // dollar sign
+    {0x0027, kU0027, base::size(kU0027)},  // apostrophe
+    {0x0028, kU0028, base::size(kU0028)},  // left parenthesis
+    {0x0029, kU0029, base::size(kU0029)},  // right parenthesis
+    {0x002A, kU002A, base::size(kU002A)},  // asterisk
+    {0x002B, kU002B, base::size(kU002B)},  // plus sign
+    {0x002C, kU002C, base::size(kU002C)},  // comma
+    {0x002D, kU002D, base::size(kU002D)},  // hyphen-minus
+    {0x002E, kU002E, base::size(kU002E)},  // full stop
+    {0x002F, kU002F, base::size(kU002F)},  // solidus
+    {0x003A, kU003A, base::size(kU003A)},  // colon
+    {0x003B, kU003B, base::size(kU003B)},  // semicolon
+    {0x003D, kU003D, base::size(kU003D)},  // equals sign
+    {0x003F, kU003F, base::size(kU003F)},  // question mark
+    {0x0040, kU0040, base::size(kU0040)},  // commercial at
+    {0x005B, kU005B, base::size(kU005B)},  // left square bracket
+    {0x005C, kU005C, base::size(kU005C)},  // reverse solidus
+    {0x005D, kU005D, base::size(kU005D)},  // right square bracket
+    {0x005F, kU005F, base::size(kU005F)},  // low line
+    {0x0060, kU0060, base::size(kU0060)},  // grave accent
+    {0x00A7, kU00A7, base::size(kU00A7)},  // section sign
+    {0x00AB, kU00AB, base::size(kU00AB)},  // left double angle quotation mark
+    {0x00B0, kU00B0, base::size(kU00B0)},  // degree sign
+    {0x00BA, kU00BA, base::size(kU00BA)},  // masculine ordinal indicator
+    {0x00E0, kU00E0, base::size(kU00E0)},  // a grave
+    {0x00E1, kU00E1, base::size(kU00E1)},  // a acute
+    {0x00E2, kU00E2, base::size(kU00E2)},  // a circumflex
+    {0x00E4, kU00E4, base::size(kU00E4)},  // a diaeresis
+    {0x00E6, kU00E6, base::size(kU00E6)},  // ae
+    {0x00E7, kU00E7, base::size(kU00E7)},  // c cedilla
+    {0x00E8, kU00E8, base::size(kU00E8)},  // e grave
+    {0x00E9, kU00E9, base::size(kU00E9)},  // e acute
+    {0x00ED, kU00ED, base::size(kU00ED)},  // i acute
+    {0x00F0, kU00F0, base::size(kU00F0)},  // eth
+    {0x00F3, kU00F3, base::size(kU00F3)},  // o acute
+    {0x00F4, kU00F4, base::size(kU00F4)},  // o circumflex
+    {0x00F6, kU00F6, base::size(kU00F6)},  // o diaeresis
+    {0x00F8, kU00F8, base::size(kU00F8)},  // o stroke
+    {0x00F9, kU00F9, base::size(kU00F9)},  // u grave
+    {0x00FA, kU00FA, base::size(kU00FA)},  // u acute
+    {0x00FC, kU00FC, base::size(kU00FC)},  // u diaeresis
+    {0x0103, kU0103, base::size(kU0103)},  // a breve
+    {0x0105, kU0105, base::size(kU0105)},  // a ogonek
+    {0x010D, kU010D, base::size(kU010D)},  // c caron
+    {0x0111, kU0111, base::size(kU0111)},  // d stroke
+    {0x0117, kU0117, base::size(kU0117)},  // e dot above
+    {0x0119, kU0119, base::size(kU0119)},  // e ogonek
+    {0x012F, kU012F, base::size(kU012F)},  // i ogonek
+    {0x0142, kU0142, base::size(kU0142)},  // l stroke
+    {0x015F, kU015F, base::size(kU015F)},  // s cedilla
+    {0x0161, kU0161, base::size(kU0161)},  // s caron
+    {0x016B, kU016B, base::size(kU016B)},  // u macron
+    {0x0173, kU0173, base::size(kU0173)},  // u ogonek
+    {0x017C, kU017C, base::size(kU017C)},  // z dot above
+    {0x017E, kU017E, base::size(kU017E)},  // z caron
 };
 
 // Table mapping unshifted characters to VKEY values.
@@ -825,8 +825,8 @@
                {ui::EF_MOD3_DOWN, "Mod3"},
                {ui::EF_CAPS_LOCK_ON, XKB_MOD_NAME_CAPS}};
   xkb_flag_map_.clear();
-  xkb_flag_map_.reserve(arraysize(flags));
-  for (size_t i = 0; i < arraysize(flags); ++i) {
+  xkb_flag_map_.reserve(base::size(flags));
+  for (size_t i = 0; i < base::size(flags); ++i) {
     xkb_mod_index_t index = xkb_keymap_mod_get_index(keymap, flags[i].xkb_name);
     if (index == XKB_MOD_INVALID) {
       DVLOG(3) << "XKB keyboard layout does not contain " << flags[i].xkb_name;
@@ -898,7 +898,7 @@
     return key_code;
 
   // Check the multi-character tables.
-  const PrintableMultiEntry* multi_end = kMultiMap + arraysize(kMultiMap);
+  const PrintableMultiEntry* multi_end = kMultiMap + base::size(kMultiMap);
   const PrintableMultiEntry* multi =
       std::lower_bound(kMultiMap, multi_end, plain_character,
                        [](const PrintableMultiEntry& e, base::char16 c) {
@@ -932,7 +932,7 @@
   }
 
   // Check the simple character table.
-  const PrintableSimpleEntry* simple_end = kSimpleMap + arraysize(kSimpleMap);
+  const PrintableSimpleEntry* simple_end = kSimpleMap + base::size(kSimpleMap);
   const PrintableSimpleEntry* simple =
       std::lower_bound(kSimpleMap, simple_end, plain_character,
                        [](const PrintableSimpleEntry& e, base::char16 c) {
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc
index 0830460..9f6f20d6 100644
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/event_constants.h"
 #include "ui/events/keycodes/dom/dom_code.h"
@@ -65,8 +65,8 @@
     static const int kTestFlags[] = {EF_SHIFT_DOWN, EF_ALTGR_DOWN,
                                      EF_MOD3_DOWN};
     xkb_flag_map_.clear();
-    xkb_flag_map_.resize(arraysize(kTestFlags));
-    for (size_t i = 0; i < arraysize(kTestFlags); ++i) {
+    xkb_flag_map_.resize(base::size(kTestFlags));
+    for (size_t i = 0; i < base::size(kTestFlags); ++i) {
       XkbFlagMapEntry e = {kTestFlags[i], kTestFlags[i]};
       xkb_flag_map_.push_back(e);
     }
@@ -767,7 +767,7 @@
       /* 296 */ {{'0', ')', '-', DomCode::NONE}, VKEY_0},
   };
 
-  for (size_t i = 0; i < arraysize(kVkeyTestCase); ++i) {
+  for (size_t i = 0; i < base::size(kVkeyTestCase); ++i) {
     SCOPED_TRACE(i);
     const auto& e = kVkeyTestCase[i];
     layout_engine_->SetEntry(&e.test);
@@ -896,7 +896,7 @@
       /* 50 */ {"ge", "ge", ""},
       /* 51 */ {"mn", "mn", ""},
       /* 52 */ {"ie", "ie", ""}};
-  for (size_t i = 0; i < arraysize(kVkeyTestCase); ++i) {
+  for (size_t i = 0; i < base::size(kVkeyTestCase); ++i) {
     SCOPED_TRACE(i);
     const VkTestXkbKeyboardLayoutEngine::RuleNames* e = &kVkeyTestCase[i];
     std::string layout_id;
diff --git a/ui/events/platform/platform_event_source_unittest.cc b/ui/events/platform/platform_event_source_unittest.cc
index d9a069e..8dba043b 100644
--- a/ui/events/platform/platform_event_source_unittest.cc
+++ b/ui/events/platform/platform_event_source_unittest.cc
@@ -12,10 +12,10 @@
 #include <vector>
 
 #include "base/bind.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/platform/platform_event_dispatcher.h"
@@ -185,8 +185,8 @@
   }
   std::unique_ptr<PlatformEvent> event = CreatePlatformEvent();
   source()->Dispatch(*event);
-  ASSERT_EQ(arraysize(sequence), list_dispatcher.size());
-  EXPECT_EQ(std::vector<int>(sequence, sequence + arraysize(sequence)),
+  ASSERT_EQ(base::size(sequence), list_dispatcher.size());
+  EXPECT_EQ(std::vector<int>(sequence, sequence + base::size(sequence)),
             list_dispatcher);
 }
 
@@ -243,8 +243,8 @@
   }
   std::unique_ptr<PlatformEvent> event = CreatePlatformEvent();
   source()->Dispatch(*event);
-  ASSERT_EQ(arraysize(sequence), list_observer.size());
-  EXPECT_EQ(std::vector<int>(sequence, sequence + arraysize(sequence)),
+  ASSERT_EQ(base::size(sequence), list_observer.size());
+  EXPECT_EQ(std::vector<int>(sequence, sequence + base::size(sequence)),
             list_observer);
 }
 
@@ -258,7 +258,7 @@
   std::unique_ptr<PlatformEvent> event = CreatePlatformEvent();
   source()->Dispatch(*event);
   const int expected[] = {10, 20, 12, 23};
-  EXPECT_EQ(std::vector<int>(expected, expected + arraysize(expected)), list);
+  EXPECT_EQ(std::vector<int>(expected, expected + base::size(expected)), list);
 }
 
 // Tests that an overridden dispatcher receives events before the default
diff --git a/ui/events/test/events_test_utils_x11.cc b/ui/events/test/events_test_utils_x11.cc
index d2eee56..6ffd37c4 100644
--- a/ui/events/test/events_test_utils_x11.cc
+++ b/ui/events/test/events_test_utils_x11.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/events/devices/x11/touch_factory_x11.h"
 #include "ui/events/event_constants.h"
 #include "ui/events/event_utils.h"
@@ -248,7 +248,7 @@
     Valuator(DeviceDataManagerX11::DT_CMT_FINGER_COUNT, finger_count)
   };
   SetUpValuators(
-      std::vector<Valuator>(valuators, valuators + arraysize(valuators)));
+      std::vector<Valuator>(valuators, valuators + base::size(valuators)));
 }
 
 void ScopedXI2Event::InitFlingScrollEvent(int deviceid,
@@ -268,7 +268,7 @@
   };
 
   SetUpValuators(
-      std::vector<Valuator>(valuators, valuators + arraysize(valuators)));
+      std::vector<Valuator>(valuators, valuators + base::size(valuators)));
 }
 
 void ScopedXI2Event::InitTouchEvent(int deviceid,
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index b8df7b0..36ed8f1 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -8,8 +8,8 @@
 #include <string.h>
 #include <cmath>
 
-#include "base/macros.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "ui/display/display.h"
 #include "ui/display/screen.h"
@@ -45,7 +45,7 @@
       {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask},
   };
   unsigned int new_x_flags = old_x_flags;
-  for (size_t i = 0; i < arraysize(flags); ++i) {
+  for (size_t i = 0; i < base::size(flags); ++i) {
     if (ui_flags & flags[i].ui)
       new_x_flags |= flags[i].x;
     else
diff --git a/ui/events/x/events_x_unittest.cc b/ui/events/x/events_x_unittest.cc
index 897c5c5..bc2eeac 100644
--- a/ui/events/x/events_x_unittest.cc
+++ b/ui/events/x/events_x_unittest.cc
@@ -10,7 +10,7 @@
 #include <set>
 #include <utility>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/test/simple_test_tick_clock.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -496,7 +496,7 @@
   unsigned int state_to_be_fabricated[] = {
     0, ShiftMask, LockMask, ShiftMask | LockMask,
   };
-  for (size_t i = 0; i < arraysize(state_to_be_fabricated); ++i) {
+  for (size_t i = 0; i < base::size(state_to_be_fabricated); ++i) {
     unsigned int state = state_to_be_fabricated[i];
     for (int is_char = 0; is_char < 2; ++is_char) {
       XEvent x_event;
@@ -513,7 +513,7 @@
   unsigned int state_to_be_not_fabricated[] = {
     ControlMask, Mod1Mask, Mod2Mask, ShiftMask | ControlMask,
   };
-  for (size_t i = 0; i < arraysize(state_to_be_not_fabricated); ++i) {
+  for (size_t i = 0; i < base::size(state_to_be_not_fabricated); ++i) {
     unsigned int state = state_to_be_not_fabricated[i];
     for (int is_char = 0; is_char < 2; ++is_char) {
       XEvent x_event;
diff --git a/ui/gfx/break_list_unittest.cc b/ui/gfx/break_list_unittest.cc
index e84d80e..84aec179 100644
--- a/ui/gfx/break_list_unittest.cc
+++ b/ui/gfx/break_list_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "ui/gfx/range/range.h"
@@ -158,8 +158,7 @@
     { 9, 4, Range(6, 8) },
   };
 
-
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     BreakList<bool>::const_iterator it = breaks.GetBreak(cases[i].position);
     EXPECT_EQ(breaks.breaks()[cases[i].break_index], *it);
     EXPECT_EQ(breaks.GetRange(it), cases[i].range);
diff --git a/ui/gfx/buffer_format_util.cc b/ui/gfx/buffer_format_util.cc
index 5e3de26a..22326d5 100644
--- a/ui/gfx/buffer_format_util.cc
+++ b/ui/gfx/buffer_format_util.cc
@@ -5,8 +5,8 @@
 #include "ui/gfx/buffer_format_util.h"
 
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/numerics/safe_math.h"
+#include "base/stl_util.h"
 
 namespace gfx {
 namespace {
@@ -21,11 +21,10 @@
     BufferFormat::UYVY_422,     BufferFormat::YUV_420_BIPLANAR,
     BufferFormat::YVU_420};
 
-static_assert(arraysize(kBufferFormats) ==
+static_assert(base::size(kBufferFormats) ==
                   (static_cast<int>(BufferFormat::LAST) + 1),
               "BufferFormat::LAST must be last value of kBufferFormats");
 
-
 bool RowSizeForBufferFormatChecked(
     size_t width, BufferFormat format, size_t plane, size_t* size_in_bytes) {
   base::CheckedNumeric<size_t> checked_size = width;
@@ -81,7 +80,7 @@
 
 std::vector<BufferFormat> GetBufferFormatsForTesting() {
   return std::vector<BufferFormat>(kBufferFormats,
-                                   kBufferFormats + arraysize(kBufferFormats));
+                                   kBufferFormats + base::size(kBufferFormats));
 }
 
 size_t NumberOfPlanesForBufferFormat(BufferFormat format) {
@@ -127,12 +126,12 @@
       return 1;
     case BufferFormat::YVU_420: {
       static size_t factor[] = {1, 2, 2};
-      DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
+      DCHECK_LT(static_cast<size_t>(plane), base::size(factor));
       return factor[plane];
     }
     case BufferFormat::YUV_420_BIPLANAR: {
       static size_t factor[] = {1, 2};
-      DCHECK_LT(static_cast<size_t>(plane), arraysize(factor));
+      DCHECK_LT(static_cast<size_t>(plane), base::size(factor));
       return factor[plane];
     }
   }
@@ -197,13 +196,13 @@
       return 0;
     case BufferFormat::YVU_420: {
       static size_t offset_in_2x2_sub_sampling_sizes[] = {0, 4, 5};
-      DCHECK_LT(plane, arraysize(offset_in_2x2_sub_sampling_sizes));
+      DCHECK_LT(plane, base::size(offset_in_2x2_sub_sampling_sizes));
       return offset_in_2x2_sub_sampling_sizes[plane] *
              (size.width() / 2 + size.height() / 2);
     }
     case gfx::BufferFormat::YUV_420_BIPLANAR: {
       static size_t offset_in_2x2_sub_sampling_sizes[] = {0, 4};
-      DCHECK_LT(plane, arraysize(offset_in_2x2_sub_sampling_sizes));
+      DCHECK_LT(plane, base::size(offset_in_2x2_sub_sampling_sizes));
       return offset_in_2x2_sub_sampling_sizes[plane] *
              (size.width() / 2 + size.height() / 2);
     }
diff --git a/ui/gfx/codec/chromeos/jpeg_codec_robust_slow_unittest.cc b/ui/gfx/codec/chromeos/jpeg_codec_robust_slow_unittest.cc
index 5304ab3..f857732 100644
--- a/ui/gfx/codec/chromeos/jpeg_codec_robust_slow_unittest.cc
+++ b/ui/gfx/codec/chromeos/jpeg_codec_robust_slow_unittest.cc
@@ -5,7 +5,7 @@
 #include <math.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/codec/chromeos/jpeg_codec_robust_slow.h"
 
@@ -94,10 +94,10 @@
   std::vector<unsigned char> output;
   int outw, outh;
   ASSERT_TRUE(JPEGCodecRobustSlow::Decode(
-      kTopSitesMigrationTestImage, arraysize(kTopSitesMigrationTestImage),
+      kTopSitesMigrationTestImage, base::size(kTopSitesMigrationTestImage),
       JPEGCodecRobustSlow::FORMAT_RGB, &output, &outw, &outh));
   ASSERT_TRUE(JPEGCodecRobustSlow::Decode(
-      kTopSitesMigrationTestImage, arraysize(kTopSitesMigrationTestImage),
+      kTopSitesMigrationTestImage, base::size(kTopSitesMigrationTestImage),
       JPEGCodecRobustSlow::FORMAT_RGBA, &output, &outw, &outh));
 }
 
diff --git a/ui/gfx/codec/jpeg_codec_unittest.cc b/ui/gfx/codec/jpeg_codec_unittest.cc
index f97206a..4b61921 100644
--- a/ui/gfx/codec/jpeg_codec_unittest.cc
+++ b/ui/gfx/codec/jpeg_codec_unittest.cc
@@ -6,7 +6,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/codec/jpeg_codec.h"
 
@@ -174,9 +174,8 @@
   std::vector<unsigned char> output;
   int outw, outh;
   JPEGCodec::Decode(kTopSitesMigrationTestImage,
-                    arraysize(kTopSitesMigrationTestImage),
-                    JPEGCodec::FORMAT_RGBA, &output,
-                    &outw, &outh);
+                    base::size(kTopSitesMigrationTestImage),
+                    JPEGCodec::FORMAT_RGBA, &output, &outw, &outh);
 }
 
 }  // namespace gfx
diff --git a/ui/gfx/codec/png_codec_unittest.cc b/ui/gfx/codec/png_codec_unittest.cc
index fee3e2a..260f7c9 100644
--- a/ui/gfx/codec/png_codec_unittest.cc
+++ b/ui/gfx/codec/png_codec_unittest.cc
@@ -9,7 +9,7 @@
 #include <cmath>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/libpng/png.h"
 #include "third_party/skia/include/core/SkBitmap.h"
@@ -923,13 +923,13 @@
       "\x00\x00\x00\x18tEXthave some\x00spaces in both\x8d\x69\x34\x2d";
 
   EXPECT_NE(std::search(encoded.begin(), encoded.end(), kExpected1,
-                        kExpected1 + arraysize(kExpected1)),
+                        kExpected1 + base::size(kExpected1)),
             encoded.end());
   EXPECT_NE(std::search(encoded.begin(), encoded.end(), kExpected2,
-                        kExpected2 + arraysize(kExpected2)),
+                        kExpected2 + base::size(kExpected2)),
             encoded.end());
   EXPECT_NE(std::search(encoded.begin(), encoded.end(), kExpected3,
-                        kExpected3 + arraysize(kExpected3)),
+                        kExpected3 + base::size(kExpected3)),
             encoded.end());
 }
 
diff --git a/ui/gfx/geometry/point3_unittest.cc b/ui/gfx/geometry/point3_unittest.cc
index 999b1f4..76b41ef 100644
--- a/ui/gfx/geometry/point3_unittest.cc
+++ b/ui/gfx/geometry/point3_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/point3_f.h"
 
@@ -28,7 +28,7 @@
     { gfx::Point3F(-9.6f, 9.5f, -2.8f), a - v1 + v2 }
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i)
+  for (size_t i = 0; i < base::size(tests); ++i)
     EXPECT_EQ(tests[i].expected.ToString(),
               tests[i].actual.ToString());
 
diff --git a/ui/gfx/geometry/point_unittest.cc b/ui/gfx/geometry/point_unittest.cc
index b453dd7..33f7f3b 100644
--- a/ui/gfx/geometry/point_unittest.cc
+++ b/ui/gfx/geometry/point_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/point.h"
 #include "ui/gfx/geometry/point_conversions.h"
@@ -57,7 +57,7 @@
     { Point(-10, 9), a - v1 + v2 }
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i)
+  for (size_t i = 0; i < base::size(tests); ++i)
     EXPECT_EQ(tests[i].expected.ToString(), tests[i].actual.ToString());
 }
 
diff --git a/ui/gfx/geometry/quad_unittest.cc b/ui/gfx/geometry/quad_unittest.cc
index 2731583aa..cf57bdcc 100644
--- a/ui/gfx/geometry/quad_unittest.cc
+++ b/ui/gfx/geometry/quad_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/quad_f.h"
@@ -153,7 +153,7 @@
     }
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     PointF a_off = tests[i].a_off;
     PointF b_off = tests[i].b_off;
     PointF c_off = tests[i].c_off;
diff --git a/ui/gfx/geometry/quaternion_unittest.cc b/ui/gfx/geometry/quaternion_unittest.cc
index 5c8fa9b..d350e26 100644
--- a/ui/gfx/geometry/quaternion_unittest.cc
+++ b/ui/gfx/geometry/quaternion_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <cmath>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/quaternion.h"
 #include "ui/gfx/geometry/vector3d_f.h"
@@ -55,7 +55,7 @@
 
 TEST(QuatTest, Addition) {
   double values[] = {0, 1, 100};
-  for (size_t i = 0; i < arraysize(values); ++i) {
+  for (size_t i = 0; i < base::size(values); ++i) {
     float t = values[i];
     Quaternion a(t, 2 * t, 3 * t, 4 * t);
     Quaternion b(5 * t, 4 * t, 3 * t, 2 * t);
@@ -80,7 +80,7 @@
        Quaternion(32, 32, 56, -6)},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     Quaternion product = cases[i].a * cases[i].b;
     CompareQuaternions(cases[i].expected, product);
   }
@@ -88,7 +88,7 @@
 
 TEST(QuatTest, Scaling) {
   double values[] = {0, 10, 100};
-  for (size_t i = 0; i < arraysize(values); ++i) {
+  for (size_t i = 0; i < base::size(values); ++i) {
     double s = values[i];
     Quaternion q(1, 2, 3, 4);
     Quaternion expected(s, 2 * s, 3 * s, 4 * s);
diff --git a/ui/gfx/geometry/scroll_offset_unittest.cc b/ui/gfx/geometry/scroll_offset_unittest.cc
index 782fdf4..4ad3460 100644
--- a/ui/gfx/geometry/scroll_offset_unittest.cc
+++ b/ui/gfx/geometry/scroll_offset_unittest.cc
@@ -7,7 +7,7 @@
 #include <cmath>
 #include <limits>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/scroll_offset.h"
 
@@ -34,7 +34,7 @@
     { ScrollOffset(3.1f - 4.3f, 5.1f + 1.3f), f1 - f2 }
   };
 
-  for (size_t i = 0; i < arraysize(scroll_offset_tests); ++i)
+  for (size_t i = 0; i < base::size(scroll_offset_tests); ++i)
     EXPECT_EQ(scroll_offset_tests[i].expected.ToString(),
               scroll_offset_tests[i].actual.ToString());
 }
@@ -50,7 +50,7 @@
     { ScrollOffset(0.3f, -0.3f), -ScrollOffset(-0.3f, 0.3f) }
   };
 
-  for (size_t i = 0; i < arraysize(scroll_offset_tests); ++i)
+  for (size_t i = 0; i < base::size(scroll_offset_tests); ++i)
     EXPECT_EQ(scroll_offset_tests[i].expected.ToString(),
               scroll_offset_tests[i].actual.ToString());
 }
@@ -68,7 +68,7 @@
     { 0, 1.2f, 3.3f, 5.6f }
   };
 
-  for (size_t i = 0; i < arraysize(float_values); ++i) {
+  for (size_t i = 0; i < base::size(float_values); ++i) {
     ScrollOffset v(float_values[i][0], float_values[i][1]);
     v.Scale(float_values[i][2], float_values[i][3]);
     EXPECT_EQ(v.x(), float_values[i][0] * float_values[i][2]);
@@ -87,7 +87,7 @@
     { 0, 1.2f, 3.3f }
   };
 
-  for (size_t i = 0; i < arraysize(single_values); ++i) {
+  for (size_t i = 0; i < base::size(single_values); ++i) {
     ScrollOffset v(single_values[i][0], single_values[i][1]);
     v.Scale(single_values[i][2]);
     EXPECT_EQ(v.x(), single_values[i][0] * single_values[i][2]);
diff --git a/ui/gfx/geometry/vector2d_unittest.cc b/ui/gfx/geometry/vector2d_unittest.cc
index 4bdf24c..8f49a8b5 100644
--- a/ui/gfx/geometry/vector2d_unittest.cc
+++ b/ui/gfx/geometry/vector2d_unittest.cc
@@ -7,7 +7,7 @@
 #include <cmath>
 #include <limits>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/vector2d.h"
 #include "ui/gfx/geometry/vector2d_f.h"
@@ -45,7 +45,7 @@
     { Vector2d(3 - 4, 5 + 1), i1 - i2 }
   };
 
-  for (size_t i = 0; i < arraysize(int_tests); ++i)
+  for (size_t i = 0; i < base::size(int_tests); ++i)
     EXPECT_EQ(int_tests[i].expected.ToString(),
               int_tests[i].actual.ToString());
 
@@ -62,7 +62,7 @@
     { Vector2dF(3.1f - 4.3f, 5.1f + 1.3f), f1 - f2 }
   };
 
-  for (size_t i = 0; i < arraysize(float_tests); ++i)
+  for (size_t i = 0; i < base::size(float_tests); ++i)
     EXPECT_EQ(float_tests[i].expected.ToString(),
               float_tests[i].actual.ToString());
 }
@@ -79,7 +79,7 @@
     { Vector2d(3, -3), -Vector2d(-3, 3) }
   };
 
-  for (size_t i = 0; i < arraysize(int_tests); ++i)
+  for (size_t i = 0; i < base::size(int_tests); ++i)
     EXPECT_EQ(int_tests[i].expected.ToString(),
               int_tests[i].actual.ToString());
 
@@ -94,7 +94,7 @@
     { Vector2dF(0.3f, -0.3f), -Vector2dF(-0.3f, 0.3f) }
   };
 
-  for (size_t i = 0; i < arraysize(float_tests); ++i)
+  for (size_t i = 0; i < base::size(float_tests); ++i)
     EXPECT_EQ(float_tests[i].expected.ToString(),
               float_tests[i].actual.ToString());
 }
@@ -112,7 +112,7 @@
     { 0, 1.2f, 3.3f, 5.6f }
   };
 
-  for (size_t i = 0; i < arraysize(double_values); ++i) {
+  for (size_t i = 0; i < base::size(double_values); ++i) {
     Vector2dF v(double_values[i][0], double_values[i][1]);
     v.Scale(double_values[i][2], double_values[i][3]);
     EXPECT_EQ(v.x(), double_values[i][0] * double_values[i][2]);
@@ -137,7 +137,7 @@
     { 0, 1.2f, 3.3f }
   };
 
-  for (size_t i = 0; i < arraysize(single_values); ++i) {
+  for (size_t i = 0; i < base::size(single_values); ++i) {
     Vector2dF v(single_values[i][0], single_values[i][1]);
     v.Scale(single_values[i][2]);
     EXPECT_EQ(v.x(), single_values[i][0] * single_values[i][2]);
@@ -161,7 +161,7 @@
     { 10, -20 },
   };
 
-  for (size_t i = 0; i < arraysize(int_values); ++i) {
+  for (size_t i = 0; i < base::size(int_values); ++i) {
     int v0 = int_values[i][0];
     int v1 = int_values[i][1];
     double length_squared =
@@ -185,7 +185,7 @@
       335890352589839028212313231225425134332.38123f },
   };
 
-  for (size_t i = 0; i < arraysize(float_values); ++i) {
+  for (size_t i = 0; i < base::size(float_values); ++i) {
     double v0 = float_values[i][0];
     double v1 = float_values[i][1];
     double length_squared =
diff --git a/ui/gfx/geometry/vector3d_unittest.cc b/ui/gfx/geometry/vector3d_unittest.cc
index 12ee757..02585c8 100644
--- a/ui/gfx/geometry/vector3d_unittest.cc
+++ b/ui/gfx/geometry/vector3d_unittest.cc
@@ -7,7 +7,7 @@
 #include <cmath>
 #include <limits>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/vector3d_f.h"
@@ -35,7 +35,7 @@
     { gfx::Vector3dF(3.1f - 4.3f, 5.1f + 1.3f, 2.7f - 8.1f), f1 - f2 }
   };
 
-  for (size_t i = 0; i < arraysize(float_tests); ++i)
+  for (size_t i = 0; i < base::size(float_tests); ++i)
     EXPECT_EQ(float_tests[i].expected.ToString(),
               float_tests[i].actual.ToString());
 }
@@ -53,7 +53,7 @@
     { gfx::Vector3dF(-0.3f, -0.3f, 0.3f), -gfx::Vector3dF(0.3f, 0.3f, -0.3f) }
   };
 
-  for (size_t i = 0; i < arraysize(float_tests); ++i)
+  for (size_t i = 0; i < base::size(float_tests); ++i)
     EXPECT_EQ(float_tests[i].expected.ToString(),
               float_tests[i].actual.ToString());
 }
@@ -86,7 +86,7 @@
     { 0, 1.2f, 1.8f, 3.3f, 5.6f, 4.2f }
   };
 
-  for (size_t i = 0; i < arraysize(triple_values); ++i) {
+  for (size_t i = 0; i < base::size(triple_values); ++i) {
     gfx::Vector3dF v(triple_values[i][0],
                      triple_values[i][1],
                      triple_values[i][2]);
@@ -122,7 +122,7 @@
     { 4.5f, 1.2f, 0, 3.3f }
   };
 
-  for (size_t i = 0; i < arraysize(single_values); ++i) {
+  for (size_t i = 0; i < base::size(single_values); ++i) {
     gfx::Vector3dF v(single_values[i][0],
                      single_values[i][1],
                      single_values[i][2]);
@@ -164,7 +164,7 @@
       27861786423846742743236423478236784678.236713617231f }
   };
 
-  for (size_t i = 0; i < arraysize(float_values); ++i) {
+  for (size_t i = 0; i < base::size(float_values); ++i) {
     double v0 = float_values[i][0];
     double v1 = float_values[i][1];
     double v2 = float_values[i][2];
@@ -198,7 +198,7 @@
       gfx::Vector3dF(1.1f, 2.2f, 3.3f), gfx::Vector3dF(4.4f, 5.5f, 6.6f) }
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     float actual = gfx::DotProduct(tests[i].input1, tests[i].input2);
     EXPECT_EQ(tests[i].expected, actual);
   }
@@ -226,7 +226,7 @@
     { Vector3dF(0, -1, 1), Vector3dF(1, 0, 0), Vector3dF(1, 1, 1) }
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     SCOPED_TRACE(i);
     Vector3dF actual = gfx::CrossProduct(tests[i].input1, tests[i].input2);
     EXPECT_EQ(tests[i].expected.ToString(), actual.ToString());
@@ -279,7 +279,7 @@
       {180, gfx::Vector3dF(0, 1, 0), gfx::Vector3dF(0, -1, 0)},
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     float actual =
         gfx::AngleBetweenVectorsInDegrees(tests[i].input1, tests[i].input2);
     EXPECT_FLOAT_EQ(tests[i].expected, actual);
@@ -306,7 +306,7 @@
 
   const gfx::Vector3dF normal_vector(1.0f, 0.0f, 0.0f);
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     float actual = gfx::ClockwiseAngleBetweenVectorsInDegrees(
         tests[i].input1, tests[i].input2, normal_vector);
     EXPECT_FLOAT_EQ(tests[i].expected, actual);
@@ -337,7 +337,7 @@
        gfx::Vector3dF(1, 0, 0)},
   };
 
-  for (size_t i = 0; i < arraysize(tests); ++i) {
+  for (size_t i = 0; i < base::size(tests); ++i) {
     gfx::Vector3dF n;
     EXPECT_EQ(tests[i].expected, tests[i].v.GetNormalized(&n));
     EXPECT_EQ(tests[i].normalized.ToString(), n.ToString());
diff --git a/ui/gfx/half_float_unittest.cc b/ui/gfx/half_float_unittest.cc
index 5e7c61e..db693ff 100644
--- a/ui/gfx/half_float_unittest.cc
+++ b/ui/gfx/half_float_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <math.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/half_float.h"
 
@@ -75,7 +75,7 @@
       0.0f,    1.0f,    10.0f,    1000.0f,  65503.0f,
       1.0E-3f, 1.0E-6f, 1.0E-20f, 1.0E-44f,
   };
-  for (size_t i = 0; i < arraysize(test); i++) {
+  for (size_t i = 0; i < base::size(test); i++) {
     EXPECT_EQ(ConvertTruth(test[i]), Convert(test[i])) << " float = "
                                                        << test[i];
     if (test[i] != 0.0) {
diff --git a/ui/gfx/icon_util.cc b/ui/gfx/icon_util.cc
index d69e329..1c9705c 100644
--- a/ui/gfx/icon_util.cc
+++ b/ui/gfx/icon_util.cc
@@ -9,7 +9,7 @@
 #include "base/files/file_util.h"
 #include "base/files/important_file_writer.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "base/win/resource_util.h"
 #include "base/win/scoped_gdi_object.h"
@@ -159,7 +159,7 @@
   256   // Used by Vista onwards for large icons.
 };
 
-const size_t IconUtil::kNumIconDimensions = arraysize(kIconDimensions);
+const size_t IconUtil::kNumIconDimensions = base::size(kIconDimensions);
 const size_t IconUtil::kNumIconDimensionsUpToMediumSize = 9;
 
 base::win::ScopedHICON IconUtil::CreateHICONFromSkBitmap(
diff --git a/ui/gfx/image/image_ios_unittest.mm b/ui/gfx/image/image_ios_unittest.mm
index 1e8c5e8b..2ad1717 100644
--- a/ui/gfx/image/image_ios_unittest.mm
+++ b/ui/gfx/image/image_ios_unittest.mm
@@ -8,7 +8,7 @@
 
 #include "base/logging.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/image/image.h"
 #include "ui/gfx/image/image_skia.h"
@@ -72,8 +72,8 @@
   const CGFloat kHeight = 100;
   const CGFloat kTestScales[3] = { 1.0f, 2.0f, 3.0f };
 
-  for (size_t i = 0; i < arraysize(kTestScales); ++i) {
-    for (size_t j = 0; j < arraysize(kTestScales); ++j) {
+  for (size_t i = 0; i < base::size(kTestScales); ++i) {
+    for (size_t j = 0; j < base::size(kTestScales); ++j) {
       const CGFloat source_scale = kTestScales[i];
       const CGFloat supported_scale = kTestScales[j];
 
diff --git a/ui/gfx/ios/uikit_util_unittest.mm b/ui/gfx/ios/uikit_util_unittest.mm
index f6cf49d..61d024c 100644
--- a/ui/gfx/ios/uikit_util_unittest.mm
+++ b/ui/gfx/ios/uikit_util_unittest.mm
@@ -5,7 +5,7 @@
 #import <Foundation/Foundation.h>
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/platform_test.h"
 #import "ui/gfx/ios/uikit_util.h"
 
@@ -20,7 +20,7 @@
    // "integer" values within <1 of the original value in the scaled space.
    CGFloat test_values[] = { 10.0, 55.5, 3.1, 2.9 };
    const CGFloat kMaxAlignDelta = 0.9999;
-   size_t value_count = arraysize(test_values);
+   size_t value_count = base::size(test_values);
    for (unsigned int i = 0; i < value_count; ++i) {
      CGFloat aligned = ui::AlignValueToUpperPixel(test_values[i]);
      EXPECT_FLOAT_EQ(aligned * scale, floor(aligned * scale));
@@ -35,7 +35,7 @@
   // "integer" values within <1 of the original value in the scaled space.
   CGFloat test_values[] = { 10.0, 55.5, 3.1, 2.9 };
   const CGFloat kMaxAlignDelta = 0.9999;
-  size_t value_count = arraysize(test_values);
+  size_t value_count = base::size(test_values);
   for (unsigned int i = 0; i < value_count; ++i) {
     CGFloat width = test_values[i];
     CGFloat height = test_values[(i + 1) % value_count];
diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc
index 8d9f38b1..d12f8a42 100644
--- a/ui/gfx/mac/io_surface.cc
+++ b/ui/gfx/mac/io_surface.cc
@@ -11,8 +11,8 @@
 #include "base/logging.h"
 #include "base/mac/mac_util.h"
 #include "base/mac/mach_logging.h"
-#include "base/macros.h"
 #include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "ui/gfx/buffer_format_util.h"
 #include "ui/gfx/icc_profile.h"
@@ -45,7 +45,7 @@
       return 8;
     case gfx::BufferFormat::YUV_420_BIPLANAR:
       static int32_t bytes_per_element[] = {1, 2};
-      DCHECK_LT(static_cast<size_t>(plane), arraysize(bytes_per_element));
+      DCHECK_LT(static_cast<size_t>(plane), base::size(bytes_per_element));
       return bytes_per_element[plane];
     case gfx::BufferFormat::R_16:
     case gfx::BufferFormat::RG_88:
diff --git a/ui/gfx/paint_vector_icon_unittest.cc b/ui/gfx/paint_vector_icon_unittest.cc
index b472dff7..ca8efecb 100644
--- a/ui/gfx/paint_vector_icon_unittest.cc
+++ b/ui/gfx/paint_vector_icon_unittest.cc
@@ -8,6 +8,7 @@
 #include <vector>
 
 #include "base/i18n/rtl.h"
+#include "base/stl_util.h"
 #include "cc/paint/paint_record.h"
 #include "cc/paint/paint_recorder.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -50,7 +51,7 @@
       MOVE_TO, 4, 5, LINE_TO, 10, 11, CLOSE,
       // This move should use (4, 5) as the start point rather than (10, 11).
       R_MOVE_TO, 20, 21, R_LINE_TO, 50, 51};
-  const VectorIconRep rep_list[] = {{elements, arraysize(elements)}};
+  const VectorIconRep rep_list[] = {{elements, base::size(elements)}};
   const VectorIcon icon = {rep_list, 1u};
 
   PaintVectorIcon(&canvas, icon, 100, SK_ColorMAGENTA);
@@ -91,7 +92,7 @@
                                   R_H_LINE_TO,
                                   -20,
                                   CLOSE};
-  const VectorIconRep rep_list[] = {{elements, arraysize(elements)}};
+  const VectorIconRep rep_list[] = {{elements, base::size(elements)}};
   const VectorIcon icon = {rep_list, 1u};
   PaintVectorIcon(&canvas, icon, canvas_size, color);
 
@@ -217,11 +218,11 @@
                                     0,
                                     CLOSE};
   // VectorIconReps are always sorted in descending order of size.
-  const VectorIconRep rep_list[] = {{elements48, arraysize(elements48)},
-                                    {elements32, arraysize(elements32)},
-                                    {elements24, arraysize(elements24)},
-                                    {elements20, arraysize(elements20)},
-                                    {elements16, arraysize(elements16)}};
+  const VectorIconRep rep_list[] = {{elements48, base::size(elements48)},
+                                    {elements32, base::size(elements32)},
+                                    {elements24, base::size(elements24)},
+                                    {elements20, base::size(elements20)},
+                                    {elements16, base::size(elements16)}};
   const VectorIcon icon = {rep_list, 5u};
 
   // Test exact sizes paint the correctly sized icon, including the largest and
diff --git a/ui/gfx/path_mac.mm b/ui/gfx/path_mac.mm
index 109f807..d2537c3e 100644
--- a/ui/gfx/path_mac.mm
+++ b/ui/gfx/path_mac.mm
@@ -6,6 +6,7 @@
 
 #import <Cocoa/Cocoa.h>
 
+#include "base/stl_util.h"
 #include "third_party/skia/include/core/SkRegion.h"
 #include "ui/gfx/path.h"
 
@@ -38,7 +39,7 @@
   SkPath::Verb verb;
   NSPoint points[4];
   while ((verb = iter.next(sk_points)) != SkPath::kDone_Verb) {
-    for (size_t i = 0; i < arraysize(points); i++)
+    for (size_t i = 0; i < base::size(points); i++)
       points[i] = NSMakePoint(sk_points[i].x(), sk_points[i].y());
 
     switch (verb) {
diff --git a/ui/gfx/path_mac_unittest.mm b/ui/gfx/path_mac_unittest.mm
index d1d4a99..2cb8ea9 100644
--- a/ui/gfx/path_mac_unittest.mm
+++ b/ui/gfx/path_mac_unittest.mm
@@ -9,6 +9,7 @@
 
 #import <Cocoa/Cocoa.h>
 
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkRegion.h"
 #include "ui/gfx/geometry/rect.h"
@@ -117,7 +118,7 @@
   const NSPoint outside_points[] = {{-1, -1}, {-1, 51},  {51, 51},   {51, -1},
                                     {99, 99}, {99, 151}, {151, 151}, {151, 99},
                                     {75, 75}, {-5, -5}};
-  ASSERT_EQ(arraysize(inside_points), arraysize(outside_points));
+  ASSERT_EQ(base::size(inside_points), base::size(outside_points));
   const Rect expected_bounds(0, 0, 150, 150);
 
   SkPath path;
@@ -127,7 +128,7 @@
 
   // Check points near the boundary of the path and verify that they are
   // reported correctly as being inside/outside the path.
-  for (size_t i = 0; i < arraysize(inside_points); i++) {
+  for (size_t i = 0; i < base::size(inside_points); i++) {
     EXPECT_TRUE([result containsPoint:inside_points[i]]);
     EXPECT_FALSE([result containsPoint:outside_points[i]]);
   }
@@ -227,7 +228,7 @@
       {kRectangleWidth / 2.0, kRectangleHeight + kCushion},
       // Left middle.
       {-kCushion, kRectangleHeight / 2.0}};
-  ASSERT_EQ(arraysize(inside_points), arraysize(outside_points));
+  ASSERT_EQ(base::size(inside_points), base::size(outside_points));
 
   SkPath path;
   path.addRRect(rrect);
@@ -235,7 +236,7 @@
 
   // Check points near the boundary of the path and verify that they are
   // reported correctly as being inside/outside the path.
-  for (size_t i = 0; i < arraysize(inside_points); i++) {
+  for (size_t i = 0; i < base::size(inside_points); i++) {
     EXPECT_TRUE([result containsPoint:inside_points[i]]);
     EXPECT_FALSE([result containsPoint:outside_points[i]]);
   }
diff --git a/ui/gfx/path_win_unittest.cc b/ui/gfx/path_win_unittest.cc
index ca9e13a..f6e8d61 100644
--- a/ui/gfx/path_win_unittest.cc
+++ b/ui/gfx/path_win_unittest.cc
@@ -9,7 +9,7 @@
 #include <algorithm>
 #include <vector>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/win/scoped_gdi_object.h"
 #include "skia/ext/skia_utils_win.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -83,8 +83,8 @@
   path.addRRect(rrect);
   base::win::ScopedRegion region(CreateHRGNFromSkPath(path));
   const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region.get());
-  EXPECT_EQ(arraysize(rects), region_rects.size());
-  for (size_t i = 0; i < arraysize(rects) && i < region_rects.size(); ++i)
+  EXPECT_EQ(base::size(rects), region_rects.size());
+  for (size_t i = 0; i < base::size(rects) && i < region_rects.size(); ++i)
     EXPECT_EQ(rects[i], region_rects[i]);
 }
 
@@ -102,8 +102,8 @@
   }
   base::win::ScopedRegion region(CreateHRGNFromSkPath(path));
   const std::vector<SkIRect>& region_rects = GetRectsFromHRGN(region.get());
-  ASSERT_EQ(arraysize(rects), region_rects.size());
-  for (size_t i = 0; i < arraysize(rects); ++i)
+  ASSERT_EQ(base::size(rects), region_rects.size());
+  for (size_t i = 0; i < base::size(rects); ++i)
     EXPECT_EQ(rects[i], region_rects[i]);
 }
 
diff --git a/ui/gfx/platform_font_mac_unittest.mm b/ui/gfx/platform_font_mac_unittest.mm
index f031568..422e242 100644
--- a/ui/gfx/platform_font_mac_unittest.mm
+++ b/ui/gfx/platform_font_mac_unittest.mm
@@ -8,7 +8,7 @@
 #include <stddef.h>
 
 #include "base/mac/mac_util.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/font.h"
 
@@ -286,7 +286,7 @@
   gfx::Font::FontStyle styles[] = {gfx::Font::NORMAL, gfx::Font::ITALIC,
                                    gfx::Font::UNDERLINE};
 
-  for (size_t i = 0; i < arraysize(styles); ++i) {
+  for (size_t i = 0; i < base::size(styles); ++i) {
     SCOPED_TRACE(testing::Message() << "Font::FontStyle: " << styles[i]);
     // Include the range of sizes used by ResourceBundle::FontStyle (-1 to +8).
     for (int delta = -1; delta <= 8; ++delta) {
diff --git a/ui/gfx/platform_font_win.cc b/ui/gfx/platform_font_win.cc
index e7c628c..0680cde 100644
--- a/ui/gfx/platform_font_win.cc
+++ b/ui/gfx/platform_font_win.cc
@@ -18,8 +18,8 @@
 #include "base/containers/flat_map.h"
 #include "base/debug/alias.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/no_destructor.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/string_util.h"
 #include "base/strings/sys_string_conversions.h"
@@ -92,7 +92,7 @@
   if (SUCCEEDED(hr)) {
     hr = font_collection->GetFontFromFontFace(font_face.Get(), dwrite_font);
     if (SUCCEEDED(hr)) {
-      wcscpy_s(font_info->lfFaceName, arraysize(font_info->lfFaceName),
+      wcscpy_s(font_info->lfFaceName, base::size(font_info->lfFaceName),
                converted_font.lfFaceName);
     }
   }
@@ -155,12 +155,12 @@
     }
 
     if (wcsncmp(font_info->lfFaceName, metrics.lfMessageFont.lfFaceName,
-                arraysize(font_info->lfFaceName))) {
+                base::size(font_info->lfFaceName))) {
       // First try the GDI compat route to get a matching DirectWrite font. If
       // that succeeds we are good. If not find a matching font from the font
       // collection.
-      wcscpy_s(font_info->lfFaceName, arraysize(font_info->lfFaceName),
-                metrics.lfMessageFont.lfFaceName);
+      wcscpy_s(font_info->lfFaceName, base::size(font_info->lfFaceName),
+               metrics.lfMessageFont.lfFaceName);
       hr = FindDirectWriteFontForLOGFONT(factory, font_info, dwrite_font);
       if (SUCCEEDED(hr))
         return hr;
@@ -219,7 +219,7 @@
 
   base::string16 font_name;
   gfx::GetFamilyNameFromDirectWriteFont(*dwrite_font, &font_name);
-  wcscpy_s(font_info->lfFaceName, arraysize(font_info->lfFaceName),
+  wcscpy_s(font_info->lfFaceName, base::size(font_info->lfFaceName),
            font_name.c_str());
   return hr;
 }
@@ -377,7 +377,7 @@
   // Add support for retrieving the family for the current locale.
   wchar_t family_name_for_locale[MAX_PATH] = {0};
   hr = family_names->GetString(0, family_name_for_locale,
-                               arraysize(family_name_for_locale));
+                               base::size(family_name_for_locale));
   if (FAILED(hr))
     CHECK(false);
 
@@ -513,7 +513,7 @@
   // locale, GetTextFace() returns the localized name.
   base::win::ScopedSelectObject font(memory_dc.Get(), font_ref_->hfont());
   wchar_t localized_font_name[LF_FACESIZE];
-  int length = GetTextFace(memory_dc.Get(), arraysize(localized_font_name),
+  int length = GetTextFace(memory_dc.Get(), base::size(localized_font_name),
                            &localized_font_name[0]);
   if (length <= 0)
     return GetFontName();
diff --git a/ui/gfx/render_text_mac.mm b/ui/gfx/render_text_mac.mm
index 41139a49..198eecd 100644
--- a/ui/gfx/render_text_mac.mm
+++ b/ui/gfx/render_text_mac.mm
@@ -15,8 +15,8 @@
 #include "base/mac/foundation_util.h"
 #include "base/mac/mac_util.h"
 #include "base/mac/scoped_cftyperef.h"
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/sys_string_conversions.h"
 #include "skia/ext/skia_utils_mac.h"
 #include "third_party/skia/include/ports/SkTypeface_mac.h"
@@ -317,7 +317,7 @@
   const void* keys[] = {kCTFontAttributeName};
   const void* values[] = {ct_font};
   base::ScopedCFTypeRef<CFDictionaryRef> attributes(
-      CFDictionaryCreate(NULL, keys, values, arraysize(keys), NULL,
+      CFDictionaryCreate(NULL, keys, values, base::size(keys), NULL,
                          &kCFTypeDictionaryValueCallBacks));
 
   base::ScopedCFTypeRef<CFStringRef> cf_text(base::SysUTF16ToCFStringRef(text));
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 8d89148..192e9a3 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -14,8 +14,8 @@
 
 #include "base/format_macros.h"
 #include "base/i18n/break_iterator.h"
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_split.h"
 #include "base/strings/string_util.h"
 #include "base/strings/stringprintf.h"
@@ -500,7 +500,7 @@
   RenderText* render_text = GetRenderText();
   EXPECT_TRUE(render_text->text().empty());
   const char* const cases[] = {kWeak, kLtr, "Hello", kRtl, "", ""};
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     EXPECT_TRUE(test_api()->colors().EqualsValueForTesting(SK_ColorBLACK));
     EXPECT_TRUE(test_api()->baselines().EqualsValueForTesting(NORMAL_BASELINE));
     EXPECT_TRUE(test_api()->font_size_overrides().EqualsValueForTesting(0));
@@ -519,7 +519,7 @@
   render_text->SetWeight(Font::Weight::BOLD);
   render_text->SetStyle(UNDERLINE, false);
   const char* const cases[] = {kWeak, kLtr, "Hello", kRtl, "", ""};
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     EXPECT_TRUE(test_api()->colors().EqualsValueForTesting(color));
     EXPECT_TRUE(test_api()->baselines().EqualsValueForTesting(SUPERSCRIPT));
     EXPECT_TRUE(
@@ -736,7 +736,7 @@
       "hop on pop",                              // Check LTR word boundaries.
       "\u05d0\u05d1 \u05d0\u05d2 \u05d1\u05d2",  // Check RTL word boundaries.
   };
-  for (size_t i = 0; i < arraysize(texts); ++i) {
+  for (size_t i = 0; i < base::size(texts); ++i) {
     base::string16 text = UTF8ToUTF16(texts[i]);
     TestVisualCursorMotionInObscuredField(render_text, text, SELECTION_NONE);
     TestVisualCursorMotionInObscuredField(render_text, text, SELECTION_RETAIN);
@@ -904,7 +904,7 @@
   render_text->SetFontList(FontList("serif, Sans serif, 12px"));
   render_text->SetElideBehavior(ELIDE_TAIL);
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     SCOPED_TRACE(base::StringPrintf("Testing cases[%" PRIuS "] '%ls'", i,
                                     cases[i].text));
 
@@ -1122,7 +1122,7 @@
 
   RenderText* render_text = GetRenderText();
   render_text->set_truncate_length(5);
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     render_text->SetText(WideToUTF16(cases[i].text));
     EXPECT_EQ(WideToUTF16(cases[i].text), render_text->text());
     EXPECT_EQ(WideToUTF16(cases[i].display_text), render_text->GetDisplayText())
@@ -1554,7 +1554,7 @@
         base::i18n::RIGHT_TO_LEFT : base::i18n::LEFT_TO_RIGHT;
 
     // Ensure that directionality modes yield the correct text directions.
-    for (size_t j = 0; j < arraysize(cases); j++) {
+    for (size_t j = 0; j < base::size(cases); j++) {
       render_text->SetText(UTF8ToUTF16(cases[j].text));
       render_text->SetDirectionalityMode(DIRECTIONALITY_FROM_TEXT);
       EXPECT_EQ(render_text->GetDisplayTextDirection(),cases[j].text_direction);
@@ -1827,7 +1827,7 @@
   };
 
   RenderText* render_text = GetRenderText();
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     SCOPED_TRACE(base::StringPrintf("Testing cases[%" PRIuS "]", i));
     render_text->SetText(cases[i].text);
 
@@ -1851,7 +1851,7 @@
 
   RenderText* render_text = GetRenderText();
   render_text->SetDisplayRect(Rect(100, 1000));
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     SCOPED_TRACE(base::StringPrintf("Testing cases[%" PRIuS "]", i));
     render_text->SetText(cases[i]);
     EXPECT_TRUE(render_text->IsValidLogicalIndex(1));
@@ -1881,7 +1881,7 @@
   const char* kTestStrings[] = {kLtrRtl, kLtrRtlLtr, kRtlLtr, kRtlLtrRtl};
   RenderText* render_text = GetRenderText();
   render_text->SetDisplayRect(Rect(0, 0, 100, 20));
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing case[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     for (size_t j = 0; j < render_text->text().length(); ++j) {
@@ -1905,7 +1905,7 @@
   render_text->SetDisplayRect(Rect(25, 1000));
   render_text->SetMultiline(true);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); i++) {
+  for (size_t i = 0; i < base::size(kTestStrings); i++) {
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     test_api()->EnsureLayout();
     EXPECT_EQ(2u, test_api()->lines().size());
@@ -1947,7 +1947,7 @@
 
   RenderText* render_text = GetRenderText();
   render_text->SetDisplayRect(gfx::Rect(100, 30));
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     SCOPED_TRACE(base::StringPrintf("Testing case %" PRIuS "", i));
     render_text->SetText(cases[i].text);
     test_api()->EnsureLayout();
@@ -1985,7 +1985,7 @@
   };
 
   RenderText* render_text = GetRenderText();
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     render_text->SetText(cases[i].text);
     bool ltr = (cases[i].expected_text_direction == base::i18n::LEFT_TO_RIGHT);
 
@@ -2017,7 +2017,7 @@
     EXPECT_EQ(render_text->selection_model(), SelectionModel());
 
     // Test the weak, LTR, RTL, and Bidi string cases.
-    for (size_t j = 0; j < arraysize(cases); j++) {
+    for (size_t j = 0; j < base::size(cases); j++) {
       render_text->SetText(UTF8ToUTF16(cases[j]));
       render_text->SelectAll(false);
       EXPECT_EQ(render_text->selection_model(), expected_forwards);
@@ -2637,7 +2637,7 @@
   const FontList& larger_font_list = default_font_list.DeriveWithSizeDelta(24);
   EXPECT_GT(larger_font_list.GetHeight(), default_font_list.GetHeight());
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     ResetRenderTextInstance();
     RenderText* render_text = GetRenderText();
     render_text->SetFontList(default_font_list);
@@ -2781,7 +2781,7 @@
     { ALIGN_CENTER, kEnlargement },
   };
 
-  for (size_t i = 0; i < arraysize(small_content_cases); i++) {
+  for (size_t i = 0; i < base::size(small_content_cases); i++) {
     render_text->SetHorizontalAlignment(small_content_cases[i].alignment);
     render_text->SetDisplayOffset(small_content_cases[i].offset);
     EXPECT_EQ(0, render_text->GetUpdatedDisplayOffset().x());
@@ -2816,7 +2816,7 @@
     { ALIGN_CENTER, kEnlargement, (kEnlargement - 1) / 2 },
   };
 
-  for (size_t i = 0; i < arraysize(large_content_cases); i++) {
+  for (size_t i = 0; i < base::size(large_content_cases); i++) {
     render_text->SetHorizontalAlignment(large_content_cases[i].alignment);
     render_text->SetDisplayOffset(large_content_cases[i].offset);
     EXPECT_EQ(large_content_cases[i].expected_offset,
@@ -2864,14 +2864,14 @@
   };
 
   RenderText* render_text = GetRenderText();
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     base::string16 text = cases[i].text;
     const size_t start_paren_char_index = text.find('(');
     ASSERT_NE(base::string16::npos, start_paren_char_index);
     const size_t end_paren_char_index = text.find(')');
     ASSERT_NE(base::string16::npos, end_paren_char_index);
 
-    for (size_t j = 0; j < arraysize(punctuation_pairs); ++j) {
+    for (size_t j = 0; j < base::size(punctuation_pairs); ++j) {
       text[start_paren_char_index] = punctuation_pairs[j].left_char;
       text[end_paren_char_index] = punctuation_pairs[j].right_char;
       render_text->SetText(text);
@@ -2935,7 +2935,7 @@
     { 16, 13, 16 },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     render_text->SetCursorPosition(cases[i].cursor);
     render_text->SelectWord();
     EXPECT_EQ(Range(cases[i].selection_start, cases[i].selection_end),
@@ -3106,7 +3106,7 @@
   RenderText* render_text = GetRenderText();
   render_text->set_selection_color(SK_ColorRED);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     const int expected_width = render_text->GetStringSize().width();
     render_text->SelectRange({0, 1});
@@ -3168,7 +3168,7 @@
   render_text->SetMultiline(true);
   render_text->SetWordWrapBehavior(WRAP_LONG_WORDS);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     render_text->Draw(canvas());
@@ -3225,7 +3225,7 @@
   render_text->SetWordWrapBehavior(WRAP_LONG_WORDS);
   render_text->SetHorizontalAlignment(ALIGN_TO_HEAD);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i].text));
     DrawVisualText();
@@ -3270,7 +3270,7 @@
   render_text->SetDisplayRect(Rect(1000, 1000));
   render_text->SetMultiline(true);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     render_text->Draw(canvas());
@@ -3297,7 +3297,7 @@
   render_text->SetDisplayRect(Rect(200, 1000));
   render_text->SetMultiline(true);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i].text));
     render_text->Draw(canvas());
@@ -3343,7 +3343,7 @@
       "abc\ndef", "a \n b ", "ab\n", "a\n\nb", "\nab", "\n",
   };
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     ResetRenderTextInstance();
     RenderText* render_text = GetRenderText();
@@ -3399,7 +3399,7 @@
   render_text->SetDisplayRect(Rect(100, 1000));
   render_text->SetMultiline(true);
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(testing::Message("kTestStrings[")
                  << i << "] = " << kTestStrings[i].text);
     render_text->SetText(UTF8ToUTF16(kTestStrings[i].text));
@@ -3453,7 +3453,7 @@
   SetGlyphWidth(kGlyphSize);
   render_text->SetDisplayRect(Rect(0, 0, kGlyphSize * 4, 0));
 
-  for (size_t i = 0; i < arraysize(kTestScenarios); ++i) {
+  for (size_t i = 0; i < base::size(kTestScenarios); ++i) {
     SCOPED_TRACE(base::StringPrintf(
         "kTestScenarios[%" PRIuS "] %d", i, kTestScenarios[i].behavior));
     render_text->SetWordWrapBehavior(kTestScenarios[i].behavior);
@@ -3511,7 +3511,7 @@
   SetGlyphWidth(kGlyphSize);
   render_text->SetDisplayRect(Rect(0, 0, kGlyphSize * 4, 0));
 
-  for (size_t i = 0; i < arraysize(kTestScenarios); ++i) {
+  for (size_t i = 0; i < base::size(kTestScenarios); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestScenarios[i].text));
     render_text->SetWordWrapBehavior(kTestScenarios[i].behavior);
@@ -3574,7 +3574,7 @@
         { Range(0, 2), Range(2, 3), Range(3, 5) } },
   };
 
-  for (size_t i = 0; i < arraysize(kTestScenarios); ++i) {
+  for (size_t i = 0; i < base::size(kTestScenarios); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(kTestScenarios[i].text);
     render_text->SetDisplayRect(Rect(0, 0, kTestScenarios[i].display_width, 0));
@@ -3618,7 +3618,7 @@
 
   EXPECT_EQ(3u, test_api()->lines().size());
   for (size_t j = 0;
-       j < std::min(arraysize(char_ranges), test_api()->lines().size()); ++j) {
+       j < std::min(base::size(char_ranges), test_api()->lines().size()); ++j) {
     SCOPED_TRACE(base::StringPrintf("%" PRIuS "-th line", j));
     int segment_size = test_api()->lines()[j].segments.size();
     ASSERT_GT(segment_size, 0);
@@ -3637,7 +3637,7 @@
   RenderText* render_text = GetRenderText();
   render_text->SetDisplayRect(Rect(200, 1000));
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     render_text->Draw(canvas());
@@ -3659,7 +3659,7 @@
 
   RenderTextHarfBuzz* render_text = GetRenderText();
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "]", i));
     render_text->SetText(UTF8ToUTF16(kTestStrings[i].text));
 
@@ -3726,7 +3726,7 @@
   run.shape.glyph_count = 4;
   run.shape.glyph_to_char.resize(4);
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::copy(cases[i].glyph_to_char, cases[i].glyph_to_char + 4,
               run.shape.glyph_to_char.begin());
     run.font_params.is_rtl = cases[i].is_rtl;
@@ -3769,7 +3769,7 @@
 
   RenderTextHarfBuzz* render_text = GetRenderText();
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Case %" PRIuS, i));
 
     base::string16 text = UTF8ToUTF16(cases[i]);
@@ -3825,7 +3825,7 @@
   RenderTextHarfBuzz* render_text = GetRenderText();
   render_text->SetText(UTF8ToUTF16("abcd"));
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::copy(cases[i].glyph_to_char, cases[i].glyph_to_char + 2,
               run.shape.glyph_to_char.begin());
     run.font_params.is_rtl = cases[i].is_rtl;
@@ -4141,7 +4141,7 @@
                                 "\u0645\u0631\u062D\u0628\u0627"};
   RenderText* render_text = GetRenderText();
 
-  for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+  for (size_t i = 0; i < base::size(kTestStrings); ++i) {
     render_text->SetText(UTF8ToUTF16(kTestStrings[i]));
     test_api()->EnsureLayout();
 
@@ -4875,7 +4875,7 @@
   render_text->SetMultiline(true);
   render_text->SetDisplayRect(Rect(200, 1000));
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     SCOPED_TRACE(base::StringPrintf("Testing case %" PRIuS "", i));
     render_text->SetText(UTF8ToUTF16(cases[i].text));
     test_api()->EnsureLayout();
diff --git a/ui/gfx/shadow_value_unittest.cc b/ui/gfx/shadow_value_unittest.cc
index d93e0967..4cc191c 100644
--- a/ui/gfx/shadow_value_unittest.cc
+++ b/ui/gfx/shadow_value_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/insets.h"
 #include "ui/gfx/geometry/vector2d.h"
@@ -58,7 +58,7 @@
       },
   };
 
-  for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+  for (size_t i = 0; i < base::size(kTestCases); ++i) {
     Insets margin = ShadowValue::GetMargin(
         ShadowValues(kTestCases[i].shadows,
                      kTestCases[i].shadows + kTestCases[i].shadow_count));
diff --git a/ui/gfx/test/icc_profiles.cc b/ui/gfx/test/icc_profiles.cc
index cf60c3b..e38bcf8 100644
--- a/ui/gfx/test/icc_profiles.cc
+++ b/ui/gfx/test/icc_profiles.cc
@@ -4,6 +4,8 @@
 
 #include "ui/gfx/test/icc_profiles.h"
 
+#include "base/stl_util.h"
+
 namespace gfx {
 
 namespace {
@@ -1895,42 +1897,42 @@
 ICCProfile ICCProfileForTestingAdobeRGB() {
   return ICCProfile::FromData(
       reinterpret_cast<const char*>(adobe_rgb_profile_data),
-      arraysize(adobe_rgb_profile_data));
+      base::size(adobe_rgb_profile_data));
 }
 
 ICCProfile ICCProfileForTestingGenericRGB() {
   return ICCProfile::FromData(
       reinterpret_cast<const char*>(generic_rgb_profile_data),
-      arraysize(generic_rgb_profile_data));
+      base::size(generic_rgb_profile_data));
 }
 
 ICCProfile ICCProfileForTestingSRGB() {
   return ICCProfile::FromData(reinterpret_cast<const char*>(srgb_profile_data),
-                              arraysize(srgb_profile_data));
+                              base::size(srgb_profile_data));
 }
 
 ICCProfile ICCProfileForTestingColorSpin() {
   return ICCProfile::FromData(
       reinterpret_cast<const char*>(colorspin_profile_data),
-      arraysize(colorspin_profile_data));
+      base::size(colorspin_profile_data));
 }
 
 ICCProfile ICCProfileForTestingNoAnalyticTrFn() {
   return ICCProfile::FromData(
       reinterpret_cast<const char*>(no_analytic_tr_fn_profile_data),
-      arraysize(no_analytic_tr_fn_profile_data));
+      base::size(no_analytic_tr_fn_profile_data));
 }
 
 ICCProfile ICCProfileForTestingA2BOnly() {
   return ICCProfile::FromData(
       reinterpret_cast<const char*>(a2b_only_profile_data),
-      arraysize(a2b_only_profile_data));
+      base::size(a2b_only_profile_data));
 }
 
 ICCProfile ICCProfileForTestingOvershoot() {
   return ICCProfile::FromData(
       reinterpret_cast<const char*>(overshoot_profile_data),
-      arraysize(overshoot_profile_data));
+      base::size(overshoot_profile_data));
 }
 
 }  // namespace gfx
diff --git a/ui/gfx/text_elider_unittest.cc b/ui/gfx/text_elider_unittest.cc
index 43852b6a..5673d352 100644
--- a/ui/gfx/text_elider_unittest.cc
+++ b/ui/gfx/text_elider_unittest.cc
@@ -13,9 +13,9 @@
 
 #include "base/files/file_path.h"
 #include "base/i18n/rtl.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -104,7 +104,7 @@
   };
 
   const FontList font_list;
-  for (size_t i = 0; i < arraysize(testcases); ++i) {
+  for (size_t i = 0; i < base::size(testcases); ++i) {
     const base::string16 expected_output = UTF8ToUTF16(testcases[i].output);
     EXPECT_EQ(expected_output,
               ElideText(UTF8ToUTF16(testcases[i].input), font_list,
@@ -127,10 +127,10 @@
   };
 
   const FontList font_list;
-  for (size_t i = 0; i < arraysize(test_width_factors); ++i) {
+  for (size_t i = 0; i < base::size(test_width_factors); ++i) {
     const int test_width =
         font_list.GetExpectedTextWidth(test_width_factors[i]);
-    for (size_t j = 0; j < arraysize(test_emails); ++j) {
+    for (size_t j = 0; j < base::size(test_emails); ++j) {
       // Extra space is available: the email should not be elided.
       const base::string16 test_email = UTF8ToUTF16(test_emails[j]);
       EXPECT_EQ(test_email,
@@ -179,7 +179,7 @@
   };
 
   static const FontList font_list;
-  for (size_t i = 0; i < arraysize(testcases); ++i) {
+  for (size_t i = 0; i < base::size(testcases); ++i) {
     base::FilePath filepath(testcases[i].input);
     base::string16 expected = UTF8ToUTF16(testcases[i].output);
     expected = base::i18n::GetDisplayStringInLTRDirectionality(expected);
@@ -207,7 +207,7 @@
     { "Tests", kTestWidth, "Test" },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     base::string16 result = ElideText(UTF8ToUTF16(cases[i].input), font_list,
                                       cases[i].width, TRUNCATE);
     EXPECT_EQ(cases[i].output, UTF16ToUTF8(result));
@@ -233,7 +233,7 @@
     { "Test", kTestWidth, "Test" },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     base::string16 result = ElideText(UTF8ToUTF16(cases[i].input), font_list,
                                       cases[i].width, ELIDE_TAIL);
     EXPECT_EQ(cases[i].output, UTF16ToUTF8(result));
@@ -262,7 +262,7 @@
     { "Test123", kEllipsis23Width, UTF8ToUTF16(kEllipsisStr + "23") },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     base::string16 result = ElideText(UTF8ToUTF16(cases[i].input), font_list,
                                       cases[i].width, ELIDE_HEAD);
     EXPECT_EQ(cases[i].output, result);
@@ -357,7 +357,7 @@
 
   const FontList font_list;
   float ellipsis_width = GetStringWidthF(kEllipsisStr, font_list);
-  for (size_t i = 0; i < arraysize(testcases_end); ++i) {
+  for (size_t i = 0; i < base::size(testcases_end); ++i) {
     // Compare sizes rather than actual contents because if the test fails,
     // output is rather long.
     EXPECT_EQ(testcases_end[i].output.size(),
@@ -382,7 +382,7 @@
      { data_scheme + million_a,          long_string_middle },
   };
 
-  for (size_t i = 0; i < arraysize(testcases_middle); ++i) {
+  for (size_t i = 0; i < base::size(testcases_middle); ++i) {
     // Compare sizes rather than actual contents because if the test fails,
     // output is rather long.
     EXPECT_EQ(testcases_middle[i].output.size(),
@@ -404,7 +404,7 @@
      { data_scheme + hundred_thousand_a, long_string_beginning },
      { data_scheme + million_a,          long_string_beginning },
   };
-  for (size_t i = 0; i < arraysize(testcases_beginning); ++i) {
+  for (size_t i = 0; i < base::size(testcases_beginning); ++i) {
     EXPECT_EQ(testcases_beginning[i].output.size(),
               ElideText(
                   testcases_beginning[i].input, font_list,
@@ -565,7 +565,7 @@
     { "Hello, my name is Tom", 10, true, "Hell...Tom" },
     { "Hello, my name is Tom", 100, false, "Hello, my name is Tom" }
   };
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     base::string16 output;
     EXPECT_EQ(cases[i].result,
               ElideString(UTF8ToUTF16(cases[i].input),
@@ -613,7 +613,7 @@
     { "Te  Te Test", test_width, 3 * line_height, false, "Te|Te|Test" },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::vector<base::string16> lines;
     EXPECT_EQ(cases[i].truncated_y ? INSUFFICIENT_SPACE_VERTICAL : 0,
               ElideRectangleText(UTF8ToUTF16(cases[i].input),
@@ -705,7 +705,7 @@
     { "Test. Test", test_width, line_height * 3, true, false, "Test|.|Test" },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::vector<base::string16> lines;
     const WordWrapBehavior wrap_behavior =
         (cases[i].wrap_words ? WRAP_LONG_WORDS : TRUNCATE_LONG_WORDS);
@@ -771,7 +771,7 @@
     { "TestTestTestT", test_width, WRAP_LONG_WORDS, false, "Test|Test|Test|T" },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     std::vector<base::string16> lines;
     EXPECT_EQ(
         cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0,
@@ -904,7 +904,7 @@
     { "Hi, my name is Tom",  1, 40, false, "Hi, my name is Tom" },
   };
   base::string16 output;
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     EXPECT_EQ(cases[i].result,
               ElideRectangleString(UTF8ToUTF16(cases[i].input),
                                    cases[i].max_rows, cases[i].max_cols,
@@ -986,7 +986,7 @@
     { "Hi, my name_is Dick",  1, 40, false, "Hi, my name_is Dick" },
   };
   base::string16 output;
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     EXPECT_EQ(cases[i].result,
               ElideRectangleString(UTF8ToUTF16(cases[i].input),
                                    cases[i].max_rows, cases[i].max_cols,
diff --git a/ui/gfx/text_utils_unittest.cc b/ui/gfx/text_utils_unittest.cc
index 7cf42c8..cd3a3bf 100644
--- a/ui/gfx/text_utils_unittest.cc
+++ b/ui/gfx/text_utils_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -50,7 +50,7 @@
       "Test\xF0\x9D\x92\x9C\xF0\x9D\x92\x9Cing" },
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     int accelerated_char_pos;
     int accelerated_char_span;
     base::string16 result = RemoveAcceleratorChar(
diff --git a/ui/gfx/transform_unittest.cc b/ui/gfx/transform_unittest.cc
index 6df8868..ee410a3 100644
--- a/ui/gfx/transform_unittest.cc
+++ b/ui/gfx/transform_unittest.cc
@@ -10,7 +10,7 @@
 #include <ostream>
 
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/angle_conversions.h"
@@ -228,7 +228,7 @@
   };
 
   Transform xform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     Transform translation;
     translation.Translate(value.tx, value.ty);
@@ -257,7 +257,7 @@
   };
 
   Transform xform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     Transform scale;
     scale.Scale(value.scale, value.scale);
@@ -288,7 +288,7 @@
   };
 
   Transform xform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     Transform rotation;
     rotation.Rotate(value.degrees);
@@ -317,7 +317,7 @@
       0, 0 }
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     for (int k = 0; k < 3; ++k) {
       Point3F p0, p1, p2;
@@ -364,7 +364,7 @@
     { 1, std::numeric_limits<float>::quiet_NaN(), 0 },
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     for (int k = 0; k < 3; ++k) {
       Point3F p0, p1, p2;
@@ -417,7 +417,7 @@
     { 100, 0, 360.0f, 100, 0 }
   };
 
-  for (size_t i = 0; i < arraysize(set_rotate_cases); ++i) {
+  for (size_t i = 0; i < base::size(set_rotate_cases); ++i) {
     const SetRotateCase& value = set_rotate_cases[i];
     Point3F p0;
     Point3F p1(value.x, value.y, 0);
@@ -451,7 +451,7 @@
   };
 
   Transform xform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     Transform translation;
     translation.Translate(value.tx, value.ty);
@@ -480,7 +480,7 @@
   };
 
   Transform xform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     Transform scale;
     scale.Scale(value.scale, value.scale);
@@ -511,7 +511,7 @@
   };
 
   Transform xform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     Transform rotation;
     rotation.Rotate(value.degrees);
@@ -537,7 +537,7 @@
     { 10, 20, 0.0f, 0.0f, 10, 20},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     for (int j = -1; j < 2; ++j) {
       for (int k = 0; k < 3; ++k) {
@@ -589,7 +589,7 @@
     { 0, 10.0f, 0},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     for (int j = -1; j < 2; ++j) {
       for (int k = 0; k < 3; ++k) {
@@ -650,7 +650,7 @@
     { 100, 0, 360.0f, 100, 0}
   };
 
-  for (size_t i = 0; i < arraysize(set_rotate_cases); ++i) {
+  for (size_t i = 0; i < base::size(set_rotate_cases); ++i) {
     const SetRotateCase& value = set_rotate_cases[i];
     for (int j = 1; j >= -1; --j) {
       float epsilon = 0.1f;
@@ -709,7 +709,7 @@
     Vector3dF(1, 1, 1)
   };
   Transform from;
-  for (size_t index = 0; index < arraysize(axes); ++index) {
+  for (size_t index = 0; index < base::size(axes); ++index) {
     for (int i = -5; i < 15; ++i) {
       Transform to;
       to.RotateAbout(axes[index], 90);
@@ -732,7 +732,7 @@
     Vector3dF(1, 1, 1)
   };
   Transform from;
-  for (size_t index = 0; index < arraysize(axes); ++index) {
+  for (size_t index = 0; index < base::size(axes); ++index) {
     for (int i = -5; i < 15; ++i) {
       Transform to;
       to.RotateAbout(axes[index], 180.0);
@@ -2458,7 +2458,7 @@
   };
 
   Transform transform;
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     transform.MakeIdentity();
     transform.matrix().set(0, 0, value.a);
@@ -2477,7 +2477,7 @@
 
   // Try the same test cases again, but this time make sure that other matrix
   // elements (except perspective) have entries, to test that they are ignored.
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     transform.MakeIdentity();
     transform.matrix().set(0, 0, value.a);
@@ -2505,7 +2505,7 @@
 
   // Try the same test cases again, but this time add perspective which is
   // always assumed to not-preserve axis alignment.
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     const TestCase& value = test_cases[i];
     transform.MakeIdentity();
     transform.matrix().set(0, 0, value.a);
diff --git a/ui/gfx/x/x11_atom_cache.cc b/ui/gfx/x/x11_atom_cache.cc
index 3447421d..7405b88 100644
--- a/ui/gfx/x/x11_atom_cache.cc
+++ b/ui/gfx/x/x11_atom_cache.cc
@@ -12,6 +12,7 @@
 
 #include "base/logging.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 
 namespace {
 
@@ -228,7 +229,7 @@
     "XdndTypeList",
 };
 
-constexpr int kCacheCount = arraysize(kAtomsToCache);
+constexpr int kCacheCount = base::size(kAtomsToCache);
 
 }  // namespace
 
diff --git a/ui/gl/gl_api_unittest.cc b/ui/gl/gl_api_unittest.cc
index b28b76d9..7dc6688 100644
--- a/ui/gl/gl_api_unittest.cc
+++ b/ui/gl/gl_api_unittest.cc
@@ -7,7 +7,7 @@
 #include <memory>
 
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gl/gl_context.h"
 #include "ui/gl/gl_gl_api_implementation.h"
@@ -152,7 +152,7 @@
   };
   static const char* kFakeDisabledExtensions = "GL_ARB_timer_query";
 
-  SetFakeExtensionStrings(kFakeExtensions, arraysize(kFakeExtensions));
+  SetFakeExtensionStrings(kFakeExtensions, base::size(kFakeExtensions));
   InitializeAPI(nullptr);
   EXPECT_TRUE(driver_->ext.b_GL_ARB_timer_query);
 
@@ -173,17 +173,17 @@
     "GL_EXT_4"
   };
 
-  SetFakeExtensionStrings(kFakeExtensions, arraysize(kFakeExtensions));
+  SetFakeExtensionStrings(kFakeExtensions, base::size(kFakeExtensions));
   InitializeAPI(nullptr);
 
-  EXPECT_EQ(arraysize(kFakeExtensions), GetNumExtensions());
-  for (uint32_t i = 0; i < arraysize(kFakeExtensions); ++i) {
+  EXPECT_EQ(base::size(kFakeExtensions), GetNumExtensions());
+  for (uint32_t i = 0; i < base::size(kFakeExtensions); ++i) {
     EXPECT_STREQ(kFakeExtensions[i], GetExtensioni(i));
   }
 
   InitializeAPI(kFakeDisabledExtensions);
-  EXPECT_EQ(arraysize(kFilteredExtensions), GetNumExtensions());
-  for (uint32_t i = 0; i < arraysize(kFilteredExtensions); ++i) {
+  EXPECT_EQ(base::size(kFilteredExtensions), GetNumExtensions());
+  for (uint32_t i = 0; i < base::size(kFilteredExtensions); ++i) {
     EXPECT_STREQ(kFilteredExtensions[i], GetExtensioni(i));
   }
 }
diff --git a/ui/gl/gl_image_io_surface_unittest.cc b/ui/gl/gl_image_io_surface_unittest.cc
index 3ec385e7..e057fecb 100644
--- a/ui/gl/gl_image_io_surface_unittest.cc
+++ b/ui/gl/gl_image_io_surface_unittest.cc
@@ -5,6 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/buffer_format_util.h"
@@ -48,7 +49,7 @@
       corrected_color[2] = color[0];
       corrected_color[3] = color[3];
     } else {
-      memcpy(corrected_color, color, arraysize(corrected_color));
+      memcpy(corrected_color, color, base::size(corrected_color));
     }
 
     for (size_t plane = 0; plane < NumberOfPlanesForBufferFormat(format);
diff --git a/ui/gl/gl_image_native_pixmap.cc b/ui/gl/gl_image_native_pixmap.cc
index 712d8492..24d883ee 100644
--- a/ui/gl/gl_image_native_pixmap.cc
+++ b/ui/gl/gl_image_native_pixmap.cc
@@ -7,6 +7,7 @@
 #include <vector>
 
 #include "base/files/scoped_file.h"
+#include "base/stl_util.h"
 #include "build/build_config.h"
 #include "ui/gfx/buffer_format_util.h"
 #include "ui/gfx/gpu_fence.h"
@@ -193,7 +194,7 @@
       if (has_dma_buf_import_modifier &&
           pixmap->GetDmaBufModifier(0) != gfx::NativePixmapPlane::kNoModifier) {
         uint64_t modifier = pixmap->GetDmaBufModifier(pixmap_plane);
-        DCHECK(attrs_plane < arraysize(kLinuxDrmModifiers));
+        DCHECK(attrs_plane < base::size(kLinuxDrmModifiers));
         attrs.push_back(kLinuxDrmModifiers[attrs_plane]);
         attrs.push_back(modifier & 0xffffffff);
         attrs.push_back(kLinuxDrmModifiers[attrs_plane] + 1);
diff --git a/ui/gl/gl_implementation.cc b/ui/gl/gl_implementation.cc
index ad110e8f..73d3eac 100644
--- a/ui/gl/gl_implementation.cc
+++ b/ui/gl/gl_implementation.cc
@@ -11,7 +11,6 @@
 #include "base/at_exit.h"
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/memory/protected_memory.h"
 #include "base/memory/protected_memory_cfi.h"
 #include "base/stl_util.h"
@@ -111,7 +110,7 @@
 #endif
 
 GLImplementation GetNamedGLImplementation(const std::string& name) {
-  for (size_t i = 0; i < arraysize(kGLImplementationNamePairs); ++i) {
+  for (size_t i = 0; i < base::size(kGLImplementationNamePairs); ++i) {
     if (name == kGLImplementationNamePairs[i].name)
       return kGLImplementationNamePairs[i].implementation;
   }
@@ -124,7 +123,7 @@
 }
 
 const char* GetGLImplementationName(GLImplementation implementation) {
-  for (size_t i = 0; i < arraysize(kGLImplementationNamePairs); ++i) {
+  for (size_t i = 0; i < base::size(kGLImplementationNamePairs); ++i) {
     if (implementation == kGLImplementationNamePairs[i].implementation)
       return kGLImplementationNamePairs[i].name;
   }
diff --git a/ui/gl/gl_switches.cc b/ui/gl/gl_switches.cc
index 9626f9b..5c5d44a 100644
--- a/ui/gl/gl_switches.cc
+++ b/ui/gl/gl_switches.cc
@@ -2,9 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "base/macros.h"
 #include "ui/gl/gl_switches.h"
 
+#include "base/stl_util.h"
+
 namespace gl {
 
 const char kGLImplementationDesktopName[] = "desktop";
@@ -130,7 +131,7 @@
     kDisableDirectCompositionLayers,
 };
 const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches =
-    arraysize(kGLSwitchesCopiedFromGpuProcessHost);
+    base::size(kGLSwitchesCopiedFromGpuProcessHost);
 
 }  // namespace switches
 
diff --git a/ui/keyboard/resources/keyboard_resource_util.cc b/ui/keyboard/resources/keyboard_resource_util.cc
index 73aa3fcd..79e2f9e 100644
--- a/ui/keyboard/resources/keyboard_resource_util.cc
+++ b/ui/keyboard/resources/keyboard_resource_util.cc
@@ -5,8 +5,8 @@
 #include "ui/keyboard/resources/keyboard_resource_util.h"
 
 #include "base/files/file_path.h"
-#include "base/macros.h"
 #include "base/path_service.h"
+#include "base/stl_util.h"
 #include "ui/base/resource/resource_bundle.h"
 #include "ui/keyboard/grit/keyboard_resources.h"
 #include "ui/keyboard/grit/keyboard_resources_map.h"
@@ -93,7 +93,7 @@
       {"keyboard/sounds/keypress-standard.wav",
        IDR_KEYBOARD_SOUNDS_KEYPRESS_STANDARD},
   };
-  *size = arraysize(kKeyboardResources);
+  *size = base::size(kKeyboardResources);
   return kKeyboardResources;
 }
 
diff --git a/ui/latency/histograms.h b/ui/latency/histograms.h
index fba71c1..3d9545b 100644
--- a/ui/latency/histograms.h
+++ b/ui/latency/histograms.h
@@ -8,7 +8,7 @@
 #include <array>
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 
 namespace ui {
 
@@ -19,7 +19,7 @@
 // estimate.
 struct PercentileResults {
   static constexpr double kPercentiles[] = {.50, .99};
-  static constexpr size_t kCount = arraysize(kPercentiles);
+  static constexpr size_t kCount = base::size(kPercentiles);
 
   double values[kCount]{};
 };
diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc
index c0344b43..4b21e43 100644
--- a/ui/native_theme/native_theme_win.cc
+++ b/ui/native_theme/native_theme_win.cc
@@ -12,7 +12,7 @@
 
 #include "base/command_line.h"
 #include "base/logging.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/win/scoped_gdi_object.h"
 #include "base/win/scoped_hdc.h"
 #include "base/win/scoped_select_object.h"
@@ -980,7 +980,7 @@
   if (handle && draw_theme_) {
     int index = part - kScrollbarDownArrow;
     DCHECK_GE(index, 0);
-    DCHECK_LT(static_cast<size_t>(index), arraysize(state_id_matrix));
+    DCHECK_LT(static_cast<size_t>(index), base::size(state_id_matrix));
     int state_id = state_id_matrix[index][state];
 
     // Hovering means that the cursor is over the scroolbar, but not over the
diff --git a/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc b/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc
index b609232..650c59b 100644
--- a/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc
+++ b/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc
@@ -9,7 +9,7 @@
 #include "base/bind.h"
 #include "base/bind_helpers.h"
 #include "base/command_line.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "third_party/skia/include/core/SkCanvas.h"
 #include "third_party/skia/include/core/SkDeferredDisplayListRecorder.h"
@@ -171,7 +171,7 @@
   else
     primary_plane_rect_ = gfx::Rect(size_);
 
-  for (size_t i = 0; i < arraysize(buffers_); ++i) {
+  for (size_t i = 0; i < base::size(buffers_); ++i) {
     buffers_[i].reset(new BufferWrapper());
     if (!buffers_[i]->Initialize(gr_context_.get(), widget_,
                                  primary_plane_rect_.size()))
@@ -180,7 +180,7 @@
 
   if (command_line->HasSwitch(kEnableOverlay)) {
     gfx::Size overlay_size = gfx::Size(size_.width() / 8, size_.height() / 8);
-    for (size_t i = 0; i < arraysize(overlay_buffer_); ++i) {
+    for (size_t i = 0; i < base::size(overlay_buffer_); ++i) {
       overlay_buffer_[i].reset(new BufferWrapper());
       overlay_buffer_[i]->Initialize(gr_context_.get(),
                                      gfx::kNullAcceleratedWidget, overlay_size);
@@ -269,7 +269,7 @@
     std::unique_ptr<gfx::GpuFence> gpu_fence) {
   switch (result) {
     case gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS:
-      for (size_t i = 0; i < arraysize(buffers_); ++i) {
+      for (size_t i = 0; i < base::size(buffers_); ++i) {
         buffers_[i].reset(new BufferWrapper());
         if (!buffers_[i]->Initialize(gr_context_.get(), widget_,
                                      primary_plane_rect_.size()))
diff --git a/ui/ozone/platform/drm/common/drm_util_unittest.cc b/ui/ozone/platform/drm/common/drm_util_unittest.cc
index 5e4e8c9..0bb4600 100644
--- a/ui/ozone/platform/drm/common/drm_util_unittest.cc
+++ b/ui/ozone/platform/drm/common/drm_util_unittest.cc
@@ -9,6 +9,7 @@
 
 #include <map>
 
+#include "base/stl_util.h"
 #include "base/test/metrics/histogram_tester.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkColorSpace.h"
@@ -324,7 +325,7 @@
   SkMatrix44 expected_hpz32x_toXYZ50_matrix;
   expected_hpz32x_primaries.toXYZD50(&expected_hpz32x_toXYZ50_matrix);
   const std::vector<uint8_t> hpz32x_edid(kHPz32x,
-                                         kHPz32x + arraysize(kHPz32x) - 1);
+                                         kHPz32x + base::size(kHPz32x) - 1);
   const gfx::ColorSpace expected_hpz32x_color_space =
       gfx::ColorSpace::CreateCustom(
           expected_hpz32x_toXYZ50_matrix,
@@ -348,7 +349,8 @@
                                                               .fWY = 0.329102f};
   SkMatrix44 expected_samus_toXYZ50_matrix;
   expected_samus_primaries.toXYZD50(&expected_samus_toXYZ50_matrix);
-  const std::vector<uint8_t> samus_edid(kSamus, kSamus + arraysize(kSamus) - 1);
+  const std::vector<uint8_t> samus_edid(kSamus,
+                                        kSamus + base::size(kSamus) - 1);
   const gfx::ColorSpace expected_samus_color_space =
       gfx::ColorSpace::CreateCustom(
           expected_samus_toXYZ50_matrix,
@@ -372,7 +374,7 @@
                                                             .fWY = 0.328125f};
   SkMatrix44 expected_eve_toXYZ50_matrix;
   expected_eve_primaries.toXYZD50(&expected_eve_toXYZ50_matrix);
-  const std::vector<uint8_t> eve_edid(kEve, kEve + arraysize(kEve) - 1);
+  const std::vector<uint8_t> eve_edid(kEve, kEve + base::size(kEve) - 1);
   const gfx::ColorSpace expected_eve_color_space =
       gfx::ColorSpace::CreateCustom(
           expected_eve_toXYZ50_matrix,
@@ -387,7 +389,7 @@
 
   // Test with gamma marked as non-existent.
   const std::vector<uint8_t> no_gamma_edid(
-      kEdidWithNoGamma, kEdidWithNoGamma + arraysize(kEdidWithNoGamma) - 1);
+      kEdidWithNoGamma, kEdidWithNoGamma + base::size(kEdidWithNoGamma) - 1);
   const gfx::ColorSpace no_gamma_color_space =
       GetColorSpaceFromEdid(display::EdidParser(no_gamma_edid));
   EXPECT_FALSE(no_gamma_color_space.IsValid());
@@ -412,7 +414,7 @@
       1);
 
   const std::vector<uint8_t> invalid_edid(
-      kInvalidEdid, kInvalidEdid + arraysize(kInvalidEdid) - 1);
+      kInvalidEdid, kInvalidEdid + base::size(kInvalidEdid) - 1);
   const gfx::ColorSpace invalid_color_space =
       GetColorSpaceFromEdid(display::EdidParser(invalid_edid));
   EXPECT_FALSE(invalid_color_space.IsValid());
@@ -423,7 +425,7 @@
       2);
 
   const std::vector<uint8_t> sst210_edid(kSST210,
-                                         kSST210 + arraysize(kSST210) - 1);
+                                         kSST210 + base::size(kSST210) - 1);
   const gfx::ColorSpace sst210_color_space =
       GetColorSpaceFromEdid(display::EdidParser(sst210_edid));
   EXPECT_FALSE(sst210_color_space.IsValid()) << sst210_color_space.ToString();
@@ -434,7 +436,7 @@
       1);
 
   const std::vector<uint8_t> sst210_edid_2(
-      kSST210Corrected, kSST210Corrected + arraysize(kSST210Corrected) - 1);
+      kSST210Corrected, kSST210Corrected + base::size(kSST210Corrected) - 1);
   const gfx::ColorSpace sst210_color_space_2 =
       GetColorSpaceFromEdid(display::EdidParser(sst210_edid_2));
   EXPECT_FALSE(sst210_color_space_2.IsValid())
@@ -447,7 +449,7 @@
 
   const std::vector<uint8_t> broken_blue_edid(
       kBrokenBluePrimaries,
-      kBrokenBluePrimaries + arraysize(kBrokenBluePrimaries) - 1);
+      kBrokenBluePrimaries + base::size(kBrokenBluePrimaries) - 1);
   const gfx::ColorSpace broken_blue_color_space =
       GetColorSpaceFromEdid(display::EdidParser(broken_blue_edid));
   EXPECT_FALSE(broken_blue_color_space.IsValid())
diff --git a/ui/ozone/platform/drm/gpu/drm_display.cc b/ui/ozone/platform/drm/gpu/drm_display.cc
index 6563246..d476350 100644
--- a/ui/ozone/platform/drm/gpu/drm_display.cc
+++ b/ui/ozone/platform/drm/gpu/drm_display.cc
@@ -6,7 +6,7 @@
 
 #include <xf86drmMode.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "ui/display/types/display_snapshot.h"
 #include "ui/display/types/gamma_ramp_rgb_entry.h"
 #include "ui/ozone/platform/drm/common/drm_util.h"
@@ -33,7 +33,7 @@
 uint32_t GetContentProtectionValue(drmModePropertyRes* property,
                                    display::HDCPState state) {
   std::string name;
-  for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
+  for (size_t i = 0; i < base::size(kContentProtectionStates); ++i) {
     if (kContentProtectionStates[i].state == state) {
       name = kContentProtectionStates[i].name;
       break;
@@ -141,7 +141,7 @@
 
   std::string name =
       GetEnumNameForProperty(connector.get(), hdcp_property.get());
-  for (size_t i = 0; i < arraysize(kContentProtectionStates); ++i) {
+  for (size_t i = 0; i < base::size(kContentProtectionStates); ++i) {
     if (name == kContentProtectionStates[i].name) {
       *state = kContentProtectionStates[i].state;
       VLOG(3) << "HDCP state: " << *state << " (" << name << ")";
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
index 297ff19a..339663cd 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
@@ -10,6 +10,7 @@
 #include <utility>
 
 #include "base/logging.h"
+#include "base/stl_util.h"
 #include "base/trace_event/trace_event.h"
 #include "third_party/libdrm/src/include/drm/drm_fourcc.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -356,7 +357,7 @@
   gfx::Size max_cursor_size = GetMaximumCursorSize(GetDrmDevice()->get_fd());
   SkImageInfo info = SkImageInfo::MakeN32Premul(max_cursor_size.width(),
                                                 max_cursor_size.height());
-  for (size_t i = 0; i < arraysize(cursor_buffers_); ++i) {
+  for (size_t i = 0; i < base::size(cursor_buffers_); ++i) {
     cursor_buffers_[i] = std::make_unique<DrmDumbBuffer>(GetDrmDevice());
     // Don't register a framebuffer for cursors since they are special (they
     // aren't modesetting buffers and drivers may fail to register them due to
diff --git a/ui/shell_dialogs/select_file_dialog_mac_unittest.mm b/ui/shell_dialogs/select_file_dialog_mac_unittest.mm
index 7b15ec2..e6a99e4 100644
--- a/ui/shell_dialogs/select_file_dialog_mac_unittest.mm
+++ b/ui/shell_dialogs/select_file_dialog_mac_unittest.mm
@@ -9,8 +9,8 @@
 #include "base/files/file_util.h"
 #import "base/mac/foundation_util.h"
 #include "base/mac/mac_util.h"
-#include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/sys_string_conversions.h"
 #include "base/strings/utf_string_conversions.h"
@@ -382,7 +382,7 @@
        HAS_ACCESSORY_VIEW | PICK_FILES | MULTIPLE_SELECTION, "Open"},
   };
 
-  for (size_t i = 0; i < arraysize(test_cases); i++) {
+  for (size_t i = 0; i < base::size(test_cases); i++) {
     SCOPED_TRACE(
         base::StringPrintf("i=%lu file_dialog_type=%d", i, test_cases[i].type));
     args.type = test_cases[i].type;
diff --git a/ui/shell_dialogs/select_file_dialog_unittest.cc b/ui/shell_dialogs/select_file_dialog_unittest.cc
index e283186..57d5f5f 100644
--- a/ui/shell_dialogs/select_file_dialog_unittest.cc
+++ b/ui/shell_dialogs/select_file_dialog_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/shell_dialogs/select_file_dialog.h"
 
@@ -101,7 +101,7 @@
                          "jklmnopqrstuvwxyz1234abcdefghijklmnopqrstuvwxyz1234ab"
                          "cdefghijklmnopqrstuvwxyz1234ab.abcdefghijkl")}};
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     base::FilePath input =
         base::FilePath(test_cases[i].input).NormalizePathSeparators();
     base::FilePath output =
diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn
index 6a13dfb..361ce56 100644
--- a/ui/views/BUILD.gn
+++ b/ui/views/BUILD.gn
@@ -7,8 +7,6 @@
 import("//build/config/jumbo.gni")
 import("//build/config/ui.gni")
 import("//components/vector_icons/vector_icons.gni")
-import("//services/catalog/public/tools/catalog.gni")
-import("//services/service_manager/public/service_manifest.gni")
 import("//testing/test.gni")
 import("//ui/base/ui_features.gni")
 import("//ui/ozone/ozone.gni")
@@ -804,7 +802,7 @@
   }
 }
 
-jumbo_source_set("test_support") {
+jumbo_source_set("test_support_internal") {
   testonly = true
   sources = [
     "animation/test/flood_fill_ink_drop_ripple_test_api.cc",
@@ -845,11 +843,7 @@
     "test/menu_runner_test_api.h",
     "test/menu_test_utils.cc",
     "test/menu_test_utils.h",
-    "test/native_widget_factory.cc",
     "test/native_widget_factory.h",
-    "test/platform_test_helper.cc",
-    "test/platform_test_helper.h",
-    "test/platform_test_helper_cocoa.mm",
     "test/scoped_views_test_helper.cc",
     "test/scoped_views_test_helper.h",
     "test/slider_test_api.cc",
@@ -884,10 +878,15 @@
     "views_test_suite.h",
   ]
 
+  # External code should depend upon "test_support".
+  visibility = [ "./*" ]
+
   configs += [ "//build/config:precompiled_headers" ]
 
-  deps = [
+  public_deps = [
     ":views",
+  ]
+  deps = [
     "//base",
     "//base/test:test_support",
     "//gpu/ipc/service",
@@ -909,32 +908,11 @@
     "//ui/gl:test_support",
   ]
 
-  if (enable_mus) {
-    sources += [
-      "test/platform_test_helper_mus.cc",
-      "test/platform_test_helper_mus.h",
-    ]
-
-    deps += [
-      ":views_unittests_catalog_source",
-      "//services/catalog:lib",
-      "//services/service_manager/background:lib",
-      "//services/service_manager/public/cpp",
-      "//services/service_manager/public/mojom",
-      "//services/ws/common",
-      "//testing/gtest",
-      "//ui/compositor:test_support",
-      "//ui/gl:test_support",
-      "//ui/resources",
-      "//ui/resources:ui_test_pak",
-    ]
-
-    data_deps = [
-      ":views_unittests_catalog",
-      "//services/ws/ime/test_ime_driver",
-      "//ui/resources:ui_test_pak_data",
-    ]
-  }
+  sources += [
+    "test/platform_test_helper.cc",
+    "test/platform_test_helper.h",
+    "test/platform_test_helper_cocoa.mm",
+  ]
 
   if (use_aura) {
     sources += [
@@ -980,7 +958,21 @@
   }
 }
 
-test("views_unittests") {
+jumbo_static_library("test_support") {
+  testonly = true
+  public_deps = [
+    ":test_support_internal",
+  ]
+  sources = [
+    "test/native_widget_factory_desktop.cc",
+  ]
+}
+
+# This target contains the unit tests that are shared between views_unittests
+# and views_mus_unittests.
+source_set("views_unittests_sources") {
+  testonly = true
+
   sources = [
     "accessible_pane_view_unittest.cc",
     "animation/bounds_animator_unittest.cc",
@@ -1035,7 +1027,6 @@
     "controls/table/test_table_model.cc",
     "controls/table/test_table_model.h",
     "controls/textfield/textfield_model_unittest.cc",
-    "controls/textfield/textfield_unittest.cc",
     "controls/tree/tree_view_unittest.cc",
     "event_monitor_unittest.cc",
     "focus/focus_manager_unittest.cc",
@@ -1046,7 +1037,6 @@
     "layout/grid_layout_unittest.cc",
     "paint_info_unittest.cc",
     "rect_based_targeting_utils_unittest.cc",
-    "run_all_unittests_main.cc",
     "selection_controller_unittest.cc",
     "test/widget_test_unittest.cc",
     "view_model_unittest.cc",
@@ -1056,7 +1046,6 @@
     "view_unittest.cc",
     "view_unittest_mac.mm",
     "widget/ax_native_widget_mac_unittest.mm",
-    "widget/desktop_widget_unittest.cc",
     "widget/native_widget_mac_unittest.mm",
     "widget/native_widget_unittest.cc",
     "widget/root_view_unittest.cc",
@@ -1072,8 +1061,10 @@
 
   configs += [ "//build/config:precompiled_headers" ]
 
-  deps = [
-    ":test_support",
+  # Make all deps in this target public so both views_unittests and
+  # views_mus_unittests will get them.
+  public_deps = [
+    ":test_support_internal",
     ":views",
     "//base",
     "//base:i18n",
@@ -1082,7 +1073,6 @@
     "//cc/paint",
     "//components/vector_icons",
     "//components/viz/common",
-    "//mojo/core/embedder",
     "//services/ws/public/mojom",
     "//skia",
     "//testing/gtest",
@@ -1101,7 +1091,6 @@
     "//ui/gl:test_support",
     "//ui/native_theme",
     "//ui/native_theme:test_support",
-    "//ui/platform_window/platform_window_handler",
     "//ui/resources",
     "//ui/resources:ui_test_pak",
     "//ui/strings",
@@ -1112,29 +1101,8 @@
     "//ui/resources:ui_test_pak_data",
   ]
 
-  if (enable_mus) {
-    sources += [
-      "mus/ax_remote_host_unittest.cc",
-      "mus/ax_tree_source_mus_unittest.cc",
-      "mus/desktop_window_tree_host_mus_unittest.cc",
-      "mus/screen_mus_unittest.cc",
-    ]
-
-    deps += [
-      "//services/ws/test_ws:mojom",
-      "//ui/accessibility/mojom",
-      "//ui/views/mus",
-      "//ui/views/mus/remote_view:tests",
-    ]
-
-    data_deps += [
-      "//services/ws/ime/test_ime_driver",
-      "//services/ws/test_ws",
-    ]
-  }
-
   if (is_win) {
-    public_deps = [
+    public_deps += [
       "//build/win:default_exe_manifest",
       "//third_party/iaccessible2",
       "//third_party/wtl",
@@ -1152,12 +1120,22 @@
     ]
   }
 
-  if (is_mac) {
-    # views_unittests not yet compiling on Mac. http://crbug.com/378134
-    sources -= [ "controls/native/native_view_host_unittest.cc" ]
-    public_deps = [
-      "//ui/accelerated_widget_mac",
-      "//ui/views_bridge_mac:views_bridge_mac",
+  if (has_native_accessibility) {
+    sources += [
+      "accessibility/ax_virtual_view_unittest.cc",
+      "accessibility/view_ax_platform_node_delegate_unittest.cc",
+    ]
+  }
+
+  if (use_x11) {
+    configs += [
+      "//build/config/linux:x11",
+      "//build/config/linux:xext",
+    ]
+    public_deps += [
+      "//ui/events/devices",
+      "//ui/events/platform/x11",
+      "//ui/gfx/x",
     ]
   }
 
@@ -1168,15 +1146,11 @@
       "accessibility/ax_tree_source_views_unittest.cc",
       "controls/native/native_view_host_aura_unittest.cc",
       "corewm/tooltip_controller_unittest.cc",
-      "touchui/touch_selection_controller_impl_unittest.cc",
       "touchui/touch_selection_menu_runner_views_unittest.cc",
       "view_unittest_aura.cc",
-      "widget/desktop_aura/desktop_focus_rules_unittest.cc",
-      "widget/desktop_aura/desktop_native_widget_aura_unittest.cc",
-      "widget/native_widget_aura_unittest.cc",
       "widget/window_reorderer_unittest.cc",
     ]
-    deps += [
+    public_deps += [
       "//ui/accessibility:test_support",
       "//ui/aura",
       "//ui/aura:test_support",
@@ -1184,39 +1158,73 @@
       "//ui/wm",
       "//ui/wm/public",
     ]
+  }
+
+  if (is_mac) {
+    # views_unittests not yet compiling on Mac. http://crbug.com/378134
+    sources -= [ "controls/native/native_view_host_unittest.cc" ]
+    public_deps += [
+      "//ui/accelerated_widget_mac",
+      "//ui/views_bridge_mac:views_bridge_mac",
+    ]
+  }
+}
+
+test("views_unittests") {
+  sources = [
+    "run_all_unittests_main.cc",
+
+    # EventGenerator doesn't work well with IME in mus so this must not be in
+    # the shared unit test sources.
+    # crbug.com/615033 crbug.com/548407
+    "controls/textfield/textfield_unittest.cc",
+  ]
+
+  if (use_aura) {
+    sources += [
+      # These tests are expecting a hierarchy as created by classic ash. They
+      # are only useful for views_unittests, and not in views_mus_unittests.
+      "touchui/touch_selection_controller_impl_unittest.cc",
+      "widget/native_widget_aura_unittest.cc",
+    ]
 
     if (is_mac) {
       # views_unittests not yet compiling on Mac. http://crbug.com/378134
       sources -= [ "widget/window_reorderer_unittest.cc" ]
     }
 
-    if (use_x11) {
-      configs += [
-        "//build/config/linux:x11",
-        "//build/config/linux:xext",
-      ]
-      deps += [
-        "//ui/events/devices",
-        "//ui/events/platform/x11",
-        "//ui/gfx/x",
-      ]
-    }
-
     if (!is_chromeos) {
+      sources += [
+        "widget/desktop_aura/desktop_focus_rules_unittest.cc",
+        "widget/desktop_aura/desktop_native_widget_aura_unittest.cc",
+      ]
       if (use_x11) {
         sources += [
           "widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc",
           "widget/desktop_aura/desktop_screen_x11_unittest.cc",
           "widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc",
         ]
-      } else if (is_linux) {
-        sources += [
-          "widget/desktop_aura/desktop_drag_drop_client_ozone_unittest.cc",
-          "widget/desktop_aura/desktop_window_tree_host_platform_unittest.cc",
-        ]
       }
     }
   }
+
+  if (is_linux && !is_chromeos && !use_x11) {
+    sources += [
+      "widget/desktop_aura/desktop_drag_drop_client_ozone_unittest.cc",
+      "widget/desktop_aura/desktop_window_tree_host_platform_unittest.cc",
+    ]
+  }
+
+  if (!is_chromeos) {
+    sources += [ "widget/desktop_widget_unittest.cc" ]
+  }
+
+  deps = [
+    ":test_support",
+    ":views_unittests_sources",
+    "//mojo/core/embedder",
+    "//ui/platform_window/platform_window_handler",
+  ]
 }
 
 # This target is added as a dependency of browser interactive_ui_tests. It must
@@ -1291,28 +1299,6 @@
   if (is_chromeos) {
     sources -= [ "corewm/desktop_capture_controller_unittest.cc" ]
   }
-
-  if (enable_mus) {
-    sources += [
-      "mus/clipboard_unittest.cc",
-      "mus/drag_interactive_uitest.cc",
-    ]
-
-    deps += [
-      "//mojo/core/embedder",
-      "//services/ws/public/mojom",
-      "//testing/gmock",
-      "//ui/base/ime",
-      "//ui/base/mojo:lib",
-      "//ui/events:events_base",
-      "//ui/touch_selection",
-      "//ui/views/mus",
-    ]
-
-    data_deps = [
-      "//services/ws/test_ws",
-    ]
-  }
 }
 
 test("views_perftests") {
@@ -1323,7 +1309,6 @@
 
   deps = [
     ":test_support",
-    ":views",
     "//base/test:test_support",
     "//cc/base:base",
     "//mojo/core/embedder",
@@ -1336,35 +1321,3 @@
     "//testing:run_perf_test",
   ]
 }
-
-if (enable_mus) {
-  service_manifest("unittests_manifest") {
-    name = "views_unittests"
-    source = "unittests_manifest.json"
-  }
-
-  service_manifest("interactive_ui_tests_manifest") {
-    name = "interactive_ui_tests"
-    source = "interactive_ui_tests_manifest.json"
-  }
-
-  catalog("views_unittests_catalog") {
-    testonly = true
-
-    embedded_services = [
-      ":unittests_manifest",
-      ":interactive_ui_tests_manifest",
-    ]
-
-    standalone_services = [
-      "//services/ws/test_ws:manifest",
-      "//services/ws/ime/test_ime_driver:manifest",
-    ]
-  }
-
-  catalog_cpp_source("views_unittests_catalog_source") {
-    testonly = true
-    catalog = ":views_unittests_catalog"
-    generated_function_name = "views::CreateViewsUnittestsCatalog"
-  }
-}
diff --git a/ui/views/DEPS b/ui/views/DEPS
index f594d804d..b16a04d 100644
--- a/ui/views/DEPS
+++ b/ui/views/DEPS
@@ -38,14 +38,6 @@
   "views_perftests\.cc": [
     "+mojo/core/embedder",
   ],
-  "views_test_base\.cc": [
-    "+mojo/core/embedder",
-    "+services/catalog",
-    "+services/service_manager/background",
-    "+services/service_manager/public",
-    "+services/ws",
-    "+ui/gl",
-  ],
   "view_unittest\.cc": [
     "+cc/playback",
     "+components/viz/common",
diff --git a/ui/views/OWNERS b/ui/views/OWNERS
index 9ebfacd..57c9ed66 100644
--- a/ui/views/OWNERS
+++ b/ui/views/OWNERS
@@ -13,9 +13,4 @@
 # If you're doing structural changes get a review from one of the OWNERS.
 per-file BUILD.gn=*
 
-per-file interactive_ui_tests_manifest.json=set noparent
-per-file interactive_ui_tests_manifest.json=file://ipc/SECURITY_OWNERS
-per-file unittests_manifest.json=set noparent
-per-file unittests_manifest.json=file://ipc/SECURITY_OWNERS
-
 # COMPONENT: Internals>Views
diff --git a/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc b/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc
index 2060c8e..aa9e497 100644
--- a/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc
+++ b/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc
@@ -7,16 +7,20 @@
 #include <wrl/client.h>
 
 #include "base/macros.h"
+#include "base/path_service.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/win/scoped_variant.h"
+#include "mojo/core/embedder/embedder.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_tree_host.h"
 #include "ui/base/ime/input_method.h"
 #include "ui/base/ime/text_edit_commands.h"
 #include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
 #include "ui/gfx/geometry/rect.h"
 #include "ui/gfx/native_widget_types.h"
+#include "ui/gl/test/gl_surface_test_support.h"
 #include "ui/views/controls/button/label_button.h"
 #include "ui/views/controls/textfield/textfield.h"
 #include "ui/views/controls/textfield/textfield_test_api.h"
@@ -27,16 +31,21 @@
 
 namespace {
 
-class AXSystemCaretWinTest : public test::DesktopWidgetTest {
+class AXSystemCaretWinTest : public test::WidgetTest {
  public:
   AXSystemCaretWinTest() : self_(CHILDID_SELF) {}
   ~AXSystemCaretWinTest() override {}
 
   void SetUp() override {
-    SetUpForInteractiveTests();
-    test::DesktopWidgetTest::SetUp();
+    mojo::core::Init();
+    gl::GLSurfaceTestSupport::InitializeOneOff();
+    ui::RegisterPathProvider();
+    base::FilePath ui_test_pak_path;
+    ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+    ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+    test::WidgetTest::SetUp();
 
-    widget_ = CreateTopLevelNativeWidget();
+    widget_ = CreateNativeDesktopWidget();
     widget_->SetBounds(gfx::Rect(0, 0, 200, 200));
     textfield_ = new Textfield();
     textfield_->SetBounds(0, 0, 200, 20);
@@ -54,7 +63,7 @@
 
   void TearDown() override {
     widget_->CloseNow();
-    test::DesktopWidgetTest::TearDown();
+    test::WidgetTest::TearDown();
     ui::ResourceBundle::CleanupSharedInstance();
   }
 
diff --git a/ui/views/accessible_pane_view_unittest.cc b/ui/views/accessible_pane_view_unittest.cc
index e0bc5ea6..f8e88ebf 100644
--- a/ui/views/accessible_pane_view_unittest.cc
+++ b/ui/views/accessible_pane_view_unittest.cc
@@ -137,17 +137,19 @@
   EXPECT_EQ(test_view_bar->child_button(),
             test_view_bar->GetWidget()->GetFocusManager()->GetFocusedView());
 
-  // Deactivate() is only reliable on Ash. On Windows it uses
-  // ::GetNextWindow() to simply activate another window, and which one is not
-  // predictable. On Mac, Deactivate() is not implemented. Note that
-  // TestBarView calls set_allow_deactivate_on_esc(true), which is only
-  // otherwise used in Ash.
+  if (!IsMus()) {
+    // Deactivate() is only reliable on Ash. On Windows it uses
+    // ::GetNextWindow() to simply activate another window, and which one is not
+    // predictable. On Mac, Deactivate() is not implemented. Note that
+    // TestBarView calls set_allow_deactivate_on_esc(true), which is only
+    // otherwise used in Ash.
 #if !defined(OS_MACOSX) || defined(OS_CHROMEOS)
-  // Esc should deactivate the widget.
-  test_view_bar->AcceleratorPressed(test_view_bar->escape_key());
-  EXPECT_TRUE(widget_main->IsActive());
-  EXPECT_FALSE(widget_bar->IsActive());
+    // Esc should deactivate the widget.
+    test_view_bar->AcceleratorPressed(test_view_bar->escape_key());
+    EXPECT_TRUE(widget_main->IsActive());
+    EXPECT_FALSE(widget_bar->IsActive());
 #endif
+  }
 
   widget_bar->CloseNow();
   widget_bar.reset();
diff --git a/ui/views/animation/ink_drop_impl_unittest.cc b/ui/views/animation/ink_drop_impl_unittest.cc
index dbe46ff2..d5d6ecf 100644
--- a/ui/views/animation/ink_drop_impl_unittest.cc
+++ b/ui/views/animation/ink_drop_impl_unittest.cc
@@ -252,6 +252,13 @@
 
 TEST_F(InkDropImplTest,
        SettingHighlightStateDuringStateExitIsntAllowedDeathTest) {
+  // gtest death tests, such as EXPECT_DCHECK_DEATH(), can not work in the
+  // presence of fork() and other process launching. In views-mus, we have
+  // already launched additional processes for our service manager. Performing
+  // this test under mus is impossible.
+  if (PlatformTestHelper::IsMus())
+    return;
+
   ::testing::FLAGS_gtest_death_test_style = "threadsafe";
 
   test::InkDropImplTestApi::SetStateOnExitHighlightState::Install(
diff --git a/ui/views/animation/square_ink_drop_ripple_unittest.cc b/ui/views/animation/square_ink_drop_ripple_unittest.cc
index cffabb85..eb57c1be 100644
--- a/ui/views/animation/square_ink_drop_ripple_unittest.cc
+++ b/ui/views/animation/square_ink_drop_ripple_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/time/time.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/gfx/geometry/point.h"
@@ -159,7 +159,7 @@
        gfx::Point(0, 0), gfx::Point(0, -kHalfTransformedSize),
        gfx::Point(0, kHalfTransformedSize)}};
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     PaintedShape shape = test_cases[i].shape;
     SCOPED_TRACE(testing::Message() << "i=" << i << " shape=" << shape);
     gfx::Transform transform = transforms_[shape];
@@ -222,7 +222,7 @@
        gfx::Point(x_offset, 0), gfx::Point(0, -kHalfTransformedSize),
        gfx::Point(0, kHalfTransformedSize)}};
 
-  for (size_t i = 0; i < arraysize(test_cases); ++i) {
+  for (size_t i = 0; i < base::size(test_cases); ++i) {
     PaintedShape shape = test_cases[i].shape;
     SCOPED_TRACE(testing::Message() << "i=" << i << " shape=" << shape);
     gfx::Transform transform = transforms_[shape];
diff --git a/ui/views/bubble/bubble_border_unittest.cc b/ui/views/bubble/bubble_border_unittest.cc
index f4f1c9082..94e5abc7 100644
--- a/ui/views/bubble/bubble_border_unittest.cc
+++ b/ui/views/bubble/bubble_border_unittest.cc
@@ -8,7 +8,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "ui/gfx/canvas.h"
 #include "ui/gfx/geometry/rect.h"
@@ -281,7 +281,7 @@
       {BubbleBorder::NONE, kMediumSize, kMediumNoArrow},
       {BubbleBorder::FLOAT, kMediumSize, kMediumNoArrow}};
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("i=%d arrow=%d",
         static_cast<int>(i), cases[i].arrow));
 
@@ -355,7 +355,7 @@
          kAnchor.y() + (kAnchor.height() - kTotalSize.height()) / 2},
     };
 
-    for (size_t i = 0; i < arraysize(cases); ++i) {
+    for (size_t i = 0; i < base::size(cases); ++i) {
       SCOPED_TRACE(base::StringPrintf("shadow=%d i=%d arrow=%d",
                                       static_cast<int>(shadow),
                                       static_cast<int>(i), cases[i].arrow));
diff --git a/ui/views/bubble/bubble_dialog_delegate_view_unittest.cc b/ui/views/bubble/bubble_dialog_delegate_view_unittest.cc
index dd72bf4f8..5b2313f 100644
--- a/ui/views/bubble/bubble_dialog_delegate_view_unittest.cc
+++ b/ui/views/bubble/bubble_dialog_delegate_view_unittest.cc
@@ -7,7 +7,7 @@
 #include <stddef.h>
 
 #include "base/i18n/rtl.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/base/hit_test.h"
 #include "ui/events/event_utils.h"
@@ -279,7 +279,7 @@
       {0, HTNOWHERE}, {60, HTCLIENT}, {1000, HTNOWHERE},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     gfx::Point point(cases[i].point, cases[i].point);
     EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point))
         << " at point " << cases[i].point;
diff --git a/ui/views/cocoa/bridged_native_widget_interactive_uitest.mm b/ui/views/cocoa/bridged_native_widget_interactive_uitest.mm
index 618c3cf..86170122 100644
--- a/ui/views/cocoa/bridged_native_widget_interactive_uitest.mm
+++ b/ui/views/cocoa/bridged_native_widget_interactive_uitest.mm
@@ -16,6 +16,7 @@
 #import "ui/base/test/windowed_nsnotification_observer.h"
 #import "ui/events/test/cocoa_test_event_utils.h"
 #include "ui/views/cocoa/bridged_native_widget_host_impl.h"
+#include "ui/views/test/views_interactive_ui_test_base.h"
 #include "ui/views/test/widget_test.h"
 #include "ui/views/widget/native_widget_mac.h"
 #include "ui/views/window/native_frame_view.h"
@@ -40,15 +41,14 @@
 
 }  // namespace
 
-class BridgedNativeWidgetUITest : public WidgetTest {
+class BridgedNativeWidgetUITest : public test::WidgetTest {
  public:
   BridgedNativeWidgetUITest() = default;
 
   // testing::Test:
   void SetUp() override {
-    SetUpForInteractiveTests();
+    ViewsInteractiveUITestBase::InteractiveSetUp();
     WidgetTest::SetUp();
-
     Widget::InitParams init_params =
         CreateParams(Widget::InitParams::TYPE_WINDOW);
     init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
diff --git a/ui/views/controls/button/menu_button_unittest.cc b/ui/views/controls/button/menu_button_unittest.cc
index f310447..8239400 100644
--- a/ui/views/controls/button/menu_button_unittest.cc
+++ b/ui/views/controls/button/menu_button_unittest.cc
@@ -384,6 +384,12 @@
 
 // Test that the MenuButton stays pressed while there are any PressedLocks.
 TEST_F(MenuButtonTest, ButtonStateForMenuButtonsWithPressedLocks) {
+  // Similarly for aura-mus-client the location of the cursor is not updated by
+  // EventGenerator so that IsMouseHovered() checks the wrong thing.
+  // https://crbug.com/615033.
+  if (IsMus())
+    return;
+
   CreateMenuButtonWithNoListener();
 
   // Move the mouse over the button; the button should be in a hovered state.
@@ -572,6 +578,10 @@
 // Tests that the MenuButton does not become pressed if it can be dragged, and a
 // DragDropClient is processing the events.
 TEST_F(MenuButtonTest, DraggableMenuButtonDoesNotActivateOnDrag) {
+  // TODO(https://crbug.com/663809): test uses GetContext(), which is not
+  // applicable to aura-mus.
+  if (IsMus())
+    return;
   TestMenuButtonListener menu_button_listener;
   CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
   TestDragController drag_controller;
@@ -596,6 +606,11 @@
 // Tests if the listener is notified correctly when a gesture tap happens on a
 // MenuButton that has a MenuButtonListener.
 TEST_F(MenuButtonTest, ActivateDropDownOnGestureTap) {
+  // Similarly for aura-mus-client the location of the cursor is not updated by
+  // EventGenerator so that IsMouseHovered() checks the wrong thing.
+  // https://crbug.com/615033.
+  if (IsMus())
+    return;
   TestMenuButtonListener menu_button_listener;
   CreateMenuButtonWithMenuButtonListener(&menu_button_listener);
 
diff --git a/ui/views/controls/menu/menu_controller_unittest.cc b/ui/views/controls/menu/menu_controller_unittest.cc
index 5f402b7..8cce8de 100644
--- a/ui/views/controls/menu/menu_controller_unittest.cc
+++ b/ui/views/controls/menu/menu_controller_unittest.cc
@@ -1712,6 +1712,11 @@
 // This tests that mouse moved events from the initial position of the mouse
 // when the menu was shown don't select the menu item at the mouse position.
 TEST_F(MenuControllerTest, MouseAtMenuItemOnShow) {
+  // aura::Window::MoveCursorTo check fails in Mus due to null
+  // window_manager_client_.
+  if (IsMus())
+    return;
+
   // Most tests create an already shown menu but this test needs one that's
   // not shown, so it can show it. The mouse position is remembered when
   // the menu is shown.
diff --git a/ui/views/controls/menu/menu_runner_unittest.cc b/ui/views/controls/menu/menu_runner_unittest.cc
index a5972e65..577c4cc 100644
--- a/ui/views/controls/menu/menu_runner_unittest.cc
+++ b/ui/views/controls/menu/menu_runner_unittest.cc
@@ -148,6 +148,11 @@
 // Tests that when a menu is run asynchronously, key events are handled properly
 // by testing that Escape key closes the menu.
 TEST_F(MenuRunnerTest, AsynchronousKeyEventHandling) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   InitMenuRunner(0);
   MenuRunner* runner = menu_runner();
   runner->RunMenuAt(owner(), nullptr, gfx::Rect(), MENU_ANCHOR_TOPLEFT,
@@ -165,6 +170,11 @@
 // Tests that a key press on a US keyboard layout activates the correct menu
 // item.
 TEST_F(MenuRunnerTest, LatinMnemonic) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   // Menus that use prefix selection don't support mnemonics - the input is
   // always part of the prefix.
   if (MenuConfig::instance().all_menus_use_prefix_selection)
@@ -191,6 +201,11 @@
 // Tests that a key press on a non-US keyboard layout activates the correct menu
 // item. Disabled on Windows because a WM_CHAR event does not activate an item.
 TEST_F(MenuRunnerTest, NonLatinMnemonic) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   // Menus that use prefix selection don't support mnemonics - the input is
   // always part of the prefix.
   if (MenuConfig::instance().all_menus_use_prefix_selection)
@@ -355,7 +370,8 @@
   std::unique_ptr<ui::test::EventGenerator> EventGeneratorForWidget(
       Widget* widget) {
     return std::make_unique<ui::test::EventGenerator>(
-        GetContext(), widget->GetNativeWindow());
+        IsMus() ? GetRootWindow(widget) : GetContext(),
+        widget->GetNativeWindow());
   }
 
   void AddMenuLauncherEventHandler(Widget* widget) {
diff --git a/ui/views/controls/native/native_view_host_aura_unittest.cc b/ui/views/controls/native/native_view_host_aura_unittest.cc
index c4d7e71b..6eeaf9b5 100644
--- a/ui/views/controls/native/native_view_host_aura_unittest.cc
+++ b/ui/views/controls/native/native_view_host_aura_unittest.cc
@@ -338,12 +338,18 @@
 
   DestroyHost();
   DestroyTopLevel();
-  // The window is detached, so no longer associated with any Widget
-  // hierarchy. The root window still owns it, but the test harness checks
-  // for orphaned windows during TearDown().
-  EXPECT_EQ(0u, test_observer.events().size())
-      << (*test_observer.events().begin()).type;
-  delete child_win;
+  if (!IsMus()) {
+    // The window is detached, so no longer associated with any Widget
+    // hierarchy. The root window still owns it, but the test harness checks
+    // for orphaned windows during TearDown().
+    EXPECT_EQ(0u, test_observer.events().size())
+        << (*test_observer.events().begin()).type;
+    delete child_win;
+  } else {
+    // In mus and aura-mus, the child window is still attached to the
+    // aura::WindowTreeHost for the Widget. So destroying the toplevel Widget
+    // takes down the child window with it.
+  }
 
   ASSERT_EQ(1u, test_observer.events().size());
   EXPECT_EQ(NativeViewHostWindowObserver::EVENT_DESTROYED,
diff --git a/ui/views/controls/scrollbar/cocoa_scroll_bar.mm b/ui/views/controls/scrollbar/cocoa_scroll_bar.mm
index 05431a3..0659d09c 100644
--- a/ui/views/controls/scrollbar/cocoa_scroll_bar.mm
+++ b/ui/views/controls/scrollbar/cocoa_scroll_bar.mm
@@ -5,6 +5,7 @@
 #import "ui/views/controls/scrollbar/cocoa_scroll_bar.h"
 
 #import "base/mac/sdk_forward_declarations.h"
+#include "base/stl_util.h"
 #include "cc/paint/paint_shader.h"
 #include "third_party/skia/include/core/SkColor.h"
 #include "third_party/skia/include/effects/SkGradientShader.h"
@@ -259,7 +260,7 @@
   cc::PaintFlags gradient;
   gradient.setShader(cc::PaintShader::MakeLinearGradient(
       gradient_bounds, kScrollerTrackGradientColors, nullptr,
-      arraysize(kScrollerTrackGradientColors), SkShader::kClamp_TileMode));
+      base::size(kScrollerTrackGradientColors), SkShader::kClamp_TileMode));
   canvas->DrawRect(track_rect, gradient);
 
   // Draw the inner border: top if horizontal, left if vertical.
diff --git a/ui/views/controls/textfield/textfield_model_unittest.cc b/ui/views/controls/textfield/textfield_model_unittest.cc
index 60884ff..75d45261 100644
--- a/ui/views/controls/textfield/textfield_model_unittest.cc
+++ b/ui/views/controls/textfield/textfield_model_unittest.cc
@@ -10,7 +10,7 @@
 #include <vector>
 
 #include "base/auto_reset.h"
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -1881,9 +1881,9 @@
 
   TextfieldModel model(nullptr);
 
-  EXPECT_EQ(all_tests.size(), arraysize(test_strings));
+  EXPECT_EQ(all_tests.size(), base::size(test_strings));
 
-  for (size_t i = 0; i < arraysize(test_strings); i++) {
+  for (size_t i = 0; i < base::size(test_strings); i++) {
     for (size_t j = 0; j < all_tests[i].size(); j++) {
       SCOPED_TRACE(testing::Message() << "Testing case " << i << ", " << j
                                       << " with string " << test_strings[i]);
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index fd456eff..e1c60d4e 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -15,8 +15,8 @@
 #include "base/command_line.h"
 #include "base/format_macros.h"
 #include "base/i18n/rtl.h"
-#include "base/macros.h"
 #include "base/pickle.h"
+#include "base/stl_util.h"
 #include "base/strings/string16.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -1245,7 +1245,7 @@
   InitTextfield();
   // [Ctrl] ([Alt] on Mac) + [Delete]/[Backspace] should delete the active
   // selection, regardless of [Shift].
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     SCOPED_TRACE(base::StringPrintf("Testing cases[%" PRIuS "]", i));
     textfield_->SetText(ASCIIToUTF16("one two three"));
     textfield_->SelectRange(gfx::Range(2, 6));
@@ -2785,7 +2785,7 @@
     // U+0020 SPACE
     0x0020,
   };
-  const size_t kUtf16CharsCount = arraysize(kUtf16Chars);
+  const size_t kUtf16CharsCount = base::size(kUtf16Chars);
 
   ui::CompositionText composition;
   composition.text.assign(kUtf16Chars, kUtf16Chars + kUtf16CharsCount);
diff --git a/ui/views/controls/webview/webview_unittest.cc b/ui/views/controls/webview/webview_unittest.cc
index 6f69e63..3b4b95b1 100644
--- a/ui/views/controls/webview/webview_unittest.cc
+++ b/ui/views/controls/webview/webview_unittest.cc
@@ -125,8 +125,11 @@
 // Provides functionality to test a WebView.
 class WebViewUnitTest : public views::test::WidgetTest {
  public:
-  WebViewUnitTest() = default;
-  ~WebViewUnitTest() override = default;
+  WebViewUnitTest()
+      : views::test::WidgetTest(
+            std::make_unique<content::TestBrowserThreadBundle>()) {}
+
+  ~WebViewUnitTest() override {}
 
   std::unique_ptr<content::WebContents> CreateWebContentsForWebView(
       content::BrowserContext* browser_context) {
@@ -135,10 +138,6 @@
   }
 
   void SetUp() override {
-    set_scoped_task_environment(
-        std::make_unique<content::TestBrowserThreadBundle>());
-    rvh_enabler_ = std::make_unique<content::RenderViewHostTestEnabler>();
-
     views::WebView::WebContentsCreator creator = base::BindRepeating(
         &WebViewUnitTest::CreateWebContentsForWebView, base::Unretained(this));
     scoped_web_contents_creator_ =
@@ -190,7 +189,7 @@
   }
 
  private:
-  std::unique_ptr<content::RenderViewHostTestEnabler> rvh_enabler_;
+  content::RenderViewHostTestEnabler rvh_enabler_;
   std::unique_ptr<content::TestBrowserContext> browser_context_;
   content::TestContentBrowserClient test_browser_client_;
   std::unique_ptr<views::WebView::ScopedWebContentsCreatorForTesting>
diff --git a/ui/views/corewm/DEPS b/ui/views/corewm/DEPS
index f3f5340..150fabd 100644
--- a/ui/views/corewm/DEPS
+++ b/ui/views/corewm/DEPS
@@ -21,7 +21,6 @@
   ],
 
   "desktop_capture_controller_unittest.cc": [
-    "+ui/views/test/native_widget_factory.h",
     "+ui/views/test/views_interactive_ui_test_base.h",
     "+ui/views/view.h",
     "+ui/views/widget/desktop_aura/desktop_native_widget_aura.h",
diff --git a/ui/views/corewm/desktop_capture_controller_unittest.cc b/ui/views/corewm/desktop_capture_controller_unittest.cc
index b1b8e82..b4b852f9 100644
--- a/ui/views/corewm/desktop_capture_controller_unittest.cc
+++ b/ui/views/corewm/desktop_capture_controller_unittest.cc
@@ -12,7 +12,6 @@
 #include "ui/aura/window_tree_host.h"
 #include "ui/events/event.h"
 #include "ui/events/test/event_generator.h"
-#include "ui/views/test/native_widget_factory.h"
 #include "ui/views/test/views_interactive_ui_test_base.h"
 #include "ui/views/view.h"
 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
@@ -104,8 +103,6 @@
   aura::client::CaptureClient* capture_client = wm::CaptureController::Get();
   params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params.bounds = gfx::Rect(50, 50, 650, 650);
-  params.native_widget = test::CreatePlatformNativeWidgetImpl(
-      params, widget1.get(), test::kStubCapture, nullptr);
   widget1->Init(params);
   internal::RootView* root1 =
       static_cast<internal::RootView*>(widget1->GetRootView());
@@ -126,8 +123,6 @@
   params = CreateParams(Widget::InitParams::TYPE_POPUP);
   params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params.bounds = gfx::Rect(50, 50, 650, 650);
-  params.native_widget = test::CreatePlatformNativeWidgetImpl(
-      params, widget2.get(), test::kStubCapture, nullptr);
   widget2->Init(params);
 
   internal::RootView* root2 =
diff --git a/ui/views/corewm/tooltip_controller_unittest.cc b/ui/views/corewm/tooltip_controller_unittest.cc
index 94f6648..77372af 100644
--- a/ui/views/corewm/tooltip_controller_unittest.cc
+++ b/ui/views/corewm/tooltip_controller_unittest.cc
@@ -4,7 +4,6 @@
 
 #include "ui/views/corewm/tooltip_controller.h"
 
-#include "base/at_exit.h"
 #include "base/macros.h"
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
@@ -61,6 +60,9 @@
   params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
 #if defined(OS_CHROMEOS)
   params.parent = root;
+#else
+  params.native_widget = ::views::test::CreatePlatformDesktopNativeWidgetImpl(
+      params, widget, nullptr);
 #endif
   params.bounds = gfx::Rect(0, 0, 200, 100);
   widget->Init(params);
@@ -77,14 +79,10 @@
 
 class TooltipControllerTest : public ViewsTestBase {
  public:
-  TooltipControllerTest() = default;
+  TooltipControllerTest() : view_(NULL) {}
   ~TooltipControllerTest() override {}
 
   void SetUp() override {
-#if !defined(OS_CHROMEOS)
-    set_native_widget_type(NativeWidgetType::kDesktop);
-#endif
-
     ViewsTestBase::SetUp();
 
     aura::Window* root_window = GetContext();
@@ -158,7 +156,7 @@
   }
 
   std::unique_ptr<views::Widget> widget_;
-  TooltipTestView* view_ = nullptr;
+  TooltipTestView* view_;
   std::unique_ptr<TooltipControllerTestHelper> helper_;
   std::unique_ptr<ui::test::EventGenerator> generator_;
 
@@ -238,6 +236,11 @@
 #if defined(OS_CHROMEOS)
 // crbug.com/664370.
 TEST_F(TooltipControllerTest, MaxWidth) {
+  // This test relies on TooltipAura being created, which does not happen in
+  // this test with mus (it happens in DesktopNativeWidgetAura).
+  if (IsMus())
+    return;
+
   base::string16 text = base::ASCIIToUTF16(
       "Really really realy long long long long  long tooltips that exceeds max "
       "width");
@@ -479,7 +482,8 @@
   }
 
   void TearDown() override {
-    aura::client::SetScreenPositionClient(GetRootWindow(), NULL);
+    if (!IsMus())
+      aura::client::SetScreenPositionClient(GetRootWindow(), NULL);
     TooltipControllerTest::TearDown();
   }
 
@@ -518,6 +522,11 @@
 #endif
 // Verifies the correct window is found for tooltips when there is a capture.
 TEST_F(TooltipControllerCaptureTest, MAYBE_Capture) {
+  // This test doesn't make sense with mus as it creates two widgets and
+  // expects to move the mouse between them.
+  if (IsMus())
+    return;
+
   const base::string16 tooltip_text(ASCIIToUTF16("1"));
   const base::string16 tooltip_text2(ASCIIToUTF16("2"));
 
@@ -601,7 +610,6 @@
   ~TooltipControllerTest2() override {}
 
   void SetUp() override {
-    at_exit_manager_ = std::make_unique<base::ShadowingAtExitManager>();
     aura::test::AuraTestBase::SetUp();
     new wm::DefaultActivationClient(root_window());
     controller_.reset(
@@ -619,7 +627,6 @@
     generator_.reset();
     helper_.reset();
     aura::test::AuraTestBase::TearDown();
-    at_exit_manager_.reset();
   }
 
  protected:
@@ -629,14 +636,17 @@
   std::unique_ptr<ui::test::EventGenerator> generator_;
 
  private:
-  // Needed to make sure the InputDeviceManager is cleaned up between test runs.
-  std::unique_ptr<base::ShadowingAtExitManager> at_exit_manager_;
   std::unique_ptr<TooltipController> controller_;
 
   DISALLOW_COPY_AND_ASSIGN(TooltipControllerTest2);
 };
 
 TEST_F(TooltipControllerTest2, VerifyLeadingTrailingWhitespaceStripped) {
+  // This test does not have a real connection to mus (because it's using
+  // AuraTestBase, not ViewsTestBase), so it can't use EventGenerator.
+  if (ViewsTestBase::IsMus())
+    return;
+
   aura::test::TestWindowDelegate test_delegate;
   std::unique_ptr<aura::Window> window(
       CreateNormalWindow(100, root_window(), &test_delegate));
@@ -650,6 +660,11 @@
 
 // Verifies that tooltip is hidden and tooltip window closed upon cancel mode.
 TEST_F(TooltipControllerTest2, CloseOnCancelMode) {
+  // This test does not have a real connection to mus (because it's using
+  // AuraTestBase, not ViewsTestBase), so it can't use EventGenerator.
+  if (ViewsTestBase::IsMus())
+    return;
+
   aura::test::TestWindowDelegate test_delegate;
   std::unique_ptr<aura::Window> window(
       CreateNormalWindow(100, root_window(), &test_delegate));
@@ -676,12 +691,13 @@
   ~TooltipControllerTest3() override = default;
 
   void SetUp() override {
-#if !defined(OS_CHROMEOS)
-    set_native_widget_type(NativeWidgetType::kDesktop);
-#endif
-
     ViewsTestBase::SetUp();
 
+    // This test assumes a hierarchy like that of Ash, which doesn't make sense
+    // with mus.
+    if (IsMus())
+      return;
+
     aura::Window* root_window = GetContext();
     new wm::DefaultActivationClient(root_window);
 
@@ -705,13 +721,15 @@
   }
 
   void TearDown() override {
-    GetRootWindow()->RemovePreTargetHandler(controller_.get());
-    wm::SetTooltipClient(GetRootWindow(), NULL);
+    if (!IsMus()) {
+      GetRootWindow()->RemovePreTargetHandler(controller_.get());
+      wm::SetTooltipClient(GetRootWindow(), NULL);
 
-    controller_.reset();
-    generator_.reset();
-    helper_.reset();
-    widget_.reset();
+      controller_.reset();
+      generator_.reset();
+      helper_.reset();
+      widget_.reset();
+    }
     ViewsTestBase::TearDown();
   }
 
@@ -738,6 +756,11 @@
 };
 
 TEST_F(TooltipControllerTest3, TooltipPositionChangesOnTwoViewsWithSameLabel) {
+  // See comment in TooltipControllerTest3::SetUp() for why this does nothing in
+  // mus.
+  if (IsMus())
+    return;
+
   // Owned by |view_|.
   // These two views have the same tooltip text
   TooltipTestView* v1 = new TooltipTestView;
diff --git a/ui/views/event_monitor_unittest.cc b/ui/views/event_monitor_unittest.cc
index fdda456..6db69c17 100644
--- a/ui/views/event_monitor_unittest.cc
+++ b/ui/views/event_monitor_unittest.cc
@@ -44,8 +44,18 @@
     widget_ = CreateTopLevelNativeWidget();
     widget_->SetSize(gfx::Size(100, 100));
     widget_->Show();
-    generator_ = std::make_unique<ui::test::EventGenerator>(
-        GetContext(), widget_->GetNativeWindow());
+    if (IsMus()) {
+      generator_ =
+          std::make_unique<ui::test::EventGenerator>(GetRootWindow(widget_));
+// This #if will always be true on this path, but the code inside won't compile
+// for non-Aura.
+#if defined(USE_AURA)
+      generator_->MoveMouseRelativeTo(widget_->GetNativeWindow(), gfx::Point());
+#endif
+    } else {
+      generator_ = std::make_unique<ui::test::EventGenerator>(
+          GetContext(), widget_->GetNativeWindow());
+    }
     generator_->set_target(ui::test::EventGenerator::Target::APPLICATION);
   }
   void TearDown() override {
diff --git a/ui/views/examples/bubble_example.cc b/ui/views/examples/bubble_example.cc
index a93f6c4..07127e6 100644
--- a/ui/views/examples/bubble_example.cc
+++ b/ui/views/examples/bubble_example.cc
@@ -4,7 +4,7 @@
 
 #include "ui/views/examples/bubble_example.h"
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/gfx/geometry/insets.h"
 #include "ui/views/bubble/bubble_dialog_delegate_view.h"
@@ -95,7 +95,7 @@
 
 void BubbleExample::ButtonPressed(Button* sender, const ui::Event& event) {
   static int arrow_index = 0, color_index = 0;
-  static const int count = arraysize(arrows);
+  static const int count = base::size(arrows);
   arrow_index = (arrow_index + count + (event.IsShiftDown() ? -1 : 1)) % count;
   BubbleBorder::Arrow arrow = arrows[arrow_index];
   if (event.IsControlDown())
@@ -104,7 +104,7 @@
     arrow = BubbleBorder::FLOAT;
 
   ExampleBubble* bubble = new ExampleBubble(sender, arrow);
-  bubble->set_color(colors[(color_index++) % arraysize(colors)]);
+  bubble->set_color(colors[(color_index++) % base::size(colors)]);
 
   if (sender == no_shadow_)
     bubble->set_shadow(BubbleBorder::NO_SHADOW);
diff --git a/ui/views/examples/label_example.cc b/ui/views/examples/label_example.cc
index e1df4fe..c9cf287 100644
--- a/ui/views/examples/label_example.cc
+++ b/ui/views/examples/label_example.cc
@@ -6,8 +6,8 @@
 
 #include <memory>
 
-#include "base/macros.h"
 #include "base/memory/ptr_util.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/gfx/geometry/insets.h"
 #include "ui/gfx/geometry/vector2d.h"
@@ -185,11 +185,11 @@
   textfield_->set_controller(this);
   layout->AddView(textfield_);
 
-  alignment_ = AddCombobox(layout, "Alignment: ", kAlignments,
-                           arraysize(kAlignments));
+  alignment_ =
+      AddCombobox(layout, "Alignment: ", kAlignments, base::size(kAlignments));
   elide_behavior_ = AddCombobox(
       layout, "Elide Behavior: ", ExamplePreferredSizeLabel::kElideBehaviors,
-      arraysize(ExamplePreferredSizeLabel::kElideBehaviors));
+      base::size(ExamplePreferredSizeLabel::kElideBehaviors));
 
   column_set = layout->AddColumnSet(1);
   column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING,
diff --git a/ui/views/examples/radio_button_example.cc b/ui/views/examples/radio_button_example.cc
index 65826da..086dbfa 100644
--- a/ui/views/examples/radio_button_example.cc
+++ b/ui/views/examples/radio_button_example.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/views/controls/button/label_button.h"
@@ -27,7 +27,7 @@
   status_ = new LabelButton(this, base::ASCIIToUTF16("Show Status"));
 
   int group = 1;
-  for (size_t i = 0; i < arraysize(radio_buttons_); ++i) {
+  for (size_t i = 0; i < base::size(radio_buttons_); ++i) {
     radio_buttons_[i] = new RadioButton(
         base::UTF8ToUTF16(base::StringPrintf(
             "Radio %d in group %d", static_cast<int>(i) + 1, group)),
@@ -40,7 +40,7 @@
   ColumnSet* column_set = layout->AddColumnSet(0);
   column_set->AddColumn(GridLayout::FILL, GridLayout::FILL,
                         1.0f, GridLayout::USE_PREF, 0, 0);
-  for (size_t i = 0; i < arraysize(radio_buttons_); ++i) {
+  for (size_t i = 0; i < base::size(radio_buttons_); ++i) {
     layout->StartRow(0, 0);
     layout->AddView(radio_buttons_[i]);
   }
diff --git a/ui/views/examples/text_example.cc b/ui/views/examples/text_example.cc
index c37608c..b999289 100644
--- a/ui/views/examples/text_example.cc
+++ b/ui/views/examples/text_example.cc
@@ -6,7 +6,7 @@
 
 #include <memory>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/gfx/canvas.h"
 #include "ui/gfx/font_list.h"
@@ -170,15 +170,15 @@
   column_set->AddPaddingColumn(0, 8);
 
   h_align_cb_ = AddCombobox(layout, "H-Align", kHorizontalAligments,
-                            arraysize(kHorizontalAligments));
+                            base::size(kHorizontalAligments));
   eliding_cb_ = AddCombobox(layout, "Eliding", kElideBehaviors,
-                            arraysize(kElideBehaviors));
-  prefix_cb_ = AddCombobox(layout, "Prefix", kPrefixOptions,
-                           arraysize(kPrefixOptions));
+                            base::size(kElideBehaviors));
+  prefix_cb_ =
+      AddCombobox(layout, "Prefix", kPrefixOptions, base::size(kPrefixOptions));
   text_cb_ = AddCombobox(layout, "Example Text", kTextExamples,
-                         arraysize(kTextExamples));
+                         base::size(kTextExamples));
   weight_cb_ = AddCombobox(layout, "Font Weight", kWeightLabels,
-                           arraysize(kWeightLabels));
+                           base::size(kWeightLabels));
   weight_cb_->SelectValue(base::ASCIIToUTF16("Normal"));
 
   layout->StartRow(0, 0);
diff --git a/ui/views/focus/focus_manager_unittest.cc b/ui/views/focus/focus_manager_unittest.cc
index 91414af..a46b9eb 100644
--- a/ui/views/focus/focus_manager_unittest.cc
+++ b/ui/views/focus/focus_manager_unittest.cc
@@ -1039,31 +1039,19 @@
   EXPECT_TRUE(parent3->HasFocus());
 }
 
+// Desktop native widget Aura tests are for non Chrome OS platforms.
 // This test is specifically for the permutation where the main
 // widget is a DesktopNativeWidgetAura and the bubble is a
 // NativeWidgetAura. When focus moves back from the bubble to the
 // parent widget, ensure that the DNWA's aura window is focused.
-#if defined(USE_AURA)
-class DesktopWidgetFocusManagerTest : public FocusManagerTest {
- public:
-  DesktopWidgetFocusManagerTest() = default;
-  ~DesktopWidgetFocusManagerTest() override = default;
-
-  // FocusManagerTest:
-  void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-    FocusManagerTest::SetUp();
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(DesktopWidgetFocusManagerTest);
-};
-
-TEST_F(DesktopWidgetFocusManagerTest, AnchoredDialogInDesktopNativeWidgetAura) {
+#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+TEST_F(FocusManagerTest, AnchoredDialogInDesktopNativeWidgetAura) {
   Widget widget;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params.bounds = gfx::Rect(0, 0, 1024, 768);
+  params.native_widget =
+      test::CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr);
   widget.Init(params);
   widget.Show();
   widget.Activate();
@@ -1118,6 +1106,6 @@
   // Finally, the outer widget's window should be focused again.
   ASSERT_EQ(widget.GetNativeView(), focus_client->GetFocusedWindow());
 }
-#endif  // defined(USE_AURA)
+#endif  // defined(USE_AURA) && !defined(OS_CHROMEOS)
 
 }  // namespace views
diff --git a/ui/views/focus/focus_traversal_unittest.cc b/ui/views/focus/focus_traversal_unittest.cc
index 2e45e0a..4a3cd7e 100644
--- a/ui/views/focus/focus_traversal_unittest.cc
+++ b/ui/views/focus/focus_traversal_unittest.cc
@@ -4,8 +4,8 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
 #include "base/run_loop.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/base/models/combobox_model.h"
@@ -455,10 +455,10 @@
                              CAMPING_LINK_ID,    BRICE_DE_NICE_LINK_ID,
                              TAXI_LINK_ID,       ASTERIX_LINK_ID};
 
-  DCHECK(arraysize(kTitles) == arraysize(kIDs));
+  DCHECK(base::size(kTitles) == base::size(kIDs));
 
   y = 5;
-  for (size_t i = 0; i < arraysize(kTitles); ++i) {
+  for (size_t i = 0; i < base::size(kTitles); ++i) {
     Link* link = new Link(ASCIIToUTF16(kTitles[i]));
     link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
     link->set_id(kIDs[i]);
@@ -704,7 +704,7 @@
   SCOPED_TRACE("TraversalWithNonEnabledViews");
 
   // Let's disable some views.
-  for (size_t i = 0; i < arraysize(kDisabledIDs); i++) {
+  for (size_t i = 0; i < base::size(kDisabledIDs); i++) {
     View* v = FindViewByID(kDisabledIDs[i]);
     ASSERT_TRUE(v != NULL);
     v->SetEnabled(false);
@@ -744,7 +744,7 @@
   SCOPED_TRACE("TraversalWithInvisibleViews");
 
   // Let's make some views invisible.
-  for (size_t i = 0; i < arraysize(kInvisibleIDs); i++) {
+  for (size_t i = 0; i < base::size(kInvisibleIDs); i++) {
     View* v = FindViewByID(kInvisibleIDs[i]);
     ASSERT_TRUE(v != NULL);
     v->SetVisible(false);
diff --git a/ui/views/layout/grid_layout_unittest.cc b/ui/views/layout/grid_layout_unittest.cc
index e4062dbc..c5c3242 100644
--- a/ui/views/layout/grid_layout_unittest.cc
+++ b/ui/views/layout/grid_layout_unittest.cc
@@ -827,6 +827,13 @@
 // GridLayout must guard against this as it hasn't yet updated the internal
 // structures it uses to calculate Layout, so will give bogus results.
 TEST_F(GridLayoutTest, LayoutOnAddDeath) {
+  // gtest death tests, such as EXPECT_DCHECK_DEATH(), can not work in the
+  // presence of fork() and other process launching. In views-mus, we have
+  // already launched additional processes for our service manager. Performing
+  // this test under mus is impossible.
+  if (PlatformTestHelper::IsMus())
+    return;
+
   ColumnSet* set = layout()->AddColumnSet(0);
   set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, GridLayout::USE_PREF, 0,
                  0);
diff --git a/ui/views/mus/BUILD.gn b/ui/views/mus/BUILD.gn
index aa466e8..9724121 100644
--- a/ui/views/mus/BUILD.gn
+++ b/ui/views/mus/BUILD.gn
@@ -104,3 +104,210 @@
     ":mus",
   ]
 }
+
+jumbo_static_library("test_support") {
+  testonly = true
+
+  sources = [
+    "../test/native_widget_factory_aura_mus.cc",
+    "mus_client_test_api.h",
+    "views_mus_test_suite.cc",
+    "views_mus_test_suite.h",
+  ]
+
+  deps = [
+    ":mus",
+    ":views_mus_tests_catalog_source",
+    "//base",
+    "//base/test:test_support",
+    "//mojo/core/embedder",
+    "//services/catalog:lib",
+    "//services/service_manager/background:lib",
+    "//services/service_manager/public/cpp",
+    "//services/ws/common",
+    "//testing/gtest",
+    "//ui/aura",
+    "//ui/aura:test_support",
+    "//ui/compositor:test_support",
+    "//ui/gl:test_support",
+    "//ui/resources",
+    "//ui/resources:ui_test_pak",
+    "//ui/views",
+    "//ui/views:test_support_internal",
+  ]
+
+  if (use_ozone) {
+    deps += [ "//ui/ozone" ]
+  }
+
+  data_deps = [
+    ":views_mus_tests_catalog",
+    "//services/ws/ime/test_ime_driver",
+    "//ui/resources:ui_test_pak_data",
+  ]
+}
+
+test("views_mus_unittests") {
+  testonly = true
+
+  sources = [
+    "ax_remote_host_unittest.cc",
+    "ax_tree_source_mus_unittest.cc",
+    "desktop_window_tree_host_mus_unittest.cc",
+    "run_all_unittests_mus.cc",
+    "screen_mus_unittest.cc",
+  ]
+
+  configs += [ "//build/config:precompiled_headers" ]
+
+  deps = [
+    ":mus",
+    ":test_support",
+    "//base",
+    "//base:i18n",
+    "//base/test:test_support",
+    "//cc",
+    "//net",
+    "//services/ws/public/mojom",
+    "//services/ws/test_ws:mojom",
+    "//skia",
+    "//testing/gtest",
+    "//third_party/icu",
+    "//ui/accessibility",
+    "//ui/accessibility/mojom",
+    "//ui/aura",
+    "//ui/aura:test_support",
+    "//ui/base",
+    "//ui/base:test_support",
+    "//ui/base/ime",
+    "//ui/compositor:test_support",
+    "//ui/events:dom_keycode_converter",
+    "//ui/events:events_base",
+    "//ui/events:test_support",
+    "//ui/events/platform",
+    "//ui/gfx:test_support",
+    "//ui/gfx/geometry",
+    "//ui/native_theme",
+    "//ui/strings",
+    "//ui/touch_selection",
+    "//ui/views",
+    "//ui/views:test_support_internal",
+    "//ui/views:views_unittests_sources",
+    "//ui/views/mus/remote_view:tests",
+    "//ui/wm",
+    "//url",
+  ]
+
+  data_deps = [
+    "//services/ws/ime/test_ime_driver",
+    "//services/ws/test_ws",
+  ]
+
+  if (is_win) {
+    deps += [
+      "//build/win:default_exe_manifest",
+      "//third_party/iaccessible2",
+      "//third_party/wtl",
+    ]
+    libs = [
+      "imm32.lib",
+      "oleacc.lib",
+      "comctl32.lib",
+    ]
+  }
+
+  if (use_x11) {
+    configs += [
+      "//build/config/linux:x11",
+      "//build/config/linux:xext",
+    ]
+    deps += [
+      "//ui/events/devices",
+      "//ui/events/platform/x11",
+      "//ui/gfx/x",
+    ]
+  }
+}
+
+# Tests that must run sequentially because they access system-wide features
+# like capture.
+test("views_mus_interactive_ui_tests") {
+  testonly = true
+
+  sources = [
+    "../widget/widget_interactive_uitest.cc",
+    "clipboard_unittest.cc",
+    "drag_interactive_uitest.cc",
+    "interactive_ui_tests_mus.cc",
+  ]
+
+  deps = [
+    ":mus",
+    ":test_support",
+    "//base",
+    "//mojo/core/embedder",
+    "//testing/gmock",
+    "//testing/gtest",
+    "//ui/aura",
+    "//ui/aura:test_support",
+    "//ui/base",
+    "//ui/base:test_support",
+    "//ui/base/ime",
+    "//ui/base/mojo:lib",
+    "//ui/events:events_base",
+    "//ui/events:test_support",
+    "//ui/gl:test_support",
+    "//ui/touch_selection",
+    "//ui/views",
+    "//ui/views:test_support_internal",
+    "//ui/wm",
+    "//ui/wm/public",
+  ]
+
+  data_deps = [
+    "//services/ws/test_ws",
+  ]
+
+  if (is_win) {
+    deps += [
+      "//build/win:default_exe_manifest",
+      "//third_party/iaccessible2",
+      "//third_party/wtl",
+    ]
+    libs = [
+      "imm32.lib",
+      "oleacc.lib",
+      "comctl32.lib",
+    ]
+  }
+}
+
+service_manifest("unittests_manifest") {
+  name = "views_mus_unittests"
+  source = "unittests_manifest.json"
+}
+
+service_manifest("interactive_ui_tests_manifest") {
+  name = "views_mus_interactive_ui_tests"
+  source = "interactive_ui_tests_manifest.json"
+}
+
+catalog("views_mus_tests_catalog") {
+  testonly = true
+
+  embedded_services = [
+    ":unittests_manifest",
+    ":interactive_ui_tests_manifest",
+  ]
+
+  standalone_services = [
+    "//services/ws/test_ws:manifest",
+    "//services/ws/ime/test_ime_driver:manifest",
+  ]
+}
+
+catalog_cpp_source("views_mus_tests_catalog_source") {
+  testonly = true
+  catalog = ":views_mus_tests_catalog"
+  generated_function_name = "views::CreateViewsMusTestsCatalog"
+}
diff --git a/ui/views/mus/DEPS b/ui/views/mus/DEPS
index 72bd2b4..6c5f22db 100644
--- a/ui/views/mus/DEPS
+++ b/ui/views/mus/DEPS
@@ -20,3 +20,12 @@
   "+ui/platform_window",
   "+ui/wm",
 ]
+
+specific_include_rules = {
+  "views_mus_test_suite.cc": [
+    "+services/service_manager/background",
+  ],
+  "views_aura_mus_test_suite.cc": [
+    "+services/service_manager/background",
+  ],
+}
diff --git a/ui/views/mus/OWNERS b/ui/views/mus/OWNERS
index 1b6d3c5..3a73ee3 100644
--- a/ui/views/mus/OWNERS
+++ b/ui/views/mus/OWNERS
@@ -3,3 +3,9 @@
 sky@chromium.org
 
 per-file ax_*=file://ui/accessibility/OWNERS
+
+per-file interactive_ui_tests_manifest.json=set noparent
+per-file interactive_ui_tests_manifest.json=file://ipc/SECURITY_OWNERS
+
+per-file unittests_manifest.json=set noparent
+per-file unittests_manifest.json=file://ipc/SECURITY_OWNERS
diff --git a/ui/views/mus/ax_remote_host_unittest.cc b/ui/views/mus/ax_remote_host_unittest.cc
index 0bcbf8e..9fc9201 100644
--- a/ui/views/mus/ax_remote_host_unittest.cc
+++ b/ui/views/mus/ax_remote_host_unittest.cc
@@ -131,7 +131,7 @@
   return widget;
 }
 
-using AXRemoteHostTest = ViewsTestWithDesktopNativeWidget;
+using AXRemoteHostTest = ViewsTestBase;
 
 TEST_F(AXRemoteHostTest, CreateRemote) {
   TestAXHostService service(false /*automation_enabled*/);
diff --git a/ui/views/mus/ax_tree_source_mus_unittest.cc b/ui/views/mus/ax_tree_source_mus_unittest.cc
index 1f8320bf..fc35420 100644
--- a/ui/views/mus/ax_tree_source_mus_unittest.cc
+++ b/ui/views/mus/ax_tree_source_mus_unittest.cc
@@ -31,7 +31,6 @@
 
   // testing::Test:
   void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
     ViewsTestBase::SetUp();
     widget_ = std::make_unique<Widget>();
     Widget::InitParams params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
diff --git a/ui/views/mus/clipboard_unittest.cc b/ui/views/mus/clipboard_unittest.cc
index bd0350f3..a00f615 100644
--- a/ui/views/mus/clipboard_unittest.cc
+++ b/ui/views/mus/clipboard_unittest.cc
@@ -4,26 +4,16 @@
 
 #include "ui/base/mojo/clipboard_client.h"
 
+#include "testing/gtest/include/gtest/gtest.h"
 #include "ui/events/platform/platform_event_source.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
+#include "ui/views/mus/mus_client.h"
+#include "ui/views/test/scoped_views_test_helper.h"
 
 namespace ui {
 
 namespace {
 
-views::ViewsTestBase* g_test_base = nullptr;
-
-// This class is necessary to allow the Mus version of ClipboardTest to
-// initialize itself as if it's a ViewsTestBase (which creates the MusClient and
-// does other necessary setup). TODO(crbug/917180): improve this.
-class ViewsTestBaseNoTest : public views::ViewsInteractiveUITestBase {
- public:
-  ViewsTestBaseNoTest() = default;
-  ~ViewsTestBaseNoTest() override = default;
-
-  // views::ViewsInteractiveUITestBase:
-  void TestBody() override {}
-};
+std::unique_ptr<views::ScopedViewsTestHelper> g_scoped_views_test_helper;
 
 }  // namespace
 
@@ -33,28 +23,19 @@
   }
 
   static Clipboard* Create() {
-    g_test_base = new ViewsTestBaseNoTest();
-    g_test_base->SetUp();
-
+    g_scoped_views_test_helper =
+        std::make_unique<views::ScopedViewsTestHelper>();
+    EXPECT_TRUE(views::MusClient::Exists());
     return Clipboard::GetForCurrentThread();
   }
 
   static void Destroy(Clipboard* clipboard) {
-    g_test_base->TearDown();
-    g_test_base = nullptr;
+    g_scoped_views_test_helper.reset();
   }
 };
 
 using TypesToTest = PlatformClipboardTraits;
 
-class NamesOfTypesToTest {
- public:
-  template <typename T>
-  static std::string GetName(int index) {
-    return "MusClipboardTest";
-  }
-};
-
 }  // namespace ui
 
 #include "ui/base/clipboard/clipboard_test_template.h"
diff --git a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
index 301fc243..9959576 100644
--- a/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
+++ b/ui/views/mus/desktop_window_tree_host_mus_unittest.cc
@@ -34,7 +34,6 @@
 #include "ui/views/mus/mus_client.h"
 #include "ui/views/mus/mus_client_test_api.h"
 #include "ui/views/mus/screen_mus.h"
-#include "ui/views/test/native_widget_factory.h"
 #include "ui/views/test/views_test_base.h"
 #include "ui/views/widget/widget.h"
 #include "ui/views/widget/widget_delegate.h"
@@ -47,14 +46,9 @@
 class DesktopWindowTreeHostMusTest : public ViewsTestBase,
                                      public WidgetObserver {
  public:
-  DesktopWindowTreeHostMusTest() = default;
-  ~DesktopWindowTreeHostMusTest() override = default;
-
-  // ViewsTestBase:
-  void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-    ViewsTestBase::SetUp();
-  }
+  DesktopWindowTreeHostMusTest()
+      : widget_activated_(nullptr), widget_deactivated_(nullptr) {}
+  ~DesktopWindowTreeHostMusTest() override {}
 
   // Creates a test widget. Takes ownership of |delegate|.
   std::unique_ptr<Widget> CreateWidget(WidgetDelegate* delegate = nullptr,
@@ -84,8 +78,8 @@
     }
   }
 
-  Widget* widget_activated_ = nullptr;
-  Widget* widget_deactivated_ = nullptr;
+  Widget* widget_activated_;
+  Widget* widget_deactivated_;
 
   DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostMusTest);
 };
@@ -413,7 +407,7 @@
 
   for (auto widget_type : kWidgetTypes) {
     Widget widget;
-    Widget::InitParams params = CreateParams(widget_type);
+    Widget::InitParams params(widget_type);
     params.show_state = ui::SHOW_STATE_FULLSCREEN;
     params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
     widget.Init(params);
diff --git a/ui/views/mus/drag_interactive_uitest.cc b/ui/views/mus/drag_interactive_uitest.cc
index b4d8e0c..92dc07d 100644
--- a/ui/views/mus/drag_interactive_uitest.cc
+++ b/ui/views/mus/drag_interactive_uitest.cc
@@ -15,7 +15,7 @@
 #include "ui/events/event.h"
 #include "ui/events/event_utils.h"
 #include "ui/views/mus/mus_client.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
+#include "ui/views/test/widget_test.h"
 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
 #include "ui/views/widget/widget.h"
 
@@ -108,7 +108,7 @@
 
 }  // namespace
 
-using DragTestInteractive = ViewsInteractiveUITestBase;
+using DragTestInteractive = WidgetTest;
 
 // Dispatch of events is asynchronous so most of DragTestInteractive.DragTest
 // consists of callback functions which will perform an action after the
@@ -151,9 +151,7 @@
   ws::mojom::EventInjectorPtr event_injector;
   MusClient::Get()->window_tree_client()->connector()->BindInterface(
       ws::mojom::kServiceName, &event_injector);
-
-  Widget* source_widget = new Widget;
-  source_widget->Init(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS));
+  Widget* source_widget = CreateTopLevelFramelessPlatformWidget();
   View* source_view = new DraggableView;
   source_widget->SetContentsView(source_view);
   source_widget->Show();
@@ -163,9 +161,7 @@
   source_widget->SetBounds(gfx::Rect(0, 0, 20, 20));
   ASSERT_TRUE(source_waiter.Wait());
 
-  Widget* target_widget = new Widget;
-  target_widget->Init(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS));
-
+  Widget* target_widget = CreateTopLevelFramelessPlatformWidget();
   TargetView* target_view = new TargetView;
   target_widget->SetContentsView(target_view);
   target_widget->Show();
diff --git a/ui/views/interactive_ui_tests_manifest.json b/ui/views/mus/interactive_ui_tests_manifest.json
similarity index 64%
rename from ui/views/interactive_ui_tests_manifest.json
rename to ui/views/mus/interactive_ui_tests_manifest.json
index 567ca61..36a5b66 100644
--- a/ui/views/interactive_ui_tests_manifest.json
+++ b/ui/views/mus/interactive_ui_tests_manifest.json
@@ -1,6 +1,6 @@
 {
-  "name": "interactive_ui_tests",
-  "display_name": "Interactive UI Tests",
+  "name": "views_mus_interactive_ui_tests",
+  "display_name": "Views Mus Interactive UI Tests",
   "interface_provider_specs": {
     "service_manager:connector": {
       "requires": {
diff --git a/ui/views/mus/interactive_ui_tests_mus.cc b/ui/views/mus/interactive_ui_tests_mus.cc
new file mode 100644
index 0000000..5bea809
--- /dev/null
+++ b/ui/views/mus/interactive_ui_tests_mus.cc
@@ -0,0 +1,9 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/mus/views_mus_test_suite.h"
+
+int main(int argc, char** argv) {
+  return views::ViewsMusTestSuite(argc, argv).RunTestsSerially();
+}
diff --git a/ui/views/mus/remote_view/remote_view_host_unittest.cc b/ui/views/mus/remote_view/remote_view_host_unittest.cc
index 616e943..30db5c39 100644
--- a/ui/views/mus/remote_view/remote_view_host_unittest.cc
+++ b/ui/views/mus/remote_view/remote_view_host_unittest.cc
@@ -46,16 +46,10 @@
 
   // aura::test::AuraTestBase
   void SetUp() override {
-    env_ = aura::Env::CreateInstance();
     EnableMusWithTestWindowTree();
     AuraTestBase::SetUp();
   }
 
-  void TearDown() override {
-    AuraTestBase::TearDown();
-    env_.reset();
-  }
-
   // Creates a widget to host |contents|.
   std::unique_ptr<views::Widget> CreateTestWidget(views::View* contents) {
     std::unique_ptr<views::Widget> widget = std::make_unique<views::Widget>();
@@ -83,8 +77,6 @@
   }
 
  private:
-  std::unique_ptr<aura::Env> env_;
-
   DISALLOW_COPY_AND_ASSIGN(RemoteViewHostTest);
 };
 
diff --git a/ui/views/mus/remote_view/remote_view_provider_unittest.cc b/ui/views/mus/remote_view/remote_view_provider_unittest.cc
index 0cd4fcac..7aea514 100644
--- a/ui/views/mus/remote_view/remote_view_provider_unittest.cc
+++ b/ui/views/mus/remote_view/remote_view_provider_unittest.cc
@@ -28,7 +28,6 @@
 
   // aura::test::AuraTestBase
   void SetUp() override {
-    env_ = aura::Env::CreateInstance();
     EnableMusWithTestWindowTree();
     AuraTestBase::SetUp();
 
@@ -111,7 +110,6 @@
   }
 
  protected:
-  std::unique_ptr<aura::Env> env_;
   std::unique_ptr<aura::Window> embedded_;
   std::unique_ptr<RemoteViewProvider> provider_;
 
diff --git a/ui/views/mus/run_all_unittests_mus.cc b/ui/views/mus/run_all_unittests_mus.cc
new file mode 100644
index 0000000..49d9aaf
--- /dev/null
+++ b/ui/views/mus/run_all_unittests_mus.cc
@@ -0,0 +1,9 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/mus/views_mus_test_suite.h"
+
+int main(int argc, char** argv) {
+  return views::ViewsMusTestSuite(argc, argv).RunTests();
+}
diff --git a/ui/views/mus/screen_mus_unittest.cc b/ui/views/mus/screen_mus_unittest.cc
index 28b0263..e27751a1 100644
--- a/ui/views/mus/screen_mus_unittest.cc
+++ b/ui/views/mus/screen_mus_unittest.cc
@@ -6,9 +6,10 @@
 
 #include "base/command_line.h"
 #include "base/test/scoped_task_environment.h"
+#include "testing/gtest/include/gtest/gtest.h"
 #include "ui/display/display_switches.h"
 #include "ui/display/screen.h"
-#include "ui/views/test/views_test_base.h"
+#include "ui/views/test/scoped_views_test_helper.h"
 
 namespace views {
 namespace {
@@ -26,7 +27,34 @@
   return results;
 }
 
-using ScreenMusTest = ViewsTestWithDesktopNativeWidget;
+TEST(ScreenMusScaleFactorTest, ConsistentDisplayInHighDPI) {
+  base::test::ScopedTaskEnvironment task_environment(
+      base::test::ScopedTaskEnvironment::MainThreadType::UI);
+  // Must be set before |test_helper| is constructed.
+  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+      switches::kForceDeviceScaleFactor, "2");
+  ScopedViewsTestHelper test_helper;
+  display::Screen* screen = display::Screen::GetScreen();
+  std::vector<display::Display> displays = screen->GetAllDisplays();
+  ASSERT_FALSE(displays.empty());
+  for (const display::Display& display : displays) {
+    EXPECT_EQ(2.f, display.device_scale_factor());
+    EXPECT_EQ(display.work_area(), display.bounds());
+  }
+}
+
+class ScreenMusTest : public testing::Test {
+ public:
+  ScreenMusTest() = default;
+  ~ScreenMusTest() override = default;
+
+ private:
+  base::test::ScopedTaskEnvironment task_environment_{
+      base::test::ScopedTaskEnvironment::MainThreadType::UI};
+  ScopedViewsTestHelper test_helper_;
+
+  DISALLOW_COPY_AND_ASSIGN(ScreenMusTest);
+};
 
 TEST_F(ScreenMusTest, PrimaryChangedToExisting) {
   ScreenMus* screen = static_cast<ScreenMus*>(display::Screen::GetScreen());
@@ -95,30 +123,5 @@
   EXPECT_EQ(kDisplayId1, screen->GetDisplayForNewWindows().id());
 }
 
-class ScreenMusScaleFactorTest : public ScreenMusTest {
- public:
-  ScreenMusScaleFactorTest() = default;
-  ~ScreenMusScaleFactorTest() override = default;
-
-  void SetUp() override {
-    base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-        switches::kForceDeviceScaleFactor, "2");
-    ScreenMusTest::SetUp();
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(ScreenMusScaleFactorTest);
-};
-
-TEST_F(ScreenMusScaleFactorTest, ConsistentDisplayInHighDPI) {
-  display::Screen* screen = display::Screen::GetScreen();
-  std::vector<display::Display> displays = screen->GetAllDisplays();
-  ASSERT_FALSE(displays.empty());
-  for (const display::Display& display : displays) {
-    EXPECT_EQ(2.f, display.device_scale_factor());
-    EXPECT_EQ(display.work_area(), display.bounds());
-  }
-}
-
 }  // namespace
 }  // namespace views
diff --git a/ui/views/unittests_manifest.json b/ui/views/mus/unittests_manifest.json
similarity index 65%
rename from ui/views/unittests_manifest.json
rename to ui/views/mus/unittests_manifest.json
index 172d8982..ad20202 100644
--- a/ui/views/unittests_manifest.json
+++ b/ui/views/mus/unittests_manifest.json
@@ -1,6 +1,6 @@
 {
-  "name": "views_unittests",
-  "display_name": "Views Unittests",
+  "name": "views_mus_unittests",
+  "display_name": "Views Mus Unittests",
   "interface_provider_specs": {
     "service_manager:connector": {
       "requires": {
diff --git a/ui/views/mus/views_mus_test_suite.cc b/ui/views/mus/views_mus_test_suite.cc
new file mode 100644
index 0000000..befc9bd2
--- /dev/null
+++ b/ui/views/mus/views_mus_test_suite.cc
@@ -0,0 +1,249 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/mus/views_mus_test_suite.h"
+
+#include <memory>
+#include <string>
+
+#include "base/base_switches.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/threading/simple_thread.h"
+#include "mojo/core/embedder/embedder.h"
+#include "mojo/core/embedder/scoped_ipc_support.h"
+#include "services/catalog/catalog.h"
+#include "services/service_manager/background/background_service_manager.h"
+#include "services/service_manager/public/cpp/connector.h"
+#include "services/service_manager/public/cpp/constants.h"
+#include "services/service_manager/public/cpp/service.h"
+#include "services/service_manager/public/cpp/service_binding.h"
+#include "services/ws/common/switches.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/aura/env.h"
+#include "ui/aura/mus/window_tree_host_mus.h"
+#include "ui/aura/test/mus/input_method_mus_test_api.h"
+#include "ui/aura/window.h"
+#include "ui/base/ui_base_features.h"
+#include "ui/base/ui_base_switches.h"
+#include "ui/compositor/test/fake_context_factory.h"
+#include "ui/gl/gl_switches.h"
+#include "ui/views/mus/desktop_window_tree_host_mus.h"
+#include "ui/views/mus/mus_client.h"
+#include "ui/views/mus/views_mus_tests_catalog_source.h"
+#include "ui/views/test/platform_test_helper.h"
+#include "ui/views/test/views_test_helper_aura.h"
+#include "ui/views/views_delegate.h"
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+
+namespace views {
+namespace {
+
+void EnsureCommandLineSwitch(const std::string& name) {
+  base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
+  if (!cmd_line->HasSwitch(name))
+    cmd_line->AppendSwitch(name);
+}
+
+class ServiceManagerConnection {
+ public:
+  ServiceManagerConnection()
+      : thread_("Persistent service_manager connections"),
+        default_service_binding_(&default_service_) {
+    catalog::Catalog::SetDefaultCatalogManifest(CreateViewsMusTestsCatalog());
+    base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+                             base::WaitableEvent::InitialState::NOT_SIGNALED);
+    base::Thread::Options options;
+    thread_.StartWithOptions(options);
+    thread_.task_runner()->PostTask(
+        FROM_HERE,
+        base::BindOnce(
+            &ServiceManagerConnection::SetUpConnectionsOnBackgroundThread,
+            base::Unretained(this), &wait));
+    wait.Wait();
+  }
+
+  ~ServiceManagerConnection() {
+    base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+                             base::WaitableEvent::InitialState::NOT_SIGNALED);
+    thread_.task_runner()->PostTask(
+        FROM_HERE,
+        base::BindOnce(
+            &ServiceManagerConnection::TearDownConnectionsOnBackgroundThread,
+            base::Unretained(this), &wait));
+    wait.Wait();
+  }
+
+  std::unique_ptr<MusClient> CreateMusClient() {
+    MusClient::InitParams params;
+    params.connector = GetConnector();
+    params.identity = service_manager_identity_;
+    return std::make_unique<MusClient>(params);
+  }
+
+ private:
+  service_manager::Connector* GetConnector() {
+    service_manager_connector_.reset();
+    base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
+                             base::WaitableEvent::InitialState::NOT_SIGNALED);
+    thread_.task_runner()->PostTask(
+        FROM_HERE, base::BindOnce(&ServiceManagerConnection::CloneConnector,
+                                  base::Unretained(this), &wait));
+    wait.Wait();
+    DCHECK(service_manager_connector_);
+    return service_manager_connector_.get();
+  }
+
+  void CloneConnector(base::WaitableEvent* wait) {
+    service_manager_connector_ =
+        default_service_binding_.GetConnector()->Clone();
+    wait->Signal();
+  }
+
+  void SetUpConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
+    background_service_manager_ =
+        std::make_unique<service_manager::BackgroundServiceManager>(nullptr,
+                                                                    nullptr);
+    service_manager::mojom::ServicePtr service;
+    default_service_binding_.Bind(mojo::MakeRequest(&service));
+    background_service_manager_->RegisterService(
+        service_manager::Identity(GetTestName(),
+                                  service_manager::kSystemInstanceGroup,
+                                  base::Token{}, base::Token::CreateRandom()),
+        std::move(service), nullptr);
+    service_manager_connector_ =
+        default_service_binding_.GetConnector()->Clone();
+    service_manager_identity_ = default_service_binding_.identity();
+    wait->Signal();
+  }
+
+  void TearDownConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
+    default_service_binding_.Close();
+    background_service_manager_.reset();
+    wait->Signal();
+  }
+
+  // Returns the name of the test executable, e.g. "views_mus_unittests".
+  std::string GetTestName() {
+    base::FilePath executable = base::CommandLine::ForCurrentProcess()
+                                    ->GetProgram()
+                                    .BaseName()
+                                    .RemoveExtension();
+    return executable.MaybeAsASCII();
+  }
+
+  base::Thread thread_;
+  std::unique_ptr<service_manager::BackgroundServiceManager>
+      background_service_manager_;
+  service_manager::Service default_service_;
+  service_manager::ServiceBinding default_service_binding_;
+  std::unique_ptr<service_manager::Connector> service_manager_connector_;
+  service_manager::Identity service_manager_identity_;
+
+  DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnection);
+};
+
+class PlatformTestHelperMus : public PlatformTestHelper {
+ public:
+  PlatformTestHelperMus() {
+    mus_client_ = service_manager_connection_.CreateMusClient();
+    ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind(
+        &PlatformTestHelperMus::CreateNativeWidget, base::Unretained(this)));
+  }
+  ~PlatformTestHelperMus() override {}
+
+  // PlatformTestHelper:
+  void OnTestHelperCreated(ViewsTestHelper* helper) override {
+    static_cast<ViewsTestHelperAura*>(helper)->EnableMusWithWindowTreeClient(
+        mus_client_->window_tree_client());
+  }
+  void SimulateNativeDestroy(Widget* widget) override {
+    aura::WindowTreeHostMus* window_tree_host =
+        static_cast<aura::WindowTreeHostMus*>(
+            widget->GetNativeView()->GetHost());
+    static_cast<aura::WindowTreeClientDelegate*>(mus_client_.get())
+        ->OnEmbedRootDestroyed(window_tree_host);
+  }
+
+  void InitializeContextFactory(
+      ui::ContextFactory** context_factory,
+      ui::ContextFactoryPrivate** context_factory_private) override {
+    *context_factory = &context_factory_;
+    *context_factory_private = nullptr;
+  }
+
+ private:
+  NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params,
+                                   internal::NativeWidgetDelegate* delegate) {
+    NativeWidget* native_widget =
+        mus_client_->CreateNativeWidget(init_params, delegate);
+    if (!native_widget)
+      return nullptr;
+
+    // Disable sending KeyEvents to IME as tests aren't set up to wait for an
+    // ack (and tests run concurrently).
+    aura::WindowTreeHostMus* window_tree_host_mus =
+        static_cast<aura::WindowTreeHostMus*>(
+            static_cast<DesktopNativeWidgetAura*>(native_widget)->host());
+    aura::InputMethodMusTestApi::Disable(window_tree_host_mus->input_method());
+    return native_widget;
+  }
+
+  ServiceManagerConnection service_manager_connection_;
+  std::unique_ptr<MusClient> mus_client_;
+  ui::FakeContextFactory context_factory_;
+
+  DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
+};
+
+std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper() {
+  return std::make_unique<PlatformTestHelperMus>();
+}
+
+}  // namespace
+
+ViewsMusTestSuite::ViewsMusTestSuite(int argc, char** argv)
+    : ViewsTestSuite(argc, argv), ipc_thread_("IPC thread") {}
+
+ViewsMusTestSuite::~ViewsMusTestSuite() {}
+
+void ViewsMusTestSuite::Initialize() {
+  PlatformTestHelper::SetIsMus();
+  // Let other services know that we're running in tests. Do this with a
+  // command line flag to avoid making blocking calls to other processes for
+  // setup for tests (e.g. to unlock the screen in the window manager).
+  EnsureCommandLineSwitch(ws::switches::kUseTestConfig);
+
+  EnsureCommandLineSwitch(switches::kOverrideUseSoftwareGLForTests);
+
+  ViewsTestSuite::Initialize();
+
+  // NOTE: this has to be after ViewsTestSuite::Initialize() as
+  // TestSuite::Initialize() resets kEnableFeatures and the command line.
+  feature_list_.InitAndEnableFeature(features::kMash);
+  base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+      switches::kEnableFeatures, features::kMash.name);
+
+  PlatformTestHelper::set_factory(base::Bind(&CreatePlatformTestHelper));
+
+  mojo::core::Init();
+  ipc_thread_.StartWithOptions(
+      base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
+  ipc_support_ = std::make_unique<mojo::core::ScopedIPCSupport>(
+      ipc_thread_.task_runner(),
+      mojo::core::ScopedIPCSupport::ShutdownPolicy::CLEAN);
+}
+
+void ViewsMusTestSuite::InitializeEnv() {
+  env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS);
+}
+
+void ViewsMusTestSuite::DestroyEnv() {
+  env_.reset();
+}
+
+}  // namespace views
diff --git a/ui/views/mus/views_mus_test_suite.h b/ui/views/mus/views_mus_test_suite.h
new file mode 100644
index 0000000..8490ab91
--- /dev/null
+++ b/ui/views/mus/views_mus_test_suite.h
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_MUS_VIEWS_MUS_TEST_SUITE_H_
+#define UI_VIEWS_MUS_VIEWS_MUS_TEST_SUITE_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/test/scoped_feature_list.h"
+#include "base/threading/thread.h"
+#include "ui/views/views_test_suite.h"
+
+namespace mojo {
+namespace core {
+class ScopedIPCSupport;
+}
+}  // namespace mojo
+
+namespace views {
+
+class ViewsMusTestSuite : public ViewsTestSuite {
+ public:
+  ViewsMusTestSuite(int argc, char** argv);
+  ~ViewsMusTestSuite() override;
+
+ private:
+  // ViewsTestSuite:
+  void Initialize() override;
+  void InitializeEnv() override;
+  void DestroyEnv() override;
+
+  base::Thread ipc_thread_;
+  std::unique_ptr<mojo::core::ScopedIPCSupport> ipc_support_;
+
+  base::test::ScopedFeatureList feature_list_;
+
+  std::unique_ptr<aura::Env> env_;
+
+  DISALLOW_COPY_AND_ASSIGN(ViewsMusTestSuite);
+};
+
+}  // namespace views
+
+#endif  // UI_VIEWS_MUS_VIEWS_MUS_TEST_SUITE_H_
diff --git a/ui/views/test/DEPS b/ui/views/test/DEPS
index 0919d159..d47da7cf 100644
--- a/ui/views/test/DEPS
+++ b/ui/views/test/DEPS
@@ -3,9 +3,7 @@
 ]
 
 specific_include_rules = {
-  "platform_test_helper_mus.cc": [
-    "+services/catalog/catalog.h",
-    "+services/service_manager/background/background_service_manager.h",
-    "+services/service_manager/public",
+  "views_interactive_ui_test_base\.cc": [
+    "+mojo/core/embedder",
   ]
 }
diff --git a/ui/views/test/event_generator_delegate_mac.mm b/ui/views/test/event_generator_delegate_mac.mm
index f6c433c0..ede2a1e 100644
--- a/ui/views/test/event_generator_delegate_mac.mm
+++ b/ui/views/test/event_generator_delegate_mac.mm
@@ -7,8 +7,8 @@
 
 #import "base/mac/scoped_nsobject.h"
 #import "base/mac/scoped_objc_class_swizzler.h"
-#include "base/macros.h"
 #include "base/memory/singleton.h"
+#include "base/stl_util.h"
 #include "ui/base/cocoa/cocoa_base_utils.h"
 #include "ui/events/event_processor.h"
 #include "ui/events/event_target.h"
@@ -369,7 +369,7 @@
       {@"Paste", @selector(paste:), @"v"},
       {@"Select All", @selector(selectAll:), @"a"},
   };
-  for (size_t i = 0; i < arraysize(fake_menu_item); ++i) {
+  for (size_t i = 0; i < base::size(fake_menu_item); ++i) {
     [fake_menu_ insertItemWithTitle:fake_menu_item[i].title
                              action:fake_menu_item[i].action
                       keyEquivalent:fake_menu_item[i].key_equivalent
diff --git a/ui/views/test/focus_manager_test.cc b/ui/views/test/focus_manager_test.cc
index 13ea5a6..373846c 100644
--- a/ui/views/test/focus_manager_test.cc
+++ b/ui/views/test/focus_manager_test.cc
@@ -14,9 +14,14 @@
 ////////////////////////////////////////////////////////////////////////////////
 // FocusManagerTest, public:
 
-FocusManagerTest::FocusManagerTest() : contents_view_(new View) {}
+FocusManagerTest::FocusManagerTest()
+    : contents_view_(new View),
+      focus_change_listener_(NULL),
+      widget_focus_change_listener_(NULL) {
+}
 
-FocusManagerTest::~FocusManagerTest() = default;
+FocusManagerTest::~FocusManagerTest() {
+}
 
 FocusManager* FocusManagerTest::GetFocusManager() {
   return GetWidget()->GetFocusManager();
diff --git a/ui/views/test/focus_manager_test.h b/ui/views/test/focus_manager_test.h
index 0efde67..fb2a292f7 100644
--- a/ui/views/test/focus_manager_test.h
+++ b/ui/views/test/focus_manager_test.h
@@ -46,8 +46,8 @@
 
  private:
   View* contents_view_;
-  FocusChangeListener* focus_change_listener_ = nullptr;
-  WidgetFocusChangeListener* widget_focus_change_listener_ = nullptr;
+  FocusChangeListener* focus_change_listener_;
+  WidgetFocusChangeListener* widget_focus_change_listener_;
   std::vector<View*> accessible_panes_;
 
   DISALLOW_COPY_AND_ASSIGN(FocusManagerTest);
diff --git a/ui/views/test/native_widget_factory.cc b/ui/views/test/native_widget_factory.cc
deleted file mode 100644
index a62e7e2..0000000
--- a/ui/views/test/native_widget_factory.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/test/native_widget_factory.h"
-
-#include "build/build_config.h"
-#include "ui/views/test/test_platform_native_widget.h"
-
-#if defined(USE_AURA)
-#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
-#include "ui/views/widget/native_widget_aura.h"
-#elif defined(OS_MACOSX)
-#include "ui/views/widget/native_widget_mac.h"
-#endif
-
-namespace views {
-namespace test {
-
-NativeWidget* CreatePlatformNativeWidgetImpl(
-    const Widget::InitParams& init_params,
-    Widget* widget,
-    uint32_t type,
-    bool* destroyed) {
-#if defined(OS_MACOSX)
-  return new TestPlatformNativeWidget<NativeWidgetMac>(
-      widget, type == kStubCapture, destroyed);
-#else
-  return new TestPlatformNativeWidget<NativeWidgetAura>(
-      widget, type == kStubCapture, destroyed);
-#endif
-}
-
-}  // namespace test
-}  // namespace views
diff --git a/ui/views/test/native_widget_factory.h b/ui/views/test/native_widget_factory.h
index a0aeda8e..7ade865 100644
--- a/ui/views/test/native_widget_factory.h
+++ b/ui/views/test/native_widget_factory.h
@@ -30,6 +30,15 @@
     uint32_t behavior,
     bool* destroyed);
 
+// Creates the appropriate desktop platform specific NativeWidget
+// implementation. On some platforms this is the same as
+// CreatePlatformNativeWidgetImpl(). If |destroyed| is non-null it it set to
+// true from the destructor of the NativeWidget.
+NativeWidget* CreatePlatformDesktopNativeWidgetImpl(
+    const Widget::InitParams& init_params,
+    Widget* widget,
+    bool* destroyed);
+
 }  // namespace test
 }  // namespace views
 
diff --git a/ui/views/test/native_widget_factory_aura_mus.cc b/ui/views/test/native_widget_factory_aura_mus.cc
new file mode 100644
index 0000000..e99ad33
--- /dev/null
+++ b/ui/views/test/native_widget_factory_aura_mus.cc
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/test/native_widget_factory.h"
+
+#include "ui/aura/mus/window_tree_host_mus_init_params.h"
+#include "ui/views/mus/desktop_window_tree_host_mus.h"
+#include "ui/views/mus/mus_client.h"
+#include "ui/views/test/test_platform_native_widget.h"
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+#include "ui/views/widget/native_widget_aura.h"
+
+namespace views {
+namespace test {
+namespace {
+
+NativeWidget* CreatePlatformNativeWidgetImplAuraMus(
+    bool create_desktop_native_widget_aura,
+    const Widget::InitParams& init_params,
+    Widget* widget,
+    int32_t type,
+    bool* destroyed) {
+  if (!create_desktop_native_widget_aura) {
+    return new TestPlatformNativeWidget<NativeWidgetAura>(
+        widget, type == kStubCapture, destroyed);
+  }
+  DesktopNativeWidgetAura* desktop_native_widget_aura =
+      new TestPlatformNativeWidget<DesktopNativeWidgetAura>(
+          widget, type == kStubCapture, destroyed);
+  std::map<std::string, std::vector<uint8_t>> mus_properties =
+      MusClient::Get()->ConfigurePropertiesFromParams(init_params);
+  aura::WindowTreeHostMusInitParams window_tree_host_init_params =
+      aura::CreateInitParamsForTopLevel(MusClient::Get()->window_tree_client(),
+                                        std::move(mus_properties));
+  desktop_native_widget_aura->SetDesktopWindowTreeHost(
+      std::make_unique<DesktopWindowTreeHostMus>(
+          std::move(window_tree_host_init_params), widget,
+          desktop_native_widget_aura));
+  return desktop_native_widget_aura;
+}
+
+}  // namespace
+
+NativeWidget* CreatePlatformNativeWidgetImpl(
+    const Widget::InitParams& init_params,
+    Widget* widget,
+    uint32_t type,
+    bool* destroyed) {
+  // Only create a NativeWidgetAura if necessary, otherwise use
+  // DesktopNativeWidgetAura.
+  return CreatePlatformNativeWidgetImplAuraMus(
+      MusClient::ShouldCreateDesktopNativeWidgetAura(init_params), init_params,
+      widget, type, destroyed);
+}
+
+NativeWidget* CreatePlatformDesktopNativeWidgetImpl(
+    const Widget::InitParams& init_params,
+    Widget* widget,
+    bool* destroyed) {
+  return CreatePlatformNativeWidgetImplAuraMus(true, init_params, widget,
+                                               kDefault, destroyed);
+}
+
+}  // namespace test
+}  // namespace views
diff --git a/ui/views/test/native_widget_factory_desktop.cc b/ui/views/test/native_widget_factory_desktop.cc
new file mode 100644
index 0000000..1dbe1d3
--- /dev/null
+++ b/ui/views/test/native_widget_factory_desktop.cc
@@ -0,0 +1,55 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/test/native_widget_factory.h"
+
+#include "ui/views/test/test_platform_native_widget.h"
+
+#if defined(USE_AURA)
+#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+#include "ui/views/widget/native_widget_aura.h"
+#elif defined(OS_MACOSX)
+#include "ui/views/widget/native_widget_mac.h"
+#endif
+
+namespace views {
+namespace test {
+
+NativeWidget* CreatePlatformNativeWidgetImpl(
+    const Widget::InitParams& init_params,
+    Widget* widget,
+    uint32_t type,
+    bool* destroyed) {
+#if defined(OS_MACOSX)
+  return new TestPlatformNativeWidget<NativeWidgetMac>(
+      widget, type == kStubCapture, destroyed);
+#else
+  return new TestPlatformNativeWidget<NativeWidgetAura>(
+      widget, type == kStubCapture, destroyed);
+#endif
+}
+
+NativeWidget* CreatePlatformDesktopNativeWidgetImpl(
+    const Widget::InitParams& init_params,
+    Widget* widget,
+    bool* destroyed) {
+#if defined(OS_MACOSX)
+  return new TestPlatformNativeWidget<NativeWidgetMac>(widget, false,
+                                                       destroyed);
+#elif defined(OS_CHROMEOS)
+  // Chromeos only has one NativeWidgetType. Chromeos with aura-mus does not
+  // compile this file.
+  return new TestPlatformNativeWidget<NativeWidgetAura>(widget, false,
+                                                        destroyed);
+#elif defined(USE_AURA)
+  return new TestPlatformNativeWidget<DesktopNativeWidgetAura>(widget, false,
+                                                               destroyed);
+#else
+  NOTREACHED();
+  return nullptr;
+#endif
+}
+
+}  // namespace test
+}  // namespace views
diff --git a/ui/views/test/platform_test_helper.cc b/ui/views/test/platform_test_helper.cc
index 46e1f3c..0816cdf 100644
--- a/ui/views/test/platform_test_helper.cc
+++ b/ui/views/test/platform_test_helper.cc
@@ -18,6 +18,7 @@
 namespace {
 
 PlatformTestHelper::Factory test_helper_factory;
+bool is_mus = false;
 
 }  // namespace
 
@@ -26,7 +27,7 @@
 }
 
 void PlatformTestHelper::set_factory(const Factory& factory) {
-  DCHECK_NE(factory.is_null(), test_helper_factory.is_null());
+  DCHECK(test_helper_factory.is_null());
   test_helper_factory = factory;
 }
 
@@ -37,6 +38,16 @@
              : base::WrapUnique(new PlatformTestHelper);
 }
 
+// static
+void PlatformTestHelper::SetIsMus() {
+  is_mus = true;
+}
+
+// static
+bool PlatformTestHelper::IsMus() {
+  return is_mus;
+}
+
 #if defined(USE_AURA)
 void PlatformTestHelper::SimulateNativeDestroy(Widget* widget) {
   delete widget->GetNativeView();
diff --git a/ui/views/test/platform_test_helper.h b/ui/views/test/platform_test_helper.h
index 7d6670b..64423afc 100644
--- a/ui/views/test/platform_test_helper.h
+++ b/ui/views/test/platform_test_helper.h
@@ -29,6 +29,9 @@
   static void set_factory(const Factory& factory);
   static std::unique_ptr<PlatformTestHelper> Create();
 
+  static void SetIsMus();
+  static bool IsMus();
+
   // Called once the ViewsTestHelper has been created, but before SetUp() is
   // called.
   virtual void OnTestHelperCreated(ViewsTestHelper* helper) {}
diff --git a/ui/views/test/platform_test_helper_mus.cc b/ui/views/test/platform_test_helper_mus.cc
deleted file mode 100644
index da05fee0..0000000
--- a/ui/views/test/platform_test_helper_mus.cc
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/views/test/platform_test_helper_mus.h"
-
-#include "base/command_line.h"
-#include "base/files/file_path.h"
-#include "base/threading/simple_thread.h"
-#include "services/catalog/catalog.h"
-#include "services/service_manager/background/background_service_manager.h"
-#include "services/service_manager/public/cpp/connector.h"
-#include "services/service_manager/public/cpp/constants.h"
-#include "services/service_manager/public/cpp/service.h"
-#include "services/service_manager/public/cpp/service_binding.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/aura/mus/window_tree_host_mus.h"
-#include "ui/aura/test/env_test_helper.h"
-#include "ui/aura/test/mus/input_method_mus_test_api.h"
-#include "ui/aura/window.h"
-#include "ui/views/mus/desktop_window_tree_host_mus.h"
-#include "ui/views/mus/mus_client.h"
-#include "ui/views/test/views_test_helper_aura.h"
-#include "ui/views/views_delegate.h"
-#include "ui/views/views_unittests_catalog_source.h"
-#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
-#include "ui/views/widget/native_widget_aura.h"
-
-namespace views {
-
-namespace {
-
-NativeWidget* CreateNativeWidget(const Widget::InitParams& init_params,
-                                 internal::NativeWidgetDelegate* delegate) {
-  NativeWidget* native_widget =
-      MusClient::Get()->CreateNativeWidget(init_params, delegate);
-  if (!native_widget)
-    return nullptr;
-
-  // Disable sending KeyEvents to IME as tests aren't set up to wait for an
-  // ack (and tests run concurrently).
-  aura::WindowTreeHostMus* window_tree_host_mus =
-      static_cast<aura::WindowTreeHostMus*>(
-          static_cast<DesktopNativeWidgetAura*>(native_widget)->host());
-  aura::InputMethodMusTestApi::Disable(window_tree_host_mus->input_method());
-  return native_widget;
-}
-
-}  // namespace
-
-class PlatformTestHelperMus::ServiceManagerConnection {
- public:
-  ServiceManagerConnection()
-      : thread_("Persistent service_manager connections"),
-        default_service_binding_(&default_service_) {
-    base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
-                             base::WaitableEvent::InitialState::NOT_SIGNALED);
-    base::Thread::Options options;
-    thread_.StartWithOptions(options);
-    thread_.task_runner()->PostTask(
-        FROM_HERE,
-        base::BindOnce(
-            &ServiceManagerConnection::SetUpConnectionsOnBackgroundThread,
-            base::Unretained(this), &wait));
-    wait.Wait();
-  }
-
-  ~ServiceManagerConnection() {
-    base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
-                             base::WaitableEvent::InitialState::NOT_SIGNALED);
-    thread_.task_runner()->PostTask(
-        FROM_HERE,
-        base::BindOnce(
-            &ServiceManagerConnection::TearDownConnectionsOnBackgroundThread,
-            base::Unretained(this), &wait));
-    wait.Wait();
-  }
-
-  std::unique_ptr<MusClient> CreateMusClient() {
-    MusClient::InitParams params;
-    params.connector = GetConnector();
-    params.identity = service_manager_identity_;
-    // The window tree client might have been created already by the test suite
-    // (e.g. AuraTestSuiteSetup).
-    params.window_tree_client =
-        aura::test::EnvTestHelper().GetWindowTreeClient();
-    return std::make_unique<MusClient>(params);
-  }
-
- private:
-  service_manager::Connector* GetConnector() {
-    service_manager_connector_.reset();
-    base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::AUTOMATIC,
-                             base::WaitableEvent::InitialState::NOT_SIGNALED);
-    thread_.task_runner()->PostTask(
-        FROM_HERE, base::BindOnce(&ServiceManagerConnection::CloneConnector,
-                                  base::Unretained(this), &wait));
-    wait.Wait();
-    DCHECK(service_manager_connector_);
-    return service_manager_connector_.get();
-  }
-
-  void CloneConnector(base::WaitableEvent* wait) {
-    service_manager_connector_ =
-        default_service_binding_.GetConnector()->Clone();
-    wait->Signal();
-  }
-
-  void SetUpConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
-    background_service_manager_ =
-        std::make_unique<service_manager::BackgroundServiceManager>(
-            nullptr, CreateViewsUnittestsCatalog());
-    service_manager::mojom::ServicePtr service;
-    default_service_binding_.Bind(mojo::MakeRequest(&service));
-    background_service_manager_->RegisterService(
-        service_manager::Identity(GetTestName(),
-                                  service_manager::kSystemInstanceGroup,
-                                  base::Token{}, base::Token::CreateRandom()),
-        std::move(service), nullptr);
-    service_manager_connector_ =
-        default_service_binding_.GetConnector()->Clone();
-    service_manager_identity_ = default_service_binding_.identity();
-    wait->Signal();
-  }
-
-  void TearDownConnectionsOnBackgroundThread(base::WaitableEvent* wait) {
-    default_service_binding_.Close();
-    background_service_manager_.reset();
-    wait->Signal();
-  }
-
-  // Returns the name of the test executable, e.g. "views_unittests".
-  std::string GetTestName() {
-    base::FilePath executable = base::CommandLine::ForCurrentProcess()
-                                    ->GetProgram()
-                                    .BaseName()
-                                    .RemoveExtension();
-    return executable.MaybeAsASCII();
-  }
-
-  base::Thread thread_;
-  std::unique_ptr<service_manager::BackgroundServiceManager>
-      background_service_manager_;
-  service_manager::Service default_service_;
-  service_manager::ServiceBinding default_service_binding_;
-  std::unique_ptr<service_manager::Connector> service_manager_connector_;
-  service_manager::Identity service_manager_identity_;
-
-  DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnection);
-};
-
-PlatformTestHelperMus::PlatformTestHelperMus() {
-  service_manager_connection_ = std::make_unique<ServiceManagerConnection>();
-  mus_client_ = service_manager_connection_->CreateMusClient();
-  ViewsDelegate::GetInstance()->set_native_widget_factory(
-      base::BindRepeating(&CreateNativeWidget));
-}
-
-PlatformTestHelperMus::~PlatformTestHelperMus() = default;
-
-void PlatformTestHelperMus::OnTestHelperCreated(ViewsTestHelper* helper) {
-  static_cast<ViewsTestHelperAura*>(helper)->EnableMusWithWindowTreeClient(
-      mus_client_->window_tree_client());
-}
-
-void PlatformTestHelperMus::SimulateNativeDestroy(Widget* widget) {
-  aura::WindowTreeHostMus* window_tree_host =
-      static_cast<aura::WindowTreeHostMus*>(widget->GetNativeView()->GetHost());
-  static_cast<aura::WindowTreeClientDelegate*>(mus_client_.get())
-      ->OnEmbedRootDestroyed(window_tree_host);
-}
-
-void PlatformTestHelperMus::InitializeContextFactory(
-    ui::ContextFactory** context_factory,
-    ui::ContextFactoryPrivate** context_factory_private) {
-  *context_factory = &context_factory_;
-  *context_factory_private = nullptr;
-}
-
-}  // namespace views
diff --git a/ui/views/test/platform_test_helper_mus.h b/ui/views/test/platform_test_helper_mus.h
deleted file mode 100644
index afc3245..0000000
--- a/ui/views/test/platform_test_helper_mus.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_VIEWS_TEST_PLATFORM_TEST_HELPER_MUS_H_
-#define UI_VIEWS_TEST_PLATFORM_TEST_HELPER_MUS_H_
-
-#include "base/macros.h"
-#include "ui/compositor/test/fake_context_factory.h"
-#include "ui/views/test/platform_test_helper.h"
-
-namespace views {
-
-class MusClient;
-
-class PlatformTestHelperMus : public PlatformTestHelper {
- public:
-  PlatformTestHelperMus();
-  ~PlatformTestHelperMus() override;
-
-  // PlatformTestHelper:
-  void OnTestHelperCreated(ViewsTestHelper* helper) override;
-  void SimulateNativeDestroy(Widget* widget) override;
-  void InitializeContextFactory(
-      ui::ContextFactory** context_factory,
-      ui::ContextFactoryPrivate** context_factory_private) override;
-
- private:
-  class ServiceManagerConnection;
-
-  std::unique_ptr<ServiceManagerConnection> service_manager_connection_;
-  std::unique_ptr<MusClient> mus_client_;
-  ui::FakeContextFactory context_factory_;
-
-  DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
-};
-
-}  // namespace views
-
-#endif  // UI_VIEWS_TEST_PLATFORM_TEST_HELPER_MUS_H_
diff --git a/ui/views/test/views_interactive_ui_test_base.cc b/ui/views/test/views_interactive_ui_test_base.cc
index 5285d08..eb9377c 100644
--- a/ui/views/test/views_interactive_ui_test_base.cc
+++ b/ui/views/test/views_interactive_ui_test_base.cc
@@ -4,14 +4,34 @@
 
 #include "ui/views/test/views_interactive_ui_test_base.h"
 
+#include "base/path_service.h"
+#include "mojo/core/embedder/embedder.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/gl/test/gl_surface_test_support.h"
+
 namespace views {
 
-ViewsInteractiveUITestBase::ViewsInteractiveUITestBase() = default;
-ViewsInteractiveUITestBase::~ViewsInteractiveUITestBase() = default;
+ViewsInteractiveUITestBase::ViewsInteractiveUITestBase() {}
+
+ViewsInteractiveUITestBase::~ViewsInteractiveUITestBase() {}
+
+// static
+void ViewsInteractiveUITestBase::InteractiveSetUp() {
+  // Mojo is initialized here similar to how each browser test case initializes
+  // Mojo when starting. This only works because each interactive_ui_test runs
+  // in a new process.
+  mojo::core::Init();
+
+  gl::GLSurfaceTestSupport::InitializeOneOff();
+  ui::RegisterPathProvider();
+  base::FilePath ui_test_pak_path;
+  ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+  ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+}
 
 void ViewsInteractiveUITestBase::SetUp() {
-  set_native_widget_type(NativeWidgetType::kDesktop);
-  SetUpForInteractiveTests();
+  InteractiveSetUp();
   ViewsTestBase::SetUp();
 }
 
diff --git a/ui/views/test/views_interactive_ui_test_base.h b/ui/views/test/views_interactive_ui_test_base.h
index 4049b66..3c3e0e2 100644
--- a/ui/views/test/views_interactive_ui_test_base.h
+++ b/ui/views/test/views_interactive_ui_test_base.h
@@ -15,6 +15,8 @@
   ViewsInteractiveUITestBase();
   ~ViewsInteractiveUITestBase() override;
 
+  static void InteractiveSetUp();
+
   // ViewsTestBase:
   void SetUp() override;
 
diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc
index 1674d6c4e..633235b 100644
--- a/ui/views/test/views_test_base.cc
+++ b/ui/views/test/views_test_base.cc
@@ -7,41 +7,10 @@
 #include <utility>
 
 #include "base/environment.h"
-#include "base/files/file_path.h"
-#include "base/path_service.h"
 #include "base/run_loop.h"
-#include "mojo/core/embedder/embedder.h"
 #include "ui/base/clipboard/clipboard.h"
 #include "ui/base/material_design/material_design_controller.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/ui_base_paths.h"
-#include "ui/base/ui_features.h"
-#include "ui/gl/test/gl_surface_test_support.h"
 #include "ui/views/test/platform_test_helper.h"
-#include "ui/views/test/test_platform_native_widget.h"
-
-#if BUILDFLAG(ENABLE_MUS)
-#include "base/at_exit.h"
-#include "base/base_switches.h"
-#include "base/command_line.h"
-#include "base/message_loop/message_loop.h"
-#include "base/threading/simple_thread.h"
-#include "base/threading/thread.h"
-#include "mojo/core/embedder/scoped_ipc_support.h"
-#include "services/ws/common/switches.h"
-#include "ui/aura/env.h"
-#include "ui/base/ui_base_features.h"
-#include "ui/base/ui_base_switches.h"
-#include "ui/views/test/platform_test_helper_mus.h"
-#include "ui/views/views_delegate.h"
-#endif
-
-#if defined(USE_AURA)
-#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
-#include "ui/views/widget/native_widget_aura.h"
-#elif defined(OS_MACOSX)
-#include "ui/views/widget/native_widget_mac.h"
-#endif
 
 #if defined(USE_X11)
 #include "ui/base/x/x11_util_internal.h"
@@ -75,15 +44,14 @@
 #endif
 }
 
-#if BUILDFLAG(ENABLE_MUS)
-std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper() {
-  return std::make_unique<PlatformTestHelperMus>();
-}
-#endif  // BUILDFLAG(ENABLE_MUS)
-
 }  // namespace
 
-ViewsTestBase::ViewsTestBase() = default;
+ViewsTestBase::ViewsTestBase(
+    std::unique_ptr<ScopedTaskEnvironment> scoped_task_environment)
+    : scoped_task_environment_(std::move(scoped_task_environment)),
+      setup_called_(false),
+      teardown_called_(false),
+      has_compositing_manager_(InitializeVisuals()) {}
 
 ViewsTestBase::~ViewsTestBase() {
   CHECK(setup_called_)
@@ -92,62 +60,23 @@
       << "You have overridden TearDown but never called super class's TearDown";
 }
 
+// static
+bool ViewsTestBase::IsMus() {
+  return PlatformTestHelper::IsMus();
+}
+
 void ViewsTestBase::SetUp() {
-  if (!scoped_task_environment_) {
-    scoped_task_environment_ = std::make_unique<ScopedTaskEnvironment>(
-        ScopedTaskEnvironment::MainThreadType::UI);
-  }
-
-  has_compositing_manager_ = InitializeVisuals();
-
-#if BUILDFLAG(ENABLE_MUS)
-  at_exit_manager_ = std::make_unique<base::ShadowingAtExitManager>();
-  if (!aura::Env::HasInstance()) {
-    env_ = aura::Env::CreateInstance(is_mus() ? aura::Env::Mode::MUS
-                                              : aura::Env::Mode::LOCAL);
-  }
-#endif
-
   testing::Test::SetUp();
   ui::MaterialDesignController::Initialize();
   setup_called_ = true;
   if (!views_delegate_for_setup_)
     views_delegate_for_setup_.reset(new TestViewsDelegate());
 
-#if BUILDFLAG(ENABLE_MUS)
-  if (is_mus()) {
-    // Set the mash feature flag, but don't override single process mash.
-    if (!features::IsSingleProcessMash()) {
-      feature_list_.InitAndEnableFeature(features::kMash);
-      base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
-          switches::kEnableFeatures, features::kMash.name);
-    }
-
-    PlatformTestHelper::set_factory(
-        base::BindRepeating(&CreatePlatformTestHelper));
-
-    mojo::core::Init();
-    ipc_thread_ = std::make_unique<base::Thread>("IPC thread");
-    ipc_thread_->StartWithOptions(
-        base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
-    ipc_support_ = std::make_unique<mojo::core::ScopedIPCSupport>(
-        ipc_thread_->task_runner(),
-        mojo::core::ScopedIPCSupport::ShutdownPolicy::CLEAN);
-  }
-#else
-  if (native_widget_type_ == NativeWidgetType::kDesktop) {
-    ViewsDelegate::GetInstance()->set_native_widget_factory(base::BindRepeating(
-        &ViewsTestBase::CreateNativeWidgetForTest, base::Unretained(this)));
-  }
-#endif
-
   test_helper_.reset(
       new ScopedViewsTestHelper(std::move(views_delegate_for_setup_)));
 }
 
 void ViewsTestBase::TearDown() {
-  if (interactive_setup_called_)
-    ui::ResourceBundle::CleanupSharedInstance();
   ui::Clipboard::DestroyClipboardForCurrentThread();
 
   // Flush the message loop because we have pending release tasks
@@ -156,38 +85,6 @@
   teardown_called_ = true;
   testing::Test::TearDown();
   test_helper_.reset();
-
-#if BUILDFLAG(ENABLE_MUS)
-  ipc_support_.reset();
-  ipc_thread_.reset();
-  if (is_mus())
-    PlatformTestHelper::set_factory({});
-  env_.reset();
-  at_exit_manager_.reset();
-#endif
-}
-
-void ViewsTestBase::SetUpForInteractiveTests() {
-  DCHECK(!setup_called_);
-  interactive_setup_called_ = true;
-
-#if BUILDFLAG(ENABLE_MUS)
-  bool init_mojo = !is_mus();
-#else
-  bool init_mojo = true;
-#endif
-  if (init_mojo) {
-    // Mojo is initialized here similar to how each browser test case
-    // initializes Mojo when starting. This only works because each
-    // interactive_ui_test runs in a new process.
-    mojo::core::Init();
-  }
-
-  gl::GLSurfaceTestSupport::InitializeOneOff();
-  ui::RegisterPathProvider();
-  base::FilePath ui_test_pak_path;
-  ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
-  ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
 }
 
 void ViewsTestBase::RunPendingMessages() {
@@ -214,39 +111,4 @@
   return test_helper_->GetContext();
 }
 
-NativeWidget* ViewsTestBase::CreateNativeWidgetForTest(
-    const Widget::InitParams& init_params,
-    internal::NativeWidgetDelegate* delegate) {
-#if defined(OS_MACOSX)
-  return new test::TestPlatformNativeWidget<NativeWidgetMac>(delegate, false,
-                                                             nullptr);
-#elif defined(USE_AURA)
-  // For widgets that have a modal parent, don't force a native widget type.
-  // This logic matches DesktopTestViewsDelegate as well as ChromeViewsDelegate.
-  if (init_params.parent &&
-      init_params.type != views::Widget::InitParams::TYPE_MENU &&
-      init_params.type != views::Widget::InitParams::TYPE_TOOLTIP) {
-    // Returning null results in using the platform default, which is
-    // NativeWidgetAura.
-    return nullptr;
-  }
-
-  if (native_widget_type_ == NativeWidgetType::kDesktop) {
-    return new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
-        delegate, false, nullptr);
-  }
-
-  return new test::TestPlatformNativeWidget<NativeWidgetAura>(delegate, true,
-                                                              nullptr);
-#else
-  NOTREACHED();
-  return nullptr;
-#endif
-}
-
-void ViewsTestWithDesktopNativeWidget::SetUp() {
-  set_native_widget_type(NativeWidgetType::kDesktop);
-  ViewsTestBase::SetUp();
-}
-
 }  // namespace views
diff --git a/ui/views/test/views_test_base.h b/ui/views/test/views_test_base.h
index 69f0c259..88a0b8c 100644
--- a/ui/views/test/views_test_base.h
+++ b/ui/views/test/views_test_base.h
@@ -8,12 +8,10 @@
 #include <memory>
 
 #include "base/macros.h"
-#include "base/test/scoped_feature_list.h"
 #include "base/test/scoped_task_environment.h"
 #include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/platform_test.h"
-#include "ui/base/ui_features.h"
 #include "ui/views/test/scoped_views_test_helper.h"
 #include "ui/views/test/test_views_delegate.h"
 #include "ui/views/widget/widget.h"
@@ -22,14 +20,6 @@
 #include "ui/base/win/scoped_ole_initializer.h"
 #endif
 
-namespace aura {
-class Env;
-}
-
-namespace base {
-class ShadowingAtExitManager;
-}
-
 namespace views {
 
 // A base class for views unit test. It creates a message loop necessary
@@ -38,25 +28,21 @@
  public:
   using ScopedTaskEnvironment = base::test::ScopedTaskEnvironment;
 
-  enum class NativeWidgetType {
-    kDefault,  // On Aura, corresponds to NativeWidgetAura.
-    kDesktop,  // On Aura, corresponds to DesktopNativeWidgetAura.
-               // For Mus/ChromeOS, passing this to the ViewsTestBase
-               // constructor will also do necessary Mus setup.
-  };
+  explicit ViewsTestBase(
+      std::unique_ptr<ScopedTaskEnvironment> scoped_task_environment =
+          std::make_unique<ScopedTaskEnvironment>(
+              ScopedTaskEnvironment::MainThreadType::UI));
 
-  ViewsTestBase();
   ~ViewsTestBase() override;
 
+  // Returns true if running aura-mus in a client configuration (not the window
+  // manager).
+  static bool IsMus();
+
   // testing::Test:
   void SetUp() override;
   void TearDown() override;
 
-  // This copies some of the setup done in ViewsTestSuite, so it's only
-  // necessary for a ViewsTestBase that runs out of that test suite, such as in
-  // interactive ui tests.
-  void SetUpForInteractiveTests();
-
   void RunPendingMessages();
 
   // Creates a widget of |type| with any platform specific data for use in
@@ -73,17 +59,6 @@
     return test_helper_->test_views_delegate();
   }
 
-  void set_native_widget_type(NativeWidgetType native_widget_type) {
-    DCHECK(!setup_called_);
-    native_widget_type_ = native_widget_type;
-  }
-
-  void set_scoped_task_environment(
-      std::unique_ptr<ScopedTaskEnvironment> scoped_task_environment) {
-    DCHECK(!setup_called_);
-    scoped_task_environment_ = std::move(scoped_task_environment);
-  }
-
   void set_views_delegate(std::unique_ptr<TestViewsDelegate> views_delegate) {
     DCHECK(!setup_called_);
     views_delegate_for_setup_.swap(views_delegate);
@@ -93,45 +68,13 @@
   // RootWindow. Everywhere else, NULL.
   gfx::NativeWindow GetContext();
 
-#if BUILDFLAG(ENABLE_MUS)
-  bool is_mus() const {
-    return native_widget_type_ == NativeWidgetType::kDesktop;
-  }
-#endif
-
-  // Factory for creating the native widget when |native_widget_type_| is set to
-  // kDesktop.
-  NativeWidget* CreateNativeWidgetForTest(
-      const Widget::InitParams& init_params,
-      internal::NativeWidgetDelegate* delegate);
-
  private:
-  // Controls what type of widget will be created by default for a test (i.e.
-  // when creating a Widget and leaving InitParams::native_widget unspecified).
-  // kDefault will allow the system default to be used (typically
-  // NativeWidgetAura on Aura). kDesktop forces DesktopNativeWidgetAura on Aura.
-  // There are exceptions, such as for modal dialog widgets, for which this
-  // value is ignored.
-  NativeWidgetType native_widget_type_ = NativeWidgetType::kDefault;
-#if BUILDFLAG(ENABLE_MUS)
-  // Needed to make sure the InputDeviceManager is cleaned up between test runs.
-  std::unique_ptr<base::ShadowingAtExitManager> at_exit_manager_;
-  // Unlike on other platforms, |aura::Env| has to be created for each test and
-  // not as part of the test suite, because the type (LOCAL or MUS) depends on
-  // the individual test.
-  std::unique_ptr<aura::Env> env_;
-  std::unique_ptr<base::Thread> ipc_thread_;
-  std::unique_ptr<mojo::core::ScopedIPCSupport> ipc_support_;
-  base::test::ScopedFeatureList feature_list_;
-#endif
-
   std::unique_ptr<ScopedTaskEnvironment> scoped_task_environment_;
   std::unique_ptr<TestViewsDelegate> views_delegate_for_setup_;
   std::unique_ptr<ScopedViewsTestHelper> test_helper_;
-  bool interactive_setup_called_ = false;
-  bool setup_called_ = false;
-  bool teardown_called_ = false;
-  bool has_compositing_manager_ = false;
+  bool setup_called_;
+  bool teardown_called_;
+  bool has_compositing_manager_;
 
 #if defined(OS_WIN)
   ui::ScopedOleInitializer ole_initializer_;
@@ -140,24 +83,6 @@
   DISALLOW_COPY_AND_ASSIGN(ViewsTestBase);
 };
 
-// A helper that makes it easier to declare basic views tests that want to test
-// desktop native widgets. See |ViewsTestBase::native_wiget_type_| and
-// |ViewsTestBase::CreateNativeWidgetForTest|. In short, for Aura, this will
-// result in most Widgets automatically being backed by a
-// DesktopNativeWidgetAura. For Mac, it has no impact as a NativeWidgetMac is
-// used either way.
-class ViewsTestWithDesktopNativeWidget : public ViewsTestBase {
- public:
-  ViewsTestWithDesktopNativeWidget() = default;
-  ~ViewsTestWithDesktopNativeWidget() override = default;
-
-  // ViewsTestBase:
-  void SetUp() override;
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(ViewsTestWithDesktopNativeWidget);
-};
-
 }  // namespace views
 
 #endif  // UI_VIEWS_TEST_VIEWS_TEST_BASE_H_
diff --git a/ui/views/test/views_test_helper_aura.cc b/ui/views/test/views_test_helper_aura.cc
index 3aa9b80..ba0f57e 100644
--- a/ui/views/test/views_test_helper_aura.cc
+++ b/ui/views/test/views_test_helper_aura.cc
@@ -76,6 +76,14 @@
 }
 
 gfx::NativeWindow ViewsTestHelperAura::GetContext() {
+  if (PlatformTestHelper::IsMus()) {
+    // GetContext() returns the root of a WindowTreeHost associated with a
+    // single display that is intended for an ash like environment. Such a
+    // configuration doesn't make sense for aura-mus-client, where it's testing
+    // DesktopNativeWidgetAura.
+    return nullptr;
+  }
+
   return aura_test_helper_->root_window();
 }
 
diff --git a/ui/views/test/widget_test.cc b/ui/views/test/widget_test.cc
index 7a2751b0..530e8d24 100644
--- a/ui/views/test/widget_test.cc
+++ b/ui/views/test/widget_test.cc
@@ -11,31 +11,38 @@
 
 namespace views {
 namespace test {
+namespace {
+
+Widget* CreateTopLevelPlatformWidgetWithStubbedCapture(
+    ViewsTestBase* test,
+    Widget::InitParams::Type type) {
+  Widget* widget = new Widget;
+  Widget::InitParams params = test->CreateParams(type);
+  params.native_widget =
+      CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr);
+  widget->Init(params);
+  return widget;
+}
+
+}  // namespace
 
 void WidgetTest::WidgetCloser::operator()(Widget* widget) const {
   widget->CloseNow();
 }
 
-WidgetTest::WidgetTest() = default;
-WidgetTest::~WidgetTest() = default;
+WidgetTest::WidgetTest(
+    std::unique_ptr<ScopedTaskEnvironment> scoped_task_environment)
+    : ViewsTestBase(std::move(scoped_task_environment)) {}
+WidgetTest::~WidgetTest() {}
 
 Widget* WidgetTest::CreateTopLevelPlatformWidget() {
-  Widget* widget = new Widget;
-  Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
-  params.native_widget =
-      CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr);
-  widget->Init(params);
-  return widget;
+  return CreateTopLevelPlatformWidgetWithStubbedCapture(
+      this, Widget::InitParams::TYPE_WINDOW);
 }
 
 Widget* WidgetTest::CreateTopLevelFramelessPlatformWidget() {
-  Widget* widget = new Widget;
-  Widget::InitParams params =
-      CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
-  params.native_widget =
-      CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr);
-  widget->Init(params);
-  return widget;
+  return CreateTopLevelPlatformWidgetWithStubbedCapture(
+      this, Widget::InitParams::TYPE_WINDOW_FRAMELESS);
 }
 
 Widget* WidgetTest::CreateChildPlatformWidget(
@@ -70,6 +77,15 @@
   return CreateChildNativeWidgetWithParent(nullptr);
 }
 
+Widget* WidgetTest::CreateNativeDesktopWidget() {
+  Widget* widget = new Widget;
+  Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr);
+  widget->Init(params);
+  return widget;
+}
+
 View* WidgetTest::GetMousePressedHandler(internal::RootView* root_view) {
   return root_view->mouse_pressed_handler_;
 }
@@ -82,16 +98,9 @@
   return root_view->gesture_handler_;
 }
 
-DesktopWidgetTest::DesktopWidgetTest() = default;
-DesktopWidgetTest::~DesktopWidgetTest() = default;
-
-void DesktopWidgetTest::SetUp() {
-  set_native_widget_type(NativeWidgetType::kDesktop);
-  WidgetTest::SetUp();
+TestDesktopWidgetDelegate::TestDesktopWidgetDelegate() : widget_(new Widget) {
 }
 
-TestDesktopWidgetDelegate::TestDesktopWidgetDelegate() : widget_(new Widget) {}
-
 TestDesktopWidgetDelegate::TestDesktopWidgetDelegate(Widget* widget)
     : widget_(widget) {}
 
@@ -103,6 +112,10 @@
 
 void TestDesktopWidgetDelegate::InitWidget(Widget::InitParams init_params) {
   init_params.delegate = this;
+#if !defined(OS_CHROMEOS)
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, widget_, nullptr);
+#endif
   init_params.bounds = initial_bounds_;
   widget_->Init(init_params);
 }
diff --git a/ui/views/test/widget_test.h b/ui/views/test/widget_test.h
index 155cef00..cd7b31e 100644
--- a/ui/views/test/widget_test.h
+++ b/ui/views/test/widget_test.h
@@ -44,7 +44,10 @@
 
   using WidgetAutoclosePtr = std::unique_ptr<Widget, WidgetCloser>;
 
-  WidgetTest();
+  explicit WidgetTest(
+      std::unique_ptr<ScopedTaskEnvironment> scoped_task_environment =
+          std::make_unique<ScopedTaskEnvironment>(
+              ScopedTaskEnvironment::MainThreadType::UI));
   ~WidgetTest() override;
 
   // Create Widgets with |native_widget| in InitParams set to an instance of
@@ -60,6 +63,11 @@
   Widget* CreateChildNativeWidgetWithParent(Widget* parent);
   Widget* CreateChildNativeWidget();
 
+  // Create a top-level Widget with |native_widget| in InitParams set to an
+  // instance of the "native desktop" type. This is a PlatformNativeWidget on
+  // ChromeOS, and a PlatformDesktopNativeWidget everywhere else.
+  Widget* CreateNativeDesktopWidget();
+
   View* GetMousePressedHandler(internal::RootView* root_view);
 
   View* GetMouseMoveHandler(internal::RootView* root_view);
@@ -107,18 +115,6 @@
   DISALLOW_COPY_AND_ASSIGN(WidgetTest);
 };
 
-class DesktopWidgetTest : public WidgetTest {
- public:
-  DesktopWidgetTest();
-  ~DesktopWidgetTest() override;
-
-  // WidgetTest:
-  void SetUp() override;
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(DesktopWidgetTest);
-};
-
 // A helper WidgetDelegate for tests that require hooks into WidgetDelegate
 // calls, and removes some of the boilerplate for initializing a Widget. Calls
 // Widget::CloseNow() when destroyed if it hasn't already been done.
diff --git a/ui/views/test/widget_test_aura.cc b/ui/views/test/widget_test_aura.cc
index b43efc2..92d65db 100644
--- a/ui/views/test/widget_test_aura.cc
+++ b/ui/views/test/widget_test_aura.cc
@@ -124,6 +124,9 @@
 }
 
 gfx::Size WidgetTest::GetNativeWidgetMinimumContentSize(Widget* widget) {
+  if (IsMus())
+    return widget->GetNativeWindow()->delegate()->GetMinimumSize();
+
   // On Windows, HWNDMessageHandler receives a WM_GETMINMAXINFO message whenever
   // the window manager is interested in knowing the size constraints. On
   // ChromeOS, it's handled internally. Elsewhere, the size constraints need to
diff --git a/ui/views/test/widget_test_unittest.cc b/ui/views/test/widget_test_unittest.cc
index f810b36..90fbde1 100644
--- a/ui/views/test/widget_test_unittest.cc
+++ b/ui/views/test/widget_test_unittest.cc
@@ -46,6 +46,11 @@
 // Ensure that Widgets with various root windows are correctly reported by
 // WidgetTest::GetAllWidgets().
 TEST_F(WidgetTestTest, GetAllWidgets) {
+  // TODO: this test transitively uses GetContext(). That should go away for
+  // aura-mus client. http://crbug.com/663781.
+  if (IsMus())
+    return;
+
   // Note Widget::Widgets is a std::set ordered by pointer value, so the order
   // that |expected| is updated below is not important.
   Widget::Widgets expected;
@@ -67,32 +72,7 @@
   Widget* native_child = CreateChildNativeWidgetWithParent(native);
   ExpectAdd(&expected, native_child, "native_child");
 
-  ExpectClose(&expected, {native, native_child}, "native");
-  ExpectClose(&expected, {platform, platform_child}, "platform");
-  ExpectClose(&expected, {frameless}, "frameless");
-}
-
-using DesktopWidgetTestTest = DesktopWidgetTest;
-
-// As above, but with desktop native widgets (i.e. DesktopNativeWidgetAura on
-// Aura).
-TEST_F(DesktopWidgetTestTest, GetAllWidgets) {
-  // Note Widget::Widgets is a std::set ordered by pointer value, so the order
-  // that |expected| is updated below is not important.
-  Widget::Widgets expected;
-
-  EXPECT_EQ(expected, GetAllWidgets());
-
-  Widget* frameless = CreateTopLevelFramelessPlatformWidget();
-  ExpectAdd(&expected, frameless, "frameless");
-
-  Widget* native = CreateTopLevelNativeWidget();
-  ExpectAdd(&expected, native, "native");
-
-  Widget* native_child = CreateChildNativeWidgetWithParent(native);
-  ExpectAdd(&expected, native_child, "native_child");
-
-  Widget* desktop = CreateTopLevelNativeWidget();
+  Widget* desktop = CreateNativeDesktopWidget();
   ExpectAdd(&expected, desktop, "desktop");
 
   Widget* desktop_child = CreateChildNativeWidgetWithParent(desktop);
@@ -110,6 +90,7 @@
 
   ExpectClose(&expected, {desktop, desktop_child}, "desktop");
   ExpectClose(&expected, {native, native_child}, "native");
+  ExpectClose(&expected, {platform, platform_child}, "platform");
   ExpectClose(&expected, {frameless}, "frameless");
 }
 
diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
index 5399b6ca..cd66a6dd 100644
--- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc
+++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
@@ -75,6 +75,10 @@
 
   void SetUp() override {
     ViewsTestBase::SetUp();
+    // TODO: test uses GetContext(), which is not applicable to aura-mus.
+    // http://crbug.com/663809.
+    if (IsMus())
+      return;
     test_cursor_client_.reset(new aura::test::TestCursorClient(GetContext()));
   }
 
@@ -317,6 +321,10 @@
 // Tests that the selection handles are placed appropriately when selection in
 // a Textfield changes.
 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   textfield_->SetText(ASCIIToUTF16("some text"));
   // Tap the textfield to invoke touch selection.
@@ -350,6 +358,10 @@
 
 // Tests that the selection handles are placed appropriately in bidi text.
 TEST_F(TouchSelectionControllerImplTest, SelectionInBidiTextfieldTest) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   textfield_->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2"));
   // Tap the textfield to invoke touch selection.
@@ -402,6 +414,10 @@
 // Tests if the SelectRect callback is called appropriately when selection
 // handles are moved.
 TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   textfield_->SetText(ASCIIToUTF16("textfield with selected text"));
   // Tap the textfield to invoke touch selection.
@@ -444,6 +460,10 @@
 }
 
 TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   textfield_->SetText(WideToUTF16(L"abc\x05e1\x05e2\x05e3" L"def"));
   // Tap the textfield to invoke touch selection.
@@ -572,6 +592,10 @@
 
 TEST_F(TouchSelectionControllerImplTest,
        HiddenSelectionHandleRetainsCursorPosition) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   static const uint32_t selection_start = 10u;
   SetupSelectionInvisibleHandle(selection_start);
   // Drag the visible handle around and make sure the selection end point of the
@@ -590,6 +614,10 @@
 // Tests that we can handle the hidden handle getting exposed as a result of a
 // drag and that it maintains the correct orientation when exposed.
 TEST_F(TouchSelectionControllerImplTest, HiddenSelectionHandleExposed) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   static const uint32_t selection_start = 0u;
   SetupSelectionInvisibleHandle(selection_start);
 
@@ -607,6 +635,10 @@
 
 TEST_F(TouchSelectionControllerImplTest,
        DoubleTapInTextfieldWithCursorHandleShouldSelectText) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   textfield_->SetText(ASCIIToUTF16("some text"));
   ui::test::EventGenerator generator(
@@ -706,6 +738,10 @@
 // the cursor position relative to the client boundaries.
 TEST_F(TouchSelectionControllerImplTest,
        VisibilityOfHandleRegardingClientBounds) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateWidget();
 
   TestTouchEditable touch_editable(widget_->GetNativeView());
@@ -753,6 +789,10 @@
 }
 
 TEST_F(TouchSelectionControllerImplTest, HandlesStackAboveParent) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   aura::Window* root = GetContext();
   ui::EventTargeter* targeter =
       root->GetHost()->dispatcher()->GetDefaultEventTargeter();
@@ -792,6 +832,10 @@
 }
 
 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   EXPECT_FALSE(GetSelectionController());
 
@@ -833,6 +877,10 @@
 }
 
 TEST_F(TouchSelectionControllerImplTest, MouseCaptureChangedEventIgnored) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   EXPECT_FALSE(GetSelectionController());
 
@@ -852,6 +900,10 @@
 }
 
 TEST_F(TouchSelectionControllerImplTest, KeyEventDeactivatesTouchSelection) {
+  // TODO: see comment in SetUp().
+  if (IsMus())
+    return;
+
   CreateTextfield();
   EXPECT_FALSE(GetSelectionController());
 
diff --git a/ui/views/touchui/touch_selection_menu_runner_views_unittest.cc b/ui/views/touchui/touch_selection_menu_runner_views_unittest.cc
index 6df1c3c..cf555e3 100644
--- a/ui/views/touchui/touch_selection_menu_runner_views_unittest.cc
+++ b/ui/views/touchui/touch_selection_menu_runner_views_unittest.cc
@@ -70,6 +70,10 @@
 // Tests that the default touch selection menu runner is installed and opening
 // and closing the menu works properly.
 TEST_F(TouchSelectionMenuRunnerViewsTest, InstalledAndWorksProperly) {
+  // See comment in SetUp().
+  if (IsMus())
+    return;
+
   gfx::Rect menu_anchor(0, 0, 10, 10);
   gfx::Size handle_size(10, 10);
 
@@ -97,6 +101,10 @@
 // Tests that anchor rect for the quick menu is adjusted correctly based on the
 // distance of handles.
 TEST_F(TouchSelectionMenuRunnerViewsTest, QuickMenuAdjustsAnchorRect) {
+  // See comment in SetUp().
+  if (IsMus())
+    return;
+
   gfx::Size handle_size(10, 10);
   TouchSelectionMenuRunnerViews::TestApi test_api(
       static_cast<TouchSelectionMenuRunnerViews*>(
@@ -129,6 +137,10 @@
 
 // Tests that running one of menu actions closes the menu properly.
 TEST_F(TouchSelectionMenuRunnerViewsTest, RunningActionClosesProperly) {
+  // See comment in SetUp().
+  if (IsMus())
+    return;
+
   gfx::Rect menu_anchor(0, 0, 10, 10);
   gfx::Size handle_size(10, 10);
   TouchSelectionMenuRunnerViews::TestApi test_api(
@@ -160,6 +172,10 @@
 
 // Tests that closing the menu widget cleans up the menu runner state properly.
 TEST_F(TouchSelectionMenuRunnerViewsTest, ClosingWidgetClosesProperly) {
+  // See comment in SetUp().
+  if (IsMus())
+    return;
+
   gfx::Rect menu_anchor(0, 0, 10, 10);
   gfx::Size handle_size(10, 10);
   TouchSelectionMenuRunnerViews::TestApi test_api(
diff --git a/ui/views/view_unittest_aura.cc b/ui/views/view_unittest_aura.cc
index edbd645..231afc3 100644
--- a/ui/views/view_unittest_aura.cc
+++ b/ui/views/view_unittest_aura.cc
@@ -72,6 +72,11 @@
 //     +-- v8
 //     +-- v9
 TEST_F(ViewAuraTest, RecreateLayersWithWindows) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   Widget* w1 = CreateControlWidget(GetContext(), gfx::Rect(0, 0, 100, 100));
   w1->GetNativeView()->layer()->set_name("w1");
 
diff --git a/ui/views/views_test_suite.cc b/ui/views/views_test_suite.cc
index d75a66d..e579a7d 100644
--- a/ui/views/views_test_suite.cc
+++ b/ui/views/views_test_suite.cc
@@ -50,20 +50,20 @@
   base::FilePath ui_test_pak_path;
   ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
   ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
-#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+#if defined(USE_AURA)
   InitializeEnv();
 #endif
 }
 
 void ViewsTestSuite::Shutdown() {
-#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+#if defined(USE_AURA)
   DestroyEnv();
 #endif
   ui::ResourceBundle::CleanupSharedInstance();
   base::TestSuite::Shutdown();
 }
 
-#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+#if defined(USE_AURA)
 void ViewsTestSuite::InitializeEnv() {
   env_ = aura::Env::CreateInstance();
 }
diff --git a/ui/views/views_test_suite.h b/ui/views/views_test_suite.h
index 73654b32..bea4d2c 100644
--- a/ui/views/views_test_suite.h
+++ b/ui/views/views_test_suite.h
@@ -30,16 +30,14 @@
   void Initialize() override;
   void Shutdown() override;
 
-#if defined(USE_AURA) && !defined(OS_CHROMEOS)
+#if defined(USE_AURA)
   // Different test suites may wish to create Env differently.
   virtual void InitializeEnv();
   virtual void DestroyEnv();
 #endif
 
  private:
-#if defined(USE_AURA) && !defined(OS_CHROMEOS)
-  // On Chrome OS, aura::Env is set up in individual test fixtures, most notably
-  // ViewsTestBase.
+#if defined(USE_AURA)
   std::unique_ptr<aura::Env> env_;
 #endif
   int argc_;
diff --git a/ui/views/widget/DEPS b/ui/views/widget/DEPS
new file mode 100644
index 0000000..a244cf72
--- /dev/null
+++ b/ui/views/widget/DEPS
@@ -0,0 +1,5 @@
+specific_include_rules = {
+  "widget_interactive_uitest\.cc": [
+    "+mojo/core/embedder",
+  ]
+}
diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc
index d0753ad..f60cc49 100644
--- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc
@@ -363,8 +363,10 @@
 
 class DesktopDragDropClientAuraX11Test : public ViewsTestBase {
  public:
-  DesktopDragDropClientAuraX11Test() = default;
-  ~DesktopDragDropClientAuraX11Test() override = default;
+  DesktopDragDropClientAuraX11Test() {
+  }
+
+  ~DesktopDragDropClientAuraX11Test() override {}
 
   int StartDragAndDrop() {
     ui::OSExchangeData data;
@@ -386,14 +388,14 @@
 
   // ViewsTestBase:
   void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-
     ViewsTestBase::SetUp();
+    test_views_delegate()->set_use_desktop_native_widgets(true);
 
     // Create widget to initiate the drags.
     widget_.reset(new Widget);
     Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
     params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+    params.native_widget = new DesktopNativeWidgetAura(widget_.get());
     params.bounds = gfx::Rect(100, 100);
     widget_->Init(params);
     widget_->Show();
diff --git a/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone_unittest.cc b/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone_unittest.cc
index 8575237..a9b8649 100644
--- a/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone_unittest.cc
@@ -26,7 +26,7 @@
 // A fake handler, which initiates dragging.
 class FakeWmDragHandler : public ui::WmDragHandler {
  public:
-  FakeWmDragHandler() = default;
+  FakeWmDragHandler() : weak_ptr_factory_(this) {}
   ~FakeWmDragHandler() override = default;
 
   // ui::WmDragHandler
@@ -45,7 +45,7 @@
 
  private:
   base::OnceCallback<void(int)> callback_;
-  base::WeakPtrFactory<FakeWmDragHandler> weak_ptr_factory_{this};
+  base::WeakPtrFactory<FakeWmDragHandler> weak_ptr_factory_;
 
   DISALLOW_COPY_AND_ASSIGN(FakeWmDragHandler);
 };
@@ -75,14 +75,14 @@
 
   // ViewsTestBase:
   void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-
     ViewsTestBase::SetUp();
+    test_views_delegate()->set_use_desktop_native_widgets(true);
 
     // Create widget to initiate the drags.
     widget_ = std::make_unique<Widget>();
     Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
     params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+    params.native_widget = new DesktopNativeWidgetAura(widget_.get());
     params.bounds = gfx::Rect(100, 100);
     widget_->Init(params);
     widget_->Show();
diff --git a/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc b/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc
index 25694f348..8b306f5 100644
--- a/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_focus_rules_unittest.cc
@@ -8,22 +8,37 @@
 #include "ui/aura/test/test_window_delegate.h"
 #include "ui/aura/window.h"
 #include "ui/aura/window_event_dispatcher.h"
-#include "ui/views/test/widget_test.h"
+#include "ui/views/test/views_test_base.h"
 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
 #include "ui/views/widget/widget.h"
 #include "ui/wm/core/window_util.h"
 
 namespace views {
 
-using DesktopFocusRulesTest = test::DesktopWidgetTest;
+namespace {
+
+std::unique_ptr<Widget> CreateDesktopWidget() {
+  std::unique_ptr<Widget> widget(new Widget);
+  Widget::InitParams params = Widget::InitParams(
+      Widget::InitParams::TYPE_WINDOW);
+  params.bounds = gfx::Rect(0, 0, 200, 200);
+  params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(widget.get());
+  widget->Init(params);
+  return widget;
+}
+
+}  // namespace
+
+typedef ViewsTestBase DesktopFocusRulesTest;
 
 // Verifies we don't attempt to activate a window in another widget.
 TEST_F(DesktopFocusRulesTest, DontFocusWindowsInOtherHierarchies) {
   // Two widgets (each with a DesktopNativeWidgetAura). |w2| has a child Window
   // |w2_child| that is not focusable. |w2_child|'s has a transient parent in
   // |w1|.
-  Widget* w1 = CreateTopLevelNativeWidget();
-  Widget* w2 = CreateTopLevelNativeWidget();
+  std::unique_ptr<views::Widget> w1(CreateDesktopWidget());
+  std::unique_ptr<views::Widget> w2(CreateDesktopWidget());
   aura::test::TestWindowDelegate w2_child_delegate;
   w2_child_delegate.set_can_focus(false);
   aura::Window* w2_child = new aura::Window(&w2_child_delegate);
@@ -35,9 +50,8 @@
       aura::client::GetFocusClient(w2->GetNativeView())->GetFocusedWindow();
   EXPECT_TRUE((focused == NULL) || w2->GetNativeView()->Contains(focused));
   wm::RemoveTransientChild(w1->GetNativeView(), w2_child);
-
-  w1->CloseNow();
-  w2->CloseNow();
+  w1.reset();
+  w2.reset();
 }
 
 }  // namespace views
diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
index ecac029..ae3193c3 100644
--- a/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
@@ -43,7 +43,7 @@
 namespace views {
 namespace test {
 
-using DesktopNativeWidgetAuraTest = DesktopWidgetTest;
+typedef ViewsTestBase DesktopNativeWidgetAuraTest;
 
 // Verifies creating a Widget with a parent that is not in a RootWindow doesn't
 // crash.
@@ -55,6 +55,7 @@
   params.bounds = gfx::Rect(0, 0, 200, 200);
   params.parent = window.get();
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(&widget);
   widget.Init(params);
 }
 
@@ -74,6 +75,7 @@
 #endif
 
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = new DesktopNativeWidgetAura(&widget);
   widget.Init(init_params);
 
   gfx::Rect bounds(0, 0, 100, 100);
@@ -102,6 +104,7 @@
   Widget::InitParams init_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = new DesktopNativeWidgetAura(&widget);
   widget.Init(init_params);
   EXPECT_FALSE(widget.GetNativeView()->IsVisible());
 }
@@ -112,10 +115,12 @@
   Widget widget;
   Widget::InitParams init_params = CreateParams(Widget::InitParams::TYPE_POPUP);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  DesktopNativeWidgetAura* widget_aura = new DesktopNativeWidgetAura(&widget);
+  init_params.native_widget = widget_aura;
   widget.Init(init_params);
 
   EXPECT_FALSE(widget.CanActivate());
-  EXPECT_EQ(nullptr, aura::client::GetFocusClient(widget.GetNativeWindow())
+  EXPECT_EQ(nullptr, aura::client::GetFocusClient(widget_aura->content_window())
                          ->GetFocusedWindow());
 }
 
@@ -127,6 +132,7 @@
   Widget::InitParams init_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = new DesktopNativeWidgetAura(&widget);
   widget.Init(init_params);
   ShowWindow(widget.GetNativeView()->GetHost()->GetAcceleratedWidget(),
              SW_SHOWNORMAL);
@@ -139,6 +145,7 @@
   Widget::InitParams init_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = new DesktopNativeWidgetAura(&widget);
   widget.Init(init_params);
 
   // Make sure that changing frame type doesn't crash when there's no non-client
@@ -158,32 +165,31 @@
 #endif  // OS_WIN
 }
 
-#if defined(OS_CHROMEOS)
-// TODO(crbug.com/916272): investigate fixing and enabling on Chrome OS.
-#define MAYBE_GlobalCursorState DISABLED_GlobalCursorState
-#else
-#define MAYBE_GlobalCursorState GlobalCursorState
-#endif
-
 // Verify that the cursor state is shared between two native widgets.
-TEST_F(DesktopNativeWidgetAuraTest, MAYBE_GlobalCursorState) {
+TEST_F(DesktopNativeWidgetAuraTest, GlobalCursorState) {
   // Create two native widgets, each owning different root windows.
   Widget widget_a;
   Widget::InitParams init_params_a =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params_a.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  DesktopNativeWidgetAura* desktop_native_widget_aura_a =
+      new DesktopNativeWidgetAura(&widget_a);
+  init_params_a.native_widget = desktop_native_widget_aura_a;
   widget_a.Init(init_params_a);
 
   Widget widget_b;
   Widget::InitParams init_params_b =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params_b.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  DesktopNativeWidgetAura* desktop_native_widget_aura_b =
+      new DesktopNativeWidgetAura(&widget_b);
+  init_params_b.native_widget = desktop_native_widget_aura_b;
   widget_b.Init(init_params_b);
 
   aura::client::CursorClient* cursor_client_a = aura::client::GetCursorClient(
-      widget_a.GetNativeView()->GetHost()->window());
+      desktop_native_widget_aura_a->host()->window());
   aura::client::CursorClient* cursor_client_b = aura::client::GetCursorClient(
-      widget_b.GetNativeView()->GetHost()->window());
+      desktop_native_widget_aura_b->host()->window());
 
   // Verify the cursor can be locked using one client and unlocked using
   // another.
@@ -264,6 +270,9 @@
     Widget::InitParams init_params =
         CreateParams(Widget::InitParams::TYPE_WINDOW);
     init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+    DesktopNativeWidgetAura* desktop_native_widget_aura =
+        new DesktopNativeWidgetAura(&widget);
+    init_params.native_widget = desktop_native_widget_aura;
     widget.Init(init_params);
 
     // Owned by |widget|.
@@ -279,12 +288,10 @@
 namespace {
 
 std::unique_ptr<Widget> CreateAndShowControlWidget(aura::Window* parent) {
-  auto widget = std::make_unique<Widget>();
   Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
   params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params.parent = parent;
-  params.native_widget = CreatePlatformNativeWidgetImpl(params, widget.get(),
-                                                        kStubCapture, nullptr);
+  auto widget = std::make_unique<Widget>();
   widget->Init(params);
   widget->Show();
   return widget;
@@ -292,20 +299,15 @@
 
 }  // namespace
 
-#if defined(OS_CHROMEOS)
-// TODO(crbug.com/916272): investigate fixing and enabling on Chrome OS.
-#define MAYBE_ReorderDoesntRecomputeOcclusion \
-  DISABLED_ReorderDoesntRecomputeOcclusion
-#else
-#define MAYBE_ReorderDoesntRecomputeOcclusion ReorderDoesntRecomputeOcclusion
-#endif
-
-TEST_F(DesktopNativeWidgetAuraTest, MAYBE_ReorderDoesntRecomputeOcclusion) {
+TEST_F(DesktopNativeWidgetAuraTest, ReorderDoesntRecomputeOcclusion) {
   // Create the parent widget.
   Widget parent;
   Widget::InitParams init_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  DesktopNativeWidgetAura* desktop_native_widget_aura =
+      new DesktopNativeWidgetAura(&parent);
+  init_params.native_widget = desktop_native_widget_aura;
   parent.Init(init_params);
   parent.Show();
 
@@ -353,6 +355,7 @@
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.bounds = gfx::Rect(0, 0, 200, 200);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(widget.get());
   widget->Init(params);
   widget->Show();
 
@@ -480,7 +483,18 @@
   DISALLOW_COPY_AND_ASSIGN(DesktopAuraTopLevelWindowTest);
 };
 
-using DesktopAuraWidgetTest = DesktopWidgetTest;
+class DesktopAuraWidgetTest : public WidgetTest {
+ public:
+  DesktopAuraWidgetTest() {}
+
+  void SetUp() override {
+    ViewsTestBase::SetUp();
+    test_views_delegate()->set_use_desktop_native_widgets(true);
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(DesktopAuraWidgetTest);
+};
 
 TEST_F(DesktopAuraWidgetTest, FullscreenWindowDestroyedBeforeOwnerTest) {
   DesktopAuraTopLevelWindowTest fullscreen_window;
@@ -601,6 +615,8 @@
   Widget* widget = new Widget;
   Widget::InitParams params =
       test->CreateParams(Widget::InitParams::TYPE_POPUP);
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr);
   params.bounds = gfx::Rect(0, 0, 50, 100);
   widget->Init(params);
   widget->SetContentsView(new CloseWidgetView(last_event_type));
@@ -635,16 +651,9 @@
 
 }  // namespace
 
-#if defined(OS_CHROMEOS)
-// TODO(crbug.com/916272): investigate fixing and enabling on Chrome OS.
-#define MAYBE_WindowMouseModalityTest DISABLED_WindowMouseModalityTest
-#else
-#define MAYBE_WindowMouseModalityTest WindowMouseModalityTest
-#endif
-
 // This test verifies that whether mouse events when a modal dialog is
 // displayed are eaten or recieved by the dialog.
-TEST_F(DesktopWidgetTest, MAYBE_WindowMouseModalityTest) {
+TEST_F(WidgetTest, WindowMouseModalityTest) {
   // Create a top level widget.
   Widget top_level_widget;
   Widget::InitParams init_params =
@@ -653,6 +662,8 @@
   gfx::Rect initial_bounds(0, 0, 500, 500);
   init_params.bounds = initial_bounds;
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+      init_params, &top_level_widget, nullptr);
   top_level_widget.Init(init_params);
   top_level_widget.Show();
   EXPECT_TRUE(top_level_widget.IsVisible());
@@ -715,7 +726,7 @@
 #if defined(OS_WIN)
 // Tests whether we can activate the top level widget when a modal dialog is
 // active.
-TEST_F(DesktopWidgetTest, WindowModalityActivationTest) {
+TEST_F(WidgetTest, WindowModalityActivationTest) {
   TestDesktopWidgetDelegate widget_delegate;
   widget_delegate.InitWidget(CreateParams(Widget::InitParams::TYPE_WINDOW));
 
@@ -753,9 +764,11 @@
 // messages via the WindowEventTarget interface implemented by the
 // HWNDMessageHandler class does not cause a crash due to an unprocessed
 // event
-TEST_F(DesktopWidgetTest, CharMessagesAsKeyboardMessagesDoesNotCrash) {
+TEST_F(WidgetTest, CharMessagesAsKeyboardMessagesDoesNotCrash) {
   Widget widget;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget.Init(params);
   widget.Show();
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 7f11f39..02e0c8d 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -9,8 +9,8 @@
 #include "base/command_line.h"
 #include "base/containers/flat_set.h"
 #include "base/location.h"
-#include "base/memory/ptr_util.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/stringprintf.h"
 #include "base/strings/utf_string_conversions.h"
@@ -1582,7 +1582,7 @@
     const unsigned char kDarkGtkThemeVariant[] = "dark";
     XChangeProperty(xdisplay_, xwindow_, gfx::GetAtom("_GTK_THEME_VARIANT"),
                     gfx::GetAtom("UTF8_STRING"), 8, PropModeReplace,
-                    kDarkGtkThemeVariant, arraysize(kDarkGtkThemeVariant) - 1);
+                    kDarkGtkThemeVariant, base::size(kDarkGtkThemeVariant) - 1);
   }
 
   // Always composite Chromium windows if a compositing WM is used.  Sometimes,
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
index 0b551f99..e25fab2 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
@@ -129,6 +129,7 @@
   params.delegate = delegate;
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params.remove_standard_frame = true;
+  params.native_widget = new DesktopNativeWidgetAura(widget.get());
   params.bounds = gfx::Rect(100, 100, 100, 100);
   widget->Init(params);
   return widget;
@@ -177,8 +178,6 @@
   ~DesktopWindowTreeHostX11Test() override {}
 
   void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-
     std::vector<int> pointer_devices;
     pointer_devices.push_back(kPointerDeviceId);
     ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(pointer_devices);
@@ -372,6 +371,7 @@
   Widget widget;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(&widget);
   widget.Init(params);
   widget.Show();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
@@ -431,6 +431,7 @@
   Widget::InitParams parent_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   parent_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  parent_params.native_widget = new DesktopNativeWidgetAura(&parent_widget);
   parent_widget.Init(parent_params);
   parent_widget.Show();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
@@ -439,6 +440,7 @@
   Widget::InitParams child_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   child_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  child_params.native_widget = new DesktopNativeWidgetAura(&child_widget);
   child_params.parent = parent_widget.GetNativeWindow();
   child_widget.Init(child_params);
   child_widget.Show();
@@ -475,6 +477,7 @@
   CustomSizeWidget widget;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(&widget);
   params.bounds = gfx::Rect(200, 100);
   widget.Init(params);
   widget.Show();
@@ -548,6 +551,7 @@
   Widget first;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(&first);
   params.bounds = gfx::Rect(0, 0, 50, 50);
   first.Init(params);
   first.Show();
@@ -555,6 +559,7 @@
   Widget second;
   params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = new DesktopNativeWidgetAura(&second);
   params.bounds = gfx::Rect(50, 50, 50, 50);
   second.Init(params);
   second.Show();
diff --git a/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc b/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc
index a688da8c..1cf88998 100644
--- a/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc
+++ b/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc
@@ -10,7 +10,6 @@
 #include <memory>
 #include <vector>
 
-#include "base/macros.h"
 #include "base/stl_util.h"
 #include "third_party/skia/include/core/SkRect.h"
 #include "ui/aura/window.h"
@@ -215,7 +214,7 @@
   XID xid3 = window3->GetHost()->GetAcceleratedWidget();
 
   XID xids[] = { xid1, xid2, xid3 };
-  StackingClientListWaiter waiter(xids, arraysize(xids));
+  StackingClientListWaiter waiter(xids, base::size(xids));
   waiter.Wait();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
 
@@ -258,7 +257,7 @@
   XID xid2 = CreateAndShowXWindow(gfx::Rect(300, 100, 100, 100));
 
   XID xids[] = { xid1, xid2 };
-  StackingClientListWaiter stack_waiter(xids, arraysize(xids));
+  StackingClientListWaiter stack_waiter(xids, base::size(xids));
   stack_waiter.Wait();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
 
@@ -307,7 +306,7 @@
   XShapeCombineRegion(xdisplay(), xid2, ShapeBounding, 0, 0, region2.get(),
                       false);
   XID xids[] = { xid1, xid2 };
-  StackingClientListWaiter stack_waiter(xids, arraysize(xids));
+  StackingClientListWaiter stack_waiter(xids, base::size(xids));
   stack_waiter.Wait();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
 
@@ -338,7 +337,7 @@
   widget1->SetShape(std::move(shape1));
 
   XID xids[] = { xid1 };
-  StackingClientListWaiter stack_waiter(xids, arraysize(xids));
+  StackingClientListWaiter stack_waiter(xids, base::size(xids));
   stack_waiter.Wait();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
 
@@ -361,7 +360,7 @@
   widget1->SetShape(nullptr);
 
   XID xids[] = { xid1 };
-  StackingClientListWaiter stack_waiter(xids, arraysize(xids));
+  StackingClientListWaiter stack_waiter(xids, base::size(xids));
   stack_waiter.Wait();
   ui::X11EventSource::GetInstance()->DispatchXEvents();
 
@@ -395,7 +394,7 @@
 
   // |menu_xid| is never added to _NET_CLIENT_LIST_STACKING.
   XID xids[] = { xid };
-  StackingClientListWaiter stack_waiter(xids, arraysize(xids));
+  StackingClientListWaiter stack_waiter(xids, base::size(xids));
   stack_waiter.Wait();
 
   EXPECT_EQ(xid, FindTopmostXWindowAt(110, 110));
diff --git a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
index e65fba7..038f3ca 100644
--- a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
+++ b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
@@ -9,10 +9,10 @@
 
 #include "base/bind.h"
 #include "base/logging.h"
-#include "base/macros.h"
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
+#include "base/stl_util.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "ui/aura/client/capture_client.h"
 #include "ui/aura/env.h"
@@ -222,7 +222,7 @@
 
   XDisplay* display = gfx::GetXDisplay();
   unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape);
-  for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
+  for (size_t i = 0; i < base::size(kModifiersMasks); ++i) {
     XUngrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_);
   }
 
@@ -254,7 +254,7 @@
 void X11WholeScreenMoveLoop::GrabEscKey() {
   XDisplay* display = gfx::GetXDisplay();
   unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape);
-  for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
+  for (size_t i = 0; i < base::size(kModifiersMasks); ++i) {
     XGrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_,
              x11::False, GrabModeAsync, GrabModeAsync);
   }
diff --git a/ui/views/widget/desktop_widget_unittest.cc b/ui/views/widget/desktop_widget_unittest.cc
index 6e17ae3..0ab25f1 100644
--- a/ui/views/widget/desktop_widget_unittest.cc
+++ b/ui/views/widget/desktop_widget_unittest.cc
@@ -5,13 +5,14 @@
 #include "ui/display/display.h"
 #include "ui/display/screen.h"
 #include "ui/views/test/native_widget_factory.h"
+#include "ui/views/test/views_test_base.h"
 #include "ui/views/test/widget_test.h"
 #include "ui/views/widget/widget.h"
 #include "ui/views/window/dialog_delegate.h"
 
 namespace views {
 
-using DesktopScreenPositionClientTest = test::DesktopWidgetTest;
+typedef ViewsTestBase DesktopScreenPositionClientTest;
 
 // Verifies setting the bounds of a dialog parented to a Widget with a
 // PlatformDesktopNativeWidget is positioned correctly.
@@ -20,6 +21,8 @@
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.bounds = gfx::Rect(10, 11, 200, 200);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget = test::CreatePlatformDesktopNativeWidgetImpl(
+      params, &parent_widget, nullptr);
   parent_widget.Init(params);
 
   // Owned by |dialog|.
@@ -57,6 +60,8 @@
       origin + work_area.OffsetFromOrigin(),
       gfx::Size(700, work_area.height() - origin.y() - work_area.y()));
   params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params1.native_widget =
+      test::CreatePlatformDesktopNativeWidgetImpl(params1, &widget1, nullptr);
   widget1.Init(params1);
 
   Widget::InitParams params2 =
@@ -65,8 +70,6 @@
   params2.parent = widget1.GetNativeView();
   params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params2.child = true;
-  params2.native_widget = test::CreatePlatformNativeWidgetImpl(
-      params2, &widget2, test::kStubCapture, nullptr);
   widget2.Init(params2);
 
   Widget::InitParams params3 =
@@ -75,8 +78,6 @@
   params3.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params3.child = true;
   params3.bounds = gfx::Rect(origin, gfx::Size(500, work_area.height() - 200));
-  params3.native_widget = test::CreatePlatformNativeWidgetImpl(
-      params3, &widget3, test::kStubCapture, nullptr);
   widget3.Init(params3);
 
   // The origin of the 3rd window should be the sum of all parent origins.
@@ -106,6 +107,8 @@
   params.bounds = gfx::Rect(
       origin, gfx::Size(work_area.width() / 2, work_area.height() / 2));
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params.native_widget =
+      test::CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr);
   widget.Init(params);
 
   // The bounds of the window should be fully on the primary display.
@@ -138,6 +141,8 @@
   params1.bounds = gfx::Rect(
       origin, gfx::Size(work_area.width() / 2, work_area.height() / 2));
   params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  params1.native_widget =
+      test::CreatePlatformDesktopNativeWidgetImpl(params1, &widget1, nullptr);
   widget1.Init(params1);
 
   gfx::Rect widget_bounds(widget1.GetWindowBoundsInScreen());
@@ -149,8 +154,6 @@
   params2.parent = widget1.GetNativeView();
   params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   params2.child = true;
-  params2.native_widget = test::CreatePlatformNativeWidgetImpl(
-      params2, &widget2, test::kStubCapture, nullptr);
   widget2.Init(params2);
 
   // The bounds of the child window should be fully in the parent.
diff --git a/ui/views/widget/native_widget_aura_interactive_uitest.cc b/ui/views/widget/native_widget_aura_interactive_uitest.cc
index ab7acdf..b4de50c 100644
--- a/ui/views/widget/native_widget_aura_interactive_uitest.cc
+++ b/ui/views/widget/native_widget_aura_interactive_uitest.cc
@@ -49,6 +49,11 @@
 // not be grabbed. And focus will be given/restored the next time the widget is
 // made active. (crbug.com/621791)
 TEST_F(NativeWidgetAuraTest, NonActiveWindowRequestImeFocus) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   TestFocusRules* test_focus_rules = new TestFocusRules;
   std::unique_ptr<wm::FocusController> focus_controller =
       std::make_unique<wm::FocusController>(test_focus_rules);
diff --git a/ui/views/widget/native_widget_mac_interactive_uitest.mm b/ui/views/widget/native_widget_mac_interactive_uitest.mm
index d7688f0..1bb90b8 100644
--- a/ui/views/widget/native_widget_mac_interactive_uitest.mm
+++ b/ui/views/widget/native_widget_mac_interactive_uitest.mm
@@ -15,6 +15,7 @@
 #include "ui/views/bubble/bubble_dialog_delegate_view.h"
 #include "ui/views/controls/textfield/textfield.h"
 #include "ui/views/test/test_widget_observer.h"
+#include "ui/views/test/views_interactive_ui_test_base.h"
 #include "ui/views/test/widget_test.h"
 
 namespace views {
@@ -32,7 +33,7 @@
 
   // WidgetTest:
   void SetUp() override {
-    SetUpForInteractiveTests();
+    ViewsInteractiveUITestBase::InteractiveSetUp();
     WidgetTest::SetUp();
   }
 
@@ -293,7 +294,7 @@
 // away from any Widget when the window is torn down. This test ensures that
 // global references AppKit may have held on to are also updated.
 TEST_F(NativeWidgetMacInteractiveUITest, GlobalNSTextInputContextUpdates) {
-  Widget* widget = CreateTopLevelNativeWidget();
+  Widget* widget = CreateNativeDesktopWidget();
   Textfield* textfield = new Textfield;
   textfield->SetBounds(0, 0, 100, 100);
   widget->GetContentsView()->AddChildView(textfield);
diff --git a/ui/views/widget/native_widget_mac_unittest.mm b/ui/views/widget/native_widget_mac_unittest.mm
index 85e6f7bd..74b583c 100644
--- a/ui/views/widget/native_widget_mac_unittest.mm
+++ b/ui/views/widget/native_widget_mac_unittest.mm
@@ -1562,7 +1562,7 @@
 
   [parent close];
 
-  Widget* parent_widget = CreateTopLevelNativeWidget();
+  Widget* parent_widget = CreateNativeDesktopWidget();
   parent = parent_widget->GetNativeWindow().GetNativeNSWindow();
   dialog = views::DialogDelegate::CreateDialogWidget(
       new DialogDelegateView, nullptr, [parent contentView]);
@@ -1680,7 +1680,7 @@
 // Tests Cocoa properties that should be given to particular widget types.
 TEST_F(NativeWidgetMacTest, NativeProperties) {
   // Create a regular widget (TYPE_WINDOW).
-  Widget* regular_widget = CreateTopLevelNativeWidget();
+  Widget* regular_widget = CreateNativeDesktopWidget();
   EXPECT_TRUE([regular_widget->GetNativeWindow().GetNativeNSWindow()
                    canBecomeKeyWindow]);
   EXPECT_TRUE([regular_widget->GetNativeWindow().GetNativeNSWindow()
diff --git a/ui/views/widget/native_widget_unittest.cc b/ui/views/widget/native_widget_unittest.cc
index d7aa5ba..661ea6a9 100644
--- a/ui/views/widget/native_widget_unittest.cc
+++ b/ui/views/widget/native_widget_unittest.cc
@@ -82,6 +82,10 @@
 
 // |toplevel_widget| has the toplevel NativeWidget.
 TEST_F(NativeWidgetTest, GetTopLevelNativeWidget2) {
+  // This test relies on GetContext(). http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   internal::NativeWidgetPrivate* child_widget = CreateNativeSubWidget();
   {
     ScopedTestWidget toplevel_widget(CreateNativeWidget());
diff --git a/ui/views/widget/root_view_unittest.cc b/ui/views/widget/root_view_unittest.cc
index fadfa68..d1bee17 100644
--- a/ui/views/widget/root_view_unittest.cc
+++ b/ui/views/widget/root_view_unittest.cc
@@ -19,7 +19,7 @@
 namespace views {
 namespace test {
 
-using RootViewTest = ViewsTestBase;
+typedef ViewsTestBase RootViewTest;
 
 class DeleteOnKeyEventView : public View {
  public:
@@ -582,15 +582,11 @@
       DialogDelegate::CreateDialogWidget(delegate, GetContext(), nullptr);
   EXPECT_EQ(1, delegate->layout_count());
   widget->CloseNow();
-}
 
-using RootViewDesktopNativeWidgetTest = ViewsTestWithDesktopNativeWidget;
-
-// Also test Aura desktop Widget codepaths.
-TEST_F(RootViewDesktopNativeWidgetTest, SingleLayoutDuringInit) {
-  RootViewTestDialogDelegate* delegate = new RootViewTestDialogDelegate();
-  Widget* widget =
-      DialogDelegate::CreateDialogWidget(delegate, GetContext(), nullptr);
+  // Also test Aura desktop Widget codepaths.
+  test_views_delegate()->set_use_desktop_native_widgets(true);
+  delegate = new RootViewTestDialogDelegate();
+  widget = DialogDelegate::CreateDialogWidget(delegate, GetContext(), nullptr);
   EXPECT_EQ(1, delegate->layout_count());
   widget->CloseNow();
 }
diff --git a/ui/views/widget/widget_interactive_uitest.cc b/ui/views/widget/widget_interactive_uitest.cc
index 7ebfb6f..3de114a 100644
--- a/ui/views/widget/widget_interactive_uitest.cc
+++ b/ui/views/widget/widget_interactive_uitest.cc
@@ -8,6 +8,7 @@
 #include "base/command_line.h"
 #include "base/location.h"
 #include "base/macros.h"
+#include "base/path_service.h"
 #include "base/run_loop.h"
 #include "base/single_thread_task_runner.h"
 #include "base/strings/stringprintf.h"
@@ -15,16 +16,18 @@
 #include "base/threading/thread_task_runner_handle.h"
 #include "base/win/windows_version.h"
 #include "build/build_config.h"
+#include "mojo/core/embedder/embedder.h"
 #include "ui/base/ime/input_method.h"
 #include "ui/base/ime/text_input_client.h"
 #include "ui/base/resource/resource_bundle.h"
 #include "ui/base/test/ui_controls.h"
+#include "ui/base/ui_base_paths.h"
 #include "ui/base/ui_base_switches.h"
-#include "ui/base/ui_features.h"
 #include "ui/events/event_processor.h"
 #include "ui/events/event_utils.h"
 #include "ui/events/test/event_generator.h"
 #include "ui/gfx/native_widget_types.h"
+#include "ui/gl/test/gl_surface_test_support.h"
 #include "ui/views/controls/textfield/textfield.h"
 #include "ui/views/controls/textfield/textfield_test_api.h"
 #include "ui/views/focus/focus_manager.h"
@@ -269,11 +272,24 @@
 
 class WidgetTestInteractive : public WidgetTest {
  public:
-  WidgetTestInteractive() = default;
-  ~WidgetTestInteractive() override = default;
+  WidgetTestInteractive() {}
+  ~WidgetTestInteractive() override {}
 
   void SetUp() override {
-    SetUpForInteractiveTests();
+    // On mus these tests run as part of views::ViewsTestSuite which already
+    // does this initialization.
+    if (!IsMus()) {
+      // Mojo is initialized here similar to how each browser test case
+      // initializes Mojo when starting. This only works because each
+      // interactive_ui_test runs in a new process.
+      mojo::core::Init();
+
+      gl::GLSurfaceTestSupport::InitializeOneOff();
+      ui::RegisterPathProvider();
+      base::FilePath ui_test_pak_path;
+      ASSERT_TRUE(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+      ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+    }
     WidgetTest::SetUp();
   }
 
@@ -288,27 +304,12 @@
     }
   }
 #endif  // defined (USE_AURA)
-};
 
-class DesktopWidgetTestInteractive : public WidgetTestInteractive {
- public:
-  DesktopWidgetTestInteractive() = default;
-  ~DesktopWidgetTestInteractive() override = default;
-
-  // WidgetTestInteractive:
-  void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-    WidgetTestInteractive::SetUp();
-  }
-
- protected:
   Widget* CreateWidget() {
-    Widget* widget = CreateTopLevelNativeWidget();
+    Widget* widget = CreateNativeDesktopWidget();
     widget->SetBounds(gfx::Rect(0, 0, 200, 200));
     return widget;
   }
-
-  DISALLOW_COPY_AND_ASSIGN(DesktopWidgetTestInteractive);
 };
 
 #if defined(OS_WIN)
@@ -321,8 +322,7 @@
 // 3. On focusing the native platform window for widget 1, the active aura
 //    window for widget 1 should be set and that for widget 2 should reset.
 // TODO(ananta): Discuss with erg on how to write this test for linux x11 aura.
-TEST_F(DesktopWidgetTestInteractive,
-       DesktopNativeWidgetAuraActivationAndFocusTest) {
+TEST_F(WidgetTestInteractive, DesktopNativeWidgetAuraActivationAndFocusTest) {
   // Create widget 1 and expect the active window to be its window.
   View* focusable_view1 = new View;
   focusable_view1->SetFocusBehavior(View::FocusBehavior::ALWAYS);
@@ -411,7 +411,7 @@
 };
 
 // TODO(dtapuska): Disabled due to it being flaky crbug.com/817531
-TEST_F(DesktopWidgetTestInteractive, DISABLED_TouchNoActivateWindow) {
+TEST_F(WidgetTestInteractive, DISABLED_TouchNoActivateWindow) {
   // ui_controls::SendTouchEvents which uses InjectTouchInput API only works
   // on Windows 8 and up.
   if (base::win::GetVersion() <= base::win::VERSION_WIN7)
@@ -622,6 +622,10 @@
 // Tests mouse move outside of the window into the "resize controller" and back
 // will still generate an OnMouseEntered and OnMouseExited event..
 TEST_F(WidgetTestInteractive, CheckResizeControllerEvents) {
+  // TODO(http://crbug.com/864787): Crashes flakily in mus with ws2.
+  if (IsMus())
+    return;
+
   Widget* toplevel = CreateTopLevelPlatformWidget();
 
   toplevel->SetBounds(gfx::Rect(0, 0, 100, 100));
@@ -738,12 +742,15 @@
 
   // NOTE: for aura-mus-client stacking of top-levels is not maintained in the
   // client, so z-order of top-levels can't be determined.
-  EXPECT_TRUE(IsWindowStackedAbove(popover.get(), child));
+  const bool check_toplevel_z_order = !IsMus();
+  if (check_toplevel_z_order)
+    EXPECT_TRUE(IsWindowStackedAbove(popover.get(), child));
   EXPECT_TRUE(IsWindowStackedAbove(child, parent.get()));
 
   // Showing the parent again should raise it and its child above the popover.
   ShowSync(parent.get());
   EXPECT_TRUE(IsWindowStackedAbove(child, parent.get()));
+  if (check_toplevel_z_order)
     EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get()));
 
   // Test grandchildren.
@@ -752,14 +759,17 @@
   grandchild->ShowInactive();
   EXPECT_TRUE(IsWindowStackedAbove(grandchild, child));
   EXPECT_TRUE(IsWindowStackedAbove(child, parent.get()));
+  if (check_toplevel_z_order)
     EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get()));
 
   ShowSync(popover.get());
+  if (check_toplevel_z_order)
     EXPECT_TRUE(IsWindowStackedAbove(popover.get(), grandchild));
   EXPECT_TRUE(IsWindowStackedAbove(grandchild, child));
 
   ShowSync(parent.get());
   EXPECT_TRUE(IsWindowStackedAbove(grandchild, child));
+  if (check_toplevel_z_order)
     EXPECT_TRUE(IsWindowStackedAbove(child, popover.get()));
 
   // Test hiding and reshowing.
@@ -769,6 +779,7 @@
 
   EXPECT_TRUE(IsWindowStackedAbove(grandchild, child));
   EXPECT_TRUE(IsWindowStackedAbove(child, parent.get()));
+  if (check_toplevel_z_order)
     EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get()));
 
   grandchild->Hide();
@@ -777,6 +788,7 @@
 
   EXPECT_TRUE(IsWindowStackedAbove(grandchild, child));
   EXPECT_TRUE(IsWindowStackedAbove(child, parent.get()));
+  if (check_toplevel_z_order)
     EXPECT_TRUE(IsWindowStackedAbove(parent.get(), popover.get()));
 }
 
@@ -1014,7 +1026,7 @@
 
 // Tests whether the focused window is set correctly when a modal window is
 // created and destroyed. When it is destroyed it should focus the owner window.
-TEST_F(DesktopWidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
+TEST_F(WidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
   TestWidgetFocusChangeListener focus_listener;
   WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
   const std::vector<gfx::NativeView>& focus_changes =
@@ -1028,6 +1040,8 @@
   gfx::Rect initial_bounds(0, 0, 500, 500);
   init_params.bounds = initial_bounds;
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+      init_params, &top_level_widget, nullptr);
   top_level_widget.Init(init_params);
   ShowSync(&top_level_widget);
 
@@ -1083,7 +1097,7 @@
 #endif
 
 // Test that when opening a system-modal window, capture is released.
-TEST_F(DesktopWidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) {
+TEST_F(WidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) {
   TestWidgetFocusChangeListener focus_listener;
   WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
 
@@ -1095,6 +1109,8 @@
   gfx::Rect initial_bounds(0, 0, 500, 500);
   init_params.bounds = initial_bounds;
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+      init_params, &top_level_widget, nullptr);
   top_level_widget.Init(init_params);
   ShowSync(&top_level_widget);
 
@@ -1124,13 +1140,15 @@
 
 #endif  // !defined(OS_CHROMEOS)
 
-TEST_F(DesktopWidgetTestInteractive, CanActivateFlagIsHonored) {
+TEST_F(WidgetTestInteractive, CanActivateFlagIsHonored) {
   Widget widget;
   Widget::InitParams init_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.bounds = gfx::Rect(0, 0, 200, 200);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   init_params.activatable = Widget::InitParams::ACTIVATABLE_NO;
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
   widget.Init(init_params);
 
   widget.Show();
@@ -1138,19 +1156,12 @@
 }
 
 #if defined(USE_AURA)
-
-#if defined(OS_CHROMEOS)
-// TODO(crbug.com/916272): investigate fixing and enabling on Chrome OS.
-#define MAYBE_TouchSelectionQuickMenuIsNotActivated \
-  DISABLED_TouchSelectionQuickMenuIsNotActivated
-#else
-#define MAYBE_TouchSelectionQuickMenuIsNotActivated \
-  TouchSelectionQuickMenuIsNotActivated
-#endif
-
 // Test that touch selection quick menu is not activated when opened.
-TEST_F(DesktopWidgetTestInteractive,
-       MAYBE_TouchSelectionQuickMenuIsNotActivated) {
+TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) {
+#if defined(OS_WIN)
+  test_views_delegate()->set_use_desktop_native_widgets(true);
+#endif  // !defined(OS_WIN)
+
   Widget* widget = CreateWidget();
 
   Textfield* textfield = new Textfield;
@@ -1178,10 +1189,9 @@
 }
 #endif  // defined(USE_AURA)
 
-#if defined(OS_WIN)
-TEST_F(DesktopWidgetTestInteractive, DisableViewDoesNotActivateWidget) {
-#else
 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) {
+#if defined(OS_WIN)
+  test_views_delegate()->set_use_desktop_native_widgets(true);
 #endif  // !defined(OS_WIN)
 
   // Create first widget and view, activate the widget, and focus the view.
@@ -1306,6 +1316,8 @@
 
   Widget widget2;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, &widget2, nullptr);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget2.Init(params);
   widget2.Show();
@@ -1367,6 +1379,11 @@
 // Testing initial focus is assigned properly for normal top-level widgets,
 // and subclasses that specify a initially focused child view.
 TEST_F(WidgetTestInteractive, InitialFocus) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   // By default, there is no initially focused view (even if there is a
   // focusable subview).
   Widget* toplevel(CreateTopLevelPlatformWidget());
@@ -1390,7 +1407,7 @@
   EXPECT_EQ(delegate.view(), widget->GetFocusManager()->GetStoredFocusView());
 }
 
-TEST_F(DesktopWidgetTestInteractive, RestoreAfterMinimize) {
+TEST_F(WidgetTestInteractive, RestoreAfterMinimize) {
   Widget* widget = CreateWidget();
   ShowSync(widget);
   ASSERT_FALSE(widget->IsMinimized());
@@ -1412,7 +1429,7 @@
 // Tests that widget visibility toggles correctly when minimized and maximized
 // on Windows. Test using both the widget API as well as native win32 functions
 // that operate directly on the underlying HWND. Behavior should be the same.
-TEST_F(DesktopWidgetTestInteractive, RestoreAndMinimizeVisibility) {
+TEST_F(WidgetTestInteractive, RestoreAndMinimizeVisibility) {
   Widget* widget = CreateWidget();
   ShowSync(widget);
   ASSERT_FALSE(widget->IsMinimized());
@@ -1449,8 +1466,7 @@
 // Tests that when a desktop native widget has modal transient child, it should
 // avoid restore focused view itself as the modal transient child window will do
 // that, thus avoids having multiple focused view visually (crbug.com/727641).
-TEST_F(DesktopWidgetTestInteractive,
-       DesktopNativeWidgetWithModalTransientChild) {
+TEST_F(WidgetTestInteractive, DesktopNativeWidgetWithModalTransientChild) {
   // Create a desktop native Widget for Widget::Deactivate().
   Widget* deactivate_widget = CreateWidget();
   ShowSync(deactivate_widget);
@@ -1542,8 +1558,19 @@
 
 class WidgetCaptureTest : public ViewsInteractiveUITestBase {
  public:
-  WidgetCaptureTest() = default;
-  ~WidgetCaptureTest() override = default;
+  WidgetCaptureTest() {
+  }
+
+  ~WidgetCaptureTest() override {}
+
+  void SetUp() override {
+    // On mus these tests run as part of views::ViewsTestSuite which already
+    // does this initialization.
+    if (!IsMus())
+      ViewsInteractiveUITestBase::SetUp();
+    else
+      ViewsTestBase::SetUp();
+  }
 
   // Verifies Widget::SetCapture() results in updating native capture along with
   // invoking the right Widget function.
@@ -1593,9 +1620,8 @@
   NativeWidget* CreateNativeWidget(const Widget::InitParams& params,
                                    bool create_desktop_native_widget,
                                    Widget* widget) {
-    // The test base class by default returns DesktopNativeWidgetAura.
     if (create_desktop_native_widget)
-      return nullptr;
+      return CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr);
     return CreatePlatformNativeWidgetImpl(params, widget, kDefault, nullptr);
   }
 
@@ -1605,16 +1631,13 @@
 
 // See description in TestCapture().
 TEST_F(WidgetCaptureTest, Capture) {
+  // TODO: capture isn't global in mus. http://crbug.com/678057.
+  if (IsMus())
+    return;
+
   TestCapture(false);
 }
 
-#if !defined(OS_CHROMEOS)
-// See description in TestCapture(). Creates DesktopNativeWidget.
-TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) {
-  TestCapture(true);
-}
-#endif
-
 // Tests to ensure capture is correctly released from a Widget with capture when
 // it is destroyed. Test for crbug.com/622201.
 TEST_F(WidgetCaptureTest, DestroyWithCapture_CloseNow) {
@@ -1622,6 +1645,7 @@
   CaptureLostTrackingWidget* widget =
       new CaptureLostTrackingWidget(&capture_state);
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget = CreateNativeWidget(params, true, widget);
   widget->Init(params);
   widget->Show();
 
@@ -1638,6 +1662,7 @@
   CaptureLostTrackingWidget* widget =
       new CaptureLostTrackingWidget(&capture_state);
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget = CreateNativeWidget(params, true, widget);
   widget->Init(params);
   widget->Show();
 
@@ -1651,6 +1676,7 @@
 TEST_F(WidgetCaptureTest, DestroyWithCapture_WidgetOwnsNativeWidget) {
   Widget widget;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget = CreateNativeWidget(params, true, &widget);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget.Init(params);
   widget.Show();
@@ -1659,8 +1685,20 @@
   EXPECT_TRUE(widget.HasCapture());
 }
 
+#if !defined(OS_CHROMEOS)
+// See description in TestCapture(). Creates DesktopNativeWidget.
+TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) {
+  TestCapture(true);
+}
+#endif
+
 // Test that no state is set if capture fails.
 TEST_F(WidgetCaptureTest, FailedCaptureRequestIsNoop) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   Widget widget;
   Widget::InitParams params =
       CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
@@ -1683,8 +1721,7 @@
   EXPECT_FALSE(widget.HasCapture());
 
   widget.Show();
-  ui::test::EventGenerator generator(GetRootWindow(&widget),
-                                     widget.GetNativeWindow());
+  ui::test::EventGenerator generator(GetContext(), widget.GetNativeWindow());
   generator.set_current_screen_location(gfx::Point(300, 10));
   generator.PressLeftButton();
 
@@ -1707,6 +1744,7 @@
   Widget widget1;
   Widget::InitParams params1 =
       CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+  params1.native_widget = CreateNativeWidget(params1, true, &widget1);
   params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget1.Init(params1);
   MouseView* mouse_view1 = new MouseView;
@@ -1717,6 +1755,7 @@
   Widget widget2;
   Widget::InitParams params2 =
       CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+  params2.native_widget = CreateNativeWidget(params2, true, &widget2);
   params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget2.Init(params2);
   widget2.Show();
@@ -1765,9 +1804,15 @@
 // Test that setting capture on widget activation of a non-toplevel widget
 // (e.g. a bubble on Linux) succeeds.
 TEST_F(WidgetCaptureTest, SetCaptureToNonToplevel) {
+  // TODO: capture isn't global in mus. http://crbug.com/678057.
+  if (IsMus())
+    return;
+
   Widget toplevel;
   Widget::InitParams toplevel_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
+  toplevel_params.native_widget = CreateNativeWidget(toplevel_params, true,
+                                                     &toplevel);
   toplevel_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   toplevel.Init(toplevel_params);
   toplevel.Show();
@@ -1867,13 +1912,13 @@
 }
 #endif  // defined(OS_WIN)
 
-class WidgetInputMethodInteractiveTest : public DesktopWidgetTestInteractive {
+class WidgetInputMethodInteractiveTest : public WidgetTestInteractive {
  public:
   WidgetInputMethodInteractiveTest() {}
 
   // testing::Test:
   void SetUp() override {
-    DesktopWidgetTestInteractive::SetUp();
+    WidgetTestInteractive::SetUp();
 #if defined(OS_WIN)
     // On Windows, Widget::Deactivate() works by activating the next topmost
     // window on the z-order stack. This only works if there is at least one
@@ -1886,7 +1931,7 @@
   void TearDown() override {
     if (deactivate_widget_)
       deactivate_widget_->CloseNow();
-    DesktopWidgetTestInteractive::TearDown();
+    WidgetTestInteractive::TearDown();
   }
 
  private:
@@ -1895,13 +1940,17 @@
   DISALLOW_COPY_AND_ASSIGN(WidgetInputMethodInteractiveTest);
 };
 
-#if defined(OS_MACOSX)
-#define MAYBE_Activation DISABLED_Activation
-#else
-#define MAYBE_Activation Activation
-#endif
 // Test input method focus changes affected by top window activaction.
-TEST_F(WidgetInputMethodInteractiveTest, MAYBE_Activation) {
+TEST_F(WidgetInputMethodInteractiveTest,
+#if defined(OS_MACOSX)
+       DISABLED_Activation
+#else
+       Activation
+#endif
+       ) {
+  if (IsMus())
+    return;
+
   Widget* widget = CreateWidget();
   Textfield* textfield = new Textfield;
   widget->GetRootView()->AddChildView(textfield);
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index bfc9a6e..642805f2 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -42,8 +42,6 @@
 #include "ui/aura/window_tree_host.h"
 #include "ui/base/view_prop.h"
 #include "ui/base/win/window_event_target.h"
-#include "ui/views/test/test_platform_native_widget.h"
-#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
 #include "ui/views/win/hwnd_util.h"
 #endif
 
@@ -556,18 +554,10 @@
 // Test to verify using various Widget methods doesn't crash when the underlying
 // NativeView is destroyed.
 //
-class WidgetWithDestroyedNativeViewTest
-    : public ViewsTestBase,
-      public testing::WithParamInterface<ViewsTestBase::NativeWidgetType> {
+class WidgetWithDestroyedNativeViewTest : public ViewsTestBase {
  public:
-  WidgetWithDestroyedNativeViewTest() = default;
-  ~WidgetWithDestroyedNativeViewTest() override = default;
-
-  // ViewsTestBase:
-  void SetUp() override {
-    set_native_widget_type(GetParam());
-    ViewsTestBase::SetUp();
-  }
+  WidgetWithDestroyedNativeViewTest() {}
+  ~WidgetWithDestroyedNativeViewTest() override {}
 
   void InvokeWidgetMethods(Widget* widget) {
     widget->GetNativeView();
@@ -619,23 +609,33 @@
   DISALLOW_COPY_AND_ASSIGN(WidgetWithDestroyedNativeViewTest);
 };
 
-TEST_P(WidgetWithDestroyedNativeViewTest, Test) {
-  Widget widget;
-  Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
-  params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
-  widget.Init(params);
-  widget.Show();
+TEST_F(WidgetWithDestroyedNativeViewTest, Test) {
+  {
+    Widget widget;
+    Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
+    params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+    widget.Init(params);
+    widget.Show();
 
-  widget.native_widget_private()->CloseNow();
-  InvokeWidgetMethods(&widget);
+    widget.native_widget_private()->CloseNow();
+    InvokeWidgetMethods(&widget);
+  }
+#if !defined(OS_CHROMEOS)
+  {
+    Widget widget;
+    Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
+    params.native_widget =
+        CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr);
+    params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+    widget.Init(params);
+    widget.Show();
+
+    widget.native_widget_private()->CloseNow();
+    InvokeWidgetMethods(&widget);
+  }
+#endif
 }
 
-INSTANTIATE_TEST_CASE_P(
-    PlatformWidgetWithDestroyedNativeViewTest,
-    WidgetWithDestroyedNativeViewTest,
-    ::testing::Values(ViewsTestBase::NativeWidgetType::kDefault,
-                      ViewsTestBase::NativeWidgetType::kDesktop));
-
 ////////////////////////////////////////////////////////////////////////////////
 // Widget observer tests.
 //
@@ -954,24 +954,9 @@
 
 }  // namespace
 
-class DesktopWidgetObserverTest : public WidgetObserverTest {
- public:
-  DesktopWidgetObserverTest() = default;
-  ~DesktopWidgetObserverTest() override = default;
-
-  // WidgetObserverTest:
-  void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-    WidgetObserverTest::SetUp();
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(DesktopWidgetObserverTest);
-};
-
 // An extension to the WidgetBoundsChangedNative test above to ensure move
 // notifications propagate to the WidgetDelegate.
-TEST_F(DesktopWidgetObserverTest, OnWidgetMovedWhenOriginChangesNative) {
+TEST_F(WidgetObserverTest, OnWidgetMovedWhenOriginChangesNative) {
   MoveTrackingTestDesktopWidgetDelegate delegate;
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   delegate.InitWidget(params);
@@ -1039,23 +1024,23 @@
 }
 
 // Test behavior of NativeWidget*::GetWindowPlacement on the native desktop.
-#if defined(USE_X11)
-  // On desktop-Linux cheat and use non-desktop widgets. On X11, minimize is
-  // asynchronous. Also (harder) showing a window doesn't activate it without
-  // user interaction (or extra steps only done for interactive ui tests).
-  // Without that, show_state remains in ui::SHOW_STATE_INACTIVE throughout.
-  // TODO(tapted): Find a nice way to run this with desktop widgets on Linux.
 TEST_F(WidgetTest, GetWindowPlacement) {
-#else
-TEST_F(DesktopWidgetTest, GetWindowPlacement) {
-#endif
 #if defined(OS_MACOSX)
   if (base::mac::IsOS10_10())
     return;  // Fails when swarmed. http://crbug.com/660582
 #endif
 
   WidgetAutoclosePtr widget;
-  widget.reset(CreateTopLevelNativeWidget());
+#if defined(USE_X11)
+  // On desktop-Linux cheat and use non-desktop widgets. On X11, minimize is
+  // asynchronous. Also (harder) showing a window doesn't activate it without
+  // user interaction (or extra steps only done for interactive ui tests).
+  // Without that, show_state remains in ui::SHOW_STATE_INACTIVE throughout.
+  // TODO(tapted): Find a nice way to run this with desktop widgets on Linux.
+  widget.reset(CreateTopLevelPlatformWidget());
+#else
+  widget.reset(CreateNativeDesktopWidget());
+#endif
 
   gfx::Rect expected_bounds(100, 110, 200, 220);
   widget->SetBounds(expected_bounds);
@@ -1115,7 +1100,7 @@
 
 // Test that widget size constraints are properly applied immediately after
 // Init(), and that SetBounds() calls are appropriately clamped.
-TEST_F(DesktopWidgetTest, MinimumSizeConstraints) {
+TEST_F(WidgetTest, MinimumSizeConstraints) {
   TestDesktopWidgetDelegate delegate;
   gfx::Size minimum_size(100, 100);
   const gfx::Size smaller_size(90, 90);
@@ -1230,8 +1215,8 @@
 #endif
 
 // Test that GetRestoredBounds() returns the original bounds of the window.
-TEST_F(DesktopWidgetTest, MAYBE_GetRestoredBounds) {
-  WidgetAutoclosePtr toplevel(CreateTopLevelNativeWidget());
+TEST_F(WidgetTest, MAYBE_GetRestoredBounds) {
+  WidgetAutoclosePtr toplevel(CreateNativeDesktopWidget());
   toplevel->Show();
   // Initial restored bounds have non-zero size.
   EXPECT_FALSE(toplevel->GetRestoredBounds().IsEmpty());
@@ -1294,7 +1279,7 @@
 // Verifies bubbles result in a focus lost when shown.
 // TODO(msw): this tests relies on focus, it needs to be in
 // interactive_ui_tests.
-TEST_F(DesktopWidgetTest, DISABLED_FocusChangesOnBubble) {
+TEST_F(WidgetTest, DISABLED_FocusChangesOnBubble) {
   // Create a widget, show and activate it and focus the contents view.
   View* contents_view = new View;
   contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
@@ -1303,6 +1288,10 @@
       CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
   init_params.bounds = gfx::Rect(0, 0, 200, 200);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+#if !defined(OS_CHROMEOS)
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
+#endif
   widget.Init(init_params);
   widget.SetContentsView(contents_view);
   widget.Show();
@@ -1347,7 +1336,7 @@
 // Test to ensure that after minimize, view width is set to zero. This is only
 // the case for desktop widgets on Windows. Other platforms retain the window
 // size while minimized.
-TEST_F(DesktopWidgetTest, TestViewWidthAfterMinimizingWidget) {
+TEST_F(WidgetTest, TestViewWidthAfterMinimizingWidget) {
   // Create a widget.
   Widget widget;
   Widget::InitParams init_params =
@@ -1356,6 +1345,8 @@
   gfx::Rect initial_bounds(0, 0, 300, 400);
   init_params.bounds = initial_bounds;
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
   widget.Init(init_params);
   NonClientView* non_client_view = widget.non_client_view();
   NonClientFrameView* frame_view = new MinimumSizeFrameView(&widget);
@@ -1435,6 +1426,8 @@
 void DesktopAuraTestValidPaintWidget::InitForTest(InitParams init_params) {
   init_params.bounds = gfx::Rect(0, 0, 200, 200);
   init_params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, this, nullptr);
   Init(init_params);
 
   View* contents_view = new View;
@@ -1445,7 +1438,7 @@
   Activate();
 }
 
-TEST_F(DesktopWidgetTest, DesktopNativeWidgetNoPaintAfterCloseTest) {
+TEST_F(WidgetTest, DesktopNativeWidgetNoPaintAfterCloseTest) {
   DesktopAuraTestValidPaintWidget widget;
   widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS));
   widget.WaitUntilPaint();
@@ -1457,7 +1450,7 @@
   EXPECT_FALSE(widget.received_paint_while_hidden());
 }
 
-TEST_F(DesktopWidgetTest, DesktopNativeWidgetNoPaintAfterHideTest) {
+TEST_F(WidgetTest, DesktopNativeWidgetNoPaintAfterHideTest) {
   DesktopAuraTestValidPaintWidget widget;
   widget.InitForTest(CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS));
   widget.WaitUntilPaint();
@@ -1472,7 +1465,7 @@
 
 // Test to ensure that the aura Window's visiblity state is set to visible if
 // the underlying widget is hidden and then shown.
-TEST_F(DesktopWidgetTest, TestWindowVisibilityAfterHide) {
+TEST_F(WidgetTest, TestWindowVisibilityAfterHide) {
   // Create a widget.
   Widget widget;
   Widget::InitParams init_params =
@@ -1481,6 +1474,8 @@
   gfx::Rect initial_bounds(0, 0, 300, 400);
   init_params.bounds = initial_bounds;
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
   widget.Init(init_params);
   NonClientView* non_client_view = widget.non_client_view();
   NonClientFrameView* frame_view = new MinimumSizeFrameView(&widget);
@@ -1724,7 +1719,9 @@
   EXPECT_EQ(0, v2->GetEventCount(ui::ET_MOUSE_MOVED));
 
   gfx::Point cursor_location(5, 5);
-  ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow());
+  ui::test::EventGenerator generator(
+      IsMus() ? GetRootWindow(widget.get()) : GetContext(),
+      widget->GetNativeWindow());
   generator.MoveMouseTo(cursor_location);
 
   EXPECT_EQ(1, v1->GetEventCount(ui::ET_MOUSE_MOVED));
@@ -1779,7 +1776,9 @@
   MousePressEventConsumer consumer;
   event_count_view->AddPostTargetHandler(&consumer);
 
-  ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow());
+  ui::test::EventGenerator generator(
+      IsMus() ? GetRootWindow(widget) : GetContext(),
+      widget->GetNativeWindow());
   generator.PressTouch();
   generator.ClickLeftButton();
 
@@ -1810,7 +1809,9 @@
 
   MousePressEventConsumer consumer;
   event_count_view->AddPostTargetHandler(&consumer);
-  ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow());
+  ui::test::EventGenerator generator(
+      IsMus() ? GetRootWindow(widget) : GetContext(),
+      widget->GetNativeWindow());
   generator.PressLeftButton();
 
   EXPECT_EQ(1, event_count_view->GetEventCount(ui::ET_MOUSE_PRESSED));
@@ -1872,8 +1873,9 @@
   // Gives explicit capture to |widget2|
   CaptureEventConsumer consumer(widget2);
   event_count_view->AddPostTargetHandler(&consumer);
-  ui::test::EventGenerator generator(GetRootWindow(widget),
-                                     widget->GetNativeWindow());
+  ui::test::EventGenerator generator(
+      IsMus() ? GetRootWindow(widget) : GetContext(),
+      widget->GetNativeWindow());
   // This event should implicitly give capture to |widget|, except that
   // |consumer| will explicitly set capture on |widget2|.
   generator.PressLeftButton();
@@ -1951,7 +1953,9 @@
       &closing_event_observer, widget->GetNativeWindow(),
       {ui::ET_MOUSE_PRESSED});
 
-  ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow());
+  ui::test::EventGenerator generator(
+      IsMus() ? GetRootWindow(widget) : GetContext(),
+      widget->GetNativeWindow());
   generator.set_target(ui::test::EventGenerator::Target::APPLICATION);
 
   EXPECT_FALSE(observer.widget_closed());
@@ -1973,7 +1977,7 @@
 
 // Verifies that widget destroyed itself in OnNativeWidgetDestroyed does not
 // crash in ASan.
-TEST_F(DesktopWidgetTest, WidgetDestroyedItselfDoesNotCrash) {
+TEST_F(WidgetTest, WidgetDestroyedItselfDoesNotCrash) {
   TestDesktopWidgetDelegate delegate(new TestNativeWidgetDestroyedWidget);
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
@@ -1984,7 +1988,7 @@
 
 // Verifies WindowClosing() is invoked correctly on the delegate when a Widget
 // is closed.
-TEST_F(DesktopWidgetTest, SingleWindowClosing) {
+TEST_F(WidgetTest, SingleWindowClosing) {
   TestDesktopWidgetDelegate delegate;
   delegate.InitWidget(CreateParams(Widget::InitParams::TYPE_WINDOW));
   EXPECT_EQ(0, delegate.window_closing_count());
@@ -1992,7 +1996,7 @@
   EXPECT_EQ(1, delegate.window_closing_count());
 }
 
-TEST_F(DesktopWidgetTest, CloseRequested_AllowsClose) {
+TEST_F(WidgetTest, CloseRequested_AllowsClose) {
   constexpr Widget::ClosedReason kReason = Widget::ClosedReason::kLostFocus;
   TestDesktopWidgetDelegate delegate;
   delegate.set_can_close(true);
@@ -2007,7 +2011,7 @@
   waiter.Wait();
 }
 
-TEST_F(DesktopWidgetTest, CloseRequested_DisallowClose) {
+TEST_F(WidgetTest, CloseRequested_DisallowClose) {
   constexpr Widget::ClosedReason kReason = Widget::ClosedReason::kLostFocus;
   TestDesktopWidgetDelegate delegate;
   delegate.set_can_close(false);
@@ -2022,7 +2026,7 @@
   delegate.GetWidget()->CloseNow();
 }
 
-TEST_F(DesktopWidgetTest, CloseRequested_SecondCloseIgnored) {
+TEST_F(WidgetTest, CloseRequested_SecondCloseIgnored) {
   constexpr Widget::ClosedReason kReason1 = Widget::ClosedReason::kLostFocus;
   constexpr Widget::ClosedReason kReason2 = Widget::ClosedReason::kUnspecified;
   TestDesktopWidgetDelegate delegate;
@@ -2043,17 +2047,21 @@
   waiter.Wait();
 }
 
-class WidgetWindowTitleTest : public DesktopWidgetTest {
+class WidgetWindowTitleTest : public WidgetTest {
  protected:
   void RunTest(bool desktop_native_widget) {
     WidgetAutoclosePtr widget(new Widget());  // Destroyed by CloseNow().
     Widget::InitParams init_params =
         CreateParams(Widget::InitParams::TYPE_WINDOW);
 
-    if (!desktop_native_widget) {
-      init_params.native_widget = CreatePlatformNativeWidgetImpl(
-          init_params, widget.get(), kStubCapture, nullptr);
-    }
+#if !defined(OS_CHROMEOS)
+    if (desktop_native_widget)
+      init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+          init_params, widget.get(), nullptr);
+#else
+    DCHECK(!desktop_native_widget)
+        << "DesktopNativeWidget does not exist on non-Aura or on ChromeOS.";
+#endif
     widget->Init(init_params);
 
     internal::NativeWidgetPrivate* native_widget =
@@ -2086,11 +2094,14 @@
   RunTest(desktop_native_widget);
 }
 
+// DesktopNativeWidget does not exist on non-Aura or on ChromeOS.
+#if !defined(OS_CHROMEOS)
 TEST_F(WidgetWindowTitleTest, SetWindowTitleChanged_DesktopNativeWidget) {
   // Override to use a DesktopNativeWidget.
   bool desktop_native_widget = true;
   RunTest(desktop_native_widget);
 }
+#endif  // !OS_CHROMEOS
 
 TEST_F(WidgetTest, WidgetDeleted_InOnMousePressed) {
   Widget* widget = new Widget;
@@ -2103,7 +2114,9 @@
   widget->SetSize(gfx::Size(100, 100));
   widget->Show();
 
-  ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow());
+  ui::test::EventGenerator generator(
+      IsMus() ? GetRootWindow(widget) : GetContext(),
+      widget->GetNativeWindow());
 
   WidgetDeletionObserver deletion_observer(widget);
   generator.PressLeftButton();
@@ -2118,6 +2131,11 @@
 #if !defined(OS_MACOSX) || defined(USE_AURA)
 
 TEST_F(WidgetTest, WidgetDeleted_InDispatchGestureEvent) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   Widget* widget = new Widget;
   Widget::InitParams params =
       CreateParams(views::Widget::InitParams::TYPE_POPUP);
@@ -2165,17 +2183,19 @@
   Widget::InitParams params(in_params);
   // Deletes itself when the Widget is destroyed.
   params.delegate = new GetNativeThemeFromDestructorView;
-  if (!is_first_run) {
-    params.native_widget = CreatePlatformNativeWidgetImpl(
-        params, widget.get(), kStubCapture, nullptr);
+#if !defined(OS_CHROMEOS)
+  if (is_first_run) {
+    params.native_widget =
+        CreatePlatformDesktopNativeWidgetImpl(params, widget.get(), nullptr);
     needs_second_run = true;
   }
+#endif
   widget->Init(params);
   return needs_second_run;
 }
 
 // See description of RunGetNativeThemeFromDestructor() for details.
-TEST_F(DesktopWidgetTest, GetNativeThemeFromDestructor) {
+TEST_F(WidgetTest, GetNativeThemeFromDestructor) {
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
   if (RunGetNativeThemeFromDestructor(params, true))
     RunGetNativeThemeFromDestructor(params, false);
@@ -2244,12 +2264,16 @@
 };
 
 // Verifies Close() results in destroying.
-TEST_F(DesktopWidgetTest, CloseDestroys) {
+TEST_F(WidgetTest, CloseDestroys) {
   bool destroyed = false;
   CloseDestroysWidget* widget = new CloseDestroysWidget(&destroyed);
   Widget::InitParams params =
       CreateParams(views::Widget::InitParams::TYPE_MENU);
   params.opacity = Widget::InitParams::OPAQUE_WINDOW;
+#if !defined(OS_CHROMEOS)
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, widget, nullptr);
+#endif
   widget->Init(params);
   widget->Show();
   widget->Hide();
@@ -2299,9 +2323,9 @@
 // ChromeOS doesn't implement or need CloseAllSecondaryWidgets() since
 // everything is under a single root window.
 #if !defined(OS_CHROMEOS)
-TEST_F(DesktopWidgetTest, CloseAllSecondaryWidgets) {
-  Widget* widget1 = CreateTopLevelNativeWidget();
-  Widget* widget2 = CreateTopLevelNativeWidget();
+TEST_F(WidgetTest, CloseAllSecondaryWidgets) {
+  Widget* widget1 = CreateNativeDesktopWidget();
+  Widget* widget2 = CreateNativeDesktopWidget();
   TestWidgetObserver observer1(widget1);
   TestWidgetObserver observer2(widget2);
   widget1->Show();  // Just show the first one.
@@ -2313,8 +2337,8 @@
 
 // Test that the NativeWidget is still valid during OnNativeWidgetDestroying(),
 // and properties that depend on it are valid, when closed via CloseNow().
-TEST_F(DesktopWidgetTest, ValidDuringOnNativeWidgetDestroyingFromCloseNow) {
-  Widget* widget = CreateTopLevelNativeWidget();
+TEST_F(WidgetTest, ValidDuringOnNativeWidgetDestroyingFromCloseNow) {
+  Widget* widget = CreateNativeDesktopWidget();
   widget->Show();
   gfx::Rect screen_rect(50, 50, 100, 100);
   widget->SetBounds(screen_rect);
@@ -2326,8 +2350,8 @@
 
 // Test that the NativeWidget is still valid during OnNativeWidgetDestroying(),
 // and properties that depend on it are valid, when closed via Close().
-TEST_F(DesktopWidgetTest, ValidDuringOnNativeWidgetDestroyingFromClose) {
-  Widget* widget = CreateTopLevelNativeWidget();
+TEST_F(WidgetTest, ValidDuringOnNativeWidgetDestroyingFromClose) {
+  Widget* widget = CreateNativeDesktopWidget();
   widget->Show();
   gfx::Rect screen_rect(50, 50, 100, 100);
   widget->SetBounds(screen_rect);
@@ -2362,6 +2386,11 @@
 // Tests that we do not crash when a Widget is destroyed before it finishes
 // processing of pending input events in the message loop.
 TEST_F(WidgetTest, NoCrashOnWidgetDeleteWithPendingEvents) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   std::unique_ptr<Widget> widget(new Widget);
   Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   params.bounds = gfx::Rect(0, 0, 200, 200);
@@ -3194,9 +3223,9 @@
   DISALLOW_COPY_AND_ASSIGN(DestroyedTrackingView);
 };
 
-class WidgetChildDestructionTest : public DesktopWidgetTest {
+class WidgetChildDestructionTest : public WidgetTest {
  public:
-  WidgetChildDestructionTest() = default;
+  WidgetChildDestructionTest() {}
 
   // Creates a top level and a child, destroys the child and verifies the views
   // of the child are destroyed before the views of the parent.
@@ -3208,10 +3237,12 @@
     Widget* top_level = new Widget;
     Widget::InitParams params =
         CreateParams(views::Widget::InitParams::TYPE_WINDOW);
-    if (!top_level_has_desktop_native_widget_aura) {
-      params.native_widget = CreatePlatformNativeWidgetImpl(
-          params, top_level, kStubCapture, nullptr);
+#if !defined(OS_CHROMEOS)
+    if (top_level_has_desktop_native_widget_aura) {
+      params.native_widget =
+          CreatePlatformDesktopNativeWidgetImpl(params, top_level, nullptr);
     }
+#endif
     top_level->Init(params);
     top_level->GetRootView()->AddChildView(
         new DestroyedTrackingView("parent", &destroyed));
@@ -3221,10 +3252,12 @@
     Widget::InitParams child_params =
         CreateParams(views::Widget::InitParams::TYPE_POPUP);
     child_params.parent = top_level->GetNativeView();
-    if (!child_has_desktop_native_widget_aura) {
-      child_params.native_widget = CreatePlatformNativeWidgetImpl(
-          child_params, child, kStubCapture, nullptr);
+#if !defined(OS_CHROMEOS)
+    if (child_has_desktop_native_widget_aura) {
+      child_params.native_widget =
+          CreatePlatformDesktopNativeWidgetImpl(child_params, child, nullptr);
     }
+#endif
     child->Init(child_params);
     child->GetRootView()->AddChildView(
         new DestroyedTrackingView("child", &destroyed));
@@ -3284,13 +3317,15 @@
 // Verifies nativeview visbility matches that of Widget visibility when
 // SetFullscreen is invoked, for a widget provided with a desktop widget.
 #if !defined(OS_CHROMEOS)
-TEST_F(DesktopWidgetTest, FullscreenStatePropagated_DesktopWidget) {
+TEST_F(WidgetTest, FullscreenStatePropagated_DesktopWidget) {
   Widget::InitParams init_params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.show_state = ui::SHOW_STATE_NORMAL;
   init_params.bounds = gfx::Rect(0, 0, 500, 500);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   Widget top_level_widget;
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+      init_params, &top_level_widget, nullptr);
 
   top_level_widget.Init(init_params);
   top_level_widget.SetFullscreen(true);
@@ -3375,12 +3410,14 @@
 
 // Verifies Widget::IsActive() invoked from
 // WidgetObserver::OnWidgetDestroying() in a child widget doesn't crash.
-TEST_F(DesktopWidgetTest, IsActiveFromDestroy) {
+TEST_F(WidgetTest, IsActiveFromDestroy) {
   // Create two widgets, one a child of the other.
   IsActiveFromDestroyObserver observer;
   Widget parent_widget;
   Widget::InitParams parent_params =
       CreateParams(Widget::InitParams::TYPE_POPUP);
+  parent_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+      parent_params, &parent_widget, nullptr);
   parent_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   parent_widget.Init(parent_params);
   parent_widget.Show();
@@ -3401,6 +3438,11 @@
 // Tests that events propagate through from the dispatcher with the correct
 // event type, and that the different platforms behave the same.
 TEST_F(WidgetTest, MouseEventTypesViaGenerator) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   EventCountView* view = new EventCountView;
   view->set_handle_mode(EventCountView::CONSUME_EVENTS);
   view->SetBounds(10, 10, 50, 40);
@@ -3567,10 +3609,12 @@
 // 2. Posting a WM_NCMOUSEMOVE message with a different hittest code.
 // 3. Posting a WM_MOUSEMOVE message.
 // Disabled because of flaky timeouts: http://crbug.com/592742
-TEST_F(DesktopWidgetTest,
-       DISABLED_SysCommandMoveOnNCLButtonDownOnCaptionAndMoveTest) {
+TEST_F(WidgetTest, DISABLED_SysCommandMoveOnNCLButtonDownOnCaptionAndMoveTest) {
   Widget widget;
-  Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+  Widget::InitParams params =
+      CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget.Init(params);
   widget.SetBounds(gfx::Rect(0, 0, 200, 200));
@@ -3600,7 +3644,7 @@
   EXPECT_FALSE(subclass_helper.received_message(WM_SYSCOMMAND));
 
   subclass_helper.Clear();
-  // Posting a WM_NCLBUTTONDOWN message followed by a WM_NCMOUSEMOVE at a
+ // Posting a WM_NCLBUTTONDOWN message followed by a WM_NCMOUSEMOVE at a
   // different location should result in a WM_SYSCOMMAND message.
   ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
   ::PostMessage(window, WM_NCMOUSEMOVE, HTCAPTION, MAKELPARAM(110, 110));
@@ -3611,7 +3655,7 @@
   EXPECT_TRUE(subclass_helper.received_message(WM_SYSCOMMAND));
 
   subclass_helper.Clear();
-  // Posting a WM_NCLBUTTONDOWN message followed by a WM_NCMOUSEMOVE at a
+ // Posting a WM_NCLBUTTONDOWN message followed by a WM_NCMOUSEMOVE at a
   // different location with a different hittest code should result in a
   // WM_SYSCOMMAND message.
   ::PostMessage(window, WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(100, 100));
@@ -3639,10 +3683,12 @@
 // This test validates that destroying the window in the context of the
 // WM_SYSCOMMAND message with SC_MOVE does not crash.
 // Disabled because of flaky timeouts: http://crbug.com/592742
-TEST_F(DesktopWidgetTest, DISABLED_DestroyInSysCommandNCLButtonDownOnCaption) {
+TEST_F(WidgetTest, DISABLED_DestroyInSysCommandNCLButtonDownOnCaption) {
   Widget widget;
   Widget::InitParams params =
       CreateParams(Widget::InitParams::TYPE_WINDOW);
+  params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(params, &widget, nullptr);
   params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   widget.Init(params);
   widget.SetBounds(gfx::Rect(0, 0, 200, 200));
@@ -3705,6 +3751,11 @@
 
 // Ensure scale factor changes are propagated from the native Widget.
 TEST_F(WidgetTest, OnDeviceScaleFactorChanged) {
+  // This relies on the NativeWidget being the WindowDelegate, which is not the
+  // case for aura-mus-client.
+  if (IsMus())
+    return;
+
   // Automatically close the widget, but not delete it.
   WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
   ScaleFactorView* view = new ScaleFactorView;
@@ -3810,6 +3861,11 @@
 
 // Test dispatch of ui::ET_MOUSEWHEEL.
 TEST_F(WidgetTest, MouseWheelEvent) {
+  // TODO: test uses GetContext(), which is not applicable to aura-mus.
+  // http://crbug.com/663809.
+  if (IsMus())
+    return;
+
   WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
   widget->SetBounds(gfx::Rect(0, 0, 600, 600));
   EventCountView* event_count_view = new EventCountView();
@@ -3826,24 +3882,9 @@
 
 class WidgetShadowTest : public WidgetTest {
  public:
-  WidgetShadowTest() = default;
-  ~WidgetShadowTest() override = default;
+  WidgetShadowTest() { InitControllers(); }
 
   // WidgetTest:
-  void SetUp() override {
-    set_native_widget_type(NativeWidgetType::kDesktop);
-    WidgetTest::SetUp();
-    InitControllers();
-  }
-
-  void TearDown() override {
-#if defined(OS_CHROMEOS)
-    shadow_controller_.reset();
-    focus_controller_.reset();
-#endif
-    WidgetTest::TearDown();
-  }
-
   Widget::InitParams CreateParams(Widget::InitParams::Type type) override {
     Widget::InitParams params =
         WidgetTest::CreateParams(override_type_.value_or(type));
@@ -3876,6 +3917,11 @@
   };
 
   void InitControllers() {
+    // Add bits usually managed by the ash::Shell. Under Mus,
+    // DesktopNativeWidgetAura provides these in-process instead.
+    if (IsMus())
+      return;
+
     focus_controller_ =
         std::make_unique<wm::FocusController>(new TestFocusRules);
     shadow_controller_ = std::make_unique<wm::ShadowController>(
@@ -3903,16 +3949,23 @@
   // A desktop window clips to its bounds, so it shouldn't have a shadow.
   bool top_level_window_should_have_shadow = false;
 
+#if defined(OS_CHROMEOS)
+  // In Mus, the shadow should be in the WindowServer process only. In non-mus
+  // CreateNativeDesktopWidget() creates a non-root window, so it should have
+  // a shadow.
+  top_level_window_should_have_shadow = !IsMus();
+#endif
+
   // To start, just create a Widget. This constructs the first ShadowController
   // which will start observing the environment for additional aura::Window
   // initialization. The very first ShadowController in DesktopNativeWidgetAura
   // is created after the call to aura::Window::Init(), so the ShadowController
   // Impl class won't ever see this first Window being initialized.
   name_ = "other_top_level";
-  Widget* other_top_level = CreateTopLevelNativeWidget();
+  Widget* other_top_level = CreateNativeDesktopWidget();
 
   name_ = "top_level";
-  Widget* top_level = CreateTopLevelNativeWidget();
+  Widget* top_level = CreateNativeDesktopWidget();
   top_level->SetBounds(gfx::Rect(100, 100, 320, 200));
 
   EXPECT_FALSE(WidgetHasInProcessShadow(top_level));
@@ -3987,18 +4040,20 @@
 // Tests the case where an intervening owner popup window is destroyed out from
 // under the currently active modal top-level window. In this instance, the
 // remaining top-level windows should be re-enabled.
-TEST_F(DesktopWidgetTest, WindowModalOwnerDestroyedEnabledTest) {
+TEST_F(WidgetTest, WindowModalOwnerDestroyedEnabledTest) {
   // top_level_widget owns owner_dialog_widget which owns owned_dialog_widget.
   Widget top_level_widget;
   Widget owner_dialog_widget;
   Widget owned_dialog_widget;
   // Create the top level widget.
   Widget::InitParams init_params =
-      CreateParams(Widget::InitParams::TYPE_WINDOW);
+    CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.show_state = ui::SHOW_STATE_NORMAL;
   gfx::Rect initial_bounds(0, 0, 500, 500);
   init_params.bounds = initial_bounds;
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+    init_params, &top_level_widget, nullptr);
   top_level_widget.Init(init_params);
   top_level_widget.Show();
 
@@ -4006,7 +4061,7 @@
   // owner_dialog_delegate instance will be destroyed when the dialog
   // is destroyed.
   ModalDialogDelegate* owner_dialog_delegate =
-      new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
+    new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
 
   init_params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.show_state = ui::SHOW_STATE_NORMAL;
@@ -4014,9 +4069,8 @@
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   init_params.delegate = owner_dialog_delegate;
   init_params.parent = top_level_widget.GetNativeView();
-  init_params.native_widget =
-      new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
-          &owner_dialog_widget, false, nullptr);
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+    init_params, &owner_dialog_widget, nullptr);
   owner_dialog_widget.Init(init_params);
 
   HWND owner_hwnd = HWNDForWidget(&owner_dialog_widget);
@@ -4027,7 +4081,7 @@
   // As above, the owned_dialog_instance instance will be destroyed
   // when the dialog is destroyed.
   ModalDialogDelegate* owned_dialog_delegate =
-      new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
+    new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
 
   init_params = CreateParams(Widget::InitParams::TYPE_WINDOW);
   init_params.show_state = ui::SHOW_STATE_NORMAL;
@@ -4035,15 +4089,13 @@
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
   init_params.delegate = owned_dialog_delegate;
   init_params.parent = owner_dialog_widget.GetNativeView();
-  init_params.native_widget =
-      new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
-          &owned_dialog_widget, false, nullptr);
+  init_params.native_widget = CreatePlatformDesktopNativeWidgetImpl(
+    init_params, &owned_dialog_widget, nullptr);
   owned_dialog_widget.Init(init_params);
 
   HWND owned_hwnd = HWNDForWidget(&owned_dialog_widget);
 
   owned_dialog_widget.Show();
-  RunPendingMessages();
 
   HWND top_hwnd = HWNDForWidget(&top_level_widget);
 
@@ -4052,7 +4104,6 @@
   EXPECT_TRUE(!!IsWindowEnabled(owned_hwnd));
 
   owner_dialog_widget.CloseNow();
-  RunPendingMessages();
 
   EXPECT_FALSE(!!IsWindow(owner_hwnd));
   EXPECT_FALSE(!!IsWindow(owned_hwnd));
@@ -4075,10 +4126,12 @@
   init_params.show_state = ui::SHOW_STATE_NORMAL;
   init_params.bounds = gfx::Rect(0, 0, 500, 500);
   init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+  init_params.native_widget =
+      CreatePlatformDesktopNativeWidgetImpl(init_params, &widget, nullptr);
   widget.Init(init_params);
 }
 
-class CompositingWidgetTest : public DesktopWidgetTest {
+class CompositingWidgetTest : public views::test::WidgetTest {
  public:
   CompositingWidgetTest()
       : widget_types_{Widget::InitParams::TYPE_WINDOW,
diff --git a/ui/views/window/dialog_delegate_unittest.cc b/ui/views/window/dialog_delegate_unittest.cc
index 5fd4c862..a439800 100644
--- a/ui/views/window/dialog_delegate_unittest.cc
+++ b/ui/views/window/dialog_delegate_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "ui/base/hit_test.h"
 #include "ui/events/event_processor.h"
@@ -227,7 +227,7 @@
       {1000, HTNOWHERE},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     gfx::Point point(cases[i].point, cases[i].point);
     EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point))
         << " case " << i << " at point " << cases[i].point;
@@ -250,7 +250,7 @@
       {50, HTCLIENT}, {60, HTCLIENT},  {1000, HTNOWHERE},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     gfx::Point point(cases[i].point, cases[i].point);
     EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point))
         << " case " << i << " at point " << cases[i].point;
@@ -272,7 +272,7 @@
       {50, HTCLIENT}, {60, HTCLIENT},  {1000, HTNOWHERE},
   };
 
-  for (size_t i = 0; i < arraysize(cases); ++i) {
+  for (size_t i = 0; i < base::size(cases); ++i) {
     gfx::Point point(cases[i].point, cases[i].point);
     EXPECT_EQ(cases[i].hit, frame->NonClientHitTest(point))
         << " at point " << cases[i].point;
diff --git a/url/gurl_unittest.cc b/url/gurl_unittest.cc
index 6f876aee..caf5dd4 100644
--- a/url/gurl_unittest.cc
+++ b/url/gurl_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
@@ -234,7 +234,7 @@
     "http:/path",
     "http:path",
   };
-  for (size_t i = 0; i < arraysize(valid_cases); i++) {
+  for (size_t i = 0; i < base::size(valid_cases); i++) {
     EXPECT_TRUE(GURL(valid_cases[i]).is_valid())
         << "Case: " << valid_cases[i];
   }
@@ -247,7 +247,7 @@
     "://google.com",
     "path",
   };
-  for (size_t i = 0; i < arraysize(invalid_cases); i++) {
+  for (size_t i = 0; i < base::size(invalid_cases); i++) {
     EXPECT_FALSE(GURL(invalid_cases[i]).is_valid())
         << "Case: " << invalid_cases[i];
   }
@@ -306,7 +306,7 @@
     {"filesystem:http://www.google.com/type/", "../foo.html", true, "filesystem:http://www.google.com/type/foo.html"},
   };
 
-  for (size_t i = 0; i < arraysize(resolve_cases); i++) {
+  for (size_t i = 0; i < base::size(resolve_cases); i++) {
     // 8-bit code path.
     GURL input(resolve_cases[i].base);
     GURL output = input.Resolve(resolve_cases[i].relative);
@@ -343,7 +343,7 @@
       {"blob:null/guid-goes-here", ""},
       {"blob:http://origin/guid-goes-here", "" /* should be http://origin/ */},
   };
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     GURL url(cases[i].input);
     GURL origin = url.GetOrigin();
     EXPECT_EQ(cases[i].expected, origin.spec());
@@ -366,7 +366,7 @@
     {"file:///tmp/test.html", ""},
     {"https://www.google.com", "https://www.google.com/"},
   };
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     GURL url(cases[i].input);
     GURL origin = url.GetAsReferrer();
     EXPECT_EQ(cases[i].expected, origin.spec());
@@ -385,7 +385,7 @@
     {"filesystem:file:///temporary/bar.html?baz=22", "filesystem:file:///temporary/"},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     GURL url(cases[i].input);
     GURL empty_path = url.GetWithEmptyPath();
     EXPECT_EQ(cases[i].expected, empty_path.spec());
@@ -431,7 +431,7 @@
     {"foobar", ""},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     GURL url(cases[i].input);
     GURL without_filename = url.GetWithoutFilename();
     EXPECT_EQ(cases[i].expected, without_filename.spec()) << i;
@@ -473,7 +473,7 @@
        "filesystem:http://www.google.com/foo/bar.html?foo#bar"},
   };
 
-  for (size_t i = 0; i < arraysize(replace_cases); i++) {
+  for (size_t i = 0; i < base::size(replace_cases); i++) {
     const ReplaceCase& cur = replace_cases[i];
     GURL url(cur.base);
     GURL::Replacements repl;
@@ -537,7 +537,7 @@
     {"filesystem:http://www.google.com/temporary/foo/bar.html?query", "/foo/bar.html?query", "/temporary"},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     GURL url(cases[i].input);
     std::string path_request = url.PathForRequest();
     EXPECT_EQ(cases[i].expected, path_request);
@@ -585,7 +585,7 @@
     {"filesystem:file:///t/foo", PORT_UNSPECIFIED},
   };
 
-  for (size_t i = 0; i < arraysize(port_tests); i++) {
+  for (size_t i = 0; i < base::size(port_tests); i++) {
     GURL url(port_tests[i].spec);
     EXPECT_EQ(port_tests[i].expected_int_port, url.EffectiveIntPort());
   }
@@ -606,7 +606,7 @@
     {"some random input!", false},
   };
 
-  for (size_t i = 0; i < arraysize(ip_tests); i++) {
+  for (size_t i = 0; i < base::size(ip_tests); i++) {
     GURL url(ip_tests[i].spec);
     EXPECT_EQ(ip_tests[i].expected_ip, url.HostIsIPAddress());
   }
@@ -631,7 +631,7 @@
     {"http://]/", "]", "]"},
     {"", "", ""},
   };
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     GURL url(cases[i].input);
     EXPECT_EQ(cases[i].expected_host, url.host());
     EXPECT_EQ(cases[i].expected_plainhost, url.HostNoBrackets());
diff --git a/url/scheme_host_port_unittest.cc b/url/scheme_host_port_unittest.cc
index 7b00f4f..ed1aaec 100644
--- a/url/scheme_host_port_unittest.cc
+++ b/url/scheme_host_port_unittest.cc
@@ -5,7 +5,7 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/gurl.h"
 #include "url/scheme_host_port.h"
@@ -253,10 +253,10 @@
       {"https", "b", 81},
   };
 
-  for (size_t i = 0; i < arraysize(tuples); i++) {
+  for (size_t i = 0; i < base::size(tuples); i++) {
     url::SchemeHostPort current(tuples[i].scheme, tuples[i].host,
                                 tuples[i].port);
-    for (size_t j = i; j < arraysize(tuples); j++) {
+    for (size_t j = i; j < base::size(tuples); j++) {
       url::SchemeHostPort to_compare(tuples[j].scheme, tuples[j].host,
                                      tuples[j].port);
       EXPECT_EQ(i < j, current < to_compare) << i << " < " << j;
diff --git a/url/url_canon_icu_unittest.cc b/url/url_canon_icu_unittest.cc
index af320f9..62ec1a9 100644
--- a/url/url_canon_icu_unittest.cc
+++ b/url/url_canon_icu_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/icu/source/common/unicode/ucnv.h"
 #include "url/url_canon.h"
@@ -54,7 +54,7 @@
       "hello\xa7\x41%26%231758%3B\xa6\x6eworld"},
   };
 
-  for (size_t i = 0; i < arraysize(icu_cases); i++) {
+  for (size_t i = 0; i < base::size(icu_cases); i++) {
     UConvScoper conv(icu_cases[i].encoding);
     ASSERT_TRUE(conv.converter() != NULL);
     ICUCharsetConverter converter(conv.converter());
@@ -112,7 +112,7 @@
       "?q=Chinese%26%2365319%3B"},
   };
 
-  for (size_t i = 0; i < arraysize(query_cases); i++) {
+  for (size_t i = 0; i < base::size(query_cases); i++) {
     Component out_comp;
 
     UConvScoper conv(query_cases[i].encoding);
diff --git a/url/url_canon_unittest.cc b/url/url_canon_unittest.cc
index a29db7f9..3f80036 100644
--- a/url/url_canon_unittest.cc
+++ b/url/url_canon_unittest.cc
@@ -5,7 +5,7 @@
 #include <errno.h>
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "base/strings/utf_string_conversions.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/third_party/mozilla/url_parse.h"
@@ -114,7 +114,7 @@
     {0x10FFFF, "\xF4\x8F\xBF\xBF"},
   };
   std::string out_str;
-  for (size_t i = 0; i < arraysize(utf_cases); i++) {
+  for (size_t i = 0; i < base::size(utf_cases); i++) {
     out_str.clear();
     StdStringCanonOutput output(&out_str);
     AppendUTF8Value(utf_cases[i].input, &output);
@@ -177,7 +177,7 @@
   };
 
   std::string out_str;
-  for (size_t i = 0; i < arraysize(utf_cases); i++) {
+  for (size_t i = 0; i < base::size(utf_cases); i++) {
     if (utf_cases[i].input8) {
       out_str.clear();
       StdStringCanonOutput output(&out_str);
@@ -248,7 +248,7 @@
 
   std::string out_str;
 
-  for (size_t i = 0; i < arraysize(scheme_cases); i++) {
+  for (size_t i = 0; i < base::size(scheme_cases); i++) {
     int url_len = static_cast<int>(strlen(scheme_cases[i].input));
     Component in_comp(0, url_len);
     Component out_comp;
@@ -513,7 +513,7 @@
 
   // CanonicalizeHost() non-verbose.
   std::string out_str;
-  for (size_t i = 0; i < arraysize(host_cases); i++) {
+  for (size_t i = 0; i < base::size(host_cases); i++) {
     // Narrow version.
     if (host_cases[i].input8) {
       int host_len = static_cast<int>(strlen(host_cases[i].input8));
@@ -561,7 +561,7 @@
   }
 
   // CanonicalizeHostVerbose()
-  for (size_t i = 0; i < arraysize(host_cases); i++) {
+  for (size_t i = 0; i < base::size(host_cases); i++) {
     // Narrow version.
     if (host_cases[i].input8) {
       int host_len = static_cast<int>(strlen(host_cases[i].input8));
@@ -691,7 +691,7 @@
     {"0.00.0x.0x0", L"0.00.0x.0x0", "0.0.0.0", Component(0, 7), CanonHostInfo::IPV4, 4, "00000000"},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     // 8-bit version.
     Component component(0, static_cast<int>(strlen(cases[i].input8)));
 
@@ -845,7 +845,7 @@
     {"[::1 hello]", L"[::1 hello]", "", Component(), CanonHostInfo::BROKEN, -1, ""},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     // 8-bit version.
     Component component(0, static_cast<int>(strlen(cases[i].input8)));
 
@@ -971,7 +971,7 @@
     {"ftp://me\\mydomain:pass@foo.com/", "", Component(0, -1), Component(0, -1), true},
   };
 
-  for (size_t i = 0; i < arraysize(user_info_cases); i++) {
+  for (size_t i = 0; i < base::size(user_info_cases); i++) {
     int url_len = static_cast<int>(strlen(user_info_cases[i].input));
     Parsed parsed;
     ParseStandardURL(user_info_cases[i].input, url_len, &parsed);
@@ -1040,7 +1040,7 @@
     {"80", PORT_UNSPECIFIED, ":80", Component(1, 2), true},
   };
 
-  for (size_t i = 0; i < arraysize(port_cases); i++) {
+  for (size_t i = 0; i < base::size(port_cases); i++) {
     int url_len = static_cast<int>(strlen(port_cases[i].input));
     Component in_comp(0, url_len);
     Component out_comp;
@@ -1163,7 +1163,7 @@
     {NULL, L"/\xfdd0zyx", "/%EF%BF%BDzyx", Component(0, 13), false},
   };
 
-  for (size_t i = 0; i < arraysize(path_cases); i++) {
+  for (size_t i = 0; i < base::size(path_cases); i++) {
     if (path_cases[i].input8) {
       int len = static_cast<int>(strlen(path_cases[i].input8));
       Component in_comp(0, len);
@@ -1240,7 +1240,7 @@
     {"q=\"asdf\"", L"q=\"asdf\"", "?q=%22asdf%22"},
   };
 
-  for (size_t i = 0; i < arraysize(query_cases); i++) {
+  for (size_t i = 0; i < base::size(query_cases); i++) {
     Component out_comp;
 
     if (query_cases[i].input8) {
@@ -1312,7 +1312,7 @@
       {"#asdf", L"#asdf", "##asdf", Component(1, 5), true},
   };
 
-  for (size_t i = 0; i < arraysize(ref_cases); i++) {
+  for (size_t i = 0; i < base::size(ref_cases); i++) {
     // 8-bit input
     if (ref_cases[i].input8) {
       int len = static_cast<int>(strlen(ref_cases[i].input8));
@@ -1424,7 +1424,7 @@
        "ws://%29w%1ew%81/", false},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     int url_len = static_cast<int>(strlen(cases[i].input));
     Parsed parsed;
     ParseStandardURL(cases[i].input, url_len, &parsed);
@@ -1457,7 +1457,7 @@
     {"http://a:b@google.com:22/foo?baz@cat", "filesystem", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "filesystem://a:b@google.com:22/foo?baz@cat"},
   };
 
-  for (size_t i = 0; i < arraysize(replace_cases); i++) {
+  for (size_t i = 0; i < base::size(replace_cases); i++) {
     const ReplaceCase& cur = replace_cases[i];
     int base_len = static_cast<int>(strlen(cur.base));
     Parsed parsed;
@@ -1540,7 +1540,7 @@
     {"file:///C:/gaba?query#ref", "http", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "file:///C:/gaba?query#ref"},
   };
 
-  for (size_t i = 0; i < arraysize(replace_cases); i++) {
+  for (size_t i = 0; i < base::size(replace_cases); i++) {
     const ReplaceCase& cur = replace_cases[i];
     int base_len = static_cast<int>(strlen(cur.base));
     Parsed parsed;
@@ -1605,7 +1605,7 @@
        "filesystem:http://bar.com:40/t/gaba?query#ref"},
   };
 
-  for (size_t i = 0; i < arraysize(replace_cases); i++) {
+  for (size_t i = 0; i < base::size(replace_cases); i++) {
     const ReplaceCase& cur = replace_cases[i];
     int base_len = static_cast<int>(strlen(cur.base));
     Parsed parsed;
@@ -1644,7 +1644,7 @@
     {"data:foo", NULL, NULL, NULL, NULL, NULL, kDeleteComp, NULL, NULL, "data:"},
   };
 
-  for (size_t i = 0; i < arraysize(replace_cases); i++) {
+  for (size_t i = 0; i < base::size(replace_cases); i++) {
     const ReplaceCase& cur = replace_cases[i];
     int base_len = static_cast<int>(strlen(cur.base));
     Parsed parsed;
@@ -1695,7 +1695,7 @@
     {"mailto:addr1", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "BLAH", "mailto:addr1"},
   };
 
-  for (size_t i = 0; i < arraysize(replace_cases); i++) {
+  for (size_t i = 0; i < base::size(replace_cases); i++) {
     const ReplaceCase& cur = replace_cases[i];
     int base_len = static_cast<int>(strlen(cur.base));
     Parsed parsed;
@@ -1800,7 +1800,7 @@
 #endif  // _WIN32
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     int url_len = static_cast<int>(strlen(cases[i].input));
     Parsed parsed;
     ParseFileURL(cases[i].input, url_len, &parsed);
@@ -1843,7 +1843,7 @@
     {"filesystem:File:///temporary/Bob?qUery#reF", "filesystem:file:///temporary/Bob?qUery#reF", true},
   };
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     int url_len = static_cast<int>(strlen(cases[i].input));
     Parsed parsed;
     ParseFileSystemURL(cases[i].input, url_len, &parsed);
@@ -1878,7 +1878,7 @@
     {"Foo:\":This /is interesting;?#", "foo:\":This /is interesting;?#"},
   };
 
-  for (size_t i = 0; i < arraysize(path_cases); i++) {
+  for (size_t i = 0; i < base::size(path_cases); i++) {
     int url_len = static_cast<int>(strlen(path_cases[i].input));
     Parsed parsed;
     ParsePathURL(path_cases[i].input, url_len, true, &parsed);
@@ -1963,7 +1963,7 @@
   Parsed parsed;
   Parsed out_parsed;
 
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     int url_len = static_cast<int>(strlen(cases[i].input));
     if (i == 0) {
       // The first test case purposely has a '\0' in it -- don't count it
@@ -2229,7 +2229,7 @@
     {"about:blank", false, false, "content://content.Provider/", true, false, true, ""},
   };
 
-  for (size_t i = 0; i < arraysize(rel_cases); i++) {
+  for (size_t i = 0; i < base::size(rel_cases); i++) {
     const RelativeCase& cur_case = rel_cases[i];
 
     Parsed parsed;
diff --git a/url/url_parse_unittest.cc b/url/url_parse_unittest.cc
index b80e865..4160e49 100644
--- a/url/url_parse_unittest.cc
+++ b/url/url_parse_unittest.cc
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/third_party/mozilla/url_parse.h"
 
@@ -137,7 +137,7 @@
     "http://user@",
     "http:",
   };
-  for (size_t i = 0; i < arraysize(length_cases); i++) {
+  for (size_t i = 0; i < base::size(length_cases); i++) {
     int true_length = static_cast<int>(strlen(length_cases[i]));
 
     Parsed parsed;
@@ -196,7 +196,7 @@
     {"file:///c:/foo", Parsed::HOST, true, 7},
     {"file:///c:/foo", Parsed::PATH, true, 7},
   };
-  for (size_t i = 0; i < arraysize(count_cases); i++) {
+  for (size_t i = 0; i < base::size(count_cases); i++) {
     int length = static_cast<int>(strlen(count_cases[i].url));
 
     // Simple test to distinguish file and standard URLs.
@@ -314,7 +314,7 @@
   // Declared outside for loop to try to catch cases in init() where we forget
   // to reset something that is reset by the constructor.
   Parsed parsed;
-  for (size_t i = 0; i < arraysize(cases); i++) {
+  for (size_t i = 0; i < base::size(cases); i++) {
     const char* url = cases[i].input;
     ParseStandardURL(url, static_cast<int>(strlen(url)), &parsed);
     int port = ParsePort(url, parsed.port);
@@ -349,7 +349,7 @@
   // Declared outside for loop to try to catch cases in init() where we forget
   // to reset something that is reset by the constructor.
   Parsed parsed;
-  for (size_t i = 0; i < arraysize(path_cases); i++) {
+  for (size_t i = 0; i < base::size(path_cases); i++) {
     const char* url = path_cases[i].input;
     ParsePathURL(url, static_cast<int>(strlen(url)), false, &parsed);
 
@@ -448,7 +448,7 @@
   // Declared outside for loop to try to catch cases in init() where we forget
   // to reset something that is reset by the construtor.
   Parsed parsed;
-  for (size_t i = 0; i < arraysize(file_cases); i++) {
+  for (size_t i = 0; i < base::size(file_cases); i++) {
     const char* url = file_cases[i].input;
     ParseFileURL(url, static_cast<int>(strlen(url)), &parsed);
     int port = ParsePort(url, parsed.port);
@@ -509,7 +509,7 @@
     {"http://www.google.com/foo;bar;html", "foo"},
   };
 
-  for (size_t i = 0; i < arraysize(file_cases); i++) {
+  for (size_t i = 0; i < base::size(file_cases); i++) {
     const char* url = file_cases[i].input;
     int len = static_cast<int>(strlen(url));
 
@@ -617,7 +617,7 @@
   // Declared outside for loop to try to catch cases in init() where we forget
   // to reset something that is reset by the constructor.
   Parsed parsed;
-  for (size_t i = 0; i < arraysize(mailto_cases); ++i) {
+  for (size_t i = 0; i < base::size(mailto_cases); ++i) {
     const char* url = mailto_cases[i].input;
     ParseMailtoURL(url, static_cast<int>(strlen(url)), &parsed);
     int port = ParsePort(url, parsed.port);
@@ -649,7 +649,7 @@
   // Declared outside for loop to try to catch cases in init() where we forget
   // to reset something that is reset by the constructor.
   Parsed parsed;
-  for (size_t i = 0; i < arraysize(filesystem_cases); i++) {
+  for (size_t i = 0; i < base::size(filesystem_cases); i++) {
     const FileSystemURLParseCase* parsecase = &filesystem_cases[i];
     const char* url = parsecase->input;
     ParseFileSystemURL(url, static_cast<int>(strlen(url)), &parsed);
diff --git a/url/url_util_unittest.cc b/url/url_util_unittest.cc
index 437530a..13036af8 100644
--- a/url/url_util_unittest.cc
+++ b/url/url_util_unittest.cc
@@ -4,7 +4,7 @@
 
 #include <stddef.h>
 
-#include "base/macros.h"
+#include "base/stl_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "url/third_party/mozilla/url_parse.h"
 #include "url/url_canon.h"
@@ -220,7 +220,7 @@
       {"%e4%bd%a0%e5%a5%bd", "\xe4\xbd\xa0\xe5\xa5\xbd"},
   };
 
-  for (size_t i = 0; i < arraysize(decode_cases); i++) {
+  for (size_t i = 0; i < base::size(decode_cases); i++) {
     const char* input = decode_cases[i].input;
     RawCanonOutputT<base::char16> output;
     DecodeURLEscapeSequences(input, strlen(input),
@@ -303,7 +303,7 @@
      "pqrstuvwxyz%7B%7C%7D~%7F"},
   };
 
-  for (size_t i = 0; i < arraysize(encode_cases); i++) {
+  for (size_t i = 0; i < base::size(encode_cases); i++) {
     const char* input = encode_cases[i].input;
     RawCanonOutputT<char> buffer;
     EncodeURIComponent(input, strlen(input), &buffer);
@@ -380,7 +380,7 @@
       // adding the requested dot doesn't seem wrong either.
       {"aaa://a\\", "aaa:.", true, "aaa://a\\."}};
 
-  for (size_t i = 0; i < arraysize(resolve_non_standard_cases); i++) {
+  for (size_t i = 0; i < base::size(resolve_non_standard_cases); i++) {
     const ResolveRelativeCase& test_data = resolve_non_standard_cases[i];
     Parsed base_parsed;
     ParsePathURL(test_data.base, strlen(test_data.base), false, &base_parsed);