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 CHECK(!m_loader); | 70 DCHECK(!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); | |
306 | 305 |
307 const ResourceResponse& response = webURLResponse.toResourceResponse(); | 306 const ResourceResponse& response = webURLResponse.toResourceResponse(); |
308 | 307 |
309 if (response.wasFetchedViaServiceWorker()) { | 308 if (response.wasFetchedViaServiceWorker()) { |
310 if (m_resource->options().corsEnabled == IsCORSEnabled && | 309 if (m_resource->options().corsEnabled == IsCORSEnabled && |
311 response.wasFallbackRequiredByServiceWorker()) { | 310 response.wasFallbackRequiredByServiceWorker()) { |
312 ResourceRequest request = m_resource->lastResourceRequest(); | 311 ResourceRequest request = m_resource->lastResourceRequest(); |
313 DCHECK_EQ(request.skipServiceWorker(), | 312 DCHECK_EQ(request.skipServiceWorker(), |
314 WebURLRequest::SkipServiceWorker::None); | 313 WebURLRequest::SkipServiceWorker::None); |
315 // This code handles the case when a regular controlling service worker | 314 // This code handles the case when a regular controlling service worker |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } else if (m_resource->options().corsEnabled == IsCORSEnabled) { | 347 } else if (m_resource->options().corsEnabled == IsCORSEnabled) { |
349 ResourceRequestBlockedReason blockedReason = | 348 ResourceRequestBlockedReason blockedReason = |
350 canAccessResponse(m_resource, response); | 349 canAccessResponse(m_resource, response); |
351 if (blockedReason != ResourceRequestBlockedReason::None) { | 350 if (blockedReason != ResourceRequestBlockedReason::None) { |
352 handleError(ResourceError::cancelledDueToAccessCheckError(response.url(), | 351 handleError(ResourceError::cancelledDueToAccessCheckError(response.url(), |
353 blockedReason)); | 352 blockedReason)); |
354 return; | 353 return; |
355 } | 354 } |
356 } | 355 } |
357 | 356 |
358 CHECK(m_resource); | |
359 context().dispatchDidReceiveResponse( | 357 context().dispatchDidReceiveResponse( |
360 m_resource->identifier(), response, | 358 m_resource->identifier(), response, |
361 m_resource->resourceRequest().frameType(), | 359 m_resource->resourceRequest().frameType(), |
362 m_resource->resourceRequest().requestContext(), m_resource); | 360 m_resource->resourceRequest().requestContext(), m_resource); |
363 | 361 |
364 CHECK(m_resource); | |
365 m_resource->responseReceived(response, std::move(handle)); | 362 m_resource->responseReceived(response, std::move(handle)); |
366 if (!m_resource->loader()) | 363 if (!m_resource->loader()) |
367 return; | 364 return; |
368 | 365 |
369 if (response.httpStatusCode() >= 400 && | 366 if (response.httpStatusCode() >= 400 && |
370 !m_resource->shouldIgnoreHTTPStatusCodeErrors()) | 367 !m_resource->shouldIgnoreHTTPStatusCodeErrors()) |
371 handleError(ResourceError::cancelledError(response.url())); | 368 handleError(ResourceError::cancelledError(response.url())); |
372 } | 369 } |
373 | 370 |
374 void ResourceLoader::didReceiveResponse(const WebURLResponse& response) { | 371 void ResourceLoader::didReceiveResponse(const WebURLResponse& response) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 return; | 500 return; |
504 | 501 |
505 // Don't activate if cache policy is explicitly set. | 502 // Don't activate if cache policy is explicitly set. |
506 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) | 503 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) |
507 return; | 504 return; |
508 | 505 |
509 m_isCacheAwareLoadingActivated = true; | 506 m_isCacheAwareLoadingActivated = true; |
510 } | 507 } |
511 | 508 |
512 } // namespace blink | 509 } // namespace blink |
OLD | NEW |