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

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

Issue 531553002: Remove dead content sniffing code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | 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) 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 19 matching lines...) Expand all
30 30
31 #ifndef ResourceLoaderOptions_h 31 #ifndef ResourceLoaderOptions_h
32 #define ResourceLoaderOptions_h 32 #define ResourceLoaderOptions_h
33 33
34 #include "core/fetch/FetchInitiatorInfo.h" 34 #include "core/fetch/FetchInitiatorInfo.h"
35 #include "platform/CrossThreadCopier.h" 35 #include "platform/CrossThreadCopier.h"
36 #include "platform/weborigin/SecurityOrigin.h" 36 #include "platform/weborigin/SecurityOrigin.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 enum ContentSniffingPolicy {
41 SniffContent,
42 DoNotSniffContent
43 };
44
45 enum DataBufferingPolicy { 40 enum DataBufferingPolicy {
46 BufferData, 41 BufferData,
47 DoNotBufferData 42 DoNotBufferData
48 }; 43 };
49 44
50 enum ContentSecurityPolicyCheck { 45 enum ContentSecurityPolicyCheck {
51 CheckContentSecurityPolicy, 46 CheckContentSecurityPolicy,
52 DoNotCheckContentSecurityPolicy 47 DoNotCheckContentSecurityPolicy
53 }; 48 };
54 49
(...skipping 30 matching lines...) Expand all
85 80
86 // A resource fetch can be marked as being CORS enabled. The loader 81 // A resource fetch can be marked as being CORS enabled. The loader
87 // must perform an access check upon seeing the response. 82 // must perform an access check upon seeing the response.
88 enum CORSEnabled { 83 enum CORSEnabled {
89 NotCORSEnabled, 84 NotCORSEnabled,
90 IsCORSEnabled 85 IsCORSEnabled
91 }; 86 };
92 87
93 struct ResourceLoaderOptions { 88 struct ResourceLoaderOptions {
94 ResourceLoaderOptions() 89 ResourceLoaderOptions()
95 : sniffContent(DoNotSniffContent) 90 : dataBufferingPolicy(BufferData)
96 , dataBufferingPolicy(BufferData)
97 , allowCredentials(DoNotAllowStoredCredentials) 91 , allowCredentials(DoNotAllowStoredCredentials)
98 , credentialsRequested(ClientDidNotRequestCredentials) 92 , credentialsRequested(ClientDidNotRequestCredentials)
99 , contentSecurityPolicyOption(CheckContentSecurityPolicy) 93 , contentSecurityPolicyOption(CheckContentSecurityPolicy)
100 , requestInitiatorContext(DocumentContext) 94 , requestInitiatorContext(DocumentContext)
101 , mixedContentBlockingTreatment(TreatAsDefaultForType) 95 , mixedContentBlockingTreatment(TreatAsDefaultForType)
102 , synchronousPolicy(RequestAsynchronously) 96 , synchronousPolicy(RequestAsynchronously)
103 , corsEnabled(NotCORSEnabled) 97 , corsEnabled(NotCORSEnabled)
104 { 98 {
105 } 99 }
106 100
107 ResourceLoaderOptions( 101 ResourceLoaderOptions(
108 ContentSniffingPolicy sniffContent,
109 DataBufferingPolicy dataBufferingPolicy, 102 DataBufferingPolicy dataBufferingPolicy,
110 StoredCredentials allowCredentials, 103 StoredCredentials allowCredentials,
111 CredentialRequest credentialsRequested, 104 CredentialRequest credentialsRequested,
112 ContentSecurityPolicyCheck contentSecurityPolicyOption, 105 ContentSecurityPolicyCheck contentSecurityPolicyOption,
113 RequestInitiatorContext requestInitiatorContext) 106 RequestInitiatorContext requestInitiatorContext)
114 : sniffContent(sniffContent) 107 : dataBufferingPolicy(dataBufferingPolicy)
115 , dataBufferingPolicy(dataBufferingPolicy)
116 , allowCredentials(allowCredentials) 108 , allowCredentials(allowCredentials)
117 , credentialsRequested(credentialsRequested) 109 , credentialsRequested(credentialsRequested)
118 , contentSecurityPolicyOption(contentSecurityPolicyOption) 110 , contentSecurityPolicyOption(contentSecurityPolicyOption)
119 , requestInitiatorContext(requestInitiatorContext) 111 , requestInitiatorContext(requestInitiatorContext)
120 , mixedContentBlockingTreatment(TreatAsDefaultForType) 112 , mixedContentBlockingTreatment(TreatAsDefaultForType)
121 , synchronousPolicy(RequestAsynchronously) 113 , synchronousPolicy(RequestAsynchronously)
122 , corsEnabled(NotCORSEnabled) 114 , corsEnabled(NotCORSEnabled)
123 { 115 {
124 } 116 }
125 117
126 // Answers the question "can a separate request with these 118 // Answers the question "can a separate request with these
127 // different options be re-used" (e.g. preload request) 119 // different options be re-used" (e.g. preload request)
128 // The safe (but possibly slow) answer is always false. 120 // The safe (but possibly slow) answer is always false.
129 bool canReuseRequest(const ResourceLoaderOptions& other) const 121 bool canReuseRequest(const ResourceLoaderOptions& other) const
130 { 122 {
131 // sniffContent is dead code.
132 // dataBufferingPolicy differences are believed to be safe for re-use. 123 // dataBufferingPolicy differences are believed to be safe for re-use.
133 // FIXME: check allowCredentials. 124 // FIXME: check allowCredentials.
134 // FIXME: check credentialsRequested. 125 // FIXME: check credentialsRequested.
135 // FIXME: check contentSecurityPolicyOption. 126 // FIXME: check contentSecurityPolicyOption.
136 // initiatorInfo is purely informational and should be benign for re-use . 127 // initiatorInfo is purely informational and should be benign for re-use .
137 // requestInitiatorContext is benign (indicates document vs. worker) 128 // requestInitiatorContext is benign (indicates document vs. worker)
138 // FIXME: check mixedContentBlockingTreatment. 129 // FIXME: check mixedContentBlockingTreatment.
139 // synchronousPolicy (safe to re-use an async XHR response for sync, etc .) 130 // synchronousPolicy (safe to re-use an async XHR response for sync, etc .)
140 return corsEnabled == other.corsEnabled; 131 return corsEnabled == other.corsEnabled;
141 // securityOrigin has more complicated checks which callers are responsi ble for. 132 // securityOrigin has more complicated checks which callers are responsi ble for.
142 } 133 }
143 134
144 // When adding members, CrossThreadResourceLoaderOptionsData should be 135 // When adding members, CrossThreadResourceLoaderOptionsData should be
145 // updated. 136 // updated.
146 ContentSniffingPolicy sniffContent; // FIXME: Dead code, please remove.
147 DataBufferingPolicy dataBufferingPolicy; 137 DataBufferingPolicy dataBufferingPolicy;
148 StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request. 138 StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request.
149 CredentialRequest credentialsRequested; // Whether the client (e.g. XHR) wan ted credentials in the first place. 139 CredentialRequest credentialsRequested; // Whether the client (e.g. XHR) wan ted credentials in the first place.
150 ContentSecurityPolicyCheck contentSecurityPolicyOption; 140 ContentSecurityPolicyCheck contentSecurityPolicyOption;
151 FetchInitiatorInfo initiatorInfo; 141 FetchInitiatorInfo initiatorInfo;
152 RequestInitiatorContext requestInitiatorContext; 142 RequestInitiatorContext requestInitiatorContext;
153 MixedContentBlockingTreatment mixedContentBlockingTreatment; 143 MixedContentBlockingTreatment mixedContentBlockingTreatment;
154 SynchronousPolicy synchronousPolicy; 144 SynchronousPolicy synchronousPolicy;
155 CORSEnabled corsEnabled; // If the resource is loaded out-of-origin, whether or not to use CORS. 145 CORSEnabled corsEnabled; // If the resource is loaded out-of-origin, whether or not to use CORS.
156 RefPtr<SecurityOrigin> securityOrigin; 146 RefPtr<SecurityOrigin> securityOrigin;
157 }; 147 };
158 148
159 // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads. 149 // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads.
160 struct CrossThreadResourceLoaderOptionsData { 150 struct CrossThreadResourceLoaderOptionsData {
161 explicit CrossThreadResourceLoaderOptionsData(const ResourceLoaderOptions& o ptions) 151 explicit CrossThreadResourceLoaderOptionsData(const ResourceLoaderOptions& o ptions)
162 : sniffContent(options.sniffContent) 152 : dataBufferingPolicy(options.dataBufferingPolicy)
163 , dataBufferingPolicy(options.dataBufferingPolicy)
164 , allowCredentials(options.allowCredentials) 153 , allowCredentials(options.allowCredentials)
165 , credentialsRequested(options.credentialsRequested) 154 , credentialsRequested(options.credentialsRequested)
166 , contentSecurityPolicyOption(options.contentSecurityPolicyOption) 155 , contentSecurityPolicyOption(options.contentSecurityPolicyOption)
167 , initiatorInfo(options.initiatorInfo) 156 , initiatorInfo(options.initiatorInfo)
168 , requestInitiatorContext(options.requestInitiatorContext) 157 , requestInitiatorContext(options.requestInitiatorContext)
169 , mixedContentBlockingTreatment(options.mixedContentBlockingTreatment) 158 , mixedContentBlockingTreatment(options.mixedContentBlockingTreatment)
170 , synchronousPolicy(options.synchronousPolicy) 159 , synchronousPolicy(options.synchronousPolicy)
171 , corsEnabled(options.corsEnabled) 160 , corsEnabled(options.corsEnabled)
172 , securityOrigin(options.securityOrigin) { } 161 , securityOrigin(options.securityOrigin) { }
173 162
174 operator ResourceLoaderOptions() const 163 operator ResourceLoaderOptions() const
175 { 164 {
176 ResourceLoaderOptions options; 165 ResourceLoaderOptions options;
177 options.sniffContent = sniffContent;
178 options.dataBufferingPolicy = dataBufferingPolicy; 166 options.dataBufferingPolicy = dataBufferingPolicy;
179 options.allowCredentials = allowCredentials; 167 options.allowCredentials = allowCredentials;
180 options.credentialsRequested = credentialsRequested; 168 options.credentialsRequested = credentialsRequested;
181 options.contentSecurityPolicyOption = contentSecurityPolicyOption; 169 options.contentSecurityPolicyOption = contentSecurityPolicyOption;
182 options.initiatorInfo = initiatorInfo; 170 options.initiatorInfo = initiatorInfo;
183 options.requestInitiatorContext = requestInitiatorContext; 171 options.requestInitiatorContext = requestInitiatorContext;
184 options.mixedContentBlockingTreatment = mixedContentBlockingTreatment; 172 options.mixedContentBlockingTreatment = mixedContentBlockingTreatment;
185 options.synchronousPolicy = synchronousPolicy; 173 options.synchronousPolicy = synchronousPolicy;
186 options.corsEnabled = corsEnabled; 174 options.corsEnabled = corsEnabled;
187 options.securityOrigin = securityOrigin; 175 options.securityOrigin = securityOrigin;
188 return options; 176 return options;
189 } 177 }
190 178
191 ContentSniffingPolicy sniffContent;
192 DataBufferingPolicy dataBufferingPolicy; 179 DataBufferingPolicy dataBufferingPolicy;
193 StoredCredentials allowCredentials; 180 StoredCredentials allowCredentials;
194 CredentialRequest credentialsRequested; 181 CredentialRequest credentialsRequested;
195 ContentSecurityPolicyCheck contentSecurityPolicyOption; 182 ContentSecurityPolicyCheck contentSecurityPolicyOption;
196 CrossThreadFetchInitiatorInfoData initiatorInfo; 183 CrossThreadFetchInitiatorInfoData initiatorInfo;
197 RequestInitiatorContext requestInitiatorContext; 184 RequestInitiatorContext requestInitiatorContext;
198 MixedContentBlockingTreatment mixedContentBlockingTreatment; 185 MixedContentBlockingTreatment mixedContentBlockingTreatment;
199 SynchronousPolicy synchronousPolicy; 186 SynchronousPolicy synchronousPolicy;
200 CORSEnabled corsEnabled; 187 CORSEnabled corsEnabled;
201 RefPtr<SecurityOrigin> securityOrigin; 188 RefPtr<SecurityOrigin> securityOrigin;
202 }; 189 };
203 190
204 template<> struct CrossThreadCopierBase<false, false, false, ResourceLoaderOptio ns> { 191 template<> struct CrossThreadCopierBase<false, false, false, ResourceLoaderOptio ns> {
205 typedef CrossThreadResourceLoaderOptionsData Type; 192 typedef CrossThreadResourceLoaderOptionsData Type;
206 static Type copy(const ResourceLoaderOptions& options) 193 static Type copy(const ResourceLoaderOptions& options)
207 { 194 {
208 return CrossThreadResourceLoaderOptionsData(options); 195 return CrossThreadResourceLoaderOptionsData(options);
209 } 196 }
210 }; 197 };
211 198
212 } // namespace blink 199 } // namespace blink
213 200
214 #endif // ResourceLoaderOptions_h 201 #endif // ResourceLoaderOptions_h
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceLoader.h ('k') | Source/core/loader/DocumentLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698