Upstream version 11.39.264.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / xwalk_runner_tizen.cc
index 886dead..3b0a322 100644 (file)
@@ -4,13 +4,24 @@
 
 #include "xwalk/runtime/browser/xwalk_runner_tizen.h"
 
+#include "base/command_line.h"
+#include "content/public/browser/browser_thread.h"
+#include "crypto/nss_util.h"
+#include "xwalk/application/browser/application_service.h"
+#include "xwalk/application/browser/application_system.h"
+#include "xwalk/application/common/id_util.h"
 #include "xwalk/runtime/browser/sysapps_component.h"
 #include "xwalk/runtime/browser/xwalk_component.h"
-#include "xwalk/sysapps/device_capabilities/device_capabilities_extension.h"
+#include "xwalk/runtime/common/xwalk_runtime_features.h"
+#include "xwalk/runtime/common/xwalk_switches.h"
 
 namespace xwalk {
 
-XWalkRunnerTizen::XWalkRunnerTizen() {}
+XWalkRunnerTizen::XWalkRunnerTizen() {
+  CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+  shared_process_mode_enabled_ =
+      !(cmd_line->HasSwitch(switches::kXWalkDisableSharedProcessMode));
+}
 
 XWalkRunnerTizen::~XWalkRunnerTizen() {}
 
@@ -19,37 +30,18 @@ XWalkRunnerTizen* XWalkRunnerTizen::GetInstance() {
   return static_cast<XWalkRunnerTizen*>(XWalkRunner::GetInstance());
 }
 
-namespace {
-
-// TODO(cmarcelo): See comment below in CreateSysAppsComponent.
-class DeviceCapabilitiesComponent : public XWalkComponent {
- public:
-  DeviceCapabilitiesComponent() {}
-  virtual ~DeviceCapabilitiesComponent() {}
-
-  // XWalkComponent implementation.
-  virtual void CreateExtensionThreadExtensions(
-      content::RenderProcessHost* host,
-      extensions::XWalkExtensionVector* extensions) OVERRIDE {
-    extensions->push_back(new sysapps::DeviceCapabilitiesExtension());
+void XWalkRunnerTizen::PreMainMessageLoopRun() {
+  XWalkRunner::PreMainMessageLoopRun();
+
+  // NSSInitSingleton is a costly operation (up to 100ms on VTC-1010),
+  // resulting in postponing the parsing and composition steps of the render
+  // process at cold start. Therefore, move the initialization logic here.
+  if (shared_process_mode_enabled()) {
+    content::BrowserThread::PostTask(
+        content::BrowserThread::IO,
+        FROM_HERE,
+        base::Bind(&crypto::EnsureNSSInit));
   }
-};
-
-}  // namespace
-
-void XWalkRunnerTizen::CreateComponents() {
-  XWalkRunner::CreateComponents();
-  AddComponent(scoped_ptr<XWalkComponent>(new DeviceCapabilitiesComponent));
-}
-
-scoped_ptr<SysAppsComponent> XWalkRunnerTizen::CreateSysAppsComponent() {
-  scoped_ptr<SysAppsComponent> sysapps_component(
-      XWalkRunner::CreateSysAppsComponent());
-  // TODO(cmarcelo): In Tizen we still use an old DeviceCapabilities, when the
-  // new version achieves feature parity we can remove the old and stop
-  // disabling the new.
-  sysapps_component->DisableDeviceCapabilities();
-  return sysapps_component.Pass();
 }
 
 }  // namespace xwalk