ApplicationCacheGroup.h [plain text]
#ifndef ApplicationCacheGroup_h
#define ApplicationCacheGroup_h
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
#include <wtf/Noncopyable.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include "KURL.h"
#include "PlatformString.h"
#include "ResourceHandle.h"
#include "ResourceHandleClient.h"
#include "SharedBuffer.h"
namespace WebCore {
class ApplicationCache;
class ApplicationCacheResource;
class DOMApplicationCache;
class Document;
class DocumentLoader;
class Frame;
class ApplicationCacheGroup : Noncopyable, ResourceHandleClient {
public:
ApplicationCacheGroup(const KURL& manifestURL);
~ApplicationCacheGroup();
enum Status { Idle, Checking, Downloading };
static ApplicationCache* cacheForMainRequest(const ResourceRequest&, DocumentLoader*);
static void selectCache(Frame*, const KURL& manifestURL);
static void selectCacheWithoutManifestURL(Frame*);
const KURL& manifestURL() const { return m_manifestURL; }
Status status() const { return m_status; }
void setStorageID(unsigned storageID) { m_storageID = storageID; }
unsigned storageID() const { return m_storageID; }
void clearStorageID();
void update(Frame*);
void cacheDestroyed(ApplicationCache*);
ApplicationCache* newestCache() const { return m_newestCache.get(); }
ApplicationCache* savedNewestCachePointer() const { return m_savedNewestCachePointer; }
void finishedLoadingMainResource(DocumentLoader*);
void failedLoadingMainResource(DocumentLoader*);
void documentLoaderDestroyed(DocumentLoader*);
void setNewestCache(PassRefPtr<ApplicationCache> newestCache);
private:
typedef void (DOMApplicationCache::*ListenerFunction)();
void callListenersOnAssociatedDocuments(ListenerFunction);
void callListeners(ListenerFunction, const Vector<RefPtr<DocumentLoader> >& loaders);
virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived);
virtual void didFinishLoading(ResourceHandle*);
virtual void didFail(ResourceHandle*, const ResourceError&);
void didReceiveManifestResponse(const ResourceResponse&);
void didReceiveManifestData(const char*, int);
void didFinishLoadingManifest();
void didFailToLoadManifest();
void startLoadingEntry();
void checkIfLoadIsComplete();
void cacheUpdateFailed();
void addEntry(const String&, unsigned type);
void associateDocumentLoaderWithCache(DocumentLoader*, ApplicationCache*);
void stopLoading();
KURL m_manifestURL;
Status m_status;
RefPtr<ApplicationCache> m_newestCache;
ApplicationCache* m_savedNewestCachePointer;
HashSet<ApplicationCache*> m_caches;
RefPtr<ApplicationCache> m_cacheBeingUpdated;
HashSet<DocumentLoader*> m_cacheCandidates;
HashSet<DocumentLoader*> m_associatedDocumentLoaders;
typedef HashMap<String, unsigned> EntryMap;
EntryMap m_pendingEntries;
Frame* m_frame;
unsigned m_storageID;
RefPtr<ResourceHandle> m_currentHandle;
RefPtr<ApplicationCacheResource> m_currentResource;
RefPtr<ApplicationCacheResource> m_manifestResource;
RefPtr<ResourceHandle> m_manifestHandle;
unsigned m_loadedSize;
};
}
#endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
#endif // ApplicationCacheGroup_h