| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (!allowsCrossOriginMethod(method, ignoredExplanation)) | 141 if (!allowsCrossOriginMethod(method, ignoredExplanation)) |
| 142 return false; | 142 return false; |
| 143 if (!allowsCrossOriginHeaders(requestHeaders, ignoredExplanation)) | 143 if (!allowsCrossOriginHeaders(requestHeaders, ignoredExplanation)) |
| 144 return false; | 144 return false; |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared() | 148 CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared() |
| 149 { | 149 { |
| 150 DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ()); | 150 DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ()); |
| 151 ASSERT(isMainThread()); | 151 DCHECK(isMainThread()); |
| 152 return cache; | 152 return cache; |
| 153 } | 153 } |
| 154 | 154 |
| 155 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU
RL& url, std::unique_ptr<CrossOriginPreflightResultCacheItem> preflightResult) | 155 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU
RL& url, std::unique_ptr<CrossOriginPreflightResultCacheItem> preflightResult) |
| 156 { | 156 { |
| 157 ASSERT(isMainThread()); | 157 DCHECK(isMainThread()); |
| 158 m_preflightHashMap.set(std::make_pair(origin, url), std::move(preflightResul
t)); | 158 m_preflightHashMap.set(std::make_pair(origin, url), std::move(preflightResul
t)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, con
st KURL& url, StoredCredentials includeCredentials, const String& method, const
HTTPHeaderMap& requestHeaders) | 161 bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, con
st KURL& url, StoredCredentials includeCredentials, const String& method, const
HTTPHeaderMap& requestHeaders) |
| 162 { | 162 { |
| 163 ASSERT(isMainThread()); | 163 DCHECK(isMainThread()); |
| 164 CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.fin
d(std::make_pair(origin, url)); | 164 CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.fin
d(std::make_pair(origin, url)); |
| 165 if (cacheIt == m_preflightHashMap.end()) | 165 if (cacheIt == m_preflightHashMap.end()) |
| 166 return false; | 166 return false; |
| 167 | 167 |
| 168 if (cacheIt->value->allowsRequest(includeCredentials, method, requestHeaders
)) | 168 if (cacheIt->value->allowsRequest(includeCredentials, method, requestHeaders
)) |
| 169 return true; | 169 return true; |
| 170 | 170 |
| 171 m_preflightHashMap.remove(cacheIt); | 171 m_preflightHashMap.remove(cacheIt); |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace blink | 175 } // namespace blink |
| OLD | NEW |