Cherry pick "Cache pending JS bridge sync IPC replies, and send in case of RenderFrame deletion."

conflicts in:
  content/common/android/gin_java_bridge_errors.cc
  content/common/android/gin_java_bridge_errors.h

Bug: 16840290

Original description:
Cache pending JS bridge sync IPC replies, and send in case of
RenderFrame deletion.

When the WebView app makes a call to java over the JavaScriptBridge,
we leave the renderer hanging on a synchronous IPC. Once control
is passed into Java, it's possible that the WebView may get destroyed
(and thus the IPC channel back to the renderer closed) which means we
can't unblock the renderer waiting on the IPC response.

Instead we cache the IPC reply message and while waiting on Java to come
back to us, if we detect that the RenderFrame has been deleted, send a
reponse back before the IPC channel is closed.

BUG=408188
Committed:
https://chromium.googlesource.com/chromium/src/+/5d3e001f79c137b2ba0f5b0e9489abea616f3431

Change-Id: I7f1b28e297059eb69c5686316b47d926ea8a3d4f
5 files changed