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

Unified Diff: fpdfsdk/fpdfview.cpp

Issue 2545653003: Make more concrete stream classes private to .cpp files (Closed)
Patch Set: {} 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 | « fpdfsdk/fpdfeditimg.cpp ('k') | fpdfsdk/fsdk_define.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fpdfview.cpp
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index 633cbe879e1274a6a16c0af93b1afb034e3d4576..449433ed9003e9703f35b448494f456af8ec39e9 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -117,6 +117,47 @@ void RenderPageImpl(CPDF_PageRenderContext* pContext,
pContext->m_pDevice->RestoreState(false);
}
+class CPDF_CustomAccess final : public IFX_SeekableReadStream {
+ public:
+ explicit CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess);
+ ~CPDF_CustomAccess() override {}
+
+ // IFX_SeekableReadStream
+ FX_FILESIZE GetSize() override;
+ void Release() override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+
+ private:
+ FPDF_FILEACCESS m_FileAccess;
+};
+
+CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess)
+ : m_FileAccess(*pFileAccess) {}
+
+FX_FILESIZE CPDF_CustomAccess::GetSize() {
+ return m_FileAccess.m_FileLen;
+}
+
+void CPDF_CustomAccess::Release() {
+ delete this;
+}
+
+bool CPDF_CustomAccess::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (offset < 0)
+ return false;
+
+ FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE>(size);
+ newPos += offset;
+ if (!newPos.IsValid() ||
+ newPos.ValueOrDie() > static_cast<FX_FILESIZE>(m_FileAccess.m_FileLen)) {
+ return false;
+ }
+ return !!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,
+ reinterpret_cast<uint8_t*>(buffer), size);
+}
+
} // namespace
UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) {
@@ -246,31 +287,8 @@ bool CFPDF_FileStream::Flush() {
}
#endif // PDF_ENABLE_XFA
-CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess)
- : m_FileAccess(*pFileAccess) {}
-
-FX_FILESIZE CPDF_CustomAccess::GetSize() {
- return m_FileAccess.m_FileLen;
-}
-
-void CPDF_CustomAccess::Release() {
- delete this;
-}
-
-bool CPDF_CustomAccess::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- if (offset < 0)
- return false;
-
- FX_SAFE_FILESIZE newPos = pdfium::base::checked_cast<FX_FILESIZE>(size);
- newPos += offset;
- if (!newPos.IsValid() ||
- newPos.ValueOrDie() > static_cast<FX_FILESIZE>(m_FileAccess.m_FileLen)) {
- return false;
- }
- return !!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,
- reinterpret_cast<uint8_t*>(buffer), size);
+IFX_SeekableReadStream* MakeSeekableReadStream(FPDF_FILEACCESS* pFileAccess) {
+ return new CPDF_CustomAccess(pFileAccess);
}
// 0 bit: FPDF_POLICY_MACHINETIME_ACCESS
« no previous file with comments | « fpdfsdk/fpdfeditimg.cpp ('k') | fpdfsdk/fsdk_define.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698