summaryrefslogtreecommitdiffstats
path: root/WebCore/loader/CrossOriginPreflightResultCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/loader/CrossOriginPreflightResultCache.cpp')
-rw-r--r--WebCore/loader/CrossOriginPreflightResultCache.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/WebCore/loader/CrossOriginPreflightResultCache.cpp b/WebCore/loader/CrossOriginPreflightResultCache.cpp
index 4bd05b2..cea66b1 100644
--- a/WebCore/loader/CrossOriginPreflightResultCache.cpp
+++ b/WebCore/loader/CrossOriginPreflightResultCache.cpp
@@ -30,6 +30,8 @@
#include "CrossOriginAccessControl.h"
#include "ResourceResponse.h"
#include <wtf/CurrentTime.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/Threading.h>
namespace WebCore {
@@ -64,8 +66,7 @@ static void addToAccessControlAllowList(const String& string, unsigned start, un
while (end && isSpaceOrNewline((*stringImpl)[end]))
--end;
- // substringCopy() is called on the strings because the cache is accessed on multiple threads.
- set.add(string.substringCopy(start, end - start + 1));
+ set.add(string.substring(start, end - start + 1));
}
template<class HashType>
@@ -137,20 +138,20 @@ bool CrossOriginPreflightResultCacheItem::allowsRequest(bool includeCredentials,
CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared()
{
- AtomicallyInitializedStatic(CrossOriginPreflightResultCache&, cache = *new CrossOriginPreflightResultCache);
+ DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ());
+ ASSERT(isMainThread());
return cache;
}
void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KURL& url, CrossOriginPreflightResultCacheItem* preflightResult)
{
- MutexLocker lock(m_mutex);
- // Note that the entry may already be present in the HashMap if another thread is accessing the same location.
- m_preflightHashMap.set(std::make_pair(origin.copy(), url.copy()), preflightResult);
+ ASSERT(isMainThread());
+ m_preflightHashMap.set(std::make_pair(origin, url), preflightResult);
}
bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, const KURL& url, bool includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders)
{
- MutexLocker lock(m_mutex);
+ ASSERT(isMainThread());
CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.find(std::make_pair(origin, url));
if (cacheIt == m_preflightHashMap.end())
return false;
@@ -165,7 +166,7 @@ bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, con
void CrossOriginPreflightResultCache::empty()
{
- MutexLocker lock(m_mutex);
+ ASSERT(isMainThread());
deleteAllValues(m_preflightHashMap);
m_preflightHashMap.clear();
}