| 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 ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, Resource* resource) | 60 ResourceLoader::ResourceLoader(ResourceFetcher* fetcher, Resource* resource) |
| 61 : m_fetcher(fetcher), | 61 : m_fetcher(fetcher), |
| 62 m_resource(resource), | 62 m_resource(resource), |
| 63 m_isCacheAwareLoadingActivated(false) { | 63 m_isCacheAwareLoadingActivated(false) { |
| 64 DCHECK(m_resource); | 64 DCHECK(m_resource); |
| 65 DCHECK(m_fetcher); | 65 DCHECK(m_fetcher); |
| 66 | 66 |
| 67 m_resource->setLoader(this); | 67 m_resource->setLoader(this); |
| 68 } | 68 } |
| 69 | 69 |
| 70 ResourceLoader::~ResourceLoader() { | 70 ResourceLoader::~ResourceLoader() {} |
| 71 DCHECK(!m_loader); | |
| 72 } | |
| 73 | 71 |
| 74 DEFINE_TRACE(ResourceLoader) { | 72 DEFINE_TRACE(ResourceLoader) { |
| 75 visitor->trace(m_fetcher); | 73 visitor->trace(m_fetcher); |
| 76 visitor->trace(m_resource); | 74 visitor->trace(m_resource); |
| 77 } | 75 } |
| 78 | 76 |
| 79 void ResourceLoader::start(const ResourceRequest& request) { | 77 void ResourceLoader::start(const ResourceRequest& request) { |
| 80 DCHECK(!m_loader); | 78 DCHECK(!m_loader); |
| 81 | 79 |
| 82 if (m_resource->options().synchronousPolicy == RequestSynchronously && | 80 if (m_resource->options().synchronousPolicy == RequestSynchronously && |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 // a 304, where it will overwrite the cached data we should be reusing. | 484 // a 304, where it will overwrite the cached data we should be reusing. |
| 487 if (dataOut.size()) { | 485 if (dataOut.size()) { |
| 488 context().dispatchDidReceiveData(m_resource->identifier(), dataOut.data(), | 486 context().dispatchDidReceiveData(m_resource->identifier(), dataOut.data(), |
| 489 dataOut.size()); | 487 dataOut.size()); |
| 490 m_resource->setResourceBuffer(dataOut); | 488 m_resource->setResourceBuffer(dataOut); |
| 491 } | 489 } |
| 492 didFinishLoading(monotonicallyIncreasingTime(), encodedDataLength, | 490 didFinishLoading(monotonicallyIncreasingTime(), encodedDataLength, |
| 493 encodedBodyLength); | 491 encodedBodyLength); |
| 494 } | 492 } |
| 495 | 493 |
| 494 void ResourceLoader::dispose() { |
| 495 m_loader = nullptr; |
| 496 } |
| 497 |
| 496 void ResourceLoader::activateCacheAwareLoadingIfNeeded( | 498 void ResourceLoader::activateCacheAwareLoadingIfNeeded( |
| 497 const ResourceRequest& request) { | 499 const ResourceRequest& request) { |
| 498 DCHECK(!m_isCacheAwareLoadingActivated); | 500 DCHECK(!m_isCacheAwareLoadingActivated); |
| 499 | 501 |
| 500 if (m_resource->options().cacheAwareLoadingEnabled != | 502 if (m_resource->options().cacheAwareLoadingEnabled != |
| 501 IsCacheAwareLoadingEnabled) | 503 IsCacheAwareLoadingEnabled) |
| 502 return; | 504 return; |
| 503 | 505 |
| 504 // Synchronous requests are not supported. | 506 // Synchronous requests are not supported. |
| 505 if (m_resource->options().synchronousPolicy == RequestSynchronously) | 507 if (m_resource->options().synchronousPolicy == RequestSynchronously) |
| 506 return; | 508 return; |
| 507 | 509 |
| 508 // Don't activate on Resource revalidation. | 510 // Don't activate on Resource revalidation. |
| 509 if (m_resource->isCacheValidator()) | 511 if (m_resource->isCacheValidator()) |
| 510 return; | 512 return; |
| 511 | 513 |
| 512 // Don't activate if cache policy is explicitly set. | 514 // Don't activate if cache policy is explicitly set. |
| 513 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) | 515 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) |
| 514 return; | 516 return; |
| 515 | 517 |
| 516 m_isCacheAwareLoadingActivated = true; | 518 m_isCacheAwareLoadingActivated = true; |
| 517 } | 519 } |
| 518 | 520 |
| 519 } // namespace blink | 521 } // namespace blink |
| OLD | NEW |