Use a joinable background thread instead of worker pool in gin

gin's V8Platform wants to provide a way to run background tasks on V8's
behalf. It was using a base::WorkerPool, which lazily constructs non
joinable threads to execute tasks. This is problematic when running
inside a shared library that needs to stop completely so it can be
unloaded. This uses a single lazily constructed thread for background
tasks. In the context of js_content_handler there likely isn't another
thread sitting around which could share work with this since all the
app does is run JS, so pooling isn't that useful.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/988483002
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index ec163de..c8ee770 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -7,7 +7,7 @@
 #include "base/bind.h"
 #include "base/location.h"
 #include "base/message_loop/message_loop_proxy.h"
-#include "base/threading/worker_pool.h"
+#include "base/threading/thread.h"
 #include "gin/per_isolate_data.h"
 
 namespace gin {
@@ -28,10 +28,13 @@
 void V8Platform::CallOnBackgroundThread(
     v8::Task* task,
     v8::Platform::ExpectedRuntime expected_runtime) {
-  base::WorkerPool::PostTask(
+  if (!background_thread_) {
+    background_thread_.reset(new base::Thread("gin_background"));
+    background_thread_->Start();
+  }
+  background_thread_->message_loop_proxy()->PostTask(
       FROM_HERE,
-      base::Bind(&v8::Task::Run, base::Owned(task)),
-      expected_runtime == v8::Platform::kLongRunningTask);
+      base::Bind(&v8::Task::Run, base::Owned(task)));
 }
 
 void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {