From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- .../loader/CrossOriginPreflightResultCache.h | 82 ++++++++++------------ 1 file changed, 38 insertions(+), 44 deletions(-) (limited to 'Source/WebCore/loader/CrossOriginPreflightResultCache.h') 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 #include #include -#include #include 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 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 m_methods; + HashSet 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 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); - bool canSkipPreflight(const String& origin, const URL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders); + void appendEntry(const String& origin, const URL&, std::unique_ptr); + 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(); - typedef HashMap, OwnPtr> CrossOriginPreflightResultHashMap; - - CrossOriginPreflightResultHashMap m_preflightHashMap; - }; + HashMap, std::unique_ptr> m_preflightHashMap; +}; } // namespace WebCore - -#endif -- cgit v1.2.1