[code health] Replace ASSERT() with DCHECK() in fxcrt/

Bug: pdfium:1596
Change-Id: Iebee9ffe8834f42919bb87bb9501e647a47f6ec7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/77550
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index b91e733..5261934 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -18,6 +18,7 @@
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/string_pool_template.h"
+#include "third_party/base/check.h"
 #include "third_party/base/numerics/safe_math.h"
 #include "third_party/base/span.h"
 #include "third_party/base/stl_util.h"
@@ -381,7 +382,7 @@
     return;
   }
 
-  ASSERT(m_pData->m_nRefs == 1);
+  DCHECK(m_pData->m_nRefs == 1);
   m_pData->m_nDataLength = nNewLength;
   m_pData->m_String[nNewLength] = 0;
   if (m_pData->m_nAllocLength - nNewLength >= 32) {
@@ -514,7 +515,7 @@
 }
 
 void ByteString::SetAt(size_t index, char c) {
-  ASSERT(IsValidIndex(index));
+  DCHECK(IsValidIndex(index));
   ReallocBeforeWrite(m_pData->m_nDataLength);
   m_pData->m_String[index] = c;
 }
diff --git a/core/fxcrt/cfx_bitstream.cpp b/core/fxcrt/cfx_bitstream.cpp
index 66220ba..db0c852 100644
--- a/core/fxcrt/cfx_bitstream.cpp
+++ b/core/fxcrt/cfx_bitstream.cpp
@@ -10,10 +10,11 @@
 
 #include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 CFX_BitStream::CFX_BitStream(pdfium::span<const uint8_t> pData)
     : m_BitPos(0), m_BitSize(pData.size() * 8), m_pData(pData.data()) {
-  ASSERT(pData.size() <= std::numeric_limits<uint32_t>::max() / 8);
+  DCHECK(pData.size() <= std::numeric_limits<uint32_t>::max() / 8);
 }
 
 CFX_BitStream::~CFX_BitStream() = default;
@@ -23,8 +24,8 @@
 }
 
 uint32_t CFX_BitStream::GetBits(uint32_t nBits) {
-  ASSERT(nBits > 0);
-  ASSERT(nBits <= 32);
+  DCHECK(nBits > 0);
+  DCHECK(nBits <= 32);
   if (nBits > m_BitSize || m_BitPos > m_BitSize - nBits)
     return 0;
 
diff --git a/core/fxcrt/cfx_datetime.cpp b/core/fxcrt/cfx_datetime.cpp
index 3db9a98..fcf9eb0 100644
--- a/core/fxcrt/cfx_datetime.cpp
+++ b/core/fxcrt/cfx_datetime.cpp
@@ -8,6 +8,7 @@
 
 #include "build/build_config.h"
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 #if defined(OS_ANDROID) || defined(OS_LINUX) || defined(OS_CHROMEOS) || \
     defined(OS_APPLE) || defined(OS_ASMJS)
@@ -29,9 +30,9 @@
 const int32_t g_FXDaysPerLeapYear = 366;
 
 int32_t DaysBeforeMonthInYear(int32_t iYear, uint8_t iMonth) {
-  ASSERT(iYear != 0);
-  ASSERT(iMonth >= 1);
-  ASSERT(iMonth <= 12);
+  DCHECK(iYear != 0);
+  DCHECK(iMonth >= 1);
+  DCHECK(iMonth <= 12);
 
   const int32_t* p =
       FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth;
@@ -39,7 +40,7 @@
 }
 
 int32_t DaysInYear(int32_t iYear) {
-  ASSERT(iYear != 0);
+  DCHECK(iYear != 0);
   return FX_IsLeapYear(iYear) ? g_FXDaysPerLeapYear : g_FXDaysPerYear;
 }
 
@@ -47,11 +48,11 @@
                    uint8_t iMonth,
                    uint8_t iDay,
                    bool bIncludeThisDay) {
-  ASSERT(iYear != 0);
-  ASSERT(iMonth >= 1);
-  ASSERT(iMonth <= 12);
-  ASSERT(iDay >= 1);
-  ASSERT(iDay <= FX_DaysInMonth(iYear, iMonth));
+  DCHECK(iYear != 0);
+  DCHECK(iMonth >= 1);
+  DCHECK(iMonth <= 12);
+  DCHECK(iDay >= 1);
+  DCHECK(iDay <= FX_DaysInMonth(iYear, iMonth));
 
   int64_t iDays = DaysBeforeMonthInYear(iYear, iMonth);
   iDays += iDay;
@@ -82,9 +83,9 @@
 }  // namespace
 
 uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth) {
-  ASSERT(iYear != 0);
-  ASSERT(iMonth >= 1);
-  ASSERT(iMonth <= 12);
+  DCHECK(iYear != 0);
+  DCHECK(iMonth >= 1);
+  DCHECK(iMonth <= 12);
 
   const uint8_t* p =
       FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth;
@@ -92,7 +93,7 @@
 }
 
 bool FX_IsLeapYear(int32_t iYear) {
-  ASSERT(iYear != 0);
+  DCHECK(iYear != 0);
   return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0;
 }
 
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index 6c34b03..76d5582 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -21,6 +21,7 @@
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace {
@@ -29,7 +30,7 @@
 // Invalid sequences are silently not output.
 std::pair<size_t, size_t> UTF8Decode(pdfium::span<const uint8_t> pSrc,
                                      pdfium::span<wchar_t> pDst) {
-  ASSERT(!pDst.empty());
+  DCHECK(!pDst.empty());
 
   uint32_t dwCode = 0;
   int32_t iPending = 0;
@@ -75,8 +76,8 @@
 static_assert(sizeof(wchar_t) > 2, "wchar_t is too small");
 
 void UTF16ToWChar(void* pBuffer, size_t iLength) {
-  ASSERT(pBuffer);
-  ASSERT(iLength > 0);
+  DCHECK(pBuffer);
+  DCHECK(iLength > 0);
 
   uint16_t* pSrc = static_cast<uint16_t*>(pBuffer);
   wchar_t* pDst = static_cast<wchar_t*>(pBuffer);
@@ -108,7 +109,7 @@
       m_wBOMLength(0),
       m_iPosition(0),
       m_pStream(stream) {
-  ASSERT(m_pStream);
+  DCHECK(m_pStream);
 
   Seek(From::Begin, 0);
 
@@ -173,8 +174,8 @@
 }
 
 size_t CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer, size_t iBufferSize) {
-  ASSERT(pBuffer);
-  ASSERT(iBufferSize > 0);
+  DCHECK(pBuffer);
+  DCHECK(iBufferSize > 0);
 
   iBufferSize =
       std::min(iBufferSize, static_cast<size_t>(GetSize() - m_iPosition));
diff --git a/core/fxcrt/cfx_timer.cpp b/core/fxcrt/cfx_timer.cpp
index ba8b3e2..f9b932b 100644
--- a/core/fxcrt/cfx_timer.cpp
+++ b/core/fxcrt/cfx_timer.cpp
@@ -8,6 +8,7 @@
 
 #include <map>
 
+#include "third_party/base/check.h"
 #include "third_party/base/no_destructor.h"
 
 namespace {
@@ -24,7 +25,7 @@
                      CallbackIface* pCallbackIface,
                      int32_t nInterval)
     : m_pHandlerIface(pHandlerIface), m_pCallbackIface(pCallbackIface) {
-  ASSERT(m_pCallbackIface);
+  DCHECK(m_pCallbackIface);
   if (m_pHandlerIface) {
     m_nTimerID = m_pHandlerIface->SetTimer(nInterval, TimerProc);
     if (HasValidID())
diff --git a/core/fxcrt/css/cfx_cssdeclaration.cpp b/core/fxcrt/css/cfx_cssdeclaration.cpp
index ad49588..fcdad47 100644
--- a/core/fxcrt/css/cfx_cssdeclaration.cpp
+++ b/core/fxcrt/css/cfx_cssdeclaration.cpp
@@ -19,6 +19,7 @@
 #include "core/fxcrt/css/cfx_cssvaluelistparser.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 #include "third_party/base/notreached.h"
 
 namespace {
@@ -31,8 +32,8 @@
                     int32_t iValueLen,
                     float* pValue,
                     CFX_CSSNumberType* pOutUnit) {
-  ASSERT(pszValue);
-  ASSERT(iValueLen > 0);
+  DCHECK(pszValue);
+  DCHECK(iValueLen > 0);
 
   int32_t iUsedLen = 0;
   *pValue = FXSYS_wcstof(pszValue, iValueLen, &iUsedLen);
@@ -60,8 +61,8 @@
                                         int32_t iValueLen,
                                         int32_t* iOffset,
                                         int32_t* iLength) {
-  ASSERT(pszValue);
-  ASSERT(iValueLen > 0);
+  DCHECK(pszValue);
+  DCHECK(iValueLen > 0);
 
   *iOffset = 0;
   *iLength = iValueLen;
@@ -79,9 +80,9 @@
 bool CFX_CSSDeclaration::ParseCSSColor(const wchar_t* pszValue,
                                        int32_t iValueLen,
                                        FX_ARGB* dwColor) {
-  ASSERT(pszValue);
-  ASSERT(iValueLen > 0);
-  ASSERT(dwColor);
+  DCHECK(pszValue);
+  DCHECK(iValueLen > 0);
+  DCHECK(dwColor);
 
   if (*pszValue == '#') {
     switch (iValueLen) {
@@ -166,7 +167,7 @@
 
 void CFX_CSSDeclaration::AddProperty(const CFX_CSSData::Property* property,
                                      WideStringView value) {
-  ASSERT(!value.IsEmpty());
+  DCHECK(!value.IsEmpty());
 
   const wchar_t* pszValue = value.unterminated_c_str();
   int32_t iValueLen = value.GetLength();
diff --git a/core/fxcrt/css/cfx_cssselector.cpp b/core/fxcrt/css/cfx_cssselector.cpp
index ca2aeec..0ef9981 100644
--- a/core/fxcrt/css/cfx_cssselector.cpp
+++ b/core/fxcrt/css/cfx_cssselector.cpp
@@ -9,6 +9,7 @@
 #include <utility>
 
 #include "core/fxcrt/fx_extension.h"
+#include "third_party/base/check.h"
 
 namespace {
 
@@ -33,7 +34,7 @@
 // static.
 std::unique_ptr<CFX_CSSSelector> CFX_CSSSelector::FromString(
     WideStringView str) {
-  ASSERT(!str.IsEmpty());
+  DCHECK(!str.IsEmpty());
 
   for (wchar_t wch : str) {
     switch (wch) {
diff --git a/core/fxcrt/css/cfx_cssstylerule.cpp b/core/fxcrt/css/cfx_cssstylerule.cpp
index 0a8a033..e2645e6 100644
--- a/core/fxcrt/css/cfx_cssstylerule.cpp
+++ b/core/fxcrt/css/cfx_cssstylerule.cpp
@@ -6,6 +6,8 @@
 
 #include "core/fxcrt/css/cfx_cssstylerule.h"
 
+#include "third_party/base/check.h"
+
 CFX_CSSStyleRule::CFX_CSSStyleRule() = default;
 
 CFX_CSSStyleRule::~CFX_CSSStyleRule() = default;
@@ -24,7 +26,6 @@
 
 void CFX_CSSStyleRule::SetSelector(
     std::vector<std::unique_ptr<CFX_CSSSelector>>* list) {
-  ASSERT(m_ppSelector.empty());
-
+  DCHECK(m_ppSelector.empty());
   m_ppSelector.swap(*list);
 }
diff --git a/core/fxcrt/css/cfx_cssstyleselector.cpp b/core/fxcrt/css/cfx_cssstyleselector.cpp
index 2c119b0..3c7de1c 100644
--- a/core/fxcrt/css/cfx_cssstyleselector.cpp
+++ b/core/fxcrt/css/cfx_cssstyleselector.cpp
@@ -19,6 +19,7 @@
 #include "core/fxcrt/css/cfx_cssstylesheet.h"
 #include "core/fxcrt/css/cfx_csssyntaxparser.h"
 #include "core/fxcrt/css/cfx_cssvaluelist.h"
+#include "third_party/base/check.h"
 #include "third_party/base/containers/adapters.h"
 #include "third_party/base/notreached.h"
 
@@ -27,7 +28,7 @@
 CFX_CSSStyleSelector::~CFX_CSSStyleSelector() = default;
 
 void CFX_CSSStyleSelector::SetDefaultFontSize(float fFontSize) {
-  ASSERT(fFontSize > 0);
+  DCHECK(fFontSize > 0);
   m_fDefaultFontSize = fFontSize;
 }
 
@@ -137,8 +138,8 @@
 
 void CFX_CSSStyleSelector::AppendInlineStyle(CFX_CSSDeclaration* pDecl,
                                              const WideString& style) {
-  ASSERT(pDecl);
-  ASSERT(!style.IsEmpty());
+  DCHECK(pDecl);
+  DCHECK(!style.IsEmpty());
 
   auto pSyntax = std::make_unique<CFX_CSSSyntaxParser>(style.AsStringView());
   pSyntax->SetParseOnlyDeclarations();
diff --git a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
index f2c8cf3..8895de2 100644
--- a/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
+++ b/core/fxcrt/css/cfx_cssstylesheet_unittest.cpp
@@ -15,6 +15,7 @@
 #include "core/fxcrt/css/cfx_cssstylerule.h"
 #include "core/fxcrt/css/cfx_cssvaluelist.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/check.h"
 
 class CFX_CSSStyleSheetTest : public testing::Test {
  public:
@@ -26,12 +27,12 @@
   void TearDown() override { decl_ = nullptr; }
 
   void VerifyLoadFails(WideStringView buf) {
-    ASSERT(sheet_);
+    DCHECK(sheet_);
     EXPECT_FALSE(sheet_->LoadBuffer(buf));
   }
 
   void LoadAndVerifyRuleCount(WideStringView buf, size_t rule_count) {
-    ASSERT(sheet_);
+    DCHECK(sheet_);
     EXPECT_TRUE(sheet_->LoadBuffer(buf));
     EXPECT_EQ(sheet_->CountRules(), rule_count);
   }
@@ -55,7 +56,7 @@
   }
 
   void VerifyFloat(CFX_CSSProperty prop, float val, CFX_CSSNumberType type) {
-    ASSERT(decl_);
+    DCHECK(decl_);
 
     bool important;
     RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important);
@@ -65,7 +66,7 @@
   }
 
   void VerifyEnum(CFX_CSSProperty prop, CFX_CSSPropertyValue val) {
-    ASSERT(decl_);
+    DCHECK(decl_);
 
     bool important;
     RetainPtr<CFX_CSSValue> v = decl_->GetProperty(prop, &important);
@@ -75,7 +76,7 @@
 
   void VerifyList(CFX_CSSProperty prop,
                   std::vector<CFX_CSSPropertyValue> expected_values) {
-    ASSERT(decl_);
+    DCHECK(decl_);
 
     bool important;
     RetainPtr<CFX_CSSValueList> list =
diff --git a/core/fxcrt/css/cfx_cssvaluelistparser.cpp b/core/fxcrt/css/cfx_cssvaluelistparser.cpp
index 447ba9f..8fb10ac 100644
--- a/core/fxcrt/css/cfx_cssvaluelistparser.cpp
+++ b/core/fxcrt/css/cfx_cssvaluelistparser.cpp
@@ -7,13 +7,14 @@
 #include "core/fxcrt/css/cfx_cssvaluelistparser.h"
 
 #include "core/fxcrt/fx_extension.h"
+#include "third_party/base/check.h"
 
 CFX_CSSValueListParser::CFX_CSSValueListParser(const wchar_t* psz,
                                                int32_t iLen,
                                                wchar_t separator)
     : m_Separator(separator), m_pCur(psz), m_pEnd(psz + iLen) {
-  ASSERT(psz);
-  ASSERT(iLen > 0);
+  DCHECK(psz);
+  DCHECK(iLen > 0);
 }
 
 bool CFX_CSSValueListParser::NextValue(CFX_CSSPrimitiveType* eType,
diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp
index 33f181d..c20b1b8 100644
--- a/core/fxcrt/fx_bidi.cpp
+++ b/core/fxcrt/fx_bidi.cpp
@@ -9,6 +9,7 @@
 #include <algorithm>
 
 #include "core/fxcrt/fx_unicode.h"
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 CFX_BidiChar::CFX_BidiChar()
@@ -77,7 +78,7 @@
 CFX_BidiString::~CFX_BidiString() = default;
 
 CFX_BidiChar::Direction CFX_BidiString::OverallDirection() const {
-  ASSERT(m_eOverallDirection != CFX_BidiChar::NEUTRAL);
+  DCHECK(m_eOverallDirection != CFX_BidiChar::NEUTRAL);
   return m_eOverallDirection;
 }
 
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index df700d7..215c97e 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -11,6 +11,7 @@
 #include <limits>
 
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 #include "third_party/base/compiler_specific.h"
 
 namespace {
@@ -29,7 +30,7 @@
 }  // namespace
 
 float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) {
-  ASSERT(pwsStr);
+  DCHECK(pwsStr);
 
   if (iLength < 0)
     iLength = static_cast<int32_t>(wcslen(pwsStr));
@@ -117,9 +118,9 @@
 }
 
 wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count) {
-  ASSERT(dstStr);
-  ASSERT(srcStr);
-  ASSERT(count > 0);
+  DCHECK(dstStr);
+  DCHECK(srcStr);
+  DCHECK(count > 0);
 
   for (size_t i = 0; i < count; ++i)
     if ((dstStr[i] = srcStr[i]) == L'\0')
@@ -128,9 +129,9 @@
 }
 
 int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count) {
-  ASSERT(s1);
-  ASSERT(s2);
-  ASSERT(count > 0);
+  DCHECK(s1);
+  DCHECK(s2);
+  DCHECK(count > 0);
 
   wchar_t wch1 = 0, wch2 = 0;
   while (count-- > 0) {
@@ -154,7 +155,7 @@
 }
 
 size_t FXSYS_ToUTF16BE(uint32_t unicode, char* buf) {
-  ASSERT(unicode <= 0xD7FF || (unicode > 0xDFFF && unicode <= 0x10FFFF));
+  DCHECK(unicode <= 0xD7FF || (unicode > 0xDFFF && unicode <= 0x10FFFF));
   if (unicode <= 0xFFFF) {
     FXSYS_IntToFourHexChars(unicode, buf);
     return 4;
diff --git a/core/fxcrt/fx_unicode.cpp b/core/fxcrt/fx_unicode.cpp
index abcd091..f667fba 100644
--- a/core/fxcrt/fx_unicode.cpp
+++ b/core/fxcrt/fx_unicode.cpp
@@ -6,6 +6,7 @@
 
 #include "core/fxcrt/fx_unicode.h"
 
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace {
@@ -139,14 +140,14 @@
   size_t idx = prop >> kMirrorBitPos;
   if (idx == kMirrorMax)
     return wch;
-  ASSERT(idx < kFXTextLayoutBidiMirrorSize);
+  DCHECK(idx < kFXTextLayoutBidiMirrorSize);
   return kFXTextLayoutBidiMirror[idx];
 }
 
 FX_BIDICLASS FX_GetBidiClass(wchar_t wch) {
   uint16_t prop = GetUnicodeProperties(wch);
   uint16_t result = (prop & kBidiClassBitMask) >> kBidiClassBitPos;
-  ASSERT(result <= static_cast<uint16_t>(FX_BIDICLASS::kPDF));
+  DCHECK(result <= static_cast<uint16_t>(FX_BIDICLASS::kPDF));
   return static_cast<FX_BIDICLASS>(result);
 }
 
@@ -154,14 +155,14 @@
 FX_CHARTYPE FX_GetCharType(wchar_t wch) {
   uint16_t prop = GetExtendedUnicodeProperties(wch);
   uint16_t result = (prop & kCharTypeBitMask) >> kCharTypeBitPos;
-  ASSERT(result <= static_cast<uint16_t>(FX_CHARTYPE::kArabic));
+  DCHECK(result <= static_cast<uint16_t>(FX_CHARTYPE::kArabic));
   return static_cast<FX_CHARTYPE>(result);
 }
 
 FX_BREAKPROPERTY FX_GetBreakProperty(wchar_t wch) {
   uint16_t prop = GetExtendedUnicodeProperties(wch);
   uint16_t result = (prop & kBreakTypeBitMask) >> kBreakTypeBitPos;
-  ASSERT(result <= static_cast<uint16_t>(FX_BREAKPROPERTY::kTB));
+  DCHECK(result <= static_cast<uint16_t>(FX_BREAKPROPERTY::kTB));
   return static_cast<FX_BREAKPROPERTY>(result);
 }
 #endif  // PDF_ENABLE_XFA
diff --git a/core/fxcrt/maybe_owned.h b/core/fxcrt/maybe_owned.h
index 4e46864..3ddb2e3 100644
--- a/core/fxcrt/maybe_owned.h
+++ b/core/fxcrt/maybe_owned.h
@@ -10,6 +10,7 @@
 
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/unowned_ptr.h"
+#include "third_party/base/check.h"
 
 namespace fxcrt {
 
@@ -51,13 +52,13 @@
 
   // Downgrades to unowned, caller takes ownership.
   std::unique_ptr<T, D> Release() {
-    ASSERT(IsOwned());
+    DCHECK(IsOwned());
     return std::move(m_pOwnedObj);
   }
 
   // Downgrades to empty, caller takes ownership.
   std::unique_ptr<T, D> ReleaseAndClear() {
-    ASSERT(IsOwned());
+    DCHECK(IsOwned());
     m_pObj = nullptr;
     return std::move(m_pOwnedObj);
   }
diff --git a/core/fxcrt/observed_ptr.cpp b/core/fxcrt/observed_ptr.cpp
index 1a9f5af..4cf3181 100644
--- a/core/fxcrt/observed_ptr.cpp
+++ b/core/fxcrt/observed_ptr.cpp
@@ -4,6 +4,7 @@
 
 #include "core/fxcrt/observed_ptr.h"
 
+#include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
 namespace fxcrt {
@@ -15,12 +16,12 @@
 }
 
 void Observable::AddObserver(ObserverIface* pObserver) {
-  ASSERT(!pdfium::Contains(m_Observers, pObserver));
+  DCHECK(!pdfium::Contains(m_Observers, pObserver));
   m_Observers.insert(pObserver);
 }
 
 void Observable::RemoveObserver(ObserverIface* pObserver) {
-  ASSERT(pdfium::Contains(m_Observers, pObserver));
+  DCHECK(pdfium::Contains(m_Observers, pObserver));
   m_Observers.erase(pObserver);
 }
 
diff --git a/core/fxcrt/observed_ptr.h b/core/fxcrt/observed_ptr.h
index ce5995f..a1a1c22 100644
--- a/core/fxcrt/observed_ptr.h
+++ b/core/fxcrt/observed_ptr.h
@@ -8,6 +8,7 @@
 #include <set>
 
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/check.h"
 
 namespace fxcrt {
 
@@ -58,7 +59,7 @@
       m_pObservable->AddObserver(this);
   }
   void OnObservableDestroyed() override {
-    ASSERT(m_pObservable);
+    DCHECK(m_pObservable);
     m_pObservable = nullptr;
   }
   bool HasObservable() const { return !!m_pObservable; }
diff --git a/core/fxcrt/retain_ptr.h b/core/fxcrt/retain_ptr.h
index b9fd495..8d18647 100644
--- a/core/fxcrt/retain_ptr.h
+++ b/core/fxcrt/retain_ptr.h
@@ -11,6 +11,7 @@
 
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/unowned_ptr.h"
+#include "third_party/base/check.h"
 
 namespace fxcrt {
 
@@ -127,7 +128,7 @@
 
   void Retain() const { ++m_nRefCount; }
   void Release() const {
-    ASSERT(m_nRefCount > 0);
+    DCHECK(m_nRefCount > 0);
     if (--m_nRefCount == 0)
       delete this;
   }
diff --git a/core/fxcrt/retained_tree_node.h b/core/fxcrt/retained_tree_node.h
index 3c550d9..6d13294 100644
--- a/core/fxcrt/retained_tree_node.h
+++ b/core/fxcrt/retained_tree_node.h
@@ -7,6 +7,7 @@
 
 #include "core/fxcrt/retain_ptr.h"
 #include "core/fxcrt/tree_node.h"
+#include "third_party/base/check.h"
 
 namespace fxcrt {
 
@@ -65,7 +66,7 @@
 
   void Retain() { ++m_nRefCount; }
   void Release() {
-    ASSERT(m_nRefCount > 0);
+    DCHECK(m_nRefCount > 0);
     if (--m_nRefCount == 0 && !TreeNode<T>::GetParent())
       delete this;
   }
diff --git a/core/fxcrt/string_data_template.cpp b/core/fxcrt/string_data_template.cpp
index 825dcd6..7b0edfb 100644
--- a/core/fxcrt/string_data_template.cpp
+++ b/core/fxcrt/string_data_template.cpp
@@ -9,6 +9,7 @@
 #include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "third_party/base/allocator/partition_allocator/partition_alloc.h"
+#include "third_party/base/check.h"
 
 namespace fxcrt {
 
@@ -16,7 +17,7 @@
 template <typename CharType>
 StringDataTemplate<CharType>* StringDataTemplate<CharType>::Create(
     size_t nLen) {
-  ASSERT(nLen > 0);
+  DCHECK(nLen > 0);
 
   // Calculate space needed for the fixed portion of the struct plus the
   // NUL char that is not included in |m_nAllocLength|.
@@ -33,7 +34,7 @@
   nSize &= ~15;
   size_t totalSize = nSize.ValueOrDie();
   size_t usableLen = (totalSize - overhead) / sizeof(CharType);
-  ASSERT(usableLen >= nLen);
+  DCHECK(usableLen >= nLen);
 
   void* pData = GetStringPartitionAllocator().root()->Alloc(
       totalSize, "StringDataTemplate");
@@ -59,7 +60,7 @@
 template <typename CharType>
 void StringDataTemplate<CharType>::CopyContents(
     const StringDataTemplate& other) {
-  ASSERT(other.m_nDataLength <= m_nAllocLength);
+  DCHECK(other.m_nDataLength <= m_nAllocLength);
   memcpy(m_String, other.m_String,
          (other.m_nDataLength + 1) * sizeof(CharType));
 }
@@ -67,8 +68,8 @@
 template <typename CharType>
 void StringDataTemplate<CharType>::CopyContents(const CharType* pStr,
                                                 size_t nLen) {
-  ASSERT(nLen >= 0);
-  ASSERT(nLen <= m_nAllocLength);
+  DCHECK(nLen >= 0);
+  DCHECK(nLen <= m_nAllocLength);
 
   memcpy(m_String, pStr, nLen * sizeof(CharType));
   m_String[nLen] = 0;
@@ -78,9 +79,9 @@
 void StringDataTemplate<CharType>::CopyContentsAt(size_t offset,
                                                   const CharType* pStr,
                                                   size_t nLen) {
-  ASSERT(offset >= 0);
-  ASSERT(nLen >= 0);
-  ASSERT(offset + nLen <= m_nAllocLength);
+  DCHECK(offset >= 0);
+  DCHECK(nLen >= 0);
+  DCHECK(offset + nLen <= m_nAllocLength);
 
   memcpy(m_String + offset, pStr, nLen * sizeof(CharType));
   m_String[offset + nLen] = 0;
@@ -90,8 +91,8 @@
 StringDataTemplate<CharType>::StringDataTemplate(size_t dataLen,
                                                  size_t allocLen)
     : m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
-  ASSERT(dataLen >= 0);
-  ASSERT(dataLen <= allocLen);
+  DCHECK(dataLen >= 0);
+  DCHECK(dataLen <= allocLen);
   m_String[dataLen] = 0;
 }
 
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index fff6155..fdbb0b1 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -16,6 +16,7 @@
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/string_pool_template.h"
+#include "third_party/base/check.h"
 #include "third_party/base/numerics/safe_math.h"
 #include "third_party/base/stl_util.h"
 
@@ -548,7 +549,7 @@
     return;
   }
 
-  ASSERT(m_pData->m_nRefs == 1);
+  DCHECK(m_pData->m_nRefs == 1);
   m_pData->m_nDataLength = nNewLength;
   m_pData->m_String[nNewLength] = 0;
   if (m_pData->m_nAllocLength - nNewLength >= 32) {
@@ -976,7 +977,7 @@
 }
 
 void WideString::SetAt(size_t index, wchar_t c) {
-  ASSERT(IsValidIndex(index));
+  DCHECK(IsValidIndex(index));
   ReallocBeforeWrite(m_pData->m_nDataLength);
   m_pData->m_String[index] = c;
 }
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 0d8e2d2..58863bc 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -11,9 +11,10 @@
 #include "core/fxcrt/xml/cfx_xmlchardata.h"
 #include "core/fxcrt/xml/cfx_xmldocument.h"
 #include "core/fxcrt/xml/cfx_xmltext.h"
+#include "third_party/base/check.h"
 
 CFX_XMLElement::CFX_XMLElement(const WideString& wsTag) : name_(wsTag) {
-  ASSERT(!name_.IsEmpty());
+  DCHECK(!name_.IsEmpty());
 }
 
 CFX_XMLElement::~CFX_XMLElement() = default;
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index cad652e..0f6df7a 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -22,6 +22,7 @@
 #include "core/fxcrt/xml/cfx_xmlinstruction.h"
 #include "core/fxcrt/xml/cfx_xmlnode.h"
 #include "core/fxcrt/xml/cfx_xmltext.h"
+#include "third_party/base/check.h"
 #include "third_party/base/notreached.h"
 
 namespace {
@@ -61,7 +62,7 @@
 }
 
 CFX_XMLParser::CFX_XMLParser(const RetainPtr<IFX_SeekableReadStream>& pStream) {
-  ASSERT(pStream);
+  DCHECK(pStream);
 
   auto proxy = pdfium::MakeRetain<CFX_SeekableStreamProxy>(pStream);
   uint16_t wCodePage = proxy->GetCodePage();