#ifndef Blob_h
#define Blob_h
#include "bindings/v8/ScriptWrappable.h"
#include "core/html/URLRegistry.h"
#include "heap/Handle.h"
#include "platform/blob/BlobData.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class ExceptionState;
class ExecutionContext;
class Blob : public RefCountedWillBeGarbageCollectedFinalized<Blob>, public ScriptWrappable, public URLRegistrable {
public:
static PassRefPtrWillBeRawPtr<Blob> create()
{
return adoptRefWillBeNoop(new Blob(BlobDataHandle::create()));
}
static PassRefPtrWillBeRawPtr<Blob> create(PassRefPtr<BlobDataHandle> blobDataHandle)
{
return adoptRefWillBeNoop(new Blob(blobDataHandle));
}
virtual ~Blob();
virtual unsigned long long size() const { return m_blobDataHandle->size(); }
virtual PassRefPtrWillBeRawPtr<Blob> slice(long long start, long long end, const String& contentType, ExceptionState&) const;
PassRefPtrWillBeRawPtr<Blob> slice(ExceptionState& exceptionState) const
{
return slice(0, std::numeric_limits<long long>::max(), String(), exceptionState);
}
PassRefPtrWillBeRawPtr<Blob> slice(long long start, ExceptionState& exceptionState) const
{
return slice(start, std::numeric_limits<long long>::max(), String(), exceptionState);
}
PassRefPtrWillBeRawPtr<Blob> slice(long long start, long long end, ExceptionState& exceptionState) const
{
return slice(start, end, String(), exceptionState);
}
virtual void close(ExecutionContext*, ExceptionState&);
String type() const { return m_blobDataHandle->type(); }
String uuid() const { return m_blobDataHandle->uuid(); }
PassRefPtr<BlobDataHandle> blobDataHandle() const { return m_blobDataHandle; }
virtual bool isFile() const { return false; }
virtual bool hasBackingFile() const { return false; }
bool hasBeenClosed() const { return m_hasBeenClosed; }
virtual void appendTo(BlobData&) const;
virtual URLRegistry& registry() const OVERRIDE FINAL;
void trace(Visitor*) { }
protected:
explicit Blob(PassRefPtr<BlobDataHandle>);
static void clampSliceOffsets(long long size, long long& start, long long& end);
private:
Blob();
RefPtr<BlobDataHandle> m_blobDataHandle;
bool m_hasBeenClosed;
};
}
#endif