diff options
author | Lei Zhang <thestig@chromium.org> | 2018-09-17 17:11:54 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-09-17 17:11:54 +0000 |
commit | 35d3d550157a31eeaa6ec8bcd8b62233d1584acb (patch) | |
tree | a56fdb7e4e82d547afb5a3e9a663e87aad8ec63a /core/fpdfapi/parser | |
parent | 8071fc75da163ed66e5e3b5fa6e7869a63bfb8a7 (diff) | |
download | pdfium-35d3d550157a31eeaa6ec8bcd8b62233d1584acb.tar.xz |
Encapsulate CPDF_StreamAcc::LoadAllData().
Make it a private method, and add public methods so only limited
combinations of LoadAllData() arguments are possible.
Change-Id: I8c2220eb0e95012350858876586f7c470c40a7c3
Reviewed-on: https://pdfium-review.googlesource.com/42590
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream_acc.cpp | 14 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_stream_acc.h | 5 |
2 files changed, 18 insertions, 1 deletions
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp index 1083e3177e..78bcb57e0b 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.cpp +++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp @@ -20,6 +20,11 @@ CPDF_StreamAcc::~CPDF_StreamAcc() { void CPDF_StreamAcc::LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc) { + if (bRawAccess) { + ASSERT(!estimated_size); + ASSERT(!bImageAcc); + } + if (!m_pStream) return; @@ -63,6 +68,15 @@ void CPDF_StreamAcc::LoadAllDataFiltered() { LoadAllData(false, 0, false); } +void CPDF_StreamAcc::LoadAllDataFilteredWithEstimatedSize( + uint32_t estimated_size) { + LoadAllData(false, estimated_size, false); +} + +void CPDF_StreamAcc::LoadAllDataImageAcc(uint32_t estimated_size) { + LoadAllData(false, estimated_size, true); +} + void CPDF_StreamAcc::LoadAllDataRaw() { LoadAllData(true, 0, false); } diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h index fae8ba0516..3c42639828 100644 --- a/core/fpdfapi/parser/cpdf_stream_acc.h +++ b/core/fpdfapi/parser/cpdf_stream_acc.h @@ -24,8 +24,9 @@ class CPDF_StreamAcc final : public Retainable { CPDF_StreamAcc(const CPDF_StreamAcc&) = delete; CPDF_StreamAcc& operator=(const CPDF_StreamAcc&) = delete; - void LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc); void LoadAllDataFiltered(); + void LoadAllDataFilteredWithEstimatedSize(uint32_t estimated_size); + void LoadAllDataImageAcc(uint32_t estimated_size); void LoadAllDataRaw(); const CPDF_Stream* GetStream() const { return m_pStream.Get(); } @@ -44,6 +45,8 @@ class CPDF_StreamAcc final : public Retainable { explicit CPDF_StreamAcc(const CPDF_Stream* pStream); ~CPDF_StreamAcc() override; + void LoadAllData(bool bRawAccess, uint32_t estimated_size, bool bImageAcc); + private: uint8_t* m_pData = nullptr; uint32_t m_dwSize = 0; |