| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 commitData(0, 0); | 319 commitData(0, 0); |
| 320 } | 320 } |
| 321 | 321 |
| 322 m_applicationCacheHost->finishedLoadingMainResource(); | 322 m_applicationCacheHost->finishedLoadingMainResource(); |
| 323 endWriting(m_writer.get()); | 323 endWriting(m_writer.get()); |
| 324 if (m_state < MainResourceDone) | 324 if (m_state < MainResourceDone) |
| 325 m_state = MainResourceDone; | 325 m_state = MainResourceDone; |
| 326 clearMainResourceHandle(); | 326 clearMainResourceHandle(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void DocumentLoader::updateRequest(Resource* resource, const ResourceRequest& re
quest) | |
| 330 { | |
| 331 ASSERT_UNUSED(resource, resource == m_mainResource); | |
| 332 m_request = request; | |
| 333 } | |
| 334 | |
| 335 void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque
st, const ResourceResponse& redirectResponse) | 329 void DocumentLoader::redirectReceived(Resource* resource, ResourceRequest& reque
st, const ResourceResponse& redirectResponse) |
| 336 { | 330 { |
| 337 ASSERT_UNUSED(resource, resource == m_mainResource); | 331 ASSERT_UNUSED(resource, resource == m_mainResource); |
| 338 ASSERT(!redirectResponse.isNull()); | 332 ASSERT(!redirectResponse.isNull()); |
| 339 m_request = request; | 333 m_request = request; |
| 340 | 334 |
| 341 // If the redirecting url is not allowed to display content from the target
origin, | 335 // If the redirecting url is not allowed to display content from the target
origin, |
| 342 // then block the redirect. | 336 // then block the redirect. |
| 343 const KURL& requestURL = m_request.url(); | 337 const KURL& requestURL = m_request.url(); |
| 344 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe
sponse.url()); | 338 RefPtr<SecurityOrigin> redirectingOrigin = SecurityOrigin::create(redirectRe
sponse.url()); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 678 |
| 685 if (maybeLoadEmpty()) | 679 if (maybeLoadEmpty()) |
| 686 return; | 680 return; |
| 687 | 681 |
| 688 ASSERT(timing().navigationStart()); | 682 ASSERT(timing().navigationStart()); |
| 689 ASSERT(!timing().fetchStart()); | 683 ASSERT(!timing().fetchStart()); |
| 690 timing().markFetchStart(); | 684 timing().markFetchStart(); |
| 691 | 685 |
| 692 m_applicationCacheHost->willStartLoadingMainResource(m_request); | 686 m_applicationCacheHost->willStartLoadingMainResource(m_request); |
| 693 | 687 |
| 694 ResourceRequest request(m_request); | |
| 695 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, | 688 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, |
| 696 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch
eckContentSecurityPolicy, DocumentContext)); | 689 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch
eckContentSecurityPolicy, DocumentContext)); |
| 697 FetchRequest cachedResourceRequest(request, FetchInitiatorTypeNames::documen
t, mainResourceLoadOptions); | 690 FetchRequest fetchRequest(m_request, FetchInitiatorTypeNames::document, main
ResourceLoadOptions); |
| 698 m_mainResource = RawResource::fetchMainResource(cachedResourceRequest, fetch
er(), m_substituteData); | 691 m_mainResource = RawResource::fetchMainResource(fetchRequest, fetcher(), m_s
ubstituteData); |
| 699 if (!m_mainResource) { | 692 if (!m_mainResource) { |
| 700 m_request = ResourceRequest(); | 693 m_request = ResourceRequest(); |
| 701 // If the load was aborted by clearing m_request, it's possible the Appl
icationCacheHost | 694 // If the load was aborted by clearing m_request, it's possible the Appl
icationCacheHost |
| 702 // is now in a state where starting an empty load will be inconsistent.
Replace it with | 695 // is now in a state where starting an empty load will be inconsistent.
Replace it with |
| 703 // a new ApplicationCacheHost. | 696 // a new ApplicationCacheHost. |
| 704 if (m_applicationCacheHost) | 697 if (m_applicationCacheHost) |
| 705 m_applicationCacheHost->detachFromDocumentLoader(); | 698 m_applicationCacheHost->detachFromDocumentLoader(); |
| 706 m_applicationCacheHost = ApplicationCacheHost::create(this); | 699 m_applicationCacheHost = ApplicationCacheHost::create(this); |
| 707 maybeLoadEmpty(); | 700 maybeLoadEmpty(); |
| 708 return; | 701 return; |
| 709 } | 702 } |
| 710 m_mainResource->addClient(this); | 703 m_mainResource->addClient(this); |
| 704 if (!m_mainResource) |
| 705 return; |
| 711 | 706 |
| 712 // A bunch of headers are set when the underlying ResourceLoader is created,
and m_request needs to include those. | 707 // A bunch of headers are set when the underlying ResourceLoader is created,
and m_request needs to include those. |
| 713 if (mainResourceLoader()) | 708 m_request = m_mainResource->resourceRequest(); |
| 714 request = mainResourceLoader()->originalRequest(); | |
| 715 // If there was a fragment identifier on m_request, the cache will have stri
pped it. m_request should include | 709 // If there was a fragment identifier on m_request, the cache will have stri
pped it. m_request should include |
| 716 // the fragment identifier, so add that back in. | 710 // the fragment identifier, so add that back in. |
| 717 if (equalIgnoringFragmentIdentifier(m_request.url(), request.url())) | 711 if (equalIgnoringFragmentIdentifier(m_request.url(), fetchRequest.url())) |
| 718 request.setURL(m_request.url()); | 712 m_request.setURL(fetchRequest.url()); |
| 719 m_request = request; | |
| 720 } | 713 } |
| 721 | 714 |
| 722 void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError) | 715 void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError) |
| 723 { | 716 { |
| 724 RefPtrWillBeRawPtr<DocumentLoader> protect(this); | 717 RefPtrWillBeRawPtr<DocumentLoader> protect(this); |
| 725 ResourceError error = resourceError.isNull() ? ResourceError::cancelledError
(m_request.url()) : resourceError; | 718 ResourceError error = resourceError.isNull() ? ResourceError::cancelledError
(m_request.url()) : resourceError; |
| 726 | 719 |
| 727 if (mainResourceLoader()) | 720 if (mainResourceLoader()) |
| 728 mainResourceLoader()->cancel(error); | 721 mainResourceLoader()->cancel(error); |
| 729 | 722 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 { | 759 { |
| 767 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding()
: emptyAtom, true, ForceSynchronousParsing); | 760 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding()
: emptyAtom, true, ForceSynchronousParsing); |
| 768 if (!source.isNull()) | 761 if (!source.isNull()) |
| 769 m_writer->appendReplacingData(source); | 762 m_writer->appendReplacingData(source); |
| 770 endWriting(m_writer.get()); | 763 endWriting(m_writer.get()); |
| 771 } | 764 } |
| 772 | 765 |
| 773 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 766 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
| 774 | 767 |
| 775 } // namespace blink | 768 } // namespace blink |
| OLD | NEW |