This source file includes following definitions.
- create
- m_storageArea
- anonymousIndexedGetter
- anonymousNamedGetter
- anonymousNamedSetter
- anonymousIndexedSetter
- anonymousNamedDeleter
- anonymousIndexedDeleter
- namedPropertyEnumerator
- namedPropertyQuery
- trace
#include "config.h"
#include "core/storage/Storage.h"
#include "bindings/v8/ExceptionState.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/PassRefPtr.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
PassRefPtrWillBeRawPtr<Storage> Storage::create(LocalFrame* frame, PassOwnPtrWillBeRawPtr<StorageArea> storageArea)
{
return adoptRefWillBeNoop(new Storage(frame, storageArea));
}
Storage::Storage(LocalFrame* frame, PassOwnPtrWillBeRawPtr<StorageArea> storageArea)
: DOMWindowProperty(frame)
, m_storageArea(storageArea)
{
ASSERT(m_frame);
ASSERT(m_storageArea);
ScriptWrappable::init(this);
}
Storage::~Storage()
{
}
String Storage::anonymousIndexedGetter(unsigned index, ExceptionState& exceptionState)
{
return anonymousNamedGetter(AtomicString::number(index), exceptionState);
}
String Storage::anonymousNamedGetter(const AtomicString& name, ExceptionState& exceptionState)
{
bool found = contains(name, exceptionState);
if (exceptionState.hadException() || !found)
return String();
String result = getItem(name, exceptionState);
if (exceptionState.hadException())
return String();
return result;
}
bool Storage::anonymousNamedSetter(const AtomicString& name, const AtomicString& value, ExceptionState& exceptionState)
{
setItem(name, value, exceptionState);
return true;
}
bool Storage::anonymousIndexedSetter(unsigned index, const AtomicString& value, ExceptionState& exceptionState)
{
return anonymousNamedSetter(AtomicString::number(index), value, exceptionState);
}
DeleteResult Storage::anonymousNamedDeleter(const AtomicString& name, ExceptionState& exceptionState)
{
bool found = contains(name, exceptionState);
if (!found)
return DeleteUnknownProperty;
if (exceptionState.hadException())
return DeleteReject;
removeItem(name, exceptionState);
if (exceptionState.hadException())
return DeleteReject;
return DeleteSuccess;
}
DeleteResult Storage::anonymousIndexedDeleter(unsigned index, ExceptionState& exceptionState)
{
DeleteResult result = anonymousNamedDeleter(AtomicString::number(index), exceptionState);
return result == DeleteUnknownProperty ? DeleteSuccess : result;
}
void Storage::namedPropertyEnumerator(Vector<String>& names, ExceptionState& exceptionState)
{
unsigned length = this->length(exceptionState);
if (exceptionState.hadException())
return;
names.resize(length);
for (unsigned i = 0; i < length; ++i) {
String key = this->key(i, exceptionState);
if (exceptionState.hadException())
return;
ASSERT(!key.isNull());
String val = getItem(key, exceptionState);
if (exceptionState.hadException())
return;
names[i] = key;
}
}
bool Storage::namedPropertyQuery(const AtomicString& name, ExceptionState& exceptionState)
{
if (name == "length")
return false;
bool found = contains(name, exceptionState);
if (exceptionState.hadException() || !found)
return false;
return true;
}
void Storage::trace(Visitor* visitor)
{
visitor->trace(m_storageArea);
}
}