| OLD | NEW |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 DoNotCheckContentSecurityPolicy | 46 DoNotCheckContentSecurityPolicy |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 enum RequestInitiatorContext { | 49 enum RequestInitiatorContext { |
| 50 DocumentContext, | 50 DocumentContext, |
| 51 WorkerContext, | 51 WorkerContext, |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 enum StoredCredentials { AllowStoredCredentials, DoNotAllowStoredCredentials }; | 54 enum StoredCredentials { AllowStoredCredentials, DoNotAllowStoredCredentials }; |
| 55 | 55 |
| 56 // APIs like XMLHttpRequest and EventSource let the user decide | 56 // APIs like XMLHttpRequest and EventSource let the user decide whether to send |
| 57 // whether to send credentials, but they're always sent for | 57 // credentials, but they're always sent for same-origin requests. Additional |
| 58 // same-origin requests. Additional information is needed to handle | 58 // information is needed to handle cross-origin redirects correctly. |
| 59 // cross-origin redirects correctly. | |
| 60 enum CredentialRequest { | 59 enum CredentialRequest { |
| 61 ClientRequestedCredentials, | 60 ClientRequestedCredentials, |
| 62 ClientDidNotRequestCredentials | 61 ClientDidNotRequestCredentials |
| 63 }; | 62 }; |
| 64 | 63 |
| 65 enum SynchronousPolicy { RequestSynchronously, RequestAsynchronously }; | 64 enum SynchronousPolicy { RequestSynchronously, RequestAsynchronously }; |
| 66 | 65 |
| 67 // A resource fetch can be marked as being CORS enabled. The loader | 66 // A resource fetch can be marked as being CORS enabled. The loader must perform |
| 68 // must perform an access check upon seeing the response. | 67 // an access check upon seeing the response. |
| 69 enum CORSEnabled { NotCORSEnabled, IsCORSEnabled }; | 68 enum CORSEnabled { NotCORSEnabled, IsCORSEnabled }; |
| 70 | 69 |
| 71 struct ResourceLoaderOptions { | 70 struct ResourceLoaderOptions { |
| 72 USING_FAST_MALLOC(ResourceLoaderOptions); | 71 USING_FAST_MALLOC(ResourceLoaderOptions); |
| 73 | 72 |
| 74 public: | 73 public: |
| 75 ResourceLoaderOptions() | 74 ResourceLoaderOptions() |
| 76 : dataBufferingPolicy(BufferData), | 75 : dataBufferingPolicy(BufferData), |
| 77 allowCredentials(DoNotAllowStoredCredentials), | 76 allowCredentials(DoNotAllowStoredCredentials), |
| 78 credentialsRequested(ClientDidNotRequestCredentials), | 77 credentialsRequested(ClientDidNotRequestCredentials), |
| 79 contentSecurityPolicyOption(CheckContentSecurityPolicy), | 78 contentSecurityPolicyOption(CheckContentSecurityPolicy), |
| 80 requestInitiatorContext(DocumentContext), | 79 requestInitiatorContext(DocumentContext), |
| 81 synchronousPolicy(RequestAsynchronously), | 80 synchronousPolicy(RequestAsynchronously), |
| 82 corsEnabled(NotCORSEnabled) {} | 81 corsEnabled(NotCORSEnabled) {} |
| 83 | 82 |
| 84 ResourceLoaderOptions( | 83 ResourceLoaderOptions( |
| 85 DataBufferingPolicy dataBufferingPolicy, | 84 DataBufferingPolicy dataBufferingPolicy, |
| 86 StoredCredentials allowCredentials, | 85 StoredCredentials allowCredentials, |
| 87 CredentialRequest credentialsRequested, | 86 CredentialRequest credentialsRequested, |
| 88 ContentSecurityPolicyDisposition contentSecurityPolicyOption, | 87 ContentSecurityPolicyDisposition contentSecurityPolicyOption, |
| 89 RequestInitiatorContext requestInitiatorContext) | 88 RequestInitiatorContext requestInitiatorContext) |
| 90 : dataBufferingPolicy(dataBufferingPolicy), | 89 : dataBufferingPolicy(dataBufferingPolicy), |
| 91 allowCredentials(allowCredentials), | 90 allowCredentials(allowCredentials), |
| 92 credentialsRequested(credentialsRequested), | 91 credentialsRequested(credentialsRequested), |
| 93 contentSecurityPolicyOption(contentSecurityPolicyOption), | 92 contentSecurityPolicyOption(contentSecurityPolicyOption), |
| 94 requestInitiatorContext(requestInitiatorContext), | 93 requestInitiatorContext(requestInitiatorContext), |
| 95 synchronousPolicy(RequestAsynchronously), | 94 synchronousPolicy(RequestAsynchronously), |
| 96 corsEnabled(NotCORSEnabled) {} | 95 corsEnabled(NotCORSEnabled) {} |
| 97 | 96 |
| 98 // Answers the question "can a separate request with these | 97 // Answers the question "can a separate request with these different options |
| 99 // different options be re-used" (e.g. preload request) | 98 // be re-used" (e.g. preload request) The safe (but possibly slow) answer is |
| 100 // The safe (but possibly slow) answer is always false. | 99 // always false. |
| 101 bool canReuseRequest(const ResourceLoaderOptions& other) const { | 100 bool canReuseRequest(const ResourceLoaderOptions& other) const { |
| 102 // dataBufferingPolicy differences are believed to be safe for re-use. | 101 // dataBufferingPolicy differences are believed to be safe for re-use. |
| 103 // FIXME: check allowCredentials. | 102 // FIXME: check allowCredentials. |
| 104 // FIXME: check credentialsRequested. | 103 // FIXME: check credentialsRequested. |
| 105 // FIXME: check contentSecurityPolicyOption. | 104 // FIXME: check contentSecurityPolicyOption. |
| 106 // initiatorInfo is purely informational and should be benign for re-use. | 105 // initiatorInfo is purely informational and should be benign for re-use. |
| 107 // requestInitiatorContext is benign (indicates document vs. worker) | 106 // requestInitiatorContext is benign (indicates document vs. worker) |
| 108 // synchronousPolicy (safe to re-use an async XHR response for sync, etc.) | 107 // synchronousPolicy (safe to re-use an async XHR response for sync, etc.) |
| 109 return corsEnabled == other.corsEnabled; | 108 return corsEnabled == other.corsEnabled; |
| 110 // securityOrigin has more complicated checks which callers are responsible
for. | 109 // securityOrigin has more complicated checks which callers are responsible |
| 110 // for. |
| 111 } | 111 } |
| 112 | 112 |
| 113 // When adding members, CrossThreadResourceLoaderOptionsData should be | 113 // When adding members, CrossThreadResourceLoaderOptionsData should be |
| 114 // updated. | 114 // updated. |
| 115 DataBufferingPolicy dataBufferingPolicy; | 115 DataBufferingPolicy dataBufferingPolicy; |
| 116 StoredCredentials | 116 |
| 117 allowCredentials; // Whether HTTP credentials and cookies are sent with t
he request. | 117 // Whether HTTP credentials and cookies are sent with the request. |
| 118 CredentialRequest | 118 StoredCredentials allowCredentials; |
| 119 credentialsRequested; // Whether the client (e.g. XHR) wanted credentials
in the first place. | 119 |
| 120 // Whether the client (e.g. XHR) wanted credentials in the first place. |
| 121 CredentialRequest credentialsRequested; |
| 122 |
| 120 ContentSecurityPolicyDisposition contentSecurityPolicyOption; | 123 ContentSecurityPolicyDisposition contentSecurityPolicyOption; |
| 121 FetchInitiatorInfo initiatorInfo; | 124 FetchInitiatorInfo initiatorInfo; |
| 122 RequestInitiatorContext requestInitiatorContext; | 125 RequestInitiatorContext requestInitiatorContext; |
| 123 SynchronousPolicy synchronousPolicy; | 126 SynchronousPolicy synchronousPolicy; |
| 124 CORSEnabled | 127 |
| 125 corsEnabled; // If the resource is loaded out-of-origin, whether or not t
o use CORS. | 128 // If the resource is loaded out-of-origin, whether or not to use CORS. |
| 129 CORSEnabled corsEnabled; |
| 130 |
| 126 RefPtr<SecurityOrigin> securityOrigin; | 131 RefPtr<SecurityOrigin> securityOrigin; |
| 127 String contentSecurityPolicyNonce; | 132 String contentSecurityPolicyNonce; |
| 128 IntegrityMetadataSet integrityMetadata; | 133 IntegrityMetadataSet integrityMetadata; |
| 129 }; | 134 }; |
| 130 | 135 |
| 131 // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads. | 136 // Encode AtomicString (in FetchInitiatorInfo) as String to cross threads. |
| 132 struct CrossThreadResourceLoaderOptionsData { | 137 struct CrossThreadResourceLoaderOptionsData { |
| 133 DISALLOW_NEW(); | 138 DISALLOW_NEW(); |
| 134 explicit CrossThreadResourceLoaderOptionsData( | 139 explicit CrossThreadResourceLoaderOptionsData( |
| 135 const ResourceLoaderOptions& options) | 140 const ResourceLoaderOptions& options) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 struct CrossThreadCopier<ResourceLoaderOptions> { | 185 struct CrossThreadCopier<ResourceLoaderOptions> { |
| 181 using Type = CrossThreadResourceLoaderOptionsData; | 186 using Type = CrossThreadResourceLoaderOptionsData; |
| 182 static Type copy(const ResourceLoaderOptions& options) { | 187 static Type copy(const ResourceLoaderOptions& options) { |
| 183 return CrossThreadResourceLoaderOptionsData(options); | 188 return CrossThreadResourceLoaderOptionsData(options); |
| 184 } | 189 } |
| 185 }; | 190 }; |
| 186 | 191 |
| 187 } // namespace blink | 192 } // namespace blink |
| 188 | 193 |
| 189 #endif // ResourceLoaderOptions_h | 194 #endif // ResourceLoaderOptions_h |
| OLD | NEW |