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 #endif |
| 25 |
22 namespace content { | 26 namespace content { |
23 namespace { | 27 namespace { |
24 | 28 |
25 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > | 29 static base::LazyInstance<scoped_refptr<ThreadSafeSender> > |
26 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; | 30 g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER; |
27 | 31 |
28 bool GpuProcessLogMessageHandler(int severity, | 32 bool GpuProcessLogMessageHandler(int severity, |
29 const char* file, int line, | 33 const char* file, int line, |
30 size_t message_start, | 34 size_t message_start, |
31 const std::string& str) { | 35 const std::string& str) { |
(...skipping 13 matching lines...) Expand all Loading... |
45 const gpu::GPUInfo& gpu_info, | 49 const gpu::GPUInfo& gpu_info, |
46 const DeferredMessages& deferred_messages) | 50 const DeferredMessages& deferred_messages) |
47 : dead_on_arrival_(dead_on_arrival), | 51 : dead_on_arrival_(dead_on_arrival), |
48 gpu_info_(gpu_info), | 52 gpu_info_(gpu_info), |
49 deferred_messages_(deferred_messages), | 53 deferred_messages_(deferred_messages), |
50 in_browser_process_(false) { | 54 in_browser_process_(false) { |
51 watchdog_thread_ = watchdog_thread; | 55 watchdog_thread_ = watchdog_thread; |
52 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
53 target_services_ = NULL; | 57 target_services_ = NULL; |
54 #endif | 58 #endif |
| 59 #if defined(USE_OZONE) |
| 60 ui::GpuPlatformSupport::Initialize(); |
| 61 #endif |
55 g_thread_safe_sender.Get() = thread_safe_sender(); | 62 g_thread_safe_sender.Get() = thread_safe_sender(); |
56 } | 63 } |
57 | 64 |
58 GpuChildThread::GpuChildThread(const std::string& channel_id) | 65 GpuChildThread::GpuChildThread(const std::string& channel_id) |
59 : ChildThread(channel_id), | 66 : ChildThread(channel_id), |
60 dead_on_arrival_(false), | 67 dead_on_arrival_(false), |
61 in_browser_process_(true) { | 68 in_browser_process_(true) { |
62 #if defined(OS_WIN) | 69 #if defined(OS_WIN) |
63 target_services_ = NULL; | 70 target_services_ = NULL; |
64 #endif | 71 #endif |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) | 113 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) |
107 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) | 114 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) |
108 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) | 115 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) |
109 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) | 116 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) |
110 IPC_MESSAGE_UNHANDLED(handled = false) | 117 IPC_MESSAGE_UNHANDLED(handled = false) |
111 IPC_END_MESSAGE_MAP() | 118 IPC_END_MESSAGE_MAP() |
112 | 119 |
113 if (handled) | 120 if (handled) |
114 return true; | 121 return true; |
115 | 122 |
| 123 #if defined(USE_OZONE) |
| 124 if (ui::GpuPlatformSupport::GetInstance()->OnMessageReceived(msg)) |
| 125 return true; |
| 126 #endif |
| 127 |
116 return gpu_channel_manager_.get() && | 128 return gpu_channel_manager_.get() && |
117 gpu_channel_manager_->OnMessageReceived(msg); | 129 gpu_channel_manager_->OnMessageReceived(msg); |
118 } | 130 } |
119 | 131 |
120 void GpuChildThread::OnInitialize() { | 132 void GpuChildThread::OnInitialize() { |
121 // Record initialization only after collecting the GPU info because that can | 133 // Record initialization only after collecting the GPU info because that can |
122 // take a significant amount of time. | 134 // take a significant amount of time. |
123 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 135 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
124 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); | 136 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); |
125 while (!deferred_messages_.empty()) { | 137 while (!deferred_messages_.empty()) { |
(...skipping 19 matching lines...) Expand all Loading... |
145 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 157 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
146 | 158 |
147 // Defer creation of the render thread. This is to prevent it from handling | 159 // Defer creation of the render thread. This is to prevent it from handling |
148 // IPC messages before the sandbox has been enabled and all other necessary | 160 // IPC messages before the sandbox has been enabled and all other necessary |
149 // initialization has succeeded. | 161 // initialization has succeeded. |
150 gpu_channel_manager_.reset( | 162 gpu_channel_manager_.reset( |
151 new GpuChannelManager(GetRouter(), | 163 new GpuChannelManager(GetRouter(), |
152 watchdog_thread_.get(), | 164 watchdog_thread_.get(), |
153 ChildProcess::current()->io_message_loop_proxy(), | 165 ChildProcess::current()->io_message_loop_proxy(), |
154 ChildProcess::current()->GetShutDownEvent())); | 166 ChildProcess::current()->GetShutDownEvent())); |
| 167 |
| 168 #if defined(USE_OZONE) |
| 169 ui::GpuPlatformSupport::GetInstance()->OnChannelEstablished(this); |
| 170 #endif |
155 } | 171 } |
156 | 172 |
157 void GpuChildThread::StopWatchdog() { | 173 void GpuChildThread::StopWatchdog() { |
158 if (watchdog_thread_.get()) { | 174 if (watchdog_thread_.get()) { |
159 watchdog_thread_->Stop(); | 175 watchdog_thread_->Stop(); |
160 } | 176 } |
161 } | 177 } |
162 | 178 |
163 void GpuChildThread::OnCollectGraphicsInfo() { | 179 void GpuChildThread::OnCollectGraphicsInfo() { |
164 #if defined(OS_WIN) | 180 #if defined(OS_WIN) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // the future posting of tasks to the message loop. | 254 // the future posting of tasks to the message loop. |
239 if (watchdog_thread_->message_loop()) | 255 if (watchdog_thread_->message_loop()) |
240 watchdog_thread_->PostAcknowledge(); | 256 watchdog_thread_->PostAcknowledge(); |
241 // Prevent rearming. | 257 // Prevent rearming. |
242 watchdog_thread_->Stop(); | 258 watchdog_thread_->Stop(); |
243 } | 259 } |
244 } | 260 } |
245 | 261 |
246 } // namespace content | 262 } // namespace content |
247 | 263 |
OLD | NEW |