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

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

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: nocompile test Created 3 years, 6 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
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/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", 541 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus",
542 status, 542 status,
543 base::TERMINATION_STATUS_MAX_ENUM); 543 base::TERMINATION_STATUS_MAX_ENUM);
544 544
545 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || 545 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION ||
546 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 546 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
547 status == base::TERMINATION_STATUS_PROCESS_CRASHED) { 547 status == base::TERMINATION_STATUS_PROCESS_CRASHED) {
548 // Windows always returns PROCESS_CRASHED on abnormal termination, as it 548 // Windows always returns PROCESS_CRASHED on abnormal termination, as it
549 // doesn't have a way to distinguish the two. 549 // doesn't have a way to distinguish the two.
550 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", 550 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode",
551 exit_code, 551 static_cast<ResultCode>(exit_code),
552 RESULT_CODE_LAST_CODE); 552 RESULT_CODE_LAST_CODE);
553 } 553 }
554 554
555 switch (status) { 555 switch (status) {
556 case base::TERMINATION_STATUS_NORMAL_TERMINATION: 556 case base::TERMINATION_STATUS_NORMAL_TERMINATION:
557 // Don't block offscreen contexts (and force page reload for webgl) 557 // Don't block offscreen contexts (and force page reload for webgl)
558 // if this was an intentional shutdown or the OOM killer on Android 558 // if this was an intentional shutdown or the OOM killer on Android
559 // killed us while Chrome was in the background. 559 // killed us while Chrome was in the background.
560 // TODO(crbug.com/598400): Restrict this to Android for now, since other 560 // TODO(crbug.com/598400): Restrict this to Android for now, since other
561 // platforms might fall through here for the 'exit_on_context_lost' workaround. 561 // platforms might fall through here for the 'exit_on_context_lost' workaround.
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 static base::Time last_gpu_crash_time; 1107 static base::Time last_gpu_crash_time;
1108 1108
1109 bool disable_crash_limit = base::CommandLine::ForCurrentProcess()->HasSwitch( 1109 bool disable_crash_limit = base::CommandLine::ForCurrentProcess()->HasSwitch(
1110 switches::kDisableGpuProcessCrashLimit); 1110 switches::kDisableGpuProcessCrashLimit);
1111 1111
1112 // Ending only acts as a failure if the GPU process was actually started and 1112 // Ending only acts as a failure if the GPU process was actually started and
1113 // was intended for actual rendering (and not just checking caps or other 1113 // was intended for actual rendering (and not just checking caps or other
1114 // options). 1114 // options).
1115 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) { 1115 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) {
1116 if (swiftshader_rendering_) { 1116 if (swiftshader_rendering_) {
1117 UMA_HISTOGRAM_ENUMERATION("GPU.SwiftShaderLifetimeEvents", 1117 UMA_HISTOGRAM_EXACT_LINEAR(
1118 DIED_FIRST_TIME + swiftshader_crash_count_, 1118 "GPU.SwiftShaderLifetimeEvents",
1119 GPU_PROCESS_LIFETIME_EVENT_MAX); 1119 DIED_FIRST_TIME + swiftshader_crash_count_,
1120 static_cast<int>(GPU_PROCESS_LIFETIME_EVENT_MAX));
1120 1121
1121 if (++swiftshader_crash_count_ >= kGpuMaxCrashCount && 1122 if (++swiftshader_crash_count_ >= kGpuMaxCrashCount &&
1122 !disable_crash_limit) { 1123 !disable_crash_limit) {
1123 // SwiftShader is too unstable to use. Disable it for current session. 1124 // SwiftShader is too unstable to use. Disable it for current session.
1124 gpu_enabled_ = false; 1125 gpu_enabled_ = false;
1125 } 1126 }
1126 } else { 1127 } else {
1127 ++gpu_crash_count_; 1128 ++gpu_crash_count_;
1128 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", 1129 UMA_HISTOGRAM_EXACT_LINEAR(
1129 std::min(DIED_FIRST_TIME + gpu_crash_count_, 1130 "GPU.GPUProcessLifetimeEvents",
1130 GPU_PROCESS_LIFETIME_EVENT_MAX - 1), 1131 std::min(DIED_FIRST_TIME + gpu_crash_count_,
1131 GPU_PROCESS_LIFETIME_EVENT_MAX); 1132 GPU_PROCESS_LIFETIME_EVENT_MAX - 1),
1133 static_cast<int>(GPU_PROCESS_LIFETIME_EVENT_MAX));
1132 1134
1133 // Allow about 1 GPU crash per hour to be removed from the crash count, 1135 // Allow about 1 GPU crash per hour to be removed from the crash count,
1134 // so very occasional crashes won't eventually add up and prevent the 1136 // so very occasional crashes won't eventually add up and prevent the
1135 // GPU process from launching. 1137 // GPU process from launching.
1136 ++gpu_recent_crash_count_; 1138 ++gpu_recent_crash_count_;
1137 base::Time current_time = base::Time::Now(); 1139 base::Time current_time = base::Time::Now();
1138 if (crashed_before_) { 1140 if (crashed_before_) {
1139 int hours_different = (current_time - last_gpu_crash_time).InHours(); 1141 int hours_different = (current_time - last_gpu_crash_time).InHours();
1140 gpu_recent_crash_count_ = 1142 gpu_recent_crash_count_ =
1141 std::max(0, gpu_recent_crash_count_ - hours_different); 1143 std::max(0, gpu_recent_crash_count_ - hours_different);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 if (!cache.get()) 1209 if (!cache.get())
1208 return; 1210 return;
1209 1211
1210 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, 1212 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader,
1211 weak_ptr_factory_.GetWeakPtr())); 1213 weak_ptr_factory_.GetWeakPtr()));
1212 1214
1213 client_id_to_shader_cache_[client_id] = cache; 1215 client_id_to_shader_cache_[client_id] = cache;
1214 } 1216 }
1215 1217
1216 } // namespace content 1218 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698