OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013, Intel Corporation | 3 * Copyright (C) 2013, Intel Corporation |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 void redirectReceived(Resource*, | 111 void redirectReceived(Resource*, |
112 ResourceRequest&, | 112 ResourceRequest&, |
113 const ResourceResponse&) override; | 113 const ResourceResponse&) override; |
114 void redirectBlocked() override; | 114 void redirectBlocked() override; |
115 void dataDownloaded(Resource*, int) override; | 115 void dataDownloaded(Resource*, int) override; |
116 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override; | 116 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override; |
117 | 117 |
118 // |this| may be dead after calling this method in async mode. | 118 // |this| may be dead after calling this method in async mode. |
119 void cancelWithError(const ResourceError&); | 119 void cancelWithError(const ResourceError&); |
120 | 120 |
121 // Notify Inspector and log to console about resource response. Use | 121 // Notify Inspector and log to console about resource response. Use this |
122 // this method if response is not going to be finished normally. | 122 // method if response is not going to be finished normally. |
123 void reportResponseReceived(unsigned long identifier, | 123 void reportResponseReceived(unsigned long identifier, |
124 const ResourceResponse&); | 124 const ResourceResponse&); |
125 | 125 |
126 // Methods containing code to handle resource fetch results which are | 126 // Methods containing code to handle resource fetch results which are common |
127 // common to both sync and async mode. | 127 // to both sync and async mode. |
128 // | 128 // |
129 // |this| may be dead after calling these method in async mode. | 129 // |this| may be dead after calling these method in async mode. |
130 void handleResponse(unsigned long identifier, | 130 void handleResponse(unsigned long identifier, |
131 const ResourceResponse&, | 131 const ResourceResponse&, |
132 std::unique_ptr<WebDataConsumerHandle>); | 132 std::unique_ptr<WebDataConsumerHandle>); |
133 void handleReceivedData(const char* data, size_t dataLength); | 133 void handleReceivedData(const char* data, size_t dataLength); |
134 void handleSuccessfulFinish(unsigned long identifier, double finishTime); | 134 void handleSuccessfulFinish(unsigned long identifier, double finishTime); |
135 | 135 |
136 // |this| may be dead after calling this method. | 136 // |this| may be dead after calling this method. |
137 void didTimeout(TimerBase*); | 137 void didTimeout(TimerBase*); |
138 // Calls the appropriate loading method according to policy and data | 138 // Calls the appropriate loading method according to policy and data about |
139 // about origin. Only for handling the initial load (including fallback | 139 // origin. Only for handling the initial load (including fallback after |
140 // after consulting ServiceWorker). | 140 // consulting ServiceWorker). |
141 // | 141 // |
142 // |this| may be dead after calling this method in async mode. | 142 // |this| may be dead after calling this method in async mode. |
143 void dispatchInitialRequest(const ResourceRequest&); | 143 void dispatchInitialRequest(const ResourceRequest&); |
144 // |this| may be dead after calling this method in async mode. | 144 // |this| may be dead after calling this method in async mode. |
145 void makeCrossOriginAccessRequest(const ResourceRequest&); | 145 void makeCrossOriginAccessRequest(const ResourceRequest&); |
146 // Loads m_fallbackRequestForServiceWorker. | 146 // Loads m_fallbackRequestForServiceWorker. |
147 // | 147 // |
148 // |this| may be dead after calling this method in async mode. | 148 // |this| may be dead after calling this method in async mode. |
149 void loadFallbackRequestForServiceWorker(); | 149 void loadFallbackRequestForServiceWorker(); |
150 // Loads m_actualRequest. | 150 // Loads m_actualRequest. |
151 void loadActualRequest(); | 151 void loadActualRequest(); |
152 // Clears m_actualRequest and reports access control check failure to | 152 // Clears m_actualRequest and reports access control check failure to |
153 // m_client. | 153 // m_client. |
154 // | 154 // |
155 // |this| may be dead after calling this method in async mode. | 155 // |this| may be dead after calling this method in async mode. |
156 void handlePreflightFailure(const String& url, | 156 void handlePreflightFailure(const String& url, |
157 const String& errorDescription); | 157 const String& errorDescription); |
158 // Investigates the response for the preflight request. If successful, | 158 // Investigates the response for the preflight request. If successful, |
159 // the actual request will be made later in handleSuccessfulFinish(). | 159 // the actual request will be made later in handleSuccessfulFinish(). |
160 // | 160 // |
161 // |this| may be dead after calling this method in async mode. | 161 // |this| may be dead after calling this method in async mode. |
162 void handlePreflightResponse(const ResourceResponse&); | 162 void handlePreflightResponse(const ResourceResponse&); |
163 // |this| may be dead after calling this method. | 163 // |this| may be dead after calling this method. |
164 void handleError(const ResourceError&); | 164 void handleError(const ResourceError&); |
165 | 165 |
166 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); | 166 void loadRequest(const ResourceRequest&, ResourceLoaderOptions); |
167 bool isAllowedRedirect(const KURL&) const; | 167 bool isAllowedRedirect(const KURL&) const; |
168 // Returns DoNotAllowStoredCredentials | 168 // Returns DoNotAllowStoredCredentials if m_forceDoNotAllowStoredCredentials |
169 // if m_forceDoNotAllowStoredCredentials is set. Otherwise, just | 169 // is set. Otherwise, just returns allowCredentials value of |
170 // returns allowCredentials value of m_resourceLoaderOptions. | 170 // m_resourceLoaderOptions. |
171 StoredCredentials effectiveAllowCredentials() const; | 171 StoredCredentials effectiveAllowCredentials() const; |
172 | 172 |
173 // TODO(hiroshige): After crbug.com/633696 is fixed, | 173 // TODO(hiroshige): After crbug.com/633696 is fixed, |
174 // - Remove RawResourceClientStateChecker logic, | 174 // - Remove RawResourceClientStateChecker logic, |
175 // - Make DocumentThreadableLoader to be a ResourceOwner and remove | 175 // - Make DocumentThreadableLoader to be a ResourceOwner and remove this |
176 // this re-implementation of ResourceOwner, and | 176 // re-implementation of ResourceOwner, and |
177 // - Consider re-applying RawResourceClientStateChecker in a more | 177 // - Consider re-applying RawResourceClientStateChecker in a more |
178 // general fashion (crbug.com/640291). | 178 // general fashion (crbug.com/640291). |
179 RawResource* resource() const { return m_resource.get(); } | 179 RawResource* resource() const { return m_resource.get(); } |
180 void clearResource() { setResource(nullptr); } | 180 void clearResource() { setResource(nullptr); } |
181 void setResource(RawResource* newResource) { | 181 void setResource(RawResource* newResource) { |
182 if (newResource == m_resource) | 182 if (newResource == m_resource) |
183 return; | 183 return; |
184 | 184 |
185 if (RawResource* oldResource = m_resource.release()) { | 185 if (RawResource* oldResource = m_resource.release()) { |
186 m_checker.willRemoveClient(); | 186 m_checker.willRemoveClient(); |
187 oldResource->removeClient(this); | 187 oldResource->removeClient(this); |
188 } | 188 } |
189 | 189 |
190 if (newResource) { | 190 if (newResource) { |
191 m_resource = newResource; | 191 m_resource = newResource; |
192 m_checker.willAddClient(); | 192 m_checker.willAddClient(); |
193 m_resource->addClient(this); | 193 m_resource->addClient(this); |
194 } | 194 } |
195 } | 195 } |
196 Member<RawResource> m_resource; | 196 Member<RawResource> m_resource; |
197 // End of ResourceOwner re-implementation, see above. | 197 // End of ResourceOwner re-implementation, see above. |
198 | 198 |
199 const SecurityOrigin* getSecurityOrigin() const; | 199 const SecurityOrigin* getSecurityOrigin() const; |
200 Document& document() const; | 200 Document& document() const; |
201 | 201 |
202 ThreadableLoaderClient* m_client; | 202 ThreadableLoaderClient* m_client; |
203 Member<Document> m_document; | 203 Member<Document> m_document; |
204 | 204 |
205 const ThreadableLoaderOptions m_options; | 205 const ThreadableLoaderOptions m_options; |
206 // Some items may be overridden by m_forceDoNotAllowStoredCredentials | 206 // Some items may be overridden by m_forceDoNotAllowStoredCredentials and |
207 // and m_securityOrigin. In such a case, build a ResourceLoaderOptions | 207 // m_securityOrigin. In such a case, build a ResourceLoaderOptions with |
208 // with up-to-date values from them and this variable, and use it. | 208 // up-to-date values from them and this variable, and use it. |
209 const ResourceLoaderOptions m_resourceLoaderOptions; | 209 const ResourceLoaderOptions m_resourceLoaderOptions; |
210 | 210 |
211 bool m_forceDoNotAllowStoredCredentials; | 211 bool m_forceDoNotAllowStoredCredentials; |
212 RefPtr<SecurityOrigin> m_securityOrigin; | 212 RefPtr<SecurityOrigin> m_securityOrigin; |
213 | 213 |
214 // True while the initial URL and all the URLs of the redirects | 214 // True while the initial URL and all the URLs of the redirects this object |
215 // this object has followed, if any, are same-origin to | 215 // has followed, if any, are same-origin to getSecurityOrigin(). |
216 // getSecurityOrigin(). | |
217 bool m_sameOriginRequest; | 216 bool m_sameOriginRequest; |
218 // Set to true if the current request is cross-origin and not simple. | 217 // Set to true if the current request is cross-origin and not simple. |
219 bool m_crossOriginNonSimpleRequest; | 218 bool m_crossOriginNonSimpleRequest; |
220 | 219 |
221 // Set to true when the response data is given to a data consumer | 220 // Set to true when the response data is given to a data consumer handle. |
222 // handle. | |
223 bool m_isUsingDataConsumerHandle; | 221 bool m_isUsingDataConsumerHandle; |
224 | 222 |
225 const bool m_async; | 223 const bool m_async; |
226 | 224 |
227 // Holds the original request context (used for sanity checks). | 225 // Holds the original request context (used for sanity checks). |
228 WebURLRequest::RequestContext m_requestContext; | 226 WebURLRequest::RequestContext m_requestContext; |
229 | 227 |
230 // Holds the original request for fallback in case the Service Worker | 228 // Holds the original request for fallback in case the Service Worker |
231 // does not respond. | 229 // does not respond. |
232 ResourceRequest m_fallbackRequestForServiceWorker; | 230 ResourceRequest m_fallbackRequestForServiceWorker; |
233 | 231 |
234 // Holds the original request and options for it during preflight | 232 // Holds the original request and options for it during preflight request |
235 // request handling phase. | 233 // handling phase. |
236 ResourceRequest m_actualRequest; | 234 ResourceRequest m_actualRequest; |
237 ResourceLoaderOptions m_actualOptions; | 235 ResourceLoaderOptions m_actualOptions; |
238 | 236 |
239 HTTPHeaderMap | 237 HTTPHeaderMap m_simpleRequestHeaders; // stores simple request headers in |
yhirano
2016/10/03 08:37:34
Placing the comment before the member variable mig
Charlie Harrison
2016/10/03 12:30:05
Done. Yupp I tried to fix most of these cases.
| |
240 m_simpleRequestHeaders; // stores simple request headers in case of a cro ss-origin redirect. | 238 // case of a cross-origin redirect. |
241 Timer<DocumentThreadableLoader> m_timeoutTimer; | 239 Timer<DocumentThreadableLoader> m_timeoutTimer; |
242 double | 240 double |
243 m_requestStartedSeconds; // Time an asynchronous fetch request is started | 241 m_requestStartedSeconds; // Time an asynchronous fetch request is started |
244 | 242 |
245 // Max number of times that this DocumentThreadableLoader can follow | 243 // Max number of times that this DocumentThreadableLoader can follow |
246 // cross-origin redirects. | 244 // cross-origin redirects. This is used to limit the number of redirects. But |
247 // This is used to limit the number of redirects. | 245 // this value is not the max number of total redirects allowed, because |
248 // But this value is not the max number of total redirects allowed, | 246 // same-origin redirects are not counted here. |
249 // because same-origin redirects are not counted here. | |
250 int m_corsRedirectLimit; | 247 int m_corsRedirectLimit; |
251 | 248 |
252 WebURLRequest::FetchRedirectMode m_redirectMode; | 249 WebURLRequest::FetchRedirectMode m_redirectMode; |
253 | 250 |
254 // Holds the referrer after a redirect response was | 251 // Holds the referrer after a redirect response was received. This referrer is |
255 // received. This referrer is used to populate the HTTP Referer | 252 // used to populate the HTTP Referer header when following the redirect. |
256 // header when following the redirect. | |
257 bool m_didRedirect; | 253 bool m_didRedirect; |
258 Referrer m_referrerAfterRedirect; | 254 Referrer m_referrerAfterRedirect; |
259 | 255 |
260 RawResourceClientStateChecker m_checker; | 256 RawResourceClientStateChecker m_checker; |
261 }; | 257 }; |
262 | 258 |
263 } // namespace blink | 259 } // namespace blink |
264 | 260 |
265 #endif // DocumentThreadableLoader_h | 261 #endif // DocumentThreadableLoader_h |
OLD | NEW |