Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: third_party/WebKit/Source/core/loader/CrossOriginPreflightResultCache.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 * 24 *
25 */ 25 */
26 26
27 #include "core/loader/CrossOriginPreflightResultCache.h" 27 #include "core/loader/CrossOriginPreflightResultCache.h"
28 28
29 #include "core/fetch/FetchUtils.h" 29 #include "core/fetch/FetchUtils.h"
30 #include "platform/HTTPNames.h" 30 #include "platform/HTTPNames.h"
31 #include "platform/network/ResourceResponse.h" 31 #include "platform/network/ResourceResponse.h"
32 #include "wtf/CurrentTime.h" 32 #include "wtf/CurrentTime.h"
33 #include "wtf/StdLibExtras.h" 33 #include "wtf/StdLibExtras.h"
34 #include <memory>
35 34
36 namespace blink { 35 namespace blink {
37 36
38 // These values are at the discretion of the user agent. 37 // These values are at the discretion of the user agent.
39 static const unsigned defaultPreflightCacheTimeoutSeconds = 5; 38 static const unsigned defaultPreflightCacheTimeoutSeconds = 5;
40 static const unsigned maxPreflightCacheTimeoutSeconds = 600; // Should be short enough to minimize the risk of using a poisoned cache after switching to a secur e network. 39 static const unsigned maxPreflightCacheTimeoutSeconds = 600; // Should be short enough to minimize the risk of using a poisoned cache after switching to a secur e network.
41 40
42 static bool parseAccessControlMaxAge(const String& string, unsigned& expiryDelta ) 41 static bool parseAccessControlMaxAge(const String& string, unsigned& expiryDelta )
43 { 42 {
44 // FIXME: this will not do the correct thing for a number starting with a '+ ' 43 // FIXME: this will not do the correct thing for a number starting with a '+ '
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return true; 144 return true;
146 } 145 }
147 146
148 CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared() 147 CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared()
149 { 148 {
150 DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ()); 149 DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ());
151 ASSERT(isMainThread()); 150 ASSERT(isMainThread());
152 return cache; 151 return cache;
153 } 152 }
154 153
155 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU RL& url, std::unique_ptr<CrossOriginPreflightResultCacheItem> preflightResult) 154 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU RL& url, PassOwnPtr<CrossOriginPreflightResultCacheItem> preflightResult)
156 { 155 {
157 ASSERT(isMainThread()); 156 ASSERT(isMainThread());
158 m_preflightHashMap.set(std::make_pair(origin, url), std::move(preflightResul t)); 157 m_preflightHashMap.set(std::make_pair(origin, url), std::move(preflightResul t));
159 } 158 }
160 159
161 bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, con st KURL& url, StoredCredentials includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders) 160 bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, con st KURL& url, StoredCredentials includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders)
162 { 161 {
163 ASSERT(isMainThread()); 162 ASSERT(isMainThread());
164 CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.fin d(std::make_pair(origin, url)); 163 CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.fin d(std::make_pair(origin, url));
165 if (cacheIt == m_preflightHashMap.end()) 164 if (cacheIt == m_preflightHashMap.end())
166 return false; 165 return false;
167 166
168 if (cacheIt->value->allowsRequest(includeCredentials, method, requestHeaders )) 167 if (cacheIt->value->allowsRequest(includeCredentials, method, requestHeaders ))
169 return true; 168 return true;
170 169
171 m_preflightHashMap.remove(cacheIt); 170 m_preflightHashMap.remove(cacheIt);
172 return false; 171 return false;
173 } 172 }
174 173
175 } // namespace blink 174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698