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

Side by Side Diff: services/ui/gpu/gpu_service.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 | « services/ui/gpu/gpu_service.h ('k') | services/ui/gpu/interfaces/gpu_service.mojom » ('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 "services/ui/gpu/gpu_service.h" 5 #include "services/ui/gpu/gpu_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/message_loop/message_loop.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "build/build_config.h" 13 #include "build/build_config.h"
13 #include "cc/output/in_process_context_provider.h" 14 #include "cc/output/in_process_context_provider.h"
14 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 15 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
15 #include "gpu/command_buffer/service/gpu_switches.h" 16 #include "gpu/command_buffer/service/gpu_switches.h"
16 #include "gpu/command_buffer/service/sync_point_manager.h" 17 #include "gpu/command_buffer/service/sync_point_manager.h"
17 #include "gpu/config/gpu_info_collector.h" 18 #include "gpu/config/gpu_info_collector.h"
18 #include "gpu/config/gpu_switches.h" 19 #include "gpu/config/gpu_switches.h"
19 #include "gpu/config/gpu_util.h" 20 #include "gpu/config/gpu_util.h"
20 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 21 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void GpuService::GetVideoMemoryUsageStats( 183 void GpuService::GetVideoMemoryUsageStats(
183 const GetVideoMemoryUsageStatsCallback& callback) { 184 const GetVideoMemoryUsageStatsCallback& callback) {
184 gpu::VideoMemoryUsageStats video_memory_usage_stats; 185 gpu::VideoMemoryUsageStats video_memory_usage_stats;
185 if (gpu_channel_manager_) { 186 if (gpu_channel_manager_) {
186 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( 187 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats(
187 &video_memory_usage_stats); 188 &video_memory_usage_stats);
188 } 189 }
189 callback.Run(video_memory_usage_stats); 190 callback.Run(video_memory_usage_stats);
190 } 191 }
191 192
193 void GpuService::RequestCompleteGpuInfo(
194 const RequestCompleteGpuInfoCallback& callback) {
195 UpdateGpuInfoPlatform();
196 callback.Run(gpu_info_);
197 #if defined(OS_WIN)
198 if (!in_host_process_) {
199 // The unsandboxed GPU process fulfilled its duty. Rest in peace.
200 base::MessageLoop::current()->QuitWhenIdle();
201 }
202 #endif
203 }
204
205 #if defined(OS_MACOSX)
206 void GpuService::UpdateGpuInfoPlatform() {
207 // gpu::CollectContextGraphicsInfo() is already called during gpu process
208 // initialization (see GpuInit::InitializeAndStartSandbox()) on non-mac
209 // platforms, and during in-browser gpu thread initialization on all platforms
210 // (See InProcessGpuThread::Init()).
211 if (in_host_process_)
212 return;
213
214 DCHECK_EQ(gpu::kCollectInfoNone, gpu_info_.context_info_state);
215 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info_);
216 switch (result) {
217 case gpu::kCollectInfoFatalFailure:
218 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal).";
219 // TODO(piman): can we signal overall failure?
220 break;
221 case gpu::kCollectInfoNonFatalFailure:
222 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal).";
223 break;
224 case gpu::kCollectInfoNone:
225 NOTREACHED();
226 break;
227 case gpu::kCollectInfoSuccess:
228 break;
229 }
230 gpu::SetKeysForCrashLogging(gpu_info_);
231 }
232 #elif defined(OS_WIN)
233 void GpuService::UpdateGpuInfoPlatform() {
234 // GPU full info collection should only happen on un-sandboxed GPU process
235 // or single process/in-process gpu mode on Windows.
236 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
237 DCHECK(command_line->HasSwitch("disable-gpu-sandbox") || in_host_process_);
238
239 // This is slow, but it's the only thing the unsandboxed GPU process does,
240 // and GpuDataManager prevents us from sending multiple collecting requests,
241 // so it's OK to be blocking.
242 gpu::GetDxDiagnostics(&gpu_info_.dx_diagnostics);
243 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess;
244 }
245 #else
246 void GpuService::UpdateGpuInfoPlatform() {}
247 #endif
248
192 void GpuService::DidCreateOffscreenContext(const GURL& active_url) { 249 void GpuService::DidCreateOffscreenContext(const GURL& active_url) {
193 (*gpu_host_)->DidCreateOffscreenContext(active_url); 250 (*gpu_host_)->DidCreateOffscreenContext(active_url);
194 } 251 }
195 252
196 void GpuService::DidDestroyChannel(int client_id) { 253 void GpuService::DidDestroyChannel(int client_id) {
197 media_gpu_channel_manager_->RemoveChannel(client_id); 254 media_gpu_channel_manager_->RemoveChannel(client_id);
198 (*gpu_host_)->DidDestroyChannel(client_id); 255 (*gpu_host_)->DidDestroyChannel(client_id);
199 } 256 }
200 257
201 void GpuService::DidDestroyOffscreenContext(const GURL& active_url) { 258 void GpuService::DidDestroyOffscreenContext(const GURL& active_url) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 NOTREACHED() << "Java exception not supported on this platform."; 370 NOTREACHED() << "Java exception not supported on this platform.";
314 #endif 371 #endif
315 } 372 }
316 373
317 void GpuService::Stop(const StopCallback& callback) { 374 void GpuService::Stop(const StopCallback& callback) {
318 base::MessageLoop::current()->QuitWhenIdle(); 375 base::MessageLoop::current()->QuitWhenIdle();
319 callback.Run(); 376 callback.Run();
320 } 377 }
321 378
322 } // namespace ui 379 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_service.h ('k') | services/ui/gpu/interfaces/gpu_service.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698