OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) | 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) |
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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 : m_fetcher(fetcher), | 60 : m_fetcher(fetcher), |
61 m_resource(resource), | 61 m_resource(resource), |
62 m_isCacheAwareLoadingActivated(false) { | 62 m_isCacheAwareLoadingActivated(false) { |
63 DCHECK(m_resource); | 63 DCHECK(m_resource); |
64 DCHECK(m_fetcher); | 64 DCHECK(m_fetcher); |
65 | 65 |
66 m_resource->setLoader(this); | 66 m_resource->setLoader(this); |
67 } | 67 } |
68 | 68 |
69 ResourceLoader::~ResourceLoader() { | 69 ResourceLoader::~ResourceLoader() { |
70 DCHECK(!m_loader); | 70 CHECK(!m_loader); |
71 } | 71 } |
72 | 72 |
73 DEFINE_TRACE(ResourceLoader) { | 73 DEFINE_TRACE(ResourceLoader) { |
74 visitor->trace(m_fetcher); | 74 visitor->trace(m_fetcher); |
75 visitor->trace(m_resource); | 75 visitor->trace(m_resource); |
76 } | 76 } |
77 | 77 |
78 void ResourceLoader::start(const ResourceRequest& request) { | 78 void ResourceLoader::start(const ResourceRequest& request) { |
79 DCHECK(!m_loader); | 79 DCHECK(!m_loader); |
80 | 80 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 return ResourceRequestBlockedReason::Other; | 296 return ResourceRequestBlockedReason::Other; |
297 } | 297 } |
298 return ResourceRequestBlockedReason::None; | 298 return ResourceRequestBlockedReason::None; |
299 } | 299 } |
300 | 300 |
301 void ResourceLoader::didReceiveResponse( | 301 void ResourceLoader::didReceiveResponse( |
302 const WebURLResponse& webURLResponse, | 302 const WebURLResponse& webURLResponse, |
303 std::unique_ptr<WebDataConsumerHandle> handle) { | 303 std::unique_ptr<WebDataConsumerHandle> handle) { |
304 DCHECK(!webURLResponse.isNull()); | 304 DCHECK(!webURLResponse.isNull()); |
| 305 CHECK(m_resource); |
305 | 306 |
306 const ResourceResponse& response = webURLResponse.toResourceResponse(); | 307 const ResourceResponse& response = webURLResponse.toResourceResponse(); |
307 | 308 |
308 if (response.wasFetchedViaServiceWorker()) { | 309 if (response.wasFetchedViaServiceWorker()) { |
309 if (m_resource->options().corsEnabled == IsCORSEnabled && | 310 if (m_resource->options().corsEnabled == IsCORSEnabled && |
310 response.wasFallbackRequiredByServiceWorker()) { | 311 response.wasFallbackRequiredByServiceWorker()) { |
311 ResourceRequest request = m_resource->lastResourceRequest(); | 312 ResourceRequest request = m_resource->lastResourceRequest(); |
312 DCHECK_EQ(request.skipServiceWorker(), | 313 DCHECK_EQ(request.skipServiceWorker(), |
313 WebURLRequest::SkipServiceWorker::None); | 314 WebURLRequest::SkipServiceWorker::None); |
314 // This code handles the case when a regular controlling service worker | 315 // This code handles the case when a regular controlling service worker |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } else if (m_resource->options().corsEnabled == IsCORSEnabled) { | 348 } else if (m_resource->options().corsEnabled == IsCORSEnabled) { |
348 ResourceRequestBlockedReason blockedReason = | 349 ResourceRequestBlockedReason blockedReason = |
349 canAccessResponse(m_resource, response); | 350 canAccessResponse(m_resource, response); |
350 if (blockedReason != ResourceRequestBlockedReason::None) { | 351 if (blockedReason != ResourceRequestBlockedReason::None) { |
351 handleError(ResourceError::cancelledDueToAccessCheckError(response.url(), | 352 handleError(ResourceError::cancelledDueToAccessCheckError(response.url(), |
352 blockedReason)); | 353 blockedReason)); |
353 return; | 354 return; |
354 } | 355 } |
355 } | 356 } |
356 | 357 |
| 358 CHECK(m_resource); |
357 context().dispatchDidReceiveResponse( | 359 context().dispatchDidReceiveResponse( |
358 m_resource->identifier(), response, | 360 m_resource->identifier(), response, |
359 m_resource->resourceRequest().frameType(), | 361 m_resource->resourceRequest().frameType(), |
360 m_resource->resourceRequest().requestContext(), m_resource); | 362 m_resource->resourceRequest().requestContext(), m_resource); |
361 | 363 |
| 364 CHECK(m_resource); |
362 m_resource->responseReceived(response, std::move(handle)); | 365 m_resource->responseReceived(response, std::move(handle)); |
363 if (!m_resource->loader()) | 366 if (!m_resource->loader()) |
364 return; | 367 return; |
365 | 368 |
366 if (response.httpStatusCode() >= 400 && | 369 if (response.httpStatusCode() >= 400 && |
367 !m_resource->shouldIgnoreHTTPStatusCodeErrors()) | 370 !m_resource->shouldIgnoreHTTPStatusCodeErrors()) |
368 handleError(ResourceError::cancelledError(response.url())); | 371 handleError(ResourceError::cancelledError(response.url())); |
369 } | 372 } |
370 | 373 |
371 void ResourceLoader::didReceiveResponse(const WebURLResponse& response) { | 374 void ResourceLoader::didReceiveResponse(const WebURLResponse& response) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 return; | 503 return; |
501 | 504 |
502 // Don't activate if cache policy is explicitly set. | 505 // Don't activate if cache policy is explicitly set. |
503 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) | 506 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) |
504 return; | 507 return; |
505 | 508 |
506 m_isCacheAwareLoadingActivated = true; | 509 m_isCacheAwareLoadingActivated = true; |
507 } | 510 } |
508 | 511 |
509 } // namespace blink | 512 } // namespace blink |
OLD | NEW |