| 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 <dirent.h> | 5 #include <dirent.h> |
| 6 #include <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 // If waitpid returned with an error, then the process doesn't exist | 487 // If waitpid returned with an error, then the process doesn't exist |
| 488 // (which most probably means it didn't exist before our call). | 488 // (which most probably means it didn't exist before our call). |
| 489 return waitpid_success; | 489 return waitpid_success; |
| 490 } | 490 } |
| 491 } | 491 } |
| 492 | 492 |
| 493 int64 TimeValToMicroseconds(const struct timeval& tv) { | 493 int64 TimeValToMicroseconds(const struct timeval& tv) { |
| 494 return tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec; | 494 return tv.tv_sec * kMicrosecondsPerSecond + tv.tv_usec; |
| 495 } | 495 } |
| 496 | 496 |
| 497 #if defined(OS_MACOSX) | 497 #if defined(OS_MACOSX) || defined(OS_FREEBSD) |
| 498 // TODO(port): this function only returns the *current* CPU's usage; | 498 // TODO(port): this function only returns the *current* CPU's usage; |
| 499 // we want to return this->process_'s CPU usage. | 499 // we want to return this->process_'s CPU usage. |
| 500 int ProcessMetrics::GetCPUUsage() { | 500 int ProcessMetrics::GetCPUUsage() { |
| 501 struct timeval now; | 501 struct timeval now; |
| 502 struct rusage usage; | 502 struct rusage usage; |
| 503 | 503 |
| 504 int retval = gettimeofday(&now, NULL); | 504 int retval = gettimeofday(&now, NULL); |
| 505 if (retval) | 505 if (retval) |
| 506 return 0; | 506 return 0; |
| 507 retval = getrusage(RUSAGE_SELF, &usage); | 507 retval = getrusage(RUSAGE_SELF, &usage); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 const ProcessFilter* filter) { | 702 const ProcessFilter* filter) { |
| 703 bool exited_cleanly = | 703 bool exited_cleanly = |
| 704 WaitForProcessesToExit(executable_name, wait_milliseconds, | 704 WaitForProcessesToExit(executable_name, wait_milliseconds, |
| 705 filter); | 705 filter); |
| 706 if (!exited_cleanly) | 706 if (!exited_cleanly) |
| 707 KillProcesses(executable_name, exit_code, filter); | 707 KillProcesses(executable_name, exit_code, filter); |
| 708 return exited_cleanly; | 708 return exited_cleanly; |
| 709 } | 709 } |
| 710 | 710 |
| 711 } // namespace base | 711 } // namespace base |
| OLD | NEW |