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

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

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/path_service_unittest.cc ('k') | base/process/process_linux.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) 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/memory.h" 5 #include "base/process/memory.h"
6 6
7 #include <new> 7 #include <new>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 FilePath oom_path(internal::GetProcPidDir(process)); 151 FilePath oom_path(internal::GetProcPidDir(process));
152 152
153 // Attempt to write the newer oom_score_adj file first. 153 // Attempt to write the newer oom_score_adj file first.
154 FilePath oom_file = oom_path.AppendASCII("oom_score_adj"); 154 FilePath oom_file = oom_path.AppendASCII("oom_score_adj");
155 if (PathExists(oom_file)) { 155 if (PathExists(oom_file)) {
156 std::string score_str = IntToString(score); 156 std::string score_str = IntToString(score);
157 DVLOG(1) << "Adjusting oom_score_adj of " << process << " to " 157 DVLOG(1) << "Adjusting oom_score_adj of " << process << " to "
158 << score_str; 158 << score_str;
159 int score_len = static_cast<int>(score_str.length()); 159 int score_len = static_cast<int>(score_str.length());
160 return (score_len == file_util::WriteFile(oom_file, 160 return (score_len == WriteFile(oom_file, score_str.c_str(), score_len));
161 score_str.c_str(),
162 score_len));
163 } 161 }
164 162
165 // If the oom_score_adj file doesn't exist, then we write the old 163 // If the oom_score_adj file doesn't exist, then we write the old
166 // style file and translate the oom_adj score to the range 0-15. 164 // style file and translate the oom_adj score to the range 0-15.
167 oom_file = oom_path.AppendASCII("oom_adj"); 165 oom_file = oom_path.AppendASCII("oom_adj");
168 if (PathExists(oom_file)) { 166 if (PathExists(oom_file)) {
169 // Max score for the old oom_adj range. Used for conversion of new 167 // Max score for the old oom_adj range. Used for conversion of new
170 // values to old values. 168 // values to old values.
171 const int kMaxOldOomScore = 15; 169 const int kMaxOldOomScore = 15;
172 170
173 int converted_score = score * kMaxOldOomScore / kMaxOomScore; 171 int converted_score = score * kMaxOldOomScore / kMaxOomScore;
174 std::string score_str = IntToString(converted_score); 172 std::string score_str = IntToString(converted_score);
175 DVLOG(1) << "Adjusting oom_adj of " << process << " to " << score_str; 173 DVLOG(1) << "Adjusting oom_adj of " << process << " to " << score_str;
176 int score_len = static_cast<int>(score_str.length()); 174 int score_len = static_cast<int>(score_str.length());
177 return (score_len == file_util::WriteFile(oom_file, 175 return (score_len == WriteFile(oom_file, score_str.c_str(), score_len));
178 score_str.c_str(),
179 score_len));
180 } 176 }
181 177
182 return false; 178 return false;
183 } 179 }
184 180
185 } // namespace base 181 } // namespace base
OLDNEW
« no previous file with comments | « base/path_service_unittest.cc ('k') | base/process/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698