| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 m_host->didLoadResource(); | 106 m_host->didLoadResource(); |
| 107 if (m_state == Terminated) | 107 if (m_state == Terminated) |
| 108 return; | 108 return; |
| 109 m_resource->clearLoader(); | 109 m_resource->clearLoader(); |
| 110 m_resource->deleteIfPossible(); | 110 m_resource->deleteIfPossible(); |
| 111 m_resource = nullptr; | 111 m_resource = nullptr; |
| 112 m_host->willTerminateResourceLoader(this); | 112 m_host->willTerminateResourceLoader(this); |
| 113 | 113 |
| 114 ASSERT(m_state != Terminated); | 114 ASSERT(m_state != Terminated); |
| 115 | 115 |
| 116 // It's possible that when we release the loader, it will be | |
| 117 // deallocated and release the last reference to this object. | |
| 118 // We need to retain to avoid accessing the object after it | |
| 119 // has been deallocated and also to avoid reentering this method. | |
| 120 RefPtrWillBeRawPtr<ResourceLoader> protector(this); | |
| 121 | |
| 122 m_host.clear(); | |
| 123 m_state = Terminated; | 116 m_state = Terminated; |
| 124 | |
| 125 if (m_loader) { | 117 if (m_loader) { |
| 126 m_loader->cancel(); | 118 m_loader->cancel(); |
| 127 m_loader.clear(); | 119 m_loader.clear(); |
| 128 } | 120 } |
| 129 | |
| 130 m_deferredRequest = ResourceRequest(); | 121 m_deferredRequest = ResourceRequest(); |
| 122 m_host.clear(); |
| 131 } | 123 } |
| 132 | 124 |
| 133 void ResourceLoader::init(const ResourceRequest& passedRequest) | 125 void ResourceLoader::init(const ResourceRequest& passedRequest) |
| 134 { | 126 { |
| 135 ASSERT(m_state != Terminated); | 127 ASSERT(m_state != Terminated); |
| 136 ResourceRequest request(passedRequest); | 128 ResourceRequest request(passedRequest); |
| 137 m_host->willSendRequest(m_resource->identifier(), request, ResourceResponse(
), m_options.initiatorInfo); | 129 m_host->willSendRequest(m_resource->identifier(), request, ResourceResponse(
), m_options.initiatorInfo); |
| 138 ASSERT(m_state != Terminated); | 130 ASSERT(m_state != Terminated); |
| 139 ASSERT(!request.isNull()); | 131 ASSERT(!request.isNull()); |
| 140 m_originalRequest = m_request = applyOptions(request); | 132 m_originalRequest = m_request = applyOptions(request); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void ResourceLoader::didReceiveCachedMetadata(blink::WebURLLoader*, const char*
data, int length) | 321 void ResourceLoader::didReceiveCachedMetadata(blink::WebURLLoader*, const char*
data, int length) |
| 330 { | 322 { |
| 331 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con
nectionState == ConnectionStateReceivingData); | 323 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con
nectionState == ConnectionStateReceivingData); |
| 332 ASSERT(m_state == Initialized); | 324 ASSERT(m_state == Initialized); |
| 333 m_resource->setSerializedCachedMetadata(data, length); | 325 m_resource->setSerializedCachedMetadata(data, length); |
| 334 } | 326 } |
| 335 | 327 |
| 336 void ResourceLoader::didSendData(blink::WebURLLoader*, unsigned long long bytesS
ent, unsigned long long totalBytesToBeSent) | 328 void ResourceLoader::didSendData(blink::WebURLLoader*, unsigned long long bytesS
ent, unsigned long long totalBytesToBeSent) |
| 337 { | 329 { |
| 338 ASSERT(m_state == Initialized); | 330 ASSERT(m_state == Initialized); |
| 339 RefPtrWillBeRawPtr<ResourceLoader> protect(this); | |
| 340 m_resource->didSendData(bytesSent, totalBytesToBeSent); | 331 m_resource->didSendData(bytesSent, totalBytesToBeSent); |
| 341 } | 332 } |
| 342 | 333 |
| 343 bool ResourceLoader::responseNeedsAccessControlCheck() const | 334 bool ResourceLoader::responseNeedsAccessControlCheck() const |
| 344 { | 335 { |
| 345 // If the fetch was (potentially) CORS enabled, an access control check of t
he response is required. | 336 // If the fetch was (potentially) CORS enabled, an access control check of t
he response is required. |
| 346 return m_options.corsEnabled == IsCORSEnabled; | 337 return m_options.corsEnabled == IsCORSEnabled; |
| 347 } | 338 } |
| 348 | 339 |
| 349 void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR
LResponse& response, WebDataConsumerHandle* rawHandle) | 340 void ResourceLoader::didReceiveResponse(blink::WebURLLoader*, const blink::WebUR
LResponse& response, WebDataConsumerHandle* rawHandle) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 m_requestCountTracker.clear(); | 554 m_requestCountTracker.clear(); |
| 564 } | 555 } |
| 565 | 556 |
| 566 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const | 557 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const |
| 567 { | 558 { |
| 568 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC
redentials); | 559 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC
redentials); |
| 569 return request; | 560 return request; |
| 570 } | 561 } |
| 571 | 562 |
| 572 } | 563 } |
| OLD | NEW |