| 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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 resource_->AppendData(data, length); | 403 resource_->AppendData(data, length); |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ResourceLoader::DidReceiveTransferSizeUpdate(int transfer_size_diff) { | 406 void ResourceLoader::DidReceiveTransferSizeUpdate(int transfer_size_diff) { |
| 407 DCHECK_GT(transfer_size_diff, 0); | 407 DCHECK_GT(transfer_size_diff, 0); |
| 408 Context().DispatchDidReceiveEncodedData(resource_->Identifier(), | 408 Context().DispatchDidReceiveEncodedData(resource_->Identifier(), |
| 409 transfer_size_diff); | 409 transfer_size_diff); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void ResourceLoader::DidFinishLoadingFirstPartInMultipart() { | 412 void ResourceLoader::DidFinishLoadingFirstPartInMultipart() { |
| 413 network_instrumentation::endResourceLoad( | 413 network_instrumentation::EndResourceLoad( |
| 414 resource_->Identifier(), | 414 resource_->Identifier(), |
| 415 network_instrumentation::RequestOutcome::Success); | 415 network_instrumentation::RequestOutcome::kSuccess); |
| 416 | 416 |
| 417 fetcher_->HandleLoaderFinish(resource_.Get(), 0, | 417 fetcher_->HandleLoaderFinish(resource_.Get(), 0, |
| 418 ResourceFetcher::kDidFinishFirstPartInMultipart); | 418 ResourceFetcher::kDidFinishFirstPartInMultipart); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void ResourceLoader::DidFinishLoading(double finish_time, | 421 void ResourceLoader::DidFinishLoading(double finish_time, |
| 422 int64_t encoded_data_length, | 422 int64_t encoded_data_length, |
| 423 int64_t encoded_body_length, | 423 int64_t encoded_body_length, |
| 424 int64_t decoded_body_length) { | 424 int64_t decoded_body_length) { |
| 425 resource_->SetEncodedDataLength(encoded_data_length); | 425 resource_->SetEncodedDataLength(encoded_data_length); |
| 426 resource_->SetEncodedBodyLength(encoded_body_length); | 426 resource_->SetEncodedBodyLength(encoded_body_length); |
| 427 resource_->SetDecodedBodyLength(decoded_body_length); | 427 resource_->SetDecodedBodyLength(decoded_body_length); |
| 428 | 428 |
| 429 loader_.reset(); | 429 loader_.reset(); |
| 430 | 430 |
| 431 network_instrumentation::endResourceLoad( | 431 network_instrumentation::EndResourceLoad( |
| 432 resource_->Identifier(), | 432 resource_->Identifier(), |
| 433 network_instrumentation::RequestOutcome::Success); | 433 network_instrumentation::RequestOutcome::kSuccess); |
| 434 | 434 |
| 435 fetcher_->HandleLoaderFinish(resource_.Get(), finish_time, | 435 fetcher_->HandleLoaderFinish(resource_.Get(), finish_time, |
| 436 ResourceFetcher::kDidFinishLoading); | 436 ResourceFetcher::kDidFinishLoading); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void ResourceLoader::DidFail(const WebURLError& error, | 439 void ResourceLoader::DidFail(const WebURLError& error, |
| 440 int64_t encoded_data_length, | 440 int64_t encoded_data_length, |
| 441 int64_t encoded_body_length, | 441 int64_t encoded_body_length, |
| 442 int64_t decoded_body_length) { | 442 int64_t decoded_body_length) { |
| 443 resource_->SetEncodedDataLength(encoded_data_length); | 443 resource_->SetEncodedDataLength(encoded_data_length); |
| 444 resource_->SetEncodedBodyLength(encoded_body_length); | 444 resource_->SetEncodedBodyLength(encoded_body_length); |
| 445 resource_->SetDecodedBodyLength(decoded_body_length); | 445 resource_->SetDecodedBodyLength(decoded_body_length); |
| 446 HandleError(error); | 446 HandleError(error); |
| 447 } | 447 } |
| 448 | 448 |
| 449 void ResourceLoader::HandleError(const ResourceError& error) { | 449 void ResourceLoader::HandleError(const ResourceError& error) { |
| 450 if (is_cache_aware_loading_activated_ && error.IsCacheMiss() && | 450 if (is_cache_aware_loading_activated_ && error.IsCacheMiss() && |
| 451 Context().ShouldLoadNewResource(resource_->GetType())) { | 451 Context().ShouldLoadNewResource(resource_->GetType())) { |
| 452 resource_->WillReloadAfterDiskCacheMiss(); | 452 resource_->WillReloadAfterDiskCacheMiss(); |
| 453 is_cache_aware_loading_activated_ = false; | 453 is_cache_aware_loading_activated_ = false; |
| 454 Restart(resource_->GetResourceRequest()); | 454 Restart(resource_->GetResourceRequest()); |
| 455 return; | 455 return; |
| 456 } | 456 } |
| 457 | 457 |
| 458 loader_.reset(); | 458 loader_.reset(); |
| 459 | 459 |
| 460 network_instrumentation::endResourceLoad( | 460 network_instrumentation::EndResourceLoad( |
| 461 resource_->Identifier(), network_instrumentation::RequestOutcome::Fail); | 461 resource_->Identifier(), network_instrumentation::RequestOutcome::kFail); |
| 462 | 462 |
| 463 fetcher_->HandleLoaderError(resource_.Get(), error); | 463 fetcher_->HandleLoaderError(resource_.Get(), error); |
| 464 } | 464 } |
| 465 | 465 |
| 466 void ResourceLoader::RequestSynchronously(const ResourceRequest& request) { | 466 void ResourceLoader::RequestSynchronously(const ResourceRequest& request) { |
| 467 // downloadToFile is not supported for synchronous requests. | 467 // downloadToFile is not supported for synchronous requests. |
| 468 DCHECK(!request.DownloadToFile()); | 468 DCHECK(!request.DownloadToFile()); |
| 469 DCHECK(loader_); | 469 DCHECK(loader_); |
| 470 DCHECK_EQ(request.Priority(), kResourceLoadPriorityHighest); | 470 DCHECK_EQ(request.Priority(), kResourceLoadPriorityHighest); |
| 471 | 471 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 return; | 527 return; |
| 528 | 528 |
| 529 // Don't activate if cache policy is explicitly set. | 529 // Don't activate if cache policy is explicitly set. |
| 530 if (request.GetCachePolicy() != WebCachePolicy::kUseProtocolCachePolicy) | 530 if (request.GetCachePolicy() != WebCachePolicy::kUseProtocolCachePolicy) |
| 531 return; | 531 return; |
| 532 | 532 |
| 533 is_cache_aware_loading_activated_ = true; | 533 is_cache_aware_loading_activated_ = true; |
| 534 } | 534 } |
| 535 | 535 |
| 536 } // namespace blink | 536 } // namespace blink |
| OLD | NEW |