summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-01 13:54:42 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-01 13:54:42 -0800
commitbea049784abf7c32d0b9758fc77d0e601d5c232b (patch)
tree8cb30eec48538191531ead20100d4e696fa6ebef /core
parentaeeb6d19d1fc794de482826ecaf8ec2fd9e92d0e (diff)
downloadpdfium-bea049784abf7c32d0b9758fc77d0e601d5c232b.tar.xz
Make more concrete stream classes private to .cpp files
Review-Url: https://codereview.chromium.org/2545653003
Diffstat (limited to 'core')
-rw-r--r--core/fxcrt/extension.h80
-rw-r--r--core/fxcrt/fx_extension.cpp166
2 files changed, 123 insertions, 123 deletions
diff --git a/core/fxcrt/extension.h b/core/fxcrt/extension.h
index ca2fc3c5b7..b62f67772b 100644
--- a/core/fxcrt/extension.h
+++ b/core/fxcrt/extension.h
@@ -34,86 +34,6 @@ class IFXCRT_FileAccess {
virtual bool Truncate(FX_FILESIZE szFile) = 0;
};
-#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:
- CFX_WideString m_path;
- uint32_t m_RefCount;
-};
-#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:
- std::unique_ptr<IFXCRT_FileAccess> m_pFile;
- uint32_t m_dwCount;
-};
-
-#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:
- 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);
-};
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 6bf61f1fb5..aa3841e31c 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -19,8 +19,28 @@
#include <ctime>
#endif
+namespace {
+
#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);
+
+ private:
+ CFX_WideString m_path;
+ uint32_t m_RefCount;
+};
+
CFX_CRTFileAccess::CFX_CRTFileAccess() : m_RefCount(0) {}
CFX_CRTFileAccess::~CFX_CRTFileAccess() {}
@@ -51,10 +71,112 @@ 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;
+
+ private:
+ 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() {}
+IFX_SeekableStream* CFX_CRTFileStream::Retain() {
+ m_dwCount++;
+ return this;
+}
+
+void CFX_CRTFileStream::Release() {
+ uint32_t nCount = --m_dwCount;
+ if (!nCount)
+ delete this;
+}
+
+FX_FILESIZE CFX_CRTFileStream::GetSize() {
+ return m_pFile->GetSize();
+}
+
+bool CFX_CRTFileStream::IsEOF() {
+ return GetPosition() >= GetSize();
+}
+
+FX_FILESIZE CFX_CRTFileStream::GetPosition() {
+ return m_pFile->GetPosition();
+}
+
+bool CFX_CRTFileStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ return m_pFile->ReadPos(buffer, size, offset) > 0;
+}
+
+size_t CFX_CRTFileStream::ReadBlock(void* buffer, size_t size) {
+ return m_pFile->Read(buffer, size);
+}
+
+bool CFX_CRTFileStream::WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ return !!m_pFile->WritePos(buffer, size, offset);
+}
+
+bool CFX_CRTFileStream::Flush() {
+ return m_pFile->Flush();
+}
+
+#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;
+
+ private:
+ 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),
@@ -283,49 +405,7 @@ bool CFX_MemoryStream::ExpandBlocks(size_t size) {
return true;
}
-IFX_SeekableStream* CFX_CRTFileStream::Retain() {
- m_dwCount++;
- return this;
-}
-
-void CFX_CRTFileStream::Release() {
- uint32_t nCount = --m_dwCount;
- if (!nCount) {
- delete this;
- }
-}
-
-FX_FILESIZE CFX_CRTFileStream::GetSize() {
- return m_pFile->GetSize();
-}
-
-bool CFX_CRTFileStream::IsEOF() {
- return GetPosition() >= GetSize();
-}
-
-FX_FILESIZE CFX_CRTFileStream::GetPosition() {
- return m_pFile->GetPosition();
-}
-
-bool CFX_CRTFileStream::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- return m_pFile->ReadPos(buffer, size, offset) > 0;
-}
-
-size_t CFX_CRTFileStream::ReadBlock(void* buffer, size_t size) {
- return m_pFile->Read(buffer, size);
-}
-
-bool CFX_CRTFileStream::WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- return !!m_pFile->WritePos(buffer, size, offset);
-}
-
-bool CFX_CRTFileStream::Flush() {
- return m_pFile->Flush();
-}
+} // namespace
#ifdef PDF_ENABLE_XFA
IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) {