diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/storage/StorageMap.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/storage/StorageMap.cpp')
-rw-r--r-- | Source/WebCore/storage/StorageMap.cpp | 38 |
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. |