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

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

Issue 2104553002: Migrate GpuProcess to use MojoChild/ShellConnection for the Shell handshake (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/public/app/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 builder.AddStartupFilter( 128 builder.AddStartupFilter(
129 new GpuMemoryBufferMessageFilter(gpu_memory_buffer_factory)); 129 new GpuMemoryBufferMessageFilter(gpu_memory_buffer_factory));
130 130
131 #if defined(USE_OZONE) 131 #if defined(USE_OZONE)
132 IPC::MessageFilter* message_filter = ui::OzonePlatform::GetInstance() 132 IPC::MessageFilter* message_filter = ui::OzonePlatform::GetInstance()
133 ->GetGpuPlatformSupport() 133 ->GetGpuPlatformSupport()
134 ->GetMessageFilter(); 134 ->GetMessageFilter();
135 if (message_filter) 135 if (message_filter)
136 builder.AddStartupFilter(message_filter); 136 builder.AddStartupFilter(message_filter);
137 #endif 137 #endif
138 builder.UseMojoShellConnection(true);
138 139
139 return builder.Build(); 140 return builder.Build();
140 } 141 }
141 142
142 } // namespace 143 } // namespace
143 144
144 // static 145 // static
145 GpuChildThread* GpuChildThread::current() { 146 GpuChildThread* GpuChildThread::current() {
146 return g_lazy_tls.Pointer()->Get(); 147 return g_lazy_tls.Pointer()->Get();
147 } 148 }
(...skipping 19 matching lines...) Expand all
167 } 168 }
168 169
169 GpuChildThread::GpuChildThread( 170 GpuChildThread::GpuChildThread(
170 const gpu::GpuPreferences& gpu_preferences, 171 const gpu::GpuPreferences& gpu_preferences,
171 const InProcessChildThreadParams& params, 172 const InProcessChildThreadParams& params,
172 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) 173 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
173 : ChildThreadImpl(ChildThreadImpl::Options::Builder() 174 : ChildThreadImpl(ChildThreadImpl::Options::Builder()
174 .InBrowserProcess(params) 175 .InBrowserProcess(params)
175 .AddStartupFilter(new GpuMemoryBufferMessageFilter( 176 .AddStartupFilter(new GpuMemoryBufferMessageFilter(
176 gpu_memory_buffer_factory)) 177 gpu_memory_buffer_factory))
178 .UseMojoShellConnection(true)
177 .Build()), 179 .Build()),
178 gpu_preferences_(gpu_preferences), 180 gpu_preferences_(gpu_preferences),
179 dead_on_arrival_(false), 181 dead_on_arrival_(false),
180 in_browser_process_(true), 182 in_browser_process_(true),
181 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) { 183 gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {
182 #if defined(OS_WIN) 184 #if defined(OS_WIN)
183 target_services_ = NULL; 185 target_services_ = NULL;
184 #endif 186 #endif
185 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( 187 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
186 switches::kSingleProcess) || 188 switches::kSingleProcess) ||
(...skipping 26 matching lines...) Expand all
213 #if defined(OS_ANDROID) 215 #if defined(OS_ANDROID)
214 // When running in in-process mode, this has been set in the browser at 216 // When running in in-process mode, this has been set in the browser at
215 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). 217 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun().
216 if (!in_browser_process_) 218 if (!in_browser_process_)
217 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); 219 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid());
218 #endif 220 #endif
219 221
220 // Only set once per process instance. 222 // Only set once per process instance.
221 process_control_.reset(new GpuProcessControlImpl()); 223 process_control_.reset(new GpuProcessControlImpl());
222 224
223 // Use of base::Unretained(this) is safe here because |service_registry()| 225 if (GetContentClient()->gpu()) // NULL in tests.
224 // will be destroyed before GpuChildThread is destructed.
225 GetInterfaceRegistry()->AddInterface(base::Bind(
226 &GpuChildThread::BindProcessControlRequest, base::Unretained(this)));
227
228 if (GetContentClient()->gpu()) { // NULL in tests.
229 GetContentClient()->gpu()->Initialize(this); 226 GetContentClient()->gpu()->Initialize(this);
230 GetContentClient()->gpu()->ExposeInterfacesToBrowser(
231 GetInterfaceRegistry());
232 }
233 } 227 }
234 228
235 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, 229 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name,
236 const std::string& group_name) { 230 const std::string& group_name) {
237 Send(new GpuHostMsg_FieldTrialActivated(trial_name)); 231 Send(new GpuHostMsg_FieldTrialActivated(trial_name));
238 } 232 }
239 233
240 bool GpuChildThread::Send(IPC::Message* msg) { 234 bool GpuChildThread::Send(IPC::Message* msg) {
241 // The GPU process must never send a synchronous IPC message to the browser 235 // The GPU process must never send a synchronous IPC message to the browser
242 // process. This could result in deadlock. 236 // process. This could result in deadlock.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 OnDestroyingVideoSurface); 284 OnDestroyingVideoSurface);
291 #endif 285 #endif
292 IPC_MESSAGE_UNHANDLED(handled = false) 286 IPC_MESSAGE_UNHANDLED(handled = false)
293 IPC_END_MESSAGE_MAP() 287 IPC_END_MESSAGE_MAP()
294 if (handled) 288 if (handled)
295 return true; 289 return true;
296 290
297 return false; 291 return false;
298 } 292 }
299 293
294 bool GpuChildThread::AcceptConnection(shell::Connection* connection) {
295 // Use of base::Unretained(this) is safe here because |service_registry()|
296 // will be destroyed before GpuChildThread is destructed.
297 connection->GetInterfaceRegistry()->AddInterface(base::Bind(
298 &GpuChildThread::BindProcessControlRequest, base::Unretained(this)));
299
300 if (GetContentClient()->gpu()) { // NULL in tests.
301 GetContentClient()->gpu()->ExposeInterfacesToBrowser(
302 connection->GetInterfaceRegistry());
303 }
304 return true;
305 }
306
307 shell::InterfaceRegistry* GpuChildThread::GetInterfaceRegistryForConnection() {
308 return nullptr;
309 }
310
311 shell::InterfaceProvider* GpuChildThread::GetInterfaceProviderForConnection() {
312 return nullptr;
313 }
314
300 void GpuChildThread::SetActiveURL(const GURL& url) { 315 void GpuChildThread::SetActiveURL(const GURL& url) {
301 GetContentClient()->SetActiveURL(url); 316 GetContentClient()->SetActiveURL(url);
302 } 317 }
303 318
304 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { 319 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
305 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); 320 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url));
306 } 321 }
307 322
308 void GpuChildThread::DidDestroyChannel(int client_id) { 323 void GpuChildThread::DidDestroyChannel(int client_id) {
309 media_service_->RemoveChannel(client_id); 324 media_service_->RemoveChannel(client_id);
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 572
558 void GpuChildThread::BindProcessControlRequest( 573 void GpuChildThread::BindProcessControlRequest(
559 mojo::InterfaceRequest<mojom::ProcessControl> request) { 574 mojo::InterfaceRequest<mojom::ProcessControl> request) {
560 DVLOG(1) << "GPU: Binding ProcessControl request"; 575 DVLOG(1) << "GPU: Binding ProcessControl request";
561 DCHECK(process_control_); 576 DCHECK(process_control_);
562 process_control_bindings_.AddBinding(process_control_.get(), 577 process_control_bindings_.AddBinding(process_control_.get(),
563 std::move(request)); 578 std::move(request));
564 } 579 }
565 580
566 } // namespace content 581 } // namespace content
OLDNEW
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/public/app/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698