OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 namespace base { | 7 namespace base { |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 ProcessEntry::ProcessEntry() {} | 10 ProcessEntry::ProcessEntry() {} |
11 ProcessEntry::~ProcessEntry() {} | 11 ProcessEntry::~ProcessEntry() {} |
12 #endif | 12 #endif |
13 | 13 |
14 int GetProcessCount(const std::wstring& executable_name, | 14 int GetProcessCount(const FilePath::StringType& executable_name, |
15 const ProcessFilter* filter) { | 15 const ProcessFilter* filter) { |
16 int count = 0; | 16 int count = 0; |
17 NamedProcessIterator iter(executable_name, filter); | 17 NamedProcessIterator iter(executable_name, filter); |
18 while (iter.NextProcessEntry()) | 18 while (iter.NextProcessEntry()) |
19 ++count; | 19 ++count; |
20 return count; | 20 return count; |
21 } | 21 } |
22 | 22 |
23 bool KillProcesses(const std::wstring& executable_name, int exit_code, | 23 bool KillProcesses(const FilePath::StringType& executable_name, int exit_code, |
24 const ProcessFilter* filter) { | 24 const ProcessFilter* filter) { |
25 bool result = true; | 25 bool result = true; |
26 NamedProcessIterator iter(executable_name, filter); | 26 NamedProcessIterator iter(executable_name, filter); |
27 while (const ProcessEntry* entry = iter.NextProcessEntry()) { | 27 while (const ProcessEntry* entry = iter.NextProcessEntry()) { |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 result &= KillProcessById(entry->pid(), exit_code, true); | 29 result &= KillProcessById(entry->pid(), exit_code, true); |
30 #else | 30 #else |
31 result &= KillProcess(entry->pid(), exit_code, true); | 31 result &= KillProcess(entry->pid(), exit_code, true); |
32 #endif | 32 #endif |
33 } | 33 } |
(...skipping 15 matching lines...) Expand all Loading... |
49 } | 49 } |
50 | 50 |
51 ProcessIterator::ProcessEntries ProcessIterator::Snapshot() { | 51 ProcessIterator::ProcessEntries ProcessIterator::Snapshot() { |
52 ProcessEntries found; | 52 ProcessEntries found; |
53 while (const ProcessEntry* process_entry = NextProcessEntry()) { | 53 while (const ProcessEntry* process_entry = NextProcessEntry()) { |
54 found.push_back(*process_entry); | 54 found.push_back(*process_entry); |
55 } | 55 } |
56 return found; | 56 return found; |
57 } | 57 } |
58 | 58 |
59 NamedProcessIterator::NamedProcessIterator(const std::wstring& executable_name, | 59 NamedProcessIterator::NamedProcessIterator( |
60 const ProcessFilter* filter) | 60 const FilePath::StringType& executable_name, |
61 : ProcessIterator(filter), | 61 const ProcessFilter* filter) : ProcessIterator(filter), |
62 executable_name_(executable_name) { | 62 executable_name_(executable_name) { |
63 } | 63 } |
64 | 64 |
65 NamedProcessIterator::~NamedProcessIterator() { | 65 NamedProcessIterator::~NamedProcessIterator() { |
66 } | 66 } |
67 | 67 |
68 } // namespace base | 68 } // namespace base |
OLD | NEW |