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

Side by Side Diff: core/fpdfapi/parser/cpdf_stream.h

Issue 2520493002: Make CPDF_Stream() take unique_ptr's to its dictionary. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_STREAM_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_STREAM_H_
9 9
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 12
13 #include "core/fpdfapi/parser/cpdf_dictionary.h" 13 #include "core/fpdfapi/parser/cpdf_dictionary.h"
14 #include "core/fpdfapi/parser/cpdf_object.h" 14 #include "core/fpdfapi/parser/cpdf_object.h"
15 #include "core/fxcrt/fx_basic.h" 15 #include "core/fxcrt/fx_basic.h"
16 16
17 class CPDF_Stream : public CPDF_Object { 17 class CPDF_Stream : public CPDF_Object {
18 public: 18 public:
19 CPDF_Stream(); 19 CPDF_Stream();
20 20
21 // Takes ownership of |pData| and |pDict|. 21 // Takes ownership of |pData| and |pDict|.
Lei Zhang 2016/11/18 23:50:34 Update comment.
Tom Sepez 2016/11/19 00:05:16 Done. I assume you meant removing the "and |pDict|
22 CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict); 22 CPDF_Stream(uint8_t* pData,
23 uint32_t size,
24 std::unique_ptr<CPDF_Dictionary> pDict);
25
23 ~CPDF_Stream() override; 26 ~CPDF_Stream() override;
24 27
25 // CPDF_Object: 28 // CPDF_Object:
26 Type GetType() const override; 29 Type GetType() const override;
27 std::unique_ptr<CPDF_Object> Clone() const override; 30 std::unique_ptr<CPDF_Object> Clone() const override;
28 CPDF_Dictionary* GetDict() const override; 31 CPDF_Dictionary* GetDict() const override;
29 CFX_WideString GetUnicodeText() const override; 32 CFX_WideString GetUnicodeText() const override;
30 bool IsStream() const override; 33 bool IsStream() const override;
31 CPDF_Stream* AsStream() override; 34 CPDF_Stream* AsStream() override;
32 const CPDF_Stream* AsStream() const override; 35 const CPDF_Stream* AsStream() const override;
33 36
34 uint32_t GetRawSize() const { return m_dwSize; } 37 uint32_t GetRawSize() const { return m_dwSize; }
35 uint8_t* GetRawData() const { return m_pDataBuf.get(); } 38 uint8_t* GetRawData() const { return m_pDataBuf.get(); }
36 39
37 // Does not takes onwership of |pData|, copies into internally-owned buffer. 40 // Does not takes onwership of |pData|, copies into internally-owned buffer.
38 void SetData(const uint8_t* pData, uint32_t size); 41 void SetData(const uint8_t* pData, uint32_t size);
39 42
40 void InitStream(const uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict); 43 void InitStream(const uint8_t* pData,
44 uint32_t size,
45 std::unique_ptr<CPDF_Dictionary> pDict);
41 void InitStreamFromFile(IFX_SeekableReadStream* pFile, 46 void InitStreamFromFile(IFX_SeekableReadStream* pFile,
42 CPDF_Dictionary* pDict); 47 std::unique_ptr<CPDF_Dictionary> pDict);
43 48
44 bool ReadRawData(FX_FILESIZE start_pos, 49 bool ReadRawData(FX_FILESIZE start_pos,
45 uint8_t* pBuf, 50 uint8_t* pBuf,
46 uint32_t buf_size) const; 51 uint32_t buf_size) const;
47 52
48 bool IsMemoryBased() const { return m_bMemoryBased; } 53 bool IsMemoryBased() const { return m_bMemoryBased; }
49 54
50 protected: 55 protected:
51 std::unique_ptr<CPDF_Object> CloneNonCyclic( 56 std::unique_ptr<CPDF_Object> CloneNonCyclic(
52 bool bDirect, 57 bool bDirect,
(...skipping 16 matching lines...) Expand all
69 74
70 inline std::unique_ptr<CPDF_Stream> ToStream(std::unique_ptr<CPDF_Object> obj) { 75 inline std::unique_ptr<CPDF_Stream> ToStream(std::unique_ptr<CPDF_Object> obj) {
71 CPDF_Stream* pStream = ToStream(obj.get()); 76 CPDF_Stream* pStream = ToStream(obj.get());
72 if (!pStream) 77 if (!pStream)
73 return nullptr; 78 return nullptr;
74 obj.release(); 79 obj.release();
75 return std::unique_ptr<CPDF_Stream>(pStream); 80 return std::unique_ptr<CPDF_Stream>(pStream);
76 } 81 }
77 82
78 #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_ 83 #endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698