[Extensions Bindings] Introduce an IPCMessageSender class

IPC messages related to extension bindings (such as API method calls or
event listener changes) sent by the renderer differ depending on if it's
a call for a main thread context or a service worker context. The call
sites differ based the context type as well as whether or not native
bindings are enabled. This makes these messages confusing, and causes
duplicate logic.

Introduce an IPCMessageSender class to handle sending the IPC messages
to the browser. There are two flavors of IPCMessageSender - one for the
main thread, and one for the worker thread. This message sender can be
used from both the native bindings implementation as well as the js
implementation, allowing us to abstract out more of the details.

In this first patch, introduce the IPCMessageSender class (in its two
flavors) and use it for API method request dispatching. This allows us
to perform a couple of cleanups:
- We get rid of the SendRequestIPC method we curried into the
  NativeExtensionBindingsSystem, and
- We get rid of the ServiceWorkerRequestSender (instead of subclassing
  the RequestSender, we can pass in the IPCMessageSender, which can be
  either for the main thread or a worker thread).

Bug: 653596
Change-Id: I406aba07945f6da4b7a8ab0b9d1788aa21385f96
Reviewed-on: https://chromium-review.googlesource.com/570947
Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487102}
17 files changed