Move CFX_StringDataTemplate to StringDataTemplate

This CL renames CFX_StringDataTemplate to StringDataTemplate and moves
into the fxcrt namespace.

Bug: pdfium:898
Change-Id: I1c1e5ae674c3cca34fd595272e9eebc9346ed6ac
Reviewed-on: https://pdfium-review.googlesource.com/14618
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index eb67898..a823fe4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -821,7 +821,6 @@
     "core/fxcrt/cfx_fixedbufgrow.h",
     "core/fxcrt/cfx_memorystream.cpp",
     "core/fxcrt/cfx_memorystream.h",
-    "core/fxcrt/cfx_string_data_template.h",
     "core/fxcrt/cfx_string_pool_template.h",
     "core/fxcrt/cfx_unowned_ptr.h",
     "core/fxcrt/cfx_utf8decoder.cpp",
@@ -857,6 +856,7 @@
     "core/fxcrt/observable.h",
     "core/fxcrt/retain_ptr.h",
     "core/fxcrt/shared_copy_on_write.h",
+    "core/fxcrt/string_data_template.h",
     "core/fxcrt/string_view_template.h",
     "core/fxcrt/widestring.cpp",
     "core/fxcrt/widestring.h",
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 2d343ff..a78020b 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -20,7 +20,7 @@
 #include "third_party/base/numerics/safe_math.h"
 #include "third_party/base/stl_util.h"
 
-template class CFX_StringDataTemplate<char>;
+template class fxcrt::StringDataTemplate<char>;
 template class fxcrt::StringViewTemplate<char>;
 template class CFX_StringPoolTemplate<ByteString>;
 template struct std::hash<ByteString>;
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index 7342fdb..c2c41e8 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -12,9 +12,9 @@
 #include <sstream>
 #include <utility>
 
-#include "core/fxcrt/cfx_string_data_template.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/string_data_template.h"
 #include "core/fxcrt/string_view_template.h"
 #include "third_party/base/optional.h"
 
@@ -185,7 +185,7 @@
   static ByteString FormatFloat(float f, int precision = 0);
 
  protected:
-  using StringData = CFX_StringDataTemplate<char>;
+  using StringData = StringDataTemplate<char>;
 
   void ReallocBeforeWrite(FX_STRSIZE nNewLen);
   void AllocBeforeWrite(FX_STRSIZE nNewLen);
diff --git a/core/fxcrt/cfx_string_data_template.h b/core/fxcrt/string_data_template.h
similarity index 76%
rename from core/fxcrt/cfx_string_data_template.h
rename to core/fxcrt/string_data_template.h
index eabb608..afec50f 100644
--- a/core/fxcrt/cfx_string_data_template.h
+++ b/core/fxcrt/string_data_template.h
@@ -4,23 +4,24 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
-#define CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
+#ifndef CORE_FXCRT_STRING_DATA_TEMPLATE_H_
+#define CORE_FXCRT_STRING_DATA_TEMPLATE_H_
 
 #include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_system.h"
 #include "third_party/base/numerics/safe_math.h"
 
+namespace fxcrt {
+
 template <typename CharType>
-class CFX_StringDataTemplate {
+class StringDataTemplate {
  public:
-  static CFX_StringDataTemplate* Create(FX_STRSIZE nLen) {
+  static StringDataTemplate* Create(FX_STRSIZE nLen) {
     ASSERT(nLen > 0);
 
     // Calculate space needed for the fixed portion of the struct plus the
     // NUL char that is not included in |m_nAllocLength|.
-    int overhead =
-        offsetof(CFX_StringDataTemplate, m_String) + sizeof(CharType);
+    int overhead = offsetof(StringDataTemplate, m_String) + sizeof(CharType);
     pdfium::base::CheckedNumeric<FX_STRSIZE> nSize = nLen;
     nSize *= sizeof(CharType);
     nSize += overhead;
@@ -36,18 +37,18 @@
     ASSERT(usableLen >= nLen);
 
     void* pData = pdfium::base::PartitionAllocGeneric(
-        gStringPartitionAllocator.root(), totalSize, "CFX_StringDataTemplate");
-    return new (pData) CFX_StringDataTemplate(nLen, usableLen);
+        gStringPartitionAllocator.root(), totalSize, "StringDataTemplate");
+    return new (pData) StringDataTemplate(nLen, usableLen);
   }
 
-  static CFX_StringDataTemplate* Create(const CFX_StringDataTemplate& other) {
-    CFX_StringDataTemplate* result = Create(other.m_nDataLength);
+  static StringDataTemplate* Create(const StringDataTemplate& other) {
+    StringDataTemplate* result = Create(other.m_nDataLength);
     result->CopyContents(other);
     return result;
   }
 
-  static CFX_StringDataTemplate* Create(const CharType* pStr, FX_STRSIZE nLen) {
-    CFX_StringDataTemplate* result = Create(nLen);
+  static StringDataTemplate* Create(const CharType* pStr, FX_STRSIZE nLen) {
+    StringDataTemplate* result = Create(nLen);
     result->CopyContents(pStr, nLen);
     return result;
   }
@@ -63,7 +64,7 @@
     return m_nRefs <= 1 && nTotalLen <= m_nAllocLength;
   }
 
-  void CopyContents(const CFX_StringDataTemplate& other) {
+  void CopyContents(const StringDataTemplate& other) {
     ASSERT(other.m_nDataLength <= m_nAllocLength);
     memcpy(m_String, other.m_String,
            (other.m_nDataLength + 1) * sizeof(CharType));
@@ -102,17 +103,21 @@
   CharType m_String[1];
 
  private:
-  CFX_StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
+  StringDataTemplate(FX_STRSIZE dataLen, FX_STRSIZE allocLen)
       : m_nRefs(0), m_nDataLength(dataLen), m_nAllocLength(allocLen) {
     ASSERT(dataLen >= 0);
     ASSERT(dataLen <= allocLen);
     m_String[dataLen] = 0;
   }
 
-  ~CFX_StringDataTemplate() = delete;
+  ~StringDataTemplate() = delete;
 };
 
-extern template class CFX_StringDataTemplate<char>;
-extern template class CFX_StringDataTemplate<wchar_t>;
+extern template class StringDataTemplate<char>;
+extern template class StringDataTemplate<wchar_t>;
 
-#endif  // CORE_FXCRT_CFX_STRING_DATA_TEMPLATE_H_
+}  // namespace fxcrt
+
+using fxcrt::StringDataTemplate;
+
+#endif  // CORE_FXCRT_STRING_DATA_TEMPLATE_H_
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index e90d8ce..e592584 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -20,7 +20,7 @@
 #include "third_party/base/numerics/safe_math.h"
 #include "third_party/base/stl_util.h"
 
-template class CFX_StringDataTemplate<wchar_t>;
+template class fxcrt::StringDataTemplate<wchar_t>;
 template class fxcrt::StringViewTemplate<wchar_t>;
 template class CFX_StringPoolTemplate<WideString>;
 template struct std::hash<WideString>;
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 4dc0abb..df7d95f 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -11,10 +11,10 @@
 #include <iterator>
 #include <utility>
 
-#include "core/fxcrt/cfx_string_data_template.h"
 #include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/retain_ptr.h"
+#include "core/fxcrt/string_data_template.h"
 #include "core/fxcrt/string_view_template.h"
 #include "third_party/base/optional.h"
 
@@ -179,7 +179,7 @@
   ByteString UTF16LE_Encode() const;
 
  protected:
-  using StringData = CFX_StringDataTemplate<wchar_t>;
+  using StringData = StringDataTemplate<wchar_t>;
 
   void ReallocBeforeWrite(FX_STRSIZE nLen);
   void AllocBeforeWrite(FX_STRSIZE nLen);