Platformize DCHECK and other macros.

PiperOrigin-RevId: 354720441
Change-Id: I6db498ac96b025432d5bfb3da0a4deeef57c114f
diff --git a/common/platform/api/quiche_logging.h b/common/platform/api/quiche_logging.h
index 46c4549..6a3e43c 100644
--- a/common/platform/api/quiche_logging.h
+++ b/common/platform/api/quiche_logging.h
@@ -39,4 +39,20 @@
 #define QUICHE_LOG_WARNING_IS_ON() QUICHE_LOG_WARNING_IS_ON_IMPL()
 #define QUICHE_LOG_ERROR_IS_ON() QUICHE_LOG_ERROR_IS_ON_IMPL()
 
+#define QUICHE_CHECK(condition) QUICHE_CHECK_IMPL(condition)
+#define QUICHE_CHECK_EQ(val1, val2) QUICHE_CHECK_EQ_IMPL(val1, val2)
+#define QUICHE_CHECK_NE(val1, val2) QUICHE_CHECK_NE_IMPL(val1, val2)
+#define QUICHE_CHECK_LE(val1, val2) QUICHE_CHECK_LE_IMPL(val1, val2)
+#define QUICHE_CHECK_LT(val1, val2) QUICHE_CHECK_LT_IMPL(val1, val2)
+#define QUICHE_CHECK_GE(val1, val2) QUICHE_CHECK_GE_IMPL(val1, val2)
+#define QUICHE_CHECK_GT(val1, val2) QUICHE_CHECK_GT_IMPL(val1, val2)
+
+#define QUICHE_DCHECK(condition) QUICHE_DCHECK_IMPL(condition)
+#define QUICHE_DCHECK_EQ(val1, val2) QUICHE_DCHECK_EQ_IMPL(val1, val2)
+#define QUICHE_DCHECK_NE(val1, val2) QUICHE_DCHECK_NE_IMPL(val1, val2)
+#define QUICHE_DCHECK_LE(val1, val2) QUICHE_DCHECK_LE_IMPL(val1, val2)
+#define QUICHE_DCHECK_LT(val1, val2) QUICHE_DCHECK_LT_IMPL(val1, val2)
+#define QUICHE_DCHECK_GE(val1, val2) QUICHE_DCHECK_GE_IMPL(val1, val2)
+#define QUICHE_DCHECK_GT(val1, val2) QUICHE_DCHECK_GT_IMPL(val1, val2)
+
 #endif  // QUICHE_COMMON_PLATFORM_API_QUICHE_LOGGING_H_
diff --git a/quic/core/batch_writer/quic_batch_writer_base.h b/quic/core/batch_writer/quic_batch_writer_base.h
index 88ce517..ff924d0 100644
--- a/quic/core/batch_writer/quic_batch_writer_base.h
+++ b/quic/core/batch_writer/quic_batch_writer_base.h
@@ -75,7 +75,8 @@
   };
   virtual ReleaseTime GetReleaseTime(
       const PerPacketOptions* /*options*/) const {
-    DCHECK(false) << "Should not be called since release time is unsupported.";
+    QUICHE_DCHECK(false)
+        << "Should not be called since release time is unsupported.";
     return ReleaseTime{0, QuicTime::Delta::Zero()};
   }
 
diff --git a/quic/core/batch_writer/quic_batch_writer_test.h b/quic/core/batch_writer/quic_batch_writer_test.h
index 585328c..820100a 100644
--- a/quic/core/batch_writer/quic_batch_writer_test.h
+++ b/quic/core/batch_writer/quic_batch_writer_test.h
@@ -45,7 +45,7 @@
   if (family == AF_INET) {
     *address = QuicSocketAddress(QuicIpAddress::Loopback4(), 0);
   } else {
-    DCHECK_EQ(family, AF_INET6);
+    QUICHE_DCHECK_EQ(family, AF_INET6);
     *address = QuicSocketAddress(QuicIpAddress::Loopback6(), 0);
   }
 
diff --git a/quic/core/batch_writer/quic_gso_batch_writer.h b/quic/core/batch_writer/quic_gso_batch_writer.h
index 9efdc5d..75683d1 100644
--- a/quic/core/batch_writer/quic_gso_batch_writer.h
+++ b/quic/core/batch_writer/quic_gso_batch_writer.h
@@ -61,8 +61,8 @@
 
   template <size_t CmsgSpace, typename CmsgBuilderT>
   FlushImplResult InternalFlushImpl(CmsgBuilderT cmsg_builder) {
-    DCHECK(!IsWriteBlocked());
-    DCHECK(!buffered_writes().empty());
+    QUICHE_DCHECK(!IsWriteBlocked());
+    QUICHE_DCHECK(!buffered_writes().empty());
 
     FlushImplResult result = {WriteResult(WRITE_STATUS_OK, 0),
                               /*num_packets_sent=*/0, /*bytes_written=*/0};
diff --git a/quic/core/congestion_control/bandwidth_sampler.h b/quic/core/congestion_control/bandwidth_sampler.h
index 5e4fe94..7a34097 100644
--- a/quic/core/congestion_control/bandwidth_sampler.h
+++ b/quic/core/congestion_control/bandwidth_sampler.h
@@ -369,7 +369,7 @@
   class QUIC_NO_EXPORT RecentAckPoints {
    public:
     void Update(QuicTime ack_time, QuicByteCount total_bytes_acked) {
-      DCHECK_GE(total_bytes_acked, ack_points_[1].total_bytes_acked);
+      QUICHE_DCHECK_GE(total_bytes_acked, ack_points_[1].total_bytes_acked);
 
       if (ack_time < ack_points_[1].ack_time) {
         // This can only happen when time goes backwards, we use the smaller
diff --git a/quic/core/congestion_control/bbr2_misc.h b/quic/core/congestion_control/bbr2_misc.h
index dc7367b..8b53c1b 100644
--- a/quic/core/congestion_control/bbr2_misc.h
+++ b/quic/core/congestion_control/bbr2_misc.h
@@ -623,7 +623,7 @@
 
 QUIC_EXPORT_PRIVATE inline QuicByteCount BytesInFlight(
     const SendTimeState& send_state) {
-  DCHECK(send_state.is_valid);
+  QUICHE_DCHECK(send_state.is_valid);
   if (send_state.bytes_in_flight != 0) {
     return send_state.bytes_in_flight;
   }
diff --git a/quic/core/congestion_control/bbr2_sender.h b/quic/core/congestion_control/bbr2_sender.h
index e97fa05..a0b5199 100644
--- a/quic/core/congestion_control/bbr2_sender.h
+++ b/quic/core/congestion_control/bbr2_sender.h
@@ -147,12 +147,12 @@
 
   // Helper function for BBR2_MODE_DISPATCH.
   Bbr2ProbeRttMode& probe_rtt_or_die() {
-    DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT);
+    QUICHE_DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT);
     return probe_rtt_;
   }
 
   const Bbr2ProbeRttMode& probe_rtt_or_die() const {
-    DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT);
+    QUICHE_DCHECK_EQ(mode_, Bbr2Mode::PROBE_RTT);
     return probe_rtt_;
   }
 
diff --git a/quic/core/congestion_control/bbr2_startup.h b/quic/core/congestion_control/bbr2_startup.h
index 226c6e7..a05bac2 100644
--- a/quic/core/congestion_control/bbr2_startup.h
+++ b/quic/core/congestion_control/bbr2_startup.h
@@ -34,7 +34,8 @@
 
   Limits<QuicByteCount> GetCwndLimits() const override {
     // Inflight_lo is never set in STARTUP.
-    DCHECK_EQ(Bbr2NetworkModel::inflight_lo_default(), model_->inflight_lo());
+    QUICHE_DCHECK_EQ(Bbr2NetworkModel::inflight_lo_default(),
+                     model_->inflight_lo());
     return NoGreaterThan(model_->inflight_lo());
   }
 
diff --git a/quic/core/congestion_control/bbr_sender.h b/quic/core/congestion_control/bbr_sender.h
index 799b235..c1dbd22 100644
--- a/quic/core/congestion_control/bbr_sender.h
+++ b/quic/core/congestion_control/bbr_sender.h
@@ -143,7 +143,7 @@
 
   // Sets the pacing gain used in STARTUP.  Must be greater than 1.
   void set_high_gain(float high_gain) {
-    DCHECK_LT(1.0f, high_gain);
+    QUICHE_DCHECK_LT(1.0f, high_gain);
     high_gain_ = high_gain;
     if (mode_ == STARTUP) {
       pacing_gain_ = high_gain;
@@ -152,7 +152,7 @@
 
   // Sets the CWND gain used in STARTUP.  Must be greater than 1.
   void set_high_cwnd_gain(float high_cwnd_gain) {
-    DCHECK_LT(1.0f, high_cwnd_gain);
+    QUICHE_DCHECK_LT(1.0f, high_cwnd_gain);
     high_cwnd_gain_ = high_cwnd_gain;
     if (mode_ == STARTUP) {
       congestion_window_gain_ = high_cwnd_gain;
@@ -161,7 +161,7 @@
 
   // Sets the gain used in DRAIN.  Must be less than 1.
   void set_drain_gain(float drain_gain) {
-    DCHECK_GT(1.0f, drain_gain);
+    QUICHE_DCHECK_GT(1.0f, drain_gain);
     drain_gain_ = drain_gain;
   }
 
diff --git a/quic/core/congestion_control/general_loss_algorithm.h b/quic/core/congestion_control/general_loss_algorithm.h
index 491c474..6a3c5dd 100644
--- a/quic/core/congestion_control/general_loss_algorithm.h
+++ b/quic/core/congestion_control/general_loss_algorithm.h
@@ -49,27 +49,27 @@
                             QuicPacketNumber previous_largest_acked) override;
 
   void OnConfigNegotiated() override {
-    DCHECK(false)
+    QUICHE_DCHECK(false)
         << "Unexpected call to GeneralLossAlgorithm::OnConfigNegotiated";
   }
 
   void OnMinRttAvailable() override {
-    DCHECK(false)
+    QUICHE_DCHECK(false)
         << "Unexpected call to GeneralLossAlgorithm::OnMinRttAvailable";
   }
 
   void OnUserAgentIdKnown() override {
-    DCHECK(false)
+    QUICHE_DCHECK(false)
         << "Unexpected call to GeneralLossAlgorithm::OnUserAgentIdKnown";
   }
 
   void OnConnectionClosed() override {
-    DCHECK(false)
+    QUICHE_DCHECK(false)
         << "Unexpected call to GeneralLossAlgorithm::OnConnectionClosed";
   }
 
   void OnReorderingDetected() override {
-    DCHECK(false)
+    QUICHE_DCHECK(false)
         << "Unexpected call to GeneralLossAlgorithm::OnReorderingDetected";
   }
 
diff --git a/quic/core/crypto/crypto_utils.h b/quic/core/crypto/crypto_utils.h
index 088ec28..ec68c65 100644
--- a/quic/core/crypto/crypto_utils.h
+++ b/quic/core/crypto/crypto_utils.h
@@ -62,7 +62,7 @@
 
     Mode mode() const { return mode_; }
     DiversificationNonce* nonce() const {
-      DCHECK_EQ(mode_, NOW);
+      QUICHE_DCHECK_EQ(mode_, NOW);
       return nonce_;
     }
 
diff --git a/quic/core/frames/quic_ack_frame.h b/quic/core/frames/quic_ack_frame.h
index 62a1ee3..8a5c7e6 100644
--- a/quic/core/frames/quic_ack_frame.h
+++ b/quic/core/frames/quic_ack_frame.h
@@ -128,7 +128,8 @@
 // have been observed, return 0.
 inline QUIC_EXPORT_PRIVATE QuicPacketNumber
 LargestAcked(const QuicAckFrame& frame) {
-  DCHECK(frame.packets.Empty() || frame.packets.Max() == frame.largest_acked);
+  QUICHE_DCHECK(frame.packets.Empty() ||
+                frame.packets.Max() == frame.largest_acked);
   return frame.largest_acked;
 }
 
diff --git a/quic/core/packet_number_indexed_queue.h b/quic/core/packet_number_indexed_queue.h
index 66174ac..eec75df 100644
--- a/quic/core/packet_number_indexed_queue.h
+++ b/quic/core/packet_number_indexed_queue.h
@@ -152,8 +152,8 @@
   }
 
   if (IsEmpty()) {
-    DCHECK(entries_.empty());
-    DCHECK(!first_packet_.IsInitialized());
+    QUICHE_DCHECK(entries_.empty());
+    QUICHE_DCHECK(!first_packet_.IsInitialized());
 
     entries_.emplace_back(std::forward<Args>(args)...);
     number_of_present_entries_ = 1;
@@ -174,7 +174,7 @@
 
   number_of_present_entries_++;
   entries_.emplace_back(std::forward<Args>(args)...);
-  DCHECK_EQ(packet_number, last_packet());
+  QUICHE_DCHECK_EQ(packet_number, last_packet());
   return true;
 }
 
diff --git a/quic/core/qpack/qpack_decoded_headers_accumulator.h b/quic/core/qpack/qpack_decoded_headers_accumulator.h
index 3c41aec..b22da2a 100644
--- a/quic/core/qpack/qpack_decoded_headers_accumulator.h
+++ b/quic/core/qpack/qpack_decoded_headers_accumulator.h
@@ -90,7 +90,7 @@
   // Input data is still fed to QpackProgressiveDecoder.
   bool header_list_size_limit_exceeded_;
 
-  // The following two members are only used for DCHECKs.
+  // The following two members are only used for QUICHE_DCHECKs.
 
   // True if headers have been completedly and successfully decoded.
   bool headers_decoded_;
diff --git a/quic/core/qpack/qpack_instruction_decoder.h b/quic/core/qpack/qpack_instruction_decoder.h
index 224146b..fc9b96e 100644
--- a/quic/core/qpack/qpack_instruction_decoder.h
+++ b/quic/core/qpack/qpack_instruction_decoder.h
@@ -143,7 +143,7 @@
   http2::HpackHuffmanDecoder huffman_decoder_;
 
   // True if a decoding error has been detected by QpackInstructionDecoder.
-  // Only used in DCHECKs.
+  // Only used in QUICHE_DCHECKs.
   bool error_detected_;
 
   // Decoding state.
diff --git a/quic/core/quic_arena_scoped_ptr.h b/quic/core/quic_arena_scoped_ptr.h
index bd7392d..19b89a3 100644
--- a/quic/core/quic_arena_scoped_ptr.h
+++ b/quic/core/quic_arena_scoped_ptr.h
@@ -185,14 +185,14 @@
       delete get();
     }
   }
-  DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value) & kFromArenaMask);
+  QUICHE_DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value) & kFromArenaMask);
   value_ = value;
 }
 
 template <typename T>
 QuicArenaScopedPtr<T>::QuicArenaScopedPtr(void* value, ConstructFrom from_arena)
     : value_(value) {
-  DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value_) & kFromArenaMask);
+  QUICHE_DCHECK_EQ(0u, reinterpret_cast<uintptr_t>(value_) & kFromArenaMask);
   switch (from_arena) {
     case ConstructFrom::kHeap:
       break;
diff --git a/quic/core/quic_circular_deque.h b/quic/core/quic_circular_deque.h
index 984b5a0..44637ab 100644
--- a/quic/core/quic_circular_deque.h
+++ b/quic/core/quic_circular_deque.h
@@ -163,23 +163,23 @@
         : deque_(deque), index_(index) {}
 
     void Increment() {
-      DCHECK_LE(ExternalPosition() + 1, deque_->size());
+      QUICHE_DCHECK_LE(ExternalPosition() + 1, deque_->size());
       index_ = deque_->index_next(index_);
     }
 
     void Decrement() {
-      DCHECK_GE(ExternalPosition(), 1u);
+      QUICHE_DCHECK_GE(ExternalPosition(), 1u);
       index_ = deque_->index_prev(index_);
     }
 
     void IncrementBy(difference_type delta) {
       if (delta >= 0) {
         // After increment we are before or at end().
-        DCHECK_LE(static_cast<size_type>(ExternalPosition() + delta),
-                  deque_->size());
+        QUICHE_DCHECK_LE(static_cast<size_type>(ExternalPosition() + delta),
+                         deque_->size());
       } else {
         // After decrement we are after or at begin().
-        DCHECK_GE(ExternalPosition(), static_cast<size_type>(-delta));
+        QUICHE_DCHECK_GE(ExternalPosition(), static_cast<size_type>(-delta));
       }
       index_ = deque_->index_increment_by(index_, delta);
     }
@@ -324,7 +324,7 @@
   }
 
   reference at(size_type pos) {
-    DCHECK(pos < size()) << "pos:" << pos << ", size():" << size();
+    QUICHE_DCHECK(pos < size()) << "pos:" << pos << ", size():" << size();
     size_type index = begin_ + pos;
     if (index < data_capacity()) {
       return *index_to_address(index);
@@ -341,7 +341,7 @@
   const_reference operator[](size_type pos) const { return at(pos); }
 
   reference front() {
-    DCHECK(!empty());
+    QUICHE_DCHECK(!empty());
     return *index_to_address(begin_);
   }
 
@@ -350,7 +350,7 @@
   }
 
   reference back() {
-    DCHECK(!empty());
+    QUICHE_DCHECK(!empty());
     return *(index_to_address(end_ == 0 ? data_capacity() - 1 : end_ - 1));
   }
 
@@ -429,7 +429,7 @@
   }
 
   void pop_front() {
-    DCHECK(!empty());
+    QUICHE_DCHECK(!empty());
     DestroyByIndex(begin_);
     begin_ = index_next(begin_);
     MaybeShrinkCapacity();
@@ -445,7 +445,7 @@
   }
 
   void pop_back() {
-    DCHECK(!empty());
+    QUICHE_DCHECK(!empty());
     end_ = index_prev(end_);
     DestroyByIndex(end_);
     MaybeShrinkCapacity();
@@ -471,7 +471,7 @@
       // When propagate_on_container_swap is false, it is undefined behavior, by
       // c++ standard, to swap between two AllocatorAwareContainer(s) with
       // unequal allocators.
-      DCHECK(get_allocator() == other.get_allocator())
+      QUICHE_DCHECK(get_allocator() == other.get_allocator())
           << "Undefined swap behavior";
       swap(allocator_and_data_.data, other.allocator_and_data_.data);
       swap(allocator_and_data_.data_capacity,
@@ -558,7 +558,7 @@
     DestroyRange(begin_, end_);
 
     if (data_capacity() > 0) {
-      DCHECK_NE(nullptr, allocator_and_data_.data);
+      QUICHE_DCHECK_NE(nullptr, allocator_and_data_.data);
       AllocatorTraits::deallocate(allocator_and_data_.allocator(),
                                   allocator_and_data_.data, data_capacity());
     }
@@ -590,7 +590,7 @@
 
   void Relocate(size_t new_capacity) {
     const size_t num_elements = size();
-    DCHECK_GT(new_capacity, num_elements)
+    QUICHE_DCHECK_GT(new_capacity, num_elements)
         << "new_capacity:" << new_capacity << ", num_elements:" << num_elements;
 
     size_t new_data_capacity = new_capacity + 1;
@@ -621,9 +621,9 @@
   template <typename T_ = T>
   typename std::enable_if<std::is_trivially_copyable<T_>::value, void>::type
   RelocateUnwrappedRange(size_type begin, size_type end, pointer dest) const {
-    DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
+    QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
     pointer src = index_to_address(begin);
-    DCHECK_NE(src, nullptr);
+    QUICHE_DCHECK_NE(src, nullptr);
     memcpy(dest, src, sizeof(T) * (end - begin));
     DestroyRange(begin, end);
   }
@@ -633,7 +633,7 @@
                               std::is_move_constructible<T_>::value,
                           void>::type
   RelocateUnwrappedRange(size_type begin, size_type end, pointer dest) const {
-    DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
+    QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
     pointer src = index_to_address(begin);
     pointer src_end = index_to_address(end);
     while (src != src_end) {
@@ -649,7 +649,7 @@
                               !std::is_move_constructible<T_>::value,
                           void>::type
   RelocateUnwrappedRange(size_type begin, size_type end, pointer dest) const {
-    DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
+    QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
     pointer src = index_to_address(begin);
     pointer src_end = index_to_address(end);
     while (src != src_end) {
@@ -692,7 +692,7 @@
 
   // Should only be called from DestroyRange.
   void DestroyUnwrappedRange(size_type begin, size_type end) const {
-    DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
+    QUICHE_DCHECK_LE(begin, end) << "begin:" << begin << ", end:" << end;
     for (; begin != end; ++begin) {
       DestroyByIndex(begin);
     }
@@ -728,7 +728,7 @@
       return index;
     }
 
-    DCHECK_LT(static_cast<size_type>(std::abs(delta)), data_capacity());
+    QUICHE_DCHECK_LT(static_cast<size_type>(std::abs(delta)), data_capacity());
     return (index + data_capacity() + delta) % data_capacity();
   }
 
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index f368bc4..3fbb0c2 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -583,7 +583,7 @@
 
   // Set the packet writer.
   void SetQuicPacketWriter(QuicPacketWriter* writer, bool owns_writer) {
-    DCHECK(writer != nullptr);
+    QUICHE_DCHECK(writer != nullptr);
     if (writer_ != nullptr && owns_writer_) {
       delete writer_;
     }
@@ -719,7 +719,7 @@
   // Used in Chromium, but not internally.
   // Must only be called before ping_alarm_ is set.
   void set_ping_timeout(QuicTime::Delta ping_timeout) {
-    DCHECK(!ping_alarm_->IsSet());
+    QUICHE_DCHECK(!ping_alarm_->IsSet());
     ping_timeout_ = ping_timeout;
   }
   const QuicTime::Delta ping_timeout() const { return ping_timeout_; }
@@ -727,7 +727,7 @@
   // data in flight, allowing for a more aggressive ping alarm in that case.
   void set_initial_retransmittable_on_wire_timeout(
       QuicTime::Delta retransmittable_on_wire_timeout) {
-    DCHECK(!ping_alarm_->IsSet());
+    QUICHE_DCHECK(!ping_alarm_->IsSet());
     initial_retransmittable_on_wire_timeout_ = retransmittable_on_wire_timeout;
   }
   const QuicTime::Delta initial_retransmittable_on_wire_timeout() const {
@@ -758,7 +758,7 @@
 
   // Must only be called on client connections.
   const ParsedQuicVersionVector& server_supported_versions() const {
-    DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
+    QUICHE_DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
     return server_supported_versions_;
   }
 
@@ -810,10 +810,10 @@
   void SetDefaultEncryptionLevel(EncryptionLevel level);
 
   // SetDecrypter sets the primary decrypter, replacing any that already exists.
-  // If an alternative decrypter is in place then the function DCHECKs. This is
-  // intended for cases where one knows that future packets will be using the
-  // new decrypter and the previous decrypter is now obsolete. |level| indicates
-  // the encryption level of the new decrypter.
+  // If an alternative decrypter is in place then the function QUICHE_DCHECKs.
+  // This is intended for cases where one knows that future packets will be
+  // using the new decrypter and the previous decrypter is now obsolete. |level|
+  // indicates the encryption level of the new decrypter.
   void SetDecrypter(EncryptionLevel level,
                     std::unique_ptr<QuicDecrypter> decrypter);
 
diff --git a/quic/core/quic_flow_controller.h b/quic/core/quic_flow_controller.h
index 5638bd4..7266a9e 100644
--- a/quic/core/quic_flow_controller.h
+++ b/quic/core/quic_flow_controller.h
@@ -100,7 +100,7 @@
   }
 
   void set_receive_window_size_limit(QuicByteCount receive_window_size_limit) {
-    DCHECK_GE(receive_window_size_limit, receive_window_size_limit_);
+    QUICHE_DCHECK_GE(receive_window_size_limit, receive_window_size_limit_);
     receive_window_size_limit_ = receive_window_size_limit;
   }
 
diff --git a/quic/core/quic_framer.h b/quic/core/quic_framer.h
index d9c48d1..571278d 100644
--- a/quic/core/quic_framer.h
+++ b/quic/core/quic_framer.h
@@ -299,8 +299,8 @@
 
   void set_version(const ParsedQuicVersion version);
 
-  // Does not DCHECK for supported version. Used by tests to set unsupported
-  // version to trigger version negotiation.
+  // Does not QUICHE_DCHECK for supported version. Used by tests to set
+  // unsupported version to trigger version negotiation.
   void set_version_for_tests(const ParsedQuicVersion version) {
     version_ = version;
   }
@@ -520,10 +520,10 @@
                                QuicDataWriter* writer);
 
   // SetDecrypter sets the primary decrypter, replacing any that already exists.
-  // If an alternative decrypter is in place then the function DCHECKs. This is
-  // intended for cases where one knows that future packets will be using the
-  // new decrypter and the previous decrypter is now obsolete. |level| indicates
-  // the encryption level of the new decrypter.
+  // If an alternative decrypter is in place then the function QUICHE_DCHECKs.
+  // This is intended for cases where one knows that future packets will be
+  // using the new decrypter and the previous decrypter is now obsolete. |level|
+  // indicates the encryption level of the new decrypter.
   void SetDecrypter(EncryptionLevel level,
                     std::unique_ptr<QuicDecrypter> decrypter);
 
diff --git a/quic/core/quic_interval_deque.h b/quic/core/quic_interval_deque.h
index 0218ff2..d4e82e2 100644
--- a/quic/core/quic_interval_deque.h
+++ b/quic/core/quic_interval_deque.h
@@ -198,12 +198,12 @@
     Iterator operator+(difference_type amount) const {
       Iterator copy = *this;
       copy.index_ += amount;
-      DCHECK(copy.index_ < copy.deque_->size());
+      QUICHE_DCHECK(copy.index_ < copy.deque_->size());
       return copy;
     }
     Iterator& operator+=(difference_type amount) {
       index_ += amount;
-      DCHECK(index_ < deque_->size());
+      QUICHE_DCHECK(index_ < deque_->size());
       return *this;
     }
     difference_type operator-(const Iterator& rhs) const {
@@ -311,7 +311,7 @@
   }
 
   const std::size_t cached_index = cached_index_.value();
-  DCHECK(cached_index < container_.size());
+  QUICHE_DCHECK(cached_index < container_.size());
 
   const QuicInterval<size_t> cached_interval =
       container_[cached_index].interval();
diff --git a/quic/core/quic_interval_set.h b/quic/core/quic_interval_set.h
index 1dca773..e272b50 100644
--- a/quic/core/quic_interval_set.h
+++ b/quic/core/quic_interval_set.h
@@ -161,7 +161,7 @@
   // Remove the first interval.
   // REQUIRES: !Empty()
   void PopFront() {
-    DCHECK(!Empty());
+    QUICHE_DCHECK(!Empty());
     intervals_.erase(intervals_.begin());
   }
 
@@ -379,7 +379,7 @@
   // Returns true if this set is valid (i.e. all intervals in it are non-empty,
   // non-adjacent, and mutually disjoint). Currently this is used as an
   // integrity check by the Intersection() and Difference() methods, but is only
-  // invoked for debug builds (via DCHECK).
+  // invoked for debug builds (via QUICHE_DCHECK).
   bool Valid() const;
 
   // Finds the first interval that potentially intersects 'other'.
@@ -711,7 +711,7 @@
                                                       const_iterator* mine,
                                                       const_iterator* theirs,
                                                       Func on_hole) {
-  CHECK(x != nullptr);
+  QUICHE_CHECK(x != nullptr);
   if ((*mine == x->intervals_.end()) || (*theirs == y.intervals_.end())) {
     return false;
   }
@@ -767,15 +767,15 @@
            i.Intersects(*theirs, &intersection)) {
       std::pair<typename Set::iterator, bool> ins =
           intervals_.insert(intersection);
-      DCHECK(ins.second);
+      QUICHE_DCHECK(ins.second);
       mine = ins.first;
       ++theirs;
     }
-    DCHECK(mine != intervals_.end());
+    QUICHE_DCHECK(mine != intervals_.end());
     --theirs;
     ++mine;
   }
-  DCHECK(Valid());
+  QUICHE_DCHECK(Valid());
 }
 
 template <typename T>
@@ -833,16 +833,16 @@
     if (!lo.Empty()) {
       // We have a low end.  This can't intersect anything else.
       std::pair<typename Set::iterator, bool> ins = intervals_.insert(lo);
-      DCHECK(ins.second);
+      QUICHE_DCHECK(ins.second);
     }
 
     if (!hi.Empty()) {
       std::pair<typename Set::iterator, bool> ins = intervals_.insert(hi);
-      DCHECK(ins.second);
+      QUICHE_DCHECK(ins.second);
       mine = ins.first;
     }
   }
-  DCHECK(Valid());
+  QUICHE_DCHECK(Valid());
 }
 
 template <typename T>
@@ -893,7 +893,7 @@
       intervals_.erase(prev);
       intervals_.erase(it);
       std::pair<typename Set::iterator, bool> ins = intervals_.insert(i);
-      DCHECK(ins.second);
+      QUICHE_DCHECK(ins.second);
       prev = ins.first;
     } else {
       prev = it;
@@ -1055,7 +1055,7 @@
   // Remove the first interval.
   // REQUIRES: !Empty()
   void PopFront() {
-    DCHECK(!Empty());
+    QUICHE_DCHECK(!Empty());
     intervals_.erase(intervals_.begin());
   }
 
@@ -1282,7 +1282,7 @@
   // Returns true if this set is valid (i.e. all intervals in it are non-empty,
   // non-adjacent, and mutually disjoint). Currently this is used as an
   // integrity check by the Intersection() and Difference() methods, but is only
-  // invoked for debug builds (via DCHECK).
+  // invoked for debug builds (via QUICHE_DCHECK).
   bool Valid() const;
 
   // Finds the first interval that potentially intersects 'other'.
@@ -1548,7 +1548,7 @@
                                                       const_iterator* mine,
                                                       const_iterator* theirs,
                                                       Func on_hole) {
-  CHECK(x != nullptr);
+  QUICHE_CHECK(x != nullptr);
   if ((*mine == x->intervals_.end()) || (*theirs == y.intervals_.end())) {
     return false;
   }
@@ -1603,15 +1603,15 @@
     while (theirs != other.intervals_.end() &&
            i.Intersects(*theirs, &intersection)) {
       std::pair<const_iterator, bool> ins = intervals_.insert(intersection);
-      DCHECK(ins.second);
+      QUICHE_DCHECK(ins.second);
       mine = ins.first;
       ++theirs;
     }
-    DCHECK(mine != intervals_.end());
+    QUICHE_DCHECK(mine != intervals_.end());
     --theirs;
     ++mine;
   }
-  DCHECK(Valid());
+  QUICHE_DCHECK(Valid());
 }
 
 template <typename T>
@@ -1667,8 +1667,8 @@
     // Loop invariants:
     //   myinterval is nonempty.
     //   mine points at a range that is a suffix of myinterval.
-    DCHECK(!myinterval.Empty());
-    DCHECK(myinterval.max() == mine->max());
+    QUICHE_DCHECK(!myinterval.Empty());
+    QUICHE_DCHECK(myinterval.max() == mine->max());
 
     // There are 3 cases.
     //  myinterval is completely before theirs (treat theirs==end() as if it is
@@ -1705,7 +1705,7 @@
     }
   }
   std::swap(result, intervals_);
-  DCHECK(Valid());
+  QUICHE_DCHECK(Valid());
 }
 
 template <typename T>
diff --git a/quic/core/quic_linux_socket_utils.h b/quic/core/quic_linux_socket_utils.h
index 022fb46..14c26dc 100644
--- a/quic/core/quic_linux_socket_utils.h
+++ b/quic/core/quic_linux_socket_utils.h
@@ -174,7 +174,7 @@
                      BufferedWrite>::value,
         "Must iterate over a collection of BufferedWrite.");
 
-    DCHECK_LE(0, num_msgs_);
+    QUICHE_DCHECK_LE(0, num_msgs_);
     if (num_msgs_ == 0) {
       return;
     }
diff --git a/quic/core/quic_lru_cache.h b/quic/core/quic_lru_cache.h
index 9fcc50b..d4b11e0 100644
--- a/quic/core/quic_lru_cache.h
+++ b/quic/core/quic_lru_cache.h
@@ -11,6 +11,7 @@
 #include "quic/platform/api/quic_export.h"
 #include "quic/platform/api/quic_flag_utils.h"
 #include "quic/platform/api/quic_flags.h"
+#include "quic/platform/api/quic_logging.h"
 
 namespace quic {
 
@@ -37,7 +38,7 @@
     if (cache_.size() > capacity_) {
       cache_.pop_front();
     }
-    DCHECK_LE(cache_.size(), capacity_);
+    QUICHE_DCHECK_LE(cache_.size(), capacity_);
   }
 
   // If cache contains an entry for |key|, return a pointer to it. This returned
@@ -52,7 +53,7 @@
     std::unique_ptr<V> value = std::move(it->second);
     cache_.erase(it);
     auto result = cache_.emplace(key, std::move(value));
-    DCHECK(result.second);
+    QUICHE_DCHECK(result.second);
     return result.first->second.get();
   }
 
diff --git a/quic/core/quic_one_block_arena.h b/quic/core/quic_one_block_arena.h
index 9e9ba98..8311477 100644
--- a/quic/core/quic_one_block_arena.h
+++ b/quic/core/quic_one_block_arena.h
@@ -3,9 +3,9 @@
 // found in the LICENSE file.
 
 // An arena that consists of a single inlined block of |ArenaSize|. Useful to
-// avoid repeated calls to malloc/new and to improve memory locality. DCHECK's
-// if an allocation out of the arena ever fails in debug builds; falls back to
-// heap allocation in release builds.
+// avoid repeated calls to malloc/new and to improve memory locality.
+// QUICHE_DCHECK's if an allocation out of the arena ever fails in debug builds;
+// falls back to heap allocation in release builds.
 
 #ifndef QUICHE_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_
 #define QUICHE_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_
@@ -33,7 +33,7 @@
   // controlled by QuicArenaScopedPtr.
   template <typename T, typename... Args>
   QuicArenaScopedPtr<T> New(Args&&... args) {
-    DCHECK_LT(AlignedSize<T>(), ArenaSize)
+    QUICHE_DCHECK_LT(AlignedSize<T>(), ArenaSize)
         << "Object is too large for the arena.";
     static_assert(alignof(T) > 1,
                   "Objects added to the arena must be at least 2B aligned.");
diff --git a/quic/core/quic_packet_number.h b/quic/core/quic_packet_number.h
index 706b4db..a1ea62f 100644
--- a/quic/core/quic_packet_number.h
+++ b/quic/core/quic_packet_number.h
@@ -27,7 +27,7 @@
   // sentinel value.
   explicit constexpr QuicPacketNumber(uint64_t packet_number)
       : packet_number_(packet_number) {
-    DCHECK_NE(UninitializedPacketNumber(), packet_number)
+    QUICHE_DCHECK_NE(UninitializedPacketNumber(), packet_number)
         << "Use default constructor for uninitialized packet number";
   }
 
@@ -103,53 +103,60 @@
 };
 
 inline bool operator==(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs;
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized())
+      << lhs << " vs. " << rhs;
   return lhs.packet_number_ == rhs.packet_number_;
 }
 
 inline bool operator!=(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs;
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized())
+      << lhs << " vs. " << rhs;
   return lhs.packet_number_ != rhs.packet_number_;
 }
 
 inline bool operator<(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs;
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized())
+      << lhs << " vs. " << rhs;
   return lhs.packet_number_ < rhs.packet_number_;
 }
 
 inline bool operator<=(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs;
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized())
+      << lhs << " vs. " << rhs;
   return lhs.packet_number_ <= rhs.packet_number_;
 }
 
 inline bool operator>(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs;
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized())
+      << lhs << " vs. " << rhs;
   return lhs.packet_number_ > rhs.packet_number_;
 }
 
 inline bool operator>=(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized()) << lhs << " vs. " << rhs;
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized())
+      << lhs << " vs. " << rhs;
   return lhs.packet_number_ >= rhs.packet_number_;
 }
 
 inline QuicPacketNumber operator+(QuicPacketNumber lhs, uint64_t delta) {
 #ifndef NDEBUG
-  DCHECK(lhs.IsInitialized());
-  DCHECK_GT(std::numeric_limits<uint64_t>::max() - lhs.ToUint64(), delta);
+  QUICHE_DCHECK(lhs.IsInitialized());
+  QUICHE_DCHECK_GT(std::numeric_limits<uint64_t>::max() - lhs.ToUint64(),
+                   delta);
 #endif
   return QuicPacketNumber(lhs.packet_number_ + delta);
 }
 
 inline QuicPacketNumber operator-(QuicPacketNumber lhs, uint64_t delta) {
 #ifndef NDEBUG
-  DCHECK(lhs.IsInitialized());
-  DCHECK_GE(lhs.ToUint64(), delta);
+  QUICHE_DCHECK(lhs.IsInitialized());
+  QUICHE_DCHECK_GE(lhs.ToUint64(), delta);
 #endif
   return QuicPacketNumber(lhs.packet_number_ - delta);
 }
 
 inline uint64_t operator-(QuicPacketNumber lhs, QuicPacketNumber rhs) {
-  DCHECK(lhs.IsInitialized() && rhs.IsInitialized() && lhs >= rhs)
+  QUICHE_DCHECK(lhs.IsInitialized() && rhs.IsInitialized() && lhs >= rhs)
       << lhs << " vs. " << rhs;
   return lhs.packet_number_ - rhs.packet_number_;
 }
diff --git a/quic/core/quic_received_packet_manager.h b/quic/core/quic_received_packet_manager.h
index 1505cac..822725d 100644
--- a/quic/core/quic_received_packet_manager.h
+++ b/quic/core/quic_received_packet_manager.h
@@ -115,7 +115,7 @@
   }
 
   void set_ack_frequency(size_t new_value) {
-    DCHECK_GT(new_value, 0u);
+    QUICHE_DCHECK_GT(new_value, 0u);
     ack_frequency_ = new_value;
   }
 
diff --git a/quic/core/quic_sent_packet_manager.h b/quic/core/quic_sent_packet_manager.h
index 16e4233..13e2396 100644
--- a/quic/core/quic_sent_packet_manager.h
+++ b/quic/core/quic_sent_packet_manager.h
@@ -356,8 +356,8 @@
       EncryptionLevel decrypted_packet_level) const;
 
   void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) {
-    DCHECK(!network_change_visitor_);
-    DCHECK(visitor);
+    QUICHE_DCHECK(!network_change_visitor_);
+    QUICHE_DCHECK(visitor);
     network_change_visitor_ = visitor;
   }
 
@@ -386,7 +386,7 @@
   }
 
   QuicPacketNumber largest_packet_peer_knows_is_acked() const {
-    DCHECK(!supports_multiple_packet_number_spaces());
+    QUICHE_DCHECK(!supports_multiple_packet_number_spaces());
     return largest_packet_peer_knows_is_acked_;
   }
 
@@ -398,7 +398,7 @@
 
   void set_peer_max_ack_delay(QuicTime::Delta peer_max_ack_delay) {
     // The delayed ack time should never be more than one half the min RTO time.
-    DCHECK_LE(peer_max_ack_delay, (min_rto_timeout_ * 0.5));
+    QUICHE_DCHECK_LE(peer_max_ack_delay, (min_rto_timeout_ * 0.5));
     peer_max_ack_delay_ = peer_max_ack_delay;
   }
 
diff --git a/quic/core/quic_sustained_bandwidth_recorder.h b/quic/core/quic_sustained_bandwidth_recorder.h
index a02b266..f1fdfeb 100644
--- a/quic/core/quic_sustained_bandwidth_recorder.h
+++ b/quic/core/quic_sustained_bandwidth_recorder.h
@@ -44,22 +44,22 @@
   bool HasEstimate() const { return has_estimate_; }
 
   QuicBandwidth BandwidthEstimate() const {
-    DCHECK(has_estimate_);
+    QUICHE_DCHECK(has_estimate_);
     return bandwidth_estimate_;
   }
 
   QuicBandwidth MaxBandwidthEstimate() const {
-    DCHECK(has_estimate_);
+    QUICHE_DCHECK(has_estimate_);
     return max_bandwidth_estimate_;
   }
 
   int64_t MaxBandwidthTimestamp() const {
-    DCHECK(has_estimate_);
+    QUICHE_DCHECK(has_estimate_);
     return max_bandwidth_timestamp_;
   }
 
   bool EstimateRecordedDuringSlowStart() const {
-    DCHECK(has_estimate_);
+    QUICHE_DCHECK(has_estimate_);
     return bandwidth_estimate_recorded_during_slow_start_;
   }
 
diff --git a/quic/core/quic_time.h b/quic/core/quic_time.h
index 25c60da..5fe9b2e 100644
--- a/quic/core/quic_time.h
+++ b/quic/core/quic_time.h
@@ -245,7 +245,7 @@
   return !(lhs < rhs);
 }
 
-// Override stream output operator for gtest or CHECK macros.
+// Override stream output operator for gtest or QUICHE_CHECK macros.
 inline std::ostream& operator<<(std::ostream& output, const QuicTime t) {
   output << t.ToDebuggingValue();
   return output;
diff --git a/quic/core/quic_time_accumulator.h b/quic/core/quic_time_accumulator.h
index d29eb74..8680cb6 100644
--- a/quic/core/quic_time_accumulator.h
+++ b/quic/core/quic_time_accumulator.h
@@ -23,18 +23,18 @@
   bool IsRunning() const { return last_start_time_ != NotRunningSentinel(); }
 
   void Start(QuicTime now) {
-    DCHECK(!IsRunning());
+    QUICHE_DCHECK(!IsRunning());
     last_start_time_ = now;
-    DCHECK(IsRunning());
+    QUICHE_DCHECK(IsRunning());
   }
 
   void Stop(QuicTime now) {
-    DCHECK(IsRunning());
+    QUICHE_DCHECK(IsRunning());
     if (now > last_start_time_) {
       total_elapsed_ = total_elapsed_ + (now - last_start_time_);
     }
     last_start_time_ = NotRunningSentinel();
-    DCHECK(!IsRunning());
+    QUICHE_DCHECK(!IsRunning());
   }
 
   // Get total elapsed time between COMPLETED Start/Stop pairs.
diff --git a/quic/core/quic_time_wait_list_manager.h b/quic/core/quic_time_wait_list_manager.h
index 6dbd737..4e685f9 100644
--- a/quic/core/quic_time_wait_list_manager.h
+++ b/quic/core/quic_time_wait_list_manager.h
@@ -115,8 +115,8 @@
   // Called when a packet is received for a connection_id that is in time wait
   // state. Sends a public reset packet to the peer which sent this
   // connection_id. Sending of the public reset packet is throttled by using
-  // exponential back off. DCHECKs for the connection_id to be in time wait
-  // state. virtual to override in tests.
+  // exponential back off. QUICHE_DCHECKs for the connection_id to be in time
+  // wait state. virtual to override in tests.
   virtual void ProcessPacket(
       const QuicSocketAddress& self_address,
       const QuicSocketAddress& peer_address,
diff --git a/quic/core/quic_udp_socket.h b/quic/core/quic_udp_socket.h
index dadb787..534273c 100644
--- a/quic/core/quic_udp_socket.h
+++ b/quic/core/quic_udp_socket.h
@@ -66,7 +66,7 @@
   bool HasValue(QuicUdpPacketInfoBit bit) const { return bitmask_.IsSet(bit); }
 
   QuicPacketCount dropped_packets() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::DROPPED_PACKETS));
     return dropped_packets_;
   }
 
@@ -76,7 +76,7 @@
   }
 
   const QuicIpAddress& self_v4_ip() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::V4_SELF_IP));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::V4_SELF_IP));
     return self_v4_ip_;
   }
 
@@ -86,7 +86,7 @@
   }
 
   const QuicIpAddress& self_v6_ip() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::V6_SELF_IP));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::V6_SELF_IP));
     return self_v6_ip_;
   }
 
@@ -104,7 +104,7 @@
   }
 
   const QuicSocketAddress& peer_address() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::PEER_ADDRESS));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::PEER_ADDRESS));
     return peer_address_;
   }
 
@@ -114,7 +114,7 @@
   }
 
   QuicWallTime receive_timestamp() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::RECV_TIMESTAMP));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::RECV_TIMESTAMP));
     return receive_timestamp_;
   }
 
@@ -124,7 +124,7 @@
   }
 
   int ttl() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::TTL));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::TTL));
     return ttl_;
   }
 
@@ -134,7 +134,7 @@
   }
 
   BufferSpan google_packet_headers() const {
-    DCHECK(HasValue(QuicUdpPacketInfoBit::GOOGLE_PACKET_HEADER));
+    QUICHE_DCHECK(HasValue(QuicUdpPacketInfoBit::GOOGLE_PACKET_HEADER));
     return google_packet_headers_;
   }
 
diff --git a/quic/core/quic_versions.h b/quic/core/quic_versions.h
index 1bc00a2..dbcbd81 100644
--- a/quic/core/quic_versions.h
+++ b/quic/core/quic_versions.h
@@ -213,7 +213,8 @@
                               QuicTransportVersion transport_version)
       : handshake_protocol(handshake_protocol),
         transport_version(transport_version) {
-    DCHECK(ParsedQuicVersionIsValid(handshake_protocol, transport_version))
+    QUICHE_DCHECK(
+        ParsedQuicVersionIsValid(handshake_protocol, transport_version))
         << QuicVersionToString(transport_version) << " "
         << HandshakeProtocolToString(handshake_protocol);
   }
@@ -222,8 +223,8 @@
       : ParsedQuicVersion(other.handshake_protocol, other.transport_version) {}
 
   ParsedQuicVersion& operator=(const ParsedQuicVersion& other) {
-    DCHECK(ParsedQuicVersionIsValid(other.handshake_protocol,
-                                    other.transport_version))
+    QUICHE_DCHECK(ParsedQuicVersionIsValid(other.handshake_protocol,
+                                           other.transport_version))
         << QuicVersionToString(other.transport_version) << " "
         << HandshakeProtocolToString(other.handshake_protocol);
     if (this != &other) {
diff --git a/quic/test_tools/crypto_test_utils.h b/quic/test_tools/crypto_test_utils.h
index 0c5534f..d839c6c 100644
--- a/quic/test_tools/crypto_test_utils.h
+++ b/quic/test_tools/crypto_test_utils.h
@@ -147,7 +147,7 @@
 
 // ParseTag returns a QuicTag from parsing |tagstr|. |tagstr| may either be
 // in the format "EXMP" (i.e. ASCII format), or "#11223344" (an explicit hex
-// format). It CHECK fails if there's a parse error.
+// format). It QUICHE_CHECK fails if there's a parse error.
 QuicTag ParseTag(const char* tagstr);
 
 // Message constructs a CHLO message from a provided vector of tag/value pairs.
diff --git a/quic/test_tools/first_flight.h b/quic/test_tools/first_flight.h
index 0ffeb5e..c18c879 100644
--- a/quic/test_tools/first_flight.h
+++ b/quic/test_tools/first_flight.h
@@ -37,7 +37,7 @@
   // |delegate| MUST be valid for the duration of the DelegatedPacketWriter's
   // lifetime.
   explicit DelegatedPacketWriter(Delegate* delegate) : delegate_(delegate) {
-    CHECK_NE(delegate_, nullptr);
+    QUICHE_CHECK_NE(delegate_, nullptr);
   }
 
   // Overrides for QuicPacketWriter.
diff --git a/quic/test_tools/packet_dropping_test_writer.h b/quic/test_tools/packet_dropping_test_writer.h
index a66fb78..c15b5de 100644
--- a/quic/test_tools/packet_dropping_test_writer.h
+++ b/quic/test_tools/packet_dropping_test_writer.h
@@ -93,22 +93,22 @@
   // to WRITE_STATUS_BLOCKED.
   void set_fake_blocked_socket_percentage(
       int32_t fake_blocked_socket_percentage) {
-    DCHECK(clock_);
+    QUICHE_DCHECK(clock_);
     QuicWriterMutexLock 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) {
-    DCHECK(clock_);
+    QUICHE_DCHECK(clock_);
     QuicWriterMutexLock lock(&config_mutex_);
-    DCHECK(!fake_packet_delay_.IsZero());
+    QUICHE_DCHECK(!fake_packet_delay_.IsZero());
     fake_packet_reorder_percentage_ = fake_packet_reorder_percentage;
   }
 
   // The delay before writing this packet.
   void set_fake_packet_delay(QuicTime::Delta fake_packet_delay) {
-    DCHECK(clock_);
+    QUICHE_DCHECK(clock_);
     QuicWriterMutexLock lock(&config_mutex_);
     fake_packet_delay_ = fake_packet_delay;
   }
@@ -119,7 +119,7 @@
   // dropped.
   void set_max_bandwidth_and_buffer_size(QuicBandwidth fake_bandwidth,
                                          QuicByteCount buffer_size) {
-    DCHECK(clock_);
+    QUICHE_DCHECK(clock_);
     QuicWriterMutexLock lock(&config_mutex_);
     fake_bandwidth_ = fake_bandwidth;
     buffer_size_ = buffer_size;
diff --git a/quic/test_tools/simulator/switch.h b/quic/test_tools/simulator/switch.h
index 79968f8..f50df6b 100644
--- a/quic/test_tools/simulator/switch.h
+++ b/quic/test_tools/simulator/switch.h
@@ -30,7 +30,7 @@
   // Returns Endpoint associated with the port under number |port_number|.  Just
   // like on most real switches, port numbering starts with 1.
   inline Endpoint* port(SwitchPortNumber port_number) {
-    DCHECK_NE(port_number, 0u);
+    QUICHE_DCHECK_NE(port_number, 0u);
     return &ports_[port_number - 1];
   }
 
diff --git a/quic/tools/quic_spdy_client_base.h b/quic/tools/quic_spdy_client_base.h
index 9ff10ad..54c73f7 100644
--- a/quic/tools/quic_spdy_client_base.h
+++ b/quic/tools/quic_spdy_client_base.h
@@ -175,8 +175,8 @@
                            bool fin,
                            QuicSpdyClientBase* client)
         : QuicDataToResend(std::move(headers), body, fin), client_(client) {
-      DCHECK(headers_);
-      DCHECK(client);
+      QUICHE_DCHECK(headers_);
+      QUICHE_DCHECK(client);
     }
 
     ClientQuicDataToResend(const ClientQuicDataToResend&) = delete;