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

Side by Side Diff: chrome/browser/task_manager/sampling/shared_sampler_win_defines.h

Issue 2657393003: Add unit-test for SharedSampler handling of zero-thread processes. (Closed)
Patch Set: Remove anonymous namespace Created 3 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_WIN_DEFINES_H_
6 #define CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_WIN_DEFINES_H_
7
8 #include <windows.h>
9 #include <winternl.h>
10
11 namespace task_manager {
12
13 // From <wdm.h>
14 typedef LONG KPRIORITY;
15 typedef LONG KWAIT_REASON; // Full definition is in wdm.h
16
17 // From ntddk.h
18 typedef struct _VM_COUNTERS {
19 SIZE_T PeakVirtualSize;
20 SIZE_T VirtualSize;
21 ULONG PageFaultCount;
22 // Padding here in 64-bit
23 SIZE_T PeakWorkingSetSize;
24 SIZE_T WorkingSetSize;
25 SIZE_T QuotaPeakPagedPoolUsage;
26 SIZE_T QuotaPagedPoolUsage;
27 SIZE_T QuotaPeakNonPagedPoolUsage;
28 SIZE_T QuotaNonPagedPoolUsage;
29 SIZE_T PagefileUsage;
30 SIZE_T PeakPagefileUsage;
31 } VM_COUNTERS;
32
33 // Two possibilities available from here:
34 // http://stackoverflow.com/questions/28858849/where-is-system-information-class -defined
35
36 typedef enum _SYSTEM_INFORMATION_CLASS {
37 SystemProcessInformation = 5, // This is the number that we need.
38 } SYSTEM_INFORMATION_CLASS;
39
40 // https://msdn.microsoft.com/en-us/library/gg750647.aspx?f=255&MSPPError=-21472 17396
41 typedef struct {
42 HANDLE UniqueProcess; // Actually process ID
43 HANDLE UniqueThread; // Actually thread ID
44 } CLIENT_ID;
45
46 // From http://alax.info/blog/1182, with corrections and modifications
47 // Originally from
48 // http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%2 0Functions%2FSystem%20Information%2FStructures%2FSYSTEM_THREAD.html
49 struct SYSTEM_THREAD_INFORMATION {
50 ULONGLONG KernelTime;
51 ULONGLONG UserTime;
52 ULONGLONG CreateTime;
53 ULONG WaitTime;
54 // Padding here in 64-bit
55 PVOID StartAddress;
56 CLIENT_ID ClientId;
57 KPRIORITY Priority;
58 LONG BasePriority;
59 ULONG ContextSwitchCount;
60 ULONG State;
61 KWAIT_REASON WaitReason;
62 };
63 #if _M_X64
64 static_assert(sizeof(SYSTEM_THREAD_INFORMATION) == 80,
65 "Structure size mismatch");
66 #else
67 static_assert(sizeof(SYSTEM_THREAD_INFORMATION) == 64,
68 "Structure size mismatch");
69 #endif
70
71 // From http://alax.info/blog/1182, with corrections and modifications
72 // Originally from
73 // http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%2 0Functions%2FSystem%20Information%2FStructures%2FSYSTEM_THREAD.html
74 struct SYSTEM_PROCESS_INFORMATION {
75 ULONG NextEntryOffset;
76 ULONG NumberOfThreads;
77 // http://processhacker.sourceforge.net/doc/struct___s_y_s_t_e_m___p_r_o_c_e_s _s___i_n_f_o_r_m_a_t_i_o_n.html
78 ULONGLONG WorkingSetPrivateSize;
79 ULONG HardFaultCount;
80 ULONG Reserved1;
81 ULONGLONG CycleTime;
82 ULONGLONG CreateTime;
83 ULONGLONG UserTime;
84 ULONGLONG KernelTime;
85 UNICODE_STRING ImageName;
86 KPRIORITY BasePriority;
87 HANDLE ProcessId;
88 HANDLE ParentProcessId;
89 ULONG HandleCount;
90 ULONG Reserved2[2];
91 // Padding here in 64-bit
92 VM_COUNTERS VirtualMemoryCounters;
93 size_t Reserved3;
94 IO_COUNTERS IoCounters;
95 SYSTEM_THREAD_INFORMATION Threads[1];
96 };
97 #if _M_X64
98 static_assert(sizeof(SYSTEM_PROCESS_INFORMATION) == 336,
99 "Structure size mismatch");
100 #else
101 static_assert(sizeof(SYSTEM_PROCESS_INFORMATION) == 248,
102 "Structure size mismatch");
103 #endif
104
105 typedef NTSTATUS(WINAPI* NTQUERYSYSTEMINFORMATION)(
106 SYSTEM_INFORMATION_CLASS SystemInformationClass,
107 PVOID SystemInformation,
108 ULONG SystemInformationLength,
109 PULONG ReturnLength);
110
111 } // namespace task_manager
112
113 #endif // CHROME_BROWSER_TASK_MANAGER_SAMPLING_SHARED_SAMPLER_WIN_DEFINES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698