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

Side by Side Diff: base/process_util_linux.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « base/prefs/pref_service_unittest.cc ('k') | base/process_util_unittest.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_util.h" 5 #include "base/process_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <malloc.h> 8 #include <malloc.h>
9 #include <sys/time.h> 9 #include <sys/time.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 // Reads the |field_num|th field from |proc_stats|. 155 // Reads the |field_num|th field from |proc_stats|.
156 // Returns an empty string on failure. 156 // Returns an empty string on failure.
157 // This version only handles VM_COMM and VM_STATE, which are the only fields 157 // This version only handles VM_COMM and VM_STATE, which are the only fields
158 // that are strings. 158 // that are strings.
159 std::string GetProcStatsFieldAsString( 159 std::string GetProcStatsFieldAsString(
160 const std::vector<std::string>& proc_stats, 160 const std::vector<std::string>& proc_stats,
161 ProcStatsFields field_num) { 161 ProcStatsFields field_num) {
162 if (field_num < VM_COMM || field_num > VM_STATE) { 162 if (field_num < VM_COMM || field_num > VM_STATE) {
163 NOTREACHED(); 163 NOTREACHED();
164 return ""; 164 return std::string();
165 } 165 }
166 166
167 if (proc_stats.size() > static_cast<size_t>(field_num)) 167 if (proc_stats.size() > static_cast<size_t>(field_num))
168 return proc_stats[field_num]; 168 return proc_stats[field_num];
169 169
170 NOTREACHED(); 170 NOTREACHED();
171 return 0; 171 return 0;
172 } 172 }
173 173
174 // Reads /proc/<pid>/cmdline and populates |proc_cmd_line_args| with the command 174 // Reads /proc/<pid>/cmdline and populates |proc_cmd_line_args| with the command
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 int score_len = static_cast<int>(score_str.length()); 882 int score_len = static_cast<int>(score_str.length());
883 return (score_len == file_util::WriteFile(oom_file, 883 return (score_len == file_util::WriteFile(oom_file,
884 score_str.c_str(), 884 score_str.c_str(),
885 score_len)); 885 score_len));
886 } 886 }
887 887
888 return false; 888 return false;
889 } 889 }
890 890
891 } // namespace base 891 } // namespace base
OLDNEW
« no previous file with comments | « base/prefs/pref_service_unittest.cc ('k') | base/process_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698