OLD | NEW |
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 "base/process_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <io.h> | 8 #include <io.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <userenv.h> | 10 #include <userenv.h> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return false; | 245 return false; |
246 | 246 |
247 win::ScopedHandle scoped_process_token(process_token); | 247 win::ScopedHandle scoped_process_token(process_token); |
248 | 248 |
249 DWORD token_info_length = 0; | 249 DWORD token_info_length = 0; |
250 if (GetTokenInformation(process_token, TokenIntegrityLevel, NULL, 0, | 250 if (GetTokenInformation(process_token, TokenIntegrityLevel, NULL, 0, |
251 &token_info_length) || | 251 &token_info_length) || |
252 GetLastError() != ERROR_INSUFFICIENT_BUFFER) | 252 GetLastError() != ERROR_INSUFFICIENT_BUFFER) |
253 return false; | 253 return false; |
254 | 254 |
255 scoped_array<char> token_label_bytes(new char[token_info_length]); | 255 scoped_ptr<char[]> token_label_bytes(new char[token_info_length]); |
256 if (!token_label_bytes.get()) | 256 if (!token_label_bytes.get()) |
257 return false; | 257 return false; |
258 | 258 |
259 TOKEN_MANDATORY_LABEL* token_label = | 259 TOKEN_MANDATORY_LABEL* token_label = |
260 reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get()); | 260 reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get()); |
261 if (!token_label) | 261 if (!token_label) |
262 return false; | 262 return false; |
263 | 263 |
264 if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_label, | 264 if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_label, |
265 token_info_length, &token_info_length)) | 265 token_info_length, &token_info_length)) |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 if (!heap_set) | 914 if (!heap_set) |
915 return true; | 915 return true; |
916 | 916 |
917 unsigned number_heaps = GetProcessHeaps(0, NULL); | 917 unsigned number_heaps = GetProcessHeaps(0, NULL); |
918 if (!number_heaps) | 918 if (!number_heaps) |
919 return false; | 919 return false; |
920 | 920 |
921 // Gives us some extra space in the array in case a thread is creating heaps | 921 // Gives us some extra space in the array in case a thread is creating heaps |
922 // at the same time we're querying them. | 922 // at the same time we're querying them. |
923 static const int MARGIN = 8; | 923 static const int MARGIN = 8; |
924 scoped_array<HANDLE> heaps(new HANDLE[number_heaps + MARGIN]); | 924 scoped_ptr<HANDLE[]> heaps(new HANDLE[number_heaps + MARGIN]); |
925 number_heaps = GetProcessHeaps(number_heaps + MARGIN, heaps.get()); | 925 number_heaps = GetProcessHeaps(number_heaps + MARGIN, heaps.get()); |
926 if (!number_heaps) | 926 if (!number_heaps) |
927 return false; | 927 return false; |
928 | 928 |
929 for (unsigned i = 0; i < number_heaps; ++i) { | 929 for (unsigned i = 0; i < number_heaps; ++i) { |
930 ULONG lfh_flag = 2; | 930 ULONG lfh_flag = 2; |
931 // Don't bother with the result code. It may fails on heaps that have the | 931 // Don't bother with the result code. It may fails on heaps that have the |
932 // HEAP_NO_SERIALIZE flag. This is expected and not a problem at all. | 932 // HEAP_NO_SERIALIZE flag. This is expected and not a problem at all. |
933 heap_set(heaps[i], | 933 heap_set(heaps[i], |
934 HeapCompatibilityInformation, | 934 HeapCompatibilityInformation, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 | 984 |
985 PERFORMANCE_INFORMATION info; | 985 PERFORMANCE_INFORMATION info; |
986 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 986 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
987 DLOG(ERROR) << "Failed to fetch internal performance info."; | 987 DLOG(ERROR) << "Failed to fetch internal performance info."; |
988 return 0; | 988 return 0; |
989 } | 989 } |
990 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 990 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
991 } | 991 } |
992 | 992 |
993 } // namespace base | 993 } // namespace base |
OLD | NEW |