Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: content/gpu/gpu_child_thread.cc

Issue 338193003: ozone: gpu: Add plumbing for platform-specific gpu messaging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge ozone_gpu back into ozone Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean) 110 IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean)
107 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash) 111 IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash)
108 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang) 112 IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang)
109 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog) 113 IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog)
110 IPC_MESSAGE_UNHANDLED(handled = false) 114 IPC_MESSAGE_UNHANDLED(handled = false)
111 IPC_END_MESSAGE_MAP() 115 IPC_END_MESSAGE_MAP()
112 116
113 if (handled) 117 if (handled)
114 return true; 118 return true;
115 119
120 #if defined(USE_OZONE)
121 if (ui::GpuPlatformSupport::GetInstance()->OnMessageReceived(msg))
122 return true;
123 #endif
124
116 return gpu_channel_manager_.get() && 125 return gpu_channel_manager_.get() &&
117 gpu_channel_manager_->OnMessageReceived(msg); 126 gpu_channel_manager_->OnMessageReceived(msg);
118 } 127 }
119 128
120 void GpuChildThread::OnInitialize() { 129 void GpuChildThread::OnInitialize() {
121 // Record initialization only after collecting the GPU info because that can 130 // Record initialization only after collecting the GPU info because that can
122 // take a significant amount of time. 131 // take a significant amount of time.
123 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; 132 gpu_info_.initialization_time = base::Time::Now() - process_start_time_;
124 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_)); 133 Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_));
125 while (!deferred_messages_.empty()) { 134 while (!deferred_messages_.empty()) {
(...skipping 19 matching lines...) Expand all
145 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); 154 logging::SetLogMessageHandler(GpuProcessLogMessageHandler);
146 155
147 // Defer creation of the render thread. This is to prevent it from handling 156 // 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 157 // IPC messages before the sandbox has been enabled and all other necessary
149 // initialization has succeeded. 158 // initialization has succeeded.
150 gpu_channel_manager_.reset( 159 gpu_channel_manager_.reset(
151 new GpuChannelManager(GetRouter(), 160 new GpuChannelManager(GetRouter(),
152 watchdog_thread_.get(), 161 watchdog_thread_.get(),
153 ChildProcess::current()->io_message_loop_proxy(), 162 ChildProcess::current()->io_message_loop_proxy(),
154 ChildProcess::current()->GetShutDownEvent())); 163 ChildProcess::current()->GetShutDownEvent()));
164
165 #if defined(USE_OZONE)
166 ui::GpuPlatformSupport::GetInstance()->OnChannelEstablished(this);
167 #endif
155 } 168 }
156 169
157 void GpuChildThread::StopWatchdog() { 170 void GpuChildThread::StopWatchdog() {
158 if (watchdog_thread_.get()) { 171 if (watchdog_thread_.get()) {
159 watchdog_thread_->Stop(); 172 watchdog_thread_->Stop();
160 } 173 }
161 } 174 }
162 175
163 void GpuChildThread::OnCollectGraphicsInfo() { 176 void GpuChildThread::OnCollectGraphicsInfo() {
164 #if defined(OS_WIN) 177 #if defined(OS_WIN)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // the future posting of tasks to the message loop. 251 // the future posting of tasks to the message loop.
239 if (watchdog_thread_->message_loop()) 252 if (watchdog_thread_->message_loop())
240 watchdog_thread_->PostAcknowledge(); 253 watchdog_thread_->PostAcknowledge();
241 // Prevent rearming. 254 // Prevent rearming.
242 watchdog_thread_->Stop(); 255 watchdog_thread_->Stop();
243 } 256 }
244 } 257 }
245 258
246 } // namespace content 259 } // namespace content
247 260
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698