| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 public: | 206 public: |
| 207 PingLoaderImpl(LocalFrame*, ResourceRequest&, const AtomicString&, StoredCre
dentials, bool); | 207 PingLoaderImpl(LocalFrame*, ResourceRequest&, const AtomicString&, StoredCre
dentials, bool); |
| 208 ~PingLoaderImpl() override; | 208 ~PingLoaderImpl() override; |
| 209 | 209 |
| 210 DECLARE_VIRTUAL_TRACE(); | 210 DECLARE_VIRTUAL_TRACE(); |
| 211 | 211 |
| 212 private: | 212 private: |
| 213 void dispose(); | 213 void dispose(); |
| 214 | 214 |
| 215 // WebURLLoaderClient | 215 // WebURLLoaderClient |
| 216 void willFollowRedirect(WebURLLoader*, WebURLRequest&, const WebURLResponse&
, int64_t encodedDataLength) override; | 216 bool willFollowRedirect(WebURLLoader*, WebURLRequest&, const WebURLResponse&
, int64_t encodedDataLength) override; |
| 217 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) final; | 217 void didReceiveResponse(WebURLLoader*, const WebURLResponse&) final; |
| 218 void didReceiveData(WebURLLoader*, const char*, int, int, int) final; | 218 void didReceiveData(WebURLLoader*, const char*, int, int, int) final; |
| 219 void didFinishLoading(WebURLLoader*, double, int64_t) final; | 219 void didFinishLoading(WebURLLoader*, double, int64_t) final; |
| 220 void didFail(WebURLLoader*, const WebURLError&) final; | 220 void didFail(WebURLLoader*, const WebURLError&) final; |
| 221 | 221 |
| 222 void timeout(TimerBase*); | 222 void timeout(TimerBase*); |
| 223 | 223 |
| 224 void didFailLoading(LocalFrame*); | 224 void didFailLoading(LocalFrame*); |
| 225 | 225 |
| 226 std::unique_ptr<WebURLLoader> m_loader; | 226 std::unique_ptr<WebURLLoader> m_loader; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 void PingLoaderImpl::dispose() | 283 void PingLoaderImpl::dispose() |
| 284 { | 284 { |
| 285 if (m_loader) { | 285 if (m_loader) { |
| 286 m_loader->cancel(); | 286 m_loader->cancel(); |
| 287 m_loader = nullptr; | 287 m_loader = nullptr; |
| 288 } | 288 } |
| 289 m_timeout.stop(); | 289 m_timeout.stop(); |
| 290 m_keepAlive.clear(); | 290 m_keepAlive.clear(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void PingLoaderImpl::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR
equest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength) | 293 bool PingLoaderImpl::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR
equest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength) |
| 294 { | 294 { |
| 295 if (!m_isBeacon) | 295 if (!m_isBeacon) |
| 296 return; | 296 return true; |
| 297 | 297 |
| 298 // TODO(tyoshino): Check if setAllowStoredCredentials() should be called | 298 // TODO(tyoshino): Check if setAllowStoredCredentials() should be called |
| 299 // also for non beacon cases. | 299 // also 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(passedRedirectResponse.toResourceRe
sponse()); | 305 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe
sponse()); |
| 306 | 306 |
| 307 DCHECK(!newRequest.isNull()); | 307 DCHECK(!newRequest.isNull()); |
| 308 DCHECK(!redirectResponse.isNull()); | 308 DCHECK(!redirectResponse.isNull()); |
| 309 | 309 |
| 310 String errorDescription; | 310 String errorDescription; |
| 311 ResourceLoaderOptions options; | 311 ResourceLoaderOptions options; |
| 312 // TODO(tyoshino): Save updated data in options.securityOrigin and pass it | 312 // TODO(tyoshino): Save updated data in options.securityOrigin and pass it |
| 313 // on the next time. | 313 // on the next time. |
| 314 if (!CrossOriginAccessControl::handleRedirect(m_origin, newRequest, redirect
Response, AllowStoredCredentials, options, errorDescription)) { | 314 if (!CrossOriginAccessControl::handleRedirect(m_origin, newRequest, redirect
Response, AllowStoredCredentials, options, errorDescription)) { |
| 315 if (LocalFrame* localFrame = frame()) { | 315 if (LocalFrame* localFrame = frame()) { |
| 316 if (localFrame->document()) | 316 if (localFrame->document()) |
| 317 localFrame->document()->addConsoleMessage(ConsoleMessage::create
(JSMessageSource, ErrorMessageLevel, errorDescription)); | 317 localFrame->document()->addConsoleMessage(ConsoleMessage::create
(JSMessageSource, ErrorMessageLevel, errorDescription)); |
| 318 } | 318 } |
| 319 // Cancel the load and self destruct. | 319 // Cancel the load and self destruct. |
| 320 dispose(); | 320 dispose(); |
| 321 // Signal WebURLLoader that the redirect musn't be followed. | 321 |
| 322 passedNewRequest = WebURLRequest(); | 322 return false; |
| 323 return; | |
| 324 } | 323 } |
| 325 // FIXME: http://crbug.com/427429 is needed to correctly propagate | 324 // FIXME: http://crbug.com/427429 is needed to correctly propagate |
| 326 // updates of Origin: following this successful redirect. | 325 // updates of Origin: following this successful redirect. |
| 326 |
| 327 return true; |
| 327 } | 328 } |
| 328 | 329 |
| 329 | 330 |
| 330 void PingLoaderImpl::didReceiveResponse(WebURLLoader*, const WebURLResponse& res
ponse) | 331 void PingLoaderImpl::didReceiveResponse(WebURLLoader*, const WebURLResponse& res
ponse) |
| 331 { | 332 { |
| 332 if (LocalFrame* frame = this->frame()) { | 333 if (LocalFrame* frame = this->frame()) { |
| 333 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; | 334 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_
SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true))
; |
| 334 const ResourceResponse& resourceResponse = response.toResourceResponse()
; | 335 const ResourceResponse& resourceResponse = response.toResourceResponse()
; |
| 335 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier
, 0, resourceResponse, 0); | 336 InspectorInstrumentation::didReceiveResourceResponse(frame, m_identifier
, 0, resourceResponse, 0); |
| 336 didFailLoading(frame); | 337 didFailLoading(frame); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); | 496 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); |
| 496 } | 497 } |
| 497 | 498 |
| 498 bool PingLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beacon
URL, Blob* data, int& payloadLength) | 499 bool PingLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beacon
URL, Blob* data, int& payloadLength) |
| 499 { | 500 { |
| 500 BeaconBlob beacon(data); | 501 BeaconBlob beacon(data); |
| 501 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); | 502 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); |
| 502 } | 503 } |
| 503 | 504 |
| 504 } // namespace blink | 505 } // namespace blink |
| OLD | NEW |