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

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

Issue 123133006: Expose a cachePolicy parameter to loadHistoryItem. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
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 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 HistoryItem* HistoryEntry::itemForFrame(Frame* frame) 112 HistoryItem* HistoryEntry::itemForFrame(Frame* frame)
113 { 113 {
114 if (HistoryNode* historyNode = historyNodeForFrame(frame)) 114 if (HistoryNode* historyNode = historyNodeForFrame(frame))
115 return historyNode->value(); 115 return historyNode->value();
116 return 0; 116 return 0;
117 } 117 }
118 118
119 HistoryController::HistoryController(Page* page) 119 HistoryController::HistoryController(Page* page)
120 : m_page(page) 120 : m_page(page)
121 , m_defersLoading(false) 121 , m_defersLoading(false)
122 , m_deferredCachePolicy(UseProtocolCachePolicy)
122 { 123 {
123 } 124 }
124 125
125 HistoryController::~HistoryController() 126 HistoryController::~HistoryController()
126 { 127 {
127 } 128 }
128 129
129 void HistoryController::updateBackForwardListForFragmentScroll(Frame* frame, His toryItem* item) 130 void HistoryController::updateBackForwardListForFragmentScroll(Frame* frame, His toryItem* item)
130 { 131 {
131 m_provisionalEntry.clear(); 132 m_provisionalEntry.clear();
132 createNewBackForwardItem(frame, item, false); 133 createNewBackForwardItem(frame, item, false);
133 } 134 }
134 135
135 void HistoryController::goToEntry(PassOwnPtr<HistoryEntry> targetEntry) 136 void HistoryController::goToEntry(PassOwnPtr<HistoryEntry> targetEntry, Resource RequestCachePolicy cachePolicy)
136 { 137 {
137 ASSERT(m_sameDocumentLoadsInProgress.isEmpty()); 138 ASSERT(m_sameDocumentLoadsInProgress.isEmpty());
138 ASSERT(m_differentDocumentLoadsInProgress.isEmpty()); 139 ASSERT(m_differentDocumentLoadsInProgress.isEmpty());
139 140
140 m_provisionalEntry = targetEntry; 141 m_provisionalEntry = targetEntry;
141 recursiveGoToEntry(m_page->mainFrame()); 142 recursiveGoToEntry(m_page->mainFrame());
142 143
143 if (m_sameDocumentLoadsInProgress.isEmpty() && m_differentDocumentLoadsInPro gress.isEmpty()) 144 if (m_sameDocumentLoadsInProgress.isEmpty() && m_differentDocumentLoadsInPro gress.isEmpty())
144 m_sameDocumentLoadsInProgress.set(m_page->mainFrame(), m_provisionalEntr y->root()); 145 m_sameDocumentLoadsInProgress.set(m_page->mainFrame(), m_provisionalEntr y->root());
145 146
146 if (m_differentDocumentLoadsInProgress.isEmpty()) { 147 if (m_differentDocumentLoadsInProgress.isEmpty()) {
147 m_previousEntry = m_currentEntry.release(); 148 m_previousEntry = m_currentEntry.release();
148 m_currentEntry = m_provisionalEntry.release(); 149 m_currentEntry = m_provisionalEntry.release();
149 } 150 }
150 151
151 for (HistoryFrameLoadSet::iterator it = m_sameDocumentLoadsInProgress.begin( ); it != m_sameDocumentLoadsInProgress.end(); ++it) 152 for (HistoryFrameLoadSet::iterator it = m_sameDocumentLoadsInProgress.begin( ); it != m_sameDocumentLoadsInProgress.end(); ++it)
152 it->key->loader().loadHistoryItem(it->value, HistorySameDocumentLoad); 153 it->key->loader().loadHistoryItem(it->value, HistorySameDocumentLoad, ca chePolicy);
153 for (HistoryFrameLoadSet::iterator it = m_differentDocumentLoadsInProgress.b egin(); it != m_differentDocumentLoadsInProgress.end(); ++it) 154 for (HistoryFrameLoadSet::iterator it = m_differentDocumentLoadsInProgress.b egin(); it != m_differentDocumentLoadsInProgress.end(); ++it)
154 it->key->loader().loadHistoryItem(it->value, HistoryDifferentDocumentLoa d); 155 it->key->loader().loadHistoryItem(it->value, HistoryDifferentDocumentLoa d, cachePolicy);
155 m_sameDocumentLoadsInProgress.clear(); 156 m_sameDocumentLoadsInProgress.clear();
156 m_differentDocumentLoadsInProgress.clear(); 157 m_differentDocumentLoadsInProgress.clear();
157 } 158 }
158 159
159 void HistoryController::recursiveGoToEntry(Frame* frame) 160 void HistoryController::recursiveGoToEntry(Frame* frame)
160 { 161 {
161 HistoryItem* newItem = m_provisionalEntry->itemForFrame(frame); 162 HistoryItem* newItem = m_provisionalEntry->itemForFrame(frame);
162 HistoryItem* oldItem = m_currentEntry ? m_currentEntry->itemForFrame(frame) : 0; 163 HistoryItem* oldItem = m_currentEntry ? m_currentEntry->itemForFrame(frame) : 0;
163 if (!newItem) 164 if (!newItem)
164 return; 165 return;
165 166
166 if (!oldItem || (newItem != oldItem && newItem->itemSequenceNumber() != oldI tem->itemSequenceNumber())) { 167 if (!oldItem || (newItem != oldItem && newItem->itemSequenceNumber() != oldI tem->itemSequenceNumber())) {
167 if (oldItem && newItem->documentSequenceNumber() == oldItem->documentSeq uenceNumber()) 168 if (oldItem && newItem->documentSequenceNumber() == oldItem->documentSeq uenceNumber())
168 m_sameDocumentLoadsInProgress.set(frame, newItem); 169 m_sameDocumentLoadsInProgress.set(frame, newItem);
169 else 170 else
170 m_differentDocumentLoadsInProgress.set(frame, newItem); 171 m_differentDocumentLoadsInProgress.set(frame, newItem);
171 return; 172 return;
172 } 173 }
173 174
174 for (Frame* child = frame->tree().firstChild(); child; child = child->tree() .nextSibling()) 175 for (Frame* child = frame->tree().firstChild(); child; child = child->tree() .nextSibling())
175 recursiveGoToEntry(child); 176 recursiveGoToEntry(child);
176 } 177 }
177 178
178 void HistoryController::goToItem(HistoryItem* targetItem) 179 void HistoryController::goToItem(HistoryItem* targetItem, ResourceRequestCachePo licy cachePolicy)
179 { 180 {
180 if (m_defersLoading) { 181 if (m_defersLoading) {
181 m_deferredItem = targetItem; 182 m_deferredItem = targetItem;
183 m_deferredCachePolicy = cachePolicy;
182 return; 184 return;
183 } 185 }
184 186
185 OwnPtr<HistoryEntry> newEntry = HistoryEntry::create(targetItem); 187 OwnPtr<HistoryEntry> newEntry = HistoryEntry::create(targetItem);
186 Deque<HistoryNode*> historyNodes; 188 Deque<HistoryNode*> historyNodes;
187 historyNodes.append(newEntry->rootHistoryNode()); 189 historyNodes.append(newEntry->rootHistoryNode());
188 while (!historyNodes.isEmpty()) { 190 while (!historyNodes.isEmpty()) {
189 // For each item, read the children (if any) off the HistoryItem, 191 // For each item, read the children (if any) off the HistoryItem,
190 // create a new HistoryNode for each child and attach it, 192 // create a new HistoryNode for each child and attach it,
191 // then clear the children on the HistoryItem. 193 // then clear the children on the HistoryItem.
192 HistoryNode* historyNode = historyNodes.takeFirst(); 194 HistoryNode* historyNode = historyNodes.takeFirst();
193 const HistoryItemVector& children = historyNode->value()->children(); 195 const HistoryItemVector& children = historyNode->value()->children();
194 for (size_t i = 0; i < children.size(); i++) { 196 for (size_t i = 0; i < children.size(); i++) {
195 HistoryNode* childHistoryNode = historyNode->addChild(children[i].ge t()); 197 HistoryNode* childHistoryNode = historyNode->addChild(children[i].ge t());
196 historyNodes.append(childHistoryNode); 198 historyNodes.append(childHistoryNode);
197 } 199 }
198 historyNode->value()->clearChildren(); 200 historyNode->value()->clearChildren();
199 } 201 }
200 goToEntry(newEntry.release()); 202 goToEntry(newEntry.release(), cachePolicy);
201 } 203 }
202 204
203 void HistoryController::setDefersLoading(bool defer) 205 void HistoryController::setDefersLoading(bool defer)
204 { 206 {
205 m_defersLoading = defer; 207 m_defersLoading = defer;
206 if (!defer && m_deferredItem) { 208 if (!defer && m_deferredItem) {
207 goToItem(m_deferredItem.get()); 209 goToItem(m_deferredItem.get(), m_deferredCachePolicy);
208 m_deferredItem = 0; 210 m_deferredItem = 0;
211 m_deferredCachePolicy = UseProtocolCachePolicy;
209 } 212 }
210 } 213 }
211 214
212 void HistoryController::updateForInitialLoadInChildFrame(Frame* frame, HistoryIt em* item) 215 void HistoryController::updateForInitialLoadInChildFrame(Frame* frame, HistoryIt em* item)
213 { 216 {
214 ASSERT(frame->tree().parent()); 217 ASSERT(frame->tree().parent());
215 if (!m_currentEntry || m_currentEntry->historyNodeForFrame(frame)) 218 if (!m_currentEntry || m_currentEntry->historyNodeForFrame(frame))
216 return; 219 return;
217 if (HistoryNode* parentHistoryNode = m_currentEntry->historyNodeForFrame(fra me->tree().parent())) 220 if (HistoryNode* parentHistoryNode = m_currentEntry->historyNodeForFrame(fra me->tree().parent()))
218 parentHistoryNode->addChild(item); 221 parentHistoryNode->addChild(item);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } else { 289 } else {
287 HistoryItem* oldItem = m_currentEntry->itemForFrame(targetFrame); 290 HistoryItem* oldItem = m_currentEntry->itemForFrame(targetFrame);
288 if (!clipAtTarget && oldItem) 291 if (!clipAtTarget && oldItem)
289 newItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber() ); 292 newItem->setDocumentSequenceNumber(oldItem->documentSequenceNumber() );
290 m_previousEntry = m_currentEntry.release(); 293 m_previousEntry = m_currentEntry.release();
291 m_currentEntry = m_previousEntry->cloneAndReplace(newItem.get(), clipAtT arget, targetFrame, m_page); 294 m_currentEntry = m_previousEntry->cloneAndReplace(newItem.get(), clipAtT arget, targetFrame, m_page);
292 } 295 }
293 } 296 }
294 297
295 } // namespace WebCore 298 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698