blob: 31c33fa36acfccd71cc85a1819660f2e4254f929 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright 2017 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CORE_FPDFAPI_PARSER_CPDF_READ_VALIDATOR_H_
#define CORE_FPDFAPI_PARSER_CPDF_READ_VALIDATOR_H_
#include "core/fpdfapi/parser/cpdf_data_avail.h"
#include "core/fxcrt/fx_stream.h"
class CPDF_ReadValidator : public IFX_SeekableReadStream {
public:
template <typename T, typename... Args>
friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
class Session {
public:
explicit Session(CPDF_ReadValidator* validator);
~Session();
private:
UnownedPtr<CPDF_ReadValidator> validator_;
bool saved_read_error_;
bool saved_has_unavailable_data_;
};
void SetDownloadHints(CPDF_DataAvail::DownloadHints* hints) {
hints_ = hints;
}
bool read_error() const { return read_error_; }
bool has_unavailable_data() const { return has_unavailable_data_; }
bool has_read_problems() const {
return read_error() || has_unavailable_data();
}
void ResetErrors();
bool IsWholeFileAvailable();
bool CheckDataRangeAndRequestIfUnavailable(FX_FILESIZE offset, size_t size);
bool CheckWholeFileAndRequestIfUnavailable();
// IFX_SeekableReadStream overrides:
bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
FX_FILESIZE GetSize() override;
protected:
CPDF_ReadValidator(const RetainPtr<IFX_SeekableReadStream>& file_read,
CPDF_DataAvail::FileAvail* file_avail);
~CPDF_ReadValidator() override;
private:
void ScheduleDownload(FX_FILESIZE offset, size_t size);
bool IsDataRangeAvailable(FX_FILESIZE offset, size_t size) const;
RetainPtr<IFX_SeekableReadStream> file_read_;
UnownedPtr<CPDF_DataAvail::FileAvail> file_avail_;
UnownedPtr<CPDF_DataAvail::DownloadHints> hints_;
bool read_error_;
bool has_unavailable_data_;
bool whole_file_already_available_;
const FX_FILESIZE file_size_;
};
#endif // CORE_FPDFAPI_PARSER_CPDF_READ_VALIDATOR_H_
|