This source file includes following definitions.
- m_containsPasswordData
- m_containsPasswordData
- create
- create
- create
- create
- copy
- deepCopy
- appendData
- appendFile
- appendFileRange
- appendBlob
- appendFileSystemURL
- appendFileSystemURLRange
- flatten
- flattenToString
#include "config.h"
#include "platform/network/FormData.h"
#include "platform/FileMetadata.h"
#include "platform/network/FormDataBuilder.h"
#include "wtf/text/CString.h"
#include "wtf/text/TextEncoding.h"
namespace WebCore {
inline FormData::FormData()
: m_identifier(0)
, m_alwaysStream(false)
, m_containsPasswordData(false)
{
}
inline FormData::FormData(const FormData& data)
: RefCounted<FormData>()
, m_elements(data.m_elements)
, m_identifier(data.m_identifier)
, m_alwaysStream(false)
, m_containsPasswordData(data.m_containsPasswordData)
{
}
FormData::~FormData()
{
}
PassRefPtr<FormData> FormData::create()
{
return adoptRef(new FormData);
}
PassRefPtr<FormData> FormData::create(const void* data, size_t size)
{
RefPtr<FormData> result = create();
result->appendData(data, size);
return result.release();
}
PassRefPtr<FormData> FormData::create(const CString& string)
{
RefPtr<FormData> result = create();
result->appendData(string.data(), string.length());
return result.release();
}
PassRefPtr<FormData> FormData::create(const Vector<char>& vector)
{
RefPtr<FormData> result = create();
result->appendData(vector.data(), vector.size());
return result.release();
}
PassRefPtr<FormData> FormData::copy() const
{
return adoptRef(new FormData(*this));
}
PassRefPtr<FormData> FormData::deepCopy() const
{
RefPtr<FormData> formData(create());
formData->m_alwaysStream = m_alwaysStream;
size_t n = m_elements.size();
formData->m_elements.reserveInitialCapacity(n);
for (size_t i = 0; i < n; ++i) {
const FormDataElement& e = m_elements[i];
switch (e.m_type) {
case FormDataElement::data:
formData->m_elements.uncheckedAppend(FormDataElement(e.m_data));
break;
case FormDataElement::encodedFile:
formData->m_elements.uncheckedAppend(FormDataElement(e.m_filename, e.m_fileStart, e.m_fileLength, e.m_expectedFileModificationTime));
break;
case FormDataElement::encodedBlob:
formData->m_elements.uncheckedAppend(FormDataElement(e.m_blobUUID, e.m_optionalBlobDataHandle));
break;
case FormDataElement::encodedFileSystemURL:
formData->m_elements.uncheckedAppend(FormDataElement(e.m_fileSystemURL, e.m_fileStart, e.m_fileLength, e.m_expectedFileModificationTime));
break;
}
}
return formData.release();
}
void FormData::appendData(const void* data, size_t size)
{
if (m_elements.isEmpty() || m_elements.last().m_type != FormDataElement::data)
m_elements.append(FormDataElement());
FormDataElement& e = m_elements.last();
size_t oldSize = e.m_data.size();
e.m_data.grow(oldSize + size);
memcpy(e.m_data.data() + oldSize, data, size);
}
void FormData::appendFile(const String& filename)
{
m_elements.append(FormDataElement(filename, 0, BlobDataItem::toEndOfFile, invalidFileTime()));
}
void FormData::appendFileRange(const String& filename, long long start, long long length, double expectedModificationTime)
{
m_elements.append(FormDataElement(filename, start, length, expectedModificationTime));
}
void FormData::appendBlob(const String& uuid, PassRefPtr<BlobDataHandle> optionalHandle)
{
m_elements.append(FormDataElement(uuid, optionalHandle));
}
void FormData::appendFileSystemURL(const KURL& url)
{
m_elements.append(FormDataElement(url, 0, BlobDataItem::toEndOfFile, invalidFileTime()));
}
void FormData::appendFileSystemURLRange(const KURL& url, long long start, long long length, double expectedModificationTime)
{
m_elements.append(FormDataElement(url, start, length, expectedModificationTime));
}
void FormData::flatten(Vector<char>& data) const
{
data.clear();
size_t n = m_elements.size();
for (size_t i = 0; i < n; ++i) {
const FormDataElement& e = m_elements[i];
if (e.m_type == FormDataElement::data)
data.append(e.m_data.data(), static_cast<size_t>(e.m_data.size()));
}
}
String FormData::flattenToString() const
{
Vector<char> bytes;
flatten(bytes);
return Latin1Encoding().decode(reinterpret_cast<const char*>(bytes.data()), bytes.size());
}
}