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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "content/child/child_process.h" | 11 #include "content/child/child_process.h" |
12 #include "content/child/thread_safe_sender.h" | 12 #include "content/child/thread_safe_sender.h" |
13 #include "content/common/gpu/gpu_messages.h" | 13 #include "content/common/gpu/gpu_messages.h" |
14 #include "content/gpu/gpu_watchdog_thread.h" | 14 #include "content/gpu/gpu_watchdog_thread.h" |
15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
17 #include "gpu/config/gpu_info_collector.h" | 17 #include "gpu/config/gpu_info_collector.h" |
18 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
19 #include "ipc/ipc_sync_message_filter.h" | 19 #include "ipc/ipc_sync_message_filter.h" |
20 #include "ui/gl/gl_implementation.h" | 20 #include "ui/gl/gl_implementation.h" |
21 | 21 |
22 #if defined(USE_OZONE) | |
23 #include "ui/ozone/gpu/gpu_platform_support.h" | |
24 #include "ui/ozone/ozone_platform.h" | |
25 #endif | |
26 | |
27 namespace content { | 22 namespace content { |
28 namespace { | 23 namespace { |
29 | 24 |
30 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 25 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
31 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 26 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
32 | 27 |
33 bool GpuProcessLogMessageHandler(int severity, | 28 bool GpuProcessLogMessageHandler(int severity, |
34 const char* file, int line, | 29 const char* file, int line, |
35 size_t message_start, | 30 size_t message_start, |
36 const std::string& str) { | 31 const std::string& str) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) | 106 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) |
112 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) | 107 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) |
113 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) | 108 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) |
114 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) | 109 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) |
115 IPC_MESSAGE_UNHANDLED(handled = false) | 110 IPC_MESSAGE_UNHANDLED(handled = false) |
116 IPC_END_MESSAGE_MAP() | 111 IPC_END_MESSAGE_MAP() |
117 | 112 |
118 if (handled) | 113 if (handled) |
119 return true; | 114 return true; |
120 | 115 |
121 #if defined(USE_OZONE) | |
122 if (ui::OzonePlatform::GetInstance() | |
123 ->GetGpuPlatformSupport() | |
124 ->OnMessageReceived(msg)) | |
125 return true; | |
126 #endif | |
127 | |
128 return gpu_channel_manager_.get() && | 116 return gpu_channel_manager_.get() && |
129 gpu_channel_manager_->OnMessageReceived(msg); | 117 gpu_channel_manager_->OnMessageReceived(msg); |
130 } | 118 } |
131 | 119 |
132 void GpuChildThread::OnInitialize() { | 120 void GpuChildThread::OnInitialize() { |
133 // Record initialization only after collecting the GPU info because that can | 121 // Record initialization only after collecting the GPU info because that can |
134 // take a significant amount of time. | 122 // take a significant amount of time. |
135 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 123 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
136 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); | 124 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); |
137 while (!deferred_messages_.empty()) { | 125 while (!deferred_messages_.empty()) { |
(...skipping 19 matching lines...) Expand all Loading... |
157 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 145 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
158 | 146 |
159 // Defer creation of the render thread. This is to prevent it from handling | 147 // Defer creation of the render thread. This is to prevent it from handling |
160 // IPC messages before the sandbox has been enabled and all other necessary | 148 // IPC messages before the sandbox has been enabled and all other necessary |
161 // initialization has succeeded. | 149 // initialization has succeeded. |
162 gpu_channel_manager_.reset( | 150 gpu_channel_manager_.reset( |
163 new GpuChannelManager(GetRouter(), | 151 new GpuChannelManager(GetRouter(), |
164 watchdog_thread_.get(), | 152 watchdog_thread_.get(), |
165 ChildProcess::current()->io_message_loop_proxy(), | 153 ChildProcess::current()->io_message_loop_proxy(), |
166 ChildProcess::current()->GetShutDownEvent())); | 154 ChildProcess::current()->GetShutDownEvent())); |
167 | |
168 #if defined(USE_OZONE) | |
169 ui::OzonePlatform::GetInstance() | |
170 ->GetGpuPlatformSupport() | |
171 ->OnChannelEstablished(this); | |
172 #endif | |
173 } | 155 } |
174 | 156 |
175 void GpuChildThread::StopWatchdog() { | 157 void GpuChildThread::StopWatchdog() { |
176 if (watchdog_thread_.get()) { | 158 if (watchdog_thread_.get()) { |
177 watchdog_thread_->Stop(); | 159 watchdog_thread_->Stop(); |
178 } | 160 } |
179 } | 161 } |
180 | 162 |
181 void GpuChildThread::OnCollectGraphicsInfo() { | 163 void GpuChildThread::OnCollectGraphicsInfo() { |
182 #if defined(OS_WIN) | 164 #if defined(OS_WIN) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // the future posting of tasks to the message loop. | 238 // the future posting of tasks to the message loop. |
257 if (watchdog_thread_->message_loop()) | 239 if (watchdog_thread_->message_loop()) |
258 watchdog_thread_->PostAcknowledge(); | 240 watchdog_thread_->PostAcknowledge(); |
259 // Prevent rearming. | 241 // Prevent rearming. |
260 watchdog_thread_->Stop(); | 242 watchdog_thread_->Stop(); |
261 } | 243 } |
262 } | 244 } |
263 | 245 |
264 } // namespace content | 246 } // namespace content |
265 | 247 |
OLD | NEW |