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

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

Issue 2479303002: Use unique_ptr return from CPDF_Parser::ParseIndirectObject() (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_PARSER_H_ 7 #ifndef CORE_FPDFAPI_PARSER_CPDF_PARSER_H_
8 #define CORE_FPDFAPI_PARSER_CPDF_PARSER_H_ 8 #define CORE_FPDFAPI_PARSER_CPDF_PARSER_H_
9 9
10 #include <map> 10 #include <map>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 CPDF_Dictionary* GetTrailer() const { return m_pTrailer; } 51 CPDF_Dictionary* GetTrailer() const { return m_pTrailer; }
52 FX_FILESIZE GetLastXRefOffset() const { return m_LastXRefOffset; } 52 FX_FILESIZE GetLastXRefOffset() const { return m_LastXRefOffset; }
53 53
54 uint32_t GetPermissions() const; 54 uint32_t GetPermissions() const;
55 uint32_t GetRootObjNum(); 55 uint32_t GetRootObjNum();
56 uint32_t GetInfoObjNum(); 56 uint32_t GetInfoObjNum();
57 CPDF_Array* GetIDArray(); 57 CPDF_Array* GetIDArray();
58 58
59 CPDF_Dictionary* GetEncryptDict() const { return m_pEncryptDict; } 59 CPDF_Dictionary* GetEncryptDict() const { return m_pEncryptDict; }
60 60
61 CPDF_Object* ParseIndirectObject(CPDF_IndirectObjectHolder* pObjList, 61 std::unique_ptr<CPDF_Object> ParseIndirectObject(
62 uint32_t objnum); 62 CPDF_IndirectObjectHolder* pObjList,
63 uint32_t objnum);
63 64
64 uint32_t GetLastObjNum() const; 65 uint32_t GetLastObjNum() const;
65 bool IsValidObjectNumber(uint32_t objnum) const; 66 bool IsValidObjectNumber(uint32_t objnum) const;
66 FX_FILESIZE GetObjectPositionOrZero(uint32_t objnum) const; 67 FX_FILESIZE GetObjectPositionOrZero(uint32_t objnum) const;
67 uint8_t GetObjectType(uint32_t objnum) const; 68 uint8_t GetObjectType(uint32_t objnum) const;
68 uint16_t GetObjectGenNum(uint32_t objnum) const; 69 uint16_t GetObjectGenNum(uint32_t objnum) const;
69 bool IsVersionUpdated() const { return m_bVersionUpdated; } 70 bool IsVersionUpdated() const { return m_bVersionUpdated; }
70 bool IsObjectFreeOrNull(uint32_t objnum) const; 71 bool IsObjectFreeOrNull(uint32_t objnum) const;
71 CPDF_CryptoHandler* GetCryptoHandler(); 72 CPDF_CryptoHandler* GetCryptoHandler();
72 IFX_SeekableReadStream* GetFileAccess() const; 73 IFX_SeekableReadStream* GetFileAccess() const;
73 74
74 FX_FILESIZE GetObjectOffset(uint32_t objnum) const; 75 FX_FILESIZE GetObjectOffset(uint32_t objnum) const;
75 FX_FILESIZE GetObjectSize(uint32_t objnum) const; 76 FX_FILESIZE GetObjectSize(uint32_t objnum) const;
76 77
77 void GetIndirectBinary(uint32_t objnum, uint8_t*& pBuffer, uint32_t& size); 78 void GetIndirectBinary(uint32_t objnum, uint8_t*& pBuffer, uint32_t& size);
78 int GetFileVersion() const { return m_FileVersion; } 79 int GetFileVersion() const { return m_FileVersion; }
79 bool IsXRefStream() const { return m_bXRefStream; } 80 bool IsXRefStream() const { return m_bXRefStream; }
80 81
81 CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjectHolder* pObjList, 82 std::unique_ptr<CPDF_Object> ParseIndirectObjectAt(
82 FX_FILESIZE pos, 83 CPDF_IndirectObjectHolder* pObjList,
83 uint32_t objnum); 84 FX_FILESIZE pos,
85 uint32_t objnum);
84 86
85 CPDF_Object* ParseIndirectObjectAtByStrict( 87 std::unique_ptr<CPDF_Object> ParseIndirectObjectAtByStrict(
86 CPDF_IndirectObjectHolder* pObjList, 88 CPDF_IndirectObjectHolder* pObjList,
87 FX_FILESIZE pos, 89 FX_FILESIZE pos,
88 uint32_t objnum, 90 uint32_t objnum,
89 FX_FILESIZE* pResultPos); 91 FX_FILESIZE* pResultPos);
90 92
91 uint32_t GetFirstPageNo() const { return m_dwFirstPageNo; } 93 uint32_t GetFirstPageNo() const { return m_dwFirstPageNo; }
92 94
93 protected: 95 protected:
94 struct ObjectInfo { 96 struct ObjectInfo {
95 ObjectInfo() : pos(0), type(0), gennum(0) {} 97 ObjectInfo() : pos(0), type(0), gennum(0) {}
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 int m_FileVersion; 152 int m_FileVersion;
151 CPDF_Dictionary* m_pTrailer; 153 CPDF_Dictionary* m_pTrailer;
152 CPDF_Dictionary* m_pEncryptDict; 154 CPDF_Dictionary* m_pEncryptDict;
153 FX_FILESIZE m_LastXRefOffset; 155 FX_FILESIZE m_LastXRefOffset;
154 bool m_bXRefStream; 156 bool m_bXRefStream;
155 std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler; 157 std::unique_ptr<CPDF_SecurityHandler> m_pSecurityHandler;
156 CFX_ByteString m_Password; 158 CFX_ByteString m_Password;
157 std::set<FX_FILESIZE> m_SortedOffset; 159 std::set<FX_FILESIZE> m_SortedOffset;
158 std::vector<CPDF_Dictionary*> m_Trailers; 160 std::vector<CPDF_Dictionary*> m_Trailers;
159 bool m_bVersionUpdated; 161 bool m_bVersionUpdated;
160 CPDF_Object* m_pLinearized; 162 std::unique_ptr<CPDF_Object> m_pLinearized;
161 uint32_t m_dwFirstPageNo; 163 uint32_t m_dwFirstPageNo;
162 uint32_t m_dwXrefStartObjNum; 164 uint32_t m_dwXrefStartObjNum;
163 165
164 // A map of object numbers to indirect streams. Map owns the streams. 166 // A map of object numbers to indirect streams. Map owns the streams.
165 std::map<uint32_t, std::unique_ptr<CPDF_StreamAcc>> m_ObjectStreamMap; 167 std::map<uint32_t, std::unique_ptr<CPDF_StreamAcc>> m_ObjectStreamMap;
166 168
167 // Mapping of object numbers to offsets. The offsets are relative to the first 169 // Mapping of object numbers to offsets. The offsets are relative to the first
168 // object in the stream. 170 // object in the stream.
169 using StreamObjectCache = std::map<uint32_t, uint32_t>; 171 using StreamObjectCache = std::map<uint32_t, uint32_t>;
170 172
171 // Mapping of streams to their object caches. This is valid as long as the 173 // Mapping of streams to their object caches. This is valid as long as the
172 // streams in |m_ObjectStreamMap| are valid. 174 // streams in |m_ObjectStreamMap| are valid.
173 std::map<CPDF_StreamAcc*, StreamObjectCache> m_ObjCache; 175 std::map<CPDF_StreamAcc*, StreamObjectCache> m_ObjCache;
174 176
175 // All indirect object numbers that are being parsed. 177 // All indirect object numbers that are being parsed.
176 std::set<uint32_t> m_ParsingObjNums; 178 std::set<uint32_t> m_ParsingObjNums;
177 }; 179 };
178 180
179 #endif // CORE_FPDFAPI_PARSER_CPDF_PARSER_H_ 181 #endif // CORE_FPDFAPI_PARSER_CPDF_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698