Changeset 179347 in webkit
- Timestamp:
- Jan 29, 2015, 10:38:51 AM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r179344 r179347 1 2015-01-29 Chris Dumez <cdumez@apple.com> 2 3 Clean up / modernize PageCache class 4 https://bugs.webkit.org/show_bug.cgi?id=141009 5 6 Reviewed by Darin Adler. 7 8 Clean up / modernize PageCache class: 9 - Use more references instead of pointers 10 - Use a ListHashSet<Ref<HistoryItem>> internally instead of a linked 11 list of HistoryItem*. This avoids having the ref/unref HistoryItems 12 manually and maintaining the list size separately. It also simplifies 13 the code dealing with the container and makes looking up HistoryItems 14 faster as a bonus. Similarly to the previous implementation, we are 15 adding elements to one end and removing from the opposite end when 16 pruning to drop old history items first. Note that even though the 17 previous implementation was called LRUList, it did not move items to 18 the front when accessed. The new implementation doesn't either. 19 - Rename "capacity" to "maxSize" to avoid confusing with containers' 20 capacity (which doesn't limit the size of the container). 21 - Use unsigned instead of int for all values that are supposed to be 22 positive. 23 - Do not explicitely define the default constructor and let the 24 compiler generate it for us (and use in-class initialization for 25 members) 26 - Fix indentation in the header. 27 1 28 2015-01-29 Julien Isorce <j.isorce@samsung.com> 2 29 -
trunk/Source/WebCore/WebCore.exp.in
r179293 r179347 1240 1240 __ZN7WebCore4Page36suspendActiveDOMObjectsAndAnimationsEv 1241 1241 __ZN7WebCore4Page37setInLowQualityImageInterpolationModeEb 1242 __ZN7WebCore4Page8goToItemE PNS_11HistoryItemENS_13FrameLoadTypeE1242 __ZN7WebCore4Page8goToItemERNS_11HistoryItemENS_13FrameLoadTypeE 1243 1243 __ZN7WebCore4Page8setMutedEb 1244 1244 __ZN7WebCore4Page9initGroupEv … … 1607 1607 __ZN7WebCore9LayerPoolC1Ev 1608 1608 __ZN7WebCore9LayerPoolD1Ev 1609 __ZN7WebCore9PageCache1 1setCapacityEi1610 __ZN7WebCore9PageCache1 8pruneToCapacityNowEiNS_13PruningReasonE1609 __ZN7WebCore9PageCache10setMaxSizeEj 1610 __ZN7WebCore9PageCache14pruneToSizeNowEjNS_13PruningReasonE 1611 1611 __ZN7WebCore9PageCache34markPagesForVisitedLinkStyleRecalcEv 1612 __ZN7WebCore9PageCache6removeE PNS_11HistoryItemE1612 __ZN7WebCore9PageCache6removeERNS_11HistoryItemE 1613 1613 __ZN7WebCore9PageCache6sharedEv 1614 1614 __ZN7WebCore9PageGroup9pageGroupERKN3WTF6StringE -
trunk/Source/WebCore/history/BackForwardController.cpp
r170134 r179347 75 75 return; 76 76 77 m_page.goToItem( item, FrameLoadType::IndexedBackForward);77 m_page.goToItem(*item, FrameLoadType::IndexedBackForward); 78 78 } 79 79 … … 84 84 return false; 85 85 86 m_page.goToItem( item, FrameLoadType::Back);86 m_page.goToItem(*item, FrameLoadType::Back); 87 87 return true; 88 88 } … … 94 94 return false; 95 95 96 m_page.goToItem( item, FrameLoadType::Forward);96 m_page.goToItem(*item, FrameLoadType::Forward); 97 97 return true; 98 98 } -
trunk/Source/WebCore/history/BackForwardList.cpp
r179247 r179347 69 69 m_entries.removeLast(); 70 70 m_entryHash.remove(item); 71 PageCache::shared().remove( item.get());71 PageCache::shared().remove(*item); 72 72 } 73 73 } … … 79 79 m_entries.remove(0); 80 80 m_entryHash.remove(item); 81 PageCache::shared().remove( item.get());81 PageCache::shared().remove(*item); 82 82 m_current--; 83 83 } … … 176 176 m_entries.removeLast(); 177 177 m_entryHash.remove(item); 178 PageCache::shared().remove( item.get());178 PageCache::shared().remove(*item); 179 179 } 180 180 … … 243 243 { 244 244 bool didRemoveAtLeastOneItem = false; 245 unsigned length = m_entries.size(); 246 for (unsigned i = 0; i < length; ++i) { 247 HistoryItem* item = m_entries[i].get(); 245 for (auto& item : m_entries) { 248 246 if (item->isInPageCache()) { 249 247 didRemoveAtLeastOneItem = true; 250 PageCache::shared().remove( item);248 PageCache::shared().remove(*item); 251 249 } 252 250 } … … 257 255 void BackForwardList::close() 258 256 { 259 int size = m_entries.size(); 260 for (int i = 0; i < size; ++i) 261 PageCache::shared().remove(m_entries[i].get()); 257 for (auto& item : m_entries) 258 PageCache::shared().remove(*item); 262 259 m_entries.clear(); 263 260 m_entryHash.clear(); 264 m_page = 0;261 m_page = nullptr; 265 262 m_closed = true; 266 263 } -
trunk/Source/WebCore/history/HistoryItem.cpp
r179247 r179347 287 287 void HistoryItem::setURL(const URL& url) 288 288 { 289 PageCache::shared().remove( this);289 PageCache::shared().remove(*this); 290 290 setURLString(url.string()); 291 291 clearDocumentState(); -
trunk/Source/WebCore/history/PageCache.cpp
r179263 r179347 1 1 /* 2 * Copyright (C) 2007, 2014 Apple Inc.All rights reserved.2 * Copyright (C) 2007, 2014, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 44 44 #include "FrameView.h" 45 45 #include "HistoryController.h" 46 #include "HistoryItem.h"47 46 #include "Logging.h" 48 47 #include "MainFrame.h" … … 111 110 } 112 111 113 static unsigned logCanCacheFrameDecision(Frame& frame, DiagnosticLoggingClient& diagnosticLoggingClient, intindentLevel)112 static unsigned logCanCacheFrameDecision(Frame& frame, DiagnosticLoggingClient& diagnosticLoggingClient, unsigned indentLevel) 114 113 { 115 114 PCLOG("+---"); … … 235 234 return; 236 235 237 int indentLevel = 0;236 unsigned indentLevel = 0; 238 237 PCLOG("--------\n Determining if page can be cached:"); 239 238 … … 298 297 return globalPageCache; 299 298 } 300 301 PageCache::PageCache() 302 : m_capacity(0) 303 , m_size(0) 304 , m_head(0) 305 , m_tail(0) 306 , m_shouldClearBackingStores(false) 307 { 308 } 309 310 bool PageCache::canCachePageContainingThisFrame(Frame* frame) 311 { 312 for (Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling()) { 313 if (!canCachePageContainingThisFrame(child)) 299 300 bool PageCache::canCachePageContainingThisFrame(Frame& frame) 301 { 302 for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling()) { 303 if (!canCachePageContainingThisFrame(*child)) 314 304 return false; 315 305 } 316 306 317 FrameLoader& frameLoader = frame ->loader();307 FrameLoader& frameLoader = frame.loader(); 318 308 DocumentLoader* documentLoader = frameLoader.documentLoader(); 319 Document* document = frame ->document();309 Document* document = frame.document(); 320 310 321 311 return documentLoader … … 327 317 // Do not cache error pages (these can be recognized as pages with substitute data or unreachable URLs). 328 318 && !(documentLoader->substituteData().isValid() && !documentLoader->substituteData().failingURL().isEmpty()) 329 && (!frameLoader.subframeLoader().containsPlugins() || frame ->page()->settings().pageCacheSupportsPlugins())330 && !(frame ->isMainFrame() && document->url().protocolIs("https") && documentLoader->response().cacheControlContainsNoStore())319 && (!frameLoader.subframeLoader().containsPlugins() || frame.page()->settings().pageCacheSupportsPlugins()) 320 && !(frame.isMainFrame() && document->url().protocolIs("https") && documentLoader->response().cacheControlContainsNoStore()) 331 321 && !DatabaseManager::manager().hasOpenDatabases(document) 332 322 && frameLoader.history().currentItem() … … 358 348 FrameLoadType loadType = page->mainFrame().loader().loadType(); 359 349 360 return m_ capacity> 0361 && canCachePageContainingThisFrame( &page->mainFrame())350 return m_maxSize > 0 351 && canCachePageContainingThisFrame(page->mainFrame()) 362 352 && page->settings().usesPageCache() 363 353 #if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS) … … 374 364 } 375 365 376 void PageCache::pruneTo CapacityNow(int capacity, PruningReason pruningReason)377 { 378 TemporaryChange< int>(m_capacity, std::max(capacity, 0));366 void PageCache::pruneToSizeNow(unsigned size, PruningReason pruningReason) 367 { 368 TemporaryChange<unsigned>(m_maxSize, size); 379 369 prune(pruningReason); 380 370 } 381 371 382 void PageCache::setCapacity(int capacity) 383 { 384 ASSERT(capacity >= 0); 385 m_capacity = std::max(capacity, 0); 386 372 void PageCache::setMaxSize(unsigned maxSize) 373 { 374 m_maxSize = maxSize; 387 375 prune(PruningReason::None); 388 376 } 389 377 390 int PageCache::frameCount() const 391 { 392 int frameCount = 0; 393 for (HistoryItem* current = m_head; current; current = current->m_next) { 394 ++frameCount; 395 ASSERT(current->m_cachedPage); 396 frameCount += current->m_cachedPage->cachedMainFrame()->descendantFrameCount(); 378 unsigned PageCache::frameCount() const 379 { 380 unsigned frameCount = m_items.size(); 381 for (auto& item : m_items) { 382 ASSERT(item->m_cachedPage); 383 frameCount += item->m_cachedPage->cachedMainFrame()->descendantFrameCount(); 397 384 } 398 385 … … 402 389 void PageCache::markPagesForVisitedLinkStyleRecalc() 403 390 { 404 for ( HistoryItem* current = m_head; current; current = current->m_next) {405 ASSERT( current->m_cachedPage);406 current->m_cachedPage->markForVisitedLinkStyleRecalc();407 } 408 } 409 410 void PageCache::markPagesForFullStyleRecalc(Page *page)411 { 412 for ( HistoryItem* current = m_head; current; current = current->m_next) {413 CachedPage& cachedPage = * current->m_cachedPage;414 if (&page ->mainFrame() == &cachedPage.cachedMainFrame()->view()->frame())391 for (auto& item : m_items) { 392 ASSERT(item->m_cachedPage); 393 item->m_cachedPage->markForVisitedLinkStyleRecalc(); 394 } 395 } 396 397 void PageCache::markPagesForFullStyleRecalc(Page& page) 398 { 399 for (auto& item : m_items) { 400 CachedPage& cachedPage = *item->m_cachedPage; 401 if (&page.mainFrame() == &cachedPage.cachedMainFrame()->view()->frame()) 415 402 cachedPage.markForFullStyleRecalc(); 416 403 } 417 404 } 418 405 419 void PageCache::markPagesForDeviceScaleChanged(Page *page)420 { 421 for ( HistoryItem* current = m_head; current; current = current->m_next) {422 CachedPage& cachedPage = * current->m_cachedPage;423 if (&page ->mainFrame() == &cachedPage.cachedMainFrame()->view()->frame())406 void PageCache::markPagesForDeviceScaleChanged(Page& page) 407 { 408 for (auto& item : m_items) { 409 CachedPage& cachedPage = *item->m_cachedPage; 410 if (&page.mainFrame() == &cachedPage.cachedMainFrame()->view()->frame()) 424 411 cachedPage.markForDeviceScaleChanged(); 425 412 } … … 429 416 void PageCache::markPagesForCaptionPreferencesChanged() 430 417 { 431 for ( HistoryItem* current = m_head; current; current = current->m_next) {432 ASSERT( current->m_cachedPage);433 current->m_cachedPage->markForCaptionPreferencesChanged();418 for (auto& item : m_items) { 419 ASSERT(item->m_cachedPage); 420 item->m_cachedPage->markForCaptionPreferencesChanged(); 434 421 } 435 422 } … … 443 430 case PruningReason::ProcessSuspended: 444 431 return DiagnosticLoggingKeys::prunedDueToProcessSuspended(); 445 case PruningReason::Reached Capacity:446 return DiagnosticLoggingKeys::prunedDueTo CapacityReached();432 case PruningReason::ReachedMaxSize: 433 return DiagnosticLoggingKeys::prunedDueToMaxSizeReached(); 447 434 case PruningReason::None: 448 435 break; … … 452 439 } 453 440 454 void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page& page) 455 { 456 ASSERT(prpItem); 441 void PageCache::add(HistoryItem& item, Page& page) 442 { 457 443 ASSERT(canCache(&page)); 458 459 HistoryItem* item = prpItem.leakRef(); // Balanced in remove().460 444 461 445 // Remove stale cache entry if necessary. 462 if (item->m_cachedPage)463 remove(item); 464 465 item ->m_cachedPage = std::make_unique<CachedPage>(page);466 item->m_pruningReason = PruningReason::None;467 addToLRUList(item);468 ++m_size;469 470 prune(PruningReason::ReachedCapacity); 471 } 472 473 std::unique_ptr<CachedPage> PageCache::take(HistoryItem* item, Page* page) 474 { 475 if (!item)446 remove(item); 447 448 item.m_cachedPage = std::make_unique<CachedPage>(page); 449 item.m_pruningReason = PruningReason::None; 450 m_items.add(&item); 451 452 prune(PruningReason::ReachedMaxSize); 453 } 454 455 std::unique_ptr<CachedPage> PageCache::take(HistoryItem& item, Page* page) 456 { 457 if (!item.m_cachedPage) { 458 if (item.m_pruningReason != PruningReason::None) 459 logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item.m_pruningReason)); 476 460 return nullptr; 477 478 std::unique_ptr<CachedPage> cachedPage = WTF::move(item->m_cachedPage); 479 480 removeFromLRUList(item); 481 --m_size; 482 483 item->deref(); // Balanced in add(). 484 485 if (!cachedPage) { 486 if (item->m_pruningReason != PruningReason::None) 487 logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item->m_pruningReason)); 488 return nullptr; 489 } 461 } 462 463 std::unique_ptr<CachedPage> cachedPage = WTF::move(item.m_cachedPage); 464 m_items.remove(&item); 490 465 491 466 if (cachedPage->hasExpired()) { 492 LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item ->url().string().ascii().data());467 LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item.url().string().ascii().data()); 493 468 logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey()); 494 469 return nullptr; … … 498 473 } 499 474 500 CachedPage* PageCache::get(HistoryItem* item, Page* page) 501 { 502 if (!item) 475 CachedPage* PageCache::get(HistoryItem& item, Page* page) const 476 { 477 CachedPage* cachedPage = item.m_cachedPage.get(); 478 if (!cachedPage) { 479 if (item.m_pruningReason != PruningReason::None) 480 logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item.m_pruningReason)); 503 481 return nullptr; 504 505 if (CachedPage* cachedPage = item->m_cachedPage.get()) { 506 if (!cachedPage->hasExpired()) 507 return cachedPage; 508 509 LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item->url().string().ascii().data()); 482 } 483 484 if (cachedPage->hasExpired()) { 485 LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item.url().string().ascii().data()); 510 486 logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey()); 511 487 PageCache::shared().remove(item); 512 } else if (item->m_pruningReason != PruningReason::None) 513 logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item->m_pruningReason)); 514 515 return nullptr; 516 } 517 518 void PageCache::remove(HistoryItem* item) 488 return nullptr; 489 } 490 return cachedPage; 491 } 492 493 void PageCache::remove(HistoryItem& item) 519 494 { 520 495 // Safely ignore attempts to remove items not in the cache. 521 if (!item || !item->m_cachedPage)496 if (!item.m_cachedPage) 522 497 return; 523 498 524 item->m_cachedPage = nullptr; 525 removeFromLRUList(item); 526 --m_size; 527 528 item->deref(); // Balanced in add(). 499 item.m_cachedPage = nullptr; 500 m_items.remove(&item); 529 501 } 530 502 531 503 void PageCache::prune(PruningReason pruningReason) 532 504 { 533 while (m_size > m_capacity) { 534 ASSERT(m_tail && m_tail->m_cachedPage); 535 m_tail->m_pruningReason = pruningReason; 536 remove(m_tail); 537 } 538 } 539 540 void PageCache::addToLRUList(HistoryItem* item) 541 { 542 item->m_next = m_head; 543 item->m_prev = 0; 544 545 if (m_head) { 546 ASSERT(m_tail); 547 m_head->m_prev = item; 548 } else { 549 ASSERT(!m_tail); 550 m_tail = item; 551 } 552 553 m_head = item; 554 } 555 556 void PageCache::removeFromLRUList(HistoryItem* item) 557 { 558 if (!item->m_next) { 559 ASSERT(item == m_tail); 560 m_tail = item->m_prev; 561 } else { 562 ASSERT(item != m_tail); 563 item->m_next->m_prev = item->m_prev; 564 } 565 566 if (!item->m_prev) { 567 ASSERT(item == m_head); 568 m_head = item->m_next; 569 } else { 570 ASSERT(item != m_head); 571 item->m_prev->m_next = item->m_next; 505 while (pageCount() > maxSize()) { 506 auto& oldestItem = m_items.first(); 507 oldestItem->m_cachedPage = nullptr; 508 oldestItem->m_pruningReason = pruningReason; 509 m_items.removeFirst(); 572 510 } 573 511 } -
trunk/Source/WebCore/history/PageCache.h
r179263 r179347 1 1 /* 2 * Copyright (C) 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2007, 2015 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #define PageCache_h 28 28 29 #include "HistoryItem.h" 29 30 #include "Timer.h" 30 31 #include <wtf/Forward.h> 31 #include <wtf/ HashSet.h>32 #include <wtf/ListHashSet.h> 32 33 #include <wtf/Noncopyable.h> 33 34 34 35 namespace WebCore { 35 36 36 class CachedPage; 37 class Frame; 38 class HistoryItem; 39 class Page; 37 class CachedPage; 38 class Frame; 39 class Page; 40 40 41 enum class PruningReason { None, ProcessSuspended, MemoryPressure, ReachedCapacity }; 42 43 class PageCache { 44 WTF_MAKE_NONCOPYABLE(PageCache); WTF_MAKE_FAST_ALLOCATED; 45 public: 46 // Function to obtain the global page cache. 47 WEBCORE_EXPORT static PageCache& shared(); 48 49 bool canCache(Page*) const; 41 enum class PruningReason { None, ProcessSuspended, MemoryPressure, ReachedMaxSize }; 50 42 51 WEBCORE_EXPORT void setCapacity(int); // number of pages to cache 52 int capacity() { return m_capacity; } 53 54 void add(PassRefPtr<HistoryItem>, Page&); // Prunes if capacity() is exceeded. 55 WEBCORE_EXPORT void remove(HistoryItem*); 56 CachedPage* get(HistoryItem*, Page*); 57 std::unique_ptr<CachedPage> take(HistoryItem*, Page*); 43 class PageCache { 44 WTF_MAKE_NONCOPYABLE(PageCache); WTF_MAKE_FAST_ALLOCATED; 45 public: 46 // Function to obtain the global page cache. 47 WEBCORE_EXPORT static PageCache& shared(); 58 48 59 int pageCount() const { return m_size; } 60 WEBCORE_EXPORT int frameCount() const; 49 bool canCache(Page*) const; 61 50 62 WEBCORE_EXPORT void markPagesForVisitedLinkStyleRecalc(); 51 // Used when memory is low to prune some cached pages. 52 WEBCORE_EXPORT void pruneToSizeNow(unsigned maxSize, PruningReason); 53 WEBCORE_EXPORT void setMaxSize(unsigned); // number of pages to cache. 54 unsigned maxSize() const { return m_maxSize; } 63 55 64 // Will mark all cached pages associated with the given page as needing style recalc. 65 void markPagesForFullStyleRecalc(Page*); 56 void add(HistoryItem&, Page&); // Prunes if maxSize() is exceeded. 57 WEBCORE_EXPORT void remove(HistoryItem&); 58 CachedPage* get(HistoryItem&, Page*) const; 59 std::unique_ptr<CachedPage> take(HistoryItem&, Page*); 66 60 67 // Used when memory is low to prune some cached pages.68 WEBCORE_EXPORT void pruneToCapacityNow(int capacity, PruningReason);61 unsigned pageCount() const { return m_items.size(); } 62 WEBCORE_EXPORT unsigned frameCount() const; 69 63 64 WEBCORE_EXPORT void markPagesForVisitedLinkStyleRecalc(); 65 // Will mark all cached pages associated with the given page as needing style recalc. 66 void markPagesForFullStyleRecalc(Page&); 67 void markPagesForDeviceScaleChanged(Page&); 70 68 #if ENABLE(VIDEO_TRACK) 71 69 void markPagesForCaptionPreferencesChanged(); 72 70 #endif 73 71 74 bool shouldClearBackingStores() const { return m_shouldClearBackingStores; } 75 void setShouldClearBackingStores(bool flag) { m_shouldClearBackingStores = flag; } 76 void markPagesForDeviceScaleChanged(Page*); 72 bool shouldClearBackingStores() const { return m_shouldClearBackingStores; } 73 void setShouldClearBackingStores(bool flag) { m_shouldClearBackingStores = flag; } 77 74 78 private: 79 PageCache(); // Use shared() instead. 80 ~PageCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons. 81 82 static bool canCachePageContainingThisFrame(Frame*); 75 private: 76 PageCache() = default; // Use shared() instead. 77 ~PageCache() = delete; // Make sure nobody accidentally calls delete -- WebCore does not delete singletons. 83 78 84 void addToLRUList(HistoryItem*); // Adds to the head of the list. 85 void removeFromLRUList(HistoryItem*); 79 static bool canCachePageContainingThisFrame(Frame&); 86 80 87 81 void prune(PruningReason); 88 82 89 int m_capacity; 90 int m_size; 83 ListHashSet<RefPtr<HistoryItem>> m_items; 84 unsigned m_maxSize {0}; 85 bool m_shouldClearBackingStores {false}; 91 86 92 // LRU List 93 HistoryItem* m_head; 94 HistoryItem* m_tail; 95 96 bool m_shouldClearBackingStores; 97 98 friend class WTF::NeverDestroyed<PageCache>; 99 }; 87 friend class WTF::NeverDestroyed<PageCache>; 88 }; 100 89 101 90 } // namespace WebCore -
trunk/Source/WebCore/loader/FrameLoader.cpp
r179247 r179347 922 922 if (childItem) { 923 923 childFrame->loader().m_requestedHistoryItem = childItem; 924 childFrame->loader().loadDifferentDocumentItem( childItem, loadType(), MayAttemptCacheOnlyLoadForFormSubmissionItem);924 childFrame->loader().loadDifferentDocumentItem(*childItem, loadType(), MayAttemptCacheOnlyLoadForFormSubmissionItem); 925 925 return; 926 926 } … … 1741 1741 1742 1742 std::unique_ptr<CachedPage> cachedPage; 1743 if (m_loadingFromCachedPage )1744 cachedPage = PageCache::shared().take( history().provisionalItem(), m_frame.page());1743 if (m_loadingFromCachedPage && history().provisionalItem()) 1744 cachedPage = PageCache::shared().take(*history().provisionalItem(), m_frame.page()); 1745 1745 1746 1746 LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame.tree().uniqueName().string().utf8().data(), … … 1759 1759 LOG(PageCache, "Pruning page cache to 0 due to memory pressure"); 1760 1760 // Don't cache any page if we are under memory pressure. 1761 PageCache::shared().pruneTo CapacityNow(0, PruningReason::MemoryPressure);1761 PageCache::shared().pruneToSizeNow(0, PruningReason::MemoryPressure); 1762 1762 } else if (systemMemoryLevel() <= memoryLevelThresholdToPrunePageCache) { 1763 1763 LOG(MemoryPressure, "Pruning page cache because system memory level is %d at: %s", systemMemoryLevel(), __PRETTY_FUNCTION__); 1764 1764 LOG(PageCache, "Pruning page cache to %d due to low memory (level %d less or equal to %d threshold)", PageCache::shared().capacity() / 2, systemMemoryLevel(), memoryLevelThresholdToPrunePageCache); 1765 PageCache::shared().pruneTo CapacityNow(PageCache::shared().capacity() / 2, PruningReason::MemoryPressure);1765 PageCache::shared().pruneToSizeNow(PageCache::shared().maxSize() / 2, PruningReason::MemoryPressure); 1766 1766 } 1767 1767 } … … 1772 1772 // Check to see if we need to cache the page we are navigating away from into the back/forward cache. 1773 1773 // We are doing this here because we know for sure that a new page is about to be loaded. 1774 HistoryItem * item =history().currentItem();1775 if (!m_frame.tree().parent() && PageCache::shared().canCache(m_frame.page()) && !item ->isInPageCache())1774 HistoryItem& item = *history().currentItem(); 1775 if (!m_frame.tree().parent() && PageCache::shared().canCache(m_frame.page()) && !item.isInPageCache()) 1776 1776 PageCache::shared().add(item, *m_frame.page()); 1777 1777 … … 3128 3128 3129 3129 if (!activeDocument->canNavigate(frame)) 3130 return 0;3130 return nullptr; 3131 3131 3132 3132 return frame; 3133 3133 } 3134 3134 3135 void FrameLoader::loadSameDocumentItem(HistoryItem *item)3136 { 3137 ASSERT(item ->documentSequenceNumber() == history().currentItem()->documentSequenceNumber());3135 void FrameLoader::loadSameDocumentItem(HistoryItem& item) 3136 { 3137 ASSERT(item.documentSequenceNumber() == history().currentItem()->documentSequenceNumber()); 3138 3138 3139 3139 // Save user view state to the current history item here since we don't do a normal load. … … 3143 3143 view->setWasScrolledByUser(false); 3144 3144 3145 history().setCurrentItem( item);3145 history().setCurrentItem(&item); 3146 3146 3147 3147 // loadInSameDocument() actually changes the URL and notifies load delegates of a "fake" load 3148 loadInSameDocument(item ->url(), item->stateObject(), false);3148 loadInSameDocument(item.url(), item.stateObject(), false); 3149 3149 3150 3150 // Restore user view state from the current history item here since we don't do a normal load. … … 3155 3155 // which should be methods of HistoryController and some of which should be 3156 3156 // methods of FrameLoader. 3157 void FrameLoader::loadDifferentDocumentItem(HistoryItem *item, FrameLoadType loadType, FormSubmissionCacheLoadPolicy cacheLoadPolicy)3157 void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, FrameLoadType loadType, FormSubmissionCacheLoadPolicy cacheLoadPolicy) 3158 3158 { 3159 3159 // Remember this item so we can traverse any child items as child frames load 3160 history().setProvisionalItem( item);3160 history().setProvisionalItem(&item); 3161 3161 3162 3162 if (CachedPage* cachedPage = PageCache::shared().get(item, m_frame.page())) { … … 3168 3168 } 3169 3169 3170 URL itemURL = item ->url();3171 URL itemOriginalURL = item ->originalURL();3170 URL itemURL = item.url(); 3171 URL itemOriginalURL = item.originalURL(); 3172 3172 URL currentURL; 3173 3173 if (documentLoader()) 3174 3174 currentURL = documentLoader()->url(); 3175 RefPtr<FormData> formData = item ->formData();3175 RefPtr<FormData> formData = item.formData(); 3176 3176 3177 3177 ResourceRequest request(itemURL); 3178 3178 3179 if (!item ->referrer().isNull())3180 request.setHTTPReferrer(item ->referrer());3179 if (!item.referrer().isNull()) 3180 request.setHTTPReferrer(item.referrer()); 3181 3181 3182 3182 // If this was a repost that failed the page cache, we might try to repost the form. … … 3187 3187 request.setHTTPMethod("POST"); 3188 3188 request.setHTTPBody(formData); 3189 request.setHTTPContentType(item ->formContentType());3190 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString(item ->referrer());3189 request.setHTTPContentType(item.formContentType()); 3190 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString(item.referrer()); 3191 3191 addHTTPOriginIfNeeded(request, securityOrigin->toString()); 3192 3192 … … 3243 3243 3244 3244 // Loads content into this frame, as specified by history item 3245 void FrameLoader::loadItem(HistoryItem *item, FrameLoadType loadType)3246 { 3247 m_requestedHistoryItem = item;3245 void FrameLoader::loadItem(HistoryItem& item, FrameLoadType loadType) 3246 { 3247 m_requestedHistoryItem = &item; 3248 3248 HistoryItem* currentItem = history().currentItem(); 3249 bool sameDocumentNavigation = currentItem && item ->shouldDoSameDocumentNavigationTo(currentItem);3249 bool sameDocumentNavigation = currentItem && item.shouldDoSameDocumentNavigationTo(currentItem); 3250 3250 3251 3251 if (sameDocumentNavigation) … … 3261 3261 // We only use cache-only loads to avoid resubmitting forms. 3262 3262 ASSERT(isBackForwardLoadType(m_loadType)); 3263 ASSERT(history().provisionalItem()); 3263 3264 ASSERT(history().provisionalItem()->formData()); 3264 3265 ASSERT(history().provisionalItem() == m_requestedHistoryItem.get()); 3265 3266 3266 3267 FrameLoadType loadType = m_loadType; 3267 HistoryItem * item =history().provisionalItem();3268 HistoryItem& item = *history().provisionalItem(); 3268 3269 3269 3270 stopAllLoaders(ShouldNotClearProvisionalItem); -
trunk/Source/WebCore/loader/FrameLoader.h
r177482 r179347 126 126 127 127 void open(CachedFrameBase&); 128 void loadItem(HistoryItem *, FrameLoadType);128 void loadItem(HistoryItem&, FrameLoadType); 129 129 HistoryItem* requestedHistoryItem() const { return m_requestedHistoryItem.get(); } 130 130 … … 300 300 void checkTimerFired(); 301 301 302 void loadSameDocumentItem(HistoryItem *);303 void loadDifferentDocumentItem(HistoryItem *, FrameLoadType, FormSubmissionCacheLoadPolicy);302 void loadSameDocumentItem(HistoryItem&); 303 void loadDifferentDocumentItem(HistoryItem&, FrameLoadType, FormSubmissionCacheLoadPolicy); 304 304 305 305 void loadProvisionalItemFromCachedPage(); -
trunk/Source/WebCore/loader/HistoryController.cpp
r179247 r179347 235 235 void HistoryController::invalidateCurrentItemCachedPage() 236 236 { 237 if (!currentItem()) 238 return; 239 237 240 // When we are pre-commit, the currentItem is where any page cache data resides. 238 if (!PageCache::shared().get(currentItem(), m_frame.page())) 239 return; 240 241 std::unique_ptr<CachedPage> cachedPage = PageCache::shared().take(currentItem(), m_frame.page()); 241 std::unique_ptr<CachedPage> cachedPage = PageCache::shared().take(*currentItem(), m_frame.page()); 242 if (!cachedPage) 243 return; 242 244 243 245 // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach … … 266 268 // Main funnel for navigating to a previous location (back/forward, non-search snap-back) 267 269 // This includes recursion to handle loading into framesets properly 268 void HistoryController::goToItem(HistoryItem *targetItem, FrameLoadType type)270 void HistoryController::goToItem(HistoryItem& targetItem, FrameLoadType type) 269 271 { 270 272 ASSERT(!m_frame.tree().parent()); … … 277 279 if (!page) 278 280 return; 279 if (!m_frame.loader().client().shouldGoToHistoryItem( targetItem))281 if (!m_frame.loader().client().shouldGoToHistoryItem(&targetItem)) 280 282 return; 281 283 if (m_defersLoading) { 282 m_deferredItem = targetItem;284 m_deferredItem = &targetItem; 283 285 m_deferredFrameLoadType = type; 284 286 return; … … 289 291 // as opposed to happening for some/one of the page commits that might happen soon 290 292 RefPtr<HistoryItem> currentItem = page->backForward().currentItem(); 291 page->backForward().setCurrentItem( targetItem);293 page->backForward().setCurrentItem(&targetItem); 292 294 m_frame.loader().client().updateGlobalHistoryItemForPage(); 293 295 … … 306 308 m_defersLoading = defer; 307 309 if (!defer && m_deferredItem) { 308 goToItem( m_deferredItem.get(), m_deferredFrameLoadType);309 m_deferredItem = 0;310 goToItem(*m_deferredItem, m_deferredFrameLoadType); 311 m_deferredItem = nullptr; 310 312 } 311 313 } … … 335 337 336 338 if (m_currentItem) { 337 PageCache::shared().remove( m_currentItem.get());339 PageCache::shared().remove(*m_currentItem); 338 340 339 341 if (m_frame.loader().loadType() == FrameLoadType::Reload || m_frame.loader().loadType() == FrameLoadType::ReloadFromOrigin) … … 500 502 // (a matching URL and frame tree snapshot), just restore the scroll position. 501 503 // Save form state (works from currentItem, since m_frameLoadComplete is true) 502 if (m_currentItem && itemsAreClones( m_currentItem.get(), m_provisionalItem.get())) {504 if (m_currentItem && itemsAreClones(*m_currentItem, m_provisionalItem.get())) { 503 505 ASSERT(m_frameLoadComplete); 504 506 saveDocumentState(); … … 708 710 // a match, we set the provisional item and recurse. Otherwise we will reload that 709 711 // frame and all its kids in recursiveGoToItem. 710 void HistoryController::recursiveSetProvisionalItem(HistoryItem* item, HistoryItem* fromItem) 711 { 712 ASSERT(item); 713 712 void HistoryController::recursiveSetProvisionalItem(HistoryItem& item, HistoryItem* fromItem) 713 { 714 714 if (!itemsAreClones(item, fromItem)) 715 715 return; 716 716 717 717 // Set provisional item, which will be committed in recursiveUpdateForCommit. 718 m_provisionalItem = item;719 720 for (const auto& childItem : item ->children()) {718 m_provisionalItem = &item; 719 720 for (const auto& childItem : item.children()) { 721 721 const String& childFrameName = childItem->target(); 722 722 … … 726 726 ASSERT(childFrame); 727 727 728 childFrame->loader().history().recursiveSetProvisionalItem( childItem.get(), fromChildItem);728 childFrame->loader().history().recursiveSetProvisionalItem(*childItem, fromChildItem); 729 729 } 730 730 } … … 732 732 // We now traverse the frame tree and item tree a second time, loading frames that 733 733 // do have the content the item requests. 734 void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromItem, FrameLoadType type) 735 { 736 ASSERT(item); 737 734 void HistoryController::recursiveGoToItem(HistoryItem& item, HistoryItem* fromItem, FrameLoadType type) 735 { 738 736 if (!itemsAreClones(item, fromItem)) { 739 737 m_frame.loader().loadItem(item, type); … … 742 740 743 741 // Just iterate over the rest, looking for frames to navigate. 744 for (const auto& childItem : item ->children()) {742 for (const auto& childItem : item.children()) { 745 743 const String& childFrameName = childItem->target(); 746 744 … … 749 747 Frame* childFrame = m_frame.tree().child(childFrameName); 750 748 ASSERT(childFrame); 751 childFrame->loader().history().recursiveGoToItem( childItem.get(), fromChildItem, type);752 } 753 } 754 755 bool HistoryController::itemsAreClones(HistoryItem *item1, HistoryItem* item2) const749 childFrame->loader().history().recursiveGoToItem(*childItem, fromChildItem, type); 750 } 751 } 752 753 bool HistoryController::itemsAreClones(HistoryItem& item1, HistoryItem* item2) const 756 754 { 757 755 // If the item we're going to is a clone of the item we're at, then we do … … 762 760 // new document and should not consider them clones. 763 761 // (See http://webkit.org/b/35532 for details.) 764 return item1 765 && item2 766 && item1 != item2 767 && item1->itemSequenceNumber() == item2->itemSequenceNumber() 768 && currentFramesMatchItem(item1) 769 && item2->hasSameFrames(item1); 762 return item2 763 && &item1 != item2 764 && item1.itemSequenceNumber() == item2->itemSequenceNumber() 765 && currentFramesMatchItem(&item1) 766 && item2->hasSameFrames(&item1); 770 767 } 771 768 -
trunk/Source/WebCore/loader/HistoryController.h
r172862 r179347 94 94 friend class Page; 95 95 bool shouldStopLoadingForHistoryItem(HistoryItem*) const; 96 void goToItem(HistoryItem *, FrameLoadType);96 void goToItem(HistoryItem&, FrameLoadType); 97 97 98 98 void initializeItem(HistoryItem*); … … 100 100 PassRefPtr<HistoryItem> createItemTree(Frame& targetFrame, bool clipAtTarget); 101 101 102 void recursiveSetProvisionalItem(HistoryItem *, HistoryItem*);103 void recursiveGoToItem(HistoryItem *, HistoryItem*, FrameLoadType);102 void recursiveSetProvisionalItem(HistoryItem&, HistoryItem*); 103 void recursiveGoToItem(HistoryItem&, HistoryItem*, FrameLoadType); 104 104 bool isReplaceLoadTypeWithProvisionalItem(FrameLoadType); 105 105 bool isReloadTypeWithProvisionalItem(FrameLoadType); 106 106 void recursiveUpdateForCommit(); 107 107 void recursiveUpdateForSameDocumentNavigation(); 108 bool itemsAreClones(HistoryItem *, HistoryItem*) const;108 bool itemsAreClones(HistoryItem&, HistoryItem*) const; 109 109 bool currentFramesMatchItem(HistoryItem*) const; 110 110 void updateBackForwardListClippedAtTarget(bool doClip); -
trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp
r178949 r179347 389 389 } 390 390 391 String DiagnosticLoggingKeys::prunedDueTo CapacityReached()391 String DiagnosticLoggingKeys::prunedDueToMaxSizeReached() 392 392 { 393 393 return ASCIILiteral("pruned.capacityReached"); -
trunk/Source/WebCore/page/DiagnosticLoggingKeys.h
r178949 r179347 77 77 static String pluginLoadedKey(); 78 78 static String pluginLoadingFailedKey(); 79 static String prunedDueTo CapacityReached();79 static String prunedDueToMaxSizeReached(); 80 80 static String prunedDueToMemoryPressureKey(); 81 81 static String prunedDueToProcessSuspended(); -
trunk/Source/WebCore/page/Frame.cpp
r179247 r179347 990 990 991 991 if (isMainFrame()) 992 PageCache::shared().markPagesForFullStyleRecalc( page);992 PageCache::shared().markPagesForFullStyleRecalc(*page); 993 993 } 994 994 -
trunk/Source/WebCore/page/Page.cpp
r179247 r179347 431 431 } 432 432 433 void Page::goToItem(HistoryItem *item, FrameLoadType type)433 void Page::goToItem(HistoryItem& item, FrameLoadType type) 434 434 { 435 435 // stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem 436 436 // being deref()-ed. Make sure we can still use it with HistoryController::goToItem later. 437 Ref Ptr<HistoryItem> protector(item);438 439 if (m_mainFrame->loader().history().shouldStopLoadingForHistoryItem( item))437 Ref<HistoryItem> protector(item); 438 439 if (m_mainFrame->loader().history().shouldStopLoadingForHistoryItem(&item)) 440 440 m_mainFrame->loader().stopAllLoaders(); 441 441 … … 840 840 841 841 mainFrame().deviceOrPageScaleFactorChanged(); 842 PageCache::shared().markPagesForDeviceScaleChanged( this);843 844 PageCache::shared().markPagesForFullStyleRecalc( this);842 PageCache::shared().markPagesForDeviceScaleChanged(*this); 843 844 PageCache::shared().markPagesForFullStyleRecalc(*this); 845 845 GraphicsContext::updateDocumentMarkerResources(); 846 846 … … 922 922 923 923 setNeedsRecalcStyleInAllFrames(); 924 PageCache::shared().markPagesForFullStyleRecalc( this);924 PageCache::shared().markPagesForFullStyleRecalc(*this); 925 925 } 926 926 … … 1662 1662 1663 1663 invalidateStylesForAllLinks(); 1664 PageCache::shared().markPagesForFullStyleRecalc( this);1664 PageCache::shared().markPagesForFullStyleRecalc(*this); 1665 1665 } 1666 1666 -
trunk/Source/WebCore/page/Page.h
r178820 r179347 151 151 void setOpenedByDOM(); 152 152 153 WEBCORE_EXPORT void goToItem(HistoryItem *, FrameLoadType);153 WEBCORE_EXPORT void goToItem(HistoryItem&, FrameLoadType); 154 154 155 155 WEBCORE_EXPORT void setGroupName(const String&); -
trunk/Source/WebCore/page/Settings.cpp
r179247 r179347 520 520 return; 521 521 522 if (!m_usesPageCache) { 523 int first = -m_page->backForward().backCount(); 524 int last = m_page->backForward().forwardCount(); 525 for (int i = first; i <= last; i++) 526 PageCache::shared().remove(m_page->backForward().itemAtIndex(i)); 527 } 522 if (!m_usesPageCache) 523 PageCache::shared().pruneToSizeNow(0, PruningReason::None); 528 524 } 529 525 -
trunk/Source/WebCore/platform/MemoryPressureHandler.cpp
r179293 r179347 103 103 // Right now, the only reason we call release critical memory while not under memory pressure is if the process is about to be suspended. 104 104 PruningReason pruningReason = memoryPressureHandler().isUnderMemoryPressure() ? PruningReason::MemoryPressure : PruningReason::ProcessSuspended; 105 PageCache::shared().pruneTo CapacityNow(0, pruningReason);105 PageCache::shared().pruneToSizeNow(0, pruningReason); 106 106 } 107 107 -
trunk/Source/WebKit/mac/ChangeLog
r179294 r179347 1 2015-01-29 Chris Dumez <cdumez@apple.com> 2 3 Clean up / modernize PageCache class 4 https://bugs.webkit.org/show_bug.cgi?id=141009 5 6 Reviewed by Darin Adler. 7 8 Clean up / modernize PageCache class. 9 10 * History/WebBackForwardList.mm: 11 (-[WebBackForwardList pageCacheSize]): 12 * WebView/WebView.mm: 13 (-[WebView _loadBackForwardListFromOtherView:]): 14 (-[WebView goToBackForwardItem:]): 15 (+[WebView _setCacheModel:]): 16 1 17 2015-01-28 Beth Dakin <bdakin@apple.com> 2 18 -
trunk/Source/WebKit/mac/History/WebBackForwardList.mm
r179247 r179347 356 356 - (NSUInteger)pageCacheSize 357 357 { 358 return [kit(core(self)->page()) usesPageCache] ? PageCache::shared(). capacity() : 0;358 return [kit(core(self)->page()) usesPageCache] ? PageCache::shared().maxSize() : 0; 359 359 } 360 360 -
trunk/Source/WebKit/mac/WebView/WebView.mm
r179247 r179347 1998 1998 return; // empty back forward list, bail 1999 1999 2000 HistoryItem* newItemToGoTo = 0;2000 HistoryItem* newItemToGoTo = nullptr; 2001 2001 2002 2002 int lastItemIndex = otherBackForwardClient->forwardListCount(); … … 2015 2015 2016 2016 ASSERT(newItemToGoTo); 2017 _private->page->goToItem( newItemToGoTo, FrameLoadType::IndexedBackForward);2017 _private->page->goToItem(*newItemToGoTo, FrameLoadType::IndexedBackForward); 2018 2018 } 2019 2019 … … 5648 5648 return NO; 5649 5649 5650 _private->page->goToItem(core(item), FrameLoadType::IndexedBackForward); 5650 ASSERT(item); 5651 _private->page->goToItem(*core(item), FrameLoadType::IndexedBackForward); 5651 5652 return YES; 5652 5653 } … … 7743 7744 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 7744 7745 7745 unsigned pageCache Capacity= 0;7746 unsigned pageCacheSize = 0; 7746 7747 7747 7748 NSUInteger nsurlCacheMemoryCapacity = 0; … … 7754 7755 case WebCacheModelDocumentViewer: { 7755 7756 // Page cache capacity (in pages) 7756 pageCache Capacity= 0;7757 pageCacheSize = 0; 7757 7758 7758 7759 // Object cache capacities (in bytes) … … 7791 7792 // Page cache capacity (in pages) 7792 7793 if (memSize >= 1024) 7793 pageCache Capacity= 3;7794 pageCacheSize = 3; 7794 7795 else if (memSize >= 512) 7795 pageCache Capacity= 2;7796 pageCacheSize = 2; 7796 7797 else if (memSize >= 256) 7797 pageCache Capacity= 1;7798 pageCacheSize = 1; 7798 7799 else 7799 pageCache Capacity= 0;7800 pageCacheSize = 0; 7800 7801 7801 7802 // Object cache capacities (in bytes) … … 7845 7846 // (Research indicates that value / page drops substantially after 3 pages.) 7846 7847 if (memSize >= 2048) 7847 pageCache Capacity= 5;7848 pageCacheSize = 5; 7848 7849 else if (memSize >= 1024) 7849 pageCache Capacity= 4;7850 pageCacheSize = 4; 7850 7851 else if (memSize >= 512) 7851 pageCache Capacity= 3;7852 pageCacheSize = 3; 7852 7853 else if (memSize >= 256) 7853 pageCache Capacity= 2;7854 pageCacheSize = 2; 7854 7855 else 7855 pageCache Capacity= 1;7856 pageCacheSize = 1; 7856 7857 7857 7858 #if PLATFORM(IOS) … … 7859 7860 // FIXME (<rdar://problem/11779846>): Avoiding jettisoning should not have to require reducing the page cache capacity. 7860 7861 // Reducing the capacity by 1 reduces overall back-forward performance. 7861 if (pageCache Capacity> 0)7862 pageCache Capacity-= 1;7862 if (pageCacheSize > 0) 7863 pageCacheSize -= 1; 7863 7864 #endif 7864 7865 … … 7936 7937 memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 7937 7938 memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 7938 PageCache::shared().set Capacity(pageCacheCapacity);7939 PageCache::shared().setMaxSize(pageCacheSize); 7939 7940 #if PLATFORM(IOS) 7940 7941 PageCache::shared().setShouldClearBackingStores(true); -
trunk/Source/WebKit/win/ChangeLog
r179278 r179347 1 2015-01-29 Chris Dumez <cdumez@apple.com> 2 3 Clean up / modernize PageCache class 4 https://bugs.webkit.org/show_bug.cgi?id=141009 5 6 Reviewed by Darin Adler. 7 8 Clean up / modernize PageCache class. 9 10 * WebView.cpp: 11 (WebView::setCacheModel): 12 1 13 2015-01-28 peavo@outlook.com <peavo@outlook.com> 2 14 -
trunk/Source/WebKit/win/WebView.cpp
r179247 r179347 531 531 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 532 532 533 unsigned pageCache Capacity= 0;533 unsigned pageCacheSize = 0; 534 534 535 535 … … 537 537 case WebCacheModelDocumentViewer: { 538 538 // Page cache capacity (in pages) 539 pageCache Capacity= 0;539 pageCacheSize = 0; 540 540 541 541 // Object cache capacities (in bytes) … … 564 564 // Page cache capacity (in pages) 565 565 if (memSize >= 1024) 566 pageCache Capacity= 3;566 pageCacheSize = 3; 567 567 else if (memSize >= 512) 568 pageCache Capacity= 2;568 pageCacheSize = 2; 569 569 else if (memSize >= 256) 570 pageCache Capacity= 1;570 pageCacheSize = 1; 571 571 else 572 pageCache Capacity= 0;572 pageCacheSize = 0; 573 573 574 574 // Object cache capacities (in bytes) … … 611 611 // (Research indicates that value / page drops substantially after 3 pages.) 612 612 if (memSize >= 2048) 613 pageCache Capacity= 5;613 pageCacheSize = 5; 614 614 else if (memSize >= 1024) 615 pageCache Capacity= 4;615 pageCacheSize = 4; 616 616 else if (memSize >= 512) 617 pageCache Capacity= 3;617 pageCacheSize = 3; 618 618 else if (memSize >= 256) 619 pageCache Capacity= 2;619 pageCacheSize = 2; 620 620 else 621 pageCache Capacity= 1;621 pageCacheSize = 1; 622 622 623 623 // Object cache capacities (in bytes) … … 676 676 memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 677 677 memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 678 PageCache::shared().set Capacity(pageCacheCapacity);678 PageCache::shared().setMaxSize(pageCacheSize); 679 679 680 680 #if USE(CFNETWORK) … … 3155 3155 return hr; 3156 3156 3157 m_page->goToItem( webHistoryItem->historyItem(), FrameLoadType::IndexedBackForward);3157 m_page->goToItem(*webHistoryItem->historyItem(), FrameLoadType::IndexedBackForward); 3158 3158 *succeeded = TRUE; 3159 3159 … … 5502 5502 5503 5503 ASSERT(newItemToGoTo); 5504 m_page->goToItem( newItemToGoTo, FrameLoadType::IndexedBackForward);5504 m_page->goToItem(*newItemToGoTo, FrameLoadType::IndexedBackForward); 5505 5505 return S_OK; 5506 5506 } -
trunk/Source/WebKit2/ChangeLog
r179346 r179347 1 2015-01-29 Chris Dumez <cdumez@apple.com> 2 3 Clean up / modernize PageCache class 4 https://bugs.webkit.org/show_bug.cgi?id=141009 5 6 Reviewed by Darin Adler. 7 8 Clean up / modernize PageCache class. 9 10 * WebProcess/WebPage/WebBackForwardListProxy.cpp: 11 (WebKit::WebBackForwardListProxy::removeItem): 12 (WebKit::WebBackForwardListProxy::close): 13 * WebProcess/WebPage/WebPage.cpp: 14 (WebKit::WebPage::goForward): 15 (WebKit::WebPage::goBack): 16 (WebKit::WebPage::goToBackForwardItem): 17 * WebProcess/WebProcess.cpp: 18 (WebKit::WebProcess::releasePageCache): 19 * WebProcess/cocoa/WebProcessCocoa.mm: 20 (WebKit::WebProcess::platformSetCacheModel): 21 * WebProcess/soup/WebProcessSoup.cpp: 22 (WebKit::WebProcess::platformSetCacheModel): 23 1 24 2015-01-29 Csaba Osztrogonác <ossy@webkit.org> 2 25 -
trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
r179247 r179347 133 133 return; 134 134 135 PageCache::shared().remove( item.get());135 PageCache::shared().remove(*item); 136 136 WebCore::Page::clearPreviousItemFromAllPages(item.get()); 137 137 historyItemToIDMap().remove(item); … … 217 217 void WebBackForwardListProxy::close() 218 218 { 219 HashSet<uint64_t>::iterator end = m_associatedItemIDs.end(); 220 for (HashSet<uint64_t>::iterator i = m_associatedItemIDs.begin(); i != end; ++i) 221 WebCore::PageCache::shared().remove(itemForID(*i)); 219 for (auto& itemID : m_associatedItemIDs) { 220 if (HistoryItem* item = itemForID(itemID)) 221 WebCore::PageCache::shared().remove(*item); 222 } 222 223 223 224 m_associatedItemIDs.clear(); 224 225 225 m_page = nullptr; 226 226 } -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r179321 r179347 1211 1211 m_pendingNavigationID = navigationID; 1212 1212 1213 m_page->goToItem( item, FrameLoadType::Forward);1213 m_page->goToItem(*item, FrameLoadType::Forward); 1214 1214 } 1215 1215 … … 1227 1227 m_pendingNavigationID = navigationID; 1228 1228 1229 m_page->goToItem( item, FrameLoadType::Back);1229 m_page->goToItem(*item, FrameLoadType::Back); 1230 1230 } 1231 1231 … … 1243 1243 m_pendingNavigationID = navigationID; 1244 1244 1245 m_page->goToItem( item, FrameLoadType::IndexedBackForward);1245 m_page->goToItem(*item, FrameLoadType::IndexedBackForward); 1246 1246 } 1247 1247 -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r179247 r179347 1117 1117 void WebProcess::releasePageCache() 1118 1118 { 1119 PageCache::shared().pruneTo CapacityNow(0, PruningReason::MemoryPressure);1119 PageCache::shared().pruneToSizeNow(0, PruningReason::MemoryPressure); 1120 1120 } 1121 1121 -
trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm
r179247 r179347 105 105 unsigned cacheMaxDeadCapacity = 0; 106 106 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 107 unsigned pageCache Capacity= 0;107 unsigned pageCacheSize = 0; 108 108 unsigned long urlCacheMemoryCapacity = 0; 109 109 unsigned long urlCacheDiskCapacity = 0; … … 111 111 calculateCacheSizes(cacheModel, memSize, diskFreeSize, 112 112 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 113 pageCache Capacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);113 pageCacheSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 114 114 115 115 116 116 memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 117 117 memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 118 PageCache::shared().set Capacity(pageCacheCapacity);118 PageCache::shared().setMaxSize(pageCacheSize); 119 119 120 120 NSURLCache *nsurlCache = [NSURLCache sharedURLCache]; -
trunk/Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp
r179247 r179347 84 84 unsigned cacheMaxDeadCapacity = 0; 85 85 auto deadDecodedDataDeletionInterval = std::chrono::seconds { 0 }; 86 unsigned pageCache Capacity= 0;86 unsigned pageCacheSize = 0; 87 87 88 88 unsigned long urlCacheMemoryCapacity = 0; … … 100 100 calculateCacheSizes(cacheModel, memSize, diskFreeSize, 101 101 cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval, 102 pageCache Capacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);102 pageCacheSize, urlCacheMemoryCapacity, urlCacheDiskCapacity); 103 103 104 104 WebCore::memoryCache().setDisabled(cacheModel == CacheModelDocumentViewer); 105 105 WebCore::memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 106 106 WebCore::memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval); 107 WebCore::PageCache::shared().set Capacity(pageCacheCapacity);107 WebCore::PageCache::shared().setMaxSize(pageCacheSize); 108 108 109 109 #if PLATFORM(GTK)
Note:
See TracChangeset
for help on using the changeset viewer.