Ejemplo n.º 1
0
Vector<char>& BlobBuilder::getBuffer()
{
    // If the last item is not a data item, create one. Otherwise, we simply append the new string to the last data item.
    if (m_items.isEmpty() || m_items[m_items.size() - 1].type != BlobDataItem::Data)
        m_items.append(BlobDataItem(RawData::create()));

    return *m_items[m_items.size() - 1].data->mutableData();
}
Ejemplo n.º 2
0
void BlobBuilder::append(Blob* blob)
{
    if (blob->isFile()) {
        // If the blob is file that is not snapshoted, capture the snapshot now.
        // FIXME: This involves synchronous file operation. We need to figure out how to make it asynchronous.
        File* file = static_cast<File*>(blob);
        long long snapshotSize;
        double snapshotModificationTime;
        file->captureSnapshot(snapshotSize, snapshotModificationTime);

        m_size += snapshotSize;
        m_items.append(BlobDataItem(file->path(), 0, snapshotSize, snapshotModificationTime));
    } else {
        long long blobSize = static_cast<long long>(blob->size());
        m_size += blobSize;
        m_items.append(BlobDataItem(blob->url(), 0, blobSize));
    }
}
Ejemplo n.º 3
0
PassRefPtr<Blob> BlobBuilder::getBlob(const String& contentType)
{
    OwnPtr<BlobData> blobData = BlobData::create();
    blobData->setContentType(contentType);
    blobData->swapItems(m_items);

    RefPtr<Blob> blob = Blob::create(blobData.release(), m_size);

    // After creating a blob from the current blob data, we do not need to keep the data around any more. Instead, we only
    // need to keep a reference to the URL of the blob just created.
    m_items.append(BlobDataItem(blob->url(), 0, m_size));

    return blob;
}
Ejemplo n.º 4
0
void BlobData::appendBlob(const KURL& url, long long offset, long long length)
{
    m_items.append(BlobDataItem(url, offset, length));
}
Ejemplo n.º 5
0
void BlobData::appendFile(const String& path, long long offset, long long length, double expectedModificationTime)
{
    m_items.append(BlobDataItem(path, offset, length, expectedModificationTime));
}
Ejemplo n.º 6
0
void BlobData::appendFile(const String& path)
{
    m_items.append(BlobDataItem(path));
}
Ejemplo n.º 7
0
void BlobData::appendData(PassRefPtr<RawData> data, long long offset, long long length)
{
    m_items.append(BlobDataItem(data, offset, length));
}
Ejemplo n.º 8
0
void BlobData::appendData(const CString& data, long long offset, long long length)
{
    m_items.append(BlobDataItem(data, offset, length));
}
Ejemplo n.º 9
0
void BlobData::appendData(const CString& data)
{
    m_items.append(BlobDataItem(data));
}