Backed out changeset b99c87fb77d3 (bug 829043)
authorJosh Matthews <josh@joshmatthews.net>
Thu, 10 Jan 2013 22:50:27 +0100
changeset 118469 c1b3fd0a0195d769e42fecc942398bab734e2818
parent 118468 86d9fdfe93b33f181b2fca4ad395017e80af1829
child 118470 2d1152cf727e19ed879e50bfca5fb023d6d08a48
push id24166
push userMs2ger@gmail.com
push dateFri, 11 Jan 2013 13:57:41 +0000
treeherdermozilla-central@63c4b0f66a0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs829043
milestone21.0a1
backs outb99c87fb77d33c6bb40262680a7b86aabf71cfd1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset b99c87fb77d3 (bug 829043)
netwerk/build/nsNetModule.cpp
netwerk/protocol/http/nsHttpChannel.cpp
netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -265,17 +265,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSou
 #endif
 
 #ifdef NECKO_PROTOCOL_data
 #include "nsDataHandler.h"
 #endif
 
 #ifdef NECKO_PROTOCOL_wyciwyg
 #include "nsWyciwygProtocolHandler.h"
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWyciwygProtocolHandler, Init)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsWyciwygProtocolHandler)
 #endif
 
 #ifdef NECKO_PROTOCOL_websocket
 #include "WebSocketChannel.h"
 #include "WebSocketChannelChild.h"
 namespace mozilla {
 namespace net {
 static BaseWebSocketChannel*
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -2463,26 +2463,39 @@ nsHttpChannel::OnOfflineCacheEntryAvaila
         }
     }
 
     bool usingSSL = false;
     (void) mURI->SchemeIs("https", &usingSSL);
     return OpenNormalCacheEntry(usingSSL);
 }
 
+static void
+GetAppInfo(nsIChannel* aChannel, uint32_t* aAppId, bool* aIsInBrowser)
+{
+    nsCOMPtr<nsILoadContext> loadContext;
+    NS_QueryNotificationCallbacks(aChannel, loadContext);
+    *aAppId = NECKO_NO_APP_ID;
+    *aIsInBrowser = false;
+    if (loadContext) {
+        loadContext->GetAppId(aAppId);
+        loadContext->GetIsInBrowserElement(aIsInBrowser);
+    }
+}
+
 nsresult
 nsHttpChannel::OpenNormalCacheEntry(bool usingSSL)
 {
     NS_ASSERTION(!mCacheEntry, "We have already mCacheEntry");
 
     nsresult rv;
 
-    uint32_t appId = NECKO_NO_APP_ID;
-    bool isInBrowser = false;
-    NS_GetAppInfo(this, &appId, &isInBrowser);
+    uint32_t appId;
+    bool isInBrowser;
+    GetAppInfo(this, &appId, &isInBrowser);
 
     nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy();
     nsAutoCString clientID;
     nsHttpHandler::GetCacheSessionNameForStoragePolicy(storagePolicy, mPrivateBrowsing,
                                                        appId, isInBrowser, clientID);
 
     nsAutoCString cacheKey;
     GenerateCacheKey(mPostID, cacheKey);
@@ -5843,19 +5856,19 @@ void
 nsHttpChannel::DoInvalidateCacheEntry(const nsCString &key)
 {
     // NOTE:
     // Following comments 24,32 and 33 in bug #327765, we only care about
     // the cache in the protocol-handler, not the application cache.
     // The logic below deviates from the original logic in OpenCacheEntry on
     // one point by using only READ_ONLY access-policy. I think this is safe.
 
-    uint32_t appId = NECKO_NO_APP_ID;
-    bool isInBrowser = false;
-    NS_GetAppInfo(this, &appId, &isInBrowser);
+    uint32_t appId;
+    bool isInBrowser;
+    GetAppInfo(this, &appId, &isInBrowser);
 
     // First, find session holding the cache-entry - use current storage-policy
     nsCacheStoragePolicy storagePolicy = DetermineStoragePolicy();
     nsAutoCString clientID;
     nsHttpHandler::GetCacheSessionNameForStoragePolicy(storagePolicy, mPrivateBrowsing,
                                                        appId, isInBrowser, clientID);
 
     LOG(("DoInvalidateCacheEntry [channel=%p session=%s policy=%d key=%s]",
--- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp
@@ -687,28 +687,20 @@ nsWyciwygChannel::OpenCacheEntry(const n
 
   // honor security settings
   nsCacheStoragePolicy storagePolicy;
   if (mPrivateBrowsing || mLoadFlags & INHIBIT_PERSISTENT_CACHING)
     storagePolicy = nsICache::STORE_IN_MEMORY;
   else
     storagePolicy = nsICache::STORE_ANYWHERE;
 
-  uint32_t appId = NECKO_NO_APP_ID;
-  bool isInBrowser = false;
-  NS_GetAppInfo(this, &appId, &isInBrowser);
-
   nsCOMPtr<nsICacheSession> cacheSession;
-  nsAutoCString sessionName;
-  nsWyciwygProtocolHandler::GetCacheSessionName(appId, isInBrowser,
-                                                mPrivateBrowsing,
-                                                sessionName);
-
   // Open a stream based cache session.
-  rv = cacheService->CreateSession(sessionName.get(), storagePolicy, true,
+  const char* sessionName = mPrivateBrowsing ? "wyciwyg-private" : "wyciwyg";
+  rv = cacheService->CreateSession(sessionName, storagePolicy, true,
                                    getter_AddRefs(cacheSession));
   if (!cacheSession) 
     return NS_ERROR_FAILURE;
 
   cacheSession->SetIsPrivate(mPrivateBrowsing);
 
   if (aAccessMode == nsICache::ACCESS_WRITE)
     rv = cacheSession->OpenCacheEntry(aCacheKey, aAccessMode, false,
--- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
@@ -8,20 +8,16 @@
 #include "nsWyciwygChannel.h"
 #include "nsWyciwygProtocolHandler.h"
 #include "nsIURL.h"
 #include "nsIComponentManager.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 #include "plstr.h"
 #include "nsNetUtil.h"
-#include "nsIObserverService.h"
-#include "mozIApplicationClearPrivateDataParams.h"
-#include "nsICacheService.h"
-#include "nsICacheSession.h"
 
 #include "mozilla/net/NeckoChild.h"
 
 using namespace mozilla::net;
 #include "mozilla/net/WyciwygChannelChild.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -35,104 +31,17 @@ nsWyciwygProtocolHandler::nsWyciwygProto
   LOG(("Creating nsWyciwygProtocolHandler [this=%x].\n", this));
 }
 
 nsWyciwygProtocolHandler::~nsWyciwygProtocolHandler() 
 {
   LOG(("Deleting nsWyciwygProtocolHandler [this=%x]\n", this));
 }
 
-nsresult
-nsWyciwygProtocolHandler::Init()
-{
-  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-  if (obs) {
-    obs->AddObserver(this, "webapps-clear-data", true);
-  }
-  return NS_OK;
-}
-
-static void
-EvictCacheSession(uint32_t aAppId,
-                  bool aInBrowser,
-                  bool aPrivateBrowsing)
-{
-  nsAutoCString clientId;
-  nsWyciwygProtocolHandler::GetCacheSessionName(aAppId, aInBrowser,
-                                                aPrivateBrowsing,
-                                                clientId);
-  nsCOMPtr<nsICacheService> serv =
-      do_GetService(NS_CACHESERVICE_CONTRACTID);
-  nsCOMPtr<nsICacheSession> session;
-  nsresult rv = serv->CreateSession(clientId.get(),
-                                    nsICache::STORE_ANYWHERE,
-                                    nsICache::STREAM_BASED,
-                                    getter_AddRefs(session));
-  if (NS_SUCCEEDED(rv) && session) {
-    session->EvictEntries();
-  }
-}
-
-void
-nsWyciwygProtocolHandler::GetCacheSessionName(uint32_t aAppId,
-                                              bool aInBrowser,
-                                              bool aPrivateBrowsing,
-                                              nsACString& aSessionName)
-{
-  if (aPrivateBrowsing) {
-    aSessionName.AssignLiteral("wyciwyg-private");
-  } else {
-    aSessionName.AssignLiteral("wyciwyg");
-  }
-  if (aAppId == NECKO_NO_APP_ID && !aInBrowser) {
-    return;
-  }
-
-  aSessionName.Append('~');
-  aSessionName.AppendInt(aAppId);
-  aSessionName.Append('~');
-  aSessionName.AppendInt(aInBrowser);
-}
-
-NS_IMETHODIMP
-nsWyciwygProtocolHandler::Observe(nsISupports *subject,
-                                  const char *topic,
-                                  const PRUnichar *data)
-{
-  if (strcmp(topic, "webapps-clear-data") == 0) {
-    nsCOMPtr<mozIApplicationClearPrivateDataParams> params =
-        do_QueryInterface(subject);
-    if (!params) {
-      NS_ERROR("'webapps-clear-data' notification's subject should be a mozIApplicationClearPrivateDataParams");
-      return NS_ERROR_UNEXPECTED;
-    }
-
-    uint32_t appId;
-    bool browserOnly;
-    nsresult rv = params->GetAppId(&appId);
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = params->GetBrowserOnly(&browserOnly);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    MOZ_ASSERT(appId != NECKO_UNKNOWN_APP_ID);
-
-    EvictCacheSession(appId, browserOnly, false);
-    EvictCacheSession(appId, browserOnly, true);
-    if (!browserOnly) {
-      EvictCacheSession(appId, true, false);
-      EvictCacheSession(appId, true, true);
-    }
-  }
-  return NS_OK;
-}
-
-NS_IMPL_ISUPPORTS3(nsWyciwygProtocolHandler,
-                   nsIProtocolHandler,
-                   nsIObserver,
-                   nsISupportsWeakReference)
+NS_IMPL_ISUPPORTS1(nsWyciwygProtocolHandler, nsIProtocolHandler)
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIProtocolHandler methods:
 ////////////////////////////////////////////////////////////////////////////////
 
 NS_IMETHODIMP
 nsWyciwygProtocolHandler::GetScheme(nsACString &result)
 {
--- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.h
@@ -3,32 +3,21 @@
  * 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 nsWyciwygProtocolHandler_h___
 #define nsWyciwygProtocolHandler_h___
 
 #include "nsIProtocolHandler.h"
-#include "nsIObserver.h"
-#include "nsWeakReference.h"
+
             
 class nsWyciwygProtocolHandler : public nsIProtocolHandler
-                               , public nsIObserver
-                               , public nsSupportsWeakReference
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIPROTOCOLHANDLER
-    NS_DECL_NSIOBSERVER
 
     nsWyciwygProtocolHandler();
     virtual ~nsWyciwygProtocolHandler();
-
-    nsresult Init();
-
-    static void GetCacheSessionName(uint32_t aAppId,
-                                    bool aInBrowser,
-                                    bool aPrivateBrowsing,
-                                    nsACString& aSessionName);
 };
 
 #endif /* nsWyciwygProtocolHandler_h___ */