summaryrefslogtreecommitdiff
path: root/Source/WebCore/storage/StorageMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/storage/StorageMap.cpp')
-rw-r--r--Source/WebCore/storage/StorageMap.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/Source/WebCore/storage/StorageMap.cpp b/Source/WebCore/storage/StorageMap.cpp
index fb7e43571..15598a8de 100644
--- a/Source/WebCore/storage/StorageMap.cpp
+++ b/Source/WebCore/storage/StorageMap.cpp
@@ -26,13 +26,13 @@
#include "config.h"
#include "StorageMap.h"
-#include <wtf/TemporaryChange.h>
+#include <wtf/SetForScope.h>
namespace WebCore {
-PassRefPtr<StorageMap> StorageMap::create(unsigned quota)
+Ref<StorageMap> StorageMap::create(unsigned quota)
{
- return adoptRef(new StorageMap(quota));
+ return adoptRef(*new StorageMap(quota));
}
StorageMap::StorageMap(unsigned quota)
@@ -43,12 +43,12 @@ StorageMap::StorageMap(unsigned quota)
{
}
-PassRefPtr<StorageMap> StorageMap::copy()
+Ref<StorageMap> StorageMap::copy()
{
- RefPtr<StorageMap> newMap = create(m_quotaSize);
+ Ref<StorageMap> newMap = create(m_quotaSize);
newMap->m_map = m_map;
newMap->m_currentLength = m_currentLength;
- return newMap.release();
+ return newMap;
}
void StorageMap::invalidateIterator()
@@ -99,7 +99,7 @@ String StorageMap::getItem(const String& key) const
return m_map.get(key);
}
-PassRefPtr<StorageMap> StorageMap::setItem(const String& key, const String& value, String& oldValue, bool& quotaException)
+RefPtr<StorageMap> StorageMap::setItem(const String& key, const String& value, String& oldValue, bool& quotaException)
{
ASSERT(!value.isNull());
quotaException = false;
@@ -109,7 +109,7 @@ PassRefPtr<StorageMap> StorageMap::setItem(const String& key, const String& valu
if (refCount() > 1) {
RefPtr<StorageMap> newStorageMap = copy();
newStorageMap->setItem(key, value, oldValue, quotaException);
- return newStorageMap.release();
+ return newStorageMap;
}
// Quota tracking. This is done in a couple of steps to keep the overflow tracking simple.
@@ -129,7 +129,7 @@ PassRefPtr<StorageMap> StorageMap::setItem(const String& key, const String& valu
bool overQuota = newLength > m_quotaSize / sizeof(UChar);
if (m_quotaSize != noQuota && (overflow || overQuota)) {
quotaException = true;
- return 0;
+ return nullptr;
}
m_currentLength = newLength;
@@ -139,12 +139,12 @@ PassRefPtr<StorageMap> StorageMap::setItem(const String& key, const String& valu
invalidateIterator();
- return 0;
+ return nullptr;
}
-PassRefPtr<StorageMap> StorageMap::setItemIgnoringQuota(const String& key, const String& value)
+RefPtr<StorageMap> StorageMap::setItemIgnoringQuota(const String& key, const String& value)
{
- TemporaryChange<unsigned> quotaSizeChange(m_quotaSize, noQuota);
+ SetForScope<unsigned> quotaSizeChange(m_quotaSize, static_cast<unsigned>(noQuota));
String oldValue;
bool quotaException;
@@ -152,17 +152,17 @@ PassRefPtr<StorageMap> StorageMap::setItemIgnoringQuota(const String& key, const
RefPtr<StorageMap> map = setItem(key, value, oldValue, quotaException);
ASSERT(!quotaException);
- return map.release();
+ return map;
}
-PassRefPtr<StorageMap> StorageMap::removeItem(const String& key, String& oldValue)
+RefPtr<StorageMap> StorageMap::removeItem(const String& key, String& oldValue)
{
// Implement copy-on-write semantics here. We're guaranteed that the only refs of StorageMaps belong to Storage objects
// so if more than one Storage object refs this map, copy it before mutating it.
if (refCount() > 1) {
RefPtr<StorageMap> newStorage = copy();
newStorage->removeItem(key, oldValue);
- return newStorage.release();
+ return newStorage;
}
oldValue = m_map.take(key);
@@ -174,7 +174,7 @@ PassRefPtr<StorageMap> StorageMap::removeItem(const String& key, String& oldValu
ASSERT(m_currentLength - oldValue.length() <= m_currentLength);
m_currentLength -= oldValue.length();
- return 0;
+ return nullptr;
}
bool StorageMap::contains(const String& key) const
@@ -184,9 +184,9 @@ bool StorageMap::contains(const String& key) const
void StorageMap::importItems(const HashMap<String, String>& items)
{
- for (HashMap<String, String>::const_iterator it = items.begin(), end = items.end(); it != end; ++it) {
- const String& key = it->key;
- const String& value = it->value;
+ for (auto& item : items) {
+ const String& key = item.key;
+ const String& value = item.value;
HashMap<String, String>::AddResult result = m_map.add(key, value);
ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.