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

Side by Side Diff: Source/core/loader/CrossOriginPreflightResultCache.h

Issue 1187563005: Code cleanup in core/loader/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 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 18 matching lines...) Expand all
29 29
30 #include "core/fetch/ResourceLoaderOptions.h" 30 #include "core/fetch/ResourceLoaderOptions.h"
31 #include "platform/weborigin/KURLHash.h" 31 #include "platform/weborigin/KURLHash.h"
32 #include "wtf/HashMap.h" 32 #include "wtf/HashMap.h"
33 #include "wtf/HashSet.h" 33 #include "wtf/HashSet.h"
34 #include "wtf/PassOwnPtr.h" 34 #include "wtf/PassOwnPtr.h"
35 #include "wtf/text/StringHash.h" 35 #include "wtf/text/StringHash.h"
36 36
37 namespace blink { 37 namespace blink {
38 38
39 class HTTPHeaderMap; 39 class HTTPHeaderMap;
40 class ResourceResponse; 40 class ResourceResponse;
41 41
42 class CrossOriginPreflightResultCacheItem { 42 class CrossOriginPreflightResultCacheItem {
43 WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCacheItem); WTF_MAKE_FAST _ALLOCATED(CrossOriginPreflightResultCacheItem); 43 WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCacheItem); WTF_MAKE_FAST_ALL OCATED(CrossOriginPreflightResultCacheItem);
44 public: 44 public:
45 CrossOriginPreflightResultCacheItem(StoredCredentials credentials) 45 CrossOriginPreflightResultCacheItem(StoredCredentials credentials)
46 : m_absoluteExpiryTime(0) 46 : m_absoluteExpiryTime(0)
47 , m_credentials(credentials) 47 , m_credentials(credentials)
48 { 48 {
49 } 49 }
50 50
51 bool parse(const ResourceResponse&, String& errorDescription); 51 bool parse(const ResourceResponse&, String& errorDescription);
52 bool allowsCrossOriginMethod(const String&, String& errorDescription) co nst; 52 bool allowsCrossOriginMethod(const String&, String& errorDescription) const;
53 bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescrip tion) const; 53 bool allowsCrossOriginHeaders(const HTTPHeaderMap&, String& errorDescription ) const;
54 bool allowsRequest(StoredCredentials, const String& method, const HTTPHe aderMap& requestHeaders) const; 54 bool allowsRequest(StoredCredentials, const String& method, const HTTPHeader Map& requestHeaders) const;
55 55
56 private: 56 private:
57 typedef HashSet<String, CaseFoldingHash> HeadersSet; 57 typedef HashSet<String, CaseFoldingHash> HeadersSet;
58 58
59 // FIXME: A better solution to holding onto the absolute expiration time might be 59 // FIXME: A better solution to holding onto the absolute expiration time mig ht be
60 // to start a timer for the expiration delta that removes this from the cache when 60 // to start a timer for the expiration delta that removes this from the cach e when
61 // it fires. 61 // it fires.
62 double m_absoluteExpiryTime; 62 double m_absoluteExpiryTime;
63 StoredCredentials m_credentials; 63 StoredCredentials m_credentials;
64 HashSet<String> m_methods; 64 HashSet<String> m_methods;
65 HeadersSet m_headers; 65 HeadersSet m_headers;
66 }; 66 };
67 67
68 class CrossOriginPreflightResultCache { 68 class CrossOriginPreflightResultCache {
69 WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCache); WTF_MAKE_FAST_ALL OCATED(CrossOriginPreflightResultCache); 69 WTF_MAKE_NONCOPYABLE(CrossOriginPreflightResultCache); WTF_MAKE_FAST_ALLOCAT ED(CrossOriginPreflightResultCache);
70 public: 70 public:
71 static CrossOriginPreflightResultCache& shared(); 71 static CrossOriginPreflightResultCache& shared();
72 72
73 void appendEntry(const String& origin, const KURL&, PassOwnPtr<CrossOrig inPreflightResultCacheItem>); 73 void appendEntry(const String& origin, const KURL&, PassOwnPtr<CrossOriginPr eflightResultCacheItem>);
74 bool canSkipPreflight(const String& origin, const KURL&, StoredCredentia ls, const String& method, const HTTPHeaderMap& requestHeaders); 74 bool canSkipPreflight(const String& origin, const KURL&, StoredCredentials, const String& method, const HTTPHeaderMap& requestHeaders);
75 75
76 private: 76 private:
77 CrossOriginPreflightResultCache() { } 77 CrossOriginPreflightResultCache() { }
78 78
79 typedef HashMap<std::pair<String, KURL>, OwnPtr<CrossOriginPreflightResu ltCacheItem>> CrossOriginPreflightResultHashMap; 79 typedef HashMap<std::pair<String, KURL>, OwnPtr<CrossOriginPreflightResultCa cheItem>> CrossOriginPreflightResultHashMap;
80 80
81 CrossOriginPreflightResultHashMap m_preflightHashMap; 81 CrossOriginPreflightResultHashMap m_preflightHashMap;
82 }; 82 };
83 83
84 } // namespace blink 84 } // namespace blink
85 85
86 #endif 86 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698