BlobResourceHandle.h [plain text]
#ifndef BlobResourceHandle_h
#define BlobResourceHandle_h
#if ENABLE(BLOB)
#include "FileStreamClient.h"
#include "ResourceHandle.h"
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class AsyncFileStream;
class BlobStorageData;
class FileStream;
class ResourceHandleClient;
class ResourceRequest;
struct BlobDataItem;
class BlobResourceHandle : public FileStreamClient, public ResourceHandle {
public:
static PassRefPtr<BlobResourceHandle> createAsync(BlobStorageData*, const ResourceRequest&, ResourceHandleClient*);
static void loadResourceSynchronously(BlobStorageData* blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data);
virtual void didGetSize(long long) OVERRIDE;
virtual void didOpen(bool) OVERRIDE;
virtual void didRead(int) OVERRIDE;
virtual void cancel() OVERRIDE;
void start();
int readSync(char*, int);
bool aborted() const { return m_aborted; }
private:
friend void delayedStartBlobResourceHandle(void*);
BlobResourceHandle(PassRefPtr<BlobStorageData>, const ResourceRequest&, ResourceHandleClient*, bool async);
virtual ~BlobResourceHandle();
void doStart();
void getSizeForNext();
void seek();
void consumeData(const char* data, int bytesRead);
void failed(int errorCode);
void readAsync();
void readDataAsync(const BlobDataItem&);
void readFileAsync(const BlobDataItem&);
int readDataSync(const BlobDataItem&, char*, int);
int readFileSync(const BlobDataItem&, char*, int);
void notifyResponse();
void notifyResponseOnSuccess();
void notifyResponseOnError();
void notifyReceiveData(const char*, int);
void notifyFail(int errorCode);
void notifyFinish();
RefPtr<BlobStorageData> m_blobData;
bool m_async;
RefPtr<AsyncFileStream> m_asyncStream; RefPtr<FileStream> m_stream; Vector<char> m_buffer;
Vector<long long> m_itemLengthList;
int m_errorCode;
bool m_aborted;
long long m_rangeOffset;
long long m_rangeEnd;
long long m_rangeSuffixLength;
long long m_totalRemainingSize;
long long m_currentItemReadSize;
unsigned m_sizeItemCount;
unsigned m_readItemCount;
bool m_fileOpened;
};
}
#endif // ENABLE(BLOB)
#endif // BlobResourceHandle_h