summaryrefslogtreecommitdiffstats
path: root/content/gpu/gpu_main.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-12 01:00:41 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-12 01:00:41 +0000
commit623c0bd198a26b6609c7545a0cce0578dbad5316 (patch)
treee5cfac9d974797d95a8b4ee0aa0e4204826f089c /content/gpu/gpu_main.cc
parent23716fb643383cb737e564d55234a7c2d58eba00 (diff)
downloadchromium_src-623c0bd198a26b6609c7545a0cce0578dbad5316.zip
chromium_src-623c0bd198a26b6609c7545a0cce0578dbad5316.tar.gz
chromium_src-623c0bd198a26b6609c7545a0cce0578dbad5316.tar.bz2
Move chrome\gpu to content\gpu.
TBR=avi Review URL: http://codereview.chromium.org/6684015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/gpu/gpu_main.cc')
-rw-r--r--content/gpu/gpu_main.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc
new file mode 100644
index 0000000..ec79ba9
--- /dev/null
+++ b/content/gpu/gpu_main.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stdlib.h>
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif
+
+#include "app/win/scoped_com_initializer.h"
+#include "base/environment.h"
+#include "base/message_loop.h"
+#include "base/stringprintf.h"
+#include "base/threading/platform_thread.h"
+#include "build/build_config.h"
+#include "content/common/content_switches.h"
+#include "content/common/main_function_params.h"
+#include "content/gpu/gpu_config.h"
+#include "content/gpu/gpu_process.h"
+#include "content/gpu/gpu_thread.h"
+
+#if defined(OS_MACOSX)
+#include "content/common/chrome_application_mac.h"
+#endif
+
+#if defined(USE_X11)
+#include "ui/base/x/x11_util.h"
+#endif
+
+// Main function for starting the Gpu process.
+int GpuMain(const MainFunctionParams& parameters) {
+ base::Time start_time = base::Time::Now();
+
+ const CommandLine& command_line = parameters.command_line_;
+ if (command_line.HasSwitch(switches::kGpuStartupDialog)) {
+ ChildProcess::WaitForDebugger("Gpu");
+ }
+
+#if defined(OS_MACOSX)
+ chrome_application_mac::RegisterCrApp();
+#endif
+
+ MessageLoop main_message_loop(MessageLoop::TYPE_UI);
+ base::PlatformThread::SetName("CrGpuMain");
+
+ if (!command_line.HasSwitch(switches::kSingleProcess)) {
+#if defined(OS_WIN)
+ // Prevent Windows from displaying a modal dialog on failures like not being
+ // able to load a DLL.
+ SetErrorMode(
+ SEM_FAILCRITICALERRORS |
+ SEM_NOGPFAULTERRORBOX |
+ SEM_NOOPENFILEERRORBOX);
+#elif defined(USE_X11)
+ ui::SetDefaultX11ErrorHandlers();
+#endif
+ }
+
+ app::win::ScopedCOMInitializer com_initializer;
+
+ // We can not tolerate early returns from this code, because the
+ // detection of early return of a child process is implemented using
+ // an IPC channel error. If the IPC channel is not fully set up
+ // between the browser and GPU process, and the GPU process crashes
+ // or exits early, the browser process will never detect it. For
+ // this reason we defer all work related to the GPU until receiving
+ // the GpuMsg_Initialize message from the browser.
+ GpuProcess gpu_process;
+
+ GpuThread* gpu_thread =
+#if defined(OS_WIN)
+ new GpuThread(parameters.sandbox_info_.TargetServices());
+#else
+ new GpuThread;
+#endif
+
+ gpu_thread->Init(start_time);
+
+ gpu_process.set_main_thread(gpu_thread);
+
+ main_message_loop.Run();
+
+ gpu_thread->StopWatchdog();
+
+ return 0;
+}