From f66e192f39fd18ea0d16fefe0284367e2cf883ae Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 23 Jun 2018 23:12:31 -0700 Subject: [PATCH] Bug 1470716: Remove unused ExtensibleStringBundle support. r=gandalf MozReview-Commit-ID: HpNjXK0IURv --HG-- extra : rebase_source : 988d650e15f4082ad0b778163b661ec105d71096 extra : absorb_source : 55ede0cae193e3dfb6c1ce9e1caffe51a9005aa6 --- intl/strres/nsIStringBundle.idl | 1 - intl/strres/nsStringBundle.cpp | 187 -------------------------------- intl/strres/nsStringBundle.h | 29 ----- 3 files changed, 217 deletions(-) diff --git a/intl/strres/nsIStringBundle.idl b/intl/strres/nsIStringBundle.idl index 1fccdb029326..3f0653055372 100644 --- a/intl/strres/nsIStringBundle.idl +++ b/intl/strres/nsIStringBundle.idl @@ -83,7 +83,6 @@ interface nsIStringBundle : nsISupports interface nsIStringBundleService : nsISupports { nsIStringBundle createBundle(in string aURLSpec); - nsIStringBundle createExtensibleBundle(in string aRegistryKey); /** * Formats a message string from a status code and status arguments. diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp index 004a437b455b..9493ec5c6c25 100644 --- a/intl/strres/nsStringBundle.cpp +++ b/intl/strres/nsStringBundle.cpp @@ -644,175 +644,6 @@ nsStringBundleBase::FormatString(const char16_t *aFormatStr, return NS_OK; } -NS_IMPL_ISUPPORTS(nsExtensibleStringBundle, nsIStringBundle) - -nsExtensibleStringBundle::nsExtensibleStringBundle() -{ - mLoaded = false; -} - -nsresult -nsExtensibleStringBundle::Init(const char * aCategory, - nsIStringBundleService* aBundleService) -{ - - nsresult rv; - nsCOMPtr catman = - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr enumerator; - rv = catman->EnumerateCategory(aCategory, getter_AddRefs(enumerator)); - if (NS_FAILED(rv)) return rv; - - bool hasMore; - while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMore)) && hasMore) { - nsCOMPtr supports; - rv = enumerator->GetNext(getter_AddRefs(supports)); - if (NS_FAILED(rv)) - continue; - - nsCOMPtr supStr = do_QueryInterface(supports, &rv); - if (NS_FAILED(rv)) - continue; - - nsAutoCString name; - rv = supStr->GetData(name); - if (NS_FAILED(rv)) - continue; - - nsCOMPtr bundle; - rv = aBundleService->CreateBundle(name.get(), getter_AddRefs(bundle)); - if (NS_FAILED(rv)) - continue; - - mBundles.AppendObject(bundle); - } - - return rv; -} - -NS_IMETHODIMP -nsExtensibleStringBundle::AsyncPreload() -{ - nsresult rv = NS_OK; - const uint32_t size = mBundles.Count(); - for (uint32_t i = 0; i < size; ++i) { - nsIStringBundle* bundle = mBundles[i]; - if (bundle) { - nsresult rv2 = bundle->AsyncPreload(); - rv = NS_FAILED(rv) ? rv : rv2; - } - } - return rv; -} - -nsExtensibleStringBundle::~nsExtensibleStringBundle() -{ -} - -size_t -nsExtensibleStringBundle::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const -{ - size_t n = 0; - const uint32_t sz = mBundles.Count(); - for (uint32_t i = 0; i < sz; ++i) { - nsIStringBundle* bundle = mBundles[i]; - if (bundle) { - n += bundle->SizeOfIncludingThis(aMallocSizeOf); - } - } - n += mBundles.ShallowSizeOfExcludingThis(aMallocSizeOf); - return aMallocSizeOf(this) + n; -} - -size_t -nsExtensibleStringBundle::SizeOfIncludingThisIfUnshared(MallocSizeOf aMallocSizeOf) const -{ - if (mRefCnt == 1) { - return SizeOfIncludingThis(aMallocSizeOf); - } else { - return 0; - } -} - -nsresult -nsExtensibleStringBundle::GetStringFromID(int32_t aID, nsAString& aResult) -{ - nsAutoCString idStr; - idStr.AppendInt(aID, 10); - return GetStringFromName(idStr.get(), aResult); -} - -nsresult -nsExtensibleStringBundle::GetStringFromAUTF8Name(const nsACString& aName, - nsAString& aResult) -{ - return GetStringFromName(PromiseFlatCString(aName).get(), aResult); -} - -nsresult -nsExtensibleStringBundle::GetStringFromName(const char* aName, - nsAString& aResult) -{ - nsresult rv; - const uint32_t size = mBundles.Count(); - for (uint32_t i = 0; i < size; ++i) { - nsIStringBundle* bundle = mBundles[i]; - if (bundle) { - rv = bundle->GetStringFromName(aName, aResult); - if (NS_SUCCEEDED(rv)) - return NS_OK; - } - } - - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsExtensibleStringBundle::FormatStringFromID(int32_t aID, - const char16_t ** aParams, - uint32_t aLength, - nsAString& aResult) -{ - nsAutoCString idStr; - idStr.AppendInt(aID, 10); - return FormatStringFromName(idStr.get(), aParams, aLength, aResult); -} - -NS_IMETHODIMP -nsExtensibleStringBundle::FormatStringFromAUTF8Name(const nsACString& aName, - const char16_t ** aParams, - uint32_t aLength, - nsAString& aResult) -{ - return FormatStringFromName(PromiseFlatCString(aName).get(), - aParams, aLength, aResult); -} - -NS_IMETHODIMP -nsExtensibleStringBundle::FormatStringFromName(const char* aName, - const char16_t** aParams, - uint32_t aLength, - nsAString& aResult) -{ - nsAutoString formatStr; - nsresult rv; - rv = GetStringFromName(aName, formatStr); - if (NS_FAILED(rv)) - return rv; - - return nsStringBundle::FormatString(formatStr.get(), aParams, aLength, - aResult); -} - -nsresult nsExtensibleStringBundle::GetSimpleEnumeration(nsISimpleEnumerator ** aResult) -{ - // XXX write me - *aResult = nullptr; - return NS_ERROR_NOT_IMPLEMENTED; -} - ///////////////////////////////////////////////////////////////////////////////////////// #define MAX_CACHED_BUNDLES 16 @@ -1069,24 +900,6 @@ nsStringBundleService::CreateBundle(const char* aURLSpec, return NS_OK; } -NS_IMETHODIMP -nsStringBundleService::CreateExtensibleBundle(const char* aCategory, - nsIStringBundle** aResult) -{ - NS_ENSURE_ARG_POINTER(aResult); - *aResult = nullptr; - - RefPtr bundle = new nsExtensibleStringBundle(); - - nsresult res = bundle->Init(aCategory, this); - if (NS_FAILED(res)) { - return res; - } - - bundle.forget(aResult); - return NS_OK; -} - #define GLOBAL_PROPERTIES "chrome://global/locale/global-strres.properties" nsresult diff --git a/intl/strres/nsStringBundle.h b/intl/strres/nsStringBundle.h index a3b5e05a9724..733d93f05d23 100644 --- a/intl/strres/nsStringBundle.h +++ b/intl/strres/nsStringBundle.h @@ -69,33 +69,4 @@ protected: nsresult GetSimpleEnumerationImpl(nsISimpleEnumerator** elements) override; }; -class nsExtensibleStringBundle; - -/** - * An extensible implementation of the StringBundle interface. - * - * @created 28/Dec/1999 - * @author Catalin Rotaru [CATA] - */ -class nsExtensibleStringBundle final : public nsIStringBundle -{ - NS_DECL_ISUPPORTS - NS_DECL_NSISTRINGBUNDLE - - nsresult Init(const char * aCategory, nsIStringBundleService *); - -public: - nsExtensibleStringBundle(); - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override; - size_t SizeOfIncludingThisIfUnshared(mozilla::MallocSizeOf aMallocSizeOf) const override; - -private: - virtual ~nsExtensibleStringBundle(); - - nsCOMArray mBundles; - bool mLoaded; -}; - - - #endif