OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <windows.h> | 7 #include <windows.h> |
8 #include <winternl.h> | 8 #include <winternl.h> |
9 #include <psapi.h> | 9 #include <psapi.h> |
10 | 10 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 | 210 |
211 // All other exit codes indicate crashes. | 211 // All other exit codes indicate crashes. |
212 | 212 |
213 // TODO(jar): Remove histogramming code when UMA stats are consistent with | 213 // TODO(jar): Remove histogramming code when UMA stats are consistent with |
214 // other crash metrics. | 214 // other crash metrics. |
215 // Histogram the low order 3 nibbles for UMA | 215 // Histogram the low order 3 nibbles for UMA |
216 const int kLeastValue = 0; | 216 const int kLeastValue = 0; |
217 const int kMaxValue = 0xFFF; | 217 const int kMaxValue = 0xFFF; |
218 const int kBucketCount = kMaxValue - kLeastValue + 1; | 218 const int kBucketCount = kMaxValue - kLeastValue + 1; |
219 static LinearHistogram least_significant_histogram(L"ExitCodes.LSNibbles", | 219 static LinearHistogram least_significant_histogram("ExitCodes.LSNibbles", |
220 kLeastValue + 1, kMaxValue, kBucketCount); | 220 kLeastValue + 1, kMaxValue, kBucketCount); |
221 least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | | 221 least_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | |
222 LinearHistogram::kHexRangePrintingFlag); | 222 LinearHistogram::kHexRangePrintingFlag); |
223 least_significant_histogram.Add(exitcode & 0xFFF); | 223 least_significant_histogram.Add(exitcode & 0xFFF); |
224 | 224 |
225 // Histogram the high order 3 nibbles | 225 // Histogram the high order 3 nibbles |
226 static LinearHistogram most_significant_histogram(L"ExitCodes.MSNibbles", | 226 static LinearHistogram most_significant_histogram("ExitCodes.MSNibbles", |
227 kLeastValue + 1, kMaxValue, kBucketCount); | 227 kLeastValue + 1, kMaxValue, kBucketCount); |
228 most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | | 228 most_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | |
229 LinearHistogram::kHexRangePrintingFlag); | 229 LinearHistogram::kHexRangePrintingFlag); |
230 // Avoid passing in negative numbers by shifting data into low end of dword. | 230 // Avoid passing in negative numbers by shifting data into low end of dword. |
231 most_significant_histogram.Add((exitcode >> 20) & 0xFFF); | 231 most_significant_histogram.Add((exitcode >> 20) & 0xFFF); |
232 | 232 |
233 // Histogram the middle order 2 nibbles | 233 // Histogram the middle order 2 nibbles |
234 static LinearHistogram mid_significant_histogram(L"ExitCodes.MidNibbles", | 234 static LinearHistogram mid_significant_histogram("ExitCodes.MidNibbles", |
235 1, 0xFF, 0x100); | 235 1, 0xFF, 0x100); |
236 mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | | 236 mid_significant_histogram.SetFlags(kUmaTargetedHistogramFlag | |
237 LinearHistogram::kHexRangePrintingFlag); | 237 LinearHistogram::kHexRangePrintingFlag); |
238 mid_significant_histogram.Add((exitcode >> 12) & 0xFF); | 238 mid_significant_histogram.Add((exitcode >> 12) & 0xFF); |
239 | 239 |
240 return true; | 240 return true; |
241 } | 241 } |
242 | 242 |
243 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { | 243 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { |
244 ScopedHandle closer(handle); // Ensure that we always close the handle. | 244 ScopedHandle closer(handle); // Ensure that we always close the handle. |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 void EnableTerminationOnHeapCorruption() { | 637 void EnableTerminationOnHeapCorruption() { |
638 // Ignore the result code. Supported on XP SP3 and Vista. | 638 // Ignore the result code. Supported on XP SP3 and Vista. |
639 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); | 639 HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); |
640 } | 640 } |
641 | 641 |
642 void RaiseProcessToHighPriority() { | 642 void RaiseProcessToHighPriority() { |
643 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); | 643 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); |
644 } | 644 } |
645 | 645 |
646 } // namespace base | 646 } // namespace base |
OLD | NEW |