| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <ctype.h> | 7 #include <ctype.h> |
| 8 #include <dirent.h> | 8 #include <dirent.h> |
| 9 #include <fcntl.h> | 9 #include <fcntl.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 size_t ProcessMetrics::GetPagefileUsage() const { | 254 size_t ProcessMetrics::GetPagefileUsage() const { |
| 255 std::vector<std::string> proc_stats; | 255 std::vector<std::string> proc_stats; |
| 256 GetProcStats(process_, &proc_stats); | 256 GetProcStats(process_, &proc_stats); |
| 257 const size_t kVmSize = 22; | 257 const size_t kVmSize = 22; |
| 258 if (proc_stats.size() > kVmSize) | 258 if (proc_stats.size() > kVmSize) |
| 259 return static_cast<size_t>(StringToInt(proc_stats[kVmSize])); | 259 return static_cast<size_t>(StringToInt(proc_stats[kVmSize])); |
| 260 return 0; | 260 return 0; |
| 261 } | 261 } |
| 262 | 262 |
| 263 size_t ProcessMetrics::GetPeakPagefileUsage() const { | 263 size_t ProcessMetrics::GetPeakPagefileUsage() const { |
| 264 NOTIMPLEMENTED(); | 264 // http://crbug.com/16251 |
| 265 return 0; | 265 return 0; |
| 266 } | 266 } |
| 267 | 267 |
| 268 // On linux, we return RSS. | 268 // On linux, we return RSS. |
| 269 size_t ProcessMetrics::GetWorkingSetSize() const { | 269 size_t ProcessMetrics::GetWorkingSetSize() const { |
| 270 std::vector<std::string> proc_stats; | 270 std::vector<std::string> proc_stats; |
| 271 GetProcStats(process_, &proc_stats); | 271 GetProcStats(process_, &proc_stats); |
| 272 const size_t kVmRss = 23; | 272 const size_t kVmRss = 23; |
| 273 if (proc_stats.size() > kVmRss) { | 273 if (proc_stats.size() > kVmRss) { |
| 274 size_t num_pages = static_cast<size_t>(StringToInt(proc_stats[kVmRss])); | 274 size_t num_pages = static_cast<size_t>(StringToInt(proc_stats[kVmRss])); |
| 275 return num_pages * getpagesize(); | 275 return num_pages * getpagesize(); |
| 276 } | 276 } |
| 277 return 0; | 277 return 0; |
| 278 } | 278 } |
| 279 | 279 |
| 280 size_t ProcessMetrics::GetPeakWorkingSetSize() const { | 280 size_t ProcessMetrics::GetPeakWorkingSetSize() const { |
| 281 NOTIMPLEMENTED(); | 281 // http://crbug.com/16251 |
| 282 return 0; | 282 return 0; |
| 283 } | 283 } |
| 284 | 284 |
| 285 size_t ProcessMetrics::GetPrivateBytes() const { | 285 size_t ProcessMetrics::GetPrivateBytes() const { |
| 286 NOTIMPLEMENTED(); | 286 // http://crbug.com/16251 |
| 287 return 0; | 287 return 0; |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { | 290 bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { |
| 291 NOTIMPLEMENTED(); | 291 // http://crbug.com/16251 |
| 292 return false; | 292 return false; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // To have /proc/self/io file you must enable CONFIG_TASK_IO_ACCOUNTING | 295 // To have /proc/self/io file you must enable CONFIG_TASK_IO_ACCOUNTING |
| 296 // in your kernel configuration. | 296 // in your kernel configuration. |
| 297 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { | 297 bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { |
| 298 std::string proc_io_contents; | 298 std::string proc_io_contents; |
| 299 FilePath io_file("/proc"); | 299 FilePath io_file("/proc"); |
| 300 io_file = io_file.Append(IntToString(process_)); | 300 io_file = io_file.Append(IntToString(process_)); |
| 301 io_file = io_file.Append("io"); | 301 io_file = io_file.Append("io"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 326 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); | 326 (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); |
| 327 } | 327 } |
| 328 state = KEY_NAME; | 328 state = KEY_NAME; |
| 329 break; | 329 break; |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 return true; | 332 return true; |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace base | 335 } // namespace base |
| OLD | NEW |