diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-09 21:28:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-09 21:28:32 +0000 |
commit | 81981300c2892598784f8b7096d5143ac04293a7 (patch) | |
tree | 3ed5b42c0aaec60d63f90dab8f1d7f93c3366f15 /core/fpdfapi/edit/cpdf_flateencoder.h | |
parent | 607f3cd63a314cd3a6c219b19cce31805b66cd6d (diff) | |
download | pdfium-81981300c2892598784f8b7096d5143ac04293a7.tar.xz |
Split the MaybeOwned CPDF_Dictionary in CPDF_FlateEncoder.
The owned copy needs to be modified, so it should be non-const. Whereas
the unowned copy can be const.
Add a GetClonedDict() method for accessing the modifiable dictionary.
Change-Id: Ia7f6bcc5f917864cd1bbc7b5000a86f6e433ae9a
Reviewed-on: https://pdfium-review.googlesource.com/32181
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/edit/cpdf_flateencoder.h')
-rw-r--r-- | core/fpdfapi/edit/cpdf_flateencoder.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/fpdfapi/edit/cpdf_flateencoder.h b/core/fpdfapi/edit/cpdf_flateencoder.h index b2213de5f3..b69b54d93b 100644 --- a/core/fpdfapi/edit/cpdf_flateencoder.h +++ b/core/fpdfapi/edit/cpdf_flateencoder.h @@ -7,6 +7,8 @@ #ifndef CORE_FPDFAPI_EDIT_CPDF_FLATEENCODER_H_ #define CORE_FPDFAPI_EDIT_CPDF_FLATEENCODER_H_ +#include <memory> + #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fxcrt/fx_memory.h" @@ -21,16 +23,22 @@ class CPDF_FlateEncoder { ~CPDF_FlateEncoder(); void CloneDict(); + CPDF_Dictionary* GetClonedDict(); + + // Returns |m_pClonedDict| if it is valid. Otherwise returns |m_pDict|. + const CPDF_Dictionary* GetDict() const; uint32_t GetSize() const { return m_dwSize; } const uint8_t* GetData() const { return m_pData.Get(); } - CPDF_Dictionary* GetDict() { return m_pDict.Get(); } - private: uint32_t m_dwSize; MaybeOwned<uint8_t, FxFreeDeleter> m_pData; - MaybeOwned<CPDF_Dictionary> m_pDict; + + // Only one of these two pointers is valid at any time. + UnownedPtr<const CPDF_Dictionary> m_pDict; + std::unique_ptr<CPDF_Dictionary> m_pClonedDict; + RetainPtr<CPDF_StreamAcc> m_pAcc; }; |