OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "base/debug/gdi_debug_util_win.h" | 4 #include "base/debug/gdi_debug_util_win.h" |
5 | 5 |
6 #include <cmath> | 6 #include <cmath> |
7 | 7 |
8 #include <psapi.h> | 8 #include <psapi.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <TlHelp32.h> | 10 #include <TlHelp32.h> |
(...skipping 21 matching lines...) Expand all Loading... |
32 proc_entry.dwSize = sizeof(PROCESSENTRY32); | 32 proc_entry.dwSize = sizeof(PROCESSENTRY32); |
33 CHECK(Process32First(snapshot, &proc_entry)); | 33 CHECK(Process32First(snapshot, &proc_entry)); |
34 | 34 |
35 do { | 35 do { |
36 if (parent_pid != proc_entry.th32ParentProcessID) | 36 if (parent_pid != proc_entry.th32ParentProcessID) |
37 continue; | 37 continue; |
38 // Got a child process. Compute GDI usage. | 38 // Got a child process. Compute GDI usage. |
39 base::win::ScopedHandle process( | 39 base::win::ScopedHandle process( |
40 OpenProcess(PROCESS_QUERY_INFORMATION, | 40 OpenProcess(PROCESS_QUERY_INFORMATION, |
41 FALSE, | 41 FALSE, |
42 proc_entry.th32ParentProcessID)); | 42 proc_entry.th32ProcessID)); |
43 if (!process.IsValid()) | 43 if (!process.IsValid()) |
44 continue; | 44 continue; |
45 | 45 |
46 int num_gdi_handles = GetGuiResources(process.Get(), GR_GDIOBJECTS); | 46 int num_gdi_handles = GetGuiResources(process.Get(), GR_GDIOBJECTS); |
47 int num_user_handles = GetGuiResources(process.Get(), GR_USEROBJECTS); | 47 int num_user_handles = GetGuiResources(process.Get(), GR_USEROBJECTS); |
48 | 48 |
49 // Compute sum and peak counts. | 49 // Compute sum and peak counts. |
50 ++child_count; | 50 ++child_count; |
51 sum_user_count += num_user_handles; | 51 sum_user_count += num_user_handles; |
52 sum_gdi_count += num_gdi_handles; | 52 sum_gdi_count += num_gdi_handles; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 0, &small_data, shared_section, 0); | 114 0, &small_data, shared_section, 0); |
115 CHECK(small_bitmap != NULL); | 115 CHECK(small_bitmap != NULL); |
116 DeleteObject(small_bitmap); | 116 DeleteObject(small_bitmap); |
117 } | 117 } |
118 // Maybe the child processes are the ones leaking GDI or USER resouces. | 118 // Maybe the child processes are the ones leaking GDI or USER resouces. |
119 CollectChildGDIUsageAndDie(GetCurrentProcessId()); | 119 CollectChildGDIUsageAndDie(GetCurrentProcessId()); |
120 } | 120 } |
121 | 121 |
122 } // namespace debug | 122 } // namespace debug |
123 } // namespace base | 123 } // namespace base |
OLD | NEW |