webengine/osswebengine/WebCore/loader/Cache.h
changeset 5 10e98eab6f85
parent 0 dd21522fd290
equal deleted inserted replaced
1:7c90e6132015 5:10e98eab6f85
    25 */
    25 */
    26 
    26 
    27 #ifndef Cache_h
    27 #ifndef Cache_h
    28 #define Cache_h
    28 #define Cache_h
    29 
    29 
       
    30 #include "config.h"
    30 #include "CachePolicy.h"
    31 #include "CachePolicy.h"
    31 #include "CachedResource.h"
    32 #include "CachedResource.h"
    32 #include "PlatformString.h"
    33 #include "PlatformString.h"
    33 #include "StringHash.h"
    34 #include "StringHash.h"
    34 #include "loader.h"
    35 #include "loader.h"
    37 #include <wtf/Noncopyable.h>
    38 #include <wtf/Noncopyable.h>
    38 #include <wtf/Vector.h>
    39 #include <wtf/Vector.h>
    39 
    40 
    40 namespace WebCore  {
    41 namespace WebCore  {
    41 
    42 
       
    43 class CachedCSSStyleSheet;
    42 class CachedResource;
    44 class CachedResource;
    43 class DocLoader;
    45 class DocLoader;
    44 class KURL;
    46 class KURL;
    45 
    47 
    46 // This cache holds subresources used by Web pages: images, scripts, stylesheets, etc.
    48 // This cache holds subresources used by Web pages: images, scripts, stylesheets, etc.
    92     Loader* loader() { return &m_loader; }
    94     Loader* loader() { return &m_loader; }
    93 
    95 
    94     // Request resources from the cache.  A load will be initiated and a cache object created if the object is not
    96     // Request resources from the cache.  A load will be initiated and a cache object created if the object is not
    95     // found in the cache.
    97     // found in the cache.
    96 #if PRELOAD_SCANNER_ENABLED
    98 #if PRELOAD_SCANNER_ENABLED
    97     CachedResource* requestResource(DocLoader*, CachedResource::Type, const KURL& url, const String* charset = 0, bool skipCanLoadCheck = false, bool sendResourceLoadCallbacks = true, bool isPreload = false);
    99     CachedResource* requestResource(DocLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
    98 #else
   100 #else
    99     CachedResource* requestResource(DocLoader*, CachedResource::Type, const KURL& url, const String* charset = 0, bool skipCanLoadCheck = false, bool sendResourceLoadCallbacks = true);
   101     CachedResource* requestResource(DocLoader*, CachedResource::Type, const KURL& url, const String& charset);
   100 #endif
   102 #endif
   101 
   103 
       
   104 	CachedCSSStyleSheet* requestUserCSSStyleSheet(DocLoader*, const String& url, const String& charset);
   102     // Sets the cache's memory capacities, in bytes. These will hold only approximately, 
   105     // Sets the cache's memory capacities, in bytes. These will hold only approximately, 
   103     // since the decoded cost of resources like scripts and stylesheets is not known.
   106     // since the decoded cost of resources like scripts and stylesheets is not known.
   104     //  - minDeadBytes: The maximum number of bytes that dead resources should consume when the cache is under pressure.
   107     //  - minDeadBytes: The maximum number of bytes that dead resources should consume when the cache is under pressure.
   105     //  - maxDeadBytes: The maximum number of bytes that dead resources should consume when the cache is not under pressure.
   108     //  - maxDeadBytes: The maximum number of bytes that dead resources should consume when the cache is not under pressure.
   106     //  - totalBytes: The maximum number of bytes that the cache should consume overall.
   109     //  - totalBytes: The maximum number of bytes that the cache should consume overall.
   146     // Function to collect cache statistics for the caches window in the Safari Debug menu.
   149     // Function to collect cache statistics for the caches window in the Safari Debug menu.
   147     Statistics getStatistics();
   150     Statistics getStatistics();
   148 
   151 
   149 #if PLATFORM(SYMBIAN)
   152 #if PLATFORM(SYMBIAN)
   150     void clearImages();
   153     void clearImages();
       
   154     static void deleteStaticCache();
   151 #endif
   155 #endif
   152 
   156 
   153 private:
   157 private:
   154     Cache();
   158     Cache();
       
   159 
       
   160 #if PLATFORM(SYMBIAN)
       
   161     ~Cache() {
       
   162         typedef HashMap<String, CachedResource*>::iterator ResourceIt;
       
   163         ResourceIt endIt = m_resources.end();
       
   164         for(ResourceIt it=m_resources.begin();it != endIt; ++it) {
       
   165             CachedResource* res = (*it).second;;
       
   166             delete res;
       
   167         }
       
   168     }
       
   169 #else
   155     ~Cache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
   170     ~Cache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
       
   171 #endif
   156        
   172        
   157     LRUList* lruListFor(CachedResource*);
   173     LRUList* lruListFor(CachedResource*);
   158     void resourceAccessed(CachedResource*);
   174     void resourceAccessed(CachedResource*);
   159 #ifndef NDEBUG
   175 #ifndef NDEBUG
   160     void dumpLRULists(bool includeLive) const;
   176     void dumpLRULists(bool includeLive) const;