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

Unified Diff: xfa/fxfa/app/xfa_ffapp.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_checksum.cpp ('k') | xfa/fxfa/app/xfa_ffapp_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxfa/app/xfa_ffapp.cpp
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
index 9c0411b731e1b7f3c941db991126f0cebdc58c2b..a0674b6522106c3df6ec9b254939d5618616a5d7 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/app/xfa_ffapp.cpp
@@ -31,7 +31,6 @@ class CXFA_FileRead : public IFX_SeekableReadStream {
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override;
bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
- void Release() override;
private:
CFX_ObjectArray<CPDF_StreamAcc> m_Data;
@@ -84,15 +83,11 @@ bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
return false;
}
-void CXFA_FileRead::Release() {
- delete this;
-}
-
} // namespace
-IFX_SeekableReadStream* MakeSeekableReadStream(
+CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream(
const std::vector<CPDF_Stream*>& streams) {
- return new CXFA_FileRead(streams);
+ return CFX_RetainPtr<IFX_SeekableReadStream>(new CXFA_FileRead(streams));
}
CXFA_FFApp::CXFA_FFApp(IXFA_AppProvider* pProvider)
@@ -108,12 +103,11 @@ CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() {
return m_pDocHandler.get();
}
-CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment,
- IFX_SeekableReadStream* pStream,
- bool bTakeOverFile) {
- std::unique_ptr<CXFA_FFDoc> pDoc(new CXFA_FFDoc(this, pDocEnvironment));
- bool bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile);
- return bSuccess ? pDoc.release() : nullptr;
+CXFA_FFDoc* CXFA_FFApp::CreateDoc(
+ IXFA_DocEnvironment* pDocEnvironment,
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pStream) {
+ auto pDoc = pdfium::MakeUnique<CXFA_FFDoc>(this, pDocEnvironment);
+ return pDoc->OpenDoc(pStream) ? pDoc.release() : nullptr;
}
CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment,
« no previous file with comments | « xfa/fxfa/app/xfa_checksum.cpp ('k') | xfa/fxfa/app/xfa_ffapp_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698