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/loader/CrossOriginPreflightResultCache.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/loader/CrossOriginPreflightResultCache.h')
-rw-r--r-- | Source/WebCore/loader/CrossOriginPreflightResultCache.h | 82 |
1 files changed, 38 insertions, 44 deletions
diff --git a/Source/WebCore/loader/CrossOriginPreflightResultCache.h b/Source/WebCore/loader/CrossOriginPreflightResultCache.h index 1c95a439f..094496e58 100644 --- a/Source/WebCore/loader/CrossOriginPreflightResultCache.h +++ b/Source/WebCore/loader/CrossOriginPreflightResultCache.h @@ -10,10 +10,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -24,65 +24,59 @@ * */ -#ifndef CrossOriginPreflightResultCache_h -#define CrossOriginPreflightResultCache_h +#pragma once #include "URLHash.h" #include "ResourceHandleTypes.h" +#include <chrono> #include <wtf/HashMap.h> #include <wtf/HashSet.h> -#include <wtf/PassOwnPtr.h> #include <wtf/text/StringHash.h> namespace WebCore { - class HTTPHeaderMap; - class ResourceResponse; +class HTTPHeaderMap; +class ResourceResponse; - class CrossOriginPreflightResultCacheItem { - WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCacheItem); WTF_MAKE_FAST_ALLOCATED; - public: - CrossOriginPreflightResultCacheItem(StoredCredentials credentials) - : m_absoluteExpiryTime(0) - , m_credentials(credentials) - { - } +class CrossOriginPreflightResultCacheItem { + WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCacheItem); WTF_MAKE_FAST_ALLOCATED; +public: + explicit CrossOriginPreflightResultCacheItem(StoredCredentials credentials) + : m_credentials(credentials) + { + } - bool parse(const ResourceResponse&, String& errorDescription); - bool allowsCrossOriginMethod(const String&, String& errorDescription) const; - bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescription) const; - bool allowsRequest(StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const; + bool parse(const ResourceResponse&, String& errorDescription); + bool allowsCrossOriginMethod(const String&, String& errorDescription) const; + bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescription) const; + bool allowsRequest(StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders) const; - private: - typedef HashSet<String, CaseFoldingHash> HeadersSet; +private: + // FIXME: A better solution to holding onto the absolute expiration time might be + // to start a timer for the expiration delta that removes this from the cache when + // it fires. + std::chrono::steady_clock::time_point m_absoluteExpiryTime; + StoredCredentials m_credentials; + HashSet<String> m_methods; + HashSet<String, ASCIICaseInsensitiveHash> m_headers; +}; - // FIXME: A better solution to holding onto the absolute expiration time might be - // to start a timer for the expiration delta that removes this from the cache when - // it fires. - double m_absoluteExpiryTime; - StoredCredentials m_credentials; - HashSet<String> m_methods; - HeadersSet m_headers; - }; +class CrossOriginPreflightResultCache { + WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCache); WTF_MAKE_FAST_ALLOCATED; - class CrossOriginPreflightResultCache { - WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCache); WTF_MAKE_FAST_ALLOCATED; - public: - static CrossOriginPreflightResultCache& shared(); +public: + WEBCORE_EXPORT static CrossOriginPreflightResultCache& singleton(); - void appendEntry(const String& origin, const URL&, PassOwnPtr<CrossOriginPreflightResultCacheItem>); - bool canSkipPreflight(const String& origin, const URL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders); + void appendEntry(const String& origin, const URL&, std::unique_ptr<CrossOriginPreflightResultCacheItem>); + bool canSkipPreflight(const String& origin, const URL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders); - void empty(); + WEBCORE_EXPORT void empty(); - private: - CrossOriginPreflightResultCache() { } +private: + friend NeverDestroyed<CrossOriginPreflightResultCache>; + CrossOriginPreflightResultCache(); - typedef HashMap<std::pair<String, URL>, OwnPtr<CrossOriginPreflightResultCacheItem>> CrossOriginPreflightResultHashMap; - - CrossOriginPreflightResultHashMap m_preflightHashMap; - }; + HashMap<std::pair<String, URL>, std::unique_ptr<CrossOriginPreflightResultCacheItem>> m_preflightHashMap; +}; } // namespace WebCore - -#endif |