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

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 2963433002: Add nullptr check for GpuProcessHost when allocating GpuMemoryBuffer
Patch Set: Created 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/gpu/browser_gpu_memory_buffer_manager.h" 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 gfx::GpuMemoryBufferId id, 331 gfx::GpuMemoryBufferId id,
332 const gfx::Size& size, 332 const gfx::Size& size,
333 gfx::BufferFormat format, 333 gfx::BufferFormat format,
334 gfx::BufferUsage usage, 334 gfx::BufferUsage usage,
335 gpu::SurfaceHandle surface_handle, 335 gpu::SurfaceHandle surface_handle,
336 int client_id, 336 int client_id,
337 const CreateCallback& callback) { 337 const CreateCallback& callback) {
338 DCHECK_CURRENTLY_ON(BrowserThread::IO); 338 DCHECK_CURRENTLY_ON(BrowserThread::IO);
339 BufferMap& buffers = clients_[client_id]; 339 BufferMap& buffers = clients_[client_id];
340 340
341 GpuProcessHost* host = GpuProcessHost::Get();
342 if (!host) {
343 DLOG(ERROR) << "Cannot allocate GpuMemoryBuffer with no GpuProcessHost.";
344 callback.Run(gfx::GpuMemoryBufferHandle());
345 return;
346 }
347
341 // Note: Handling of cases where the client is removed before the allocation 348 // Note: Handling of cases where the client is removed before the allocation
342 // completes is less subtle if we set the buffer type to EMPTY_BUFFER here 349 // completes is less subtle if we set the buffer type to EMPTY_BUFFER here
343 // and verify that this has not changed when creation completes. 350 // and verify that this has not changed when creation completes.
344 auto insert_result = buffers.insert(std::make_pair( 351 auto insert_result = buffers.insert(std::make_pair(
345 id, BufferInfo(size, gfx::EMPTY_BUFFER, format, usage, 0))); 352 id, BufferInfo(size, gfx::EMPTY_BUFFER, format, usage, 0)));
346 if (!insert_result.second) { 353 if (!insert_result.second) {
347 DLOG(ERROR) << "Child process attempted to create a GpuMemoryBuffer with " 354 DLOG(ERROR) << "Child process attempted to create a GpuMemoryBuffer with "
348 "an existing ID."; 355 "an existing ID.";
349 callback.Run(gfx::GpuMemoryBufferHandle()); 356 callback.Run(gfx::GpuMemoryBufferHandle());
350 return; 357 return;
351 } 358 }
352 359
353 GpuProcessHost* host = GpuProcessHost::Get();
354 // Note: Unretained is safe as IO thread is stopped before manager is 360 // Note: Unretained is safe as IO thread is stopped before manager is
355 // destroyed. 361 // destroyed.
356 host->CreateGpuMemoryBuffer( 362 host->CreateGpuMemoryBuffer(
357 id, size, format, usage, client_id, surface_handle, 363 id, size, format, usage, client_id, surface_handle,
358 base::Bind(&BrowserGpuMemoryBufferManager::GpuMemoryBufferCreatedOnIO, 364 base::Bind(&BrowserGpuMemoryBufferManager::GpuMemoryBufferCreatedOnIO,
359 base::Unretained(this), id, surface_handle, client_id, 365 base::Unretained(this), id, surface_handle, client_id,
360 host->host_id(), callback)); 366 host->host_id(), callback));
361 } 367 }
362 368
363 void BrowserGpuMemoryBufferManager::GpuMemoryBufferCreatedOnIO( 369 void BrowserGpuMemoryBufferManager::GpuMemoryBufferCreatedOnIO(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 format(format), 483 format(format),
478 usage(usage), 484 usage(usage),
479 gpu_host_id(gpu_host_id) {} 485 gpu_host_id(gpu_host_id) {}
480 486
481 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = 487 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) =
482 default; 488 default;
483 489
484 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} 490 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {}
485 491
486 } // namespace content 492 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698