#include "config.h"
#include "BlobData.h"
#include "Blob.h"
#include "BlobURL.h"
#include "ThreadableBlobRegistry.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
const long long BlobDataItem::toEndOfFile = -1;
RawData::RawData()
{
}
void RawData::detachFromCurrentThread()
{
}
void BlobDataItem::detachFromCurrentThread()
{
data->detachFromCurrentThread();
path = path.isolatedCopy();
url = url.copy();
}
PassOwnPtr<BlobData> BlobData::create()
{
return adoptPtr(new BlobData());
}
void BlobData::detachFromCurrentThread()
{
m_contentType = m_contentType.isolatedCopy();
m_contentDisposition = m_contentDisposition.isolatedCopy();
for (size_t i = 0; i < m_items.size(); ++i)
m_items.at(i).detachFromCurrentThread();
}
void BlobData::setContentType(const String& contentType)
{
ASSERT(Blob::isNormalizedContentType(contentType));
m_contentType = contentType;
}
void BlobData::appendData(PassRefPtr<RawData> data, long long offset, long long length)
{
m_items.append(BlobDataItem(data, offset, length));
}
void BlobData::appendFile(const String& path)
{
m_items.append(BlobDataItem(path));
}
void BlobData::appendFile(const String& path, long long offset, long long length, double expectedModificationTime)
{
m_items.append(BlobDataItem(path, offset, length, expectedModificationTime));
}
void BlobData::appendBlob(const KURL& url, long long offset, long long length)
{
m_items.append(BlobDataItem(url, offset, length));
}
#if ENABLE(FILE_SYSTEM)
void BlobData::appendURL(const KURL& url, long long offset, long long length, double expectedModificationTime)
{
m_items.append(BlobDataItem(url, offset, length, expectedModificationTime));
}
#endif
void BlobData::swapItems(BlobDataItemList& items)
{
m_items.swap(items);
}
BlobDataHandle::BlobDataHandle(PassOwnPtr<BlobData> data, long long size)
{
UNUSED_PARAM(size);
m_internalURL = BlobURL::createInternalURL();
ThreadableBlobRegistry::registerBlobURL(m_internalURL, data);
}
BlobDataHandle::~BlobDataHandle()
{
ThreadableBlobRegistry::unregisterBlobURL(m_internalURL);
}
}