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

Side by Side Diff: base/process/process_iterator_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/process/internal_linux.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/process_iterator.h" 5 #include "base/process/process_iterator.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/process/internal_linux.h" 9 #include "base/process/internal_linux.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 26 matching lines...) Expand all
37 // line arguments. Returns true if successful. 37 // line arguments. Returns true if successful.
38 // Note: /proc/<pid>/cmdline contains command line arguments separated by single 38 // Note: /proc/<pid>/cmdline contains command line arguments separated by single
39 // null characters. We tokenize it into a vector of strings using '\0' as a 39 // null characters. We tokenize it into a vector of strings using '\0' as a
40 // delimiter. 40 // delimiter.
41 bool GetProcCmdline(pid_t pid, std::vector<std::string>* proc_cmd_line_args) { 41 bool GetProcCmdline(pid_t pid, std::vector<std::string>* proc_cmd_line_args) {
42 // Synchronously reading files in /proc is safe. 42 // Synchronously reading files in /proc is safe.
43 ThreadRestrictions::ScopedAllowIO allow_io; 43 ThreadRestrictions::ScopedAllowIO allow_io;
44 44
45 FilePath cmd_line_file = internal::GetProcPidDir(pid).Append("cmdline"); 45 FilePath cmd_line_file = internal::GetProcPidDir(pid).Append("cmdline");
46 std::string cmd_line; 46 std::string cmd_line;
47 if (!file_util::ReadFileToString(cmd_line_file, &cmd_line)) 47 if (!ReadFileToString(cmd_line_file, &cmd_line))
48 return false; 48 return false;
49 std::string delimiters; 49 std::string delimiters;
50 delimiters.push_back('\0'); 50 delimiters.push_back('\0');
51 Tokenize(cmd_line, delimiters, proc_cmd_line_args); 51 Tokenize(cmd_line, delimiters, proc_cmd_line_args);
52 return true; 52 return true;
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 ProcessIterator::ProcessIterator(const ProcessFilter* filter) 57 ProcessIterator::ProcessIterator(const ProcessFilter* filter)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return true; 128 return true;
129 } 129 }
130 130
131 bool NamedProcessIterator::IncludeEntry() { 131 bool NamedProcessIterator::IncludeEntry() {
132 if (executable_name_ != entry().exe_file()) 132 if (executable_name_ != entry().exe_file())
133 return false; 133 return false;
134 return ProcessIterator::IncludeEntry(); 134 return ProcessIterator::IncludeEntry();
135 } 135 }
136 136
137 } // namespace base 137 } // namespace base
OLDNEW
« no previous file with comments | « base/process/internal_linux.cc ('k') | base/process/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698