| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #ifndef SKY_ENGINE_CORE_FETCH_RESOURCELOADEROPTIONS_H_ | |
| 32 #define SKY_ENGINE_CORE_FETCH_RESOURCELOADEROPTIONS_H_ | |
| 33 | |
| 34 #include "sky/engine/core/fetch/FetchInitiatorInfo.h" | |
| 35 | |
| 36 namespace blink { | |
| 37 | |
| 38 enum DataBufferingPolicy { | |
| 39 BufferData, | |
| 40 DoNotBufferData | |
| 41 }; | |
| 42 | |
| 43 enum RequestInitiatorContext { | |
| 44 DocumentContext, | |
| 45 }; | |
| 46 | |
| 47 enum StoredCredentials { | |
| 48 AllowStoredCredentials, | |
| 49 DoNotAllowStoredCredentials | |
| 50 }; | |
| 51 | |
| 52 // APIs like XMLHttpRequest and EventSource let the user decide | |
| 53 // whether to send credentials, but they're always sent for | |
| 54 // same-origin requests. Additional information is needed to handle | |
| 55 // cross-origin redirects correctly. | |
| 56 enum CredentialRequest { | |
| 57 ClientRequestedCredentials, | |
| 58 ClientDidNotRequestCredentials | |
| 59 }; | |
| 60 | |
| 61 // FIXME(sky): remove | |
| 62 enum SynchronousPolicy { | |
| 63 RequestAsynchronously | |
| 64 }; | |
| 65 | |
| 66 // A resource fetch can be marked as being CORS enabled. The loader | |
| 67 // must perform an access check upon seeing the response. | |
| 68 enum CORSEnabled { | |
| 69 NotCORSEnabled, | |
| 70 IsCORSEnabled | |
| 71 }; | |
| 72 | |
| 73 struct ResourceLoaderOptions { | |
| 74 ResourceLoaderOptions() | |
| 75 : dataBufferingPolicy(BufferData) | |
| 76 , allowCredentials(DoNotAllowStoredCredentials) | |
| 77 , credentialsRequested(ClientDidNotRequestCredentials) | |
| 78 , requestInitiatorContext(DocumentContext) | |
| 79 , synchronousPolicy(RequestAsynchronously) | |
| 80 , corsEnabled(NotCORSEnabled) | |
| 81 { | |
| 82 } | |
| 83 | |
| 84 ResourceLoaderOptions( | |
| 85 DataBufferingPolicy dataBufferingPolicy, | |
| 86 StoredCredentials allowCredentials, | |
| 87 CredentialRequest credentialsRequested, | |
| 88 RequestInitiatorContext requestInitiatorContext) | |
| 89 : dataBufferingPolicy(dataBufferingPolicy) | |
| 90 , allowCredentials(allowCredentials) | |
| 91 , credentialsRequested(credentialsRequested) | |
| 92 , requestInitiatorContext(requestInitiatorContext) | |
| 93 , synchronousPolicy(RequestAsynchronously) | |
| 94 , corsEnabled(NotCORSEnabled) | |
| 95 { | |
| 96 } | |
| 97 | |
| 98 // Answers the question "can a separate request with these | |
| 99 // different options be re-used" (e.g. preload request) | |
| 100 // The safe (but possibly slow) answer is always false. | |
| 101 bool canReuseRequest(const ResourceLoaderOptions& other) const | |
| 102 { | |
| 103 // dataBufferingPolicy differences are believed to be safe for re-use. | |
| 104 // FIXME: check allowCredentials. | |
| 105 // FIXME: check credentialsRequested. | |
| 106 // FIXME: check contentSecurityPolicyOption. | |
| 107 // initiatorInfo is purely informational and should be benign for re-use
. | |
| 108 // requestInitiatorContext is benign (indicates document vs. worker) | |
| 109 // synchronousPolicy (safe to re-use an async XHR response for sync, etc
.) | |
| 110 return corsEnabled == other.corsEnabled; | |
| 111 } | |
| 112 | |
| 113 DataBufferingPolicy dataBufferingPolicy; | |
| 114 StoredCredentials allowCredentials; // Whether HTTP credentials and cookies
are sent with the request. | |
| 115 CredentialRequest credentialsRequested; // Whether the client (e.g. XHR) wan
ted credentials in the first place. | |
| 116 FetchInitiatorInfo initiatorInfo; | |
| 117 RequestInitiatorContext requestInitiatorContext; | |
| 118 SynchronousPolicy synchronousPolicy; | |
| 119 CORSEnabled corsEnabled; // If the resource is loaded out-of-origin, whether
or not to use CORS. | |
| 120 }; | |
| 121 | |
| 122 } // namespace blink | |
| 123 | |
| 124 #endif // SKY_ENGINE_CORE_FETCH_RESOURCELOADEROPTIONS_H_ | |
| OLD | NEW |