diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index e2316821f833..ec764dcdffd8 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -101,7 +101,6 @@ #include "mozilla/dom/ipc/ProcessPriorityManager.h" #include "nsPermissionManager.h" #include "nsCookieService.h" -#include "nsApplicationCacheService.h" extern void NS_ShutdownChainItemPool(); @@ -258,7 +257,6 @@ nsLayoutStatics::Initialize() nsPermissionManager::AppUninstallObserverInit(); nsCookieService::AppUninstallObserverInit(); - nsApplicationCacheService::AppClearDataObserverInit(); nsDOMStorageBaseDB::Init(); diff --git a/netwerk/base/public/nsIApplicationCacheService.idl b/netwerk/base/public/nsIApplicationCacheService.idl index 5bdcef4f3919..3596f98a2eb1 100644 --- a/netwerk/base/public/nsIApplicationCacheService.idl +++ b/netwerk/base/public/nsIApplicationCacheService.idl @@ -15,7 +15,7 @@ interface nsILoadContext; * The application cache service manages the set of application cache * groups. */ -[scriptable, uuid(1750F671-0170-4d3f-A836-455501141E32)] +[scriptable, uuid(F94DB1CC-AB56-480b-8F86-40748878557E)] interface nsIApplicationCacheService : nsISupports { /** @@ -62,20 +62,6 @@ interface nsIApplicationCacheService : nsISupports */ void deactivateGroup(in ACString group); - /** - * Deletes some or all of an application's cache entries. - * - * @param appId - * The mozIApplication.localId of the application. - * - * @param discardOnlyBrowserEntries - * If true, only entries marked as 'inBrowserElement' are deleted - * (this is used by browser applications to delete user browsing - * data/history.). If false, *all* entries for the given appId are - * deleted (this is used for application uninstallation). - */ - void discardByAppId(in int32_t appID, in boolean discardOnlyBrowserEntries); - /** * Try to find the best application cache to serve a resource. */ diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index 0229e5efe62f..923b5cd09f57 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -77,7 +77,6 @@ #include "nsILoadContext.h" #include "mozilla/Services.h" #include "nsIPrivateBrowsingChannel.h" -#include "mozIApplicationClearPrivateDataParams.h" #include @@ -1335,46 +1334,6 @@ NS_GetAppInfo(nsIChannel *aChannel, uint32_t *aAppID, bool *aIsInBrowserElement) return true; } -#define TOPIC_WEB_APP_CLEAR_DATA "webapps-clear-data" - -/** - * Gets appId and browserOnly parameters from the TOPIC_WEB_APP_CLEAR_DATA - * nsIObserverService notification. Used when clearing user data or - * uninstalling web apps. - */ -inline nsresult -NS_GetAppInfoFromClearDataNotification(nsISupports *aSubject, - uint32_t *aAppID, bool* aBrowserOnly) -{ - nsresult rv; - - nsCOMPtr - clearParams(do_QueryInterface(aSubject)); - MOZ_ASSERT(clearParams); - if (!clearParams) { - return NS_ERROR_UNEXPECTED; - } - - uint32_t appId; - rv = clearParams->GetAppId(&appId); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - MOZ_ASSERT(appId != NECKO_NO_APP_ID); - MOZ_ASSERT(appId != NECKO_UNKNOWN_APP_ID); - NS_ENSURE_SUCCESS(rv, rv); - if (appId == NECKO_NO_APP_ID || appId == NECKO_UNKNOWN_APP_ID) { - return NS_ERROR_UNEXPECTED; - } - - bool browserOnly = false; - rv = clearParams->GetBrowserOnly(&browserOnly); - MOZ_ASSERT(NS_SUCCEEDED(rv)); - NS_ENSURE_SUCCESS(rv, rv); - - *aAppID = appId; - *aBrowserOnly = browserOnly; - return NS_OK; -} - /** * Wraps an nsIAuthPrompt so that it can be used as an nsIAuthPrompt2. This * method is provided mainly for use by other methods in this file. diff --git a/netwerk/cache/Makefile.in b/netwerk/cache/Makefile.in index 8c6b9a8d2d40..f525a9a85be5 100644 --- a/netwerk/cache/Makefile.in +++ b/netwerk/cache/Makefile.in @@ -30,7 +30,6 @@ XPIDLSRCS = \ EXPORTS = \ nsCacheService.h \ - nsApplicationCacheService.h \ $(NULL) CPPSRCS = \ diff --git a/netwerk/cache/nsApplicationCacheService.cpp b/netwerk/cache/nsApplicationCacheService.cpp index 89e3ebb71e23..95708c81829d 100644 --- a/netwerk/cache/nsApplicationCacheService.cpp +++ b/netwerk/cache/nsApplicationCacheService.cpp @@ -6,18 +6,13 @@ #include "nsDiskCacheDeviceSQL.h" #include "nsCacheService.h" #include "nsApplicationCacheService.h" -#include "nsCRT.h" + #include "nsNetUtil.h" -#include "nsIObserverService.h" using namespace mozilla; static NS_DEFINE_CID(kCacheServiceCID, NS_CACHESERVICE_CID); -//----------------------------------------------------------------------------- -// nsApplicationCacheService -//----------------------------------------------------------------------------- - NS_IMPL_ISUPPORTS1(nsApplicationCacheService, nsIApplicationCacheService) nsApplicationCacheService::nsApplicationCacheService() @@ -134,18 +129,6 @@ nsApplicationCacheService::CacheOpportunistically(nsIApplicationCache* cache, return device->CacheOpportunistically(cache, key); } -NS_IMETHODIMP -nsApplicationCacheService::DiscardByAppId(int32_t appID, bool isInBrowser) -{ - if (!mCacheService) - return NS_ERROR_UNEXPECTED; - - nsRefPtr device; - nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device)); - NS_ENSURE_SUCCESS(rv, rv); - return device->DiscardByAppId(appID, isInBrowser); -} - NS_IMETHODIMP nsApplicationCacheService::GetGroups(uint32_t *count, char ***keys) @@ -171,53 +154,3 @@ nsApplicationCacheService::GetGroupsTimeOrdered(uint32_t *count, NS_ENSURE_SUCCESS(rv, rv); return device->GetGroupsTimeOrdered(count, keys); } - -//----------------------------------------------------------------------------- -// AppCacheClearDataObserver: handles clearing appcache data for app uninstall -// and clearing user data events. -//----------------------------------------------------------------------------- - -namespace { - -class AppCacheClearDataObserver MOZ_FINAL : public nsIObserver { -public: - NS_DECL_ISUPPORTS - - // nsIObserver implementation. - NS_IMETHODIMP - Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) - { - MOZ_ASSERT(!nsCRT::strcmp(aTopic, TOPIC_WEB_APP_CLEAR_DATA)); - - uint32_t appId = NECKO_UNKNOWN_APP_ID; - bool browserOnly = false; - nsresult rv = NS_GetAppInfoFromClearDataNotification(aSubject, &appId, - &browserOnly); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr cacheService = - do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - return cacheService->DiscardByAppId(appId, browserOnly); - } -}; - -NS_IMPL_ISUPPORTS1(AppCacheClearDataObserver, nsIObserver) - -} // anonymous namespace - -// Instantiates and registers AppCacheClearDataObserver for notifications -void -nsApplicationCacheService::AppClearDataObserverInit() -{ - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1"); - if (observerService) { - nsRefPtr obs - = new AppCacheClearDataObserver(); - observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA, - /*holdsWeak=*/ false); - } -} - diff --git a/netwerk/cache/nsApplicationCacheService.h b/netwerk/cache/nsApplicationCacheService.h index 4580f5cbb18b..228fa3ddb7fd 100644 --- a/netwerk/cache/nsApplicationCacheService.h +++ b/netwerk/cache/nsApplicationCacheService.h @@ -5,11 +5,8 @@ #ifndef _nsApplicationCacheService_h_ #define _nsApplicationCacheService_h_ -#include "nsIApplicationCacheService.h" #include "mozilla/Attributes.h" -class nsCacheService; - class nsApplicationCacheService MOZ_FINAL : public nsIApplicationCacheService { public: @@ -17,9 +14,6 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIAPPLICATIONCACHESERVICE - - static void AppClearDataObserverInit(); - private: nsresult GetJARIdentifier(nsIURI *aURI, nsILoadContext *aLoadContext, diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index c503cdc6617c..edb34763f9b7 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -1215,7 +1215,6 @@ nsOfflineCacheDevice::Init() " AND NameSpace <= ?2 AND ?2 GLOB NameSpace || '*'" " ORDER BY NameSpace DESC;"), StatementSql ( mStatement_InsertNamespaceEntry, "INSERT INTO moz_cache_namespaces (ClientID, NameSpace, Data, ItemType) VALUES(?, ?, ?, ?);"), - StatementSql ( mStatement_EnumerateApps, "SELECT GroupID, ActiveClientID FROM moz_cache_groups WHERE GroupID LIKE ?1;"), StatementSql ( mStatement_EnumerateGroups, "SELECT GroupID, ActiveClientID FROM moz_cache_groups;"), StatementSql ( mStatement_EnumerateGroupsTimeOrder, "SELECT GroupID, ActiveClientID FROM moz_cache_groups ORDER BY ActivateTimeStamp;") }; @@ -1246,17 +1245,6 @@ GetGroupForCache(const nsCSubstring &clientID, nsCString &group) return NS_OK; } -nsresult -AppendJARIdentifier(nsACString &_result, int32_t appId, bool isInBrowserElement) -{ - _result.Append('#'); - _result.AppendInt(appId); - _result.Append('+'); - _result.Append(isInBrowserElement ? 't' : 'f'); - - return NS_OK; -} - nsresult GetJARIdentifier(nsIURI *aURI, nsILoadContext *aLoadContext, @@ -1283,7 +1271,11 @@ GetJARIdentifier(nsIURI *aURI, return NS_OK; // This load context has some special attributes, create a jar identifier - return AppendJARIdentifier(_result, appId, isInBrowserElement); + _result.AppendInt(appId); + _result.Append('+'); + _result.Append(isInBrowserElement ? 't' : 'f'); + + return NS_OK; } } // anon namespace @@ -1309,8 +1301,10 @@ nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL, NS_ENSURE_SUCCESS(rv, rv); // Include JAR ID, i.e. the extended origin if present. - if (!jarid.IsEmpty()) + if (!jarid.IsEmpty()) { + _result.Append('#'); _result.Append(jarid); + } return NS_OK; } @@ -2368,52 +2362,6 @@ nsOfflineCacheDevice::DeactivateGroup(const nsACString &group) return NS_OK; } -nsresult -nsOfflineCacheDevice::DiscardByAppId(int32_t appID, bool browserEntriesOnly) -{ - nsresult rv; - - nsAutoCString jaridsuffix; - jaridsuffix.Append('%'); - 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 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) { - // If deleting app, delete any 'inBrowserElement' entries too - rv = DiscardByAppId(appID, true); - NS_ENSURE_SUCCESS(rv, rv); - } - - return NS_OK; -} - bool nsOfflineCacheDevice::CanUseCache(nsIURI *keyURI, const nsACString &clientID, diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.h b/netwerk/cache/nsDiskCacheDeviceSQL.h index 5dbb49bfbf0f..04e442d88b2f 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.h +++ b/netwerk/cache/nsDiskCacheDeviceSQL.h @@ -158,8 +158,6 @@ public: nsresult CacheOpportunistically(nsIApplicationCache* cache, const nsACString &key); - nsresult DiscardByAppId(int32_t appID, bool isInBrowser); - nsresult GetGroups(uint32_t *count,char ***keys); nsresult GetGroupsTimeOrdered(uint32_t *count, @@ -259,7 +257,6 @@ private: nsCOMPtr mStatement_DeactivateGroup; nsCOMPtr mStatement_FindClient; nsCOMPtr mStatement_FindClientByNamespace; - nsCOMPtr mStatement_EnumerateApps; nsCOMPtr mStatement_EnumerateGroups; nsCOMPtr mStatement_EnumerateGroupsTimeOrder;