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

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

Issue 183793002: Make start/stop loading notifications per-frame (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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/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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool isBackForwardLoadType(FrameLoadType type) 98 bool isBackForwardLoadType(FrameLoadType type)
99 { 99 {
100 return type == FrameLoadTypeBackForward; 100 return type == FrameLoadTypeBackForward;
101 } 101 }
102 102
103 static bool needsHistoryItemRestore(FrameLoadType type) 103 static bool needsHistoryItemRestore(FrameLoadType type)
104 { 104 {
105 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload || ty pe == FrameLoadTypeReloadFromOrigin; 105 return type == FrameLoadTypeBackForward || type == FrameLoadTypeReload || ty pe == FrameLoadTypeReloadFromOrigin;
106 } 106 }
107 107
108 class FrameLoader::FrameProgressTracker {
109 public:
110 static PassOwnPtr<FrameProgressTracker> create(LocalFrame* frame) { return a doptPtr(new FrameProgressTracker(frame)); }
111 ~FrameProgressTracker()
112 {
113 ASSERT(!m_inProgress || m_frame->page());
114 if (m_inProgress)
115 m_frame->page()->progress().progressCompleted(m_frame);
116 }
117
118 void progressStarted()
119 {
120 ASSERT(m_frame->page());
121 if (!m_inProgress)
122 m_frame->page()->progress().progressStarted(m_frame);
123 m_inProgress = true;
124 }
125
126 void progressCompleted()
127 {
128 ASSERT(m_inProgress);
129 ASSERT(m_frame->page());
130 m_inProgress = false;
131 m_frame->page()->progress().progressCompleted(m_frame);
132 }
133
134 private:
135 FrameProgressTracker(LocalFrame* frame)
136 : m_frame(frame)
137 , m_inProgress(false)
138 {
139 }
140
141 LocalFrame* m_frame;
142 bool m_inProgress;
143 };
144
145 FrameLoader::FrameLoader(LocalFrame* frame, FrameLoaderClient* client) 108 FrameLoader::FrameLoader(LocalFrame* frame, FrameLoaderClient* client)
146 : m_frame(frame) 109 : m_frame(frame)
147 , m_client(client) 110 , m_client(client)
148 , m_mixedContentChecker(frame) 111 , m_mixedContentChecker(frame)
149 , m_progressTracker(FrameProgressTracker::create(m_frame)) 112 , m_progressTracker(ProgressTracker::create(frame))
150 , m_state(FrameStateProvisional) 113 , m_state(FrameStateProvisional)
151 , m_loadType(FrameLoadTypeStandard) 114 , m_loadType(FrameLoadTypeStandard)
152 , m_fetchContext(FrameFetchContext::create(frame)) 115 , m_fetchContext(FrameFetchContext::create(frame))
153 , m_inStopAllLoaders(false) 116 , m_inStopAllLoaders(false)
154 , m_isComplete(false) 117 , m_isComplete(false)
155 , m_checkTimer(this, &FrameLoader::checkTimerFired) 118 , m_checkTimer(this, &FrameLoader::checkTimerFired)
156 , m_shouldCallCheckCompleted(false) 119 , m_shouldCallCheckCompleted(false)
157 , m_didAccessInitialDocument(false) 120 , m_didAccessInitialDocument(false)
158 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 121 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
159 , m_forcedSandboxFlags(SandboxNone) 122 , m_forcedSandboxFlags(SandboxNone)
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, UpdateBackForwardListPolicy updateBackForwardList) 529 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, UpdateBackForwardListPolicy updateBackForwardList)
567 { 530 {
568 // Update the data source's request with the new URL to fake the URL change 531 // Update the data source's request with the new URL to fake the URL change
569 m_frame->document()->setURL(newURL); 532 m_frame->document()->setURL(newURL);
570 documentLoader()->updateForSameDocumentNavigation(newURL); 533 documentLoader()->updateForSameDocumentNavigation(newURL);
571 534
572 // Generate start and stop notifications only when loader is completed so th at we 535 // Generate start and stop notifications only when loader is completed so th at we
573 // don't fire them for fragment redirection that happens in window.onload ha ndler. 536 // don't fire them for fragment redirection that happens in window.onload ha ndler.
574 // See https://bugs.webkit.org/show_bug.cgi?id=31838 537 // See https://bugs.webkit.org/show_bug.cgi?id=31838
575 if (m_frame->document()->loadEventFinished()) 538 if (m_frame->document()->loadEventFinished())
576 m_client->postProgressStartedNotification(NavigationWithinSameDocument); 539 m_client->didStartLoading(NavigationWithinSameDocument);
577 540
578 HistoryCommitType historyCommitType = updateBackForwardList == UpdateBackFor wardList && m_currentItem ? StandardCommit : HistoryInertCommit; 541 HistoryCommitType historyCommitType = updateBackForwardList == UpdateBackFor wardList && m_currentItem ? StandardCommit : HistoryInertCommit;
579 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource == SameDocumentNavigationHistoryApi, data); 542 setHistoryItemStateForCommit(historyCommitType, sameDocumentNavigationSource == SameDocumentNavigationHistoryApi, data);
580 m_client->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe); 543 m_client->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy pe);
581 m_client->dispatchDidReceiveTitle(m_frame->document()->title()); 544 m_client->dispatchDidReceiveTitle(m_frame->document()->title());
582 if (m_frame->document()->loadEventFinished()) 545 if (m_frame->document()->loadEventFinished())
583 m_client->postProgressFinishedNotification(); 546 m_client->didStopLoading();
584 } 547 }
585 548
586 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, UpdateBackForwardListPolicy updateBackForwardList, ClientRe directPolicy clientRedirect) 549 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, UpdateBackForwardListPolicy updateBackForwardList, ClientRe directPolicy clientRedirect)
587 { 550 {
588 // If we have a state object, we cannot also be a new navigation. 551 // If we have a state object, we cannot also be a new navigation.
589 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList); 552 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList);
590 553
591 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 554 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
592 if (m_provisionalDocumentLoader) { 555 if (m_provisionalDocumentLoader) {
593 m_provisionalDocumentLoader->stopLoading(); 556 m_provisionalDocumentLoader->stopLoading();
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 page->mainFrame()->loader().checkLoadCompleteForThisFrame(); 1044 page->mainFrame()->loader().checkLoadCompleteForThisFrame();
1082 } 1045 }
1083 1046
1084 void FrameLoader::checkLoadComplete(DocumentLoader* documentLoader) 1047 void FrameLoader::checkLoadComplete(DocumentLoader* documentLoader)
1085 { 1048 {
1086 if (documentLoader) 1049 if (documentLoader)
1087 documentLoader->checkLoadComplete(); 1050 documentLoader->checkLoadComplete();
1088 checkLoadComplete(); 1051 checkLoadComplete();
1089 } 1052 }
1090 1053
1091 int FrameLoader::numPendingOrLoadingRequests(bool recurse) const
1092 {
1093 if (!recurse)
1094 return m_frame->document()->fetcher()->requestCount();
1095
1096 int count = 0;
1097 for (LocalFrame* frame = m_frame; frame; frame = frame->tree().traverseNext( m_frame))
1098 count += frame->document()->fetcher()->requestCount();
1099 return count;
1100 }
1101
1102 String FrameLoader::userAgent(const KURL& url) const 1054 String FrameLoader::userAgent(const KURL& url) const
1103 { 1055 {
1104 String userAgent = m_client->userAgent(url); 1056 String userAgent = m_client->userAgent(url);
1105 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); 1057 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
1106 return userAgent; 1058 return userAgent;
1107 } 1059 }
1108 1060
1109 void FrameLoader::frameDetached() 1061 void FrameLoader::frameDetached()
1110 { 1062 {
1111 // stopAllLoaders can detach the LocalFrame, so protect it. 1063 // stopAllLoaders can detach the LocalFrame, so protect it.
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 { 1425 {
1474 SandboxFlags flags = m_forcedSandboxFlags; 1426 SandboxFlags flags = m_forcedSandboxFlags;
1475 if (LocalFrame* parentFrame = m_frame->tree().parent()) 1427 if (LocalFrame* parentFrame = m_frame->tree().parent())
1476 flags |= parentFrame->document()->sandboxFlags(); 1428 flags |= parentFrame->document()->sandboxFlags();
1477 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1429 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1478 flags |= ownerElement->sandboxFlags(); 1430 flags |= ownerElement->sandboxFlags();
1479 return flags; 1431 return flags;
1480 } 1432 }
1481 1433
1482 } // namespace WebCore 1434 } // namespace WebCore
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