Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: Source/core/loader/DocumentLoader.cpp

Issue 1170503003: Remove resource type-specific fetching logic from ResourceFetcher (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Null-check Document::loader() before calling startPreload() Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/DocumentLoader.h ('k') | Source/core/loader/DocumentThreadableLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "core/loader/DocumentLoader.h" 31 #include "core/loader/DocumentLoader.h"
32 32
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/DocumentParser.h" 34 #include "core/dom/DocumentParser.h"
35 #include "core/dom/WeakIdentifierMap.h" 35 #include "core/dom/WeakIdentifierMap.h"
36 #include "core/events/Event.h" 36 #include "core/events/Event.h"
37 #include "core/fetch/CSSStyleSheetResource.h"
37 #include "core/fetch/FetchInitiatorTypeNames.h" 38 #include "core/fetch/FetchInitiatorTypeNames.h"
39 #include "core/fetch/FetchRequest.h"
40 #include "core/fetch/ImageResource.h"
38 #include "core/fetch/MemoryCache.h" 41 #include "core/fetch/MemoryCache.h"
39 #include "core/fetch/ResourceFetcher.h" 42 #include "core/fetch/ResourceFetcher.h"
40 #include "core/fetch/ResourceLoader.h" 43 #include "core/fetch/ResourceLoader.h"
44 #include "core/fetch/ScriptResource.h"
41 #include "core/frame/FrameHost.h" 45 #include "core/frame/FrameHost.h"
42 #include "core/frame/LocalDOMWindow.h" 46 #include "core/frame/LocalDOMWindow.h"
43 #include "core/frame/LocalFrame.h" 47 #include "core/frame/LocalFrame.h"
44 #include "core/frame/Settings.h" 48 #include "core/frame/Settings.h"
45 #include "core/frame/csp/ContentSecurityPolicy.h" 49 #include "core/frame/csp/ContentSecurityPolicy.h"
46 #include "core/html/HTMLFrameOwnerElement.h" 50 #include "core/html/HTMLFrameOwnerElement.h"
47 #include "core/html/parser/HTMLDocumentParser.h" 51 #include "core/html/parser/HTMLDocumentParser.h"
48 #include "core/html/parser/TextResourceDecoder.h" 52 #include "core/html/parser/TextResourceDecoder.h"
49 #include "core/inspector/ConsoleMessage.h" 53 #include "core/inspector/ConsoleMessage.h"
50 #include "core/inspector/InspectorInstrumentation.h" 54 #include "core/inspector/InspectorInstrumentation.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const ResourceRequest& DocumentLoader::request() const 136 const ResourceRequest& DocumentLoader::request() const
133 { 137 {
134 return m_request; 138 return m_request;
135 } 139 }
136 140
137 const KURL& DocumentLoader::url() const 141 const KURL& DocumentLoader::url() const
138 { 142 {
139 return m_request.url(); 143 return m_request.url();
140 } 144 }
141 145
146 void DocumentLoader::startPreload(Resource::Type type, FetchRequest& request)
147 {
148 ASSERT(type == Resource::Script || type == Resource::CSSStyleSheet || type = = Resource::Image);
149 ResourcePtr<Resource> resource;
150 if (type == Resource::Image)
151 resource = ImageResource::fetch(request, fetcher());
152 else if (type == Resource::Script)
153 resource = ScriptResource::fetch(request, fetcher());
154 else
155 resource = CSSStyleSheetResource::fetch(request, fetcher());
156
157 if (resource)
158 fetcher()->preloadStarted(resource.get());
159 }
160
142 void DocumentLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDoc umentNavigationSource sameDocumentNavigationSource) 161 void DocumentLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDoc umentNavigationSource sameDocumentNavigationSource)
143 { 162 {
144 KURL oldURL = m_request.url(); 163 KURL oldURL = m_request.url();
145 m_originalRequest.setURL(newURL); 164 m_originalRequest.setURL(newURL);
146 m_request.setURL(newURL); 165 m_request.setURL(newURL);
147 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 166 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
148 m_request.setHTTPMethod("GET"); 167 m_request.setHTTPMethod("GET");
149 m_request.setHTTPBody(nullptr); 168 m_request.setHTTPBody(nullptr);
150 } 169 }
151 clearRedirectChain(); 170 clearRedirectChain();
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (!m_frame || m_request.isNull()) 702 if (!m_frame || m_request.isNull())
684 return; 703 return;
685 704
686 m_applicationCacheHost->willStartLoadingMainResource(m_request); 705 m_applicationCacheHost->willStartLoadingMainResource(m_request);
687 prepareSubframeArchiveLoadIfNeeded(); 706 prepareSubframeArchiveLoadIfNeeded();
688 707
689 ResourceRequest request(m_request); 708 ResourceRequest request(m_request);
690 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions, 709 DEFINE_STATIC_LOCAL(ResourceLoaderOptions, mainResourceLoadOptions,
691 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext)); 710 (DoNotBufferData, AllowStoredCredentials, ClientRequestedCredentials, Ch eckContentSecurityPolicy, DocumentContext));
692 FetchRequest cachedResourceRequest(request, FetchInitiatorTypeNames::documen t, mainResourceLoadOptions); 711 FetchRequest cachedResourceRequest(request, FetchInitiatorTypeNames::documen t, mainResourceLoadOptions);
693 m_mainResource = m_fetcher->fetchMainResource(cachedResourceRequest, m_subst ituteData); 712 m_mainResource = RawResource::fetchMainResource(cachedResourceRequest, fetch er(), m_substituteData);
694 if (!m_mainResource) { 713 if (!m_mainResource) {
695 m_request = ResourceRequest(); 714 m_request = ResourceRequest();
696 // If the load was aborted by clearing m_request, it's possible the Appl icationCacheHost 715 // If the load was aborted by clearing m_request, it's possible the Appl icationCacheHost
697 // is now in a state where starting an empty load will be inconsistent. Replace it with 716 // is now in a state where starting an empty load will be inconsistent. Replace it with
698 // a new ApplicationCacheHost. 717 // a new ApplicationCacheHost.
699 m_applicationCacheHost = ApplicationCacheHost::create(this); 718 m_applicationCacheHost = ApplicationCacheHost::create(this);
700 maybeLoadEmpty(); 719 maybeLoadEmpty();
701 return; 720 return;
702 } 721 }
703 m_mainResource->addClient(this); 722 m_mainResource->addClient(this);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L() 791 // This is only called by FrameLoader::replaceDocumentWhileExecutingJavaScriptUR L()
773 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source, Document* ownerDocument) 792 void DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL(const DocumentIn it& init, const String& source, Document* ownerDocument)
774 { 793 {
775 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing); 794 m_writer = createWriterFor(ownerDocument, init, mimeType(), m_writer ? m_wri ter->encoding() : emptyAtom, true, ForceSynchronousParsing);
776 if (!source.isNull()) 795 if (!source.isNull())
777 m_writer->appendReplacingData(source); 796 m_writer->appendReplacingData(source);
778 endWriting(m_writer.get()); 797 endWriting(m_writer.get());
779 } 798 }
780 799
781 } // namespace blink 800 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/DocumentLoader.h ('k') | Source/core/loader/DocumentThreadableLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698