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

Unified Diff: base/debug/gdi_debug_util_win.cc

Issue 2467283002: Collect total counters in case of GDI failure. (Closed)
Patch Set: Use std::max instead of 'if'. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/gdi_debug_util_win.cc
diff --git a/base/debug/gdi_debug_util_win.cc b/base/debug/gdi_debug_util_win.cc
index bb5e933418d7df97cab90fe41edfda5cb5dc190d..bf9827c57579edc40d8b945062989a20445494c1 100644
--- a/base/debug/gdi_debug_util_win.cc
+++ b/base/debug/gdi_debug_util_win.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/debug/gdi_debug_util_win.h"
+#include <algorithm>
#include <cmath>
#include <psapi.h>
@@ -20,6 +21,15 @@ void CollectChildGDIUsageAndDie(DWORD parent_pid) {
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
CHECK_NE(INVALID_HANDLE_VALUE, snapshot);
+ int total_process_count = 0;
+ base::debug::Alias(&total_process_count);
+ int total_peak_gdi_count = 0;
+ base::debug::Alias(&total_peak_gdi_count);
+ int total_gdi_count = 0;
+ base::debug::Alias(&total_gdi_count);
+ int total_user_count = 0;
+ base::debug::Alias(&total_user_count);
+
int child_count = 0;
base::debug::Alias(&child_count);
int peak_gdi_count = 0;
@@ -34,9 +44,6 @@ void CollectChildGDIUsageAndDie(DWORD parent_pid) {
CHECK(Process32First(snapshot, &proc_entry));
do {
- if (parent_pid != proc_entry.th32ParentProcessID)
- continue;
- // Got a child process. Compute GDI usage.
base::win::ScopedHandle process(
OpenProcess(PROCESS_QUERY_INFORMATION,
FALSE,
@@ -47,12 +54,20 @@ void CollectChildGDIUsageAndDie(DWORD parent_pid) {
int num_gdi_handles = GetGuiResources(process.Get(), GR_GDIOBJECTS);
int num_user_handles = GetGuiResources(process.Get(), GR_USEROBJECTS);
- // Compute sum and peak counts.
+ // Compute sum and peak counts for all processes.
+ ++total_process_count;
+ total_user_count += num_user_handles;
+ total_gdi_count += num_gdi_handles;
+ total_peak_gdi_count = std::max(total_peak_gdi_count, num_gdi_handles);
+
+ if (parent_pid != proc_entry.th32ParentProcessID)
+ continue;
+
+ // Compute sum and peak counts for child processes.
++child_count;
sum_user_count += num_user_handles;
sum_gdi_count += num_gdi_handles;
- if (peak_gdi_count < num_gdi_handles)
- peak_gdi_count = num_gdi_handles;
+ peak_gdi_count = std::max(peak_gdi_count, num_gdi_handles);
} while (Process32Next(snapshot, &proc_entry));
« 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