summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-07 19:01:56 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-07 19:01:56 -0800
commit64f4e25304dfd93651ac5c9d5379ed2fffbb993f (patch)
tree67f755611451432631bd27c494236b8b6ee418b4 /xfa/fxfa/parser
parent1306b180a6a8e306a7d00db9cdaa983784c354ed (diff)
downloadpdfium-64f4e25304dfd93651ac5c9d5379ed2fffbb993f.tar.xz
Use unique_ptr for CXFA_XMLParser.
Also rename CFDE_XMLParser to IFDE_XMLParser since its an interface. Review-Url: https://codereview.chromium.org/2555373002
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp18
-rw-r--r--xfa/fxfa/parser/cxfa_xml_parser.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_xml_parser.h5
3 files changed, 13 insertions, 14 deletions
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 9eca652db7..9f6fef9c1f 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -6,6 +6,8 @@
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
+#include <utility>
+
#include "core/fxcrt/fx_ext.h"
#include "third_party/base/ptr_util.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -293,9 +295,11 @@ int32_t CXFA_SimpleParser::StartParse(
wCodePage != FX_CODEPAGE_UTF8) {
m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
}
- m_pXMLDoc.reset(new CFDE_XMLDoc);
- m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream);
- if (!m_pXMLDoc->LoadXML(m_pXMLParser))
+ m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>();
+ auto pNewParser =
+ pdfium::MakeUnique<CXFA_XMLParser>(m_pXMLDoc->GetRoot(), m_pStream);
+ m_pXMLParser = pNewParser.get();
+ if (!m_pXMLDoc->LoadXML(std::move(pNewParser)))
return XFA_PARSESTATUS_StatusErr;
m_ePacketID = ePacketID;
@@ -326,12 +330,12 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML,
IFX_Pause* pPause) {
CloseParser();
pXMLNode = nullptr;
-
- auto pStream = pdfium::MakeRetain<CXFA_WideTextRead>(wsXML);
m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>();
- CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), pStream);
+ auto pStream = pdfium::MakeRetain<CXFA_WideTextRead>(wsXML);
+ auto pParser =
+ pdfium::MakeUnique<CXFA_XMLParser>(m_pXMLDoc->GetRoot(), pStream);
pParser->m_dwCheckStatus = 0x03;
- if (!m_pXMLDoc->LoadXML(pParser))
+ if (!m_pXMLDoc->LoadXML(std::move(pParser)))
return XFA_PARSESTATUS_StatusErr;
int32_t iRet = m_pXMLDoc->DoLoad(pPause);
diff --git a/xfa/fxfa/parser/cxfa_xml_parser.cpp b/xfa/fxfa/parser/cxfa_xml_parser.cpp
index 6d2ef350d9..95920d9773 100644
--- a/xfa/fxfa/parser/cxfa_xml_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_xml_parser.cpp
@@ -29,10 +29,6 @@ CXFA_XMLParser::~CXFA_XMLParser() {
m_ws2.clear();
}
-void CXFA_XMLParser::Release() {
- delete this;
-}
-
int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) {
if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error)
return -1;
diff --git a/xfa/fxfa/parser/cxfa_xml_parser.h b/xfa/fxfa/parser/cxfa_xml_parser.h
index 4c64ee2f8c..e49a9dd127 100644
--- a/xfa/fxfa/parser/cxfa_xml_parser.h
+++ b/xfa/fxfa/parser/cxfa_xml_parser.h
@@ -14,14 +14,13 @@
class IFGAS_Stream;
class IFX_Pause;
-class CXFA_XMLParser : public CFDE_XMLParser {
+class CXFA_XMLParser : public IFDE_XMLParser {
public:
CXFA_XMLParser(CFDE_XMLNode* pRoot,
const CFX_RetainPtr<IFGAS_Stream>& pStream);
~CXFA_XMLParser() override;
- // CFDE_XMLParser
- void Release() override;
+ // IFDE_XMLParser
int32_t DoParser(IFX_Pause* pPause) override;
FX_FILESIZE m_nStart[2];