Changeset 24624 in webkit
- Timestamp:
- Jul 25, 2007, 9:54:22 AM (18 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r24623 r24624 1 2007-07-25 Marvin Decker <marv.decker@gmail.com> 2 3 Reviewed by Maciej, Darin. 4 5 - http://bugs.webkit.org/show_bug.cgi?id=14030 6 7 Add ResourceHandle::setClient to resolve some messiness with handle 8 releasing. Clear the client when ResourceLoader is going to release 9 the handle to prevent crashes in the case where somebody still holds a 10 reference (this doesn't seem to currently happen in practice). Add 11 NULL-checking for ResourceHandle implementations using the client. 12 13 * loader/ResourceLoader.cpp: 14 (WebCore::ResourceLoader::releaseResources): 15 * platform/network/ResourceHandle.cpp: 16 (WebCore::ResourceHandle::fireBlockedFailure): 17 (WebCore::ResourceHandle::setClient): 18 * platform/network/ResourceHandle.h: 19 * platform/network/cf/ResourceHandleCFNet.cpp: 20 (WebCore::willSendRequest): 21 (WebCore::didReceiveResponse): 22 (WebCore::didReceiveData): 23 (WebCore::didFinishLoading): 24 (WebCore::didFail): 25 (WebCore::willCacheResponse): 26 (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): 27 (WebCore::ResourceHandle::receivedCancellation): 28 * platform/network/mac/ResourceHandleMac.mm: 29 (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): 30 (WebCore::ResourceHandle::didCancelAuthenticationChallenge): 31 (WebCore::ResourceHandle::receivedCancellation): 32 (-[WebCoreResourceHandleAsDelegate connection:willSendRequest:redirectResponse:]): 33 (-[WebCoreResourceHandleAsDelegate connection:didReceiveResponse:]): 34 (-[WebCoreResourceHandleAsDelegate connection:didReceiveData:lengthReceived:]): 35 (-[WebCoreResourceHandleAsDelegate connection:willStopBufferingData:]): 36 (-[WebCoreResourceHandleAsDelegate connectionDidFinishLoading:]): 37 (-[WebCoreResourceHandleAsDelegate connection:didFailWithError:]): 38 (-[WebCoreResourceHandleAsDelegate connection:willCacheResponse:]): 39 1 40 2007-07-25 Maxime Britto <mbritto@pleyo.com> 2 41 -
trunk/WebCore/loader/ResourceLoader.cpp
r24459 r24624 90 90 m_identifier = 0; 91 91 92 m_handle = 0; 92 if (m_handle) { 93 // Clear out the ResourceHandle's client so that it doesn't try to call 94 // us back after we release it. 95 m_handle->setClient(0); 96 m_handle = 0; 97 } 98 93 99 m_resourceData = 0; 94 100 m_deferredRequest = ResourceRequest(); -
trunk/WebCore/platform/network/ResourceHandle.cpp
r24484 r24624 65 65 void ResourceHandle::fireBlockedFailure(Timer<ResourceHandle>* timer) 66 66 { 67 client()->wasBlocked(this); 67 if (client()) 68 client()->wasBlocked(this); 68 69 delete timer; 69 70 } … … 72 73 { 73 74 return d->m_client; 75 } 76 77 void ResourceHandle::setClient(ResourceHandleClient* client) 78 { 79 d->m_client = client; 74 80 } 75 81 -
trunk/WebCore/platform/network/ResourceHandle.h
r24202 r24624 149 149 void clearAuthentication(); 150 150 void cancel(); 151 151 152 // The client may be 0, in which case no callbacks will be made. 152 153 ResourceHandleClient* client() const; 154 void setClient(ResourceHandleClient*); 155 153 156 void setDefersLoading(bool); 154 157 -
trunk/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
r24209 r24624 67 67 68 68 ResourceRequest request(cfRequest); 69 handle->client()->willSendRequest(handle, request, cfRedirectResponse); 69 if (handle->client()) 70 handle->client()->willSendRequest(handle, request, cfRedirectResponse); 70 71 71 72 cfRequest = request.cfURLRequest(); … … 81 82 LOG(Network, "CFNet - didReceiveResponse(conn=%p, handle=%p) (%s)", conn, handle, handle->request().url().url().ascii()); 82 83 83 handle->client()->didReceiveResponse(handle, cfResponse); 84 if (handle->client()) 85 handle->client()->didReceiveResponse(handle, cfResponse); 84 86 } 85 87 … … 92 94 LOG(Network, "CFNet - didReceiveData(conn=%p, handle=%p, bytes=%d) (%s)", conn, handle, length, handle->request().url().url().ascii()); 93 95 94 handle->client()->didReceiveData(handle, (const char*)bytes, length, originalLength); 96 if (handle->client()) 97 handle->client()->didReceiveData(handle, (const char*)bytes, length, originalLength); 95 98 } 96 99 … … 101 104 LOG(Network, "CFNet - didFinishLoading(conn=%p, handle=%p) (%s)", conn, handle, handle->request().url().url().ascii()); 102 105 103 handle->client()->didFinishLoading(handle); 106 if (handle->client()) 107 handle->client()->didFinishLoading(handle); 104 108 } 105 109 … … 110 114 LOG(Network, "CFNet - didFail(conn=%p, handle=%p, error = %p) (%s)", conn, handle, error, handle->request().url().url().ascii()); 111 115 112 handle->client()->didFail(handle, ResourceError(error)); 116 if (handle->client()) 117 handle->client()->didFail(handle, ResourceError(error)); 113 118 } 114 119 … … 119 124 CacheStoragePolicy policy = static_cast<CacheStoragePolicy>(CFCachedURLResponseGetStoragePolicy(cachedResponse)); 120 125 121 handle->client()->willCacheResponse(handle, policy); 126 if (handle->client()) 127 handle->client()->willCacheResponse(handle, policy); 122 128 123 129 if (static_cast<CFURLCacheStoragePolicy>(policy) != CFCachedURLResponseGetStoragePolicy(cachedResponse)) … … 292 298 d->m_currentWebChallenge = AuthenticationChallenge(d->m_currentCFChallenge, this); 293 299 294 client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); 300 if (client()) 301 client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); 295 302 } 296 303 … … 329 336 return; 330 337 331 client()->receivedCancellation(this, challenge); 338 if (client()) 339 client()->receivedCancellation(this, challenge); 332 340 } 333 341 -
trunk/WebCore/platform/network/mac/ResourceHandleMac.mm
r24205 r24624 265 265 d->m_currentWebChallenge = core(webChallenge); 266 266 [webChallenge release]; 267 268 client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); 267 268 if (client()) 269 client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge); 269 270 } 270 271 … … 275 276 ASSERT(d->m_currentWebChallenge == challenge); 276 277 277 client()->didCancelAuthenticationChallenge(this, d->m_currentWebChallenge); 278 if (client()) 279 client()->didCancelAuthenticationChallenge(this, d->m_currentWebChallenge); 278 280 } 279 281 … … 305 307 return; 306 308 307 client()->receivedCancellation(this, challenge); 309 if (client()) 310 client()->receivedCancellation(this, challenge); 308 311 } 309 312 … … 336 339 - (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse 337 340 { 338 if (!m_handle )341 if (!m_handle || !m_handle->client()) 339 342 return nil; 340 343 ++inNSURLConnectionCallback; … … 385 388 - (void)connection:(NSURLConnection *)con didReceiveResponse:(NSURLResponse *)r 386 389 { 387 if (!m_handle )390 if (!m_handle || !m_handle->client()) 388 391 return; 389 392 ++inNSURLConnectionCallback; … … 394 397 - (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived 395 398 { 396 if (!m_handle )399 if (!m_handle || !m_handle->client()) 397 400 return; 398 401 // FIXME: If we get more than 2B bytes in a single chunk, this code won't do the right thing. … … 406 409 - (void)connection:(NSURLConnection *)con willStopBufferingData:(NSData *)data 407 410 { 408 if (!m_handle )411 if (!m_handle || !m_handle->client()) 409 412 return; 410 413 // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing. … … 418 421 - (void)connectionDidFinishLoading:(NSURLConnection *)con 419 422 { 420 if (!m_handle )423 if (!m_handle || !m_handle->client()) 421 424 return; 422 425 ++inNSURLConnectionCallback; … … 427 430 - (void)connection:(NSURLConnection *)con didFailWithError:(NSError *)error 428 431 { 429 if (!m_handle )432 if (!m_handle || !m_handle->client()) 430 433 return; 431 434 ++inNSURLConnectionCallback; … … 440 443 LOG_ERROR("connection:willCacheResponse: was called inside of [NSURLConnection initWithRequest:delegate:] (4067625)"); 441 444 #endif 442 if (!m_handle )445 if (!m_handle || !m_handle->client()) 443 446 return nil; 444 447 ++inNSURLConnectionCallback;
Note:
See TracChangeset
for help on using the changeset viewer.