OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 #include <psapi.h> | 11 #include <psapi.h> |
12 | 12 |
13 #include <ios> | 13 #include <ios> |
14 | 14 |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/debug/stack_trace.h" | 16 #include "base/debug/stack_trace.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/sys_info.h" |
20 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
21 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
22 | 23 |
23 // userenv.dll is required for CreateEnvironmentBlock(). | 24 // userenv.dll is required for CreateEnvironmentBlock(). |
24 #pragma comment(lib, "userenv.lib") | 25 #pragma comment(lib, "userenv.lib") |
25 | 26 |
26 namespace base { | 27 namespace base { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 wait_milliseconds, | 548 wait_milliseconds, |
548 filter); | 549 filter); |
549 if (!exited_cleanly) | 550 if (!exited_cleanly) |
550 KillProcesses(executable_name, exit_code, filter); | 551 KillProcesses(executable_name, exit_code, filter); |
551 return exited_cleanly; | 552 return exited_cleanly; |
552 } | 553 } |
553 | 554 |
554 /////////////////////////////////////////////////////////////////////////////// | 555 /////////////////////////////////////////////////////////////////////////////// |
555 // ProcesMetrics | 556 // ProcesMetrics |
556 | 557 |
557 ProcessMetrics::ProcessMetrics(ProcessHandle process) : process_(process), | 558 ProcessMetrics::ProcessMetrics(ProcessHandle process) |
558 last_time_(0), | 559 : process_(process), |
559 last_system_time_(0) { | 560 processor_count_(base::SysInfo::NumberOfProcessors()), |
560 SYSTEM_INFO system_info; | 561 last_time_(0), |
561 GetSystemInfo(&system_info); | 562 last_system_time_(0) { |
562 processor_count_ = system_info.dwNumberOfProcessors; | |
563 } | 563 } |
564 | 564 |
565 // static | 565 // static |
566 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) { | 566 ProcessMetrics* ProcessMetrics::CreateProcessMetrics(ProcessHandle process) { |
567 return new ProcessMetrics(process); | 567 return new ProcessMetrics(process); |
568 } | 568 } |
569 | 569 |
570 ProcessMetrics::~ProcessMetrics() { } | 570 ProcessMetrics::~ProcessMetrics() { } |
571 | 571 |
572 size_t ProcessMetrics::GetPagefileUsage() const { | 572 size_t ProcessMetrics::GetPagefileUsage() const { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 | 899 |
900 PERFORMANCE_INFORMATION info; | 900 PERFORMANCE_INFORMATION info; |
901 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { | 901 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { |
902 LOG(ERROR) << "Failed to fetch internal performance info."; | 902 LOG(ERROR) << "Failed to fetch internal performance info."; |
903 return 0; | 903 return 0; |
904 } | 904 } |
905 return (info.CommitTotal * system_info.dwPageSize) / 1024; | 905 return (info.CommitTotal * system_info.dwPageSize) / 1024; |
906 } | 906 } |
907 | 907 |
908 } // namespace base | 908 } // namespace base |
OLD | NEW |