Bug 792652 - Get rid of CloneProtocol (r=dvander)
☠☠ backed out by d2098e1d1f2d ☠ ☠
authorBill McCloskey <billm@mozilla.com>
Fri, 28 Oct 2016 21:02:19 -0700
changeset 321746 92e7fee81fa21b99f7774443e4b48f42101bdd66
parent 321745 62b32efde227dd15715fee36cfdd92199c4ce12a
child 321747 004cd692ba6d4ae50ad7b082d67745760e9213c6
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersdvander
bugs792652
milestone52.0a1
Bug 792652 - Get rid of CloneProtocol (r=dvander) CloneProtocol is leftover code from Nuwa. We can remove it now.
dom/ipc/CrashReporterParent.cpp
dom/ipc/CrashReporterParent.h
dom/storage/DOMStorageIPC.cpp
dom/storage/DOMStorageIPC.h
hal/sandbox/SandboxHal.cpp
ipc/glue/ProtocolUtils.cpp
ipc/glue/ProtocolUtils.h
ipc/ipdl/ipdl/lower.py
netwerk/cookie/CookieServiceParent.cpp
netwerk/cookie/CookieServiceParent.h
netwerk/ipc/NeckoParent.cpp
netwerk/ipc/NeckoParent.h
--- a/dom/ipc/CrashReporterParent.cpp
+++ b/dom/ipc/CrashReporterParent.cpp
@@ -42,44 +42,16 @@ CrashReporterParent::ActorDestroy(ActorD
 
 bool
 CrashReporterParent::RecvAppendAppNotes(const nsCString& data)
 {
   mAppNotes.Append(data);
   return true;
 }
 
-mozilla::ipc::IProtocol*
-CrashReporterParent::CloneProtocol(Channel* aChannel,
-                                   mozilla::ipc::ProtocolCloneContext* aCtx)
-{
-#ifdef MOZ_CRASHREPORTER
-  ContentParent* contentParent = aCtx->GetContentParent();
-  CrashReporter::ThreadId childThreadId = contentParent->Pid();
-  GeckoProcessType childProcessType =
-    contentParent->Process()->GetProcessType();
-
-  nsAutoPtr<PCrashReporterParent> actor(
-    contentParent->AllocPCrashReporterParent(childThreadId,
-                                             childProcessType)
-  );
-  if (!actor ||
-      !contentParent->RecvPCrashReporterConstructor(actor,
-                                                    childThreadId,
-                                                    childThreadId)) {
-    return nullptr;
-  }
-
-  return actor.forget();
-#else
-  MOZ_CRASH("Not Implemented");
-  return nullptr;
-#endif
-}
-
 CrashReporterParent::CrashReporterParent()
   :
 #ifdef MOZ_CRASHREPORTER
     mNotes(4),
 #endif
     mStartTime(::time(nullptr))
   , mInitialized(false)
 {
--- a/dom/ipc/CrashReporterParent.h
+++ b/dom/ipc/CrashReporterParent.h
@@ -155,20 +155,16 @@ public:
                                        const nsCString& aData) override
   {
     AnnotateCrashReport(aKey, aData);
     return true;
   }
 
   virtual bool RecvAppendAppNotes(const nsCString& aData) override;
 
-  virtual mozilla::ipc::IProtocol*
-  CloneProtocol(Channel* aChannel,
-                mozilla::ipc::ProtocolCloneContext *aCtx) override;
-
 #ifdef MOZ_CRASHREPORTER
   void
   NotifyCrashService();
 #endif
 
 #ifdef MOZ_CRASHREPORTER
   AnnotationTable mNotes;
 #endif
--- a/dom/storage/DOMStorageIPC.cpp
+++ b/dom/storage/DOMStorageIPC.cpp
@@ -366,28 +366,16 @@ DOMStorageDBParent::DOMStorageDBParent()
 DOMStorageDBParent::~DOMStorageDBParent()
 {
   DOMStorageObserver* observer = DOMStorageObserver::Self();
   if (observer) {
     observer->RemoveSink(this);
   }
 }
 
-mozilla::ipc::IProtocol*
-DOMStorageDBParent::CloneProtocol(Channel* aChannel,
-                                  mozilla::ipc::ProtocolCloneContext* aCtx)
-{
-  ContentParent* contentParent = aCtx->GetContentParent();
-  nsAutoPtr<PStorageParent> actor(contentParent->AllocPStorageParent());
-  if (!actor || !contentParent->RecvPStorageConstructor(actor)) {
-    return nullptr;
-  }
-  return actor.forget();
-}
-
 DOMStorageDBParent::CacheParentBridge*
 DOMStorageDBParent::NewCache(const nsACString& aOriginSuffix, const nsACString& aOriginNoSuffix)
 {
   return new CacheParentBridge(this, aOriginSuffix, aOriginNoSuffix);
 }
 
 void
 DOMStorageDBParent::ActorDestroy(ActorDestroyReason aWhy)
--- a/dom/storage/DOMStorageIPC.h
+++ b/dom/storage/DOMStorageIPC.h
@@ -120,20 +120,16 @@ private:
 class DOMStorageDBParent final : public PStorageParent
                                , public DOMStorageObserverSink
 {
   virtual ~DOMStorageDBParent();
 
 public:
   DOMStorageDBParent();
 
-  virtual mozilla::ipc::IProtocol*
-  CloneProtocol(Channel* aChannel,
-                mozilla::ipc::ProtocolCloneContext* aCtx) override;
-
   NS_IMETHOD_(MozExternalRefCountType) AddRef(void);
   NS_IMETHOD_(MozExternalRefCountType) Release(void);
 
   void AddIPDLReference();
   void ReleaseIPDLReference();
 
   bool IPCOpen() { return mIPCOpen; }
 
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -896,28 +896,16 @@ public:
     } else {
       // Invalid factory reset reason. That should never happen.
       return false;
     }
 
     hal::FactoryReset(reason);
     return true;
   }
-
-  virtual mozilla::ipc::IProtocol*
-  CloneProtocol(Channel* aChannel,
-                mozilla::ipc::ProtocolCloneContext* aCtx) override
-  {
-    ContentParent* contentParent = aCtx->GetContentParent();
-    nsAutoPtr<PHalParent> actor(contentParent->AllocPHalParent());
-    if (!actor || !contentParent->RecvPHalConstructor(actor)) {
-      return nullptr;
-    }
-    return actor.forget();
-  }
 };
 
 class HalChild : public PHalChild {
 public:
   virtual void
   ActorDestroy(ActorDestroyReason aWhy) override
   {
     sHalChildDestroyed = true;
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -48,28 +48,16 @@ MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLAT
                                           ::LocalFree)
 MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPSecurityDescriptor, \
                                           RemovePointer<PSECURITY_DESCRIPTOR>::Type, \
                                           ::LocalFree)
 #endif
 
 namespace ipc {
 
-ProtocolCloneContext::ProtocolCloneContext()
-  : mNeckoParent(nullptr)
-{}
-
-ProtocolCloneContext::~ProtocolCloneContext()
-{}
-
-void ProtocolCloneContext::SetContentParent(ContentParent* aContentParent)
-{
-  mContentParent = aContentParent;
-}
-
 IToplevelProtocol::IToplevelProtocol(ProtocolId aProtoId)
  : mProtocolId(aProtoId)
 {
 }
 
 IToplevelProtocol::~IToplevelProtocol()
 {
   if (mTrans) {
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -125,41 +125,16 @@ struct Trigger
     {
       MOZ_ASSERT(0 <= msg && msg < INT32_MAX);
     }
 
     uint32_t mAction : 1;
     uint32_t mMessage : 31;
 };
 
-class ProtocolCloneContext
-{
-  typedef mozilla::dom::ContentParent ContentParent;
-  typedef mozilla::net::NeckoParent NeckoParent;
-
-  RefPtr<ContentParent> mContentParent;
-  NeckoParent* mNeckoParent;
-
-public:
-  ProtocolCloneContext();
-
-  ~ProtocolCloneContext();
-
-  void SetContentParent(ContentParent* aContentParent);
-
-  ContentParent* GetContentParent() { return mContentParent; }
-
-  void SetNeckoParent(NeckoParent* aNeckoParent)
-  {
-    mNeckoParent = aNeckoParent;
-  }
-
-  NeckoParent* GetNeckoParent() { return mNeckoParent; }
-};
-
 template<class ListenerT>
 class IProtocolManager
 {
 public:
     enum ActorDestroyReason {
         FailedConstructor,
         Deletion,
         AncestorDeletion,
@@ -193,25 +168,16 @@ public:
 
 typedef IPCMessageStart ProtocolId;
 
 /**
  * All RPC protocols should implement this interface.
  */
 class IProtocol : public MessageListener
 {
-public:
-    /**
-     * This function is used to clone this protocol actor.
-     *
-     * see IProtocol::CloneProtocol()
-     */
-    virtual IProtocol*
-    CloneProtocol(MessageChannel* aChannel,
-                  ProtocolCloneContext* aCtx) = 0;
 };
 
 template<class PFooSide>
 class Endpoint;
 
 /**
  * All top-level protocols should inherit this class.
  *
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -1164,19 +1164,16 @@ class Protocol(ipdl.ast.Protocol):
         return ExprVar('GetIPCChannel')
 
     def callGetChannel(self, actorThis=None):
         fn = self.getChannelMethod()
         if actorThis is not None:
             fn = ExprSelect(actorThis, '->', fn.name)
         return ExprCall(fn)
 
-    def cloneProtocol(self):
-        return ExprVar('CloneProtocol')
-
     def processingErrorVar(self):
         assert self.decl.type.isToplevel()
         return ExprVar('ProcessingError')
 
     def shouldContinueFromTimeoutVar(self):
         assert self.decl.type.isToplevel()
         return ExprVar('ShouldContinueFromReplyTimeout')
 
@@ -2631,18 +2628,16 @@ class _GenerateProtocolActorCode(ipdl.as
             Typedef(Type(self.protocol.fqBaseClass()), 'ProtocolBase'),
             Typedef(Type('IPC::Message'), 'Message'),
             Typedef(Type(self.protocol.channelName()), 'Channel'),
             Typedef(Type(self.protocol.fqListenerName()), 'ChannelListener'),
             Typedef(Type('base::ProcessHandle'), 'ProcessHandle'),
             Typedef(Type('mozilla::ipc::MessageChannel'), 'MessageChannel'),
             Typedef(Type('mozilla::ipc::SharedMemory'), 'SharedMemory'),
             Typedef(Type('mozilla::ipc::Trigger'), 'Trigger'),
-            Typedef(Type('mozilla::ipc::ProtocolCloneContext'),
-                    'ProtocolCloneContext')
         ]
 
 
     def visitTranslationUnit(self, tu):
         self.protocol = tu.protocol
 
         hf = self.hdrfile
         cf = self.cppfile
@@ -3636,18 +3631,16 @@ class _GenerateProtocolActorCode(ipdl.as
         sizevar = ExprVar('aSize')
         typevar = ExprVar('aType')
         unsafevar = ExprVar('aUnsafe')
         protocolbase = Type('ProtocolBase', ptr=1)
         sourcevar = ExprVar('aSource')
         ivar = ExprVar('i')
         kidsvar = ExprVar('kids')
         ithkid = ExprIndex(kidsvar, ivar)
-        clonecontexttype = Type('ProtocolCloneContext', ptr=1)
-        clonecontextvar = ExprVar('aCtx')
 
         register = MethodDefn(MethodDecl(
             p.registerMethod().name,
             params=[ Decl(protocolbase, routedvar.name) ],
             ret=_actorIdType(), virtual=1))
         registerid = MethodDefn(MethodDecl(
             p.registerIDMethod().name,
             params=[ Decl(protocolbase, routedvar.name),
@@ -3693,23 +3686,16 @@ class _GenerateProtocolActorCode(ipdl.as
             const=1,
             virtual=1))
 
         getchannel = MethodDefn(MethodDecl(
             p.getChannelMethod().name,
             ret=Type('MessageChannel', ptr=1),
             virtual=1))
 
-        cloneprotocol = MethodDefn(MethodDecl(
-            p.cloneProtocol().name,
-            params=[ Decl(Type('Channel', ptr=True), 'aChannel'),
-                     Decl(clonecontexttype, clonecontextvar.name) ],
-            ret=Type(p.fqBaseClass(), ptr=1),
-            virtual=1))
-
         if p.decl.type.isToplevel():
             tmpvar = ExprVar('tmp')
 
             register.addstmts([
                 StmtDecl(Decl(_actorIdType(), tmpvar.name),
                          p.nextActorIdExpr(self.side)),
                 StmtExpr(ExprCall(
                     ExprSelect(p.actorMapVar(), '.', 'AddWithID'),
@@ -3888,21 +3874,16 @@ class _GenerateProtocolActorCode(ipdl.as
                 [ rawvar ])))
             destroyshmem.addstmt(StmtReturn(ExprCall(
                 ExprSelect(p.managerVar(), '->', p.destroySharedMemory().name),
                 [ shmemvar ])))
             otherpid.addstmt(StmtReturn(
                 p.callOtherPid(p.managerVar())))
             getchannel.addstmt(StmtReturn(p.channelVar()))
 
-        cloneprotocol.addstmts([
-            _fatalError('Clone() has not yet been implemented'),
-            StmtReturn(ExprLiteral.NULL)
-        ])
-
         othervar = ExprVar('other')
         managertype = Type(_actorName(p.name, self.side), ptr=1)
 
         # Keep track of types created with an INOUT ctor. We need to call
         # Register() or RegisterID() for them depending on the side the managee
         # is created.
         inoutCtorTypes = []
         for msg in p.messageDecls:
@@ -3962,17 +3943,16 @@ class _GenerateProtocolActorCode(ipdl.as
                  unregister,
                  removemanagee,
                  createshmem,
                  lookupshmem,
                  istracking,
                  destroyshmem,
                  otherpid,
                  getchannel,
-                 cloneprotocol,
                  Whitespace.NL ]
 
     def makeShmemIface(self):
         p = self.protocol
         idvar = ExprVar('id')
         sizevar = ExprVar('aSize')
         typevar = ExprVar('aType')
         memvar = ExprVar('aMem')
--- a/netwerk/cookie/CookieServiceParent.cpp
+++ b/netwerk/cookie/CookieServiceParent.cpp
@@ -147,23 +147,11 @@ CookieServiceParent::RecvSetCookieString
   // NB: dummyChannel could be null if something failed in CreateDummyChannel.
   nsDependentCString cookieString(aCookieString, 0);
   mCookieService->SetCookieStringInternal(hostURI, aIsForeign, cookieString,
                                           aServerTime, aFromHttp, aAttrs,
                                           isPrivate, dummyChannel);
   return true;
 }
 
-mozilla::ipc::IProtocol*
-CookieServiceParent::CloneProtocol(Channel* aChannel,
-                                   mozilla::ipc::ProtocolCloneContext* aCtx)
-{
-  NeckoParent* manager = aCtx->GetNeckoParent();
-  nsAutoPtr<PCookieServiceParent> actor(manager->AllocPCookieServiceParent());
-  if (!actor || !manager->RecvPCookieServiceConstructor(actor)) {
-    return nullptr;
-  }
-  return actor.forget();
-}
-
 } // namespace net
 } // namespace mozilla
 
--- a/netwerk/cookie/CookieServiceParent.h
+++ b/netwerk/cookie/CookieServiceParent.h
@@ -31,20 +31,16 @@ protected:
 
   virtual bool RecvSetCookieString(const URIParams& aHost,
                                    const bool& aIsForeign,
                                    const nsCString& aCookieString,
                                    const nsCString& aServerTime,
                                    const bool& aFromHttp,
                                    const NeckoOriginAttributes& aAttrs) override;
 
-  virtual mozilla::ipc::IProtocol*
-  CloneProtocol(Channel* aChannel,
-                mozilla::ipc::ProtocolCloneContext* aCtx) override;
-
   RefPtr<nsCookieService> mCookieService;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // mozilla_net_CookieServiceParent_h
 
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -740,28 +740,16 @@ NeckoParent::AllocPTransportProviderPare
 bool
 NeckoParent::DeallocPTransportProviderParent(PTransportProviderParent* aActor)
 {
   RefPtr<TransportProviderParent> provider =
     dont_AddRef(static_cast<TransportProviderParent*>(aActor));
   return true;
 }
 
-mozilla::ipc::IProtocol*
-NeckoParent::CloneProtocol(Channel* aChannel,
-                           mozilla::ipc::ProtocolCloneContext* aCtx)
-{
-  ContentParent* contentParent = aCtx->GetContentParent();
-  nsAutoPtr<PNeckoParent> actor(contentParent->AllocPNeckoParent());
-  if (!actor || !contentParent->RecvPNeckoConstructor(actor)) {
-    return nullptr;
-  }
-  return actor.forget();
-}
-
 namespace {
 std::map<uint64_t, nsCOMPtr<nsIAuthPromptCallback> >&
 CallbackMap()
 {
   MOZ_ASSERT(NS_IsMainThread());
   static std::map<uint64_t, nsCOMPtr<nsIAuthPromptCallback> > sCallbackMap;
   return sCallbackMap;
 }
--- a/netwerk/ipc/NeckoParent.h
+++ b/netwerk/ipc/NeckoParent.h
@@ -162,20 +162,16 @@ protected:
                                    const uint16_t& flags) override;
   virtual bool RecvCancelHTMLDNSPrefetch(const nsString& hostname,
                                          const uint16_t& flags,
                                          const nsresult& reason) override;
   virtual PWebSocketEventListenerParent*
     AllocPWebSocketEventListenerParent(const uint64_t& aInnerWindowID) override;
   virtual bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent*) override;
 
-  virtual mozilla::ipc::IProtocol*
-  CloneProtocol(Channel* aChannel,
-                mozilla::ipc::ProtocolCloneContext* aCtx) override;
-
   virtual PDataChannelParent*
     AllocPDataChannelParent(const uint32_t& channelId) override;
   virtual bool DeallocPDataChannelParent(PDataChannelParent* parent) override;
 
   virtual bool RecvPDataChannelConstructor(PDataChannelParent* aActor,
                                            const uint32_t& channelId) override;
 
   virtual PRtspControllerParent* AllocPRtspControllerParent() override;