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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceLoaderOptions.h

Issue 2454983002: Cache-aware Resource loading (Closed)
Patch Set: nit Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.cpp ('k') | no next file » | 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 enum SynchronousPolicy { RequestSynchronously, RequestAsynchronously }; 64 enum SynchronousPolicy { RequestSynchronously, RequestAsynchronously };
65 65
66 // A resource fetch can be marked as being CORS enabled. The loader must perform 66 // A resource fetch can be marked as being CORS enabled. The loader must perform
67 // an access check upon seeing the response. 67 // an access check upon seeing the response.
68 enum CORSEnabled { NotCORSEnabled, IsCORSEnabled }; 68 enum CORSEnabled { NotCORSEnabled, IsCORSEnabled };
69 69
70 // Was the request generated from a "parser-inserted" element? 70 // Was the request generated from a "parser-inserted" element?
71 // https://html.spec.whatwg.org/multipage/scripting.html#parser-inserted 71 // https://html.spec.whatwg.org/multipage/scripting.html#parser-inserted
72 enum ParserDisposition { ParserInserted, NotParserInserted }; 72 enum ParserDisposition { ParserInserted, NotParserInserted };
73 73
74 enum CacheAwareLoadingEnabled {
75 NotCacheAwareLoadingEnabled,
76 IsCacheAwareLoadingEnabled
77 };
78
74 struct ResourceLoaderOptions { 79 struct ResourceLoaderOptions {
75 USING_FAST_MALLOC(ResourceLoaderOptions); 80 USING_FAST_MALLOC(ResourceLoaderOptions);
76 81
77 public: 82 public:
78 ResourceLoaderOptions() 83 ResourceLoaderOptions()
79 : dataBufferingPolicy(BufferData), 84 : dataBufferingPolicy(BufferData),
80 allowCredentials(DoNotAllowStoredCredentials), 85 allowCredentials(DoNotAllowStoredCredentials),
81 credentialsRequested(ClientDidNotRequestCredentials), 86 credentialsRequested(ClientDidNotRequestCredentials),
82 contentSecurityPolicyOption(CheckContentSecurityPolicy), 87 contentSecurityPolicyOption(CheckContentSecurityPolicy),
83 requestInitiatorContext(DocumentContext), 88 requestInitiatorContext(DocumentContext),
84 synchronousPolicy(RequestAsynchronously), 89 synchronousPolicy(RequestAsynchronously),
85 corsEnabled(NotCORSEnabled), 90 corsEnabled(NotCORSEnabled),
86 parserDisposition(ParserInserted) {} 91 parserDisposition(ParserInserted),
92 cacheAwareLoadingEnabled(NotCacheAwareLoadingEnabled) {}
87 93
88 ResourceLoaderOptions( 94 ResourceLoaderOptions(
89 DataBufferingPolicy dataBufferingPolicy, 95 DataBufferingPolicy dataBufferingPolicy,
90 StoredCredentials allowCredentials, 96 StoredCredentials allowCredentials,
91 CredentialRequest credentialsRequested, 97 CredentialRequest credentialsRequested,
92 ContentSecurityPolicyDisposition contentSecurityPolicyOption, 98 ContentSecurityPolicyDisposition contentSecurityPolicyOption,
93 RequestInitiatorContext requestInitiatorContext) 99 RequestInitiatorContext requestInitiatorContext)
94 : dataBufferingPolicy(dataBufferingPolicy), 100 : dataBufferingPolicy(dataBufferingPolicy),
95 allowCredentials(allowCredentials), 101 allowCredentials(allowCredentials),
96 credentialsRequested(credentialsRequested), 102 credentialsRequested(credentialsRequested),
97 contentSecurityPolicyOption(contentSecurityPolicyOption), 103 contentSecurityPolicyOption(contentSecurityPolicyOption),
98 requestInitiatorContext(requestInitiatorContext), 104 requestInitiatorContext(requestInitiatorContext),
99 synchronousPolicy(RequestAsynchronously), 105 synchronousPolicy(RequestAsynchronously),
100 corsEnabled(NotCORSEnabled), 106 corsEnabled(NotCORSEnabled),
101 parserDisposition(ParserInserted) {} 107 parserDisposition(ParserInserted),
108 cacheAwareLoadingEnabled(NotCacheAwareLoadingEnabled) {}
102 109
103 // Answers the question "can a separate request with these different options 110 // Answers the question "can a separate request with these different options
104 // be re-used" (e.g. preload request) The safe (but possibly slow) answer is 111 // be re-used" (e.g. preload request) The safe (but possibly slow) answer is
105 // always false. 112 // always false.
106 bool canReuseRequest(const ResourceLoaderOptions& other) const { 113 bool canReuseRequest(const ResourceLoaderOptions& other) const {
107 // dataBufferingPolicy differences are believed to be safe for re-use. 114 // dataBufferingPolicy differences are believed to be safe for re-use.
108 // FIXME: check allowCredentials. 115 // FIXME: check allowCredentials.
109 // FIXME: check credentialsRequested. 116 // FIXME: check credentialsRequested.
110 // FIXME: check contentSecurityPolicyOption. 117 // FIXME: check contentSecurityPolicyOption.
111 // initiatorInfo is purely informational and should be benign for re-use. 118 // initiatorInfo is purely informational and should be benign for re-use.
(...skipping 20 matching lines...) Expand all
132 RequestInitiatorContext requestInitiatorContext; 139 RequestInitiatorContext requestInitiatorContext;
133 SynchronousPolicy synchronousPolicy; 140 SynchronousPolicy synchronousPolicy;
134 141
135 // If the resource is loaded out-of-origin, whether or not to use CORS. 142 // If the resource is loaded out-of-origin, whether or not to use CORS.
136 CORSEnabled corsEnabled; 143 CORSEnabled corsEnabled;
137 144
138 RefPtr<SecurityOrigin> securityOrigin; 145 RefPtr<SecurityOrigin> securityOrigin;
139 String contentSecurityPolicyNonce; 146 String contentSecurityPolicyNonce;
140 IntegrityMetadataSet integrityMetadata; 147 IntegrityMetadataSet integrityMetadata;
141 ParserDisposition parserDisposition; 148 ParserDisposition parserDisposition;
149 CacheAwareLoadingEnabled cacheAwareLoadingEnabled;
142 }; 150 };
143 151
144 // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads. 152 // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads.
145 struct CrossThreadResourceLoaderOptionsData { 153 struct CrossThreadResourceLoaderOptionsData {
146 DISALLOW_NEW(); 154 DISALLOW_NEW();
147 explicit CrossThreadResourceLoaderOptionsData( 155 explicit CrossThreadResourceLoaderOptionsData(
148 const ResourceLoaderOptions& options) 156 const ResourceLoaderOptions& options)
149 : dataBufferingPolicy(options.dataBufferingPolicy), 157 : dataBufferingPolicy(options.dataBufferingPolicy),
150 allowCredentials(options.allowCredentials), 158 allowCredentials(options.allowCredentials),
151 credentialsRequested(options.credentialsRequested), 159 credentialsRequested(options.credentialsRequested),
152 contentSecurityPolicyOption(options.contentSecurityPolicyOption), 160 contentSecurityPolicyOption(options.contentSecurityPolicyOption),
153 initiatorInfo(options.initiatorInfo), 161 initiatorInfo(options.initiatorInfo),
154 requestInitiatorContext(options.requestInitiatorContext), 162 requestInitiatorContext(options.requestInitiatorContext),
155 synchronousPolicy(options.synchronousPolicy), 163 synchronousPolicy(options.synchronousPolicy),
156 corsEnabled(options.corsEnabled), 164 corsEnabled(options.corsEnabled),
157 securityOrigin(options.securityOrigin 165 securityOrigin(options.securityOrigin
158 ? options.securityOrigin->isolatedCopy() 166 ? options.securityOrigin->isolatedCopy()
159 : nullptr), 167 : nullptr),
160 contentSecurityPolicyNonce(options.contentSecurityPolicyNonce), 168 contentSecurityPolicyNonce(options.contentSecurityPolicyNonce),
161 integrityMetadata(options.integrityMetadata), 169 integrityMetadata(options.integrityMetadata),
162 parserDisposition(options.parserDisposition) {} 170 parserDisposition(options.parserDisposition),
171 cacheAwareLoadingEnabled(options.cacheAwareLoadingEnabled) {}
163 172
164 operator ResourceLoaderOptions() const { 173 operator ResourceLoaderOptions() const {
165 ResourceLoaderOptions options; 174 ResourceLoaderOptions options;
166 options.dataBufferingPolicy = dataBufferingPolicy; 175 options.dataBufferingPolicy = dataBufferingPolicy;
167 options.allowCredentials = allowCredentials; 176 options.allowCredentials = allowCredentials;
168 options.credentialsRequested = credentialsRequested; 177 options.credentialsRequested = credentialsRequested;
169 options.contentSecurityPolicyOption = contentSecurityPolicyOption; 178 options.contentSecurityPolicyOption = contentSecurityPolicyOption;
170 options.initiatorInfo = initiatorInfo; 179 options.initiatorInfo = initiatorInfo;
171 options.requestInitiatorContext = requestInitiatorContext; 180 options.requestInitiatorContext = requestInitiatorContext;
172 options.synchronousPolicy = synchronousPolicy; 181 options.synchronousPolicy = synchronousPolicy;
173 options.corsEnabled = corsEnabled; 182 options.corsEnabled = corsEnabled;
174 options.securityOrigin = securityOrigin; 183 options.securityOrigin = securityOrigin;
175 options.contentSecurityPolicyNonce = contentSecurityPolicyNonce; 184 options.contentSecurityPolicyNonce = contentSecurityPolicyNonce;
176 options.integrityMetadata = integrityMetadata; 185 options.integrityMetadata = integrityMetadata;
177 options.parserDisposition = parserDisposition; 186 options.parserDisposition = parserDisposition;
187 options.cacheAwareLoadingEnabled = cacheAwareLoadingEnabled;
178 return options; 188 return options;
179 } 189 }
180 190
181 DataBufferingPolicy dataBufferingPolicy; 191 DataBufferingPolicy dataBufferingPolicy;
182 StoredCredentials allowCredentials; 192 StoredCredentials allowCredentials;
183 CredentialRequest credentialsRequested; 193 CredentialRequest credentialsRequested;
184 ContentSecurityPolicyDisposition contentSecurityPolicyOption; 194 ContentSecurityPolicyDisposition contentSecurityPolicyOption;
185 CrossThreadFetchInitiatorInfoData initiatorInfo; 195 CrossThreadFetchInitiatorInfoData initiatorInfo;
186 RequestInitiatorContext requestInitiatorContext; 196 RequestInitiatorContext requestInitiatorContext;
187 SynchronousPolicy synchronousPolicy; 197 SynchronousPolicy synchronousPolicy;
188 CORSEnabled corsEnabled; 198 CORSEnabled corsEnabled;
189 RefPtr<SecurityOrigin> securityOrigin; 199 RefPtr<SecurityOrigin> securityOrigin;
190 String contentSecurityPolicyNonce; 200 String contentSecurityPolicyNonce;
191 IntegrityMetadataSet integrityMetadata; 201 IntegrityMetadataSet integrityMetadata;
192 ParserDisposition parserDisposition; 202 ParserDisposition parserDisposition;
203 CacheAwareLoadingEnabled cacheAwareLoadingEnabled;
193 }; 204 };
194 205
195 template <> 206 template <>
196 struct CrossThreadCopier<ResourceLoaderOptions> { 207 struct CrossThreadCopier<ResourceLoaderOptions> {
197 using Type = CrossThreadResourceLoaderOptionsData; 208 using Type = CrossThreadResourceLoaderOptionsData;
198 static Type copy(const ResourceLoaderOptions& options) { 209 static Type copy(const ResourceLoaderOptions& options) {
199 return CrossThreadResourceLoaderOptionsData(options); 210 return CrossThreadResourceLoaderOptionsData(options);
200 } 211 }
201 }; 212 };
202 213
203 } // namespace blink 214 } // namespace blink
204 215
205 #endif // ResourceLoaderOptions_h 216 #endif // ResourceLoaderOptions_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698