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

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

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking 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
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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", 539 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus",
540 status, 540 status,
541 base::TERMINATION_STATUS_MAX_ENUM); 541 base::TERMINATION_STATUS_MAX_ENUM);
542 542
543 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || 543 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION ||
544 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 544 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
545 status == base::TERMINATION_STATUS_PROCESS_CRASHED) { 545 status == base::TERMINATION_STATUS_PROCESS_CRASHED) {
546 // Windows always returns PROCESS_CRASHED on abnormal termination, as it 546 // Windows always returns PROCESS_CRASHED on abnormal termination, as it
547 // doesn't have a way to distinguish the two. 547 // doesn't have a way to distinguish the two.
548 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", 548 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode",
549 exit_code, 549 static_cast<ResultCode>(exit_code),
550 RESULT_CODE_LAST_CODE); 550 RESULT_CODE_LAST_CODE);
551 } 551 }
552 552
553 switch (status) { 553 switch (status) {
554 case base::TERMINATION_STATUS_NORMAL_TERMINATION: 554 case base::TERMINATION_STATUS_NORMAL_TERMINATION:
555 // Don't block offscreen contexts (and force page reload for webgl) 555 // Don't block offscreen contexts (and force page reload for webgl)
556 // if this was an intentional shutdown or the OOM killer on Android 556 // if this was an intentional shutdown or the OOM killer on Android
557 // killed us while Chrome was in the background. 557 // killed us while Chrome was in the background.
558 // TODO(crbug.com/598400): Restrict this to Android for now, since other 558 // TODO(crbug.com/598400): Restrict this to Android for now, since other
559 // platforms might fall through here for the 'exit_on_context_lost' workaround. 559 // platforms might fall through here for the 'exit_on_context_lost' workaround.
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 static base::Time last_gpu_crash_time; 1125 static base::Time last_gpu_crash_time;
1126 1126
1127 bool disable_crash_limit = base::CommandLine::ForCurrentProcess()->HasSwitch( 1127 bool disable_crash_limit = base::CommandLine::ForCurrentProcess()->HasSwitch(
1128 switches::kDisableGpuProcessCrashLimit); 1128 switches::kDisableGpuProcessCrashLimit);
1129 1129
1130 // Ending only acts as a failure if the GPU process was actually started and 1130 // Ending only acts as a failure if the GPU process was actually started and
1131 // was intended for actual rendering (and not just checking caps or other 1131 // was intended for actual rendering (and not just checking caps or other
1132 // options). 1132 // options).
1133 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) { 1133 if (process_launched_ && kind_ == GPU_PROCESS_KIND_SANDBOXED) {
1134 if (swiftshader_rendering_) { 1134 if (swiftshader_rendering_) {
1135 UMA_HISTOGRAM_ENUMERATION("GPU.SwiftShaderLifetimeEvents", 1135 UMA_HISTOGRAM_EXACT_LINEAR(
1136 DIED_FIRST_TIME + swiftshader_crash_count_, 1136 "GPU.SwiftShaderLifetimeEvents",
1137 GPU_PROCESS_LIFETIME_EVENT_MAX); 1137 DIED_FIRST_TIME + swiftshader_crash_count_,
1138 static_cast<int>(GPU_PROCESS_LIFETIME_EVENT_MAX));
1138 1139
1139 if (++swiftshader_crash_count_ >= kGpuMaxCrashCount && 1140 if (++swiftshader_crash_count_ >= kGpuMaxCrashCount &&
1140 !disable_crash_limit) { 1141 !disable_crash_limit) {
1141 // SwiftShader is too unstable to use. Disable it for current session. 1142 // SwiftShader is too unstable to use. Disable it for current session.
1142 gpu_enabled_ = false; 1143 gpu_enabled_ = false;
1143 } 1144 }
1144 } else { 1145 } else {
1145 ++gpu_crash_count_; 1146 ++gpu_crash_count_;
1146 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", 1147 UMA_HISTOGRAM_EXACT_LINEAR(
1147 std::min(DIED_FIRST_TIME + gpu_crash_count_, 1148 "GPU.GPUProcessLifetimeEvents",
1148 GPU_PROCESS_LIFETIME_EVENT_MAX - 1), 1149 std::min(DIED_FIRST_TIME + gpu_crash_count_,
1149 GPU_PROCESS_LIFETIME_EVENT_MAX); 1150 GPU_PROCESS_LIFETIME_EVENT_MAX - 1),
1151 static_cast<int>(GPU_PROCESS_LIFETIME_EVENT_MAX));
1150 1152
1151 // Allow about 1 GPU crash per hour to be removed from the crash count, 1153 // Allow about 1 GPU crash per hour to be removed from the crash count,
1152 // so very occasional crashes won't eventually add up and prevent the 1154 // so very occasional crashes won't eventually add up and prevent the
1153 // GPU process from launching. 1155 // GPU process from launching.
1154 ++gpu_recent_crash_count_; 1156 ++gpu_recent_crash_count_;
1155 base::Time current_time = base::Time::Now(); 1157 base::Time current_time = base::Time::Now();
1156 if (crashed_before_) { 1158 if (crashed_before_) {
1157 int hours_different = (current_time - last_gpu_crash_time).InHours(); 1159 int hours_different = (current_time - last_gpu_crash_time).InHours();
1158 gpu_recent_crash_count_ = 1160 gpu_recent_crash_count_ =
1159 std::max(0, gpu_recent_crash_count_ - hours_different); 1161 std::max(0, gpu_recent_crash_count_ - hours_different);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 if (!cache.get()) 1231 if (!cache.get())
1230 return; 1232 return;
1231 1233
1232 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, 1234 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader,
1233 weak_ptr_factory_.GetWeakPtr())); 1235 weak_ptr_factory_.GetWeakPtr()));
1234 1236
1235 client_id_to_shader_cache_[client_id] = cache; 1237 client_id_to_shader_cache_[client_id] = cache;
1236 } 1238 }
1237 1239
1238 } // namespace content 1240 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_stats.cc ('k') | content/renderer/input/render_widget_input_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698