| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 StoredCredentials, | 197 StoredCredentials, |
| 198 bool); | 198 bool); |
| 199 ~PingLoaderImpl() override; | 199 ~PingLoaderImpl() override; |
| 200 | 200 |
| 201 DECLARE_VIRTUAL_TRACE(); | 201 DECLARE_VIRTUAL_TRACE(); |
| 202 | 202 |
| 203 private: | 203 private: |
| 204 void dispose(); | 204 void dispose(); |
| 205 | 205 |
| 206 // WebURLLoaderClient | 206 // WebURLLoaderClient |
| 207 void willFollowRedirect(WebURLLoader*, | 207 bool willFollowRedirect(WebURLLoader*, |
| 208 WebURLRequest&, | 208 WebURLRequest&, |
| 209 const WebURLResponse&) override; | 209 const WebURLResponse&) override; |
| 210 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) final; | 210 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) final; |
| 211 void didReceiveData(WebURLLoader*, const char*, int, int, int) final; | 211 void didReceiveData(WebURLLoader*, const char*, int, int, int) final; |
| 212 void didFinishLoading(WebURLLoader*, double, int64_t) final; | 212 void didFinishLoading(WebURLLoader*, double, int64_t) final; |
| 213 void didFail(WebURLLoader*, const WebURLError&) final; | 213 void didFail(WebURLLoader*, const WebURLError&) final; |
| 214 | 214 |
| 215 void timeout(TimerBase*); | 215 void timeout(TimerBase*); |
| 216 | 216 |
| 217 void didFailLoading(LocalFrame*); | 217 void didFailLoading(LocalFrame*); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 281 |
| 282 void PingLoaderImpl::dispose() { | 282 void PingLoaderImpl::dispose() { |
| 283 if (m_loader) { | 283 if (m_loader) { |
| 284 m_loader->cancel(); | 284 m_loader->cancel(); |
| 285 m_loader = nullptr; | 285 m_loader = nullptr; |
| 286 } | 286 } |
| 287 m_timeout.stop(); | 287 m_timeout.stop(); |
| 288 m_keepAlive.clear(); | 288 m_keepAlive.clear(); |
| 289 } | 289 } |
| 290 | 290 |
| 291 void PingLoaderImpl::willFollowRedirect( | 291 bool PingLoaderImpl::willFollowRedirect( |
| 292 WebURLLoader*, | 292 WebURLLoader*, |
| 293 WebURLRequest& passedNewRequest, | 293 WebURLRequest& passedNewRequest, |
| 294 const WebURLResponse& passedRedirectResponse) { | 294 const WebURLResponse& passedRedirectResponse) { |
| 295 if (!m_isBeacon) | 295 if (!m_isBeacon) |
| 296 return; | 296 return true; |
| 297 | 297 |
| 298 // TODO(tyoshino): Check if setAllowStoredCredentials() should be called also | 298 // TODO(tyoshino): Check if setAllowStoredCredentials() should be called also |
| 299 // for non beacon cases. | 299 // for non beacon cases. |
| 300 passedNewRequest.setAllowStoredCredentials(true); | 300 passedNewRequest.setAllowStoredCredentials(true); |
| 301 if (m_corsMode == NotCORSEnabled) | 301 if (m_corsMode == NotCORSEnabled) |
| 302 return; | 302 return true; |
| 303 | 303 |
| 304 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); | 304 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); |
| 305 const ResourceResponse& redirectResponse( | 305 const ResourceResponse& redirectResponse( |
| 306 passedRedirectResponse.toResourceResponse()); | 306 passedRedirectResponse.toResourceResponse()); |
| 307 | 307 |
| 308 DCHECK(!newRequest.isNull()); | 308 DCHECK(!newRequest.isNull()); |
| 309 DCHECK(!redirectResponse.isNull()); | 309 DCHECK(!redirectResponse.isNull()); |
| 310 | 310 |
| 311 String errorDescription; | 311 String errorDescription; |
| 312 ResourceLoaderOptions options; | 312 ResourceLoaderOptions options; |
| 313 // TODO(tyoshino): Save updated data in options.securityOrigin and pass it | 313 // TODO(tyoshino): Save updated data in options.securityOrigin and pass it |
| 314 // on the next time. | 314 // on the next time. |
| 315 if (!CrossOriginAccessControl::handleRedirect( | 315 if (!CrossOriginAccessControl::handleRedirect( |
| 316 m_origin, newRequest, redirectResponse, AllowStoredCredentials, | 316 m_origin, newRequest, redirectResponse, AllowStoredCredentials, |
| 317 options, errorDescription)) { | 317 options, errorDescription)) { |
| 318 if (LocalFrame* localFrame = frame()) { | 318 if (LocalFrame* localFrame = frame()) { |
| 319 if (localFrame->document()) | 319 if (localFrame->document()) |
| 320 localFrame->document()->addConsoleMessage(ConsoleMessage::create( | 320 localFrame->document()->addConsoleMessage(ConsoleMessage::create( |
| 321 JSMessageSource, ErrorMessageLevel, errorDescription)); | 321 JSMessageSource, ErrorMessageLevel, errorDescription)); |
| 322 } | 322 } |
| 323 // Cancel the load and self destruct. | 323 // Cancel the load and self destruct. |
| 324 dispose(); | 324 dispose(); |
| 325 // Signal WebURLLoader that the redirect musn't be followed. | 325 |
| 326 passedNewRequest = WebURLRequest(); | 326 return false; |
| 327 return; | |
| 328 } | 327 } |
| 329 // FIXME: http://crbug.com/427429 is needed to correctly propagate updates of | 328 // FIXME: http://crbug.com/427429 is needed to correctly propagate updates of |
| 330 // Origin: following this successful redirect. | 329 // Origin: following this successful redirect. |
| 330 |
| 331 return true; |
| 331 } | 332 } |
| 332 | 333 |
| 333 void PingLoaderImpl::didReceiveResponse(WebURLLoader*, | 334 void PingLoaderImpl::didReceiveResponse(WebURLLoader*, |
| 334 const WebURLResponse& response) { | 335 const WebURLResponse& response) { |
| 335 if (LocalFrame* frame = this->frame()) { | 336 if (LocalFrame* frame = this->frame()) { |
| 336 TRACE_EVENT_INSTANT1( | 337 TRACE_EVENT_INSTANT1( |
| 337 "devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOPE_THREAD, "data", | 338 "devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOPE_THREAD, "data", |
| 338 InspectorResourceFinishEvent::data(m_identifier, 0, true)); | 339 InspectorResourceFinishEvent::data(m_identifier, 0, true)); |
| 339 const ResourceResponse& resourceResponse = response.toResourceResponse(); | 340 const ResourceResponse& resourceResponse = response.toResourceResponse(); |
| 340 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier, 0, | 341 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier, 0, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 bool PingLoader::sendBeacon(LocalFrame* frame, | 551 bool PingLoader::sendBeacon(LocalFrame* frame, |
| 551 int allowance, | 552 int allowance, |
| 552 const KURL& beaconURL, | 553 const KURL& beaconURL, |
| 553 Blob* data, | 554 Blob* data, |
| 554 int& payloadLength) { | 555 int& payloadLength) { |
| 555 BeaconBlob beacon(data); | 556 BeaconBlob beacon(data); |
| 556 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); | 557 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); |
| 557 } | 558 } |
| 558 | 559 |
| 559 } // namespace blink | 560 } // namespace blink |
| OLD | NEW |