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

Side by Side Diff: components/viz/common/server_gpu_memory_buffer_manager.cc

Issue 2955813002: viz: Replace a DCHECK with proper error handling. (Closed)
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 | components/viz/common/server_gpu_memory_buffer_manager_unittest.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/viz/common/server_gpu_memory_buffer_manager.h" 5 #include "components/viz/common/server_gpu_memory_buffer_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/threading/sequenced_task_runner_handle.h" 8 #include "base/threading/sequenced_task_runner_handle.h"
9 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" 9 #include "gpu/ipc/client/gpu_memory_buffer_impl.h"
10 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" 10 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h"
(...skipping 29 matching lines...) Expand all
40 pending_buffers_.insert(client_id); 40 pending_buffers_.insert(client_id);
41 gpu_service_->CreateGpuMemoryBuffer( 41 gpu_service_->CreateGpuMemoryBuffer(
42 id, size, format, usage, client_id, surface_handle, 42 id, size, format, usage, client_id, surface_handle,
43 base::Bind(&ServerGpuMemoryBufferManager::OnGpuMemoryBufferAllocated, 43 base::Bind(&ServerGpuMemoryBufferManager::OnGpuMemoryBufferAllocated,
44 weak_factory_.GetWeakPtr(), client_id, 44 weak_factory_.GetWeakPtr(), client_id,
45 base::Passed(std::move(callback)))); 45 base::Passed(std::move(callback))));
46 return; 46 return;
47 } 47 }
48 } 48 }
49 49
50 DCHECK(gpu::GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) 50 gfx::GpuMemoryBufferHandle buffer_handle;
51 << static_cast<int>(usage); 51 // The requests are coming in from untrusted clients. So verify that it is
52 task_runner_->PostTask( 52 // possible to allocate shared memory buffer first.
53 FROM_HERE, 53 if (gpu::GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage) &&
54 base::BindOnce( 54 gpu::GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size,
55 std::move(callback), 55 format)) {
56 gpu::GpuMemoryBufferImplSharedMemory::CreateGpuMemoryBuffer(id, size, 56 buffer_handle = gpu::GpuMemoryBufferImplSharedMemory::CreateGpuMemoryBuffer(
57 format))); 57 id, size, format);
58 }
59
60 task_runner_->PostTask(FROM_HERE,
61 base::BindOnce(std::move(callback), buffer_handle));
58 } 62 }
59 63
60 std::unique_ptr<gfx::GpuMemoryBuffer> 64 std::unique_ptr<gfx::GpuMemoryBuffer>
61 ServerGpuMemoryBufferManager::CreateGpuMemoryBuffer( 65 ServerGpuMemoryBufferManager::CreateGpuMemoryBuffer(
62 const gfx::Size& size, 66 const gfx::Size& size,
63 gfx::BufferFormat format, 67 gfx::BufferFormat format,
64 gfx::BufferUsage usage, 68 gfx::BufferUsage usage,
65 gpu::SurfaceHandle surface_handle) { 69 gpu::SurfaceHandle surface_handle) {
66 gfx::GpuMemoryBufferId id(next_gpu_memory_id_++); 70 gfx::GpuMemoryBufferId id(next_gpu_memory_id_++);
67 gfx::GpuMemoryBufferHandle handle; 71 gfx::GpuMemoryBufferHandle handle;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 135 }
132 std::move(callback).Run(gfx::GpuMemoryBufferHandle()); 136 std::move(callback).Run(gfx::GpuMemoryBufferHandle());
133 return; 137 return;
134 } 138 }
135 if (!handle.is_null()) 139 if (!handle.is_null())
136 native_buffers_[client_id].insert(handle.id); 140 native_buffers_[client_id].insert(handle.id);
137 std::move(callback).Run(handle); 141 std::move(callback).Run(handle);
138 } 142 }
139 143
140 } // namespace viz 144 } // namespace viz
OLDNEW
« no previous file with comments | « no previous file | components/viz/common/server_gpu_memory_buffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698