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

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

Issue 356723003: Add 'XHR' to the Resource::Type enum, and use it for XHR requests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Preflight. Created 6 years, 5 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 | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/inspector/InspectorPageAgent.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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // APIs like XMLHttpRequest and EventSource let the user decide 64 // APIs like XMLHttpRequest and EventSource let the user decide
65 // whether to send credentials, but they're always sent for 65 // whether to send credentials, but they're always sent for
66 // same-origin requests. Additional information is needed to handle 66 // same-origin requests. Additional information is needed to handle
67 // cross-origin redirects correctly. 67 // cross-origin redirects correctly.
68 enum CredentialRequest { 68 enum CredentialRequest {
69 ClientRequestedCredentials, 69 ClientRequestedCredentials,
70 ClientDidNotRequestCredentials 70 ClientDidNotRequestCredentials
71 }; 71 };
72 72
73 enum MixedContentBlockingTreatment {
74 TreatAsDefaultForType,
75 TreatAsPassiveContent,
76 TreatAsActiveContent,
77 TreatAsAlwaysAllowedContent
78 };
79
80 enum SynchronousPolicy { 73 enum SynchronousPolicy {
81 RequestSynchronously, 74 RequestSynchronously,
82 RequestAsynchronously 75 RequestAsynchronously
83 }; 76 };
84 77
85 // A resource fetch can be marked as being CORS enabled. The loader 78 // A resource fetch can be marked as being CORS enabled. The loader
86 // must perform an access check upon seeing the response. 79 // must perform an access check upon seeing the response.
87 enum CORSEnabled { 80 enum CORSEnabled {
88 NotCORSEnabled, 81 NotCORSEnabled,
89 IsCORSEnabled 82 IsCORSEnabled
90 }; 83 };
91 84
92 struct ResourceLoaderOptions { 85 struct ResourceLoaderOptions {
93 ResourceLoaderOptions() 86 ResourceLoaderOptions()
94 : sniffContent(DoNotSniffContent) 87 : sniffContent(DoNotSniffContent)
95 , dataBufferingPolicy(BufferData) 88 , dataBufferingPolicy(BufferData)
96 , allowCredentials(DoNotAllowStoredCredentials) 89 , allowCredentials(DoNotAllowStoredCredentials)
97 , credentialsRequested(ClientDidNotRequestCredentials) 90 , credentialsRequested(ClientDidNotRequestCredentials)
98 , contentSecurityPolicyOption(CheckContentSecurityPolicy) 91 , contentSecurityPolicyOption(CheckContentSecurityPolicy)
99 , requestInitiatorContext(DocumentContext) 92 , requestInitiatorContext(DocumentContext)
100 , mixedContentBlockingTreatment(TreatAsDefaultForType)
101 , synchronousPolicy(RequestAsynchronously) 93 , synchronousPolicy(RequestAsynchronously)
102 , corsEnabled(NotCORSEnabled) 94 , corsEnabled(NotCORSEnabled)
103 { 95 {
104 } 96 }
105 97
106 ResourceLoaderOptions( 98 ResourceLoaderOptions(
107 ContentSniffingPolicy sniffContent, 99 ContentSniffingPolicy sniffContent,
108 DataBufferingPolicy dataBufferingPolicy, 100 DataBufferingPolicy dataBufferingPolicy,
109 StoredCredentials allowCredentials, 101 StoredCredentials allowCredentials,
110 CredentialRequest credentialsRequested, 102 CredentialRequest credentialsRequested,
111 ContentSecurityPolicyCheck contentSecurityPolicyOption, 103 ContentSecurityPolicyCheck contentSecurityPolicyOption,
112 RequestInitiatorContext requestInitiatorContext) 104 RequestInitiatorContext requestInitiatorContext)
113 : sniffContent(sniffContent) 105 : sniffContent(sniffContent)
114 , dataBufferingPolicy(dataBufferingPolicy) 106 , dataBufferingPolicy(dataBufferingPolicy)
115 , allowCredentials(allowCredentials) 107 , allowCredentials(allowCredentials)
116 , credentialsRequested(credentialsRequested) 108 , credentialsRequested(credentialsRequested)
117 , contentSecurityPolicyOption(contentSecurityPolicyOption) 109 , contentSecurityPolicyOption(contentSecurityPolicyOption)
118 , requestInitiatorContext(requestInitiatorContext) 110 , requestInitiatorContext(requestInitiatorContext)
119 , mixedContentBlockingTreatment(TreatAsDefaultForType)
120 , synchronousPolicy(RequestAsynchronously) 111 , synchronousPolicy(RequestAsynchronously)
121 , corsEnabled(NotCORSEnabled) 112 , corsEnabled(NotCORSEnabled)
122 { 113 {
123 } 114 }
124 115
125 // Answers the question "can a separate request with these 116 // Answers the question "can a separate request with these
126 // different options be re-used" (e.g. preload request) 117 // different options be re-used" (e.g. preload request)
127 // The safe (but possibly slow) answer is always false. 118 // The safe (but possibly slow) answer is always false.
128 bool canReuseRequest(const ResourceLoaderOptions& other) const 119 bool canReuseRequest(const ResourceLoaderOptions& other) const
129 { 120 {
130 // sniffContent is dead code. 121 // sniffContent is dead code.
131 // dataBufferingPolicy differences are believed to be safe for re-use. 122 // dataBufferingPolicy differences are believed to be safe for re-use.
132 // FIXME: check allowCredentials. 123 // FIXME: check allowCredentials.
133 // FIXME: check credentialsRequested. 124 // FIXME: check credentialsRequested.
134 // FIXME: check contentSecurityPolicyOption. 125 // FIXME: check contentSecurityPolicyOption.
135 // initiatorInfo is purely informational and should be benign for re-use . 126 // initiatorInfo is purely informational and should be benign for re-use .
136 // requestInitiatorContext is benign (indicates document vs. worker) 127 // requestInitiatorContext is benign (indicates document vs. worker)
137 // FIXME: check mixedContentBlockingTreatment.
138 // synchronousPolicy (safe to re-use an async XHR response for sync, etc .) 128 // synchronousPolicy (safe to re-use an async XHR response for sync, etc .)
139 return corsEnabled == other.corsEnabled; 129 return corsEnabled == other.corsEnabled;
140 // securityOrigin has more complicated checks which callers are responsi ble for. 130 // securityOrigin has more complicated checks which callers are responsi ble for.
141 } 131 }
142 132
143 ContentSniffingPolicy sniffContent; // FIXME: Dead code, please remove. 133 ContentSniffingPolicy sniffContent; // FIXME: Dead code, please remove.
144 DataBufferingPolicy dataBufferingPolicy; 134 DataBufferingPolicy dataBufferingPolicy;
145 StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request. 135 StoredCredentials allowCredentials; // Whether HTTP credentials and cookies are sent with the request.
146 CredentialRequest credentialsRequested; // Whether the client (e.g. XHR) wan ted credentials in the first place. 136 CredentialRequest credentialsRequested; // Whether the client (e.g. XHR) wan ted credentials in the first place.
147 ContentSecurityPolicyCheck contentSecurityPolicyOption; 137 ContentSecurityPolicyCheck contentSecurityPolicyOption;
148 FetchInitiatorInfo initiatorInfo; 138 FetchInitiatorInfo initiatorInfo;
149 RequestInitiatorContext requestInitiatorContext; 139 RequestInitiatorContext requestInitiatorContext;
150 MixedContentBlockingTreatment mixedContentBlockingTreatment;
151 SynchronousPolicy synchronousPolicy; 140 SynchronousPolicy synchronousPolicy;
152 CORSEnabled corsEnabled; // If the resource is loaded out-of-origin, whether or not to use CORS. 141 CORSEnabled corsEnabled; // If the resource is loaded out-of-origin, whether or not to use CORS.
153 RefPtr<SecurityOrigin> securityOrigin; 142 RefPtr<SecurityOrigin> securityOrigin;
154 }; 143 };
155 144
156 } // namespace WebCore 145 } // namespace WebCore
157 146
158 #endif // ResourceLoaderOptions_h 147 #endif // ResourceLoaderOptions_h
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.cpp ('k') | Source/core/inspector/InspectorPageAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698