Bug 978486 - Remove nsErrorService::mErrorStringBundleKeyMap. r=froydnj

This commit is contained in:
Andrew McCreight 2014-03-04 09:49:40 -08:00
parent bcfecf4989
commit cb2d3b3251
4 changed files with 4 additions and 59 deletions

View File

@ -718,21 +718,9 @@ nsStringBundleService::FormatWithBundle(nsIStringBundle* bundle, nsresult aStatu
nsresult rv;
nsXPIDLCString key;
// then find a key into the string bundle for that particular error:
rv = mErrorService->GetErrorStringBundleKey(aStatus, getter_Copies(key));
// first try looking up the error message with the string key:
if (NS_SUCCEEDED(rv)) {
rv = bundle->FormatStringFromName(NS_ConvertASCIItoUTF16(key).get(),
(const char16_t**)argArray,
argCount, result);
}
// if the string key fails, try looking up the error message with the int key:
if (NS_FAILED(rv)) {
uint16_t code = NS_ERROR_GET_CODE(aStatus);
rv = bundle->FormatStringFromID(code, (const char16_t**)argArray, argCount, result);
}
// try looking up the error message with the int key:
uint16_t code = NS_ERROR_GET_CODE(aStatus);
rv = bundle->FormatStringFromID(code, (const char16_t**)argArray, argCount, result);
// If the int key fails, try looking up the default error message. E.g. print:
// An unknown error has occurred (0x804B0003).

View File

@ -93,27 +93,4 @@ nsErrorService::GetErrorStringBundle(int16_t errorModule, char **result)
return NS_OK;
}
NS_IMETHODIMP
nsErrorService::RegisterErrorStringBundleKey(nsresult error, const char *stringBundleKey)
{
return mErrorStringBundleKeyMap.Put(static_cast<uint32_t>(error),
stringBundleKey);
}
NS_IMETHODIMP
nsErrorService::UnregisterErrorStringBundleKey(nsresult error)
{
return mErrorStringBundleKeyMap.Remove(static_cast<uint32_t>(error));
}
NS_IMETHODIMP
nsErrorService::GetErrorStringBundleKey(nsresult error, char **result)
{
char* value = mErrorStringBundleKeyMap.Get(static_cast<uint32_t>(error));
if (value == nullptr)
return NS_ERROR_OUT_OF_MEMORY;
*result = value;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -40,7 +40,6 @@ private:
protected:
nsInt2StrHashtable mErrorStringBundleURLMap;
nsInt2StrHashtable mErrorStringBundleKeyMap;
};
#endif // nsErrorService_h__

View File

@ -13,7 +13,7 @@
* This service will eventually get replaced by extending xpidl to allow errors to be defined.
* (http://bugzilla.mozilla.org/show_bug.cgi?id=13423).
*/
[scriptable, uuid(e72f94b2-5f85-11d4-9877-00c04fa0cf4a)]
[scriptable, uuid(afe1f190-a3c2-11e3-a5e2-0800200c9a66)]
interface nsIErrorService : nsISupports
{
/**
@ -31,25 +31,6 @@ interface nsIErrorService : nsISupports
* Retrieves a string bundle URL for an error module.
*/
string getErrorStringBundle(in short errorModule);
/**
* Registers a key in a string bundle for an nsresult error code. Only the code portion
* of the nsresult is used (obtained with NS_ERROR_GET_CODE) in this registration. The
* string bundle key is used to look up internationalized messages in the string bundle.
*/
void registerErrorStringBundleKey(in nsresult error, in string stringBundleKey);
/**
* Unregisters a key in a string bundle for an nsresult error code.
*/
void unregisterErrorStringBundleKey(in nsresult error);
/**
* Retrieves a key in a string bundle for an nsresult error code. If no key is registered
* for the specified nsresult's code (obtained with NS_ERROR_GET_CODE), then the stringified
* version of the nsresult code is returned.
*/
string getErrorStringBundleKey(in nsresult error);
};
%{C++