Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2421)

Unified Diff: core/fxcrt/fx_xml_parser.cpp

Issue 2560783003: Catch stray Retains() and Releases() outside of RetainPtr<>. (Closed)
Patch Set: override required per chrome style Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fxcrt/fx_extension.cpp ('k') | xfa/fgas/crt/fgas_stream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcrt/fx_xml_parser.cpp
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index ab309263878fadf7df61d0ffa5f9c1fb5518c6e9..1b562c20830b9bb098c5b7208a4eaff8306bd7b7 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -70,8 +70,8 @@ bool g_FXCRT_XML_IsNameChar(uint8_t ch) {
class CXML_DataBufAcc : public IFX_BufferedReadStream {
public:
- CXML_DataBufAcc(const uint8_t* pBuffer, size_t size);
- ~CXML_DataBufAcc() override;
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// IFX_BufferedReadStream
bool IsEOF() override;
@@ -83,6 +83,9 @@ class CXML_DataBufAcc : public IFX_BufferedReadStream {
FX_FILESIZE GetBlockOffset() override;
private:
+ CXML_DataBufAcc(const uint8_t* pBuffer, size_t size);
+ ~CXML_DataBufAcc() override;
+
const uint8_t* m_pBuffer;
size_t m_dwSize;
size_t m_dwCurPos;
@@ -130,9 +133,8 @@ FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() {
class CXML_DataStmAcc : public IFX_BufferedReadStream {
public:
- explicit CXML_DataStmAcc(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
- ~CXML_DataStmAcc() override;
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
// IFX_BufferedReadStream
bool IsEOF() override;
@@ -144,6 +146,10 @@ class CXML_DataStmAcc : public IFX_BufferedReadStream {
FX_FILESIZE GetBlockOffset() override;
private:
+ explicit CXML_DataStmAcc(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
+ ~CXML_DataStmAcc() override;
+
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
uint8_t* m_pBuffer;
FX_FILESIZE m_nStart;
@@ -215,12 +221,12 @@ CXML_Parser::CXML_Parser()
CXML_Parser::~CXML_Parser() {}
bool CXML_Parser::Init(uint8_t* pBuffer, size_t size) {
- m_pDataAcc.Reset(new CXML_DataBufAcc(pBuffer, size));
+ m_pDataAcc = pdfium::MakeRetain<CXML_DataBufAcc>(pBuffer, size);
return Init();
}
bool CXML_Parser::Init(const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead) {
- m_pDataAcc.Reset(new CXML_DataStmAcc(pFileRead));
+ m_pDataAcc = pdfium::MakeRetain<CXML_DataStmAcc>(pFileRead);
return Init();
}
« no previous file with comments | « core/fxcrt/fx_extension.cpp ('k') | xfa/fgas/crt/fgas_stream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698