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

Unified Diff: core/fpdfapi/fpdf_parser/include/cpdf_stream.h

Issue 2347993002: Clean up CPDF_Stream. (Closed)
Patch Set: ctor Created 4 years, 3 months 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 | « core/fpdfapi/fpdf_parser/cpdf_stream.cpp ('k') | core/fpdfdoc/cpvt_generateap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_parser/include/cpdf_stream.h
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_stream.h b/core/fpdfapi/fpdf_parser/include/cpdf_stream.h
index 7ea761ef51d257796003447f380e10e7f585899f..b39b20a1e9318651e591c5f7e09ca2b50b5b1222 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_stream.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_stream.h
@@ -7,14 +7,18 @@
#ifndef CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_
#define CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_
+#include <memory>
#include <set>
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
-#include "core/fxcrt/include/fx_stream.h"
+#include "core/fxcrt/include/fx_basic.h"
class CPDF_Stream : public CPDF_Object {
public:
+ CPDF_Stream();
+
+ // Takes onwership of |pData| and |pDict|.
CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
dsinclair 2016/09/19 13:12:18 Can we pass through a std::unique_ptr to make the
// CPDF_Object.
@@ -27,12 +31,10 @@ class CPDF_Stream : public CPDF_Object {
const CPDF_Stream* AsStream() const override;
uint32_t GetRawSize() const { return m_dwSize; }
- uint8_t* GetRawData() const { return m_pDataBuf; }
+ uint8_t* GetRawData() const { return m_pDataBuf.get(); }
- void SetData(const uint8_t* pData,
- uint32_t size,
- FX_BOOL bCompressed,
- FX_BOOL bKeepBuf);
+ // Does not takes onwership of |pData|, copies into internally-owned buffer.
+ void SetData(const uint8_t* pData, uint32_t size);
void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
void InitStreamFromFile(IFX_FileRead* pFile, CPDF_Dictionary* pDict);
@@ -41,26 +43,19 @@ class CPDF_Stream : public CPDF_Object {
uint8_t* pBuf,
uint32_t buf_size) const;
- bool IsMemoryBased() const { return m_GenNum == kMemoryBasedGenNum; }
+ bool IsMemoryBased() const { return m_bMemoryBased; }
protected:
- static const uint32_t kMemoryBasedGenNum = (uint32_t)-1;
-
~CPDF_Stream() override;
CPDF_Object* CloneNonCyclic(
bool bDirect,
std::set<const CPDF_Object*>* pVisited) const override;
- void InitStreamInternal(CPDF_Dictionary* pDict);
-
- CPDF_Dictionary* m_pDict;
- uint32_t m_dwSize;
- uint32_t m_GenNum;
-
- union {
- uint8_t* m_pDataBuf;
- IFX_FileRead* m_pFile;
- };
+ std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> m_pDict;
+ bool m_bMemoryBased = true;
+ uint32_t m_dwSize = 0;
+ std::unique_ptr<uint8_t, FxFreeDeleter> m_pDataBuf;
+ IFX_FileRead* m_pFile = nullptr;
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_STREAM_H_
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_stream.cpp ('k') | core/fpdfdoc/cpvt_generateap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698