summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_data_avail.cpp
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2017-10-02 22:07:55 +0300
committerChromium commit bot <commit-bot@chromium.org>2017-10-03 14:10:19 +0000
commit62b218074ea2bc658488c583362930a798b39107 (patch)
tree634ff6930024868b1956c5bfe796cfa4894df2c9 /core/fpdfapi/parser/cpdf_data_avail.cpp
parent0feba6f9ef721e4927e37da68ac27572ffae1453 (diff)
downloadpdfium-62b218074ea2bc658488c583362930a798b39107.tar.xz
Improve CPDF_ReadVaildator
Merge CPDF_ReadValidator::IsXXXAvailable and CPDF_ReadValidator::SheduleXXXDowload methods into one CheckXXXAndRequestIfUnavailable. Change-Id: Ib108d5bc3589df17269c841b0024dd4690909304 Reviewed-on: https://pdfium-review.googlesource.com/13730 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_data_avail.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index 8b378aab0e..b2415915c4 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -322,11 +322,10 @@ bool CPDF_DataAvail::CheckPageStatus() {
}
bool CPDF_DataAvail::LoadAllFile() {
- if (GetValidator()->IsWholeFileAvailable()) {
+ if (GetValidator()->CheckWholeFileAndRequestIfUnavailable()) {
m_docStatus = PDF_DATAAVAIL_DONE;
return true;
}
- GetValidator()->ScheduleDownloadWholeFile();
return false;
}
@@ -590,18 +589,17 @@ bool CPDF_DataAvail::CheckFirstPage() {
dwEnd = (uint32_t)m_dwFileLen;
const FX_FILESIZE start_pos = m_dwFileLen > 1024 ? 1024 : m_dwFileLen;
- const uint32_t data_size = dwEnd > 1024 ? dwEnd - 1024 : 0;
- if (!GetValidator()->IsDataRangeAvailable(start_pos, data_size)) {
- GetValidator()->ScheduleDataDownload(start_pos, data_size);
+ const size_t data_size = dwEnd > 1024 ? static_cast<size_t>(dwEnd - 1024) : 0;
+ if (!GetValidator()->CheckDataRangeAndRequestIfUnavailable(start_pos,
+ data_size))
return false;
- }
m_docStatus =
m_bSupportHintTable ? PDF_DATAAVAIL_HINTTABLE : PDF_DATAAVAIL_DONE;
return true;
}
-bool CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset, uint32_t size) {
+bool CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset, size_t size) {
if (offset < 0 || offset > m_dwFileLen)
return true;
@@ -613,10 +611,9 @@ bool CPDF_DataAvail::IsDataAvail(FX_FILESIZE offset, uint32_t size) {
else
size += 512;
- if (!GetValidator()->IsDataRangeAvailable(offset, size)) {
- GetValidator()->ScheduleDataDownload(offset, size);
+ if (!GetValidator()->CheckDataRangeAndRequestIfUnavailable(offset, size))
return false;
- }
+
return true;
}
@@ -1207,17 +1204,14 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData() {
return DataError;
if (!m_bMainXRefLoadTried) {
- FX_SAFE_UINT32 data_size = m_dwFileLen;
+ FX_SAFE_SIZE_T data_size = m_dwFileLen;
data_size -= m_pLinearized->GetLastXRefOffset();
if (!data_size.IsValid())
return DataError;
- if (!GetValidator()->IsDataRangeAvailable(
- m_pLinearized->GetLastXRefOffset(), data_size.ValueOrDie())) {
- GetValidator()->ScheduleDataDownload(m_pLinearized->GetLastXRefOffset(),
- data_size.ValueOrDie());
+ if (!GetValidator()->CheckDataRangeAndRequestIfUnavailable(
+ m_pLinearized->GetLastXRefOffset(), data_size.ValueOrDie()))
return DataNotAvailable;
- }
CPDF_Parser::Error eRet =
m_pDocument->GetParser()->LoadLinearizedMainXRefTable();