Bug 792652 - Move TakeMinidump to IToplevelProtocol (r=dvander)
authorBill McCloskey <billm@mozilla.com>
Tue, 01 Nov 2016 20:44:27 -0700
changeset 364624 56e30c8c735bd5ccb75a68a507f8a2e73a0271b3
parent 364623 c2236f71a3ea005e6aefe5b36c08107b96483e08
child 364625 b6feaf5672e0d2876e9dc58f5a5e1f219bb2b52a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs792652
milestone52.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 792652 - Move TakeMinidump to IToplevelProtocol (r=dvander)
ipc/glue/ProtocolUtils.cpp
ipc/glue/ProtocolUtils.h
ipc/ipdl/ipdl/lower.py
--- a/ipc/glue/ProtocolUtils.cpp
+++ b/ipc/glue/ProtocolUtils.cpp
@@ -530,16 +530,27 @@ IToplevelProtocol::OtherPid() const
 
 void
 IToplevelProtocol::SetOtherProcessId(base::ProcessId aOtherPid)
 {
   mOtherPid = aOtherPid;
 }
 
 bool
+IToplevelProtocol::TakeMinidump(nsIFile** aDump, uint32_t* aSequence)
+{
+  MOZ_RELEASE_ASSERT(GetSide() == ParentSide);
+#ifdef MOZ_CRASHREPORTER
+  return XRE_TakeMinidumpForChild(OtherPid(), aDump, aSequence);
+#else
+  return false;
+#endif
+}
+
+bool
 IToplevelProtocol::Open(mozilla::ipc::Transport* aTransport,
                         base::ProcessId aOtherPid,
                         MessageLoop* aThread,
                         mozilla::ipc::Side aSide)
 {
   SetOtherProcessId(aOtherPid);
   return GetIPCChannel()->Open(aTransport, aThread, aSide);
 }
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -165,16 +165,17 @@ public:
     virtual Shmem::SharedMemory* CreateSharedMemory(
         size_t, SharedMemory::SharedMemoryType, bool, int32_t*);
     virtual Shmem::SharedMemory* LookupSharedMemory(int32_t);
     virtual bool IsTrackingSharedMemory(Shmem::SharedMemory*);
     virtual bool DestroySharedMemory(Shmem&);
 
     // XXX odd ducks, acknowledged
     virtual ProcessId OtherPid() const;
+    Side GetSide() const { return mSide; }
 
     virtual const char* ProtocolName() const = 0;
     void FatalError(const char* const aErrorMsg) const;
     virtual void HandleFatalError(const char* aProtocolName, const char* aErrorMsg) const;
 
     Maybe<IProtocol*> ReadActor(const IPC::Message* aMessage, PickleIterator* aIter, bool aNullable,
                                 const char* aActorDescription, int32_t aProtocolTypeId);
 
@@ -229,16 +230,18 @@ public:
 
     Transport* GetTransport() const { return mTrans.get(); }
 
     ProtocolId GetProtocolId() const { return mProtocolId; }
 
     base::ProcessId OtherPid() const;
     void SetOtherProcessId(base::ProcessId aOtherPid);
 
+    bool TakeMinidump(nsIFile** aDump, uint32_t* aSequence);
+
     virtual void OnChannelClose() = 0;
     virtual void OnChannelError() = 0;
     virtual void ProcessingError(Result aError, const char* aMsgName) {}
     virtual void OnChannelConnected(int32_t peer_pid) {}
 
     bool Open(mozilla::ipc::Transport* aTransport,
               base::ProcessId aOtherPid,
               MessageLoop* aThread = nullptr,
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -3184,39 +3184,16 @@ class _GenerateProtocolActorCode(ipdl.as
                                        'ProcessNativeEventsInInterruptCall'))),
                     CppDirective('else'),
                     _fatalError('This method is Windows-only'),
                     CppDirective('endif'),
                     ])
 
             self.cls.addstmts([ processnative, Whitespace.NL ])
 
-        if ptype.isToplevel() and self.side is 'parent':
-            ## bool GetMinidump(nsIFile** dump)
-            self.cls.addstmt(Label.PROTECTED)
-
-            dumpvar = ExprVar('aDump')
-            seqvar = ExprVar('aSequence')
-            getdump = MethodDefn(MethodDecl(
-                'TakeMinidump',
-                params=[ Decl(Type('nsIFile', ptrptr=1), dumpvar.name),
-                         Decl(Type.UINT32PTR, seqvar.name)],
-                ret=Type.BOOL,
-                const=1))
-            getdump.addstmts([
-                CppDirective('ifdef', 'MOZ_CRASHREPORTER'),
-                StmtReturn(ExprCall(
-                    ExprVar('XRE_TakeMinidumpForChild'),
-                    args=[ ExprCall(p.otherPidMethod()), dumpvar, seqvar ])),
-                CppDirective('else'),
-                StmtReturn.FALSE,
-                CppDirective('endif')
-            ])
-            self.cls.addstmts([ getdump, Whitespace.NL ])
-
         ## private methods
         self.cls.addstmt(Label.PRIVATE)
 
         ## ProtocolName()
         actorname = _actorName(p.name, self.side)
         protocolname = MethodDefn(MethodDecl(
             'ProtocolName', params=[],
             const=1, virtual=1, ret=Type('char', const=1, ptr=1)))