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

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

Issue 1197243004: Replace some Tokenize calls with SplitString. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android Created 5 years, 6 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 | « ash/display/display_info.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) 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 <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/sysctl.h> 8 #include <sys/sysctl.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 14
14 namespace base { 15 namespace base {
15 16
16 ProcessIterator::ProcessIterator(const ProcessFilter* filter) 17 ProcessIterator::ProcessIterator(const ProcessFilter* filter)
17 : index_of_kinfo_proc_(), 18 : index_of_kinfo_proc_(),
18 filter_(filter) { 19 filter_(filter) {
19 20
20 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid() }; 21 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid() };
21 22
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 data.resize(length); 83 data.resize(length);
83 84
84 if (sysctl(mib, arraysize(mib), &data[0], &length, NULL, 0) < 0) { 85 if (sysctl(mib, arraysize(mib), &data[0], &length, NULL, 0) < 0) {
85 LOG(ERROR) << "failed to fetch a commandline"; 86 LOG(ERROR) << "failed to fetch a commandline";
86 continue; 87 continue;
87 } 88 }
88 89
89 std::string delimiters; 90 std::string delimiters;
90 delimiters.push_back('\0'); 91 delimiters.push_back('\0');
91 Tokenize(data, delimiters, &entry_.cmd_line_args_); 92 entry_.cmd_line_args_ = SplitString(data, delimiters,
93 KEEP_WHITESPACE, SPLIT_WANT_NONEMPTY);
92 94
93 size_t exec_name_end = data.find('\0'); 95 size_t exec_name_end = data.find('\0');
94 if (exec_name_end == std::string::npos) { 96 if (exec_name_end == std::string::npos) {
95 LOG(ERROR) << "command line data didn't match expected format"; 97 LOG(ERROR) << "command line data didn't match expected format";
96 continue; 98 continue;
97 } 99 }
98 100
99 entry_.pid_ = kinfo.ki_pid; 101 entry_.pid_ = kinfo.ki_pid;
100 entry_.ppid_ = kinfo.ki_ppid; 102 entry_.ppid_ = kinfo.ki_ppid;
101 entry_.gid_ = kinfo.ki_pgid; 103 entry_.gid_ = kinfo.ki_pgid;
(...skipping 15 matching lines...) Expand all
117 } 119 }
118 120
119 bool NamedProcessIterator::IncludeEntry() { 121 bool NamedProcessIterator::IncludeEntry() {
120 if (executable_name_ != entry().exe_file()) 122 if (executable_name_ != entry().exe_file())
121 return false; 123 return false;
122 124
123 return ProcessIterator::IncludeEntry(); 125 return ProcessIterator::IncludeEntry();
124 } 126 }
125 127
126 } // namespace base 128 } // namespace base
OLDNEW
« no previous file with comments | « ash/display/display_info.cc ('k') | base/process/process_iterator_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698