Remove last usage of CFX_ObjectArray.

Review-Url: https://codereview.chromium.org/2558373002
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index 24ae5d2..51a8a18 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -19,6 +19,9 @@
   CPDF_StreamAcc();
   ~CPDF_StreamAcc();
 
+  CPDF_StreamAcc(const CPDF_StreamAcc&) = delete;
+  CPDF_StreamAcc& operator=(const CPDF_StreamAcc&) = delete;
+
   void LoadAllData(const CPDF_Stream* pStream,
                    bool bRawAccess = false,
                    uint32_t estimated_size = 0,
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 2b8f6b6..30673f6 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -321,108 +321,6 @@
 typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
 typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray;
 typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array;
-
-template <class ObjectClass>
-class CFX_ObjectArray : public CFX_BasicArray {
- public:
-  CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {}
-
-  ~CFX_ObjectArray() { RemoveAll(); }
-
-  void Add(const ObjectClass& data) {
-    new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
-  }
-
-  ObjectClass& Add() {
-    return *(ObjectClass*)new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass();
-  }
-
-  void* AddSpace() { return InsertSpaceAt(m_nSize, 1); }
-
-  int32_t Append(const CFX_ObjectArray& src,
-                 int32_t nStart = 0,
-                 int32_t nCount = -1) {
-    if (nCount == 0) {
-      return 0;
-    }
-    int32_t nSize = src.GetSize();
-    if (!nSize) {
-      return 0;
-    }
-    ASSERT(nStart > -1 && nStart < nSize);
-    if (nCount < 0) {
-      nCount = nSize;
-    }
-    if (nStart + nCount > nSize) {
-      nCount = nSize - nStart;
-    }
-    if (nCount < 1) {
-      return 0;
-    }
-    nSize = m_nSize;
-    InsertSpaceAt(m_nSize, nCount);
-    ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
-    nSize = nStart + nCount;
-    for (int32_t i = nStart; i < nSize; i++, pStartObj++) {
-      new ((void*)pStartObj) ObjectClass(src[i]);
-    }
-    return nCount;
-  }
-
-  int32_t Copy(const CFX_ObjectArray& src,
-               int32_t nStart = 0,
-               int32_t nCount = -1) {
-    if (nCount == 0) {
-      return 0;
-    }
-    int32_t nSize = src.GetSize();
-    if (!nSize) {
-      return 0;
-    }
-    ASSERT(nStart > -1 && nStart < nSize);
-    if (nCount < 0) {
-      nCount = nSize;
-    }
-    if (nStart + nCount > nSize) {
-      nCount = nSize - nStart;
-    }
-    if (nCount < 1) {
-      return 0;
-    }
-    RemoveAll();
-    SetSize(nCount);
-    ObjectClass* pStartObj = (ObjectClass*)m_pData;
-    nSize = nStart + nCount;
-    for (int32_t i = nStart; i < nSize; i++, pStartObj++) {
-      new ((void*)pStartObj) ObjectClass(src[i]);
-    }
-    return nCount;
-  }
-
-  int GetSize() const { return m_nSize; }
-
-  ObjectClass& operator[](int index) const {
-    ASSERT(index < m_nSize);
-    return *(ObjectClass*)CFX_BasicArray::GetDataPtr(index);
-  }
-
-  ObjectClass* GetDataPtr(int index) {
-    return (ObjectClass*)CFX_BasicArray::GetDataPtr(index);
-  }
-
-  void RemoveAt(int index) {
-    ASSERT(index < m_nSize);
-    ((ObjectClass*)GetDataPtr(index))->~ObjectClass();
-    CFX_BasicArray::RemoveAt(index, 1);
-  }
-
-  void RemoveAll() {
-    for (int i = 0; i < m_nSize; i++) {
-      ((ObjectClass*)GetDataPtr(i))->~ObjectClass();
-    }
-    CFX_BasicArray::SetSize(0);
-  }
-};
 #endif  // PDF_ENABLE_XFA
 
 template <class DataType, int FixedSize>
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
index 4de5f70..c264e03 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/app/xfa_ffapp.cpp
@@ -11,6 +11,7 @@
 #include <utility>
 #include <vector>
 
+#include "third_party/base/stl_util.h"
 #include "xfa/fgas/font/cfgas_fontmgr.h"
 #include "xfa/fwl/cfwl_notedriver.h"
 #include "xfa/fwl/cfwl_widgetmgr.h"
@@ -33,13 +34,13 @@
   bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
 
  private:
-  CFX_ObjectArray<CPDF_StreamAcc> m_Data;
+  std::vector<std::unique_ptr<CPDF_StreamAcc>> m_Data;
 };
 
 CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) {
   for (CPDF_Stream* pStream : streams) {
-    CPDF_StreamAcc& acc = m_Data.Add();
-    acc.LoadAllData(pStream);
+    m_Data.push_back(pdfium::MakeUnique<CPDF_StreamAcc>());
+    m_Data.back()->LoadAllData(pStream);
   }
 }
 
@@ -47,35 +48,32 @@
 
 FX_FILESIZE CXFA_FileRead::GetSize() {
   uint32_t dwSize = 0;
-  int32_t iCount = m_Data.GetSize();
-  for (int32_t i = 0; i < iCount; i++) {
-    CPDF_StreamAcc& acc = m_Data[i];
-    dwSize += acc.GetSize();
-  }
+  for (const auto& acc : m_Data)
+    dwSize += acc->GetSize();
   return dwSize;
 }
 
 bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
-  int32_t iCount = m_Data.GetSize();
+  int32_t iCount = pdfium::CollectionSize<int32_t>(m_Data);
   int32_t index = 0;
   while (index < iCount) {
-    CPDF_StreamAcc& acc = m_Data[index];
-    FX_FILESIZE dwSize = acc.GetSize();
-    if (offset < dwSize) {
+    const auto& acc = m_Data[index];
+    FX_FILESIZE dwSize = acc->GetSize();
+    if (offset < dwSize)
       break;
-    }
+
     offset -= dwSize;
     index++;
   }
   while (index < iCount) {
-    CPDF_StreamAcc& acc = m_Data[index];
-    uint32_t dwSize = acc.GetSize();
+    const auto& acc = m_Data[index];
+    uint32_t dwSize = acc->GetSize();
     size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset));
-    FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead);
+    FXSYS_memcpy(buffer, acc->GetData() + offset, dwRead);
     size -= dwRead;
-    if (size == 0) {
+    if (size == 0)
       return true;
-    }
+
     buffer = (uint8_t*)buffer + dwRead;
     offset = 0;
     index++;