diff --git a/components/gcm_driver/crypto/encryption_header_parsers.cc b/components/gcm_driver/crypto/encryption_header_parsers.cc
index ed07f698cb5c2..f56c1b758b767 100644
--- a/components/gcm_driver/crypto/encryption_header_parsers.cc
+++ b/components/gcm_driver/crypto/encryption_header_parsers.cc
@@ -55,10 +55,8 @@ bool RecordSizeToInt(std::string_view value, uint64_t* rs) {
 
 }  // namespace
 
-EncryptionHeaderIterator::EncryptionHeaderIterator(
-    std::string::const_iterator header_begin,
-    std::string::const_iterator header_end)
-    : iterator_(std::string_view(header_begin, header_end), /*delimiter=*/','),
+EncryptionHeaderIterator::EncryptionHeaderIterator(std::string_view header)
+    : iterator_(header, ','),
       rs_(kDefaultRecordSizeBytes) {}
 
 EncryptionHeaderIterator::~EncryptionHeaderIterator() = default;
@@ -105,10 +103,8 @@ bool EncryptionHeaderIterator::GetNext() {
   return name_value_pairs.valid();
 }
 
-CryptoKeyHeaderIterator::CryptoKeyHeaderIterator(
-    std::string::const_iterator header_begin,
-    std::string::const_iterator header_end)
-    : iterator_(std::string_view(header_begin, header_end), /*delimiter=*/',') {
+CryptoKeyHeaderIterator::CryptoKeyHeaderIterator(std::string_view header)
+    : iterator_(header, ',') {
 }
 
 CryptoKeyHeaderIterator::~CryptoKeyHeaderIterator() = default;
diff --git a/components/gcm_driver/crypto/encryption_header_parsers.h b/components/gcm_driver/crypto/encryption_header_parsers.h
index bd38ce18907c1..7ddabc91ac7a8 100644
--- a/components/gcm_driver/crypto/encryption_header_parsers.h
+++ b/components/gcm_driver/crypto/encryption_header_parsers.h
@@ -8,6 +8,8 @@
 #include <stdint.h>
 #include <string>
 
+#include <string_view>
+
 #include "net/http/http_util.h"
 
 namespace gcm {
@@ -20,8 +22,7 @@ namespace gcm {
 // https://tools.ietf.org/html/rfc7230#section-1.2
 class EncryptionHeaderIterator {
  public:
-  EncryptionHeaderIterator(std::string::const_iterator header_begin,
-                           std::string::const_iterator header_end);
+  explicit EncryptionHeaderIterator(std::string_view header);
   ~EncryptionHeaderIterator();
 
   // Advances the iterator to the next header value, if any. Returns true if
@@ -57,8 +58,7 @@ class EncryptionHeaderIterator {
 // https://tools.ietf.org/html/rfc7230#section-1.2
 class CryptoKeyHeaderIterator {
  public:
-  CryptoKeyHeaderIterator(std::string::const_iterator header_begin,
-                          std::string::const_iterator header_end);
+  explicit CryptoKeyHeaderIterator(std::string_view header);
   ~CryptoKeyHeaderIterator();
 
   // Advances the iterator to the next header value, if any. Returns true if
diff --git a/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc b/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc
index 00b3fa6c7e84c..f9e04f353b13e 100644
--- a/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc
+++ b/components/gcm_driver/crypto/encryption_header_parsers_unittest.cc
@@ -44,17 +44,17 @@ TEST(EncryptionHeaderParsersTest, ParseValidEncryptionHeaders) {
       {"keyid=foo;someothervalue=1;rs=42", "foo", "", 42},
   });
 
-  for (size_t i = 0; i < std::size(expected_results); i++) {
-    SCOPED_TRACE(i);
+  for (const auto& expected : expected_results) {
+    SCOPED_TRACE(expected.header);
 
-    std::string header(expected_results[i].header);
+    std::string header(expected.header);
 
-    EncryptionHeaderIterator iterator(header.begin(), header.end());
+    EncryptionHeaderIterator iterator(header);
     ASSERT_TRUE(iterator.GetNext());
 
-    EXPECT_EQ(expected_results[i].parsed_keyid, iterator.keyid());
-    EXPECT_EQ(expected_results[i].parsed_salt, iterator.salt());
-    EXPECT_EQ(expected_results[i].parsed_rs, iterator.rs());
+    EXPECT_EQ(expected.parsed_keyid, iterator.keyid());
+    EXPECT_EQ(expected.parsed_salt, iterator.salt());
+    EXPECT_EQ(expected.parsed_rs, iterator.rs());
 
     EXPECT_FALSE(iterator.GetNext());
   }
@@ -63,42 +63,43 @@ TEST(EncryptionHeaderParsersTest, ParseValidEncryptionHeaders) {
 TEST(EncryptionHeaderParsersTest, ParseValidMultiValueEncryptionHeaders) {
   const size_t kNumberOfValues = 2u;
 
+  struct ParsedValues {
+    const char* const keyid;
+    const char* const salt;
+    uint64_t rs;
+  };
+
   struct ExpectedResults {
     const char* const header;
-    struct {
-      const char* const keyid;
-      const char* const salt;
-      uint64_t rs;
-    } parsed_values[kNumberOfValues];
+    std::array<ParsedValues, kNumberOfValues> parsed_values;
   };
-  auto expected_results = std::to_array<ExpectedResults>({
-      {"keyid=foo;salt=c2l4dGVlbmNvb2xieXRlcw;rs=1024,keyid=foo;salt=c2l4dGVlbm"
-       "Nvb2xieXRlcw;rs=1024",
-       {{"foo", "sixteencoolbytes", 1024}, {"foo", "sixteencoolbytes", 1024}}},
+  auto expected_results = std::to_array<ExpectedResults>({{"keyid=foo;salt=c2l4dGVlbmNvb2xieXRlcw;rs=1024,keyid=foo;salt="
+"c2l4dGVlbm5jb29ieXRlcw;rs=1024",
+       {{{"foo", "sixteencoolbytes", 1024},
+         {"foo", "sixteencoolbytes", 1024}}}},
       {"keyid=foo,salt=c2l4dGVlbmNvb2xieXRlcw;rs=1024",
-       {{"foo", "", kDefaultRecordSize}, {"", "sixteencoolbytes", 1024}}},
+       {{{"foo", "", kDefaultRecordSize},
+         {"", "sixteencoolbytes", 1024}}}},
       {"keyid=foo,keyid=bar;salt=c2l4dGVlbmNvb2xieXRlcw;rs=1024",
-       {{"foo", "", kDefaultRecordSize}, {"bar", "sixteencoolbytes", 1024}}},
+       {{{"foo", "", kDefaultRecordSize},
+         {"bar", "sixteencoolbytes", 1024}}}},
       {"keyid=\"foo,keyid=bar\",salt=c2l4dGVlbmNvb2xieXRlcw",
-       {{"foo,keyid=bar", "", kDefaultRecordSize},
-        {"", "sixteencoolbytes", kDefaultRecordSize}}},
+       {{{"foo,keyid=bar", "", kDefaultRecordSize},
+         {"", "sixteencoolbytes", kDefaultRecordSize}}}},
   });
 
-  for (size_t i = 0; i < std::size(expected_results); i++) {
-    SCOPED_TRACE(i);
+  for (const auto& expected : expected_results) {
+    SCOPED_TRACE(expected.header);
 
-    std::string header(expected_results[i].header);
+    std::string header(expected.header);
 
-    EncryptionHeaderIterator iterator(header.begin(), header.end());
-    for (size_t j = 0; j < kNumberOfValues; ++j) {
+    EncryptionHeaderIterator iterator(header);
+    for (const auto& parsed_value : expected.parsed_values) {
       ASSERT_TRUE(iterator.GetNext());
 
-      UNSAFE_TODO(EXPECT_EQ(expected_results[i].parsed_values[j].keyid,
-                            iterator.keyid()));
-      UNSAFE_TODO(EXPECT_EQ(expected_results[i].parsed_values[j].salt,
-                            iterator.salt()));
-      UNSAFE_TODO(
-          EXPECT_EQ(expected_results[i].parsed_values[j].rs, iterator.rs()));
+      EXPECT_EQ(parsed_value.keyid, iterator.keyid());
+      EXPECT_EQ(parsed_value.salt, iterator.salt());
+      EXPECT_EQ(parsed_value.rs, iterator.rs());
     }
 
     EXPECT_FALSE(iterator.GetNext());
@@ -106,7 +107,7 @@ TEST(EncryptionHeaderParsersTest, ParseValidMultiValueEncryptionHeaders) {
 }
 
 TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionHeaders) {
-  const auto expected_failures = std::to_array<const char*>({
+  const auto expected_failures = std::to_array<const char*>({ 
       // Values in the name-value pairs are not optional.
       "keyid",
       "keyid=",
@@ -137,7 +138,7 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionHeaders) {
       "rs=foobar",
   });
 
-  const auto expected_failures_second_iter = std::to_array<const char*>({
+  const auto expected_failures_second_iter = std::to_array<const char*>({ 
       // Valid first field, missing value in the second field.
       "keyid=foo,novaluekey",
 
@@ -148,21 +149,21 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidEncryptionHeaders) {
       "rs=2,rs=0",
   });
 
-  for (size_t i = 0; i < std::size(expected_failures); i++) {
-    SCOPED_TRACE(i);
+  for (const char* header_str : expected_failures) {
+    SCOPED_TRACE(header_str);
 
-    std::string header(expected_failures[i]);
+    std::string header(header_str);
 
-    EncryptionHeaderIterator iterator(header.begin(), header.end());
+    EncryptionHeaderIterator iterator(header);
     EXPECT_FALSE(iterator.GetNext());
   }
 
-  for (size_t i = 0; i < std::size(expected_failures_second_iter); i++) {
-    SCOPED_TRACE(i);
+  for (const char* header_str : expected_failures_second_iter) {
+    SCOPED_TRACE(header_str);
 
-    std::string header(expected_failures_second_iter[i]);
+    std::string header(header_str);
 
-    EncryptionHeaderIterator iterator(header.begin(), header.end());
+    EncryptionHeaderIterator iterator(header);
     EXPECT_TRUE(iterator.GetNext());
     EXPECT_FALSE(iterator.GetNext());
   }
@@ -175,14 +176,13 @@ TEST(EncryptionHeaderParsersTest, ParseValidCryptoKeyHeaders) {
     const char* const parsed_aesgcm128;
     const char* const parsed_dh;
   };
-  auto expected_results = std::to_array<ExpectedResults>({
-      {"keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz",
+  auto expected_results = std::to_array<ExpectedResults>({{"keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz",
        "foo", "sixteencoolbytes", "twelvecoolbytes"},
       {"keyid=foo; aesgcm128=c2l4dGVlbmNvb2xieXRlcw; dh=dHdlbHZlY29vbGJ5dGVz",
        "foo", "sixteencoolbytes", "twelvecoolbytes"},
       {"keyid = foo ; aesgcm128 = c2l4dGVlbmNvb2xieXRlcw ; dh = "
-       "dHdlbHZlY29vbGJ5"
-       "dGVz ",
+"dHdlbHZlY29vbGJ5" 
+"dGVz "
        "foo", "sixteencoolbytes", "twelvecoolbytes"},
       {"KEYID=foo;AESGCM128=c2l4dGVlbmNvb2xieXRlcw;DH=dHdlbHZlY29vbGJ5dGVz",
        "foo", "sixteencoolbytes", "twelvecoolbytes"},
@@ -194,17 +194,17 @@ TEST(EncryptionHeaderParsersTest, ParseValidCryptoKeyHeaders) {
        "twelvecoolbytes", ""},
   });
 
-  for (size_t i = 0; i < std::size(expected_results); i++) {
-    SCOPED_TRACE(i);
+  for (const auto& expected : expected_results) {
+    SCOPED_TRACE(expected.header);
 
-    std::string header(expected_results[i].header);
+    std::string header(expected.header);
 
-    CryptoKeyHeaderIterator iterator(header.begin(), header.end());
+    CryptoKeyHeaderIterator iterator(header);
     ASSERT_TRUE(iterator.GetNext());
 
-    EXPECT_EQ(expected_results[i].parsed_keyid, iterator.keyid());
-    EXPECT_EQ(expected_results[i].parsed_aesgcm128, iterator.aesgcm128());
-    EXPECT_EQ(expected_results[i].parsed_dh, iterator.dh());
+    EXPECT_EQ(expected.parsed_keyid, iterator.keyid());
+    EXPECT_EQ(expected.parsed_aesgcm128, iterator.aesgcm128());
+    EXPECT_EQ(expected.parsed_dh, iterator.dh());
 
     EXPECT_FALSE(iterator.GetNext());
   }
@@ -213,42 +213,39 @@ TEST(EncryptionHeaderParsersTest, ParseValidCryptoKeyHeaders) {
 TEST(EncryptionHeaderParsersTest, ParseValidMultiValueCryptoKeyHeaders) {
   const size_t kNumberOfValues = 2u;
 
+  struct ParsedValues {
+    const char* const keyid;
+    const char* const aesgcm128;
+    const char* const dh;
+  };
+
   struct ExpectedResults {
     const char* const header;
-    struct {
-      const char* const keyid;
-      const char* const aesgcm128;
-      const char* const dh;
-    } parsed_values[kNumberOfValues];
+    std::array<ParsedValues, kNumberOfValues> parsed_values;
   };
-  auto expected_results = std::to_array<ExpectedResults>({
-      {"keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz,"
-       "keyid=bar;aesgcm128=dHdlbHZlY29vbGJ5dGVz;dh=c2l4dGVlbmNvb2xieXRlcw",
-       {{"foo", "sixteencoolbytes", "twelvecoolbytes"},
-        {"bar", "twelvecoolbytes", "sixteencoolbytes"}}},
+  auto expected_results = std::to_array<ExpectedResults>({{"keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz,keyid=bar;aesgcm128=dHdlbHZlY29vbGJ5dGVz;dh=c2l4dGVlbmNvb2xieXRlcw",
+       {{{"foo", "sixteencoolbytes", "twelvecoolbytes"},
+         {"bar", "twelvecoolbytes", "sixteencoolbytes"}}}},
       {"keyid=foo,aesgcm128=c2l4dGVlbmNvb2xieXRlcw",
-       {{"foo", "", ""}, {"", "sixteencoolbytes", ""}}},
+       {{{"foo", "", ""}, {"", "sixteencoolbytes", ""}}}},
       {"keyid=foo,keyid=bar;dh=dHdlbHZlY29vbGJ5dGVz",
-       {{"foo", "", ""}, {"bar", "", "twelvecoolbytes"}}},
+       {{{"foo", "", ""}, {"bar", "", "twelvecoolbytes"}}}},
       {"keyid=\"foo,keyid=bar\",aesgcm128=c2l4dGVlbmNvb2xieXRlcw",
-       {{"foo,keyid=bar", "", ""}, {"", "sixteencoolbytes", ""}}},
+       {{{"foo,keyid=bar", "", ""}, {"", "sixteencoolbytes", ""}}}},
   });
 
-  for (size_t i = 0; i < std::size(expected_results); i++) {
-    SCOPED_TRACE(i);
+  for (const auto& expected : expected_results) {
+    SCOPED_TRACE(expected.header);
 
-    std::string header(expected_results[i].header);
+    std::string header(expected.header);
 
-    CryptoKeyHeaderIterator iterator(header.begin(), header.end());
-    for (size_t j = 0; j < kNumberOfValues; ++j) {
+    CryptoKeyHeaderIterator iterator(header);
+    for (const auto& parsed_value : expected.parsed_values) {
       ASSERT_TRUE(iterator.GetNext());
 
-      UNSAFE_TODO(EXPECT_EQ(expected_results[i].parsed_values[j].keyid,
-                            iterator.keyid()));
-      UNSAFE_TODO(EXPECT_EQ(expected_results[i].parsed_values[j].aesgcm128,
-                            iterator.aesgcm128()));
-      UNSAFE_TODO(
-          EXPECT_EQ(expected_results[i].parsed_values[j].dh, iterator.dh()));
+      EXPECT_EQ(parsed_value.keyid, iterator.keyid());
+      EXPECT_EQ(parsed_value.aesgcm128, iterator.aesgcm128());
+      EXPECT_EQ(parsed_value.dh, iterator.dh());
     }
 
     EXPECT_FALSE(iterator.GetNext());
@@ -256,7 +253,7 @@ TEST(EncryptionHeaderParsersTest, ParseValidMultiValueCryptoKeyHeaders) {
 }
 
 TEST(EncryptionHeaderParsersTest, ParseInvalidCryptoKeyHeaders) {
-  const auto expected_failures = std::to_array<const char*>({
+  const auto expected_failures = std::to_array<const char*>({ 
       // Values in the name-value pairs are not optional.
       "keyid",
       "keyid=",
@@ -280,7 +277,7 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidCryptoKeyHeaders) {
       "dh=123$xyz",
   });
 
-  const auto expected_failures_second_iter = std::to_array<const char*>({
+  const auto expected_failures_second_iter = std::to_array<const char*>({ 
       // Valid first field, missing value in the second field.
       "keyid=foo,novaluekey",
 
@@ -288,21 +285,21 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidCryptoKeyHeaders) {
       "dh=dHdlbHZlY29vbGJ5dGVz,aesgcm128=123$xyz",
   });
 
-  for (size_t i = 0; i < std::size(expected_failures); i++) {
-    SCOPED_TRACE(i);
+  for (const char* header_str : expected_failures) {
+    SCOPED_TRACE(header_str);
 
-    std::string header(expected_failures[i]);
+    std::string header(header_str);
 
-    CryptoKeyHeaderIterator iterator(header.begin(), header.end());
+    CryptoKeyHeaderIterator iterator(header);
     EXPECT_FALSE(iterator.GetNext());
   }
 
-  for (size_t i = 0; i < std::size(expected_failures_second_iter); i++) {
-    SCOPED_TRACE(i);
+  for (const char* header_str : expected_failures_second_iter) {
+    SCOPED_TRACE(header_str);
 
-    std::string header(expected_failures_second_iter[i]);
+    std::string header(header_str);
 
-    CryptoKeyHeaderIterator iterator(header.begin(), header.end());
+    CryptoKeyHeaderIterator iterator(header);
     EXPECT_TRUE(iterator.GetNext());
     EXPECT_FALSE(iterator.GetNext());
   }
@@ -311,8 +308,8 @@ TEST(EncryptionHeaderParsersTest, ParseInvalidCryptoKeyHeaders) {
 TEST(EncryptionHeaderParsersTest, SixValueHeader) {
   const std::string header("keyid=0,keyid=1,keyid=2,keyid=3,keyid=4,keyid=5");
 
-  EncryptionHeaderIterator encryption_iterator(header.begin(), header.end());
-  CryptoKeyHeaderIterator crypto_key_iterator(header.begin(), header.end());
+  EncryptionHeaderIterator encryption_iterator(header);
+  CryptoKeyHeaderIterator crypto_key_iterator(header);
 
   for (size_t i = 0; i < 6; ++i) {
     SCOPED_TRACE(i);
@@ -332,11 +329,9 @@ TEST(EncryptionHeaderParsersTest, InvalidHeadersResetOutput) {
 
   // Valid first field, undecodable aesgcm128 parameter in the second field.
   const std::string crypto_key_header(
-      "keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz,"
-      "aesgcm128=$$$");
+      "keyid=foo;aesgcm128=c2l4dGVlbmNvb2xieXRlcw;dh=dHdlbHZlY29vbGJ5dGVz,aesgcm128=$$$");
 
-  EncryptionHeaderIterator encryption_iterator(
-      encryption_header.begin(), encryption_header.end());
+  EncryptionHeaderIterator encryption_iterator(encryption_header);
 
   ASSERT_EQ(0u, encryption_iterator.keyid().size());
   ASSERT_EQ(0u, encryption_iterator.salt().size());
@@ -354,8 +349,7 @@ TEST(EncryptionHeaderParsersTest, InvalidHeadersResetOutput) {
   EXPECT_EQ(0u, encryption_iterator.salt().size());
   EXPECT_EQ(4096u, encryption_iterator.rs());
 
-  CryptoKeyHeaderIterator crypto_key_iterator(
-      crypto_key_header.begin(), crypto_key_header.end());
+  CryptoKeyHeaderIterator crypto_key_iterator(crypto_key_header);
 
   ASSERT_EQ(0u, crypto_key_iterator.keyid().size());
   ASSERT_EQ(0u, crypto_key_iterator.aesgcm128().size());
diff --git a/components/gcm_driver/crypto/gcm_encryption_provider.cc b/components/gcm_driver/crypto/gcm_encryption_provider.cc
index ee42ce4db898d..023339762a661 100644
--- a/components/gcm_driver/crypto/gcm_encryption_provider.cc
+++ b/components/gcm_driver/crypto/gcm_encryption_provider.cc
@@ -182,7 +182,7 @@ void GCMEncryptionProvider::DecryptMessage(const std::string& app_id,
     CHECK(crypto_key_header != message.data.end());
 
     EncryptionHeaderIterator encryption_header_iterator(
-        encryption_header->second.begin(), encryption_header->second.end());
+        encryption_header->second);
     if (!encryption_header_iterator.GetNext()) {
       DLOG(ERROR) << "Unable to parse the value of the Encryption header";
       std::move(callback).Run(GCMDecryptionResult::INVALID_ENCRYPTION_HEADER,
@@ -202,7 +202,7 @@ void GCMEncryptionProvider::DecryptMessage(const std::string& app_id,
     record_size = encryption_header_iterator.rs();
 
     CryptoKeyHeaderIterator crypto_key_header_iterator(
-        crypto_key_header->second.begin(), crypto_key_header->second.end());
+        crypto_key_header->second);
     if (!crypto_key_header_iterator.GetNext()) {
       DLOG(ERROR) << "Unable to parse the value of the Crypto-Key header";
       std::move(callback).Run(GCMDecryptionResult::INVALID_CRYPTO_KEY_HEADER,
diff --git a/media/formats/mp4/box_reader_unittest.cc b/media/formats/mp4/box_reader_unittest.cc
index 750b9e09bbbf8..3f09ebaed20a7 100644
--- a/media/formats/mp4/box_reader_unittest.cc
+++ b/media/formats/mp4/box_reader_unittest.cc
@@ -2,10 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifdef UNSAFE_BUFFERS_BUILD
-// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
-#pragma allow_unsafe_buffers
-#endif
+#include <array>
+
+#include "base/containers/span.h"
+
+
 
 #include "media/formats/mp4/box_reader.h"
 
@@ -29,7 +30,7 @@ using ::testing::StrictMock;
 namespace media {
 namespace mp4 {
 
-static const uint8_t kSkipBox[] = {
+static const auto kSkipBox = std::to_array<uint8_t>({
     // Top-level test box containing three children
     0x00, 0x00, 0x00, 0x40, 's', 'k', 'i', 'p', 0x01, 0x02, 0x03, 0x04, 0x05,
     0x06, 0x07, 0x08, 0xf9, 0x0a, 0x0b, 0x0c, 0xfd, 0x0e, 0x0f, 0x10,
@@ -41,7 +42,7 @@ static const uint8_t kSkipBox[] = {
     // Empty free box
     0x00, 0x00, 0x00, 0x08, 'f', 'r', 'e', 'e',
     // Trailing garbage
-    0x00};
+    0x00,});
 
 struct FreeBox : Box {
   bool Parse(BoxReader* reader) override {
@@ -94,7 +95,7 @@ class BoxReaderTest : public testing::Test {
 
  protected:
   std::vector<uint8_t> GetBuf() {
-    return std::vector<uint8_t>(kSkipBox, kSkipBox + sizeof(kSkipBox));
+    return std::vector<uint8_t>(kSkipBox.begin(), kSkipBox.end());
   }
 
   void TestTopLevelBox(base::span<const uint8_t> data, uint32_t fourCC) {
diff --git a/net/base/address_tracker_linux.cc b/net/base/address_tracker_linux.cc
index ff0a77f823ef1..cc276d901ddb8 100644
--- a/net/base/address_tracker_linux.cc
+++ b/net/base/address_tracker_linux.cc
@@ -45,10 +45,10 @@ namespace {
 // Some kernel functions such as wireless_send_event and rtnetlink_ifinfo_prep
 // may send spurious messages over rtnetlink. RTM_NEWLINK messages where
 // ifi_change == 0 and rta_type == IFLA_WIRELESS should be ignored.
-bool IgnoreWirelessChange(const struct ifinfomsg* msg, int length) {
-  for (const struct rtattr* attr = UNSAFE_TODO(IFLA_RTA(msg));
+bool IgnoreWirelessChange(base::span<const struct ifinfomsg> msg, int length) {
+  for (const struct rtattr* attr = UNSAFE_TODO(IFLA_RTA(msg.data()));
        RTA_OK(attr, length); attr = UNSAFE_TODO(RTA_NEXT(attr, length))) {
-    if (attr->rta_type == IFLA_WIRELESS && msg->ifi_change == 0)
+    if (attr->rta_type == IFLA_WIRELESS && msg.front().ifi_change == 0)
       return true;
   }
   return false;
@@ -140,11 +140,14 @@ bool GetAddress(const struct nlmsghdr* header,
 // SafelyCastNetlinkMsgData<T> performs a bounds check before casting |header|'s
 // data to a |T*|. When the bounds check fails, returns nullptr.
 template <typename T>
-T* SafelyCastNetlinkMsgData(const struct nlmsghdr* header, int length) {
+base::span<const T> SafelyCastNetlinkMsgData(const struct nlmsghdr* header,
+                                             int length) {
   DCHECK(NLMSG_OK(header, static_cast<__u32>(length)));
   if (length <= 0 || static_cast<size_t>(length) < NLMSG_HDRLEN + sizeof(T))
-    return nullptr;
-  return reinterpret_cast<const T*>(UNSAFE_TODO(NLMSG_DATA(header)));
+    return {};
+  // SAFETY: The bounds of the message have been checked above.
+  return UNSAFE_BUFFERS(
+      base::span(reinterpret_cast<const T*>(NLMSG_DATA(header)), 1u));
 }
 
 }  // namespace
@@ -484,23 +487,23 @@ void AddressTrackerLinux::HandleMessage(const char* buffer,
       case NLMSG_DONE:
         return;
       case NLMSG_ERROR: {
-        const struct nlmsgerr* msg =
-            SafelyCastNetlinkMsgData<const struct nlmsgerr>(header, length);
-        if (msg == nullptr)
+        base::span<const nlmsgerr> msg =
+            SafelyCastNetlinkMsgData<nlmsgerr>(header, length);
+        if (msg.empty())
           return;
-        LOG(ERROR) << "Unexpected netlink error " << msg->error << ".";
+        LOG(ERROR) << "Unexpected netlink error " << msg.front().error << ".";
       } return;
       case RTM_NEWADDR: {
         IPAddress address;
         bool really_deprecated;
-        const struct ifaddrmsg* msg =
-            SafelyCastNetlinkMsgData<const struct ifaddrmsg>(header, length);
-        if (msg == nullptr)
+        base::span<const ifaddrmsg> msg =
+            SafelyCastNetlinkMsgData<ifaddrmsg>(header, length);
+        if (msg.empty())
           return;
-        if (IsInterfaceIgnored(msg->ifa_index))
+        if (IsInterfaceIgnored(msg.front().ifa_index))
           break;
         if (GetAddress(header, length, &address, &really_deprecated)) {
-          struct ifaddrmsg msg_copy = *msg;
+          struct ifaddrmsg msg_copy = msg.front();
           AddressTrackerAutoLock lock(*this, address_map_lock_);
           // Routers may frequently (every few seconds) output the IPv6 ULA
           // prefix which can cause the linux kernel to frequently output two
@@ -531,11 +534,11 @@ void AddressTrackerLinux::HandleMessage(const char* buffer,
       } break;
       case RTM_DELADDR: {
         IPAddress address;
-        const struct ifaddrmsg* msg =
-            SafelyCastNetlinkMsgData<const struct ifaddrmsg>(header, length);
-        if (msg == nullptr)
+        base::span<const ifaddrmsg> msg =
+            SafelyCastNetlinkMsgData<ifaddrmsg>(header, length);
+        if (msg.empty())
           return;
-        if (IsInterfaceIgnored(msg->ifa_index))
+        if (IsInterfaceIgnored(msg.front().ifa_index))
           break;
         if (GetAddress(header, length, &address, nullptr)) {
           AddressTrackerAutoLock lock(*this, address_map_lock_);
@@ -548,53 +551,55 @@ void AddressTrackerLinux::HandleMessage(const char* buffer,
         }
       } break;
       case RTM_NEWLINK: {
-        const struct ifinfomsg* msg =
-            SafelyCastNetlinkMsgData<const struct ifinfomsg>(header, length);
-        if (msg == nullptr)
+        base::span<const struct ifinfomsg> msg =
+            SafelyCastNetlinkMsgData<struct ifinfomsg>(header, length);
+        if (msg.empty())
           return;
-        if (IsInterfaceIgnored(msg->ifi_index))
+        if (IsInterfaceIgnored(msg.front().ifi_index))
           break;
         if (IgnoreWirelessChange(msg, IFLA_PAYLOAD(header))) {
           VLOG(2) << "Ignoring RTM_NEWLINK message";
           break;
         }
-        if (!(msg->ifi_flags & IFF_LOOPBACK) && (msg->ifi_flags & IFF_UP) &&
-            (msg->ifi_flags & IFF_LOWER_UP) && (msg->ifi_flags & IFF_RUNNING)) {
+        if (!(msg.front().ifi_flags & IFF_LOOPBACK) &&
+            (msg.front().ifi_flags & IFF_UP) &&
+            (msg.front().ifi_flags & IFF_LOWER_UP) &&
+            (msg.front().ifi_flags & IFF_RUNNING)) {
           AddressTrackerAutoLock lock(*this, online_links_lock_);
-          if (online_links_.insert(msg->ifi_index).second) {
+          if (online_links_.insert(msg.front().ifi_index).second) {
             *link_changed = true;
             if (online_links_diff_.has_value()) {
-              (*online_links_diff_)[msg->ifi_index] = true;
+              (*online_links_diff_)[msg.front().ifi_index] = true;
             }
-            if (IsTunnelInterface(msg->ifi_index))
+            if (IsTunnelInterface(msg.front().ifi_index))
               *tunnel_changed = true;
           }
         } else {
           AddressTrackerAutoLock lock(*this, online_links_lock_);
-          if (online_links_.erase(msg->ifi_index)) {
+          if (online_links_.erase(msg.front().ifi_index)) {
             *link_changed = true;
             if (online_links_diff_.has_value()) {
-              (*online_links_diff_)[msg->ifi_index] = false;
+              (*online_links_diff_)[msg.front().ifi_index] = false;
             }
-            if (IsTunnelInterface(msg->ifi_index))
+            if (IsTunnelInterface(msg.front().ifi_index))
               *tunnel_changed = true;
           }
         }
       } break;
       case RTM_DELLINK: {
-        const struct ifinfomsg* msg =
-            SafelyCastNetlinkMsgData<const struct ifinfomsg>(header, length);
-        if (msg == nullptr)
+        base::span<const ifinfomsg> msg =
+            SafelyCastNetlinkMsgData<ifinfomsg>(header, length);
+        if (msg.empty())
           return;
-        if (IsInterfaceIgnored(msg->ifi_index))
+        if (IsInterfaceIgnored(msg.front().ifi_index))
           break;
         AddressTrackerAutoLock lock(*this, online_links_lock_);
-        if (online_links_.erase(msg->ifi_index)) {
+        if (online_links_.erase(msg.front().ifi_index)) {
           *link_changed = true;
           if (online_links_diff_.has_value()) {
-            (*online_links_diff_)[msg->ifi_index] = false;
+            (*online_links_diff_)[msg.front().ifi_index] = false;
           }
-          if (IsTunnelInterface(msg->ifi_index))
+          if (IsTunnelInterface(msg.front().ifi_index))
             *tunnel_changed = true;
         }
       } break;
diff --git a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
index eb5939a9d729a..7a5dd8550d2a0 100644
--- a/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
+++ b/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.cc
@@ -269,8 +269,14 @@ static void HarfBuzzGetGlyphHorizontalAdvances(
     void* user_data) {
   HarfBuzzFontData* hb_font_data =
       reinterpret_cast<HarfBuzzFontData*>(font_data);
-  SkFontGetGlyphWidthForHarfBuzz(hb_font_data->font_, count, first_glyph,
-                                 glyph_stride, first_advance, advance_stride);
+  SkFontGetGlyphWidthForHarfBuzz(
+      hb_font_data->font_, count,
+      UNSAFE_BUFFERS(base::span<const hb_codepoint_t>(
+          first_glyph, count * glyph_stride / sizeof(hb_codepoint_t))),
+      glyph_stride,
+      UNSAFE_BUFFERS(base::span<hb_position_t>(
+          first_advance, count * advance_stride / sizeof(hb_position_t))),
+      advance_stride);
 }
 
 static hb_bool_t HarfBuzzGetGlyphVerticalOrigin(hb_font_t* hb_font,
diff --git a/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.cc b/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.cc
index 2e91edbae488b..c6e8b8cf998b7 100644
--- a/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.cc
+++ b/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.cc
@@ -2,10 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#ifdef UNSAFE_BUFFERS_BUILD
-// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
-#pragma allow_unsafe_buffers
-#endif
+
 
 #include "third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.h"
 
@@ -21,14 +18,14 @@ namespace blink {
 namespace {
 
 template <class T>
-T* advance_by_byte_size(T* p, unsigned byte_size) {
-  return reinterpret_cast<T*>(reinterpret_cast<uint8_t*>(p) + byte_size);
+base::span<T> advance_by_byte_size(base::span<T> p, unsigned byte_size) {
+  return p.subspan(byte_size / sizeof(T));
 }
 
 template <class T>
-const T* advance_by_byte_size(const T* p, unsigned byte_size) {
-  return reinterpret_cast<const T*>(reinterpret_cast<const uint8_t*>(p) +
-                                    byte_size);
+base::span<const T> advance_by_byte_size(base::span<const T> p,
+                                         unsigned byte_size) {
+  return p.subspan(byte_size / sizeof(T));
 }
 
 }  // namespace
@@ -55,9 +52,9 @@ void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
 
 void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
                                     unsigned count,
-                                    const hb_codepoint_t* glyphs,
+                                    base::span<const hb_codepoint_t> glyphs,
                                     const unsigned glyph_stride,
-                                    hb_position_t* advances,
+                                    base::span<hb_position_t> advances,
                                     unsigned advance_stride) {
   // Batch the call to getWidths because its function entry cost is not
   // cheap. getWidths accepts multiple glyphd ID, but not from a sparse
@@ -65,7 +62,7 @@ void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
   Vector<Glyph, 256> glyph_array(count);
   for (unsigned i = 0; i < count;
        i++, glyphs = advance_by_byte_size(glyphs, glyph_stride)) {
-    glyph_array[i] = *glyphs;
+    glyph_array[i] = glyphs[0];
   }
   Vector<SkScalar, 256> sk_width_array(count);
   font.getWidths(glyph_array, sk_width_array);
@@ -78,7 +75,7 @@ void SkFontGetGlyphWidthForHarfBuzz(const SkFont& font,
   // Copy the results back to the sparse array.
   for (unsigned i = 0; i < count;
        i++, advances = advance_by_byte_size(advances, advance_stride)) {
-    *advances = SkiaScalarToHarfBuzzPosition(sk_width_array[i]);
+    advances[0] = SkiaScalarToHarfBuzzPosition(sk_width_array[i]);
   }
 }
 
diff --git a/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.h b/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.h
index 16bc2fb9f8703..cdcf92f52f539 100644
--- a/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.h
+++ b/third_party/blink/renderer/platform/fonts/skia/skia_text_metrics.h
@@ -25,9 +25,9 @@ void SkFontGetGlyphWidthForHarfBuzz(const SkFont&,
                                     hb_position_t* width);
 void SkFontGetGlyphWidthForHarfBuzz(const SkFont&,
                                     unsigned count,
-                                    const hb_codepoint_t* first_glyph,
+                                    base::span<const hb_codepoint_t> first_glyph,
                                     unsigned glyph_stride,
-                                    hb_position_t* first_advance,
+                                    base::span<hb_position_t> first_advance,
                                     unsigned advance_stride);
 void SkFontGetGlyphExtentsForHarfBuzz(const SkFont&,
                                       hb_codepoint_t,
