code: private void drainPendingCalls() {
      assert realStream != null;
      assert !passThrough;
      List<Runnable> toRun = new ArrayList<>();
      DelayedStreamListener delayedListener = null;
      while (true) {
        synchronized (this) {
          if (pendingCalls.isEmpty()) {
            pendingCalls = null;
            passThrough = true;
            delayedListener = this.delayedListener;
            break;
          }
          // Since there were pendingCalls, we need to process them. To maintain ordering we can't set
          // passThrough=true until we run all pendingCalls, but new Runnables may be added after we
          // drop the lock. So we will have to re-check pendingCalls.
          List<Runnable> tmp = toRun;
          toRun = pendingCalls;
          pendingCalls = tmp;
        }
        for (Runnable runnable : toRun) {
          // Must not call transport while lock is held to prevent deadlocks.
          // TODO(ejona): exception handling
          runnable.run();
        }
        toRun.clear();
      }
      if (delayedListener != null) {
        delayedListener.drainPendingCallbacks();
      }
    }
docs: Called to transition {@code passThrough} to {@code true}. This method is not safe to be called
  multiple times; the caller must ensure it will only be called once, ever. {@code this} lock
  should not be held when calling this method.