libbinder: RPC factor out BinderNode erase

In preparation for adding an invariant here.

Bug: 183140903
Test: binderRpcTest
Change-Id: I541f7c3e5bcb5ee049fabe34acb9784cfeed0d0c
diff --git a/libs/binder/RpcState.h b/libs/binder/RpcState.h
index d448938..2654dff 100644
--- a/libs/binder/RpcState.h
+++ b/libs/binder/RpcState.h
@@ -195,6 +195,12 @@
         // (no additional data specific to remote binders)
     };
 
+    // checks if there is any reference left to a node and erases it. If erase
+    // happens, and there is a strong reference to the binder kept by
+    // binderNode, this returns that strong reference, so that it can be
+    // dropped after any locks are removed.
+    sp<IBinder> tryEraseNode(std::map<RpcAddress, BinderNode>::iterator& it);
+
     std::mutex mNodeMutex;
     bool mTerminated = false;
     // binders known by both sides of a session