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

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

Issue 13866038: Revert 148069 and 148060 to see if they were responsible for a perf regression (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "FrameTree.h" 47 #include "FrameTree.h"
48 #include "HTMLFormElement.h" 48 #include "HTMLFormElement.h"
49 #include "HTMLFrameOwnerElement.h" 49 #include "HTMLFrameOwnerElement.h"
50 #include "HistoryItem.h" 50 #include "HistoryItem.h"
51 #include "InspectorInstrumentation.h" 51 #include "InspectorInstrumentation.h"
52 #include "Logging.h" 52 #include "Logging.h"
53 #include "MemoryCache.h" 53 #include "MemoryCache.h"
54 #include "Page.h" 54 #include "Page.h"
55 #include "ProgressTracker.h" 55 #include "ProgressTracker.h"
56 #include "ResourceBuffer.h" 56 #include "ResourceBuffer.h"
57 #include "ResourceLoader.h"
58 #include "SchemeRegistry.h" 57 #include "SchemeRegistry.h"
59 #include "SecurityPolicy.h" 58 #include "SecurityPolicy.h"
60 #include "Settings.h" 59 #include "Settings.h"
60 #include "SubresourceLoader.h"
61 #include "TextResourceDecoder.h" 61 #include "TextResourceDecoder.h"
62 #include "WebCoreMemoryInstrumentation.h" 62 #include "WebCoreMemoryInstrumentation.h"
63 #include <wtf/Assertions.h> 63 #include <wtf/Assertions.h>
64 #include <wtf/MemoryInstrumentationHashMap.h> 64 #include <wtf/MemoryInstrumentationHashMap.h>
65 #include <wtf/MemoryInstrumentationHashSet.h> 65 #include <wtf/MemoryInstrumentationHashSet.h>
66 #include <wtf/MemoryInstrumentationVector.h> 66 #include <wtf/MemoryInstrumentationVector.h>
67 #include <wtf/text/CString.h> 67 #include <wtf/text/CString.h>
68 #include <wtf/text/WTFString.h> 68 #include <wtf/text/WTFString.h>
69 #include <wtf/unicode/Unicode.h> 69 #include <wtf/unicode/Unicode.h>
70 70
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (m_committed) { 248 if (m_committed) {
249 // Attempt to stop the frame if the document loader is loading, or if it is done loading but 249 // Attempt to stop the frame if the document loader is loading, or if it is done loading but
250 // still parsing. Failure to do so can cause a world leak. 250 // still parsing. Failure to do so can cause a world leak.
251 Document* doc = m_frame->document(); 251 Document* doc = m_frame->document();
252 252
253 if (loading || doc->parsing()) 253 if (loading || doc->parsing())
254 m_frame->loader()->stopLoading(UnloadEventPolicyNone); 254 m_frame->loader()->stopLoading(UnloadEventPolicyNone);
255 } 255 }
256 256
257 // Always cancel multipart loaders 257 // Always cancel multipart loaders
258 cancelAll(m_multipartResourceLoaders); 258 cancelAll(m_multipartSubresourceLoaders);
259 259
260 // Appcache uses ResourceHandle directly, DocumentLoader doesn't count these loads. 260 // Appcache uses ResourceHandle directly, DocumentLoader doesn't count these loads.
261 m_applicationCacheHost->stopLoadingInFrame(m_frame); 261 m_applicationCacheHost->stopLoadingInFrame(m_frame);
262 262
263 clearArchiveResources(); 263 clearArchiveResources();
264 264
265 if (!loading) { 265 if (!loading) {
266 // If something above restarted loading we might run into mysterious cra shes like 266 // If something above restarted loading we might run into mysterious cra shes like
267 // https://bugs.webkit.org/show_bug.cgi?id=62764 and <rdar://problem/932 8684> 267 // https://bugs.webkit.org/show_bug.cgi?id=62764 and <rdar://problem/932 8684>
268 ASSERT(!isLoading()); 268 ASSERT(!isLoading());
269 return; 269 return;
270 } 270 }
271 271
272 // We might run in to infinite recursion if we're stopping loading as the re sult of 272 // We might run in to infinite recursion if we're stopping loading as the re sult of
273 // detaching from the frame, so break out of that recursion here. 273 // detaching from the frame, so break out of that recursion here.
274 // See <rdar://problem/9673866> for more details. 274 // See <rdar://problem/9673866> for more details.
275 if (m_isStopping) 275 if (m_isStopping)
276 return; 276 return;
277 277
278 m_isStopping = true; 278 m_isStopping = true;
279 279
280 FrameLoader* frameLoader = DocumentLoader::frameLoader(); 280 FrameLoader* frameLoader = DocumentLoader::frameLoader();
281 281
282 if (isLoadingMainResource()) 282 if (isLoadingMainResource())
283 // Stop the main resource loader and let it send the cancelled message. 283 // Stop the main resource loader and let it send the cancelled message.
284 cancelMainResourceLoad(frameLoader->cancelledError(m_request)); 284 cancelMainResourceLoad(frameLoader->cancelledError(m_request));
285 else if (!m_resourceLoaders.isEmpty()) 285 else if (!m_subresourceLoaders.isEmpty())
286 // The main resource loader already finished loading. Set the cancelled error on the 286 // The main resource loader already finished loading. Set the cancelled error on the
287 // document and let the resourceLoaders send individual cancelled messag es below. 287 // document and let the subresourceLoaders send individual cancelled mes sages below.
288 setMainDocumentError(frameLoader->cancelledError(m_request)); 288 setMainDocumentError(frameLoader->cancelledError(m_request));
289 else 289 else
290 // If there are no resource loaders, we need to manufacture a cancelled message. 290 // If there are no resource loaders, we need to manufacture a cancelled message.
291 // (A back/forward navigation has no resource loaders because its resour ces are cached.) 291 // (A back/forward navigation has no resource loaders because its resour ces are cached.)
292 mainReceivedError(frameLoader->cancelledError(m_request)); 292 mainReceivedError(frameLoader->cancelledError(m_request));
293 293
294 stopLoadingSubresources(); 294 stopLoadingSubresources();
295 295
296 m_isStopping = false; 296 m_isStopping = false;
297 } 297 }
298 298
299 void DocumentLoader::commitIfReady() 299 void DocumentLoader::commitIfReady()
300 { 300 {
301 if (!m_committed) { 301 if (!m_committed) {
302 m_committed = true; 302 m_committed = true;
303 frameLoader()->commitProvisionalLoad(); 303 frameLoader()->commitProvisionalLoad();
304 } 304 }
305 } 305 }
306 306
307 bool DocumentLoader::isLoading() const 307 bool DocumentLoader::isLoading() const
308 { 308 {
309 // FIXME: This should always be enabled, but it seems to cause 309 // FIXME: This should always be enabled, but it seems to cause
310 // http/tests/security/feed-urls-from-remote.html to timeout on Mac WK1 310 // http/tests/security/feed-urls-from-remote.html to timeout on Mac WK1
311 // see http://webkit.org/b/110554 and http://webkit.org/b/110401 311 // see http://webkit.org/b/110554 and http://webkit.org/b/110401
312 #if ENABLE(THREADED_HTML_PARSER) 312 #if ENABLE(THREADED_HTML_PARSER)
313 if (document() && document()->hasActiveParser()) 313 if (document() && document()->hasActiveParser())
314 return true; 314 return true;
315 #endif 315 #endif
316 return isLoadingMainResource() || !m_resourceLoaders.isEmpty(); 316 return isLoadingMainResource() || !m_subresourceLoaders.isEmpty();
317 } 317 }
318 318
319 void DocumentLoader::notifyFinished(CachedResource* resource) 319 void DocumentLoader::notifyFinished(CachedResource* resource)
320 { 320 {
321 ASSERT_UNUSED(resource, m_mainResource == resource); 321 ASSERT_UNUSED(resource, m_mainResource == resource);
322 ASSERT(m_mainResource); 322 ASSERT(m_mainResource);
323 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) { 323 if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
324 finishedLoading(m_mainResource->loadFinishTime()); 324 finishedLoading(m_mainResource->loadFinishTime());
325 return; 325 return;
326 } 326 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 ASSERT(m_frame->document()->parsing()); 711 ASSERT(m_frame->document()->parsing());
712 m_writer.addData(bytes, length); 712 m_writer.addData(bytes, length);
713 } 713 }
714 714
715 void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const 715 void DocumentLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
716 { 716 {
717 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); 717 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader);
718 info.addMember(m_frame, "frame"); 718 info.addMember(m_frame, "frame");
719 info.addMember(m_cachedResourceLoader, "cachedResourceLoader"); 719 info.addMember(m_cachedResourceLoader, "cachedResourceLoader");
720 info.addMember(m_mainResource, "mainResource"); 720 info.addMember(m_mainResource, "mainResource");
721 info.addMember(m_resourceLoaders, "resourceLoaders"); 721 info.addMember(m_subresourceLoaders, "subresourceLoaders");
722 info.addMember(m_multipartResourceLoaders, "multipartResourceLoaders"); 722 info.addMember(m_multipartSubresourceLoaders, "multipartSubresourceLoaders") ;
723 info.addMember(m_substituteData, "substituteData"); 723 info.addMember(m_substituteData, "substituteData");
724 info.addMember(m_pageTitle.string(), "pageTitle.string()"); 724 info.addMember(m_pageTitle.string(), "pageTitle.string()");
725 info.addMember(m_overrideEncoding, "overrideEncoding"); 725 info.addMember(m_overrideEncoding, "overrideEncoding");
726 info.addMember(m_originalRequest, "originalRequest"); 726 info.addMember(m_originalRequest, "originalRequest");
727 info.addMember(m_originalRequestCopy, "originalRequestCopy"); 727 info.addMember(m_originalRequestCopy, "originalRequestCopy");
728 info.addMember(m_request, "request"); 728 info.addMember(m_request, "request");
729 info.addMember(m_response, "response"); 729 info.addMember(m_response, "response");
730 info.addMember(m_lastCheckedRequest, "lastCheckedRequest"); 730 info.addMember(m_lastCheckedRequest, "lastCheckedRequest");
731 info.addMember(m_pendingSubstituteResources, "pendingSubstituteResources"); 731 info.addMember(m_pendingSubstituteResources, "pendingSubstituteResources");
732 info.addMember(m_substituteResourceDeliveryTimer, "substituteResourceDeliver yTimer"); 732 info.addMember(m_substituteResourceDeliveryTimer, "substituteResourceDeliver yTimer");
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 copy.swap(m_pendingSubstituteResources); 916 copy.swap(m_pendingSubstituteResources);
917 917
918 SubstituteResourceMap::const_iterator end = copy.end(); 918 SubstituteResourceMap::const_iterator end = copy.end();
919 for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++i t) { 919 for (SubstituteResourceMap::const_iterator it = copy.begin(); it != end; ++i t) {
920 RefPtr<ResourceLoader> loader = it->key; 920 RefPtr<ResourceLoader> loader = it->key;
921 SubstituteResource* resource = it->value.get(); 921 SubstituteResource* resource = it->value.get();
922 922
923 if (resource) { 923 if (resource) {
924 SharedBuffer* data = resource->data(); 924 SharedBuffer* data = resource->data();
925 925
926 loader->didReceiveResponse(0, resource->response()); 926 loader->didReceiveResponse(resource->response());
927 927
928 // Calling ResourceLoader::didReceiveResponse can end up cancelling the load, 928 // Calling ResourceLoader::didReceiveResponse can end up cancelling the load,
929 // so we need to check if the loader has reached its terminal state. 929 // so we need to check if the loader has reached its terminal state.
930 if (loader->reachedTerminalState()) 930 if (loader->reachedTerminalState())
931 return; 931 return;
932 932
933 loader->didReceiveData(0, data->data(), data->size(), data->size()); 933 loader->didReceiveData(0, data->data(), data->size(), data->size());
934 934
935 // Calling ResourceLoader::didReceiveData can end up cancelling the load, 935 // Calling ResourceLoader::didReceiveData can end up cancelling the load,
936 // so we need to check if the loader has reached its terminal state. 936 // so we need to check if the loader has reached its terminal state.
937 if (loader->reachedTerminalState()) 937 if (loader->reachedTerminalState())
938 return; 938 return;
939 939
940 loader->didFinishLoading(0, 0); 940 loader->didFinishLoading(0);
941 } else { 941 } else {
942 // A null resource means that we should fail the load. 942 // A null resource means that we should fail the load.
943 // FIXME: Maybe we should use another error here - something like "n ot in cache". 943 // FIXME: Maybe we should use another error here - something like "n ot in cache".
944 loader->didFail(0, loader->cannotShowURLError()); 944 loader->didFail(loader->cannotShowURLError());
945 } 945 }
946 } 946 }
947 } 947 }
948 948
949 #ifndef NDEBUG 949 #ifndef NDEBUG
950 bool DocumentLoader::isSubstituteLoadPending(ResourceLoader* loader) const 950 bool DocumentLoader::isSubstituteLoadPending(ResourceLoader* loader) const
951 { 951 {
952 return m_pendingSubstituteResources.contains(loader); 952 return m_pendingSubstituteResources.contains(loader);
953 } 953 }
954 #endif 954 #endif
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 } 1032 }
1033 1033
1034 void DocumentLoader::setDefersLoading(bool defers) 1034 void DocumentLoader::setDefersLoading(bool defers)
1035 { 1035 {
1036 // Multiple frames may be loading the same main resource simultaneously. If deferral state changes, 1036 // Multiple frames may be loading the same main resource simultaneously. If deferral state changes,
1037 // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only 1037 // each frame's DocumentLoader will try to send a setDefersLoading() to the same underlying ResourceLoader. Ensure only
1038 // the "owning" DocumentLoader does so, as setDefersLoading() is not resilie nt to setting the same value repeatedly. 1038 // the "owning" DocumentLoader does so, as setDefersLoading() is not resilie nt to setting the same value repeatedly.
1039 if (mainResourceLoader() && mainResourceLoader()->documentLoader() == this) 1039 if (mainResourceLoader() && mainResourceLoader()->documentLoader() == this)
1040 mainResourceLoader()->setDefersLoading(defers); 1040 mainResourceLoader()->setDefersLoading(defers);
1041 1041
1042 setAllDefersLoading(m_resourceLoaders, defers); 1042 setAllDefersLoading(m_subresourceLoaders, defers);
1043 if (!defers) 1043 if (!defers)
1044 deliverSubstituteResourcesAfterDelay(); 1044 deliverSubstituteResourcesAfterDelay();
1045 } 1045 }
1046 1046
1047 void DocumentLoader::setMainResourceDataBufferingPolicy(DataBufferingPolicy data BufferingPolicy) 1047 void DocumentLoader::setMainResourceDataBufferingPolicy(DataBufferingPolicy data BufferingPolicy)
1048 { 1048 {
1049 if (m_mainResource) 1049 if (m_mainResource)
1050 m_mainResource->setDataBufferingPolicy(dataBufferingPolicy); 1050 m_mainResource->setDataBufferingPolicy(dataBufferingPolicy);
1051 } 1051 }
1052 1052
1053 void DocumentLoader::stopLoadingSubresources() 1053 void DocumentLoader::stopLoadingSubresources()
1054 { 1054 {
1055 cancelAll(m_resourceLoaders); 1055 cancelAll(m_subresourceLoaders);
1056 } 1056 }
1057 1057
1058 void DocumentLoader::addResourceLoader(ResourceLoader* loader) 1058 void DocumentLoader::addSubresourceLoader(ResourceLoader* loader)
1059 { 1059 {
1060 // The main resource's underlying ResourceLoader will ask to be added here. 1060 // The main resource's underlying ResourceLoader will ask to be added here.
1061 // It is much simpler to handle special casing of main resource loads if we don't 1061 // It is much simpler to handle special casing of main resource loads if we don't
1062 // let it be added. In the main resource load case, mainResourceLoader() 1062 // let it be added. In the main resource load case, mainResourceLoader()
1063 // will still be null at this point, but m_gotFirstByte should be false here if and only 1063 // will still be null at this point, but m_gotFirstByte should be false here if and only
1064 // if we are just starting the main resource load. 1064 // if we are just starting the main resource load.
1065 if (!m_gotFirstByte) 1065 if (!m_gotFirstByte)
1066 return; 1066 return;
1067 ASSERT(!m_resourceLoaders.contains(loader)); 1067 ASSERT(!m_subresourceLoaders.contains(loader));
1068 ASSERT(!mainResourceLoader() || mainResourceLoader() != loader); 1068 ASSERT(!mainResourceLoader() || mainResourceLoader() != loader);
1069 m_resourceLoaders.add(loader); 1069 m_subresourceLoaders.add(loader);
1070 } 1070 }
1071 1071
1072 void DocumentLoader::removeResourceLoader(ResourceLoader* loader) 1072 void DocumentLoader::removeSubresourceLoader(ResourceLoader* loader)
1073 { 1073 {
1074 if (!m_resourceLoaders.contains(loader)) 1074 if (!m_subresourceLoaders.contains(loader))
1075 return; 1075 return;
1076 m_resourceLoaders.remove(loader); 1076 m_subresourceLoaders.remove(loader);
1077 checkLoadComplete(); 1077 checkLoadComplete();
1078 if (Frame* frame = m_frame) 1078 if (Frame* frame = m_frame)
1079 frame->loader()->checkLoadComplete(); 1079 frame->loader()->checkLoadComplete();
1080 } 1080 }
1081 1081
1082 bool DocumentLoader::isMultipartReplacingLoad() const 1082 bool DocumentLoader::isMultipartReplacingLoad() const
1083 { 1083 {
1084 return isLoadingMultipartContent() && frameLoader()->isReplacing(); 1084 return isLoadingMultipartContent() && frameLoader()->isReplacing();
1085 } 1085 }
1086 1086
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 } 1179 }
1180 1180
1181 if (mainResourceLoader()) 1181 if (mainResourceLoader())
1182 mainResourceLoader()->cancel(error); 1182 mainResourceLoader()->cancel(error);
1183 1183
1184 mainReceivedError(error); 1184 mainReceivedError(error);
1185 } 1185 }
1186 1186
1187 void DocumentLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loa der) 1187 void DocumentLoader::subresourceLoaderFinishedLoadingOnePart(ResourceLoader* loa der)
1188 { 1188 {
1189 m_multipartResourceLoaders.add(loader); 1189 m_multipartSubresourceLoaders.add(loader);
1190 m_resourceLoaders.remove(loader); 1190 m_subresourceLoaders.remove(loader);
1191 checkLoadComplete(); 1191 checkLoadComplete();
1192 if (Frame* frame = m_frame) 1192 if (Frame* frame = m_frame)
1193 frame->loader()->checkLoadComplete(); 1193 frame->loader()->checkLoadComplete();
1194 } 1194 }
1195 1195
1196 void DocumentLoader::maybeFinishLoadingMultipartContent() 1196 void DocumentLoader::maybeFinishLoadingMultipartContent()
1197 { 1197 {
1198 if (!isMultipartReplacingLoad()) 1198 if (!isMultipartReplacingLoad())
1199 return; 1199 return;
1200 1200
1201 frameLoader()->setupForReplace(); 1201 frameLoader()->setupForReplace();
1202 m_committed = false; 1202 m_committed = false;
1203 RefPtr<ResourceBuffer> resourceData = mainResourceData(); 1203 RefPtr<ResourceBuffer> resourceData = mainResourceData();
1204 commitLoad(resourceData->data(), resourceData->size()); 1204 commitLoad(resourceData->data(), resourceData->size());
1205 } 1205 }
1206 1206
1207 void DocumentLoader::handledOnloadEvents() 1207 void DocumentLoader::handledOnloadEvents()
1208 { 1208 {
1209 m_wasOnloadHandled = true; 1209 m_wasOnloadHandled = true;
1210 applicationCacheHost()->stopDeferringEvents(); 1210 applicationCacheHost()->stopDeferringEvents();
1211 } 1211 }
1212 1212
1213 } // namespace WebCore 1213 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/loader/DocumentLoader.h ('k') | Source/WebCore/loader/DocumentThreadableLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698