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 if (mainResourceLoader()) { | 703 // A bunch of headers are set when the underlying ResourceLoader is created,
and m_request needs to include those. |
711 // A bunch of headers are set when the underlying ResourceLoader | 704 // Even when using a cached resource, we may make some modification to the r
equest, e.g. adding the referer header. |
712 // is created, and m_request needs to include those. | 705 m_request = mainResourceLoader() ? m_mainResource->resourceRequest() : fetch
Request.resourceRequest(); |
713 request = mainResourceLoader()->originalRequest(); | |
714 } else { | |
715 // Even when using a cached resource, we may make some modification | |
716 // to the request, e.g. adding the referer header. | |
717 request = cachedResourceRequest.resourceRequest(); | |
718 } | |
719 // If there was a fragment identifier on m_request, the cache will have stri
pped it. m_request should include | 706 // If there was a fragment identifier on m_request, the cache will have stri
pped it. m_request should include |
720 // the fragment identifier, so add that back in. | 707 // the fragment identifier, so add that back in. |
721 if (equalIgnoringFragmentIdentifier(m_request.url(), request.url())) | 708 if (equalIgnoringFragmentIdentifier(m_request.url(), fetchRequest.url())) |
722 request.setURL(m_request.url()); | 709 m_request.setURL(fetchRequest.url()); |
723 m_request = request; | |
724 m_mainResource->addClient(this); | 710 m_mainResource->addClient(this); |
725 } | 711 } |
726 | 712 |
727 void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError) | 713 void DocumentLoader::cancelMainResourceLoad(const ResourceError& resourceError) |
728 { | 714 { |
729 RefPtrWillBeRawPtr<DocumentLoader> protect(this); | 715 RefPtrWillBeRawPtr<DocumentLoader> protect(this); |
730 ResourceError error = resourceError.isNull() ? ResourceError::cancelledError
(m_request.url()) : resourceError; | 716 ResourceError error = resourceError.isNull() ? ResourceError::cancelledError
(m_request.url()) : resourceError; |
731 | 717 |
732 if (mainResourceLoader()) | 718 if (mainResourceLoader()) |
733 mainResourceLoader()->cancel(error); | 719 mainResourceLoader()->cancel(error); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 { | 757 { |
772 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding()
: emptyAtom, true, ForceSynchronousParsing); | 758 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding()
: emptyAtom, true, ForceSynchronousParsing); |
773 if (!source.isNull()) | 759 if (!source.isNull()) |
774 m_writer->appendReplacingData(source); | 760 m_writer->appendReplacingData(source); |
775 endWriting(m_writer.get()); | 761 endWriting(m_writer.get()); |
776 } | 762 } |
777 | 763 |
778 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); | 764 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); |
779 | 765 |
780 } // namespace blink | 766 } // namespace blink |
OLD | NEW |