ApplicationCache.h [plain text]
#ifndef ApplicationCache_h
#define ApplicationCache_h
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include "StringHash.h"
#include "PlatformString.h"
namespace WebCore {
class ApplicationCacheGroup;
class ApplicationCacheResource;
class DocumentLoader;
class KURL;
class ResourceRequest;
class ApplicationCache : public RefCounted<ApplicationCache> {
public:
static PassRefPtr<ApplicationCache> create() { return new ApplicationCache; }
~ApplicationCache();
void addResource(PassRefPtr<ApplicationCacheResource> resource);
unsigned removeResource(const String& url);
void setManifestResource(PassRefPtr<ApplicationCacheResource> manifest);
ApplicationCacheResource* manifestResource() const { return m_manifest; }
void setGroup(ApplicationCacheGroup*);
ApplicationCacheGroup* group() const { return m_group; }
ApplicationCacheResource* resourceForRequest(const ResourceRequest&);
ApplicationCacheResource* resourceForURL(const String& url);
unsigned numDynamicEntries() const;
String dynamicEntry(unsigned index) const;
bool addDynamicEntry(const String& url);
void removeDynamicEntry(const String& url);
void setOnlineWhitelist(const HashSet<String>& onlineWhitelist);
const HashSet<String>& onlineWhitelist() const { return m_onlineWhitelist; }
bool isURLInOnlineWhitelist(const KURL&);
#ifndef NDEBUG
void dump();
#endif
typedef HashMap<String, RefPtr<ApplicationCacheResource> > ResourceMap;
ResourceMap::const_iterator begin() const { return m_resources.begin(); }
ResourceMap::const_iterator end() const { return m_resources.end(); }
void setStorageID(unsigned storageID) { m_storageID = storageID; }
unsigned storageID() const { return m_storageID; }
void clearStorageID();
static bool requestIsHTTPOrHTTPSGet(const ResourceRequest&);
private:
ApplicationCache();
ApplicationCacheGroup* m_group;
ResourceMap m_resources;
ApplicationCacheResource* m_manifest;
HashSet<String> m_onlineWhitelist;
unsigned m_storageID;
};
}
#endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
#endif // ApplicationCache_h