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

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

Issue 1194003004: Oilpan: enable appcache + move DocumentLoader to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased 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
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/FrameLoaderClient.h » ('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, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 FrameLoader::~FrameLoader() 172 FrameLoader::~FrameLoader()
173 { 173 {
174 // Verify that this FrameLoader has been detached. 174 // Verify that this FrameLoader has been detached.
175 ASSERT(!m_progressTracker); 175 ASSERT(!m_progressTracker);
176 } 176 }
177 177
178 DEFINE_TRACE(FrameLoader) 178 DEFINE_TRACE(FrameLoader)
179 { 179 {
180 visitor->trace(m_frame); 180 visitor->trace(m_frame);
181 visitor->trace(m_progressTracker); 181 visitor->trace(m_progressTracker);
182 visitor->trace(m_documentLoader);
183 visitor->trace(m_provisionalDocumentLoader);
184 visitor->trace(m_policyDocumentLoader);
182 visitor->trace(m_currentItem); 185 visitor->trace(m_currentItem);
183 visitor->trace(m_provisionalItem); 186 visitor->trace(m_provisionalItem);
184 visitor->trace(m_deferredHistoryLoad); 187 visitor->trace(m_deferredHistoryLoad);
185 } 188 }
186 189
187 void FrameLoader::init() 190 void FrameLoader::init()
188 { 191 {
189 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); 192 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString()));
190 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); 193 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal);
191 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested); 194 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // This is only called by ScriptController::executeScriptIfJavaScriptURL 311 // This is only called by ScriptController::executeScriptIfJavaScriptURL
309 // and always contains the result of evaluating a javascript: url. 312 // and always contains the result of evaluating a javascript: url.
310 // This is the <iframe src="javascript:'html'"> case. 313 // This is the <iframe src="javascript:'html'"> case.
311 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument) 314 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument)
312 { 315 {
313 if (!m_frame->document()->loader()) 316 if (!m_frame->document()->loader())
314 return; 317 return;
315 318
316 // DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed, 319 // DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed,
317 // so protect it with a RefPtr. 320 // so protect it with a RefPtr.
318 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); 321 RefPtrWillBeRawPtr<DocumentLoader> documentLoader(m_frame->document()->loade r());
319 322
320 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); 323 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL);
321 324
322 // Prepare a DocumentInit before clearing the frame, because it may need to 325 // Prepare a DocumentInit before clearing the frame, because it may need to
323 // inherit an aliased security context. 326 // inherit an aliased security context.
324 DocumentInit init(m_frame->document()->url(), m_frame); 327 DocumentInit init(m_frame->document()->url(), m_frame);
325 init.withNewRegistrationContext(); 328 init.withNewRegistrationContext();
326 329
327 stopAllLoaders(); 330 stopAllLoaders();
328 m_frame->detachChildren(); 331 m_frame->detachChildren();
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { 640 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) {
638 m_currentItem->setStateObject(data); 641 m_currentItem->setStateObject(data);
639 m_currentItem->setScrollRestorationType(scrollRestorationType); 642 m_currentItem->setScrollRestorationType(scrollRestorationType);
640 } 643 }
641 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe); 644 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe);
642 client()->dispatchDidReceiveTitle(m_frame->document()->title()); 645 client()->dispatchDidReceiveTitle(m_frame->document()->title());
643 if (m_frame->document()->loadEventFinished()) 646 if (m_frame->document()->loadEventFinished())
644 client()->didStopLoading(); 647 client()->didStopLoading();
645 } 648 }
646 649
650 void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade r)
651 {
652 if (!loader)
653 return;
654
655 loader->detachFromFrame();
656 loader = nullptr;
657 }
658
647 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect) 659 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect)
648 { 660 {
649 // If we have a state object, we cannot also be a new navigation. 661 // If we have a state object, we cannot also be a new navigation.
650 ASSERT(!stateObject || type == FrameLoadTypeBackForward); 662 ASSERT(!stateObject || type == FrameLoadTypeBackForward);
651 663
652 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 664 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
653 if (m_provisionalDocumentLoader) { 665 if (m_provisionalDocumentLoader) {
654 m_provisionalDocumentLoader->stopLoading(); 666 m_provisionalDocumentLoader->stopLoading();
655 if (m_provisionalDocumentLoader) 667 detachDocumentLoader(m_provisionalDocumentLoader);
656 m_provisionalDocumentLoader->detachFromFrame();
657 m_provisionalDocumentLoader = nullptr;
658 if (!m_frame->host()) 668 if (!m_frame->host())
659 return; 669 return;
660 } 670 }
661 m_loadType = type; 671 m_loadType = type;
662 672
663 KURL oldURL = m_frame->document()->url(); 673 KURL oldURL = m_frame->document()->url();
664 // If we were in the autoscroll/panScroll mode we want to stop it before fol lowing the link to the anchor 674 // If we were in the autoscroll/panScroll mode we want to stop it before fol lowing the link to the anchor
665 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier(); 675 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier();
666 if (hashChange) { 676 if (hashChange) {
667 m_frame->eventHandler().stopAutoscroll(); 677 m_frame->eventHandler().stopAutoscroll();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 if (m_frame->document()->parsing()) { 970 if (m_frame->document()->parsing()) {
961 finishedParsing(); 971 finishedParsing();
962 m_frame->document()->setParsingState(Document::FinishedParsing); 972 m_frame->document()->setParsingState(Document::FinishedParsing);
963 } 973 }
964 m_frame->document()->setReadyState(Document::Complete); 974 m_frame->document()->setReadyState(Document::Complete);
965 if (m_provisionalDocumentLoader) 975 if (m_provisionalDocumentLoader)
966 m_provisionalDocumentLoader->stopLoading(); 976 m_provisionalDocumentLoader->stopLoading();
967 if (m_documentLoader) 977 if (m_documentLoader)
968 m_documentLoader->stopLoading(); 978 m_documentLoader->stopLoading();
969 979
970 if (m_provisionalDocumentLoader) 980 detachDocumentLoader(m_provisionalDocumentLoader);
971 m_provisionalDocumentLoader->detachFromFrame(); 981 detachDocumentLoader(m_policyDocumentLoader);
972 m_provisionalDocumentLoader = nullptr;
973 982
974 m_checkTimer.stop(); 983 m_checkTimer.stop();
975 m_frame->navigationScheduler().cancel(); 984 m_frame->navigationScheduler().cancel();
976 985
977 m_inStopAllLoaders = false; 986 m_inStopAllLoaders = false;
978 987
979 // detachFromParent() can be called multiple times on same LocalFrame, which 988 // detachFromParent() can be called multiple times on same LocalFrame, which
980 // means we may no longer have a FrameLoaderClient to talk to. 989 // means we may no longer have a FrameLoaderClient to talk to.
981 if (client()) 990 if (client())
982 client()->didStopAllLoaders(); 991 client()->didStopAllLoaders();
(...skipping 19 matching lines...) Expand all
1002 { 1011 {
1003 if (m_didAccessInitialDocumentTimer.isActive()) { 1012 if (m_didAccessInitialDocumentTimer.isActive()) {
1004 m_didAccessInitialDocumentTimer.stop(); 1013 m_didAccessInitialDocumentTimer.stop();
1005 didAccessInitialDocumentTimerFired(0); 1014 didAccessInitialDocumentTimerFired(0);
1006 } 1015 }
1007 } 1016 }
1008 1017
1009 bool FrameLoader::prepareForCommit() 1018 bool FrameLoader::prepareForCommit()
1010 { 1019 {
1011 PluginScriptForbiddenScope forbidPluginDestructorScripting; 1020 PluginScriptForbiddenScope forbidPluginDestructorScripting;
1012 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; 1021 RefPtrWillBeRawPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
1013 1022
1014 if (m_documentLoader) { 1023 if (m_documentLoader) {
1015 client()->dispatchWillClose(); 1024 client()->dispatchWillClose();
1016 dispatchUnloadEvent(); 1025 dispatchUnloadEvent();
1017 } 1026 }
1018 m_frame->detachChildren(); 1027 m_frame->detachChildren();
1019 // The previous calls to dispatchUnloadEvent() and detachChildren() can 1028 // The previous calls to dispatchUnloadEvent() and detachChildren() can
1020 // execute arbitrary script via things like unload events. If the executed 1029 // execute arbitrary script via things like unload events. If the executed
1021 // script intiates a new load or causes the current frame to be detached, 1030 // script intiates a new load or causes the current frame to be detached,
1022 // we need to abandon the current load. 1031 // we need to abandon the current load.
1023 if (pdl != m_provisionalDocumentLoader) 1032 if (pdl != m_provisionalDocumentLoader)
1024 return false; 1033 return false;
1025 if (m_documentLoader) { 1034 if (m_documentLoader) {
1026 FrameNavigationDisabler navigationDisabler(m_frame); 1035 FrameNavigationDisabler navigationDisabler(m_frame);
1027 m_documentLoader->detachFromFrame(); 1036 detachDocumentLoader(m_documentLoader);
1028 } 1037 }
1029 // detachFromFrame() will abort XHRs that haven't completed, which can 1038 // detachFromFrame() will abort XHRs that haven't completed, which can
1030 // trigger event listeners for 'abort'. These event listeners might detach 1039 // trigger event listeners for 'abort'. These event listeners might detach
1031 // the frame. 1040 // the frame.
1032 // TODO(dcheng): Investigate if this can be moved above the check that 1041 // TODO(dcheng): Investigate if this can be moved above the check that
1033 // m_provisionalDocumentLoader hasn't changed. 1042 // m_provisionalDocumentLoader hasn't changed.
1034 if (!m_frame->client()) 1043 if (!m_frame->client())
1035 return false; 1044 return false;
1036 // No more events will be dispatched so detach the Document. 1045 // No more events will be dispatched so detach the Document.
1037 if (m_frame->document()) 1046 if (m_frame->document())
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); 1145 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
1137 return userAgent; 1146 return userAgent;
1138 } 1147 }
1139 1148
1140 void FrameLoader::detach() 1149 void FrameLoader::detach()
1141 { 1150 {
1142 #if !ENABLE(OILPAN) 1151 #if !ENABLE(OILPAN)
1143 // The caller must protect a reference to m_frame. 1152 // The caller must protect a reference to m_frame.
1144 ASSERT(m_frame->refCount() > 1); 1153 ASSERT(m_frame->refCount() > 1);
1145 #endif 1154 #endif
1146 if (m_documentLoader) 1155 detachDocumentLoader(m_documentLoader);
1147 m_documentLoader->detachFromFrame(); 1156 detachDocumentLoader(m_provisionalDocumentLoader);
1148 m_documentLoader = nullptr; 1157 detachDocumentLoader(m_policyDocumentLoader);
1149 1158
1150 Frame* parent = m_frame->tree().parent(); 1159 Frame* parent = m_frame->tree().parent();
1151 if (parent && parent->isLocalFrame()) 1160 if (parent && parent->isLocalFrame())
1152 toLocalFrame(parent)->loader().scheduleCheckCompleted(); 1161 toLocalFrame(parent)->loader().scheduleCheckCompleted();
1153 if (m_progressTracker) { 1162 if (m_progressTracker) {
1154 m_progressTracker->dispose(); 1163 m_progressTracker->dispose();
1155 m_progressTracker.clear(); 1164 m_progressTracker.clear();
1156 } 1165 }
1157 setOpener(0); 1166 setOpener(0);
1158 } 1167 }
(...skipping 11 matching lines...) Expand all
1170 // FIXME: For now, fallback content doesn't work cross process. 1179 // FIXME: For now, fallback content doesn't work cross process.
1171 ASSERT(m_frame->owner()->isLocal()); 1180 ASSERT(m_frame->owner()->isLocal());
1172 m_frame->deprecatedLocalOwner()->renderFallbackContent(); 1181 m_frame->deprecatedLocalOwner()->renderFallbackContent();
1173 } 1182 }
1174 1183
1175 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); 1184 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
1176 if (loader == m_provisionalDocumentLoader) { 1185 if (loader == m_provisionalDocumentLoader) {
1177 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); 1186 client()->dispatchDidFailProvisionalLoad(error, historyCommitType);
1178 if (loader != m_provisionalDocumentLoader) 1187 if (loader != m_provisionalDocumentLoader)
1179 return; 1188 return;
1180 m_provisionalDocumentLoader->detachFromFrame(); 1189 detachDocumentLoader(m_provisionalDocumentLoader);
1181 m_provisionalDocumentLoader = nullptr;
1182 m_progressTracker->progressCompleted(); 1190 m_progressTracker->progressCompleted();
1183 } else { 1191 } else {
1184 ASSERT(loader == m_documentLoader); 1192 ASSERT(loader == m_documentLoader);
1185 if (m_frame->document()->parser()) 1193 if (m_frame->document()->parser())
1186 m_frame->document()->parser()->stopParsing(); 1194 m_frame->document()->parser()->stopParsing();
1187 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { 1195 if (!m_provisionalDocumentLoader && m_frame->isLoading()) {
1188 client()->dispatchDidFailLoad(error, historyCommitType); 1196 client()->dispatchDidFailLoad(error, historyCommitType);
1189 m_progressTracker->progressCompleted(); 1197 m_progressTracker->progressCompleted();
1190 } 1198 }
1191 } 1199 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 ResourceRequest& request = frameLoadRequest.resourceRequest(); 1284 ResourceRequest& request = frameLoadRequest.resourceRequest();
1277 1285
1278 m_policyDocumentLoader = client()->createDocumentLoader(m_frame, request, fr ameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData() : defaultSubstituteDataForURL(request.url())); 1286 m_policyDocumentLoader = client()->createDocumentLoader(m_frame, request, fr ameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData() : defaultSubstituteDataForURL(request.url()));
1279 m_policyDocumentLoader->setNavigationType(navigationType); 1287 m_policyDocumentLoader->setNavigationType(navigationType);
1280 m_policyDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoadTypeR edirectWithLockedBackForwardList); 1288 m_policyDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoadTypeR edirectWithLockedBackForwardList);
1281 m_policyDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedirect( ) == ClientRedirect); 1289 m_policyDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedirect( ) == ClientRedirect);
1282 1290
1283 // stopAllLoaders can detach the LocalFrame, so protect it. 1291 // stopAllLoaders can detach the LocalFrame, so protect it.
1284 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1292 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1285 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, fra meLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), navigationPolicy) || !shouldClose()) && m_policyDocumentLoader) { 1293 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, fra meLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), navigationPolicy) || !shouldClose()) && m_policyDocumentLoader) {
1286 m_policyDocumentLoader->detachFromFrame(); 1294 detachDocumentLoader(m_policyDocumentLoader);
1287 m_policyDocumentLoader = nullptr;
1288 return; 1295 return;
1289 } 1296 }
1290 1297
1291 // FIXME: This is an odd set of steps to shut down parsing and it's unclear why it works. 1298 // FIXME: This is an odd set of steps to shut down parsing and it's unclear why it works.
1292 // It's also unclear why other steps don't work. 1299 // It's also unclear why other steps don't work.
1293 if (m_frame->document()->parsing()) { 1300 if (m_frame->document()->parsing()) {
1294 finishedParsing(); 1301 finishedParsing();
1295 m_frame->document()->setParsingState(Document::FinishedParsing); 1302 m_frame->document()->setParsingState(Document::FinishedParsing);
1296 } 1303 }
1297 m_frame->document()->setReadyState(Document::Complete); 1304 m_frame->document()->setReadyState(Document::Complete);
1298 1305
1299 if (m_provisionalDocumentLoader) { 1306 if (m_provisionalDocumentLoader) {
1300 m_provisionalDocumentLoader->stopLoading(); 1307 m_provisionalDocumentLoader->stopLoading();
1301 if (m_provisionalDocumentLoader) 1308 detachDocumentLoader(m_provisionalDocumentLoader);
1302 m_provisionalDocumentLoader->detachFromFrame();
1303 m_provisionalDocumentLoader = nullptr;
1304 } 1309 }
1305 m_checkTimer.stop(); 1310 m_checkTimer.stop();
1306 1311
1307 // <rdar://problem/6250856> - In certain circumstances on pages with multipl e frames, stopAllLoaders() 1312 // <rdar://problem/6250856> - In certain circumstances on pages with multipl e frames, stopAllLoaders()
1308 // might detach the current FrameLoader, in which case we should bail on thi s newly defunct load. 1313 // might detach the current FrameLoader, in which case we should bail on thi s newly defunct load.
1309 if (!m_frame->page() || !m_policyDocumentLoader) 1314 if (!m_frame->page() || !m_policyDocumentLoader)
1310 return; 1315 return;
1311 1316
1312 InspectorInstrumentation::didStartProvisionalLoad(m_frame); 1317 InspectorInstrumentation::didStartProvisionalLoad(m_frame);
1313 1318
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 // FIXME: We need a way to propagate insecure requests policy flags to 1487 // FIXME: We need a way to propagate insecure requests policy flags to
1483 // out-of-process frames. For now, we'll always use default behavior. 1488 // out-of-process frames. For now, we'll always use default behavior.
1484 if (!parentFrame->isLocalFrame()) 1489 if (!parentFrame->isLocalFrame())
1485 return nullptr; 1490 return nullptr;
1486 1491
1487 ASSERT(toLocalFrame(parentFrame)->document()); 1492 ASSERT(toLocalFrame(parentFrame)->document());
1488 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1493 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1489 } 1494 }
1490 1495
1491 } // namespace blink 1496 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/FrameLoaderClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698