OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/process_metrics.h" | 5 #include "base/process/process_metrics.h" |
6 | 6 |
7 #include <sys/resource.h> | 7 #include <sys/resource.h> |
8 #include <sys/time.h> | 8 #include <sys/time.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 int64 TimeValToMicroseconds(const struct timeval& tv) { | 14 int64 TimeValToMicroseconds(const struct timeval& tv) { |
15 static const int kMicrosecondsPerSecond = 1000000; | |
16 int64 ret = tv.tv_sec; // Avoid (int * int) integer overflow. | 15 int64 ret = tv.tv_sec; // Avoid (int * int) integer overflow. |
17 ret *= kMicrosecondsPerSecond; | 16 ret *= Time::kMicrosecondsPerSecond; |
18 ret += tv.tv_usec; | 17 ret += tv.tv_usec; |
19 return ret; | 18 return ret; |
20 } | 19 } |
21 | 20 |
22 ProcessMetrics::~ProcessMetrics() { } | 21 ProcessMetrics::~ProcessMetrics() { } |
23 | 22 |
24 #if defined(OS_LINUX) | 23 #if defined(OS_LINUX) |
25 static const rlim_t kSystemDefaultMaxFds = 8192; | 24 static const rlim_t kSystemDefaultMaxFds = 8192; |
26 #elif defined(OS_MACOSX) | 25 #elif defined(OS_MACOSX) |
27 static const rlim_t kSystemDefaultMaxFds = 256; | 26 static const rlim_t kSystemDefaultMaxFds = 256; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 limits.rlim_cur = new_limit; | 62 limits.rlim_cur = new_limit; |
64 if (setrlimit(RLIMIT_NOFILE, &limits) != 0) { | 63 if (setrlimit(RLIMIT_NOFILE, &limits) != 0) { |
65 PLOG(INFO) << "Failed to set file descriptor limit"; | 64 PLOG(INFO) << "Failed to set file descriptor limit"; |
66 } | 65 } |
67 } else { | 66 } else { |
68 PLOG(INFO) << "Failed to get file descriptor limit"; | 67 PLOG(INFO) << "Failed to get file descriptor limit"; |
69 } | 68 } |
70 } | 69 } |
71 | 70 |
72 } // namespace base | 71 } // namespace base |
OLD | NEW |