Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / content / browser / browser_main_loop.cc
index 23d2936..3376aeb 100644 (file)
@@ -70,6 +70,7 @@
 #include "base/android/jni_android.h"
 #include "content/browser/android/browser_startup_controller.h"
 #include "content/browser/android/surface_texture_peer_browser_impl.h"
+#include "ui/gl/gl_surface.h"
 #endif
 
 #if defined(OS_MACOSX) && !defined(OS_IOS)
@@ -81,7 +82,6 @@
 #include <commctrl.h>
 #include <shellapi.h>
 
-#include "base/win/text_services_message_filter.h"
 #include "content/browser/system_message_window_win.h"
 #include "content/common/sandbox_win.h"
 #include "net/base/winsock_init.h"
 #include <X11/Xlib.h>
 #endif
 
+#if defined(USE_OZONE)
+#include "ui/ozone/ozone_platform.h"
+#endif
+
 // One of the linux specific headers defines this as a macro.
 #ifdef DestroyAll
 #undef DestroyAll
@@ -324,7 +328,8 @@ BrowserMainLoop::BrowserMainLoop(const MainFunctionParams& parameters)
       created_threads_(false),
       // ContentMainRunner should have enabled tracing of the browser process
       // when kTraceStartup is in the command line.
-      is_tracing_startup_(base::debug::TraceLog::GetInstance()->IsEnabled()) {
+      is_tracing_startup_(
+          parameters.command_line.HasSwitch(switches::kTraceStartup)) {
   DCHECK(!g_current_browser_main_loop);
   g_current_browser_main_loop = this;
 }
@@ -466,8 +471,8 @@ void BrowserMainLoop::MainMessageLoopStart() {
         MediaInternals::GetInstance()));
   }
   {
-    TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MIDIManager")
-    midi_manager_.reset(media::MIDIManager::Create());
+    TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:MidiManager")
+    midi_manager_.reset(media::MidiManager::Create());
   }
   {
     TRACE_EVENT0("startup", "BrowserMainLoop::Subsystem:ContentWebUIController")
@@ -499,17 +504,6 @@ void BrowserMainLoop::MainMessageLoopStart() {
 
 #if defined(OS_WIN)
   system_message_window_.reset(new SystemMessageWindowWin);
-
-  if (base::win::IsTSFAwareRequired()) {
-    // Create a TSF message filter for the message loop. MessageLoop takes
-    // ownership of the filter.
-    scoped_ptr<base::win::TextServicesMessageFilter> tsf_message_filter(
-      new base::win::TextServicesMessageFilter);
-    if (tsf_message_filter->Init()) {
-      base::MessageLoopForUI::current()->SetMessageFilter(
-        tsf_message_filter.PassAs<base::MessageLoopForUI::MessageFilter>());
-    }
-  }
 #endif
 
   if (parts_)
@@ -783,6 +777,10 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
   }
 #endif
 
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
+  ZygoteHostImpl::GetInstance()->TearDownAfterLastChild();
+#endif  // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
+
   // The device monitors are using |system_monitor_| as dependency, so delete
   // them before |system_monitor_| goes away.
   // On Mac and windows, the monitor needs to be destroyed on the same thread
@@ -943,6 +941,13 @@ int BrowserMainLoop::BrowserThreadsStarted() {
 #if !defined(OS_IOS)
   HistogramSynchronizer::GetInstance();
 
+#if defined(OS_ANDROID)
+  // On Android, GLSurface::InitializeOneOff() must be called before initalizing
+  // the GpuDataManagerImpl as it uses the GL bindings. crbug.com/326295
+  if (!gfx::GLSurface::InitializeOneOff())
+    LOG(FATAL) << "GLSurface::InitializeOneOff failed";
+#endif
+
   // Initialize the GpuDataManager before we set up the MessageLoops because
   // otherwise we'll trigger the assertion about doing IO on the UI thread.
   GpuDataManagerImpl::GetInstance()->Initialize();
@@ -971,6 +976,12 @@ int BrowserMainLoop::BrowserThreadsStarted() {
   device_monitor_mac_.reset(new DeviceMonitorMac());
 #endif
 
+#if defined(USE_OZONE)
+  ui::OzonePlatform::Initialize();
+  ui::EventFactoryOzone::GetInstance()->SetFileTaskRunner(
+      BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+#endif
+
   // RDH needs the IO thread to be created
   {
     TRACE_EVENT0("startup",