| 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 "content/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/common/child_process.h" | 14 #include "content/common/child_process.h" |
| 15 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
| 16 #include "content/gpu/gpu_info_collector.h" | 16 #include "content/gpu/gpu_info_collector.h" |
| 17 #include "content/gpu/gpu_watchdog_thread.h" | 17 #include "content/gpu/gpu_watchdog_thread.h" |
| 18 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
| 19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 20 #include "ipc/ipc_channel_handle.h" | 20 #include "ipc/ipc_channel_handle.h" |
| 21 #include "ipc/ipc_sync_message_filter.h" | 21 #include "ipc/ipc_sync_message_filter.h" |
| 22 #include "ui/gl/gl_implementation.h" | 22 #include "ui/gl/gl_implementation.h" |
| 23 | 23 |
| 24 #if defined(OS_ANDROID) |
| 25 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 26 #include <sys/resource.h> |
| 27 #endif |
| 28 |
| 24 namespace content { | 29 namespace content { |
| 25 namespace { | 30 namespace { |
| 26 | 31 |
| 27 bool GpuProcessLogMessageHandler(int severity, | 32 bool GpuProcessLogMessageHandler(int severity, |
| 28 const char* file, int line, | 33 const char* file, int line, |
| 29 size_t message_start, | 34 size_t message_start, |
| 30 const std::string& str) { | 35 const std::string& str) { |
| 31 std::string header = str.substr(0, message_start); | 36 std::string header = str.substr(0, message_start); |
| 32 std::string message = str.substr(message_start); | 37 std::string message = str.substr(message_start); |
| 33 | 38 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 123 |
| 119 void GpuChildThread::OnInitialize() { | 124 void GpuChildThread::OnInitialize() { |
| 120 Send(new GpuHostMsg_Initialized(!dead_on_arrival_)); | 125 Send(new GpuHostMsg_Initialized(!dead_on_arrival_)); |
| 121 | 126 |
| 122 if (dead_on_arrival_) { | 127 if (dead_on_arrival_) { |
| 123 VLOG(1) << "Exiting GPU process due to errors during initialization"; | 128 VLOG(1) << "Exiting GPU process due to errors during initialization"; |
| 124 MessageLoop::current()->Quit(); | 129 MessageLoop::current()->Quit(); |
| 125 return; | 130 return; |
| 126 } | 131 } |
| 127 | 132 |
| 133 #if defined(OS_ANDROID) |
| 134 // TODO(epenner): Move thread priorities to base. (crbug.com/170549) |
| 135 int nice_value = -6; // High priority |
| 136 setpriority(PRIO_PROCESS, base::PlatformThread::CurrentId(), nice_value); |
| 137 #endif |
| 138 |
| 128 // We don't need to pipe log messages if we are running the GPU thread in | 139 // We don't need to pipe log messages if we are running the GPU thread in |
| 129 // the browser process. | 140 // the browser process. |
| 130 if (!in_browser_process_) | 141 if (!in_browser_process_) |
| 131 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 142 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
| 132 | 143 |
| 133 // Record initialization only after collecting the GPU info because that can | 144 // Record initialization only after collecting the GPU info because that can |
| 134 // take a significant amount of time. | 145 // take a significant amount of time. |
| 135 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 146 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
| 136 | 147 |
| 137 // Defer creation of the render thread. This is to prevent it from handling | 148 // Defer creation of the render thread. This is to prevent it from handling |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // the future posting of tasks to the message loop. | 238 // the future posting of tasks to the message loop. |
| 228 if (watchdog_thread_->message_loop()) | 239 if (watchdog_thread_->message_loop()) |
| 229 watchdog_thread_->PostAcknowledge(); | 240 watchdog_thread_->PostAcknowledge(); |
| 230 // Prevent rearming. | 241 // Prevent rearming. |
| 231 watchdog_thread_->Stop(); | 242 watchdog_thread_->Stop(); |
| 232 } | 243 } |
| 233 } | 244 } |
| 234 | 245 |
| 235 } // namespace content | 246 } // namespace content |
| 236 | 247 |
| OLD | NEW |