Remove quic/platform/api/quic_mutex.h

PiperOrigin-RevId: 662101214
diff --git a/quiche/quic/core/crypto/crypto_secret_boxer.cc b/quiche/quic/core/crypto/crypto_secret_boxer.cc
index 6860bec..b51ce6b 100644
--- a/quiche/quic/core/crypto/crypto_secret_boxer.cc
+++ b/quiche/quic/core/crypto/crypto_secret_boxer.cc
@@ -15,6 +15,7 @@
 #include "openssl/err.h"
 #include "quiche/quic/core/crypto/quic_random.h"
 #include "quiche/quic/platform/api/quic_logging.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 
 namespace quic {
 
@@ -67,7 +68,7 @@
     new_state->ctxs.push_back(std::move(ctx));
   }
 
-  QuicWriterMutexLock l(&lock_);
+  quiche::QuicheWriterMutexLock l(&lock_);
   state_ = std::move(new_state);
   return true;
 }
@@ -94,7 +95,7 @@
 
   size_t bytes_written;
   {
-    QuicReaderMutexLock l(&lock_);
+    quiche::QuicheReaderMutexLock l(&lock_);
     if (!EVP_AEAD_CTX_seal(state_->ctxs[0].get(), out, &bytes_written, out_len,
                            nonce, kSIVNonceSize,
                            reinterpret_cast<const uint8_t*>(plaintext.data()),
@@ -125,7 +126,7 @@
 
   bool ok = false;
   {
-    QuicReaderMutexLock l(&lock_);
+    quiche::QuicheReaderMutexLock l(&lock_);
     for (const bssl::UniquePtr<EVP_AEAD_CTX>& ctx : state_->ctxs) {
       size_t bytes_written;
       if (EVP_AEAD_CTX_open(ctx.get(),
diff --git a/quiche/quic/core/crypto/crypto_secret_boxer.h b/quiche/quic/core/crypto/crypto_secret_boxer.h
index 964d760..5b76891 100644
--- a/quiche/quic/core/crypto/crypto_secret_boxer.h
+++ b/quiche/quic/core/crypto/crypto_secret_boxer.h
@@ -13,7 +13,7 @@
 #include "absl/strings/string_view.h"
 #include "quiche/quic/core/crypto/quic_random.h"
 #include "quiche/quic/platform/api/quic_export.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 
 namespace quic {
 
@@ -55,11 +55,11 @@
  private:
   struct State;
 
-  mutable QuicMutex lock_;
+  mutable quiche::QuicheMutex lock_;
 
   // state_ is an opaque pointer to whatever additional state the concrete
   // implementation of CryptoSecretBoxer requires.
-  std::unique_ptr<State> state_ QUIC_GUARDED_BY(lock_);
+  std::unique_ptr<State> state_ QUICHE_GUARDED_BY(lock_);
 };
 
 }  // namespace quic
diff --git a/quiche/quic/core/crypto/quic_crypto_server_config.cc b/quiche/quic/core/crypto/quic_crypto_server_config.cc
index 7acc867..4115f2e 100644
--- a/quiche/quic/core/crypto/quic_crypto_server_config.cc
+++ b/quiche/quic/core/crypto/quic_crypto_server_config.cc
@@ -438,7 +438,7 @@
   }
 
   {
-    QuicWriterMutexLock locked(&configs_lock_);
+    quiche::QuicheWriterMutexLock locked(&configs_lock_);
     if (configs_.find(config->id) != configs_.end()) {
       QUIC_LOG(WARNING) << "Failed to add config because another with the same "
                            "server config id already exists: "
@@ -501,7 +501,7 @@
 
   QUIC_LOG(INFO) << "Updating configs:";
 
-  QuicWriterMutexLock locked(&configs_lock_);
+  quiche::QuicheWriterMutexLock locked(&configs_lock_);
   ConfigMap new_configs;
 
   for (const quiche::QuicheReferenceCountedPointer<Config>& config :
@@ -552,7 +552,7 @@
 }
 
 std::vector<std::string> QuicCryptoServerConfig::GetConfigIds() const {
-  QuicReaderMutexLock locked(&configs_lock_);
+  quiche::QuicheReaderMutexLock locked(&configs_lock_);
   std::vector<std::string> scids;
   for (auto it = configs_.begin(); it != configs_.end(); ++it) {
     scids.push_back(it->first);
@@ -1123,7 +1123,7 @@
     const QuicWallTime& now, absl::string_view requested_scid,
     quiche::QuicheReferenceCountedPointer<Config> old_primary_config,
     Configs* configs) const {
-  QuicReaderMutexLock locked(&configs_lock_);
+  quiche::QuicheReaderMutexLock locked(&configs_lock_);
 
   if (!primary_config_) {
     return false;
@@ -1359,7 +1359,7 @@
   std::string serialized;
   std::string source_address_token;
   {
-    QuicReaderMutexLock locked(&configs_lock_);
+    quiche::QuicheReaderMutexLock locked(&configs_lock_);
     serialized = primary_config_->serialized;
     source_address_token = NewSourceAddressToken(
         *primary_config_->source_address_token_boxer,
@@ -1717,7 +1717,7 @@
 
 void QuicCryptoServerConfig::AcquirePrimaryConfigChangedCb(
     std::unique_ptr<PrimaryConfigChangedCallback> cb) {
-  QuicWriterMutexLock locked(&configs_lock_);
+  quiche::QuicheWriterMutexLock locked(&configs_lock_);
   primary_config_changed_cb_ = std::move(cb);
 }
 
@@ -1758,7 +1758,7 @@
 }
 
 int QuicCryptoServerConfig::NumberOfConfigs() const {
-  QuicReaderMutexLock locked(&configs_lock_);
+  quiche::QuicheReaderMutexLock locked(&configs_lock_);
   return configs_.size();
 }
 
diff --git a/quiche/quic/core/crypto/quic_crypto_server_config.h b/quiche/quic/core/crypto/quic_crypto_server_config.h
index d2346a9..30875a6 100644
--- a/quiche/quic/core/crypto/quic_crypto_server_config.h
+++ b/quiche/quic/core/crypto/quic_crypto_server_config.h
@@ -27,8 +27,8 @@
 #include "quiche/quic/core/proto/source_address_token_proto.h"
 #include "quiche/quic/core/quic_time.h"
 #include "quiche/quic/platform/api/quic_export.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/platform/api/quic_socket_address.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 #include "quiche/common/platform/api/quiche_reference_counted.h"
 
 namespace quic {
@@ -539,7 +539,7 @@
   // Get a ref to the config with a given server config id.
   quiche::QuicheReferenceCountedPointer<Config> GetConfigWithScid(
       absl::string_view requested_scid) const
-      QUIC_SHARED_LOCKS_REQUIRED(configs_lock_);
+      QUICHE_SHARED_LOCKS_REQUIRED(configs_lock_);
 
   // A snapshot of the configs associated with an in-progress handshake.
   struct QUICHE_EXPORT Configs {
@@ -568,7 +568,7 @@
   // SelectNewPrimaryConfig reevaluates the primary config based on the
   // "primary_time" deadlines contained in each.
   void SelectNewPrimaryConfig(QuicWallTime now) const
-      QUIC_EXCLUSIVE_LOCKS_REQUIRED(configs_lock_);
+      QUICHE_EXCLUSIVE_LOCKS_REQUIRED(configs_lock_);
 
   // EvaluateClientHello checks |client_hello_state->client_hello| for gross
   // errors and determines whether it is fresh (i.e. not a replay). The results
@@ -843,7 +843,7 @@
 
   // Returns true if the next config promotion should happen now.
   bool IsNextConfigReady(QuicWallTime now) const
-      QUIC_SHARED_LOCKS_REQUIRED(configs_lock_);
+      QUICHE_SHARED_LOCKS_REQUIRED(configs_lock_);
 
   // replay_protection_ controls whether the server enforces that handshakes
   // aren't replays.
@@ -858,16 +858,16 @@
   //   1) configs_.empty() <-> primary_config_ == nullptr
   //   2) primary_config_ != nullptr -> primary_config_->is_primary
   //   3) ∀ c∈configs_, c->is_primary <-> c == primary_config_
-  mutable QuicMutex configs_lock_;
+  mutable quiche::QuicheMutex configs_lock_;
 
   // configs_ contains all active server configs. It's expected that there are
   // about half-a-dozen configs active at any one time.
-  ConfigMap configs_ QUIC_GUARDED_BY(configs_lock_);
+  ConfigMap configs_ QUICHE_GUARDED_BY(configs_lock_);
 
   // primary_config_ points to a Config (which is also in |configs_|) which is
   // the primary config - i.e. the one that we'll give out to new clients.
   mutable quiche::QuicheReferenceCountedPointer<Config> primary_config_
-      QUIC_GUARDED_BY(configs_lock_);
+      QUICHE_GUARDED_BY(configs_lock_);
 
   // fallback_config_ points to a Config (which is also in |configs_|) which is
   // the fallback config, which will be used if the other configs are unuseable
@@ -875,16 +875,16 @@
   //
   // TODO(b/112548056): This is currently always nullptr.
   quiche::QuicheReferenceCountedPointer<Config> fallback_config_
-      QUIC_GUARDED_BY(configs_lock_);
+      QUICHE_GUARDED_BY(configs_lock_);
 
   // next_config_promotion_time_ contains the nearest, future time when an
   // active config will be promoted to primary.
   mutable QuicWallTime next_config_promotion_time_
-      QUIC_GUARDED_BY(configs_lock_);
+      QUICHE_GUARDED_BY(configs_lock_);
 
   // Callback to invoke when the primary config changes.
   std::unique_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_
-      QUIC_GUARDED_BY(configs_lock_);
+      QUICHE_GUARDED_BY(configs_lock_);
 
   // Used to protect the source-address tokens that are given to clients.
   CryptoSecretBoxer source_address_token_boxer_;
diff --git a/quiche/quic/platform/api/quic_mutex.h b/quiche/quic/platform/api/quic_mutex.h
index 1e6f36a..6bf90db 100644
--- a/quiche/quic/platform/api/quic_mutex.h
+++ b/quiche/quic/platform/api/quic_mutex.h
@@ -10,10 +10,10 @@
 #include "quiche/common/platform/api/quiche_mutex.h"
 
 #define QUIC_EXCLUSIVE_LOCKS_REQUIRED QUICHE_EXCLUSIVE_LOCKS_REQUIRED
-#define QUIC_GUARDED_BY QUICHE_GUARDED_BY
+#define QUICHE_GUARDED_BY QUICHE_GUARDED_BY
 #define QUIC_LOCKABLE QUICHE_LOCKABLE
 #define QUIC_LOCKS_EXCLUDED QUICHE_LOCKS_EXCLUDED
-#define QUIC_SHARED_LOCKS_REQUIRED QUICHE_SHARED_LOCKS_REQUIRED
+#define QUICHE_SHARED_LOCKS_REQUIRED QUICHE_SHARED_LOCKS_REQUIRED
 #define QUIC_EXCLUSIVE_LOCK_FUNCTION QUICHE_EXCLUSIVE_LOCK_FUNCTION
 #define QUIC_UNLOCK_FUNCTION QUICHE_UNLOCK_FUNCTION
 #define QUIC_SHARED_LOCK_FUNCTION QUICHE_SHARED_LOCK_FUNCTION
@@ -23,7 +23,7 @@
 namespace quic {
 
 using QuicMutex = quiche::QuicheMutex;
-using QuicReaderMutexLock = quiche::QuicheReaderMutexLock;
+using quiche::QuicheReaderMutexLock = quiche::QuicheReaderMutexLock;
 using QuicWriterMutexLock = quiche::QuicheWriterMutexLock;
 using QuicNotification = quiche::QuicheNotification;
 
diff --git a/quiche/quic/qbone/bonnet/icmp_reachable.cc b/quiche/quic/qbone/bonnet/icmp_reachable.cc
index da5e103..bc79dcf 100644
--- a/quiche/quic/qbone/bonnet/icmp_reachable.cc
+++ b/quiche/quic/qbone/bonnet/icmp_reachable.cc
@@ -12,7 +12,6 @@
 #include "quiche/quic/core/crypto/quic_random.h"
 #include "quiche/quic/core/io/quic_event_loop.h"
 #include "quiche/quic/platform/api/quic_logging.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/qbone/platform/icmp_packet.h"
 #include "quiche/common/platform/api/quiche_logging.h"
 #include "quiche/common/quiche_text_utils.h"
@@ -104,7 +103,7 @@
   }
   alarm_->Set(clock_->Now());
 
-  QuicWriterMutexLock mu(&header_lock_);
+  quiche::QuicheWriterMutexLock mu(&header_lock_);
   icmp_header_.icmp6_type = ICMP6_ECHO_REQUEST;
   icmp_header_.icmp6_code = 0;
 
@@ -135,7 +134,7 @@
       absl::string_view(buffer, size));
 
   auto* header = reinterpret_cast<const icmp6_hdr*>(&buffer);
-  QuicWriterMutexLock mu(&header_lock_);
+  quiche::QuicheWriterMutexLock mu(&header_lock_);
   if (header->icmp6_data32[0] != icmp_header_.icmp6_data32[0]) {
     QUIC_VLOG(2) << "Unexpected response. id: " << header->icmp6_id
                  << " seq: " << header->icmp6_seq
@@ -160,7 +159,7 @@
 }
 
 void IcmpReachable::OnAlarm() {
-  QuicWriterMutexLock mu(&header_lock_);
+  quiche::QuicheWriterMutexLock mu(&header_lock_);
 
   if (end_ < start_) {
     QUIC_VLOG(1) << "Timed out on sequence: " << icmp_header_.icmp6_seq;
diff --git a/quiche/quic/qbone/bonnet/icmp_reachable.h b/quiche/quic/qbone/bonnet/icmp_reachable.h
index f00c99a..d706c9b 100644
--- a/quiche/quic/qbone/bonnet/icmp_reachable.h
+++ b/quiche/quic/qbone/bonnet/icmp_reachable.h
@@ -16,9 +16,9 @@
 #include "quiche/quic/core/quic_clock.h"
 #include "quiche/quic/core/quic_time.h"
 #include "quiche/quic/platform/api/quic_ip_address.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/qbone/bonnet/icmp_reachable_interface.h"
 #include "quiche/quic/qbone/platform/kernel_interface.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 
 namespace quic {
 
@@ -79,9 +79,9 @@
 
   // Initializes this reachability probe. Must be called from within the
   // |epoll_server|'s thread.
-  bool Init() QUIC_LOCKS_EXCLUDED(header_lock_) override;
+  bool Init() QUICHE_LOCKS_EXCLUDED(header_lock_) override;
 
-  void OnAlarm() QUIC_LOCKS_EXCLUDED(header_lock_);
+  void OnAlarm() QUICHE_LOCKS_EXCLUDED(header_lock_);
 
   static absl::string_view StatusName(Status status);
 
@@ -113,7 +113,7 @@
     IcmpReachable* reachable_;
   };
 
-  bool OnEvent(int fd) QUIC_LOCKS_EXCLUDED(header_lock_);
+  bool OnEvent(int fd) QUICHE_LOCKS_EXCLUDED(header_lock_);
 
   const QuicTime::Delta timeout_;
 
@@ -134,8 +134,8 @@
   int send_fd_;
   int recv_fd_;
 
-  QuicMutex header_lock_;
-  icmp6_hdr icmp_header_ QUIC_GUARDED_BY(header_lock_){};
+  quiche::QuicheMutex header_lock_;
+  icmp6_hdr icmp_header_ QUICHE_GUARDED_BY(header_lock_){};
 
   QuicTime start_ = QuicTime::Zero();
   QuicTime end_ = QuicTime::Zero();
diff --git a/quiche/quic/qbone/qbone_client_test.cc b/quiche/quic/qbone/qbone_client_test.cc
index 53acb22..a8e78a2 100644
--- a/quiche/quic/qbone/qbone_client_test.cc
+++ b/quiche/quic/qbone/qbone_client_test.cc
@@ -21,7 +21,6 @@
 #include "quiche/quic/core/quic_types.h"
 #include "quiche/quic/core/quic_versions.h"
 #include "quiche/quic/platform/api/quic_flags.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/platform/api/quic_socket_address.h"
 #include "quiche/quic/platform/api/quic_test.h"
 #include "quiche/quic/platform/api/quic_test_loopback.h"
@@ -58,17 +57,17 @@
 class DataSavingQbonePacketWriter : public QbonePacketWriter {
  public:
   void WritePacketToNetwork(const char* packet, size_t size) override {
-    QuicWriterMutexLock lock(&mu_);
+    quiche::QuicheWriterMutexLock lock(&mu_);
     data_.push_back(std::string(packet, size));
   }
 
   std::vector<std::string> data() {
-    QuicWriterMutexLock lock(&mu_);
+    quiche::QuicheWriterMutexLock lock(&mu_);
     return data_;
   }
 
  private:
-  QuicMutex mu_;
+  quiche::QuicheMutex mu_;
   std::vector<std::string> data_;
 };
 
diff --git a/quiche/quic/test_tools/packet_dropping_test_writer.cc b/quiche/quic/test_tools/packet_dropping_test_writer.cc
index fa3eb73..a16cda7 100644
--- a/quiche/quic/test_tools/packet_dropping_test_writer.cc
+++ b/quiche/quic/test_tools/packet_dropping_test_writer.cc
@@ -97,7 +97,7 @@
   ++num_calls_to_write_;
   ReleaseOldPackets();
 
-  QuicWriterMutexLock lock(&config_mutex_);
+  quiche::QuicheWriterMutexLock lock(&config_mutex_);
   if (passthrough_for_next_n_packets_ > 0) {
     --passthrough_for_next_n_packets_;
     return QuicPacketWriterWrapper::WritePacket(buffer, buf_len, self_address,
@@ -201,7 +201,7 @@
   if (delayed_packets_.empty()) {
     return QuicTime::Zero();
   }
-  QuicReaderMutexLock lock(&config_mutex_);
+  quiche::QuicheReaderMutexLock lock(&config_mutex_);
   auto iter = delayed_packets_.begin();
   // Determine if we should re-order.
   if (delayed_packets_.size() > 1 && fake_packet_reorder_percentage_ > 0 &&
diff --git a/quiche/quic/test_tools/packet_dropping_test_writer.h b/quiche/quic/test_tools/packet_dropping_test_writer.h
index 2b05005..84bfcfa 100644
--- a/quiche/quic/test_tools/packet_dropping_test_writer.h
+++ b/quiche/quic/test_tools/packet_dropping_test_writer.h
@@ -15,8 +15,8 @@
 #include "quiche/quic/core/quic_clock.h"
 #include "quiche/quic/core/quic_connection.h"
 #include "quiche/quic/core/quic_packet_writer_wrapper.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/test_tools/quic_test_utils.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 
 namespace quic {
 namespace test {
@@ -80,7 +80,7 @@
   // |fake_packet_loss_percentage|, because every dropped package is followed by
   // a minimum number of successfully written packets.
   void set_fake_packet_loss_percentage(int32_t fake_packet_loss_percentage) {
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     fake_packet_loss_percentage_ = fake_packet_loss_percentage;
   }
 
@@ -89,14 +89,14 @@
   // simulated error conditions.
   void set_passthrough_for_next_n_packets(
       uint32_t passthrough_for_next_n_packets) {
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     passthrough_for_next_n_packets_ = passthrough_for_next_n_packets;
   }
 
   // Simulate dropping the first n packets unconditionally.
   // Subsequent packets will be lost at fake_packet_loss_percentage_ if set.
   void set_fake_drop_first_n_packets(int32_t fake_drop_first_n_packets) {
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     fake_drop_first_n_packets_ = fake_drop_first_n_packets;
   }
 
@@ -105,14 +105,14 @@
   void set_fake_blocked_socket_percentage(
       int32_t fake_blocked_socket_percentage) {
     QUICHE_DCHECK(clock_);
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     fake_blocked_socket_percentage_ = fake_blocked_socket_percentage;
   }
 
   // The percent of time a packet is simulated as being reordered.
   void set_fake_reorder_percentage(int32_t fake_packet_reorder_percentage) {
     QUICHE_DCHECK(clock_);
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     QUICHE_DCHECK(!fake_packet_delay_.IsZero());
     fake_packet_reorder_percentage_ = fake_packet_reorder_percentage;
   }
@@ -120,7 +120,7 @@
   // The delay before writing this packet.
   void set_fake_packet_delay(QuicTime::Delta fake_packet_delay) {
     QUICHE_DCHECK(clock_);
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     fake_packet_delay_ = fake_packet_delay;
   }
 
@@ -131,7 +131,7 @@
   void set_max_bandwidth_and_buffer_size(QuicBandwidth fake_bandwidth,
                                          QuicByteCount buffer_size) {
     QUICHE_DCHECK(clock_);
-    QuicWriterMutexLock lock(&config_mutex_);
+    quiche::QuicheWriterMutexLock lock(&config_mutex_);
     fake_bandwidth_ = fake_bandwidth;
     buffer_size_ = buffer_size;
   }
@@ -179,17 +179,17 @@
   DelayedPacketList delayed_packets_;
   QuicByteCount cur_buffer_size_;
   uint64_t num_calls_to_write_;
-  uint32_t passthrough_for_next_n_packets_ QUIC_GUARDED_BY(config_mutex_);
+  uint32_t passthrough_for_next_n_packets_ QUICHE_GUARDED_BY(config_mutex_);
   int32_t num_consecutive_succesful_writes_;
 
-  QuicMutex config_mutex_;
-  int32_t fake_packet_loss_percentage_ QUIC_GUARDED_BY(config_mutex_);
-  int32_t fake_drop_first_n_packets_ QUIC_GUARDED_BY(config_mutex_);
-  int32_t fake_blocked_socket_percentage_ QUIC_GUARDED_BY(config_mutex_);
-  int32_t fake_packet_reorder_percentage_ QUIC_GUARDED_BY(config_mutex_);
-  QuicTime::Delta fake_packet_delay_ QUIC_GUARDED_BY(config_mutex_);
-  QuicBandwidth fake_bandwidth_ QUIC_GUARDED_BY(config_mutex_);
-  QuicByteCount buffer_size_ QUIC_GUARDED_BY(config_mutex_);
+  quiche::QuicheMutex config_mutex_;
+  int32_t fake_packet_loss_percentage_ QUICHE_GUARDED_BY(config_mutex_);
+  int32_t fake_drop_first_n_packets_ QUICHE_GUARDED_BY(config_mutex_);
+  int32_t fake_blocked_socket_percentage_ QUICHE_GUARDED_BY(config_mutex_);
+  int32_t fake_packet_reorder_percentage_ QUICHE_GUARDED_BY(config_mutex_);
+  QuicTime::Delta fake_packet_delay_ QUICHE_GUARDED_BY(config_mutex_);
+  QuicBandwidth fake_bandwidth_ QUICHE_GUARDED_BY(config_mutex_);
+  QuicByteCount buffer_size_ QUICHE_GUARDED_BY(config_mutex_);
 };
 
 }  // namespace test
diff --git a/quiche/quic/test_tools/quic_crypto_server_config_peer.cc b/quiche/quic/test_tools/quic_crypto_server_config_peer.cc
index c63b0c5..b8a6280 100644
--- a/quiche/quic/test_tools/quic_crypto_server_config_peer.cc
+++ b/quiche/quic/test_tools/quic_crypto_server_config_peer.cc
@@ -19,14 +19,14 @@
 
 quiche::QuicheReferenceCountedPointer<QuicCryptoServerConfig::Config>
 QuicCryptoServerConfigPeer::GetPrimaryConfig() {
-  QuicReaderMutexLock locked(&server_config_->configs_lock_);
+  quiche::QuicheReaderMutexLock locked(&server_config_->configs_lock_);
   return quiche::QuicheReferenceCountedPointer<QuicCryptoServerConfig::Config>(
       server_config_->primary_config_);
 }
 
 quiche::QuicheReferenceCountedPointer<QuicCryptoServerConfig::Config>
 QuicCryptoServerConfigPeer::GetConfig(std::string config_id) {
-  QuicReaderMutexLock locked(&server_config_->configs_lock_);
+  quiche::QuicheReaderMutexLock locked(&server_config_->configs_lock_);
   if (config_id == "<primary>") {
     return quiche::QuicheReferenceCountedPointer<
         QuicCryptoServerConfig::Config>(server_config_->primary_config_);
@@ -83,7 +83,7 @@
 
 void QuicCryptoServerConfigPeer::CheckConfigs(
     std::vector<std::pair<std::string, bool>> expected_ids_and_status) {
-  QuicReaderMutexLock locked(&server_config_->configs_lock_);
+  quiche::QuicheReaderMutexLock locked(&server_config_->configs_lock_);
 
   ASSERT_EQ(expected_ids_and_status.size(), server_config_->configs_.size())
       << ConfigsDebug();
@@ -132,7 +132,7 @@
 }
 
 void QuicCryptoServerConfigPeer::SelectNewPrimaryConfig(int seconds) {
-  QuicWriterMutexLock locked(&server_config_->configs_lock_);
+  quiche::QuicheWriterMutexLock locked(&server_config_->configs_lock_);
   server_config_->SelectNewPrimaryConfig(
       QuicWallTime::FromUNIXSeconds(seconds));
 }
diff --git a/quiche/quic/test_tools/quic_crypto_server_config_peer.h b/quiche/quic/test_tools/quic_crypto_server_config_peer.h
index f8a1ee5..fe9f32c 100644
--- a/quiche/quic/test_tools/quic_crypto_server_config_peer.h
+++ b/quiche/quic/test_tools/quic_crypto_server_config_peer.h
@@ -65,7 +65,7 @@
   // ConfigsDebug returns a std::string that contains debugging information
   // about the set of Configs loaded in |server_config_| and their status.
   std::string ConfigsDebug()
-      QUIC_SHARED_LOCKS_REQUIRED(server_config_->configs_lock_);
+      QUICHE_SHARED_LOCKS_REQUIRED(server_config_->configs_lock_);
 
   void SelectNewPrimaryConfig(int seconds);
 
diff --git a/quiche/quic/test_tools/quic_test_server.cc b/quiche/quic/test_tools/quic_test_server.cc
index a02b849..9ef1368 100644
--- a/quiche/quic/test_tools/quic_test_server.cc
+++ b/quiche/quic/test_tools/quic_test_server.cc
@@ -94,7 +94,7 @@
       const ParsedQuicVersion& version,
       const ParsedClientHello& /*parsed_chlo*/,
       ConnectionIdGeneratorInterface& connection_id_generator) override {
-    QuicReaderMutexLock lock(&factory_lock_);
+    quiche::QuicheReaderMutexLock lock(&factory_lock_);
     // The QuicServerSessionBase takes ownership of |connection| below.
     QuicConnection* connection = new QuicConnection(
         id, self_address, peer_address, helper(), alarm_factory(), writer(),
@@ -130,7 +130,7 @@
   }
 
   void SetSessionFactory(QuicTestServer::SessionFactory* factory) {
-    QuicWriterMutexLock lock(&factory_lock_);
+    quiche::QuicheWriterMutexLock lock(&factory_lock_);
     QUICHE_DCHECK(session_factory_ == nullptr);
     QUICHE_DCHECK(stream_factory_ == nullptr);
     QUICHE_DCHECK(crypto_stream_factory_ == nullptr);
@@ -138,21 +138,21 @@
   }
 
   void SetStreamFactory(QuicTestServer::StreamFactory* factory) {
-    QuicWriterMutexLock lock(&factory_lock_);
+    quiche::QuicheWriterMutexLock lock(&factory_lock_);
     QUICHE_DCHECK(session_factory_ == nullptr);
     QUICHE_DCHECK(stream_factory_ == nullptr);
     stream_factory_ = factory;
   }
 
   void SetCryptoStreamFactory(QuicTestServer::CryptoStreamFactory* factory) {
-    QuicWriterMutexLock lock(&factory_lock_);
+    quiche::QuicheWriterMutexLock lock(&factory_lock_);
     QUICHE_DCHECK(session_factory_ == nullptr);
     QUICHE_DCHECK(crypto_stream_factory_ == nullptr);
     crypto_stream_factory_ = factory;
   }
 
  private:
-  QuicMutex factory_lock_;
+  quiche::QuicheMutex factory_lock_;
   QuicTestServer::SessionFactory* session_factory_;             // Not owned.
   QuicTestServer::StreamFactory* stream_factory_;               // Not owned.
   QuicTestServer::CryptoStreamFactory* crypto_stream_factory_;  // Not owned.
diff --git a/quiche/quic/test_tools/quic_test_utils.h b/quiche/quic/test_tools/quic_test_utils.h
index d0d98ab..1e59e0a 100644
--- a/quiche/quic/test_tools/quic_test_utils.h
+++ b/quiche/quic/test_tools/quic_test_utils.h
@@ -38,7 +38,6 @@
 #include "quiche/quic/core/quic_time.h"
 #include "quiche/quic/core/quic_types.h"
 #include "quiche/quic/core/quic_utils.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/platform/api/quic_socket_address.h"
 #include "quiche/quic/test_tools/mock_clock.h"
 #include "quiche/quic/test_tools/mock_connection_id_generator.h"
@@ -2078,7 +2077,7 @@
                           const QuicSocketAddress& peer_address,
                           PerPacketOptions* options,
                           const QuicPacketWriterParams& params) override {
-    QuicReaderMutexLock lock(&mutex_);
+    quiche::QuicheReaderMutexLock lock(&mutex_);
     QUIC_LOG(ERROR) << "DroppingPacketsWithSpecificDestinationWriter::"
                        "WritePacket with peer address "
                     << peer_address.ToString() << " and peer_address_to_drop_ "
@@ -2094,12 +2093,12 @@
   }
 
   void set_peer_address_to_drop(const QuicSocketAddress& peer_address) {
-    QuicWriterMutexLock lock(&mutex_);
+    quiche::QuicheWriterMutexLock lock(&mutex_);
     peer_address_to_drop_ = peer_address;
   }
 
  private:
-  QuicMutex mutex_;
+  quiche::QuicheMutex mutex_;
   QuicSocketAddress peer_address_to_drop_ ABSL_GUARDED_BY(mutex_);
 };
 
diff --git a/quiche/quic/test_tools/server_thread.cc b/quiche/quic/test_tools/server_thread.cc
index 9c561e4..dfa1098 100644
--- a/quiche/quic/test_tools/server_thread.cc
+++ b/quiche/quic/test_tools/server_thread.cc
@@ -12,6 +12,7 @@
 #include "quiche/quic/test_tools/crypto_test_utils.h"
 #include "quiche/quic/test_tools/quic_dispatcher_peer.h"
 #include "quiche/quic/test_tools/quic_server_peer.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 #include "quiche/common/quiche_callbacks.h"
 
 namespace quic {
@@ -36,7 +37,7 @@
     return;
   }
 
-  QuicWriterMutexLock lock(&port_lock_);
+  quiche::QuicheWriterMutexLock lock(&port_lock_);
   port_ = server_->port();
 
   initialized_ = true;
@@ -61,20 +62,20 @@
 }
 
 int ServerThread::GetPort() {
-  QuicReaderMutexLock lock(&port_lock_);
+  quiche::QuicheReaderMutexLock lock(&port_lock_);
   int rc = port_;
   return rc;
 }
 
 void ServerThread::Schedule(quiche::SingleUseCallback<void()> action) {
   QUICHE_DCHECK(!quit_.HasBeenNotified());
-  QuicWriterMutexLock lock(&scheduled_actions_lock_);
+  quiche::QuicheWriterMutexLock lock(&scheduled_actions_lock_);
   scheduled_actions_.push_back(std::move(action));
 }
 
 void ServerThread::ScheduleAndWaitForCompletion(
     quiche::SingleUseCallback<void()> action) {
-  QuicNotification action_done;
+  quiche::QuicheNotification action_done;
   Schedule([&] {
     std::move(action)();
     action_done.Notify();
@@ -91,7 +92,7 @@
     QuicTime::Delta timeout) {
   const QuicTime deadline = clock_->Now() + timeout;
   while (clock_->Now() < deadline) {
-    QuicNotification done_checking;
+    quiche::QuicheNotification done_checking;
     bool should_terminate = false;
     Schedule([&] {
       should_terminate = termination_predicate();
@@ -145,7 +146,7 @@
 void ServerThread::ExecuteScheduledActions() {
   quiche::QuicheCircularDeque<quiche::SingleUseCallback<void()>> actions;
   {
-    QuicWriterMutexLock lock(&scheduled_actions_lock_);
+    quiche::QuicheWriterMutexLock lock(&scheduled_actions_lock_);
     actions.swap(scheduled_actions_);
   }
   while (!actions.empty()) {
diff --git a/quiche/quic/test_tools/server_thread.h b/quiche/quic/test_tools/server_thread.h
index 9547934..b3d0f8d 100644
--- a/quiche/quic/test_tools/server_thread.h
+++ b/quiche/quic/test_tools/server_thread.h
@@ -8,10 +8,10 @@
 #include <memory>
 
 #include "quiche/quic/core/quic_config.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/platform/api/quic_socket_address.h"
 #include "quiche/quic/platform/api/quic_thread.h"
 #include "quiche/quic/tools/quic_server.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 #include "quiche/common/quiche_callbacks.h"
 
 namespace quic {
@@ -74,24 +74,25 @@
   void MaybeNotifyOfHandshakeConfirmation();
   void ExecuteScheduledActions();
 
-  QuicNotification
-      confirmed_;            // Notified when the first handshake is confirmed.
-  QuicNotification pause_;   // Notified when the server should pause.
-  QuicNotification paused_;  // Notitied when the server has paused
-  QuicNotification resume_;  // Notified when the server should resume.
-  QuicNotification quit_;    // Notified when the server should quit.
+  quiche::QuicheNotification
+      confirmed_;  // Notified when the first handshake is confirmed.
+  quiche::QuicheNotification pause_;   // Notified when the server should pause.
+  quiche::QuicheNotification paused_;  // Notitied when the server has paused
+  quiche::QuicheNotification
+      resume_;                       // Notified when the server should resume.
+  quiche::QuicheNotification quit_;  // Notified when the server should quit.
 
   std::unique_ptr<QuicServer> server_;
   QuicClock* clock_;
   QuicSocketAddress address_;
-  mutable QuicMutex port_lock_;
-  int port_ QUIC_GUARDED_BY(port_lock_);
+  mutable quiche::QuicheMutex port_lock_;
+  int port_ QUICHE_GUARDED_BY(port_lock_);
 
   bool initialized_;
 
-  QuicMutex scheduled_actions_lock_;
+  quiche::QuicheMutex scheduled_actions_lock_;
   quiche::QuicheCircularDeque<quiche::SingleUseCallback<void()>>
-      scheduled_actions_ QUIC_GUARDED_BY(scheduled_actions_lock_);
+      scheduled_actions_ QUICHE_GUARDED_BY(scheduled_actions_lock_);
 };
 
 }  // namespace test
diff --git a/quiche/quic/tools/quic_memory_cache_backend.cc b/quiche/quic/tools/quic_memory_cache_backend.cc
index 2993384..22e51f7 100644
--- a/quiche/quic/tools/quic_memory_cache_backend.cc
+++ b/quiche/quic/tools/quic_memory_cache_backend.cc
@@ -130,7 +130,7 @@
 
 const QuicBackendResponse* QuicMemoryCacheBackend::GetResponse(
     absl::string_view host, absl::string_view path) const {
-  QuicWriterMutexLock lock(&response_mutex_);
+  quiche::QuicheWriterMutexLock lock(&response_mutex_);
 
   auto it = responses_.find(GetKey(host, path));
   if (it == responses_.end()) {
@@ -166,7 +166,7 @@
 }
 
 void QuicMemoryCacheBackend::AddDefaultResponse(QuicBackendResponse* response) {
-  QuicWriterMutexLock lock(&response_mutex_);
+  quiche::QuicheWriterMutexLock lock(&response_mutex_);
   default_response_.reset(response);
 }
 
@@ -193,7 +193,7 @@
 bool QuicMemoryCacheBackend::SetResponseDelay(absl::string_view host,
                                               absl::string_view path,
                                               QuicTime::Delta delay) {
-  QuicWriterMutexLock lock(&response_mutex_);
+  quiche::QuicheWriterMutexLock lock(&response_mutex_);
   auto it = responses_.find(GetKey(host, path));
   if (it == responses_.end()) return false;
 
@@ -271,7 +271,7 @@
 }
 
 void QuicMemoryCacheBackend::GenerateDynamicResponses() {
-  QuicWriterMutexLock lock(&response_mutex_);
+  quiche::QuicheWriterMutexLock lock(&response_mutex_);
   // Add a generate bytes response.
   quiche::HttpHeaderBlock response_headers;
   response_headers[":status"] = "200";
@@ -348,7 +348,7 @@
 
 QuicMemoryCacheBackend::~QuicMemoryCacheBackend() {
   {
-    QuicWriterMutexLock lock(&response_mutex_);
+    quiche::QuicheWriterMutexLock lock(&response_mutex_);
     responses_.clear();
   }
 }
@@ -358,7 +358,7 @@
     SpecialResponseType response_type, HttpHeaderBlock response_headers,
     absl::string_view response_body, HttpHeaderBlock response_trailers,
     const std::vector<quiche::HttpHeaderBlock>& early_hints) {
-  QuicWriterMutexLock lock(&response_mutex_);
+  quiche::QuicheWriterMutexLock lock(&response_mutex_);
 
   QUICHE_DCHECK(!host.empty())
       << "Host must be populated, e.g. \"www.google.com\"";
diff --git a/quiche/quic/tools/quic_memory_cache_backend.h b/quiche/quic/tools/quic_memory_cache_backend.h
index ed47d1d..84456a8 100644
--- a/quiche/quic/tools/quic_memory_cache_backend.h
+++ b/quiche/quic/tools/quic_memory_cache_backend.h
@@ -13,10 +13,10 @@
 #include "absl/container/flat_hash_map.h"
 #include "absl/strings/string_view.h"
 #include "quiche/quic/core/http/spdy_utils.h"
-#include "quiche/quic/platform/api/quic_mutex.h"
 #include "quiche/quic/tools/quic_backend_response.h"
 #include "quiche/quic/tools/quic_simple_server_backend.h"
 #include "quiche/common/http/http_header_block.h"
+#include "quiche/common/platform/api/quiche_mutex.h"
 #include "quiche/spdy/core/spdy_framer.h"
 
 namespace quic {
@@ -153,19 +153,19 @@
 
   // Cached responses.
   absl::flat_hash_map<std::string, std::unique_ptr<QuicBackendResponse>>
-      responses_ QUIC_GUARDED_BY(response_mutex_);
+      responses_ QUICHE_GUARDED_BY(response_mutex_);
 
   // The default response for cache misses, if set.
   std::unique_ptr<QuicBackendResponse> default_response_
-      QUIC_GUARDED_BY(response_mutex_);
+      QUICHE_GUARDED_BY(response_mutex_);
 
   // The generate bytes response, if set.
   std::unique_ptr<QuicBackendResponse> generate_bytes_response_
-      QUIC_GUARDED_BY(response_mutex_);
+      QUICHE_GUARDED_BY(response_mutex_);
 
   // Protects against concurrent access from test threads setting responses, and
   // server threads accessing those responses.
-  mutable QuicMutex response_mutex_;
+  mutable quiche::QuicheMutex response_mutex_;
   bool cache_initialized_;
 
   bool enable_webtransport_ = false;