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

Side by Side Diff: xfa/fde/xml/cfx_saxreader.cpp

Issue 2451493002: Refcount all the IFX_ stream classes all the time. (Closed)
Patch Set: Clean up cast expression Created 4 years 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
« no previous file with comments | « xfa/fde/xml/cfx_saxreader.h ('k') | xfa/fgas/crt/fgas_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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 #include "xfa/fde/xml/cfx_saxreader.h" 7 #include "xfa/fde/xml/cfx_saxreader.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 &CFX_SAXReader::ParseTagAttributeValue, 56 &CFX_SAXReader::ParseTagAttributeValue,
57 &CFX_SAXReader::ParseMaybeClose, 57 &CFX_SAXReader::ParseMaybeClose,
58 &CFX_SAXReader::ParseTagClose, 58 &CFX_SAXReader::ParseTagClose,
59 &CFX_SAXReader::ParseTagEnd, 59 &CFX_SAXReader::ParseTagEnd,
60 &CFX_SAXReader::ParseTargetData, 60 &CFX_SAXReader::ParseTargetData,
61 }; 61 };
62 62
63 } // namespace 63 } // namespace
64 64
65 CFX_SAXFile::CFX_SAXFile() 65 CFX_SAXFile::CFX_SAXFile()
66 : m_pFile(nullptr), 66 : m_dwStart(0),
67 m_dwStart(0),
68 m_dwEnd(0), 67 m_dwEnd(0),
69 m_dwCur(0), 68 m_dwCur(0),
70 m_pBuf(nullptr), 69 m_pBuf(nullptr),
71 m_dwBufSize(0), 70 m_dwBufSize(0),
72 m_dwBufIndex(0) {} 71 m_dwBufIndex(0) {}
73 bool CFX_SAXFile::StartFile(IFX_SeekableReadStream* pFile, 72
73 CFX_SAXFile::~CFX_SAXFile() {}
74
75 bool CFX_SAXFile::StartFile(const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
74 uint32_t dwStart, 76 uint32_t dwStart,
75 uint32_t dwLen) { 77 uint32_t dwLen) {
76 ASSERT(!m_pFile && pFile); 78 ASSERT(!m_pFile && pFile);
77 uint32_t dwSize = pFile->GetSize(); 79 uint32_t dwSize = pFile->GetSize();
78 if (dwStart >= dwSize) { 80 if (dwStart >= dwSize)
79 return false; 81 return false;
80 } 82
81 if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize) { 83 if (dwLen == static_cast<uint32_t>(-1) || dwStart + dwLen > dwSize)
82 dwLen = dwSize - dwStart; 84 dwLen = dwSize - dwStart;
83 } 85
84 if (dwLen == 0) { 86 if (dwLen == 0)
85 return false; 87 return false;
86 } 88
87 m_dwBufSize = std::min(dwLen, kSaxFileBufSize); 89 m_dwBufSize = std::min(dwLen, kSaxFileBufSize);
88 m_pBuf = FX_Alloc(uint8_t, m_dwBufSize); 90 m_pBuf = FX_Alloc(uint8_t, m_dwBufSize);
89 if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize)) { 91 if (!pFile->ReadBlock(m_pBuf, dwStart, m_dwBufSize))
90 return false; 92 return false;
91 } 93
92 m_dwStart = dwStart; 94 m_dwStart = dwStart;
93 m_dwEnd = dwStart + dwLen; 95 m_dwEnd = dwStart + dwLen;
94 m_dwCur = dwStart; 96 m_dwCur = dwStart;
95 m_pFile = pFile; 97 m_pFile = pFile;
96 m_dwBufIndex = 0; 98 m_dwBufIndex = 0;
97 return true; 99 return true;
98 } 100 }
99 101
100 bool CFX_SAXFile::ReadNextBlock() { 102 bool CFX_SAXFile::ReadNextBlock() {
101 ASSERT(m_pFile); 103 ASSERT(m_pFile);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } else { 209 } else {
208 m_iNameSize += 1024 * 1024; 210 m_iNameSize += 1024 * 1024;
209 } 211 }
210 m_pszName = (uint8_t*)FX_Realloc(uint8_t, m_pszName, m_iNameSize); 212 m_pszName = (uint8_t*)FX_Realloc(uint8_t, m_pszName, m_iNameSize);
211 } 213 }
212 214
213 bool CFX_SAXReader::SkipSpace(uint8_t ch) { 215 bool CFX_SAXReader::SkipSpace(uint8_t ch) {
214 return (m_dwParseMode & CFX_SaxParseMode_NotSkipSpace) == 0 && ch < 0x21; 216 return (m_dwParseMode & CFX_SaxParseMode_NotSkipSpace) == 0 && ch < 0x21;
215 } 217 }
216 218
217 int32_t CFX_SAXReader::StartParse(IFX_SeekableReadStream* pFile, 219 int32_t CFX_SAXReader::StartParse(
218 uint32_t dwStart, 220 const CFX_RetainPtr<IFX_SeekableReadStream>& pFile,
219 uint32_t dwLen, 221 uint32_t dwStart,
220 uint32_t dwParseMode) { 222 uint32_t dwLen,
223 uint32_t dwParseMode) {
221 m_iState = -1; 224 m_iState = -1;
222 Reset(); 225 Reset();
223 if (!m_File.StartFile(pFile, dwStart, dwLen)) { 226 if (!m_File.StartFile(pFile, dwStart, dwLen))
224 return -1; 227 return -1;
225 } 228
226 m_iState = 0; 229 m_iState = 0;
227 m_eMode = CFX_SaxMode::Text; 230 m_eMode = CFX_SaxMode::Text;
228 m_ePrevMode = CFX_SaxMode::Text; 231 m_ePrevMode = CFX_SaxMode::Text;
229 m_bCharData = false; 232 m_bCharData = false;
230 m_dwDataOffset = 0; 233 m_dwDataOffset = 0;
231 m_dwParseMode = dwParseMode; 234 m_dwParseMode = dwParseMode;
232 m_Stack.emplace(new CFX_SAXItem(++m_dwItemID)); 235 m_Stack.emplace(new CFX_SAXItem(++m_dwItemID));
233 return 0; 236 return 0;
234 } 237 }
235 238
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 CFX_SAXItem* pItem = GetCurrentItem(); 730 CFX_SAXItem* pItem = GetCurrentItem();
728 if (!pItem) 731 if (!pItem)
729 return; 732 return;
730 733
731 pItem->m_bSkip = true; 734 pItem->m_bSkip = true;
732 } 735 }
733 736
734 void CFX_SAXReader::SetHandler(CXFA_SAXReaderHandler* pHandler) { 737 void CFX_SAXReader::SetHandler(CXFA_SAXReaderHandler* pHandler) {
735 m_pHandler = pHandler; 738 m_pHandler = pHandler;
736 } 739 }
OLDNEW
« no previous file with comments | « xfa/fde/xml/cfx_saxreader.h ('k') | xfa/fgas/crt/fgas_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698