Diff
Modified: trunk/Source/WebCore/ChangeLog (232191 => 232192)
--- trunk/Source/WebCore/ChangeLog 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebCore/ChangeLog 2018-05-25 18:40:27 UTC (rev 232192)
@@ -1,3 +1,24 @@
+2018-05-25 Chris Dumez <[email protected]>
+
+ Minor ApplicationCacheStorage clean up
+ https://bugs.webkit.org/show_bug.cgi?id=185984
+
+ Reviewed by Youenn Fablet.
+
+ * loader/appcache/ApplicationCacheStorage.cpp:
+ (WebCore::ApplicationCacheStorage::getManifestURLs):
+ (WebCore::ApplicationCacheStorage::deleteCacheGroup):
+ (WebCore::ApplicationCacheStorage::originsWithCache):
+ (WebCore::ApplicationCacheStorage::deleteAllCaches):
+ (WebCore::ApplicationCacheStorage::deleteCacheForOrigin):
+ (WebCore::ApplicationCacheStorage::ApplicationCacheStorage):
+ (WebCore::ApplicationCacheStorage::cacheDirectory const): Deleted.
+ (WebCore::ApplicationCacheStorage::cacheGroupSize): Deleted.
+ (WebCore::ApplicationCacheStorage::getOriginsWithCache): Deleted.
+ (WebCore::ApplicationCacheStorage::create): Deleted.
+ * loader/appcache/ApplicationCacheStorage.h:
+ (WebCore::ApplicationCacheStorage::create):
+
2018-05-25 Sihui Liu <[email protected]>
[WKHTTPCookieStore getAllCookies] returns inconsistent creation time
Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (232191 => 232192)
--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp 2018-05-25 18:40:27 UTC (rev 232192)
@@ -356,11 +356,6 @@
m_cacheHostSet.remove(urlHostHash(group.manifestURL()));
}
-const String& ApplicationCacheStorage::cacheDirectory() const
-{
- return m_cacheDirectory;
-}
-
void ApplicationCacheStorage::setMaximumSize(int64_t size)
{
m_maximumSize = size;
@@ -1318,54 +1313,26 @@
return true;
}
-bool ApplicationCacheStorage::getManifestURLs(Vector<URL>* urls)
+std::optional<Vector<URL>> ApplicationCacheStorage::manifestURLs()
{
SQLiteTransactionInProgressAutoCounter transactionCounter;
- ASSERT(urls);
openDatabase(false);
if (!m_database.isOpen())
- return false;
+ return std::nullopt;
SQLiteStatement selectURLs(m_database, "SELECT manifestURL FROM CacheGroups");
if (selectURLs.prepare() != SQLITE_OK)
- return false;
+ return std::nullopt;
+ Vector<URL> urls;
while (selectURLs.step() == SQLITE_ROW)
- urls->append(URL(ParsedURLString, selectURLs.getColumnText(0)));
+ urls.append(URL(ParsedURLString, selectURLs.getColumnText(0)));
- return true;
+ return WTFMove(urls);
}
-bool ApplicationCacheStorage::cacheGroupSize(const String& manifestURL, int64_t* size)
-{
- SQLiteTransactionInProgressAutoCounter transactionCounter;
-
- ASSERT(size);
- openDatabase(false);
- if (!m_database.isOpen())
- return false;
-
- SQLiteStatement statement(m_database, "SELECT sum(Caches.size) FROM Caches INNER JOIN CacheGroups ON Caches.cacheGroup=CacheGroups.id WHERE CacheGroups.manifestURL=?");
- if (statement.prepare() != SQLITE_OK)
- return false;
-
- statement.bindText(1, manifestURL);
-
- int result = statement.step();
- if (result == SQLITE_DONE)
- return false;
-
- if (result != SQLITE_ROW) {
- LOG_ERROR("Could not get the size of the cache group, error \"%s\"", m_database.lastErrorMsg());
- return false;
- }
-
- *size = statement.getColumnInt64(0);
- return true;
-}
-
bool ApplicationCacheStorage::deleteCacheGroupRecord(const String& manifestURL)
{
ASSERT(SQLiteDatabaseTracker::hasTransactionInProgress());
@@ -1403,8 +1370,7 @@
SQLiteTransaction deleteTransaction(m_database);
// Check to see if the group is in memory.
- auto* group = m_cachesInMemory.get(manifestURL);
- if (group)
+ if (auto* group = m_cachesInMemory.get(manifestURL))
cacheGroupMadeObsolete(*group);
else {
// The cache group is not in memory, so remove it from the disk.
@@ -1506,15 +1472,19 @@
return totalSize;
}
-void ApplicationCacheStorage::getOriginsWithCache(HashSet<RefPtr<SecurityOrigin>>& origins)
+Vector<Ref<SecurityOrigin>> ApplicationCacheStorage::originsWithCache()
{
- Vector<URL> urls;
- getManifestURLs(&urls);
+ auto urls = manifestURLs();
+ if (!urls)
+ return { };
// Multiple manifest URLs might share the same SecurityOrigin, so we might be creating extra, wasted origins here.
// The current schema doesn't allow for a more efficient way of building this list.
- for (auto& url : urls)
- origins.add(SecurityOrigin::create(url));
+ Vector<Ref<SecurityOrigin>> origins;
+ origins.reserveInitialCapacity(urls->size());
+ for (auto& url : *urls)
+ origins.uncheckedAppend(SecurityOrigin::create(url));
+ return origins;
}
void ApplicationCacheStorage::deleteAllEntries()
@@ -1525,11 +1495,9 @@
void ApplicationCacheStorage::deleteAllCaches()
{
- HashSet<RefPtr<SecurityOrigin>> origins;
-
- getOriginsWithCache(origins);
+ auto origins = originsWithCache();
for (auto& origin : origins)
- deleteCacheForOrigin(*origin);
+ deleteCacheForOrigin(origin);
vacuumDatabaseFile();
}
@@ -1536,8 +1504,8 @@
void ApplicationCacheStorage::deleteCacheForOrigin(const SecurityOrigin& securityOrigin)
{
- Vector<URL> urls;
- if (!getManifestURLs(&urls)) {
+ auto urls = manifestURLs();
+ if (!urls) {
LOG_ERROR("Failed to retrieve ApplicationCache manifest URLs");
return;
}
@@ -1544,7 +1512,7 @@
URL originURL(URL(), securityOrigin.toString());
- for (const auto& url : urls) {
+ for (const auto& url : *urls) {
if (!protocolHostAndPortAreEqual(url, originURL))
continue;
@@ -1565,15 +1533,7 @@
ApplicationCacheStorage::ApplicationCacheStorage(const String& cacheDirectory, const String& flatFileSubdirectoryName)
: m_cacheDirectory(cacheDirectory)
, m_flatFileSubdirectoryName(flatFileSubdirectoryName)
- , m_maximumSize(ApplicationCacheStorage::noQuota())
- , m_isMaximumSizeReached(false)
- , m_defaultOriginQuota(ApplicationCacheStorage::noQuota())
{
}
-Ref<ApplicationCacheStorage> ApplicationCacheStorage::create(const String& cacheDirectory, const String& flatFileSubdirectoryName)
-{
- return adoptRef(*new ApplicationCacheStorage(cacheDirectory, flatFileSubdirectoryName));
-}
-
-}
+} // namespace WebCore
Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h (232191 => 232192)
--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.h 2018-05-25 18:40:27 UTC (rev 232192)
@@ -51,10 +51,12 @@
DiskOrOperationFailure
};
- WEBCORE_EXPORT static Ref<ApplicationCacheStorage> create(const String& cacheDirectory, const String& flatFileSubdirectoryName);
+ static Ref<ApplicationCacheStorage> create(const String& cacheDirectory, const String& flatFileSubdirectoryName)
+ {
+ return adoptRef(*new ApplicationCacheStorage(cacheDirectory, flatFileSubdirectoryName));
+ }
- const String& cacheDirectory() const;
-
+
WEBCORE_EXPORT void setMaximumSize(int64_t size);
WEBCORE_EXPORT int64_t maximumSize() const;
bool isMaximumSizeReached() const;
@@ -72,7 +74,6 @@
ApplicationCacheGroup* fallbackCacheGroupForURL(const URL&); // Cache that has a fallback entry to load a main resource from if normal loading fails.
ApplicationCacheGroup* findOrCreateCacheGroup(const URL& manifestURL);
- ApplicationCacheGroup* findInMemoryCacheGroup(const URL& manifestURL) const;
void cacheGroupDestroyed(ApplicationCacheGroup&);
void cacheGroupMadeObsolete(ApplicationCacheGroup&);
@@ -86,12 +87,7 @@
WEBCORE_EXPORT void empty();
- bool getManifestURLs(Vector<URL>* urls);
- bool cacheGroupSize(const String& manifestURL, int64_t* size);
- bool deleteCacheGroup(const String& manifestURL);
- WEBCORE_EXPORT void vacuumDatabaseFile();
-
- WEBCORE_EXPORT void getOriginsWithCache(HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>&);
+ WEBCORE_EXPORT Vector<Ref<SecurityOrigin>> originsWithCache();
WEBCORE_EXPORT void deleteAllEntries();
// FIXME: This should be consolidated with deleteAllEntries().
@@ -107,10 +103,14 @@
static int64_t noQuota() { return std::numeric_limits<int64_t>::max(); }
private:
- ApplicationCacheStorage(const String& cacheDirectory, const String& flatFileSubdirectoryName);
+ WEBCORE_EXPORT ApplicationCacheStorage(const String& cacheDirectory, const String& flatFileSubdirectoryName);
RefPtr<ApplicationCache> loadCache(unsigned storageID);
ApplicationCacheGroup* loadCacheGroup(const URL& manifestURL);
+ std::optional<Vector<URL>> manifestURLs();
+ ApplicationCacheGroup* findInMemoryCacheGroup(const URL& manifestURL) const;
+ bool deleteCacheGroup(const String& manifestURL);
+ void vacuumDatabaseFile();
using ResourceStorageIDJournal = StorageIDJournal<ApplicationCacheResource>;
using GroupStorageIDJournal = StorageIDJournal<ApplicationCacheGroup>;
@@ -121,7 +121,7 @@
bool deleteCacheGroupRecord(const String& manifestURL);
bool ensureOriginRecord(const SecurityOrigin*);
- bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
+ static bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
void deleteTables();
bool writeDataToUniqueFileInDirectory(SharedBuffer&, const String& directory, String& outFilename, const String& fileExtension);
@@ -142,10 +142,10 @@
const String m_flatFileSubdirectoryName;
String m_cacheFile;
- int64_t m_maximumSize;
- bool m_isMaximumSizeReached;
+ int64_t m_maximumSize { noQuota() };
+ bool m_isMaximumSizeReached { false };
- int64_t m_defaultOriginQuota;
+ int64_t m_defaultOriginQuota { noQuota() };
SQLiteDatabase m_database;
Modified: trunk/Source/WebKit/ChangeLog (232191 => 232192)
--- trunk/Source/WebKit/ChangeLog 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKit/ChangeLog 2018-05-25 18:40:27 UTC (rev 232192)
@@ -1,5 +1,17 @@
2018-05-25 Chris Dumez <[email protected]>
+ Minor ApplicationCacheStorage clean up
+ https://bugs.webkit.org/show_bug.cgi?id=185984
+
+ Reviewed by Youenn Fablet.
+
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::fetchDataAndApply):
+ * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+ (WKBundlePageCopyOriginsWithApplicationCache):
+
+2018-05-25 Chris Dumez <[email protected]>
+
Avoid triggering network cache speculative revalidation for loads allowing expired content
https://bugs.webkit.org/show_bug.cgi?id=185985
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (232191 => 232192)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-05-25 18:40:27 UTC (rev 232192)
@@ -447,12 +447,11 @@
WebsiteData websiteData;
- HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
// FIXME: getOriginsWithCache should return a collection of SecurityOriginDatas.
- storage->getOriginsWithCache(origins);
+ auto origins = storage->originsWithCache();
for (auto& origin : origins) {
- uint64_t size = fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes) ? storage->diskUsageForOrigin(*origin) : 0;
+ uint64_t size = fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes) ? storage->diskUsageForOrigin(origin) : 0;
WebsiteData::Entry entry { origin->data(), WebsiteDataType::OfflineWebApplicationCache, size };
websiteData.entries.append(WTFMove(entry));
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (232191 => 232192)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp 2018-05-25 18:40:27 UTC (rev 232192)
@@ -686,8 +686,7 @@
WKArrayRef WKBundlePageCopyOriginsWithApplicationCache(WKBundlePageRef page)
{
- HashSet<RefPtr<WebCore::SecurityOrigin>> origins;
- toImpl(page)->corePage()->applicationCacheStorage().getOriginsWithCache(origins);
+ auto origins = toImpl(page)->corePage()->applicationCacheStorage().originsWithCache();
Vector<RefPtr<API::Object>> originIdentifiers;
originIdentifiers.reserveInitialCapacity(origins.size());
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (232191 => 232192)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2018-05-25 18:40:27 UTC (rev 232192)
@@ -1,3 +1,13 @@
+2018-05-25 Chris Dumez <[email protected]>
+
+ Minor ApplicationCacheStorage clean up
+ https://bugs.webkit.org/show_bug.cgi?id=185984
+
+ Reviewed by Youenn Fablet.
+
+ * WebCoreSupport/WebApplicationCache.mm:
+ (+[WebApplicationCache originsWithCache]):
+
2018-05-25 David Kilzer <[email protected]>
Fix issues with -dealloc methods found by clang static analyzer
Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebApplicationCache.mm (232191 => 232192)
--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebApplicationCache.mm 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebApplicationCache.mm 2018-05-25 18:40:27 UTC (rev 232192)
@@ -123,14 +123,12 @@
+ (NSArray *)originsWithCache
{
- HashSet<RefPtr<SecurityOrigin>> coreOrigins;
- webApplicationCacheStorage().getOriginsWithCache(coreOrigins);
+ auto coreOrigins = webApplicationCacheStorage().originsWithCache();
NSMutableArray *webOrigins = [[[NSMutableArray alloc] initWithCapacity:coreOrigins.size()] autorelease];
- HashSet<RefPtr<SecurityOrigin>>::const_iterator end = coreOrigins.end();
- for (HashSet<RefPtr<SecurityOrigin>>::const_iterator it = coreOrigins.begin(); it != end; ++it) {
- RetainPtr<WebSecurityOrigin> webOrigin = adoptNS([[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:(*it).get()]);
+ for (auto& coreOrigin : coreOrigins) {
+ auto webOrigin = adoptNS([[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:coreOrigin.ptr()]);
[webOrigins addObject:webOrigin.get()];
}
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (232191 => 232192)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2018-05-25 18:40:27 UTC (rev 232192)
@@ -1,3 +1,13 @@
+2018-05-25 Chris Dumez <[email protected]>
+
+ Minor ApplicationCacheStorage clean up
+ https://bugs.webkit.org/show_bug.cgi?id=185984
+
+ Reviewed by Youenn Fablet.
+
+ * WebApplicationCache.cpp:
+ (WebApplicationCache::originsWithCache):
+
2018-05-24 Chris Dumez <[email protected]>
Reduce copying of FontCascadeDescription objects by moving them around
Modified: trunk/Source/WebKitLegacy/win/WebApplicationCache.cpp (232191 => 232192)
--- trunk/Source/WebKitLegacy/win/WebApplicationCache.cpp 2018-05-25 18:35:13 UTC (rev 232191)
+++ trunk/Source/WebKitLegacy/win/WebApplicationCache.cpp 2018-05-25 18:40:27 UTC (rev 232192)
@@ -187,13 +187,12 @@
if (!origins)
return E_POINTER;
- HashSet<RefPtr<WebCore::SecurityOrigin>> coreOrigins;
- storage().getOriginsWithCache(coreOrigins);
+ auto coreOrigins = storage().originsWithCache();
RetainPtr<CFMutableArrayRef> arrayItem = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, coreOrigins.size(), &MarshallingHelpers::kIUnknownArrayCallBacks));
- for (auto it : coreOrigins)
- CFArrayAppendValue(arrayItem.get(), reinterpret_cast<void*>(WebSecurityOrigin::createInstance(&(*it))));
+ for (auto& coreOrigin : coreOrigins)
+ CFArrayAppendValue(arrayItem.get(), reinterpret_cast<void*>(WebSecurityOrigin::createInstance(coreOrigin.ptr())));
RetainPtr<CFMutableDictionaryRef> dictionary = adoptCF(
CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));