Add fallback mechanism to release Extension ports if the JS context has been destroyed.

The bug is that chrome.runtime.sendMessage looks for when its callback is
garbage collected, and when it is, close the associated port. It's important to
close the port to notify the other end of the closure, cleanup renderer state
both locally and on that other end, and potentially browser state.

Unfortunately the port management is implemented in JS itself, and port
releasing needs to go through JS. The problem is that it's not possible to call
into JS while in the process of garbage collection, so we delay it, by which
point the JS context may have been destroyed and again it's not possible to
call into JS. We fixed the former case a while ago, and this patch fixes the
latter.

BUG=471599
[email protected]

Review URL: https://codereview.chromium.org/1136953017

Cr-Commit-Position: refs/heads/master@{#330234}
diff --git a/extensions/renderer/script_context.h b/extensions/renderer/script_context.h
index 73579b9..012f11f7 100644
--- a/extensions/renderer/script_context.h
+++ b/extensions/renderer/script_context.h
@@ -108,9 +108,11 @@
   // must do that if they want.
   //
   // USE THIS METHOD RATHER THAN v8::Function::Call WHEREVER POSSIBLE.
-  v8::Local<v8::Value> CallFunction(v8::Local<v8::Function> function,
+  v8::Local<v8::Value> CallFunction(const v8::Local<v8::Function>& function,
                                     int argc,
                                     v8::Local<v8::Value> argv[]) const;
+  v8::Local<v8::Value> CallFunction(
+      const v8::Local<v8::Function>& function) const;
 
   void DispatchEvent(const char* event_name, v8::Local<v8::Array> args) const;