Bug 913807 - HTTP cache v2: API+top service+integration+tests, off by default, r=michal+ehsan+mark.finkle+fabrice+mhammond+gavin

This commit is contained in:
Honza Bambas
2013-09-20 11:11:25 +02:00
parent d68fc79787
commit a55f8e6460
274 changed files with 9823 additions and 2927 deletions

View File

@@ -25,6 +25,7 @@
#include "nsArrayUtils.h"
#include "nsIArray.h"
#include "nsIVariant.h"
#include "nsILoadContextInfo.h"
#include "nsThreadUtils.h"
#include "nsISerializable.h"
#include "nsSerializationHelper.h"
@@ -2423,31 +2424,33 @@ nsOfflineCacheDevice::DiscardByAppId(int32_t appID, bool browserEntriesOnly)
rv = AppendJARIdentifier(jaridsuffix, appID, browserEntriesOnly);
NS_ENSURE_SUCCESS(rv, rv);
AutoResetStatement statement(mStatement_EnumerateApps);
rv = statement->BindUTF8StringByIndex(0, jaridsuffix);
NS_ENSURE_SUCCESS(rv, rv);
bool hasRows;
rv = statement->ExecuteStep(&hasRows);
NS_ENSURE_SUCCESS(rv, rv);
while (hasRows) {
nsAutoCString group;
rv = statement->GetUTF8String(0, group);
NS_ENSURE_SUCCESS(rv, rv);
nsCString clientID;
rv = statement->GetUTF8String(1, clientID);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIRunnable> ev =
new nsOfflineCacheDiscardCache(this, group, clientID);
rv = nsCacheService::DispatchToCacheIOThread(ev);
{
AutoResetStatement statement(mStatement_EnumerateApps);
rv = statement->BindUTF8StringByIndex(0, jaridsuffix);
NS_ENSURE_SUCCESS(rv, rv);
bool hasRows;
rv = statement->ExecuteStep(&hasRows);
NS_ENSURE_SUCCESS(rv, rv);
while (hasRows) {
nsAutoCString group;
rv = statement->GetUTF8String(0, group);
NS_ENSURE_SUCCESS(rv, rv);
nsCString clientID;
rv = statement->GetUTF8String(1, clientID);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIRunnable> ev =
new nsOfflineCacheDiscardCache(this, group, clientID);
rv = nsCacheService::DispatchToCacheIOThread(ev);
NS_ENSURE_SUCCESS(rv, rv);
rv = statement->ExecuteStep(&hasRows);
NS_ENSURE_SUCCESS(rv, rv);
}
}
if (!browserEntriesOnly) {
@@ -2462,7 +2465,7 @@ nsOfflineCacheDevice::DiscardByAppId(int32_t appID, bool browserEntriesOnly)
bool
nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI,
const nsACString &clientID,
nsILoadContext *loadContext)
nsILoadContextInfo *loadContextInfo)
{
{
MutexAutoLock lock(mLock);
@@ -2493,12 +2496,9 @@ nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI,
uint32_t appId = NECKO_NO_APP_ID;
bool isInBrowserElement = false;
if (loadContext) {
rv = loadContext->GetAppId(&appId);
NS_ENSURE_SUCCESS(rv, false);
rv = loadContext->GetIsInBrowserElement(&isInBrowserElement);
NS_ENSURE_SUCCESS(rv, false);
if (loadContextInfo) {
appId = loadContextInfo->AppId();
isInBrowserElement = loadContextInfo->IsInBrowserElement();
}
// Check the groupID we found is equal to groupID based
@@ -2518,7 +2518,7 @@ nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI,
nsresult
nsOfflineCacheDevice::ChooseApplicationCache(const nsACString &key,
nsILoadContext *loadContext,
nsILoadContextInfo *loadContextInfo,
nsIApplicationCache **out)
{
*out = nullptr;
@@ -2546,7 +2546,7 @@ nsOfflineCacheDevice::ChooseApplicationCache(const nsACString &key,
rv = statement->GetUTF8String(0, clientID);
NS_ENSURE_SUCCESS(rv, rv);
if (CanUseCache(keyURI, clientID, loadContext)) {
if (CanUseCache(keyURI, clientID, loadContextInfo)) {
return GetApplicationCache(clientID, out);
}
}
@@ -2578,7 +2578,7 @@ nsOfflineCacheDevice::ChooseApplicationCache(const nsACString &key,
rv = nsstatement->GetUTF8String(0, clientID);
NS_ENSURE_SUCCESS(rv, rv);
if (CanUseCache(keyURI, clientID, loadContext)) {
if (CanUseCache(keyURI, clientID, loadContextInfo)) {
return GetApplicationCache(clientID, out);
}
}