Changeset 40286 in webkit


Ignore:
Timestamp:
Jan 26, 2009 7:49:43 PM (15 years ago)
Author:
beidson@apple.com
Message:

2009-01-26 Brady Eidson <beidson@apple.com>

Reviewed by Darin Adler

-Make the recently added back/forward cache logging much better by actually

walking the entire frame tree and indenting the resulting output.

-Fix a null-termination bug in HistoryItem tree logging

  • history/HistoryItem.cpp: (WebCore::HistoryItem::showTreeWithIndent):
  • loader/FrameLoader.cpp: (WebCore::pageCacheLogPrefix): (WebCore::pageCacheLog): (WebCore::FrameLoader::logCanCachePageDecision): (WebCore::FrameLoader::logCanCacheFrameDecision):
  • loader/FrameLoader.h:
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r40285 r40286  
     12009-01-26  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Darin Adler
     4
     5        -Make the recently added back/forward cache logging much better by actually
     6         walking the entire frame tree and indenting the resulting output.
     7        -Fix a null-termination bug in HistoryItem tree logging
     8
     9        * history/HistoryItem.cpp:
     10        (WebCore::HistoryItem::showTreeWithIndent):
     11
     12        * loader/FrameLoader.cpp:
     13        (WebCore::pageCacheLogPrefix):
     14        (WebCore::pageCacheLog):
     15        (WebCore::FrameLoader::logCanCachePageDecision):
     16        (WebCore::FrameLoader::logCanCacheFrameDecision):
     17        * loader/FrameLoader.h:
     18
    1192009-01-26  Adam Treat  <adam.treat@torchmobile.com>
    220
  • trunk/WebCore/history/HistoryItem.cpp

    r40132 r40286  
    413413    for (unsigned i = 0; i < indentLevel; ++i)
    414414        prefix.append("  ", 2);
     415    prefix.append("\0", 1);
    415416
    416417    fprintf(stderr, "%s+-%s (%p)\n", prefix.data(), m_urlString.utf8().data(), this);
  • trunk/WebCore/loader/FrameLoader.cpp

    r40267 r40286  
    19481948
    19491949#ifndef NDEBUG
     1950static String& pageCacheLogPrefix(int indentLevel)
     1951{
     1952    static int previousIndent = -1;
     1953    DEFINE_STATIC_LOCAL(String, prefix, ());
     1954   
     1955    if (indentLevel != previousIndent) {   
     1956        previousIndent = indentLevel;
     1957        prefix.truncate(0);
     1958        for (int i = 0; i < previousIndent; ++i)
     1959            prefix += "    ";
     1960    }
     1961   
     1962    return prefix;
     1963}
     1964
     1965static void pageCacheLog(const String& prefix, const String& message)
     1966{
     1967    LOG(PageCache, "%s%s", prefix.utf8().data(), message.utf8().data());
     1968}
     1969
     1970#define PCLOG(...) pageCacheLog(pageCacheLogPrefix(indentLevel), String::format(__VA_ARGS__))
     1971
    19501972void FrameLoader::logCanCachePageDecision()
    19511973{
     
    19571979        return;
    19581980
    1959     LOG(PageCache, "--------\nDetermining if page can be cached:");
    1960    
    1961     bool cannotCache = !logCanCacheFrameDecision();
    1962    
    1963     for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
    1964         cannotCache = !child->loader()->logCanCacheFrameDecision();
     1981    int indentLevel = 0;
     1982    PCLOG("--------\n Determining if page can be cached:");
     1983
     1984    bool cannotCache = !logCanCacheFrameDecision(1);
    19651985       
    19661986    FrameLoadType loadType = this->loadType();
    19671987    do {
    19681988        if (m_frame->tree()->parent())
    1969             { LOG(PageCache, " -Frame has a parent frame"); cannotCache = true; }
     1989            { PCLOG("  -Frame has a parent frame"); cannotCache = true; }
    19701990        if (!m_frame->page()) {
    1971             LOG(PageCache, " -There is no Page object");
     1991            PCLOG("  -There is no Page object");
    19721992            cannotCache = true;
    19731993            break;
    19741994        }
    19751995        if (!m_frame->page()->backForwardList()->enabled())
    1976             { LOG(PageCache, " -The back/forward list is disabled"); cannotCache = true; }
     1996            { PCLOG("  -The back/forward list is disabled"); cannotCache = true; }
    19771997        if (!(m_frame->page()->backForwardList()->capacity() > 0))
    1978             { LOG(PageCache, " -The back/forward list has a 0 capacity"); cannotCache = true; }
     1998            { PCLOG("  -The back/forward list has a 0 capacity"); cannotCache = true; }
    19791999        if (!m_frame->page()->settings()->usesPageCache())
    1980             { LOG(PageCache, " -Page settings says b/f cache disabled"); cannotCache = true; }
     2000            { PCLOG("  -Page settings says b/f cache disabled"); cannotCache = true; }
    19812001        if (loadType == FrameLoadTypeReload)
    1982             { LOG(PageCache, " -Load type is: Reload"); cannotCache = true; }
     2002            { PCLOG("  -Load type is: Reload"); cannotCache = true; }
    19832003        if (loadType == FrameLoadTypeReloadAllowingStaleData)
    1984             { LOG(PageCache, " -Load type is: Reload allowing stale data"); cannotCache = true; }
     2004            { PCLOG("  -Load type is: Reload allowing stale data"); cannotCache = true; }
    19852005        if (loadType == FrameLoadTypeReloadFromOrigin)
    1986             { LOG(PageCache, " -Load type is: Reload from origin"); cannotCache = true; }
     2006            { PCLOG("  -Load type is: Reload from origin"); cannotCache = true; }
    19872007        if (loadType == FrameLoadTypeSame)
    1988             { LOG(PageCache, " -Load type is: Same"); cannotCache = true; }
     2008            { PCLOG("  -Load type is: Same"); cannotCache = true; }
    19892009    } while (false);
    19902010   
    1991     LOG(PageCache, cannotCache ? "Page CANNOT be cached\n--------" : "Page CAN be cached\n--------");
    1992 }
    1993 
    1994 bool FrameLoader::logCanCacheFrameDecision()
     2011    PCLOG(cannotCache ? " Page CANNOT be cached\n--------" : " Page CAN be cached\n--------");
     2012}
     2013
     2014bool FrameLoader::logCanCacheFrameDecision(int indentLevel)
    19952015{
    19962016    // Only bother logging for frames that have actually loaded and have content.
     
    20012021        return false;
    20022022
     2023    PCLOG("+---");
    20032024    KURL newURL = m_provisionalDocumentLoader ? m_provisionalDocumentLoader->url() : KURL();
    20042025    if (!newURL.isEmpty())
    2005         LOG(PageCache, "----\nDetermining if frame can be cached navigating from (%s) to (%s):", currentURL.string().utf8().data(), newURL.string().utf8().data());
     2026        PCLOG(" Determining if frame can be cached navigating from (%s) to (%s):", currentURL.string().utf8().data(), newURL.string().utf8().data());
    20062027    else
    2007         LOG(PageCache, "----\nDetermining if subframe with URL (%s) can be cached:", currentURL.string().utf8().data());
     2028        PCLOG(" Determining if subframe with URL (%s) can be cached:", currentURL.string().utf8().data());
    20082029       
    20092030    bool cannotCache = false;
     
    20112032    do {
    20122033        if (!m_documentLoader) {
    2013             LOG(PageCache, " -There is no DocumentLoader object");
     2034            PCLOG("  -There is no DocumentLoader object");
    20142035            cannotCache = true;
    20152036            break;
    20162037        }
    20172038        if (!m_documentLoader->mainDocumentError().isNull())
    2018             { LOG(PageCache, " -Main document has an error"); cannotCache = true; }
     2039            { PCLOG("  -Main document has an error"); cannotCache = true; }
    20192040        if (m_frame->tree()->childCount())
    2020             { LOG(PageCache, " -Frame has child frames"); cannotCache = true; }
     2041            { PCLOG("  -Frame has child frames"); cannotCache = true; }
    20212042        if (m_containsPlugIns)
    2022             { LOG(PageCache, " -Frame contains plugins"); cannotCache = true; }
     2043            { PCLOG("  -Frame contains plugins"); cannotCache = true; }
    20232044        if (m_URL.protocolIs("https"))
    2024             { LOG(PageCache, " -Frame is HTTPS"); cannotCache = true; }
     2045            { PCLOG("  -Frame is HTTPS"); cannotCache = true; }
    20252046        if (!m_frame->document()) {
    2026             LOG(PageCache, " -There is no Document object");
     2047            PCLOG("  -There is no Document object");
    20272048            cannotCache = true;
    20282049            break;
    20292050        }
    20302051        if (m_frame->document()->hasWindowEventListener(eventNames().unloadEvent))
    2031             { LOG(PageCache, " -Frame has an unload event listener"); cannotCache = true; }
     2052            { PCLOG("  -Frame has an unload event listener"); cannotCache = true; }
    20322053#if ENABLE(DATABASE)
    20332054        if (m_frame->document()->hasOpenDatabases())
    2034             { LOG(PageCache, " -Frame has open database handles"); cannotCache = true; }
     2055            { PCLOG("  -Frame has open database handles"); cannotCache = true; }
    20352056#endif
    20362057        if (m_frame->document()->usingGeolocation())
    2037             { LOG(PageCache, " -Frame uses Geolocation"); cannotCache = true; }
     2058            { PCLOG("  -Frame uses Geolocation"); cannotCache = true; }
    20382059        if (!m_currentHistoryItem)
    2039             { LOG(PageCache, " -No current history item"); cannotCache = true; }
     2060            { PCLOG("  -No current history item"); cannotCache = true; }
    20402061        if (isQuickRedirectComing())
    2041             { LOG(PageCache, " -Quick redirect is coming"); cannotCache = true; }
     2062            { PCLOG("  -Quick redirect is coming"); cannotCache = true; }
    20422063        if (m_documentLoader->isLoadingInAPISense())
    2043             { LOG(PageCache, " -DocumentLoader is still loading in API sense"); cannotCache = true; }
     2064            { PCLOG("  -DocumentLoader is still loading in API sense"); cannotCache = true; }
    20442065        if (m_documentLoader->isStopping())
    2045             { LOG(PageCache, " -DocumentLoader is in the middle of stopping"); cannotCache = true; }
     2066            { PCLOG("  -DocumentLoader is in the middle of stopping"); cannotCache = true; }
    20462067        if (!m_frame->document()->canSuspendActiveDOMObjects())
    2047             { LOG(PageCache, " -The document cannot suspect its active DOM Objects"); cannotCache = true; }
     2068            { PCLOG("  -The document cannot suspect its active DOM Objects"); cannotCache = true; }
    20482069#if ENABLE(OFFLINE_WEB_APPLICATIONS)
    20492070        if (m_documentLoader->applicationCache())
    2050             { LOG(PageCache, " -The DocumentLoader has an active application cache"); cannotCache = true; }
     2071            { PCLOG("  -The DocumentLoader has an active application cache"); cannotCache = true; }
    20512072        if (m_documentLoader->candidateApplicationCacheGroup())
    2052             { LOG(PageCache, " -The DocumentLoader has a candidateApplicationCacheGroup"); cannotCache = true; }
     2073            { PCLOG("  -The DocumentLoader has a candidateApplicationCacheGroup"); cannotCache = true; }
    20532074#endif
    20542075        if (!m_client->canCachePage())
    2055             { LOG(PageCache, " -The client says this frame cannot be cached"); cannotCache = true; }
     2076            { PCLOG("  -The client says this frame cannot be cached"); cannotCache = true; }
    20562077    } while (false);
    2057    
    2058     LOG(PageCache, cannotCache ? "Frame CANNOT be cached\n----" : "Frame CAN be cached\n----");
    2059    
     2078
     2079    for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
     2080        if (!child->loader()->logCanCacheFrameDecision(indentLevel + 1))
     2081            cannotCache = true;
     2082   
     2083    PCLOG(cannotCache ? " Frame CANNOT be cached" : " Frame CAN be cached");
     2084    PCLOG("+---");
     2085
    20602086    return !cannotCache;
    20612087}
  • trunk/WebCore/loader/FrameLoader.h

    r40012 r40286  
    461461#ifndef NDEBUG
    462462        void logCanCachePageDecision();
    463         bool logCanCacheFrameDecision();
     463        bool logCanCacheFrameDecision(int indentLevel);
    464464#endif
    465465
Note: See TracChangeset for help on using the changeset viewer.