diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-30 16:12:02 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-30 20:26:02 +0000 |
commit | 0bb1333a9eff1190ddd68f34c71d6a779c69dfef (patch) | |
tree | 5a46946c4852f147309e2b1389e6f42d6553abf7 /fpdfsdk/fpdf_dataavail.cpp | |
parent | 908c848202ef137e98d96f82a4eadfae551403b7 (diff) | |
download | pdfium-0bb1333a9eff1190ddd68f34c71d6a779c69dfef.tar.xz |
Add some calls to MakeUnique
This CL replaces some new's with pdfium::MakeUnique.
Change-Id: I50faf3ed55e7730b094c14a7989a9dd51cf33cbb
Reviewed-on: https://pdfium-review.googlesource.com/3430
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_dataavail.cpp')
-rw-r--r-- | fpdfsdk/fpdf_dataavail.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp index b1bc1e3bc0..f2358d2e5c 100644 --- a/fpdfsdk/fpdf_dataavail.cpp +++ b/fpdfsdk/fpdf_dataavail.cpp @@ -60,9 +60,9 @@ class CFPDF_FileAvailWrap : public CPDF_DataAvail::FileAvail { class CFPDF_FileAccessWrap : public IFX_SeekableReadStream { public: - static CFX_RetainPtr<CFPDF_FileAccessWrap> Create() { - return CFX_RetainPtr<CFPDF_FileAccessWrap>(new CFPDF_FileAccessWrap()); - } + template <typename T, typename... Args> + friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + ~CFPDF_FileAccessWrap() override {} void Set(FPDF_FILEACCESS* pFile) { m_pFileAccess = pFile; } @@ -101,8 +101,8 @@ class CFPDF_DownloadHintsWrap : public CPDF_DataAvail::DownloadHints { class CFPDF_DataAvail { public: CFPDF_DataAvail() - : m_FileAvail(new CFPDF_FileAvailWrap), - m_FileRead(CFPDF_FileAccessWrap::Create()) {} + : m_FileAvail(pdfium::MakeUnique<CFPDF_FileAvailWrap>()), + m_FileRead(pdfium::MakeRetain<CFPDF_FileAccessWrap>()) {} ~CFPDF_DataAvail() {} std::unique_ptr<CPDF_DataAvail> m_pDataAvail; @@ -145,11 +145,10 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { if (!pDataAvail) return nullptr; - std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser); + auto pParser = pdfium::MakeUnique<CPDF_Parser>(); pParser->SetPassword(password); - std::unique_ptr<CPDF_Document> pDocument( - new CPDF_Document(std::move(pParser))); + auto pDocument = pdfium::MakeUnique<CPDF_Document>(std::move(pParser)); CPDF_Parser::Error error = pDocument->GetParser()->StartLinearizedParse( pDataAvail->m_pDataAvail->GetFileRead(), pDocument.get()); if (error != CPDF_Parser::SUCCESS) { |