Bug 732708 - remove nsIDOMStorageList; r=honzab
authorNathan Froyd <froydnj@mozilla.com>
Wed, 28 Mar 2012 12:33:41 -0400
changeset 90989 17696f172c013c3dd29697474a9dab3228655c64
parent 90988 507c719614ecfb24d21bc63045fdb6ae091303f8
child 90990 40604eba22ce0100b8fe786835bcd0f540933a81
push id7957
push usernfroyd@mozilla.com
push dateWed, 04 Apr 2012 17:12:38 +0000
treeherdermozilla-inbound@17696f172c01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershonzab
bugs732708
milestone14.0a1
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
Bug 732708 - remove nsIDOMStorageList; r=honzab
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/base/nsDOMClassInfoClasses.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/interfaces/base/nsIDOMWindow.idl
dom/interfaces/storage/Makefile.in
dom/interfaces/storage/nsIDOMStorageList.idl
dom/src/storage/nsDOMStorage.cpp
dom/src/storage/nsDOMStorage.h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1351,18 +1351,16 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(Storage, nsStorage2SH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS |
                            nsIXPCScriptable::WANT_NEWRESOLVE |
                            nsIXPCScriptable::WANT_GETPROPERTY |
                            nsIXPCScriptable::WANT_SETPROPERTY |
                            nsIXPCScriptable::WANT_DELPROPERTY |
                            nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
                            nsIXPCScriptable::WANT_NEWENUMERATE)
-  NS_DEFINE_CLASSINFO_DATA(StorageList, nsStorageListSH,
-                           ARRAY_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(StorageEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(StorageEventObsolete, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH,
@@ -3916,20 +3914,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(StorageObsolete, nsIDOMStorageObsolete)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageObsolete)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(Storage, nsIDOMStorage)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorage)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(StorageList, nsIDOMStorageList)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageList)
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(StorageItem, nsIDOMStorageItem)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageItem)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMToString)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(StorageEvent, nsIDOMStorageEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
@@ -10625,28 +10619,16 @@ nsStorage2SH::NewEnumerate(nsIXPConnectW
                     "Bad call from the JS engine");
   delete keys;
 
   *statep = JSVAL_NULL;
 
   return NS_OK;
 }
 
-// StorageList scriptable helper
-
-nsISupports*
-nsStorageListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
-                              nsWrapperCache **aCache, nsresult *aResult)
-{
-  nsDOMStorageList* storagelist = static_cast<nsDOMStorageList*>(aNative);
-
-  return storagelist->GetNamedItem(aName, aResult);
-}
-
-
 // nsIDOMEventListener::HandleEvent() 'this' converter helper
 
 NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)
   NS_INTERFACE_MAP_ENTRY(nsIXPCFunctionThisTranslator)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -1422,46 +1422,16 @@ protected:
 
 public:
   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
   {
     return new nsStorage2SH(aData);
   }
 };
 
-class nsStorageListSH : public nsNamedArraySH
-{
-protected:
-  nsStorageListSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
-  {
-  }
-
-  virtual ~nsStorageListSH()
-  {
-  }
-
-  virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
-                                 nsWrapperCache **aCache, nsresult *aResult)
-  {
-    return nsnull;
-  }
-  // Override nsNamedArraySH::GetNamedItem()
-  virtual nsISupports* GetNamedItem(nsISupports *aNative,
-                                    const nsAString& aName,
-                                    nsWrapperCache **cache,
-                                    nsresult *aResult);
-
-public:
-  static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
-  {
-    return new nsStorageListSH(aData);
-  }
-};
-
-
 // Event handler 'this' translator class, this is called by XPConnect
 // when a "function interface" (nsIDOMEventListener) is called, this
 // class extracts 'this' fomr the first argument to the called
 // function (nsIDOMEventListener::HandleEvent(in nsIDOMEvent)), this
 // class will pass back nsIDOMEvent::currentTarget to be used as
 // 'this'.
 
 class nsEventListenerThisTranslator : public nsIXPCFunctionThisTranslator
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -369,17 +369,16 @@ DOMCI_CLASS(XPathEvaluator)
 DOMCI_CLASS(XPathException)
 DOMCI_CLASS(XPathExpression)
 DOMCI_CLASS(XPathNSResolver)
 DOMCI_CLASS(XPathResult)
 
 // WhatWG WebApps Objects
 DOMCI_CLASS(StorageObsolete)
 DOMCI_CLASS(Storage)
-DOMCI_CLASS(StorageList)
 DOMCI_CLASS(StorageItem)
 DOMCI_CLASS(StorageEvent)
 DOMCI_CLASS(StorageEventObsolete)
 
 // DOMParser, XMLSerializer
 DOMCI_CLASS(DOMParser)
 DOMCI_CLASS(XMLSerializer)
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8448,25 +8448,16 @@ nsGlobalWindow::Observe(nsISupports* aSu
         return NS_OK;
       }
 
       nsCAutoString currentDomain;
       rv = codebase->GetAsciiHost(currentDomain);
       if (NS_FAILED(rv)) {
         return NS_OK;
       }
-
-      if (!nsDOMStorageList::CanAccessDomain(NS_ConvertUTF16toUTF8(aData),
-                                             currentDomain)) {
-        // This window can't reach the global storage object for the
-        // domain for which the change happened, so don't fire any
-        // events in this window.
-
-        return NS_OK;
-      }
     }
 
     nsAutoString domain(aData);
 
     if (IsFrozen()) {
       // This window is frozen, rather than firing the events here,
       // store the domain in which the change happened and fire the
       // events if we're ever thawed.
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -83,17 +83,16 @@
 #include "nsIPrincipal.h"
 #include "nsIXPCScriptable.h"
 #include "nsPoint.h"
 #include "nsSize.h"
 #include "nsRect.h"
 #include "mozFlushType.h"
 #include "prclist.h"
 #include "nsIDOMStorageObsolete.h"
-#include "nsIDOMStorageList.h"
 #include "nsIDOMStorageEvent.h"
 #include "nsIDOMStorageIndexedDB.h"
 #include "nsIDOMOfflineResourceList.h"
 #include "nsIArray.h"
 #include "nsIContent.h"
 #include "nsIIDBFactory.h"
 #include "nsFrameMessageManager.h"
 #include "mozilla/TimeStamp.h"
--- a/dom/interfaces/base/nsIDOMWindow.idl
+++ b/dom/interfaces/base/nsIDOMWindow.idl
@@ -44,17 +44,16 @@
 interface nsIFrameRequestCallback;
 interface nsIControllers;
 interface nsIDOMBlob;
 interface nsIDOMLocation;
 interface nsIDOMMediaQueryList;
 interface nsIDOMOfflineResourceList;
 interface nsIDOMPerformance;
 interface nsIDOMStorage;
-interface nsIDOMStorageList;
 interface nsIPrompt;
 interface nsISelection;
 interface nsIVariant;
 
 [scriptable, uuid(8fc58f56-f769-4368-a098-edd08550cf1a)]
 interface nsIDOMMozURLProperty : nsISupports
 {
   DOMString createObjectURL(in nsIDOMBlob blob);
--- a/dom/interfaces/storage/Makefile.in
+++ b/dom/interfaces/storage/Makefile.in
@@ -57,12 +57,11 @@ XPIDLSRCS =                             
 
 SDK_XPIDLSRCS =                      \
         nsIDOMStorage.idl        \
         nsIDOMStorageObsolete.idl\
         nsIDOMStorageEvent.idl   \
         nsIDOMStorageEventObsolete.idl \
         nsIDOMStorageItem.idl    \
         nsIDOMStorageIndexedDB.idl \
-        nsIDOMStorageList.idl    \
        $(NULL)
 
 include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/dom/interfaces/storage/nsIDOMStorageList.idl
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- *   Neil Deakin <enndeakin@sympatico.ca>
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "domstubs.idl"
-
-/**
- * Interface for a client side storage. See
- * http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side
- * for more information.
- *
- * Allows access to contextual storage areas by domain.
- */
-
-interface nsIDOMStorageObsolete;
-
-[scriptable, uuid(A4E9B257-5CCF-4b17-8721-23AC45C83128)]
-interface nsIDOMStorageList : nsISupports
-{
-  /**
-   * Returns a storage object for a particular domain.
-   *
-   * @param domain domain to retrieve
-   * @returns a storage area for the given domain
-   */
-  nsIDOMStorageObsolete namedItem(in DOMString domain);
-};
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -1981,186 +1981,16 @@ nsDOMStorage2::RemoveItem(const nsAStrin
 NS_IMETHODIMP
 nsDOMStorage2::Clear()
 {
   mStorage->mEventBroadcaster = this;
   return mStorage->Clear();
 }
 
 //
-// nsDOMStorageList
-//
-
-DOMCI_DATA(StorageList, nsDOMStorageList)
-
-NS_INTERFACE_MAP_BEGIN(nsDOMStorageList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMStorageList)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StorageList)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_ADDREF(nsDOMStorageList)
-NS_IMPL_RELEASE(nsDOMStorageList)
-
-nsIDOMStorageObsolete*
-nsDOMStorageList::GetNamedItem(const nsAString& aDomain, nsresult* aResult)
-{
-  nsCAutoString requestedDomain;
-
-  // Normalize the requested domain
-  nsCOMPtr<nsIIDNService> idn = do_GetService(NS_IDNSERVICE_CONTRACTID);
-  if (idn) {
-    *aResult = idn->ConvertUTF8toACE(NS_ConvertUTF16toUTF8(aDomain),
-                                     requestedDomain);
-    NS_ENSURE_SUCCESS(*aResult, nsnull);
-  } else {
-    // Don't have the IDN service, best we can do is URL escape.
-    NS_EscapeURL(NS_ConvertUTF16toUTF8(aDomain),
-                 esc_OnlyNonASCII | esc_AlwaysCopy,
-                 requestedDomain);
-  }
-  ToLowerCase(requestedDomain);
-
-  nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
-  if (!ssm) {
-    *aResult = NS_ERROR_FAILURE;
-    return nsnull;
-  }
-
-  nsCOMPtr<nsIPrincipal> subjectPrincipal;
-  *aResult = ssm->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal));
-  NS_ENSURE_SUCCESS(*aResult, nsnull);
-
-  nsCAutoString currentDomain;
-  if (subjectPrincipal) {
-    nsCOMPtr<nsIURI> unused;
-    *aResult = GetPrincipalURIAndHost(subjectPrincipal, getter_AddRefs(unused),
-                                      currentDomain);
-    NS_ENSURE_SUCCESS(*aResult, nsnull);
-
-    bool sessionOnly;
-    if (!nsDOMStorage::CanUseStorage(&sessionOnly)) {
-      *aResult = NS_ERROR_DOM_SECURITY_ERR;
-      return nsnull;
-    }
-  }
-
-  bool isSystem = nsContentUtils::IsCallerTrustedForRead();
-  if (currentDomain.IsEmpty() && !isSystem) {
-    *aResult = NS_ERROR_DOM_SECURITY_ERR;
-    return nsnull;
-  }
-
-  return GetStorageForDomain(requestedDomain,
-                             currentDomain, isSystem, aResult);
-}
-
-NS_IMETHODIMP
-nsDOMStorageList::NamedItem(const nsAString& aDomain,
-                            nsIDOMStorageObsolete** aStorage)
-{
-  nsresult rv;
-  NS_IF_ADDREF(*aStorage = GetNamedItem(aDomain, &rv));
-  return rv;
-}
-
-// static
-bool
-nsDOMStorageList::CanAccessDomain(const nsACString& aRequestedDomain,
-                                  const nsACString& aCurrentDomain)
-{
-  return aRequestedDomain.Equals(aCurrentDomain);
-}
-
-nsIDOMStorageObsolete*
-nsDOMStorageList::GetStorageForDomain(const nsACString& aRequestedDomain,
-                                      const nsACString& aCurrentDomain,
-                                      bool aNoCurrentDomainCheck,
-                                      nsresult* aResult)
-{
-  nsTArray<nsCString> requestedDomainArray;
-  if ((!aNoCurrentDomainCheck &&
-       !CanAccessDomain(aRequestedDomain, aCurrentDomain)) ||
-    !ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
-    *aResult = NS_ERROR_DOM_SECURITY_ERR;
-
-    return nsnull;
-  }
-
-  // now rebuild a string for the domain.
-  nsCAutoString usedDomain;
-  PRUint32 requestedPos = 0;
-  for (requestedPos = 0; requestedPos < requestedDomainArray.Length();
-       requestedPos++) {
-    if (!usedDomain.IsEmpty())
-      usedDomain.Append('.');
-    usedDomain.Append(requestedDomainArray[requestedPos]);
-  }
-
-  *aResult = NS_OK;
-
-  // now have a valid domain, so look it up in the storage table
-  nsIDOMStorageObsolete* storage = mStorages.GetWeak(usedDomain);
-  if (!storage) {
-    nsRefPtr<nsDOMStorage> newstorage;
-    newstorage = new nsDOMStorage();
-    if (newstorage && mStorages.Put(usedDomain, newstorage)) {
-      storage = newstorage;
-    }
-    else {
-      *aResult = NS_ERROR_OUT_OF_MEMORY;
-    }
-  }
-
-  return storage;
-}
-
-// static
-bool
-nsDOMStorageList::ConvertDomainToArray(const nsACString& aDomain,
-                                       nsTArray<nsCString> *aArray)
-{
-  PRInt32 length = aDomain.Length();
-  PRInt32 n = 0;
-  while (n < length) {
-    PRInt32 dotpos = aDomain.FindChar('.', n);
-    nsCAutoString domain;
-
-    if (dotpos == -1) // no more dots
-      domain.Assign(Substring(aDomain, n));
-    else if (dotpos - n == 0) // no point continuing in this case
-      return false;
-    else if (dotpos >= 0)
-      domain.Assign(Substring(aDomain, n, dotpos - n));
-
-    ToLowerCase(domain);
-    aArray->AppendElement(domain);
-
-    if (dotpos == -1)
-      break;
-
-    n = dotpos + 1;
-  }
-
-  // if n equals the length, there is a dot at the end, so treat it as invalid
-  return (n != length);
-}
-
-nsresult
-NS_NewDOMStorageList(nsIDOMStorageList** aResult)
-{
-  *aResult = new nsDOMStorageList();
-  if (!*aResult)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(*aResult);
-  return NS_OK;
-}
-
-//
 // nsDOMStorageItem
 //
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMStorageItem)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMStorageItem)
   {
     tmp->mStorage = nsnull;
   }
--- a/dom/src/storage/nsDOMStorage.h
+++ b/dom/src/storage/nsDOMStorage.h
@@ -40,17 +40,16 @@
 
 #ifndef nsDOMStorage_h___
 #define nsDOMStorage_h___
 
 #include "nscore.h"
 #include "nsAutoPtr.h"
 #include "nsIDOMStorageObsolete.h"
 #include "nsIDOMStorage.h"
-#include "nsIDOMStorageList.h"
 #include "nsIDOMStorageItem.h"
 #include "nsIPermissionManager.h"
 #include "nsInterfaceHashtable.h"
 #include "nsVoidArray.h"
 #include "nsTArray.h"
 #include "nsPIDOMStorage.h"
 #include "nsIDOMToString.h"
 #include "nsDOMEvent.h"
@@ -460,69 +459,16 @@ private:
   nsCOMPtr<nsIPrincipal> mPrincipal;
 
   // Needed for the storage event, this is address of the document this storage
   // is bound to
   nsString mDocumentURI;
   nsRefPtr<nsDOMStorage> mStorage;
 };
 
-class nsDOMStorageList : public nsIDOMStorageList
-{
-public:
-  nsDOMStorageList()
-  {
-    mStorages.Init();
-  }
-
-  virtual ~nsDOMStorageList() {}
-
-  // nsISupports
-  NS_DECL_ISUPPORTS
-
-  // nsIDOMStorageList
-  NS_DECL_NSIDOMSTORAGELIST
-
-  nsIDOMStorageObsolete* GetNamedItem(const nsAString& aDomain, nsresult* aResult);
-
-  /**
-   * Check whether aCurrentDomain has access to aRequestedDomain
-   */
-  static bool
-  CanAccessDomain(const nsACString& aRequestedDomain,
-                  const nsACString& aCurrentDomain);
-
-protected:
-
-  /**
-   * Return the global nsIDOMStorageObsolete for a particular domain.
-   * aNoCurrentDomainCheck may be true to skip the domain comparison;
-   * this is used for chrome code so that it may retrieve data from
-   * any domain.
-   *
-   * @param aRequestedDomain domain to return
-   * @param aCurrentDomain domain of current caller
-   * @param aNoCurrentDomainCheck true to skip domain comparison
-   */
-  nsIDOMStorageObsolete*
-  GetStorageForDomain(const nsACString& aRequestedDomain,
-                      const nsACString& aCurrentDomain,
-                      bool aNoCurrentDomainCheck,
-                      nsresult* aResult);
-
-  /**
-   * Convert the domain into an array of its component parts.
-   */
-  static bool
-  ConvertDomainToArray(const nsACString& aDomain,
-                       nsTArray<nsCString>* aArray);
-
-  nsInterfaceHashtable<nsCStringHashKey, nsIDOMStorageObsolete> mStorages;
-};
-
 class nsDOMStorageItem : public nsIDOMStorageItem,
                          public nsIDOMToString
 {
 public:
   nsDOMStorageItem(DOMStorageBase* aStorage,
                    const nsAString& aKey,
                    const nsAString& aValue,
                    bool aSecure);
@@ -632,18 +578,15 @@ protected:
 };
 
 nsresult
 NS_NewDOMStorage(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
 nsresult
 NS_NewDOMStorage2(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
-nsresult
-NS_NewDOMStorageList(nsIDOMStorageList** aResult);
-
 PRUint32
 GetOfflinePermission(const nsACString &aDomain);
 
 bool
 IsOfflineAllowed(const nsACString &aDomain);
 
 #endif /* nsDOMStorage_h___ */