summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-05 13:19:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-05 13:19:48 +0000
commitdc235a42164fa3d9684e4a48d4383e7db632ebaa (patch)
tree679dcc40b153cc5471ea1d4e55c0b43371f3556d /core/fpdfapi
parent2c15639637cc9908751fee21019cf3c4a8c60732 (diff)
downloadpdfium-dc235a42164fa3d9684e4a48d4383e7db632ebaa.tar.xz
Share read validator between CPDF_DataAvail and CPDF_SyntaxParser.
Change-Id: I61c92050b034fbffa747a2519aba368e9678afcd Reviewed-on: https://pdfium-review.googlesource.com/15850 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp6
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h1
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp16
-rw-r--r--core/fpdfapi/parser/cpdf_parser.h5
4 files changed, 13 insertions, 15 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index f1a5d0c143..cc75ee37f1 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -916,10 +916,6 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckResources(
return resource_avail->CheckAvail();
}
-RetainPtr<IFX_SeekableReadStream> CPDF_DataAvail::GetFileRead() const {
- return m_pFileRead;
-}
-
RetainPtr<CPDF_ReadValidator> CPDF_DataAvail::GetValidator() const {
return m_pFileRead;
}
@@ -1029,7 +1025,7 @@ CPDF_DataAvail::ParseDocument(const char* password) {
CPDF_ReadValidator::Session read_session(GetValidator().Get());
CPDF_Parser::Error error = document->GetParser()->StartLinearizedParse(
- GetFileRead(), document.get());
+ GetValidator(), document.get());
// Additional check, that all ok.
if (GetValidator()->has_read_problems()) {
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index 08bb77a23f..2ea93fa759 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -100,7 +100,6 @@ class CPDF_DataAvail final {
DocAvailStatus IsPageAvail(uint32_t dwPage, DownloadHints* pHints);
DocFormStatus IsFormAvail(DownloadHints* pHints);
DocLinearizationStatus IsLinearizedPDF();
- RetainPtr<IFX_SeekableReadStream> GetFileRead() const;
int GetPageCount() const;
CPDF_Dictionary* GetPageDictionary(int index) const;
RetainPtr<CPDF_ReadValidator> GetValidator() const;
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index d8ac8c97b3..ba993c2e3c 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -16,6 +16,7 @@
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_linearized_header.h"
#include "core/fpdfapi/parser/cpdf_number.h"
+#include "core/fpdfapi/parser/cpdf_read_validator.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_security_handler.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
@@ -201,14 +202,14 @@ void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) {
}
bool CPDF_Parser::InitSyntaxParser(
- const RetainPtr<IFX_SeekableReadStream>& file_access) {
- const int32_t header_offset = GetHeaderOffset(file_access);
+ const RetainPtr<CPDF_ReadValidator>& validator) {
+ const int32_t header_offset = GetHeaderOffset(validator);
if (header_offset == kInvalidHeaderOffset)
return false;
- if (file_access->GetSize() < header_offset + kPDFHeaderSize)
+ if (validator->GetSize() < header_offset + kPDFHeaderSize)
return false;
- m_pSyntax->InitParser(file_access, header_offset);
+ m_pSyntax->InitParserWithValidator(validator, header_offset);
return ParseFileVersion();
}
@@ -232,7 +233,8 @@ bool CPDF_Parser::ParseFileVersion() {
CPDF_Parser::Error CPDF_Parser::StartParse(
const RetainPtr<IFX_SeekableReadStream>& pFileAccess,
CPDF_Document* pDocument) {
- if (!InitSyntaxParser(pFileAccess))
+ if (!InitSyntaxParser(
+ pdfium::MakeRetain<CPDF_ReadValidator>(pFileAccess, nullptr)))
return FORMAT_ERROR;
return StartParseInternal(pDocument);
}
@@ -1327,13 +1329,13 @@ std::unique_ptr<CPDF_LinearizedHeader> CPDF_Parser::ParseLinearizedHeader() {
}
CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
- const RetainPtr<IFX_SeekableReadStream>& pFileAccess,
+ const RetainPtr<CPDF_ReadValidator>& validator,
CPDF_Document* pDocument) {
ASSERT(!m_bHasParsed);
m_bXRefStream = false;
m_LastXRefOffset = 0;
- if (!InitSyntaxParser(pFileAccess))
+ if (!InitSyntaxParser(validator))
return FORMAT_ERROR;
m_pLinearized = ParseLinearizedHeader();
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index 08bb901ae6..5f0a4a1cf3 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -26,6 +26,7 @@ class CPDF_Document;
class CPDF_IndirectObjectHolder;
class CPDF_LinearizedHeader;
class CPDF_Object;
+class CPDF_ReadValidator;
class CPDF_SecurityHandler;
class CPDF_StreamAcc;
class CPDF_SyntaxParser;
@@ -52,7 +53,7 @@ class CPDF_Parser {
Error StartParse(const RetainPtr<IFX_SeekableReadStream>& pFile,
CPDF_Document* pDocument);
- Error StartLinearizedParse(const RetainPtr<IFX_SeekableReadStream>& pFile,
+ Error StartLinearizedParse(const RetainPtr<CPDF_ReadValidator>& validator,
CPDF_Document* pDocument);
void SetPassword(const char* password) { m_Password = password; }
@@ -195,7 +196,7 @@ class CPDF_Parser {
CPDF_SyntaxParser::ParseType parse_type,
FX_FILESIZE* pResultPos);
- bool InitSyntaxParser(const RetainPtr<IFX_SeekableReadStream>& file_access);
+ bool InitSyntaxParser(const RetainPtr<CPDF_ReadValidator>& validator);
bool ParseFileVersion();
ObjectType GetObjectType(uint32_t objnum) const;