Bug 1554377 - Cleanup nsCookie implementation - Removed mIPCOpen, r=Ehsan
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 31 May 2019 09:32:51 +0000
changeset 476342 519ab3e488483b7a13c5787164e469cda3795ad0
parent 476341 6c5a7ea701e20d22a182ff9959442f8f2217b70b
child 476343 fd04e3ff79c48f86b7f4f5ada7fb18a93ed600a1
push id36092
push userarchaeopteryx@coole-files.de
push dateFri, 31 May 2019 17:03:46 +0000
treeherdermozilla-central@8384972e1f6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1554377
milestone69.0a1
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 1554377 - Cleanup nsCookie implementation - Removed mIPCOpen, r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D32616
netwerk/cookie/CookieServiceChild.cpp
netwerk/cookie/CookieServiceChild.h
--- a/netwerk/cookie/CookieServiceChild.cpp
+++ b/netwerk/cookie/CookieServiceChild.cpp
@@ -50,35 +50,33 @@ already_AddRefed<CookieServiceChild> Coo
   }
 
   return do_AddRef(gCookieService);
 }
 
 NS_IMPL_ISUPPORTS(CookieServiceChild, nsICookieService, nsIObserver,
                   nsITimerCallback, nsISupportsWeakReference)
 
-CookieServiceChild::CookieServiceChild() : mIPCOpen(false) {
+CookieServiceChild::CookieServiceChild() {
   NS_ASSERTION(IsNeckoChild(), "not a child process");
 
   mozilla::dom::ContentChild* cc =
       static_cast<mozilla::dom::ContentChild*>(gNeckoChild->Manager());
   if (cc->IsShuttingDown()) {
     return;
   }
 
   // This corresponds to Release() in DeallocPCookieService.
   NS_ADDREF_THIS();
 
   NeckoChild::InitNeckoChild();
 
   // Create a child PCookieService actor.
   gNeckoChild->SendPCookieServiceConstructor(this);
 
-  mIPCOpen = true;
-
   mThirdPartyUtil = ThirdPartyUtil::GetInstance();
   NS_ASSERTION(mThirdPartyUtil, "couldn't get ThirdPartyUtil service");
 
   mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
   NS_ASSERTION(mTLDService, "couldn't get TLDService");
 
   // Init our prefs and observer.
   nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID);
@@ -122,22 +120,18 @@ CookieServiceChild::Notify(nsITimer* aTi
   } else {
     MOZ_CRASH("Unknown timer");
   }
   return NS_OK;
 }
 
 CookieServiceChild::~CookieServiceChild() { gCookieService = nullptr; }
 
-void CookieServiceChild::ActorDestroy(ActorDestroyReason why) {
-  mIPCOpen = false;
-}
-
 void CookieServiceChild::TrackCookieLoad(nsIChannel* aChannel) {
-  if (!mIPCOpen) {
+  if (!CanSend()) {
     return;
   }
 
   bool isForeign = false;
   bool isTrackingResource = false;
   bool firstPartyStorageAccessGranted = false;
   uint32_t rejectedReason = 0;
   nsCOMPtr<nsIURI> uri;
@@ -558,17 +552,17 @@ nsresult CookieServiceChild::SetCookieSt
   } else {
     SerializeURI(nullptr, channelURIParams);
   }
 
   Maybe<LoadInfoArgs> optionalLoadInfoArgs;
   LoadInfoToLoadInfoArgs(loadInfo, &optionalLoadInfoArgs);
 
   // Asynchronously call the parent.
-  if (mIPCOpen) {
+  if (CanSend()) {
     SendSetCookieString(hostURIParams, channelURIParams, optionalLoadInfoArgs,
                         isForeign, isTrackingResource,
                         firstPartyStorageAccessGranted, rejectedReason, attrs,
                         cookieString, stringServerTime, aFromHttp);
   }
 
   bool requireHostMatch;
   nsCString baseDomain;
--- a/netwerk/cookie/CookieServiceChild.h
+++ b/netwerk/cookie/CookieServiceChild.h
@@ -93,21 +93,18 @@ class CookieServiceChild : public PCooki
       nsTArray<OriginAttributes>&& aAttrsList);
 
   mozilla::ipc::IPCResult RecvRemoveCookie(const CookieStruct& aCookie,
                                            const OriginAttributes& aAttrs);
 
   mozilla::ipc::IPCResult RecvAddCookie(const CookieStruct& aCookie,
                                         const OriginAttributes& aAttrs);
 
-  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
-
   CookiesMap mCookiesMap;
   nsCOMPtr<nsITimer> mCookieTimer;
   nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
   nsCOMPtr<nsIEffectiveTLDService> mTLDService;
-  bool mIPCOpen;
 };
 
 }  // namespace net
 }  // namespace mozilla
 
 #endif  // mozilla_net_CookieServiceChild_h__