This source file includes following definitions.
- copyData
- adopt
- get
- add
- get
- contains
- add
#include "config.h"
#include "platform/network/HTTPHeaderMap.h"
using namespace std;
namespace WebCore {
HTTPHeaderMap::HTTPHeaderMap()
{
}
HTTPHeaderMap::~HTTPHeaderMap()
{
}
PassOwnPtr<CrossThreadHTTPHeaderMapData> HTTPHeaderMap::copyData() const
{
OwnPtr<CrossThreadHTTPHeaderMapData> data = adoptPtr(new CrossThreadHTTPHeaderMapData());
data->reserveInitialCapacity(size());
HTTPHeaderMap::const_iterator endIt = end();
for (HTTPHeaderMap::const_iterator it = begin(); it != endIt; ++it)
data->uncheckedAppend(make_pair(it->key.string().isolatedCopy(), it->value.string().isolatedCopy()));
return data.release();
}
void HTTPHeaderMap::adopt(PassOwnPtr<CrossThreadHTTPHeaderMapData> data)
{
clear();
size_t dataSize = data->size();
for (size_t index = 0; index < dataSize; ++index) {
pair<String, String>& header = (*data)[index];
set(AtomicString(header.first), AtomicString(header.second));
}
}
const AtomicString& HTTPHeaderMap::get(const AtomicString& name) const
{
return HashMap<AtomicString, AtomicString, CaseFoldingHash>::get(name);
}
HTTPHeaderMap::AddResult HTTPHeaderMap::add(const AtomicString& name, const AtomicString& value)
{
return HashMap<AtomicString, AtomicString, CaseFoldingHash>::add(name, value);
}
struct CaseFoldingCStringTranslator {
static unsigned hash(const char* cString)
{
return CaseFoldingHash::hash(cString, strlen(cString));
}
static bool equal(const AtomicString& key, const char* cString)
{
return equalIgnoringCase(key, cString);
}
static void translate(AtomicString& location, const char* cString, unsigned )
{
location = AtomicString(cString);
}
};
const AtomicString& HTTPHeaderMap::get(const char* name) const
{
const_iterator i = find<CaseFoldingCStringTranslator>(name);
if (i == end())
return nullAtom;
return i->value;
}
bool HTTPHeaderMap::contains(const char* name) const
{
return find<CaseFoldingCStringTranslator>(name) != end();
}
HTTPHeaderMap::AddResult HTTPHeaderMap::add(const char* name, const AtomicString& value)
{
return HashMap<AtomicString, AtomicString, CaseFoldingHash>::add<CaseFoldingCStringTranslator>(name, value);
}
}