Bug 580450 - Clean up IPC::URI. r=dwitte
authorJosh Matthews <josh@joshmatthews.net>
Mon, 26 Jul 2010 15:59:34 -0400
changeset 48713 4d2c9a0c5e1c6c91a04fdb43e4d14f2afbf86704
parent 48712 36f921c9692f2bdffa23099e31a4cdfa7ace67e2
child 48714 101e02600e5bdc410184569f586a6970df191df2
push id14780
push userjmatthews@mozilla.com
push dateMon, 02 Aug 2010 15:03:56 +0000
treeherdermozilla-central@4d2c9a0c5e1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwitte
bugs580450
milestone2.0b3pre
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 580450 - Clean up IPC::URI. r=dwitte
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
netwerk/cookie/CookieServiceParent.cpp
netwerk/ipc/NeckoMessageUtils.h
netwerk/protocol/http/HttpChannelParent.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -346,15 +346,15 @@ ContentChild::RecvNotifyRemotePrefObserv
         ++i;
     }
     return true;
 }
 
 bool
 ContentChild::RecvNotifyVisited(const IPC::URI& aURI)
 {
-    nsCOMPtr<nsIURI> newURI = aURI;
+    nsCOMPtr<nsIURI> newURI(aURI);
     History::GetService()->NotifyVisited(newURI);
     return true;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -272,17 +272,17 @@ ContentParent::RecvGetChildList(const ns
 bool
 ContentParent::RecvTestPermission(const IPC::URI&  aUri,
                                    const nsCString& aType,
                                    const PRBool&    aExact,
                                    PRUint32*        retValue)
 {
     EnsurePermissionService();
 
-    nsCOMPtr<nsIURI> uri = aUri;
+    nsCOMPtr<nsIURI> uri(aUri);
     if (aExact) {
         mPermissionService->TestExactPermission(uri, aType.get(), retValue);
     } else {
         mPermissionService->TestPermission(uri, aType.get(), retValue);
     }
     return true;
 }
 
@@ -430,30 +430,30 @@ ContentParent::RequestRunToCompletion()
         mShouldCallUnblockChild = true;
     }
     return !!mRunToCompletionDepth;
 }
 
 bool
 ContentParent::RecvStartVisitedQuery(const IPC::URI& aURI)
 {
-    nsCOMPtr<nsIURI> newURI = aURI;
+    nsCOMPtr<nsIURI> newURI(aURI);
     IHistory *history = nsContentUtils::GetHistory(); 
     history->RegisterVisitedCallback(newURI, nsnull);
     return true;
 }
 
 
 bool
 ContentParent::RecvVisitURI(const IPC::URI& uri,
-                                   const IPC::URI& referrer,
-                                   const PRUint32& flags)
+                            const IPC::URI& referrer,
+                            const PRUint32& flags)
 {
-    nsCOMPtr<nsIURI> ourURI = uri;
-    nsCOMPtr<nsIURI> ourReferrer = referrer;
+    nsCOMPtr<nsIURI> ourURI(uri);
+    nsCOMPtr<nsIURI> ourReferrer(referrer);
     IHistory *history = nsContentUtils::GetHistory(); 
     history->VisitURI(ourURI, ourReferrer, flags);
     return true;
 }
 
 
 bool
 ContentParent::RecvSetURITitle(const IPC::URI& uri,
--- a/netwerk/cookie/CookieServiceParent.cpp
+++ b/netwerk/cookie/CookieServiceParent.cpp
@@ -65,18 +65,18 @@ CookieServiceParent::RecvGetCookieString
                                          const bool& aFromHttp,
                                          nsCString* aResult)
 {
   if (!mCookieService)
     return true;
 
   // Deserialize URIs. Having a host URI is mandatory and should always be
   // provided by the child; thus we consider failure fatal.
-  nsCOMPtr<nsIURI> hostURI = aHost;
-  nsCOMPtr<nsIURI> originatingURI = aOriginating;
+  nsCOMPtr<nsIURI> hostURI(aHost);
+  nsCOMPtr<nsIURI> originatingURI(aOriginating);
   if (!hostURI)
     return false;
 
   mCookieService->GetCookieInternal(hostURI, originatingURI,
                                     aFromHttp, *aResult);
   return true;
 }
 
@@ -87,18 +87,18 @@ CookieServiceParent::RecvSetCookieString
                                          const nsCString& aServerTime,
                                          const bool& aFromHttp)
 {
   if (!mCookieService)
     return true;
 
   // Deserialize URIs. Having a host URI is mandatory and should always be
   // provided by the child; thus we consider failure fatal.
-  nsCOMPtr<nsIURI> hostURI = aHost;
-  nsCOMPtr<nsIURI> originatingURI = aOriginating;
+  nsCOMPtr<nsIURI> hostURI(aHost);
+  nsCOMPtr<nsIURI> originatingURI(aOriginating);
   if (!hostURI)
     return false;
 
   mCookieService->SetCookieStringInternal(hostURI, originatingURI,
                                           aCookieString, aServerTime,
                                           aFromHttp);
   return true;
 }
--- a/netwerk/ipc/NeckoMessageUtils.h
+++ b/netwerk/ipc/NeckoMessageUtils.h
@@ -52,25 +52,26 @@ namespace IPC {
 // Since IPDL doesn't have any knowledge of pointers, there's no easy way to
 // pass around nsIURI pointers.  This is a very thin wrapper that IPDL can
 // easily work with, allowing for conversion to and from an nsIURI pointer.
 
 class URI {
  public:
   URI() : mURI(nsnull) {}
   URI(nsIURI* aURI) : mURI(aURI) {}
-  // The contained URI is already addrefed on creation. We don't want another
-  // addref when passing it off to its actual owner.
-  operator nsCOMPtr<nsIURI>() const { return already_AddRefed<nsIURI>(mURI); }
+  operator nsIURI*() const { return mURI.get(); }
 
   friend struct ParamTraits<URI>;
   
  private:
+  // Unimplemented
+  URI(URI&);
   URI& operator=(URI&);
-  nsIURI* mURI;
+
+  nsCOMPtr<nsIURI> mURI;
 };
   
 template<>
 struct ParamTraits<URI>
 {
   typedef URI paramType;
   
   static void Write(Message* aMsg, const paramType& aParam)
@@ -131,34 +132,34 @@ struct ParamTraits<URI>
           !ReadParam(aMsg, aIter, &charset))
         return false;
       
       nsCOMPtr<nsIURI> uri;
       nsresult rv = NS_NewURI(getter_AddRefs(uri), spec, charset.get());
       if (NS_FAILED(rv))
         return false;
       
-      uri.forget(&aResult->mURI);
+      uri.swap(aResult->mURI);
       return true;
     }
     
     nsCAutoString cidStr;
     nsCID cid;
     if (!ReadParam(aMsg, aIter, &cidStr) ||
         !cid.Parse(cidStr.get()))
       return false;
 
     nsCOMPtr<nsIURI> uri = do_CreateInstance(cid);
     if (!uri)
       return false;
     nsCOMPtr<nsIIPCSerializable> serializable = do_QueryInterface(uri);
     if (!serializable || !serializable->Read(aMsg, aIter))
       return false;
 
-    uri.forget(&aResult->mURI);
+    uri.swap(aResult->mURI);
     return true;
   }
 
   static void Log(const paramType& aParam, std::wstring* aLog)
   {
     nsIURI* uri = aParam.mURI;
     if (uri) {
       nsCString spec;
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -102,21 +102,21 @@ HttpChannelParent::RecvAsyncOpen(const I
                                  const nsHttpAtom&          requestMethod,
                                  const nsCString&           uploadStreamData,
                                  const PRInt32&             uploadStreamInfo,
                                  const PRUint16&            priority,
                                  const PRUint8&             redirectionLimit,
                                  const PRBool&              allowPipelining,
                                  const PRBool&              forceAllowThirdPartyCookie)
 {
-  nsCOMPtr<nsIURI> uri = aURI;
-  nsCOMPtr<nsIURI> originalUri = aOriginalURI;
-  nsCOMPtr<nsIURI> docUri = aDocURI;
-  nsCOMPtr<nsIURI> referrerUri = aReferrerURI;
-  
+  nsCOMPtr<nsIURI> uri(aURI);
+  nsCOMPtr<nsIURI> originalUri(aOriginalURI);
+  nsCOMPtr<nsIURI> docUri(aDocURI);
+  nsCOMPtr<nsIURI> referrerUri(aReferrerURI);
+
   nsCString uriSpec;
   uri->GetSpec(uriSpec);
   LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s]\n", 
        this, uriSpec.get()));
 
   nsresult rv;
 
   nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));