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

Unified Diff: xfa/fxfa/app/xfa_ffdoc.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 | « xfa/fxfa/app/xfa_ffapp_unittest.cpp ('k') | xfa/fxfa/app/xfa_ffwidget.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxfa/app/xfa_ffdoc.cpp
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp
index e719a41c63c6853243b22dffd7ad1d2e8cfccf03..917c8539911b36d2355cf21b24ede983ad32dca4 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -152,12 +152,10 @@ int32_t Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) {
CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment)
: m_pDocEnvironment(pDocEnvironment),
m_pDocumentParser(nullptr),
- m_pStream(nullptr),
m_pApp(pApp),
m_pNotify(nullptr),
m_pPDFDoc(nullptr),
- m_dwDocType(XFA_DOCTYPE_Static),
- m_bOwnStream(true) {}
+ m_dwDocType(XFA_DOCTYPE_Static) {}
CXFA_FFDoc::~CXFA_FFDoc() {
CloseDoc();
@@ -292,8 +290,7 @@ CXFA_FFDocView* CXFA_FFDoc::GetDocView() {
return it != m_TypeToDocViewMap.end() ? it->second.get() : nullptr;
}
-bool CXFA_FFDoc::OpenDoc(IFX_SeekableReadStream* pStream, bool bTakeOverFile) {
- m_bOwnStream = bTakeOverFile;
+bool CXFA_FFDoc::OpenDoc(const CFX_RetainPtr<IFX_SeekableReadStream>& pStream) {
m_pStream = pStream;
return true;
}
@@ -326,14 +323,8 @@ bool CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) {
if (xfaStreams.empty())
return false;
- IFX_SeekableReadStream* pFileRead = MakeSeekableReadStream(xfaStreams);
m_pPDFDoc = pPDFDoc;
- if (m_pStream) {
- m_pStream->Release();
- m_pStream = nullptr;
- }
- m_pStream = pFileRead;
- m_bOwnStream = true;
+ m_pStream = MakeSeekableReadStream(xfaStreams);
return true;
}
@@ -351,11 +342,6 @@ bool CXFA_FFDoc::CloseDoc() {
m_pNotify.reset(nullptr);
m_pApp->GetXFAFontMgr()->ReleaseDocFonts(this);
- if (m_dwDocType != XFA_DOCTYPE_XDP && m_pStream && m_bOwnStream) {
- m_pStream->Release();
- m_pStream = nullptr;
- }
-
for (const auto& pair : m_HashToDibDpiMap)
delete pair.second.pDibSource;
@@ -417,21 +403,21 @@ CFX_DIBitmap* CXFA_FFDoc::GetPDFNamedImage(const CFX_WideStringC& wsName,
CPDF_StreamAcc streamAcc;
streamAcc.LoadAllData(pStream);
- IFX_SeekableReadStream* pImageFileRead = IFX_MemoryStream::Create(
- (uint8_t*)streamAcc.GetData(), streamAcc.GetSize());
+ CFX_RetainPtr<IFX_SeekableReadStream> pImageFileRead =
+ IFX_MemoryStream::Create((uint8_t*)streamAcc.GetData(),
+ streamAcc.GetSize());
CFX_DIBitmap* pDibSource = XFA_LoadImageFromBuffer(
pImageFileRead, FXCODEC_IMAGE_UNKNOWN, iImageXDpi, iImageYDpi);
m_HashToDibDpiMap[dwHash] = {pDibSource, iImageXDpi, iImageYDpi};
- pImageFileRead->Release();
return pDibSource;
}
-bool CXFA_FFDoc::SavePackage(XFA_HashCode code,
- IFX_SeekableWriteStream* pFile,
- CXFA_ChecksumContext* pCSContext) {
+bool CXFA_FFDoc::SavePackage(
+ XFA_HashCode code,
+ const CFX_RetainPtr<IFX_SeekableWriteStream>& pFile,
+ CXFA_ChecksumContext* pCSContext) {
CXFA_Document* doc = m_pDocumentParser->GetDocument();
-
std::unique_ptr<CXFA_DataExporter> pExport(new CXFA_DataExporter(doc));
CXFA_Node* pNode = code == XFA_HASHCODE_Xfa ? doc->GetRoot()
: ToNode(doc->GetXFAObject(code));
@@ -446,8 +432,10 @@ bool CXFA_FFDoc::SavePackage(XFA_HashCode code,
pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr);
}
-bool CXFA_FFDoc::ImportData(IFX_SeekableReadStream* pStream, bool bXDP) {
- std::unique_ptr<CXFA_DataImporter> importer(
- new CXFA_DataImporter(m_pDocumentParser->GetDocument()));
+bool CXFA_FFDoc::ImportData(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
+ bool bXDP) {
+ auto importer =
+ pdfium::MakeUnique<CXFA_DataImporter>(m_pDocumentParser->GetDocument());
return importer->ImportData(pStream);
}
« no previous file with comments | « xfa/fxfa/app/xfa_ffapp_unittest.cpp ('k') | xfa/fxfa/app/xfa_ffwidget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698