| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/gfx/gl/gl_context.h" | 8 #include "app/gfx/gl/gl_context.h" |
| 9 #include "app/gfx/gl/gl_implementation.h" | 9 #include "app/gfx/gl/gl_implementation.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #if defined(USE_LINUX_BREAKPAD) | 24 #if defined(USE_LINUX_BREAKPAD) |
| 25 #include "chrome/app/breakpad_linux.h" | 25 #include "chrome/app/breakpad_linux.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
| 29 #include "app/win_util.h" | 29 #include "app/win_util.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined(USE_X11) | 32 #if defined(USE_X11) |
| 33 #include "app/x11_util.h" | |
| 34 #include "app/x11_util_internal.h" | |
| 35 #include "gfx/gtk_util.h" | 33 #include "gfx/gtk_util.h" |
| 36 #endif | 34 #endif |
| 37 | 35 |
| 38 namespace { | 36 namespace { |
| 39 | 37 |
| 40 // 1% per watchdog trial group. | 38 // 1% per watchdog trial group. |
| 41 const int kFieldTrialSize = 1; | 39 const int kFieldTrialSize = 1; |
| 42 | 40 |
| 43 // 5 - 20 seconds timeout. | 41 // 5 - 20 seconds timeout. |
| 44 const int kMinGpuTimeout = 5; | 42 const int kMinGpuTimeout = 5; |
| 45 const int kMaxGpuTimeout = 20; | 43 const int kMaxGpuTimeout = 20; |
| 46 | 44 |
| 47 #if defined(USE_X11) | 45 } // namespace |
| 48 int GpuX11ErrorHandler(Display* d, XErrorEvent* error) { | |
| 49 LOG(ERROR) << x11_util::GetErrorEventDescription(d, error); | |
| 50 return 0; | |
| 51 } | |
| 52 | |
| 53 void SetGpuX11ErrorHandlers() { | |
| 54 // Set up the error handlers so that only general errors aren't fatal. | |
| 55 x11_util::SetX11ErrorHandlers(GpuX11ErrorHandler, NULL); | |
| 56 } | |
| 57 #endif | |
| 58 | |
| 59 } | |
| 60 | 46 |
| 61 // Main function for starting the Gpu process. | 47 // Main function for starting the Gpu process. |
| 62 int GpuMain(const MainFunctionParams& parameters) { | 48 int GpuMain(const MainFunctionParams& parameters) { |
| 63 base::Time start_time = base::Time::Now(); | 49 base::Time start_time = base::Time::Now(); |
| 64 | 50 |
| 65 #if defined(USE_LINUX_BREAKPAD) | 51 #if defined(USE_LINUX_BREAKPAD) |
| 66 // Needs to be called after we have chrome::DIR_USER_DATA. | 52 // Needs to be called after we have chrome::DIR_USER_DATA. |
| 67 InitCrashReporter(); | 53 InitCrashReporter(); |
| 68 #endif | 54 #endif |
| 69 | 55 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 87 #endif | 73 #endif |
| 88 | 74 |
| 89 #if defined(USE_X11) | 75 #if defined(USE_X11) |
| 90 // The X11 port of the command buffer code assumes it can access the X | 76 // The X11 port of the command buffer code assumes it can access the X |
| 91 // display via the macro GDK_DISPLAY(), which implies that Gtk has been | 77 // display via the macro GDK_DISPLAY(), which implies that Gtk has been |
| 92 // initialized. This code was taken from PluginThread. TODO(kbr): | 78 // initialized. This code was taken from PluginThread. TODO(kbr): |
| 93 // rethink whether initializing Gtk is really necessary or whether we | 79 // rethink whether initializing Gtk is really necessary or whether we |
| 94 // should just send a raw display connection down to the GPUProcessor. | 80 // should just send a raw display connection down to the GPUProcessor. |
| 95 g_thread_init(NULL); | 81 g_thread_init(NULL); |
| 96 gfx::GtkInitFromCommandLine(command_line); | 82 gfx::GtkInitFromCommandLine(command_line); |
| 97 SetGpuX11ErrorHandlers(); | |
| 98 #endif | 83 #endif |
| 99 | 84 |
| 100 // Load the GL implementation and locate the bindings before starting the GPU | 85 // Load the GL implementation and locate the bindings before starting the GPU |
| 101 // watchdog because this can take a lot of time and the GPU watchdog might | 86 // watchdog because this can take a lot of time and the GPU watchdog might |
| 102 // terminate the GPU process. | 87 // terminate the GPU process. |
| 103 if (!gfx::GLContext::InitializeOneOff()) | 88 if (!gfx::GLContext::InitializeOneOff()) |
| 104 return EXIT_FAILURE; | 89 return EXIT_FAILURE; |
| 105 | 90 |
| 106 // Do this soon before running the message loop so accurate | 91 // Do this soon before running the message loop so accurate |
| 107 // initialization time is recorded in the GPU info. Don't do it before | 92 // initialization time is recorded in the GPU info. Don't do it before |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 watchdog_thread->Start(); | 135 watchdog_thread->Start(); |
| 151 } | 136 } |
| 152 | 137 |
| 153 main_message_loop.Run(); | 138 main_message_loop.Run(); |
| 154 | 139 |
| 155 if (enable_watchdog) | 140 if (enable_watchdog) |
| 156 watchdog_thread->Stop(); | 141 watchdog_thread->Stop(); |
| 157 | 142 |
| 158 return 0; | 143 return 0; |
| 159 } | 144 } |
| OLD | NEW |