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

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

Issue 2753293003: gpu: Replace GpuMsg_CollectGraphicsInfo with mojom API. (Closed)
Patch Set: tot merge Created 3 years, 9 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') | services/ui/gpu/gpu_service.h » ('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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // The GPU process must never send a synchronous IPC message to the browser 227 // The GPU process must never send a synchronous IPC message to the browser
228 // process. This could result in deadlock. 228 // process. This could result in deadlock.
229 DCHECK(!msg->is_sync()); 229 DCHECK(!msg->is_sync());
230 230
231 return ChildThreadImpl::Send(msg); 231 return ChildThreadImpl::Send(msg);
232 } 232 }
233 233
234 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { 234 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) {
235 bool handled = true; 235 bool handled = true;
236 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) 236 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
237 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
238 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) 237 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched)
239 IPC_MESSAGE_UNHANDLED(handled = false) 238 IPC_MESSAGE_UNHANDLED(handled = false)
240 IPC_END_MESSAGE_MAP() 239 IPC_END_MESSAGE_MAP()
241 240
242 return handled; 241 return handled;
243 } 242 }
244 243
245 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { 244 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) {
246 if (ChildThreadImpl::OnMessageReceived(msg)) 245 if (ChildThreadImpl::OnMessageReceived(msg))
247 return true; 246 return true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 309
311 GetInterfaceRegistry()->ResumeBinding(); 310 GetInterfaceRegistry()->ResumeBinding();
312 } 311 }
313 312
314 void GpuChildThread::CreateDisplayCompositor( 313 void GpuChildThread::CreateDisplayCompositor(
315 cc::mojom::DisplayCompositorRequest request, 314 cc::mojom::DisplayCompositorRequest request,
316 cc::mojom::DisplayCompositorClientPtr client) { 315 cc::mojom::DisplayCompositorClientPtr client) {
317 NOTREACHED(); 316 NOTREACHED();
318 } 317 }
319 318
320 void GpuChildThread::OnCollectGraphicsInfo() {
321 if (dead_on_arrival_)
322 return;
323
324 gpu::GPUInfo gpu_info(gpu_service_->gpu_info());
325 #if defined(OS_MACOSX)
326 // gpu::CollectContextGraphicsInfo() is already called during gpu process
327 // initialization (see GpuInit::InitializeAndStartSandbox()) on non-mac
328 // platforms, and during in-browser gpu thread initialization on all platforms
329 // (See InProcessGpuThread::Init()).
330 if (!in_browser_process_) {
331 DCHECK_EQ(gpu::kCollectInfoNone, gpu_info.context_info_state);
332 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info);
333 switch (result) {
334 case gpu::kCollectInfoFatalFailure:
335 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal).";
336 // TODO(piman): can we signal overall failure?
337 break;
338 case gpu::kCollectInfoNonFatalFailure:
339 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal).";
340 break;
341 case gpu::kCollectInfoNone:
342 NOTREACHED();
343 break;
344 case gpu::kCollectInfoSuccess:
345 break;
346 }
347 GetContentClient()->SetGpuInfo(gpu_info);
348 }
349 #endif
350
351 #if defined(OS_WIN)
352 // GPU full info collection should only happen on un-sandboxed GPU process
353 // or single process/in-process gpu mode on Windows.
354 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
355 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) ||
356 in_browser_process_);
357
358 // This is slow, but it's the only thing the unsandboxed GPU process does,
359 // and GpuDataManager prevents us from sending multiple collecting requests,
360 // so it's OK to be blocking.
361 gpu::GetDxDiagnostics(&gpu_info.dx_diagnostics);
362 gpu_info.dx_diagnostics_info_state = gpu::kCollectInfoSuccess;
363 #endif // OS_WIN
364
365 gpu_service_->set_gpu_info(gpu_info);
366 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info));
367
368 #if defined(OS_WIN)
369 if (!in_browser_process_) {
370 // The unsandboxed GPU process fulfilled its duty. Rest in peace.
371 base::MessageLoop::current()->QuitWhenIdle();
372 }
373 #endif // OS_WIN
374 }
375
376 void GpuChildThread::OnGpuSwitched() { 319 void GpuChildThread::OnGpuSwitched() {
377 DVLOG(1) << "GPU: GPU has switched"; 320 DVLOG(1) << "GPU: GPU has switched";
378 // Notify observers in the GPU process. 321 // Notify observers in the GPU process.
379 if (!in_browser_process_) 322 if (!in_browser_process_)
380 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); 323 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
381 } 324 }
382 325
383 void GpuChildThread::OnDestroyGpuMemoryBuffer( 326 void GpuChildThread::OnDestroyGpuMemoryBuffer(
384 gfx::GpuMemoryBufferId id, 327 gfx::GpuMemoryBufferId id,
385 int client_id, 328 int client_id,
386 const gpu::SyncToken& sync_token) { 329 const gpu::SyncToken& sync_token) {
387 if (gpu_channel_manager()) 330 if (gpu_channel_manager())
388 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token); 331 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token);
389 } 332 }
390 333
391 void GpuChildThread::BindServiceFactoryRequest( 334 void GpuChildThread::BindServiceFactoryRequest(
392 service_manager::mojom::ServiceFactoryRequest request) { 335 service_manager::mojom::ServiceFactoryRequest request) {
393 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; 336 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest";
394 DCHECK(service_factory_); 337 DCHECK(service_factory_);
395 service_factory_bindings_.AddBinding(service_factory_.get(), 338 service_factory_bindings_.AddBinding(service_factory_.get(),
396 std::move(request)); 339 std::move(request));
397 } 340 }
398 341
399 } // namespace content 342 } // namespace content
OLDNEW
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | services/ui/gpu/gpu_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698