| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 m_resource->appendData(data, length); | 321 m_resource->appendData(data, length); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t
encodedDataLength) | 324 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t
encodedDataLength) |
| 325 { | 325 { |
| 326 | 326 |
| 327 RELEASE_ASSERT(m_state == ConnectionStateReceivedResponse || m_state == Conn
ectionStateReceivingData); | 327 RELEASE_ASSERT(m_state == ConnectionStateReceivedResponse || m_state == Conn
ectionStateReceivingData); |
| 328 m_state = ConnectionStateFinishedLoading; | 328 m_state = ConnectionStateFinishedLoading; |
| 329 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().getString().lat
in1().data()); | 329 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().getString().lat
in1().data()); |
| 330 | 330 |
| 331 RefPtrWillBeRawPtr<Resource> protectResource(m_resource.get()); | 331 RawPtr<Resource> protectResource(m_resource.get()); |
| 332 m_resource->setLoadFinishTime(finishTime); | 332 m_resource->setLoadFinishTime(finishTime); |
| 333 didFinishLoadingOnePart(finishTime, encodedDataLength); | 333 didFinishLoadingOnePart(finishTime, encodedDataLength); |
| 334 if (m_state == ConnectionStateReleased) | 334 if (m_state == ConnectionStateReleased) |
| 335 return; | 335 return; |
| 336 m_resource->finish(); | 336 m_resource->finish(); |
| 337 | 337 |
| 338 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release | 338 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release |
| 339 // the resources a second time, they have been released by cancel. | 339 // the resources a second time, they have been released by cancel. |
| 340 if (m_state == ConnectionStateReleased) | 340 if (m_state == ConnectionStateReleased) |
| 341 return; | 341 return; |
| 342 releaseResources(); | 342 releaseResources(); |
| 343 } | 343 } |
| 344 | 344 |
| 345 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) | 345 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) |
| 346 { | 346 { |
| 347 | 347 |
| 348 ASSERT(m_state != ConnectionStateReleased); | 348 ASSERT(m_state != ConnectionStateReleased); |
| 349 m_state = ConnectionStateFailed; | 349 m_state = ConnectionStateFailed; |
| 350 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().getStri
ng().latin1().data()); | 350 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().getStri
ng().latin1().data()); |
| 351 | 351 |
| 352 RefPtrWillBeRawPtr<Resource> protectResource(m_resource.get()); | 352 RawPtr<Resource> protectResource(m_resource.get()); |
| 353 m_resource->setResourceError(error); | 353 m_resource->setResourceError(error); |
| 354 | 354 |
| 355 if (!m_notifiedLoadComplete) { | 355 if (!m_notifiedLoadComplete) { |
| 356 m_notifiedLoadComplete = true; | 356 m_notifiedLoadComplete = true; |
| 357 m_fetcher->didFailLoading(m_resource.get(), error); | 357 m_fetcher->didFailLoading(m_resource.get(), error); |
| 358 } | 358 } |
| 359 if (m_state == ConnectionStateReleased) | 359 if (m_state == ConnectionStateReleased) |
| 360 return; | 360 return; |
| 361 | 361 |
| 362 m_resource->error(Resource::LoadError); | 362 m_resource->error(Resource::LoadError); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 374 ASSERT(m_loader); | 374 ASSERT(m_loader); |
| 375 | 375 |
| 376 // Synchronous requests should always be max priority, lest they hang the re
nderer. | 376 // Synchronous requests should always be max priority, lest they hang the re
nderer. |
| 377 request.setPriority(ResourceLoadPriorityHighest); | 377 request.setPriority(ResourceLoadPriorityHighest); |
| 378 | 378 |
| 379 if (m_fetcher->defersLoading()) { | 379 if (m_fetcher->defersLoading()) { |
| 380 cancel(); | 380 cancel(); |
| 381 return; | 381 return; |
| 382 } | 382 } |
| 383 | 383 |
| 384 RefPtrWillBeRawPtr<Resource> protectResource(m_resource.get()); | 384 RawPtr<Resource> protectResource(m_resource.get()); |
| 385 WrappedResourceRequest requestIn(request); | 385 WrappedResourceRequest requestIn(request); |
| 386 WebURLResponse responseOut; | 386 WebURLResponse responseOut; |
| 387 responseOut.initialize(); | 387 responseOut.initialize(); |
| 388 WebURLError errorOut; | 388 WebURLError errorOut; |
| 389 WebData dataOut; | 389 WebData dataOut; |
| 390 m_loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); | 390 m_loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); |
| 391 if (errorOut.reason) { | 391 if (errorOut.reason) { |
| 392 if (m_state == ConnectionStateReleased) { | 392 if (m_state == ConnectionStateReleased) { |
| 393 // A message dispatched while synchronously fetching the resource | 393 // A message dispatched while synchronously fetching the resource |
| 394 // can bring about the cancellation of this load. | 394 // can bring about the cancellation of this load. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 409 // empty buffer is a noop in most cases, but is destructive in the case of | 409 // empty buffer is a noop in most cases, but is destructive in the case of |
| 410 // a 304, where it will overwrite the cached data we should be reusing. | 410 // a 304, where it will overwrite the cached data we should be reusing. |
| 411 if (dataOut.size()) { | 411 if (dataOut.size()) { |
| 412 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size
(), encodedDataLength); | 412 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size
(), encodedDataLength); |
| 413 m_resource->setResourceBuffer(dataOut); | 413 m_resource->setResourceBuffer(dataOut); |
| 414 } | 414 } |
| 415 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); | 415 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
| 416 } | 416 } |
| 417 | 417 |
| 418 } // namespace blink | 418 } // namespace blink |
| OLD | NEW |