Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: base/process/internal_linux.cc

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/prefs/pref_service_factory.cc ('k') | base/profiler/scoped_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/internal_linux.h" 5 #include "base/process/internal_linux.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // Split the rest. 99 // Split the rest.
100 std::vector<std::string> other_stats; 100 std::vector<std::string> other_stats;
101 SplitString(stats_data.substr(close_parens_idx + 2), ' ', &other_stats); 101 SplitString(stats_data.substr(close_parens_idx + 2), ' ', &other_stats);
102 for (size_t i = 0; i < other_stats.size(); ++i) 102 for (size_t i = 0; i < other_stats.size(); ++i)
103 proc_stats->push_back(other_stats[i]); 103 proc_stats->push_back(other_stats[i]);
104 return true; 104 return true;
105 } 105 }
106 106
107 typedef std::map<std::string, std::string> ProcStatMap; 107 typedef std::map<std::string, std::string> ProcStatMap;
108 void ParseProcStat(const std::string& contents, ProcStatMap* output) { 108 void ParseProcStat(const std::string& contents, ProcStatMap* output) {
109 typedef std::pair<std::string, std::string> StringPair; 109 base::StringPairs key_value_pairs;
110 std::vector<StringPair> key_value_pairs;
111 SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs); 110 SplitStringIntoKeyValuePairs(contents, ' ', '\n', &key_value_pairs);
112 for (size_t i = 0; i < key_value_pairs.size(); ++i) { 111 for (size_t i = 0; i < key_value_pairs.size(); ++i) {
113 const StringPair& key_value_pair = key_value_pairs[i]; 112 output->insert(key_value_pairs[i]);
114 output->insert(key_value_pair);
115 } 113 }
116 } 114 }
117 115
118 int64 GetProcStatsFieldAsInt64(const std::vector<std::string>& proc_stats, 116 int64 GetProcStatsFieldAsInt64(const std::vector<std::string>& proc_stats,
119 ProcStatsFields field_num) { 117 ProcStatsFields field_num) {
120 DCHECK_GE(field_num, VM_PPID); 118 DCHECK_GE(field_num, VM_PPID);
121 CHECK_LT(static_cast<size_t>(field_num), proc_stats.size()); 119 CHECK_LT(static_cast<size_t>(field_num), proc_stats.size());
122 120
123 int64 value; 121 int64 value;
124 return StringToInt64(proc_stats[field_num], &value) ? value : 0; 122 return StringToInt64(proc_stats[field_num], &value) ? value : 0;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // which means the answer is 100. 178 // which means the answer is 100.
181 // It may be the case that this value is always 100. 179 // It may be the case that this value is always 100.
182 static const int kHertz = sysconf(_SC_CLK_TCK); 180 static const int kHertz = sysconf(_SC_CLK_TCK);
183 181
184 return TimeDelta::FromMicroseconds( 182 return TimeDelta::FromMicroseconds(
185 Time::kMicrosecondsPerSecond * clock_ticks / kHertz); 183 Time::kMicrosecondsPerSecond * clock_ticks / kHertz);
186 } 184 }
187 185
188 } // namespace internal 186 } // namespace internal
189 } // namespace base 187 } // namespace base
OLDNEW
« no previous file with comments | « base/prefs/pref_service_factory.cc ('k') | base/profiler/scoped_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698