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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/json/json_reader_unittest.cc ('k') | base/process/process_iterator_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) 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 return 0; 47 return 0;
48 } 48 }
49 return pid; 49 return pid;
50 } 50 }
51 51
52 bool ReadProcFile(const FilePath& file, std::string* buffer) { 52 bool ReadProcFile(const FilePath& file, std::string* buffer) {
53 buffer->clear(); 53 buffer->clear();
54 // Synchronously reading files in /proc is safe. 54 // Synchronously reading files in /proc is safe.
55 ThreadRestrictions::ScopedAllowIO allow_io; 55 ThreadRestrictions::ScopedAllowIO allow_io;
56 56
57 if (!file_util::ReadFileToString(file, buffer)) { 57 if (!ReadFileToString(file, buffer)) {
58 DLOG(WARNING) << "Failed to read " << file.MaybeAsASCII(); 58 DLOG(WARNING) << "Failed to read " << file.MaybeAsASCII();
59 return false; 59 return false;
60 } 60 }
61 return !buffer->empty(); 61 return !buffer->empty();
62 } 62 }
63 63
64 bool ReadProcStats(pid_t pid, std::string* buffer) { 64 bool ReadProcStats(pid_t pid, std::string* buffer) {
65 FilePath stat_file = internal::GetProcPidDir(pid).Append(kStatFile); 65 FilePath stat_file = internal::GetProcPidDir(pid).Append(kStatFile);
66 return ReadProcFile(stat_file, buffer); 66 return ReadProcFile(stat_file, buffer);
67 } 67 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // which means the answer is 100. 181 // which means the answer is 100.
182 // It may be the case that this value is always 100. 182 // It may be the case that this value is always 100.
183 static const int kHertz = sysconf(_SC_CLK_TCK); 183 static const int kHertz = sysconf(_SC_CLK_TCK);
184 184
185 return TimeDelta::FromMicroseconds( 185 return TimeDelta::FromMicroseconds(
186 Time::kMicrosecondsPerSecond * clock_ticks / kHertz); 186 Time::kMicrosecondsPerSecond * clock_ticks / kHertz);
187 } 187 }
188 188
189 } // namespace internal 189 } // namespace internal
190 } // namespace base 190 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_reader_unittest.cc ('k') | base/process/process_iterator_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698