summaryrefslogtreecommitdiff
path: root/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/loader/appcache/ApplicationCacheGroup.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/loader/appcache/ApplicationCacheGroup.h')
-rw-r--r--Source/WebCore/loader/appcache/ApplicationCacheGroup.h100
1 files changed, 46 insertions, 54 deletions
diff --git a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
index e1fb198ed..ceb83dfc6 100644
--- a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
+++ b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,13 +23,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef ApplicationCacheGroup_h
-#define ApplicationCacheGroup_h
+#pragma once
#include "DOMApplicationCache.h"
#include "URL.h"
#include "ResourceHandleClient.h"
-#include "SharedBuffer.h"
#include <wtf/Noncopyable.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
@@ -39,6 +37,7 @@ namespace WebCore {
class ApplicationCache;
class ApplicationCacheResource;
+class ApplicationCacheStorage;
class Document;
class DocumentLoader;
class Frame;
@@ -50,10 +49,11 @@ enum ApplicationCacheUpdateOption {
ApplicationCacheUpdateWithoutBrowsingContext
};
-class ApplicationCacheGroup : ResourceHandleClient {
- WTF_MAKE_NONCOPYABLE(ApplicationCacheGroup); WTF_MAKE_FAST_ALLOCATED;
+class ApplicationCacheGroup final : private ResourceHandleClient {
+ WTF_MAKE_NONCOPYABLE(ApplicationCacheGroup);
+ WTF_MAKE_FAST_ALLOCATED;
public:
- ApplicationCacheGroup(const URL& manifestURL, bool isCopy = false);
+ explicit ApplicationCacheGroup(Ref<ApplicationCacheStorage>&&, const URL& manifestURL);
virtual ~ApplicationCacheGroup();
enum UpdateStatus { Idle, Checking, Downloading };
@@ -61,11 +61,12 @@ public:
static ApplicationCache* cacheForMainRequest(const ResourceRequest&, DocumentLoader*);
static ApplicationCache* fallbackCacheForMainRequest(const ResourceRequest&, DocumentLoader*);
- static void selectCache(Frame*, const URL& manifestURL);
- static void selectCacheWithoutManifestURL(Frame*);
-
+ static void selectCache(Frame&, const URL& manifestURL);
+ static void selectCacheWithoutManifestURL(Frame&);
+
+ ApplicationCacheStorage& storage() { return m_storage; }
const URL& manifestURL() const { return m_manifestURL; }
- const SecurityOrigin* origin() const { return m_origin.get(); }
+ const SecurityOrigin& origin() const { return m_origin.get(); }
UpdateStatus updateStatus() const { return m_updateStatus; }
void setUpdateStatus(UpdateStatus status);
@@ -73,46 +74,44 @@ public:
unsigned storageID() const { return m_storageID; }
void clearStorageID();
- void update(Frame*, ApplicationCacheUpdateOption); // FIXME: Frame should not be needed when updating without browsing context.
- void cacheDestroyed(ApplicationCache*);
+ void update(Frame&, ApplicationCacheUpdateOption); // FIXME: Frame should not be needed when updating without browsing context.
+ void cacheDestroyed(ApplicationCache&);
- void abort(Frame*);
+ void abort(Frame&);
- bool cacheIsBeingUpdated(const ApplicationCache* cache) const { return cache == m_cacheBeingUpdated; }
+ bool cacheIsComplete(ApplicationCache& cache) { return m_caches.contains(&cache); }
- void stopLoadingInFrame(Frame*);
+ void stopLoadingInFrame(Frame&);
ApplicationCache* newestCache() const { return m_newestCache.get(); }
- void setNewestCache(PassRefPtr<ApplicationCache>);
+ void setNewestCache(Ref<ApplicationCache>&&);
void makeObsolete();
bool isObsolete() const { return m_isObsolete; }
- void finishedLoadingMainResource(DocumentLoader*);
- void failedLoadingMainResource(DocumentLoader*);
-
- void disassociateDocumentLoader(DocumentLoader*);
+ void finishedLoadingMainResource(DocumentLoader&);
+ void failedLoadingMainResource(DocumentLoader&);
- bool isCopy() const { return m_isCopy; }
+ void disassociateDocumentLoader(DocumentLoader&);
private:
- static void postListenerTask(ApplicationCacheHost::EventID id, const HashSet<DocumentLoader*>& set) { postListenerTask(id, 0, 0, set); }
- static void postListenerTask(ApplicationCacheHost::EventID id, DocumentLoader* loader) { postListenerTask(id, 0, 0, loader); }
- static void postListenerTask(ApplicationCacheHost::EventID, int progressTotal, int progressDone, const HashSet<DocumentLoader*>&);
- static void postListenerTask(ApplicationCacheHost::EventID, int progressTotal, int progressDone, DocumentLoader*);
+ static void postListenerTask(const AtomicString& eventType, const HashSet<DocumentLoader*>& set) { postListenerTask(eventType, 0, 0, set); }
+ static void postListenerTask(const AtomicString& eventType, DocumentLoader& loader) { postListenerTask(eventType, 0, 0, loader); }
+ static void postListenerTask(const AtomicString& eventType, int progressTotal, int progressDone, const HashSet<DocumentLoader*>&);
+ static void postListenerTask(const AtomicString& eventType, int progressTotal, int progressDone, DocumentLoader&);
void scheduleReachedMaxAppCacheSizeCallback();
- PassRefPtr<ResourceHandle> createResourceHandle(const URL&, ApplicationCacheResource* newestCachedResource);
+ RefPtr<ResourceHandle> createResourceHandle(const URL&, ApplicationCacheResource* newestCachedResource);
// For normal resource loading, WebKit client is asked about each resource individually. Since application cache does not belong to any particular document,
// the existing client callback cannot be used, so assume that any client that enables application cache also wants it to use credential storage.
- virtual bool shouldUseCredentialStorage(ResourceHandle*) override { return true; }
+ bool shouldUseCredentialStorage(ResourceHandle*) override { return true; }
- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) override;
- virtual void didReceiveData(ResourceHandle*, const char*, unsigned length, int encodedDataLength) override;
- virtual void didFinishLoading(ResourceHandle*, double finishTime) override;
- virtual void didFail(ResourceHandle*, const ResourceError&) override;
+ void didReceiveResponse(ResourceHandle*, ResourceResponse&&) override;
+ void didReceiveData(ResourceHandle*, const char*, unsigned length, int encodedDataLength) override;
+ void didFinishLoading(ResourceHandle*, double finishTime) override;
+ void didFail(ResourceHandle*, const ResourceError&) override;
void didReceiveManifestResponse(const ResourceResponse&);
void didReceiveManifestData(const char*, int);
@@ -132,10 +131,12 @@ private:
void associateDocumentLoaderWithCache(DocumentLoader*, ApplicationCache*);
void stopLoading();
-
+
+ Ref<ApplicationCacheStorage> m_storage;
+
URL m_manifestURL;
- RefPtr<SecurityOrigin> m_origin;
- UpdateStatus m_updateStatus;
+ Ref<SecurityOrigin> m_origin;
+ UpdateStatus m_updateStatus { Idle };
// This is the newest complete cache in the group.
RefPtr<ApplicationCache> m_newestCache;
@@ -150,26 +151,25 @@ private:
// List of pending master entries, used during the update process to ensure that new master entries are cached.
HashSet<DocumentLoader*> m_pendingMasterResourceLoaders;
// How many of the above pending master entries have not yet finished downloading.
- int m_downloadingPendingMasterResourceLoadersCount;
+ int m_downloadingPendingMasterResourceLoadersCount { 0 };
// These are all the document loaders that are associated with a cache in this group.
HashSet<DocumentLoader*> m_associatedDocumentLoaders;
// The URLs and types of pending cache entries.
- typedef HashMap<String, unsigned> EntryMap;
- EntryMap m_pendingEntries;
+ HashMap<String, unsigned> m_pendingEntries;
// The total number of items to be processed to update the cache group and the number that have been done.
- int m_progressTotal;
- int m_progressDone;
+ int m_progressTotal { 0 };
+ int m_progressDone { 0 };
// Frame used for fetching resources when updating.
// FIXME: An update started by a particular frame should not stop if it is destroyed, but there are other frames associated with the same cache group.
- Frame* m_frame;
+ Frame* m_frame { nullptr };
// An obsolete cache group is never stored, but the opposite is not true - storing may fail for multiple reasons, such as exceeding disk quota.
- unsigned m_storageID;
- bool m_isObsolete;
+ unsigned m_storageID { 0 };
+ bool m_isObsolete { false };
// During update, this is used to handle asynchronously arriving results.
enum CompletionType {
@@ -178,32 +178,24 @@ private:
Failure,
Completed
};
- CompletionType m_completionType;
-
- // Whether this cache group is a copy that's only used for transferring the cache to another file.
- bool m_isCopy;
+ CompletionType m_completionType { None };
// This flag is set immediately after the ChromeClient::reachedMaxAppCacheSize() callback is invoked as a result of the storage layer failing to save a cache
// due to reaching the maximum size of the application cache database file. This flag is used by ApplicationCacheGroup::checkIfLoadIsComplete() to decide
// the course of action in case of this failure (i.e. call the ChromeClient callback or run the failure steps).
- bool m_calledReachedMaxAppCacheSize;
+ bool m_calledReachedMaxAppCacheSize { false };
RefPtr<ResourceHandle> m_currentHandle;
RefPtr<ApplicationCacheResource> m_currentResource;
-
-#if ENABLE(INSPECTOR)
unsigned long m_currentResourceIdentifier;
-#endif
RefPtr<ApplicationCacheResource> m_manifestResource;
RefPtr<ResourceHandle> m_manifestHandle;
int64_t m_availableSpaceInQuota;
- bool m_originQuotaExceededPreviously;
+ bool m_originQuotaExceededPreviously { false };
friend class ChromeClientCallbackTimer;
};
} // namespace WebCore
-
-#endif // ApplicationCacheGroup_h