Bug 794023 - Use std::numeric_limits for NECKO_UNKNOWN_APP. f=ehsan r=jduell
authorMounir Lamouri <mounir.lamouri@gmail.com>
Fri, 28 Sep 2012 11:04:32 +0100
changeset 108534 97a779a92b92a7b65a25515bc9311969178d6cc5
parent 108533 c1b8d9b1b7f0c047368405adbd6e2ac7b3ff8854
child 108535 2eb1ca5c87ea8810bcceda6be97d76339bb4ab2c
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersjduell
bugs794023
milestone18.0a1
Bug 794023 - Use std::numeric_limits for NECKO_UNKNOWN_APP. f=ehsan r=jduell
netwerk/base/public/nsNetUtil.h
netwerk/cookie/nsCookieService.cpp
--- a/netwerk/base/public/nsNetUtil.h
+++ b/netwerk/base/public/nsNetUtil.h
@@ -73,16 +73,18 @@
 #include "nsISocketProviderService.h"
 #include "nsISocketProvider.h"
 #include "nsIRedirectChannelRegistrar.h"
 #include "nsIMIMEHeaderParam.h"
 #include "nsILoadContext.h"
 #include "mozilla/Services.h"
 #include "nsIPrivateBrowsingChannel.h"
 
+#include <limits>
+
 #ifdef MOZILLA_INTERNAL_API
 
 inline already_AddRefed<nsIIOService>
 do_GetIOService(nsresult* error = 0)
 {
     already_AddRefed<nsIIOService> ret = mozilla::services::GetIOService();
     if (error)
         *error = ret.get() ? NS_OK : NS_ERROR_FAILURE;
@@ -1303,18 +1305,17 @@ NS_UsePrivateBrowsing(nsIChannel *channe
     nsCOMPtr<nsILoadContext> loadContext;
     NS_QueryNotificationCallbacks(channel, loadContext);
     return loadContext && loadContext->UsePrivateBrowsing();
 }
 
 // Constants duplicated from nsIScriptSecurityManager so we avoid having necko
 // know about script security manager.
 #define NECKO_NO_APP_ID 0
-// Note: UNKNOWN also equals PR_UINT32_MAX
-#define NECKO_UNKNOWN_APP_ID 4294967295
+#define NECKO_UNKNOWN_APP_ID std::numeric_limits<uint32_t>::max()
 
 /**
  * Gets AppId and isInBrowserElement from channel's nsILoadContext.
  * Returns false if error or channel's callbacks don't implement nsILoadContext.
  */
 inline bool
 NS_GetAppInfo(nsIChannel *aChannel, uint32_t *aAppID, bool *aIsInBrowserElement)
 {
--- a/netwerk/cookie/nsCookieService.cpp
+++ b/netwerk/cookie/nsCookieService.cpp
@@ -3811,19 +3811,17 @@ NS_IMETHODIMP
 nsCookieService::GetCookiesForApp(uint32_t aAppId, bool aOnlyBrowserElement,
                                   nsISimpleEnumerator** aEnumerator)
 {
   if (!mDBState) {
     NS_WARNING("No DBState! Profile already closed?");
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  // TODO: For the moment NECKO_UNKNOWN_APP_ID isn't working well with Necko.
-  // This should be uncommented with bug 794023.
-  NS_ENSURE_TRUE(aAppId != NECKO_NO_APP_ID /*&& aAppId != NECKO_UNKNOWN_APP_ID*/,
+  NS_ENSURE_TRUE(aAppId != NECKO_NO_APP_ID && aAppId != NECKO_UNKNOWN_APP_ID,
                  NS_ERROR_INVALID_ARG);
 
   GetCookiesForAppStruct data(aAppId, aOnlyBrowserElement);
   mDBState->hostTable.EnumerateEntries(GetCookiesForApp, &data);
 
   return NS_NewArrayEnumerator(aEnumerator, data.cookies);
 }