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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. 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>
34 35
35 namespace blink { 36 namespace blink {
36 37
37 // These values are at the discretion of the user agent. 38 // These values are at the discretion of the user agent.
38 static const unsigned defaultPreflightCacheTimeoutSeconds = 5; 39 static const unsigned defaultPreflightCacheTimeoutSeconds = 5;
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. 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.
40 41
41 static bool parseAccessControlMaxAge(const String& string, unsigned& expiryDelta ) 42 static bool parseAccessControlMaxAge(const String& string, unsigned& expiryDelta )
42 { 43 {
43 // FIXME: this will not do the correct thing for a number starting with a '+ ' 44 // 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
144 return true; 145 return true;
145 } 146 }
146 147
147 CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared() 148 CrossOriginPreflightResultCache& CrossOriginPreflightResultCache::shared()
148 { 149 {
149 DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ()); 150 DEFINE_STATIC_LOCAL(CrossOriginPreflightResultCache, cache, ());
150 ASSERT(isMainThread()); 151 ASSERT(isMainThread());
151 return cache; 152 return cache;
152 } 153 }
153 154
154 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU RL& url, PassOwnPtr<CrossOriginPreflightResultCacheItem> preflightResult) 155 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KU RL& url, std::unique_ptr<CrossOriginPreflightResultCacheItem> preflightResult)
155 { 156 {
156 ASSERT(isMainThread()); 157 ASSERT(isMainThread());
157 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));
158 } 159 }
159 160
160 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)
161 { 162 {
162 ASSERT(isMainThread()); 163 ASSERT(isMainThread());
163 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));
164 if (cacheIt == m_preflightHashMap.end()) 165 if (cacheIt == m_preflightHashMap.end())
165 return false; 166 return false;
166 167
167 if (cacheIt->value->allowsRequest(includeCredentials, method, requestHeaders )) 168 if (cacheIt->value->allowsRequest(includeCredentials, method, requestHeaders ))
168 return true; 169 return true;
169 170
170 m_preflightHashMap.remove(cacheIt); 171 m_preflightHashMap.remove(cacheIt);
171 return false; 172 return false;
172 } 173 }
173 174
174 } // namespace blink 175 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698