OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
16 #include "base/win/scoped_com_initializer.h" | 16 #include "base/win/scoped_com_initializer.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/common/gpu/gpu_config.h" | 18 #include "content/common/gpu/gpu_config.h" |
19 #include "content/gpu/gpu_child_thread.h" | 19 #include "content/gpu/gpu_child_thread.h" |
20 #include "content/gpu/gpu_info_collector.h" | 20 #include "content/gpu/gpu_info_collector.h" |
21 #include "content/gpu/gpu_process.h" | 21 #include "content/gpu/gpu_process.h" |
22 #include "content/public/common/content_client.h" | |
23 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
24 #include "content/public/common/main_function_params.h" | 23 #include "content/public/common/main_function_params.h" |
25 #include "crypto/hmac.h" | 24 #include "crypto/hmac.h" |
26 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
27 #include "ui/gl/gl_switches.h" | 26 #include "ui/gl/gl_switches.h" |
28 | 27 |
29 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
30 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" | 29 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
31 #include "sandbox/src/sandbox.h" | 30 #include "sandbox/src/sandbox.h" |
32 #endif | 31 #endif |
(...skipping 21 matching lines...) Expand all Loading... | |
54 // able to load a DLL. | 53 // able to load a DLL. |
55 SetErrorMode( | 54 SetErrorMode( |
56 SEM_FAILCRITICALERRORS | | 55 SEM_FAILCRITICALERRORS | |
57 SEM_NOGPFAULTERRORBOX | | 56 SEM_NOGPFAULTERRORBOX | |
58 SEM_NOOPENFILEERRORBOX); | 57 SEM_NOOPENFILEERRORBOX); |
59 #elif defined(USE_X11) | 58 #elif defined(USE_X11) |
60 ui::SetDefaultX11ErrorHandlers(); | 59 ui::SetDefaultX11ErrorHandlers(); |
61 #endif | 60 #endif |
62 } | 61 } |
63 | 62 |
64 // Initialization of the OpenGL bindings may fail, in which case we | |
65 // will need to tear down this process. However, we can not do so | |
66 // safely until the IPC channel is set up, because the detection of | |
67 // early return of a child process is implemented using an IPC | |
68 // channel error. If the IPC channel is not fully set up between the | |
69 // browser and GPU process, and the GPU process crashes or exits | |
70 // early, the browser process will never detect it. For this reason | |
71 // we defer tearing down the GPU process until receiving the | |
72 // GpuMsg_Initialize message from the browser. | |
73 bool dead_on_arrival = false; | |
74 | |
75 // Load and initialize the GL implementation and locate the GL entry points. | |
76 content::GPUInfo gpu_info; | |
77 if (gfx::GLSurface::InitializeOneOff()) { | |
apatrick_chromium
2012/05/16 18:02:35
See remarkes for gpu_child_thread.cc first. I thin
| |
78 // Collect information about the GPU. | |
79 if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info)) { | |
80 LOG(INFO) << "gpu_info_collector::CollectGraphicsInfo failed"; | |
81 } | |
82 | |
83 #if defined(OS_LINUX) | |
84 if (gpu_info.gpu.vendor_id == 0x10de && // NVIDIA | |
85 gpu_info.driver_vendor == "NVIDIA") { | |
86 base::ThreadRestrictions::AssertIOAllowed(); | |
87 if (access("/dev/nvidiactl", R_OK) != 0) { | |
88 LOG(INFO) << "NVIDIA device file /dev/nvidiactl access denied"; | |
89 gpu_info.gpu_accessible = false; | |
90 dead_on_arrival = true; | |
91 } | |
92 } | |
93 #endif | |
94 | |
95 // Set the GPU info even if it failed. | |
96 content::GetContentClient()->SetGpuInfo(gpu_info); | |
97 } else { | |
98 LOG(INFO) << "gfx::GLSurface::InitializeOneOff failed"; | |
99 gpu_info.gpu_accessible = false; | |
100 dead_on_arrival = true; | |
101 } | |
102 | |
103 // Warm up the random subsystem, which needs to be done pre-sandbox on all | 63 // Warm up the random subsystem, which needs to be done pre-sandbox on all |
104 // platforms. | 64 // platforms. |
105 (void) base::RandUint64(); | 65 (void) base::RandUint64(); |
106 | 66 |
107 // Warm up the crypto subsystem, which needs to done pre-sandbox on all | 67 // Warm up the crypto subsystem, which needs to done pre-sandbox on all |
108 // platforms. | 68 // platforms. |
109 crypto::HMAC hmac(crypto::HMAC::SHA256); | 69 crypto::HMAC hmac(crypto::HMAC::SHA256); |
110 unsigned char key = '\0'; | 70 unsigned char key = '\0'; |
111 bool ret = hmac.Init(&key, sizeof(key)); | 71 bool ret = hmac.Init(&key, sizeof(key)); |
112 (void) ret; | 72 (void) ret; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 } | 105 } |
146 #elif defined(OS_LINUX) | 106 #elif defined(OS_LINUX) |
147 message_loop_type = MessageLoop::TYPE_DEFAULT; | 107 message_loop_type = MessageLoop::TYPE_DEFAULT; |
148 #endif | 108 #endif |
149 | 109 |
150 MessageLoop main_message_loop(message_loop_type); | 110 MessageLoop main_message_loop(message_loop_type); |
151 base::PlatformThread::SetName("CrGpuMain"); | 111 base::PlatformThread::SetName("CrGpuMain"); |
152 | 112 |
153 GpuProcess gpu_process; | 113 GpuProcess gpu_process; |
154 | 114 |
155 GpuChildThread* child_thread = new GpuChildThread(dead_on_arrival, gpu_info); | 115 GpuChildThread* child_thread = new GpuChildThread; |
156 | 116 |
157 child_thread->Init(start_time); | 117 child_thread->Init(start_time); |
158 | 118 |
159 gpu_process.set_main_thread(child_thread); | 119 gpu_process.set_main_thread(child_thread); |
160 | 120 |
161 main_message_loop.Run(); | 121 main_message_loop.Run(); |
162 | 122 |
163 child_thread->StopWatchdog(); | 123 child_thread->StopWatchdog(); |
164 | 124 |
165 return 0; | 125 return 0; |
166 } | 126 } |
OLD | NEW |