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

Unified Diff: core/fxcrt/fx_extension.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
Index: core/fxcrt/fx_extension.cpp
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 6bf61f1fb574a054e5136ee53ce44c9b130a380a..27f9971f6c239a132d25b4eef75306963c5d2106 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -21,6 +21,24 @@
#ifdef PDF_ENABLE_XFA
+class CFX_CRTFileAccess : public IFX_FileAccess {
+ public:
+ CFX_CRTFileAccess();
+ ~CFX_CRTFileAccess() override;
+
+ // IFX_FileAccess
+ void Release() override;
+ IFX_FileAccess* Retain() override;
+ void GetPath(CFX_WideString& wsPath) override;
+ IFX_SeekableStream* CreateFileStream(uint32_t dwModes) override;
+
+ bool Init(const CFX_WideStringC& wsPath);
+
+ protected:
npm 2016/12/01 21:21:49 Can this be private?
Tom Sepez 2016/12/01 21:33:45 Done.
+ CFX_WideString m_path;
+ uint32_t m_RefCount;
+};
+
CFX_CRTFileAccess::CFX_CRTFileAccess() : m_RefCount(0) {}
CFX_CRTFileAccess::~CFX_CRTFileAccess() {}
@@ -51,11 +69,71 @@ bool CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) {
#endif // PDF_ENABLE_XFA
+class CFX_CRTFileStream final : public IFX_SeekableStream {
+ public:
+ explicit CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA);
+ ~CFX_CRTFileStream() override;
+
+ // IFX_SeekableStream:
+ IFX_SeekableStream* Retain() override;
+ void Release() override;
+ FX_FILESIZE GetSize() override;
+ bool IsEOF() override;
+ FX_FILESIZE GetPosition() override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ size_t ReadBlock(void* buffer, size_t size) override;
+ bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool Flush() override;
+
+ protected:
npm 2016/12/01 21:21:49 Ditto
Tom Sepez 2016/12/01 21:33:45 Done.
+ std::unique_ptr<IFXCRT_FileAccess> m_pFile;
+ uint32_t m_dwCount;
+};
+
CFX_CRTFileStream::CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA)
: m_pFile(std::move(pFA)), m_dwCount(1) {}
CFX_CRTFileStream::~CFX_CRTFileStream() {}
npm 2016/12/01 21:21:49 Can you place the other methods in CFX_CRTFileStre
Tom Sepez 2016/12/01 21:33:45 Ooops. Pasted in wrong place. fixed.
+#define FX_MEMSTREAM_BlockSize (64 * 1024)
+#define FX_MEMSTREAM_Consecutive 0x01
+#define FX_MEMSTREAM_TakeOver 0x02
+
+class CFX_MemoryStream final : public IFX_MemoryStream {
+ public:
+ explicit CFX_MemoryStream(bool bConsecutive);
+ CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, bool bTakeOver);
+ ~CFX_MemoryStream() override;
+
+ // IFX_MemoryStream
+ IFX_SeekableStream* Retain() override;
+ void Release() override;
+ FX_FILESIZE GetSize() override;
+ bool IsEOF() override;
+ FX_FILESIZE GetPosition() override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ size_t ReadBlock(void* buffer, size_t size) override;
+ bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool Flush() override;
+ bool IsConsecutive() const override;
+ void EstimateSize(size_t nInitSize, size_t nGrowSize) override;
+ uint8_t* GetBuffer() const override;
+ void AttachBuffer(uint8_t* pBuffer,
+ size_t nSize,
+ bool bTakeOver = false) override;
+ void DetachBuffer() override;
+
+ protected:
npm 2016/12/01 21:21:49 Ditto private?
Tom Sepez 2016/12/01 21:33:45 Done. Protected on a final class is always wrong.
+ CFX_ArrayTemplate<uint8_t*> m_Blocks;
+ uint32_t m_dwCount;
+ size_t m_nTotalSize;
+ size_t m_nCurSize;
+ size_t m_nCurPos;
+ size_t m_nGrowSize;
+ uint32_t m_dwFlags;
+ bool ExpandBlocks(size_t size);
+};
+
CFX_MemoryStream::CFX_MemoryStream(bool bConsecutive)
: m_dwCount(1),
m_nTotalSize(0),
« no previous file with comments | « core/fxcrt/extension.h ('k') | fpdfsdk/fpdfeditimg.cpp » ('j') | fpdfsdk/fpdfview.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698