Backout bec7e68cad9a & a6228bc28958 (bug 786299) for Windows compilation errors on a CLOSED TREE
authorEd Morley <emorley@mozilla.com>
Sat, 29 Sep 2012 01:44:30 +0100
changeset 108693 551152b8c271020905260a9478248e7011d562af
parent 108692 b903d1d1b861078a37d37be598d3faa1347117ec
child 108694 c09a0c022b2eda4a4f5f48658d19290100d4837b
child 108696 4aa02fbdea6ec08a3131497353c969fa014adf69
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
bugs786299
milestone18.0a1
backs outbec7e68cad9af2ccf552f024d61c37352097890c
Backout bec7e68cad9a & a6228bc28958 (bug 786299) for Windows compilation errors on a CLOSED TREE
layout/build/nsLayoutStatics.cpp
netwerk/base/public/nsIApplicationCacheService.idl
netwerk/base/public/nsNetUtil.h
netwerk/cache/Makefile.in
netwerk/cache/nsApplicationCacheService.cpp
netwerk/cache/nsApplicationCacheService.h
netwerk/cache/nsDiskCacheDeviceSQL.cpp
netwerk/cache/nsDiskCacheDeviceSQL.h
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -96,17 +96,16 @@
 #include "nsDOMMutationObserver.h"
 #include "nsHyphenationManager.h"
 #include "nsEditorSpellCheck.h"
 #include "nsWindowMemoryReporter.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ipc/ProcessPriorityManager.h"
 #include "nsPermissionManager.h"
 #include "nsCookieService.h"
-#include "nsApplicationCacheService.h"
 
 extern void NS_ShutdownChainItemPool();
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 
 nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
@@ -253,17 +252,16 @@ nsLayoutStatics::Initialize()
   nsWindowMemoryReporter::Init();
 
   nsSVGUtils::Init();
 
   InitProcessPriorityManager();
 
   nsPermissionManager::AppUninstallObserverInit();
   nsCookieService::AppUninstallObserverInit();
-  nsApplicationCacheService::AppClearDataObserverInit();
 
   nsDOMStorageBaseDB::Init();
 
   return NS_OK;
 }
 
 void
 nsLayoutStatics::Shutdown()
--- a/netwerk/base/public/nsIApplicationCacheService.idl
+++ b/netwerk/base/public/nsIApplicationCacheService.idl
@@ -10,17 +10,17 @@ interface nsIApplicationCache;
 interface nsIFile;
 interface nsIURI;
 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
 {
     /**
      * Create group string identifying cache group according the manifest
      * URL and the given load context.
      */
     ACString buildGroupID(in nsIURI aManifestURL,
                           in nsILoadContext aLoadContext);
@@ -58,30 +58,16 @@ interface nsIApplicationCacheService : n
     nsIApplicationCache getActiveCache(in ACString group);
 
     /**
      * Deactivate the currently-active cache object for a cache group.
      */
     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.
      */
     nsIApplicationCache chooseApplicationCache(in ACString key,
                                                [optional] in nsILoadContext loadContext);
 
     /**
      * Flags the key as being opportunistically cached.
      *
--- a/netwerk/base/public/nsNetUtil.h
+++ b/netwerk/base/public/nsNetUtil.h
@@ -72,17 +72,16 @@
 #include "nsIChannelPolicy.h"
 #include "nsISocketProviderService.h"
 #include "nsISocketProvider.h"
 #include "nsIRedirectChannelRegistrar.h"
 #include "nsIMIMEHeaderParam.h"
 #include "nsILoadContext.h"
 #include "mozilla/Services.h"
 #include "nsIPrivateBrowsingChannel.h"
-#include "mozIApplicationClearPrivateDataParams.h"
 
 #include <limits>
 
 #ifdef MOZILLA_INTERNAL_API
 
 inline already_AddRefed<nsIIOService>
 do_GetIOService(nsresult* error = 0)
 {
@@ -1330,56 +1329,16 @@ NS_GetAppInfo(nsIChannel *aChannel, uint
     NS_ENSURE_SUCCESS(rv, false);
 
     rv = loadContext->GetIsInBrowserElement(aIsInBrowserElement);
     NS_ENSURE_SUCCESS(rv, false);
 
     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<mozIApplicationClearPrivateDataParams>
-        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.
  *
  * *aAuthPrompt2 should be set to null before calling this function.
  */
 inline void
 NS_WrapAuthPrompt(nsIAuthPrompt *aAuthPrompt, nsIAuthPrompt2** aAuthPrompt2)
--- a/netwerk/cache/Makefile.in
+++ b/netwerk/cache/Makefile.in
@@ -25,17 +25,16 @@ XPIDLSRCS = \
   nsICacheService.idl \
   nsICacheSession.idl \
   nsICacheVisitor.idl \
   nsIDiskCacheStreamInternal.idl \
   $(NULL)
 
 EXPORTS = \
   nsCacheService.h \
-  nsApplicationCacheService.h \
   $(NULL)
 
 CPPSRCS = \
   nsCache.cpp \
   nsCacheEntry.cpp \
   nsCacheEntryDescriptor.cpp \
   nsCacheMetaData.cpp \
   nsCacheService.cpp \
--- a/netwerk/cache/nsApplicationCacheService.cpp
+++ b/netwerk/cache/nsApplicationCacheService.cpp
@@ -1,28 +1,23 @@
 /* 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 "nsDiskCache.h"
 #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()
 {
     nsCOMPtr<nsICacheService> serv = do_GetService(kCacheServiceCID);
     mCacheService = nsCacheService::GlobalInstance();
 }
 
@@ -130,28 +125,16 @@ nsApplicationCacheService::CacheOpportun
 
     nsRefPtr<nsOfflineCacheDevice> device;
     nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device));
     NS_ENSURE_SUCCESS(rv, rv);
     return device->CacheOpportunistically(cache, key);
 }
 
 NS_IMETHODIMP
-nsApplicationCacheService::DiscardByAppId(int32_t appID, bool isInBrowser)
-{
-    if (!mCacheService)
-        return NS_ERROR_UNEXPECTED;
-
-    nsRefPtr<nsOfflineCacheDevice> 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)
 {
     if (!mCacheService)
         return NS_ERROR_UNEXPECTED;
 
     nsRefPtr<nsOfflineCacheDevice> device;
     nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device));
@@ -166,58 +149,8 @@ nsApplicationCacheService::GetGroupsTime
     if (!mCacheService)
         return NS_ERROR_UNEXPECTED;
 
     nsRefPtr<nsOfflineCacheDevice> device;
     nsresult rv = mCacheService->GetOfflineDevice(getter_AddRefs(device));
     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<nsIApplicationCacheService> 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<nsIObserverService> observerService =
-        do_GetService("@mozilla.org/observer-service;1");
-    if (observerService) {
-        nsRefPtr<AppCacheClearDataObserver> obs
-            = new AppCacheClearDataObserver();
-        observerService->AddObserver(obs, TOPIC_WEB_APP_CLEAR_DATA,
-                                     /*holdsWeak=*/ false);
-    }
-}
-
--- a/netwerk/cache/nsApplicationCacheService.h
+++ b/netwerk/cache/nsApplicationCacheService.h
@@ -1,30 +1,24 @@
 /* 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/. */
 
 #ifndef _nsApplicationCacheService_h_
 #define _nsApplicationCacheService_h_
 
-#include "nsIApplicationCacheService.h"
 #include "mozilla/Attributes.h"
 
-class nsCacheService;
-
 class nsApplicationCacheService MOZ_FINAL : public nsIApplicationCacheService
 {
 public:
     nsApplicationCacheService();
 
     NS_DECL_ISUPPORTS
     NS_DECL_NSIAPPLICATIONCACHESERVICE
-
-    static void AppClearDataObserverInit();
-
 private:
     nsresult GetJARIdentifier(nsIURI *aURI,
                               nsILoadContext *aLoadContext,
                               nsACString &_result);
 
     nsRefPtr<nsCacheService> mCacheService;
 };
 
--- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp
@@ -1210,17 +1210,16 @@ nsOfflineCacheDevice::Init()
                                                      "  ON ns.ClientID = groups.ActiveClientID"
                                                      " WHERE ns.NameSpace <= ?1 AND ?1 GLOB ns.NameSpace || '*'"
                                                      " ORDER BY ns.NameSpace DESC, groups.ActivateTimeStamp DESC;"),
     StatementSql ( mStatement_FindNamespaceEntry,    "SELECT NameSpace, Data, ItemType FROM moz_cache_namespaces"
                                                      " WHERE ClientID = ?1"
                                                      " 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;")
   };
   for (uint32_t i = 0; NS_SUCCEEDED(rv) && i < ArrayLength(prepared); ++i)
   {
     LOG(("Creating statement: %s\n", prepared[i].sql));
 
     rv = mDB->CreateStatement(nsDependentCString(prepared[i].sql),
@@ -1242,27 +1241,16 @@ GetGroupForCache(const nsCSubstring &cli
   group.Assign(clientID);
   group.Truncate(group.FindChar('|'));
   NS_UnescapeURL(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,
                  nsACString &_result)
 {
     _result.Truncate();
 
     if (!aLoadContext)
         return NS_OK;
@@ -1278,17 +1266,21 @@ GetJARIdentifier(nsIURI *aURI,
     uint32_t appId;
     rv = aLoadContext->GetAppId(&appId);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!isInBrowserElement && appId == NECKO_NO_APP_ID)
         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
 
 // static
 nsresult
 nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
                                                    nsILoadContext *aLoadContext,
@@ -1304,18 +1296,20 @@ nsOfflineCacheDevice::BuildApplicationCa
 
   _result.Assign(manifestSpec);
 
   nsAutoCString jarid;
   rv = GetJARIdentifier(aManifestURL, aLoadContext, jarid);
   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;
 }
 
 nsresult
 nsOfflineCacheDevice::InitActiveCaches()
 {
   mCaches.Init();
@@ -2363,62 +2357,16 @@ nsOfflineCacheDevice::DeactivateGroup(co
     mActiveCaches.RemoveEntry(*active);
     mActiveCachesByGroup.Remove(group);
     active = nullptr;
   }
 
   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<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) {
-    // 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,
                                   nsILoadContext *loadContext)
 {
   if (!mActiveCaches.Contains(clientID))
     return false;
 
--- a/netwerk/cache/nsDiskCacheDeviceSQL.h
+++ b/netwerk/cache/nsDiskCacheDeviceSQL.h
@@ -153,18 +153,16 @@ public:
 
   nsresult                ChooseApplicationCache(const nsACString &key,
                                                  nsILoadContext *loadContext,
                                                  nsIApplicationCache **out);
 
   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,
                                                char ***keys);
 
   bool                    IsLocked(const nsACString &key);
   void                    Lock(const nsACString &key);
   void                    Unlock(const nsACString &key);
@@ -254,17 +252,16 @@ private:
   nsCOMPtr<mozIStorageStatement>  mStatement_FindNamespaceEntry;
   nsCOMPtr<mozIStorageStatement>  mStatement_InsertNamespaceEntry;
   nsCOMPtr<mozIStorageStatement>  mStatement_CleanupUnmarked;
   nsCOMPtr<mozIStorageStatement>  mStatement_GatherEntries;
   nsCOMPtr<mozIStorageStatement>  mStatement_ActivateClient;
   nsCOMPtr<mozIStorageStatement>  mStatement_DeactivateGroup;
   nsCOMPtr<mozIStorageStatement>  mStatement_FindClient;
   nsCOMPtr<mozIStorageStatement>  mStatement_FindClientByNamespace;
-  nsCOMPtr<mozIStorageStatement>  mStatement_EnumerateApps;
   nsCOMPtr<mozIStorageStatement>  mStatement_EnumerateGroups;
   nsCOMPtr<mozIStorageStatement>  mStatement_EnumerateGroupsTimeOrder;
 
   nsCOMPtr<nsIFile>               mBaseDirectory;
   nsCOMPtr<nsIFile>               mCacheDirectory;
   uint32_t                        mCacheCapacity; // in bytes
   int32_t                         mDeltaCounter;
   bool                            mAutoShutdown;