void HistoryController::updateForReload() { #if !LOG_DISABLED if (m_frame->loader()->documentLoader()) LOG(History, "WebCoreHistory: Updating History for reload in frame %s", m_frame->loader()->documentLoader()->title().utf8().data()); #endif if (m_currentItem) { pageCache()->remove(m_currentItem.get()); if (m_frame->loader()->loadType() == FrameLoadTypeReload || m_frame->loader()->loadType() == FrameLoadTypeReloadFromOrigin) saveScrollPositionAndViewStateToItem(m_currentItem.get()); // Sometimes loading a page again leads to a different result because of cookies. Bugzilla 4072 if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty()) m_currentItem->setURL(m_frame->loader()->documentLoader()->requestURL()); } }
void WebProcess::platformSetCacheModel(CacheModel cacheModel) { #if USE(CFNETWORK) RetainPtr<CFStringRef> cfurlCacheDirectory; if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession()) cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(defaultStorageSession)); else cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(0)); if (!cfurlCacheDirectory) cfurlCacheDirectory = WebCore::localUserSpecificStorageDirectory().createCFString(); // As a fudge factor, use 1000 instead of 1024, in case the reported byte // count doesn't align exactly to a megabyte boundary. uint64_t memSize = memorySize() / 1024 / 1000; uint64_t diskFreeSize = volumeFreeSize(cfurlCacheDirectory.get()) / 1024 / 1000; unsigned cacheTotalCapacity = 0; unsigned cacheMinDeadCapacity = 0; unsigned cacheMaxDeadCapacity = 0; double deadDecodedDataDeletionInterval = 0; unsigned pageCacheCapacity = 0; unsigned long urlCacheMemoryCapacity = 0; unsigned long urlCacheDiskCapacity = 0; calculateCacheSizes(cacheModel, memSize, diskFreeSize, cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity); memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); pageCache()->setCapacity(pageCacheCapacity); RetainPtr<CFURLCacheRef> cfurlCache; if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession()) cfurlCache.adoptCF(wkCopyURLCache(defaultStorageSession)); else cfurlCache.adoptCF(CFURLCacheCopySharedURLCache()); CFURLCacheSetMemoryCapacity(cfurlCache.get(), urlCacheMemoryCapacity); CFURLCacheSetDiskCapacity(cfurlCache.get(), max<unsigned long>(urlCacheDiskCapacity, CFURLCacheDiskCapacity(cfurlCache.get()))); // Don't shrink a big disk cache, since that would cause churn. #endif }
void BackForwardList::setCapacity(int size) { while (size < (int)m_entries.size()) { RefPtr<HistoryItem> item = m_entries.last(); m_entries.removeLast(); m_entryHash.remove(item); pageCache()->remove(item.get()); } if (!size) m_current = NoCurrentItemIndex; #ifdef ANDROID_HISTORY_CLIENT else if (m_current > m_entries.size() - 1) { m_current = m_entries.size() - 1; m_page->mainFrame()->loader()->client()->dispatchDidChangeHistoryIndex(this); } #else else if (m_current > m_entries.size() - 1) m_current = m_entries.size() - 1; #endif m_capacity = size; }
void PageGroup::removeAllVisitedLinks() { Page::removeAllVisitedLinks(); pageCache()->markPagesForVistedLinkStyleRecalc(); }
void HistoryItem::setURL(const KURL& url) { pageCache()->remove(this); setURLString(url.string()); clearDocumentState(); }
void PageGroup::captionPreferencesChanged() { for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it) (*it)->captionPreferencesChanged(); pageCache()->markPagesForCaptionPreferencesChanged(); }
CachedFrame::CachedFrame(Frame& frame) : CachedFrameBase(frame) { #ifndef NDEBUG cachedFrameCounter.increment(); #endif ASSERT(m_document); ASSERT(m_documentLoader); ASSERT(m_view); if (frame.page()->focusController().focusedFrame() == &frame) frame.page()->focusController().setFocusedFrame(&frame.mainFrame()); // Custom scrollbar renderers will get reattached when the document comes out of the page cache m_view->detachCustomScrollbars(); m_document->setInPageCache(true); frame.loader().stopLoading(UnloadEventPolicyUnloadAndPageHide); // Create the CachedFrames for all Frames in the FrameTree. for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling()) m_childFrames.append(std::make_unique<CachedFrame>(*child)); // Active DOM objects must be suspended before we cache the frame script data, // but after we've fired the pagehide event, in case that creates more objects. // Suspending must also happen after we've recursed over child frames, in case // those create more objects. m_document->documentWillSuspendForPageCache(); m_document->suspendScriptedAnimationControllerCallbacks(); m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive); m_cachedFrameScriptData = std::make_unique<ScriptCachedFrameData>(frame); m_document->domWindow()->suspendForPageCache(); frame.loader().client().savePlatformDataToCachedFrame(this); #if USE(ACCELERATED_COMPOSITING) if (m_isComposited && pageCache()->shouldClearBackingStores()) frame.view()->clearBackingStores(); #endif // documentWillSuspendForPageCache() can set up a layout timer on the FrameView, so clear timers after that. frame.clearTimers(); // Deconstruct the FrameTree, to restore it later. // We do this for two reasons: // 1 - We reuse the main frame, so when it navigates to a new page load it needs to start with a blank FrameTree. // 2 - It's much easier to destroy a CachedFrame while it resides in the PageCache if it is disconnected from its parent. for (unsigned i = 0; i < m_childFrames.size(); ++i) frame.tree().removeChild(&m_childFrames[i]->view()->frame()); if (!m_isMainFrame) frame.page()->decrementSubframeCount(); frame.loader().client().didSaveToPageCache(); #ifndef NDEBUG if (m_isMainFrame) LOG(PageCache, "Finished creating CachedFrame for main frame url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get()); else LOG(PageCache, "Finished creating CachedFrame for child frame with url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get()); #endif #if PLATFORM(IOS) if (m_isMainFrame) { if (DOMWindow* domWindow = m_document->domWindow()) { if (domWindow->scrollEventListenerCount() && frame.page()) frame.page()->chrome().client().setNeedsScrollNotifications(&frame, false); } } #endif }
void PageGroup::captionPreferencesChanged() { for (HashSet<Page*>::iterator i = m_pages.begin(); i != m_pages.end(); ++i) (*i)->captionPreferencesChanged(); pageCache()->markPagesForCaptionPreferencesChanged(); }
void WebProcess::releasePageCache() { int savedPageCacheCapacity = pageCache()->capacity(); pageCache()->setCapacity(0); pageCache()->setCapacity(savedPageCacheCapacity); }
CachedFrame::CachedFrame(Frame* frame) : CachedFrameBase(frame) { #ifndef NDEBUG cachedFrameCounter().increment(); #endif ASSERT(m_document); ASSERT(m_documentLoader); ASSERT(m_view); if (frame->page()->focusController()->focusedFrame() == frame) frame->page()->focusController()->setFocusedFrame(frame->page()->mainFrame()); // Custom scrollbar renderers will get reattached when the document comes out of the page cache m_view->detachCustomScrollbars(); m_document->documentWillBecomeInactive(); frame->clearTimers(); m_document->setInPageCache(true); frame->loader()->stopLoading(UnloadEventPolicyUnloadAndPageHide); // Create the CachedFrames for all Frames in the FrameTree. for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) m_childFrames.append(CachedFrame::create(child)); // Active DOM objects must be suspended before we cache the frame script data, // but after we've fired the pagehide event, in case that creates more objects. // Suspending must also happen after we've recursed over child frames, in case // those create more objects. // FIXME: It's still possible to have objects created after suspending in some cases, see http://webkit.org/b/53733 for more details. m_document->suspendScriptedAnimationControllerCallbacks(); m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive); m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame)); frame->loader()->client()->savePlatformDataToCachedFrame(this); #if USE(ACCELERATED_COMPOSITING) if (m_isComposited && pageCache()->shouldClearBackingStores()) frame->view()->clearBackingStores(); #endif // Deconstruct the FrameTree, to restore it later. // We do this for two reasons: // 1 - We reuse the main frame, so when it navigates to a new page load it needs to start with a blank FrameTree. // 2 - It's much easier to destroy a CachedFrame while it resides in the PageCache if it is disconnected from its parent. for (unsigned i = 0; i < m_childFrames.size(); ++i) frame->tree()->removeChild(m_childFrames[i]->view()->frame()); if (!m_isMainFrame) frame->page()->decrementFrameCount(); frame->loader()->client()->didSaveToPageCache(); #ifndef NDEBUG if (m_isMainFrame) LOG(PageCache, "Finished creating CachedFrame for main frame url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get()); else LOG(PageCache, "Finished creating CachedFrame for child frame with url '%s' and DocumentLoader %p\n", m_url.string().utf8().data(), m_documentLoader.get()); #endif }
inline void PageGroup::addVisitedLink(LinkHash hash) { ASSERT(shouldTrackVisitedLinks); Page::visitedStateChanged(this, hash); pageCache()->markPagesForVistedLinkStyleRecalc(); }