5#include "testing/fake_file_access.h"
9#include "core/fxcrt/fx_system.h"
10#include "third_party/base/check.h"
12class FileAccessWrapper
final :
public FPDF_FILEACCESS {
16 m_FileLen = simulator_->GetFileSize();
22 unsigned long position,
25 return static_cast<FileAccessWrapper*>(param)->simulator_->GetBlock(
26 position, pBuf, size);
33class FileAvailImpl
final :
public FX_FILEAVAIL {
37 IsDataAvail = &IsDataAvailImpl;
43 return static_cast<FileAvailImpl*>(pThis)->simulator_->IsDataAvail(offset,
51class DownloadHintsImpl
final :
public FX_DOWNLOADHINTS {
62 return static_cast<DownloadHintsImpl*>(pThis)->simulator_->AddSegment(
81 return file_access_wrapper_.get();
85 return file_avail_.get();
89 return download_hints_.get();
93 return available_data_.Contains(RangeSet::Range(offset, offset + size));
97 requested_data_.Union(RangeSet::Range(offset, offset + size));
101 return file_access_->m_FileLen;
106 unsigned long size) {
110 if (!IsDataAvail(
static_cast<size_t>(position),
static_cast<size_t>(size)))
113 return file_access_->m_GetBlock(file_access_->m_Param, position, pBuf, size);
117 available_data_.Union(requested_data_);
118 requested_data_.Clear();
122 available_data_.Union(RangeSet::Range(0,
static_cast<size_t>(GetFileSize())));
123 requested_data_.Clear();
DownloadHintsImpl(FakeFileAccess *simulator)
static void AddSegmentImpl(FX_DOWNLOADHINTS *pThis, size_t offset, size_t size)
void SetRequestedDataAvailable()
void SetWholeFileAvailable()
void AddSegment(size_t offset, size_t size)
FPDF_BOOL IsDataAvail(size_t offset, size_t size) const
int GetBlock(unsigned long position, unsigned char *pBuf, unsigned long size)
FakeFileAccess(FPDF_FILEACCESS *file_access)
FX_DOWNLOADHINTS * GetDownloadHints() const
unsigned long GetFileSize()
FX_FILEAVAIL * GetFileAvail() const
FPDF_FILEACCESS * GetFileAccess() const
FileAccessWrapper(FakeFileAccess *simulator)
static int GetBlockImpl(void *param, unsigned long position, unsigned char *pBuf, unsigned long size)
FileAvailImpl(FakeFileAccess *simulator)
static FPDF_BOOL IsDataAvailImpl(FX_FILEAVAIL *pThis, size_t offset, size_t size)
void(* AddSegment)(struct _FX_DOWNLOADHINTS *pThis, size_t offset, size_t size)