Plugin Power Saver: Record PPS UMAs only for users with PPS enabled.
[chromium-blink-merge.git] / base / process / process_iterator_win.cc
blob9d5a970ef48cd65cfb117dd694277b09e3acba70
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"
7 namespace base {
9 ProcessIterator::ProcessIterator(const ProcessFilter* filter)
10 : started_iteration_(false),
11 filter_(filter) {
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() {
36 // Case insensitive.
37 return _wcsicmp(executable_name_.c_str(), entry().exe_file()) == 0 &&
38 ProcessIterator::IncludeEntry();
41 } // namespace base