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
3 // found in the LICENSE file.
5 #include "base/process/process_iterator.h"
9 ProcessIterator::ProcessIterator(const ProcessFilter
* filter
)
10 : started_iteration_(false),
12 snapshot_
= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS
, 0);
15 ProcessIterator::~ProcessIterator() {
16 CloseHandle(snapshot_
);
19 bool ProcessIterator::CheckForNextProcess() {
20 InitProcessEntry(&entry_
);
22 if (!started_iteration_
) {
23 started_iteration_
= true;
24 return !!Process32First(snapshot_
, &entry_
);
27 return !!Process32Next(snapshot_
, &entry_
);
30 void ProcessIterator::InitProcessEntry(ProcessEntry
* entry
) {
31 memset(entry
, 0, sizeof(*entry
));
32 entry
->dwSize
= sizeof(*entry
);
35 bool NamedProcessIterator::IncludeEntry() {
37 return _wcsicmp(executable_name_
.c_str(), entry().exe_file()) == 0 &&
38 ProcessIterator::IncludeEntry();