Bug 1073711: Clean up nsCacheService::CreateSessionInternal; drop useless null-check of 'this' and after 'new', and use nsRefPtr::forget(). r=mayhemer
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 03 Oct 2014 10:54:44 -0700
changeset 208772 3bea361c1f4014e09fdcee60db8b585b104acab9
parent 208771 eaa8c62e29f650fd254241f11b0862d3473230ad
child 208773 b1a9b31ab26e28c99b9583a31e5ea5c97f16aa68
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmayhemer
bugs1073711
milestone35.0a1
Bug 1073711: Clean up nsCacheService::CreateSessionInternal; drop useless null-check of 'this' and after 'new', and use nsRefPtr::forget(). r=mayhemer
netwerk/cache/nsCacheService.cpp
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1318,22 +1318,19 @@ nsCacheService::CreateSession(const char
 }
 
 nsresult
 nsCacheService::CreateSessionInternal(const char *          clientID,
                                       nsCacheStoragePolicy  storagePolicy,
                                       bool                  streamBased,
                                       nsICacheSession     **result)
 {
-    if (this == nullptr)  return NS_ERROR_NOT_AVAILABLE;
-
-    nsCacheSession * session = new nsCacheSession(clientID, storagePolicy, streamBased);
-    if (!session)  return NS_ERROR_OUT_OF_MEMORY;
-
-    NS_ADDREF(*result = session);
+    nsRefPtr<nsCacheSession> session =
+        new nsCacheSession(clientID, storagePolicy, streamBased);
+    session.forget(result);
 
     return NS_OK;
 }
 
 
 nsresult
 nsCacheService::EvictEntriesForSession(nsCacheSession * session)
 {