Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / content / worker / worker_thread.cc
index de67978..687637b 100644 (file)
@@ -23,9 +23,9 @@
 #include "third_party/WebKit/public/web/WebDatabase.h"
 #include "third_party/WebKit/public/web/WebKit.h"
 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
-#include "webkit/glue/webkit_glue.h"
+#include "v8/include/v8.h"
 
-using WebKit::WebRuntimeFeatures;
+using blink::WebRuntimeFeatures;
 
 namespace content {
 
@@ -38,23 +38,27 @@ WorkerThread::WorkerThread() {
       thread_safe_sender(),
       sync_message_filter(),
       quota_message_filter()));
-  WebKit::initialize(webkit_platform_support_.get());
+
+  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+  if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
+    std::string flags(
+        command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
+    v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
+  }
+  SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line);
+
+  blink::initialize(webkit_platform_support_.get());
 
   appcache_dispatcher_.reset(
       new AppCacheDispatcher(this, new AppCacheFrontendImpl()));
 
-  web_database_observer_impl_.reset(
-      new WebDatabaseObserverImpl(sync_message_filter()));
-  WebKit::WebDatabase::setObserver(web_database_observer_impl_.get());
   db_message_filter_ = new DBMessageFilter();
   channel()->AddFilter(db_message_filter_.get());
 
   indexed_db_message_filter_ = new IndexedDBMessageFilter(
       thread_safe_sender());
-  channel()->AddFilter(indexed_db_message_filter_.get());
+  channel()->AddFilter(indexed_db_message_filter_->GetFilter());
 
-  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-  SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line);
 }
 
 void WorkerThread::OnShutdown() {
@@ -70,14 +74,18 @@ WorkerThread::~WorkerThread() {
 void WorkerThread::Shutdown() {
   ChildThread::Shutdown();
 
+  if (webkit_platform_support_) {
+    webkit_platform_support_->web_database_observer_impl()->
+        WaitForAllDatabasesToClose();
+  }
+
   // Shutdown in reverse of the initialization order.
-  channel()->RemoveFilter(indexed_db_message_filter_.get());
   indexed_db_message_filter_ = NULL;
 
   channel()->RemoveFilter(db_message_filter_.get());
   db_message_filter_ = NULL;
 
-  WebKit::shutdown();
+  blink::shutdown();
   lazy_tls.Pointer()->Set(NULL);
 }
 
@@ -109,12 +117,14 @@ bool WorkerThread::OnMessageReceived(const IPC::Message& msg) {
 
 void WorkerThread::OnCreateWorker(
     const WorkerProcessMsg_CreateWorker_Params& params) {
-  WorkerAppCacheInitInfo appcache_init_info(
-      params.creator_process_id,
-      params.shared_worker_appcache_id);
-
   // WebSharedWorkerStub own themselves.
-  new WebSharedWorkerStub(params.name, params.route_id, appcache_init_info);
+  new WebSharedWorkerStub(
+      params.url,
+      params.name,
+      params.content_security_policy,
+      params.security_policy_type,
+      params.pause_on_start,
+      params.route_id);
 }
 
 // The browser process is likely dead. Terminate all workers.