BlobResourceHandle.h [plain text]
#ifndef BlobResourceHandle_h
#define BlobResourceHandle_h
#if ENABLE(BLOB)
#include "FileStreamClient.h"
#include "PlatformString.h"
#include "ResourceHandle.h"
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.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> create(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceHandleClient* client, bool async = true)
{
return adoptRef(new BlobResourceHandle(blobData, request, client, async));
}
static void loadResourceSynchronously(PassRefPtr<BlobStorageData> blobData, const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data);
virtual void didGetSize(long long);
virtual void didOpen(bool);
virtual void didRead(int);
virtual void cancel();
void start();
int readSync(char*, int);
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