Files
roytam1 c317230594 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1242724: add an export of runnable_utils.h unless/until it gets moved to xpcom/mfbt r=glandium (1d5e839f99)
- Bug 1223240 - Make it easier to set up top-level protocols (r=jld) (3beaf4a6fa)
- Bug 1194259: Make ICE IP restriction to default routes work in E10S r=jesup,mcmanus,drno (cbe463cf27)
- Bug 1239584, Part 1 - Add nsIPushNotifier and nsIPushMessage interfaces. r=dragana (7b71518e7d)
- Bug 1239584, Part 2 - Remove message manager usage from `PushService.jsm`. r=dragana (f76ab36278)
- Bug 1210211 - Part 3: Test for push notification quota with web notifications. r=kitcambridge (f37472f9b2)
- Bug 1189998, Part 3 - Update consolidated Push tests. r=mt (fae3b02e6e)
- Bug 1225968 - Refactor data delivery tests to support addition of new tests, r=kitcambridge (3163083135)
- Bug 1225968 - Adding more messages to the push message tests, r=kitcambridge (7e1bac99ba)
- Bug 1239558 - Exempt system Push subscriptions from quota and permissions checks. r=dragana (0dd8399414)
- Bug 1239584, Part 3 - Update tests. r=dragana (937e339387)
- Bug 1165256 - Make appcache fully work with OriginAttribues. r=jduell (91d666752a)
- reapply Bug 1232506: Make dom/devicestorage really work with e10s. r=alchen (bd77941ea9)
- Bug 1236433 - Part 1: Provide a Native Wrapper to Allow Fallback Whenproperty_get/set is Unavailable; r=edgar (f9026a7f50)
- Bug 1168959 - Memory-safety bugs in NetworkUtils.cpp generally. r=fabrice (13c6c14168)
- Bug 1236433 - Part 2: Adopt Wrapper in Network Utilities; r=edgar (dde58ea083)
- Bug 1209654 - Modify the type of the threshold of addAlarm() and getAllAlarms() to long long from long, and add test cases. r=ettseng, r=bz (79c7e31440)
- Bug 1000040 - Part 1: Add required APIs for Ethernet; r=vicamo,bholley (fcff7c8078)
- Bug 1231306 - Handle plugin state changes correctly in content process (r=jimm) (1f2daa6ad4)
- Bug 1213454: Ensure that mSupportsAsyncInit is propagated from content process; r=jimm (e86f36fe0a)
- Bug 1246574 - Store sandbox level to nsPluginTag for e10s. r=jimm (04617c8d28)
- Bug 1201904 - Force windowless mode for Flash when sandbox level >= 2. r=bsmedberg (662c6612a2)
- Bug 1233619 (part 1) - Remove unneeded gfxContext argument from EndUpdate() and EndUpdateBackground() functions. r=roc. (1f74728aec)
- Bug 1233619 (part 2) - Moz2Dify BeginUpdate() and BeginUpdateBackground() functions. r=roc. (36accc1499)
- Bug 1243656 - Use async for RequestCommitOrCancel. r=masayuki (aa57ea37dc)
- Bug 1243268 - Support ImmSetCandidateWindow(CFS_EXCLUDE) on plugin process. r=masayuki (78975bd3e4)
- Bug 1235573 - Don't post GCS_RESULTSTR when plugin doesn't handle WM_IME_COMPOSITION correctly. r=masayuki (11690062a3)
- Bug 1173371 Part 1: Take Chromium commit 0e49d029d5a1a25d971880b9e44d67ac70b31a80 for sandbox code. r=aklotz (517cb91822)
- Bug 1157864 - Record chromium patch applied in previous commit. r=me (dc1e63191b)
- Bug 1173371 Part 2: Change Chromium sandbox to allow rules for files on network drives to be added. a=aklotz (2bd72777e5)
- Bug 1173371 Part 3: Add sandbox policy rule to allow read access to the Firefox program directory when it is on a network drive. r=aklotz (c0a180d4b8)
- Bug 1244774: Correct wchar_t/char16_t VS2015 compilation problem caused by patches for bug 1173371. r=jimm (d5326694f8)
2023-08-17 14:45:22 +08:00

170 lines
4.7 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CacheLog.h"
#include "AppCacheStorage.h"
#include "CacheStorageService.h"
#include "OldWrappers.h"
#include "nsICacheEntryDoomCallback.h"
#include "nsCacheService.h"
#include "nsIApplicationCache.h"
#include "nsIApplicationCacheService.h"
#include "nsIURI.h"
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
namespace mozilla {
namespace net {
NS_IMPL_ISUPPORTS_INHERITED0(AppCacheStorage, CacheStorage)
AppCacheStorage::AppCacheStorage(nsILoadContextInfo* aInfo,
nsIApplicationCache* aAppCache)
: CacheStorage(aInfo, true /* disk */, false /* lookup app cache */, false /* skip size check */, false /* pin */)
, mAppCache(aAppCache)
{
MOZ_COUNT_CTOR(AppCacheStorage);
}
AppCacheStorage::~AppCacheStorage()
{
ProxyReleaseMainThread(mAppCache);
MOZ_COUNT_DTOR(AppCacheStorage);
}
NS_IMETHODIMP AppCacheStorage::AsyncOpenURI(nsIURI *aURI,
const nsACString & aIdExtension,
uint32_t aFlags,
nsICacheEntryOpenCallback *aCallback)
{
if (!CacheStorageService::Self())
return NS_ERROR_NOT_INITIALIZED;
NS_ENSURE_ARG(aURI);
NS_ENSURE_ARG(aCallback);
nsresult rv;
nsCOMPtr<nsIApplicationCache> appCache = mAppCache;
if (!appCache) {
rv = ChooseApplicationCache(aURI, getter_AddRefs(appCache));
NS_ENSURE_SUCCESS(rv, rv);
}
if (!appCache) {
LOG(("AppCacheStorage::AsyncOpenURI entry not found in any appcache, giving up"));
aCallback->OnCacheEntryAvailable(nullptr, false, nullptr, NS_ERROR_CACHE_KEY_NOT_FOUND);
return NS_OK;
}
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString cacheKey;
rv = noRefURI->GetAsciiSpec(cacheKey);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString scheme;
rv = noRefURI->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<_OldCacheLoad> appCacheLoad =
new _OldCacheLoad(scheme, cacheKey, aCallback, appCache,
LoadInfo(), WriteToDisk(), aFlags);
rv = appCacheLoad->Start();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMETHODIMP AppCacheStorage::OpenTruncate(nsIURI *aURI, const nsACString & aIdExtension,
nsICacheEntry **aCacheEntry)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP AppCacheStorage::Exists(nsIURI *aURI, const nsACString & aIdExtension,
bool *aResult)
{
*aResult = false;
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP AppCacheStorage::AsyncDoomURI(nsIURI *aURI, const nsACString & aIdExtension,
nsICacheEntryDoomCallback* aCallback)
{
if (!CacheStorageService::Self())
return NS_ERROR_NOT_INITIALIZED;
if (!mAppCache) {
return NS_ERROR_NOT_AVAILABLE;
}
RefPtr<_OldStorage> old = new _OldStorage(
LoadInfo(), WriteToDisk(), LookupAppCache(), true, mAppCache);
return old->AsyncDoomURI(aURI, aIdExtension, aCallback);
}
NS_IMETHODIMP AppCacheStorage::AsyncEvictStorage(nsICacheEntryDoomCallback* aCallback)
{
if (!CacheStorageService::Self())
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
if (!mAppCache) {
// Discard everything under this storage context
nsCOMPtr<nsIApplicationCacheService> appCacheService =
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = appCacheService->Evict(LoadInfo());
NS_ENSURE_SUCCESS(rv, rv);
} else {
// Discard the group
RefPtr<_OldStorage> old = new _OldStorage(
LoadInfo(), WriteToDisk(), LookupAppCache(), true, mAppCache);
rv = old->AsyncEvictStorage(aCallback);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
if (aCallback)
aCallback->OnCacheEntryDoomed(NS_OK);
return NS_OK;
}
NS_IMETHODIMP AppCacheStorage::AsyncVisitStorage(nsICacheStorageVisitor* aVisitor,
bool aVisitEntries)
{
if (!CacheStorageService::Self())
return NS_ERROR_NOT_INITIALIZED;
LOG(("AppCacheStorage::AsyncVisitStorage [this=%p, cb=%p]", this, aVisitor));
nsresult rv;
nsCOMPtr<nsICacheService> serv =
do_GetService(NS_CACHESERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<_OldVisitCallbackWrapper> cb = new _OldVisitCallbackWrapper(
"offline", aVisitor, aVisitEntries, LoadInfo());
rv = nsCacheService::GlobalInstance()->VisitEntriesInternal(cb);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
} // namespace net
} // namespace mozilla