| 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() {} |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 const ProcessEntry* ProcessIterator::NextProcessEntry() { | 37 const ProcessEntry* ProcessIterator::NextProcessEntry() { |
| 38 bool result = false; | 38 bool result = false; |
| 39 do { | 39 do { |
| 40 result = CheckForNextProcess(); | 40 result = CheckForNextProcess(); |
| 41 } while (result && !IncludeEntry()); | 41 } while (result && !IncludeEntry()); |
| 42 if (result) | 42 if (result) |
| 43 return &entry_; | 43 return &entry_; |
| 44 return NULL; | 44 return NULL; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool ProcessIterator::IncludeEntry() { | |
| 48 return !filter_ || filter_->Includes(entry_); | |
| 49 } | |
| 50 | |
| 51 ProcessIterator::ProcessEntries ProcessIterator::Snapshot() { | 47 ProcessIterator::ProcessEntries ProcessIterator::Snapshot() { |
| 52 ProcessEntries found; | 48 ProcessEntries found; |
| 53 while (const ProcessEntry* process_entry = NextProcessEntry()) { | 49 while (const ProcessEntry* process_entry = NextProcessEntry()) { |
| 54 found.push_back(*process_entry); | 50 found.push_back(*process_entry); |
| 55 } | 51 } |
| 56 return found; | 52 return found; |
| 57 } | 53 } |
| 58 | 54 |
| 55 bool ProcessIterator::IncludeEntry() { |
| 56 return !filter_ || filter_->Includes(entry_); |
| 57 } |
| 58 |
| 59 NamedProcessIterator::NamedProcessIterator( | 59 NamedProcessIterator::NamedProcessIterator( |
| 60 const FilePath::StringType& executable_name, | 60 const FilePath::StringType& executable_name, |
| 61 const ProcessFilter* filter) : 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 |