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

Unified Diff: core/fpdfapi/parser/cfdf_document.cpp

Issue 2451493002: Refcount all the IFX_ stream classes all the time. (Closed)
Patch Set: Clean up cast expression 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/fpdfapi/parser/cfdf_document.h ('k') | core/fpdfapi/parser/cpdf_data_avail.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cfdf_document.cpp
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index a6045e7795e37a359c18ee92a1bbcef57a43a933..65755520c08d7c6cbb0eb24ef721bd560c98a4c7 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -15,15 +15,9 @@
#include "third_party/base/ptr_util.h"
CFDF_Document::CFDF_Document()
- : CPDF_IndirectObjectHolder(),
- m_pRootDict(nullptr),
- m_pFile(nullptr),
- m_bOwnFile(false) {}
-
-CFDF_Document::~CFDF_Document() {
- if (m_bOwnFile && m_pFile)
- m_pFile->Release();
-}
+ : CPDF_IndirectObjectHolder(), m_pRootDict(nullptr) {}
+
+CFDF_Document::~CFDF_Document() {}
std::unique_ptr<CFDF_Document> CFDF_Document::CreateNewDoc() {
auto pDoc = pdfium::MakeUnique<CFDF_Document>();
@@ -33,25 +27,23 @@ std::unique_ptr<CFDF_Document> CFDF_Document::CreateNewDoc() {
}
std::unique_ptr<CFDF_Document> CFDF_Document::ParseFile(
- IFX_SeekableReadStream* pFile,
- bool bOwnFile) {
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFile) {
if (!pFile)
return nullptr;
auto pDoc = pdfium::MakeUnique<CFDF_Document>();
- pDoc->ParseStream(pFile, bOwnFile);
+ pDoc->ParseStream(pFile);
return pDoc->m_pRootDict ? std::move(pDoc) : nullptr;
}
-std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(const uint8_t* pData,
+std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(uint8_t* pData,
uint32_t size) {
- return CFDF_Document::ParseFile(
- IFX_MemoryStream::Create((uint8_t*)pData, size), true);
+ return CFDF_Document::ParseFile(IFX_MemoryStream::Create(pData, size));
}
-void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) {
+void CFDF_Document::ParseStream(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFile) {
m_pFile = pFile;
- m_bOwnFile = bOwnFile;
CPDF_SyntaxParser parser;
parser.InitParser(m_pFile, 0);
while (1) {
« no previous file with comments | « core/fpdfapi/parser/cfdf_document.h ('k') | core/fpdfapi/parser/cpdf_data_avail.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698