| 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 "chrome_frame/test_utils.h" | 5 #include "chrome_frame/test_utils.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlwin.h> | 8 #include <atlwin.h> |
| 9 #include <winternl.h> | 9 #include <winternl.h> |
| 10 | 10 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 237 } |
| 238 | 238 |
| 239 // Used to filter processes by process ID. | 239 // Used to filter processes by process ID. |
| 240 class ArgumentFilter : public base::ProcessFilter { | 240 class ArgumentFilter : public base::ProcessFilter { |
| 241 public: | 241 public: |
| 242 explicit ArgumentFilter(const std::wstring& argument) | 242 explicit ArgumentFilter(const std::wstring& argument) |
| 243 : argument_to_find_(argument) {} | 243 : argument_to_find_(argument) {} |
| 244 | 244 |
| 245 // Returns true to indicate set-inclusion and false otherwise. This method | 245 // Returns true to indicate set-inclusion and false otherwise. This method |
| 246 // should not have side-effects and should be idempotent. | 246 // should not have side-effects and should be idempotent. |
| 247 virtual bool Includes(base::ProcessId pid, base::ProcessId parent_pid) const { | 247 virtual bool Includes(const base::ProcessEntry& entry) const { |
| 248 bool found = false; | 248 bool found = false; |
| 249 std::wstring command_line; | 249 std::wstring command_line; |
| 250 if (GetCommandLineForProcess(pid, &command_line)) { | 250 if (GetCommandLineForProcess(entry.pid(), &command_line)) { |
| 251 std::wstring::const_iterator it = | 251 std::wstring::const_iterator it = |
| 252 std::search(command_line.begin(), | 252 std::search(command_line.begin(), |
| 253 command_line.end(), | 253 command_line.end(), |
| 254 argument_to_find_.begin(), | 254 argument_to_find_.begin(), |
| 255 argument_to_find_.end(), | 255 argument_to_find_.end(), |
| 256 CaseInsensitiveCompareASCII<wchar_t>()); | 256 CaseInsensitiveCompareASCII<wchar_t>()); |
| 257 found = (it != command_line.end()); | 257 found = (it != command_line.end()); |
| 258 } | 258 } |
| 259 return found; | 259 return found; |
| 260 } | 260 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 272 base::NamedProcessIterator iter(process_name, &filter); | 272 base::NamedProcessIterator iter(process_name, &filter); |
| 273 while (const base::ProcessEntry* entry = iter.NextProcessEntry()) { | 273 while (const base::ProcessEntry* entry = iter.NextProcessEntry()) { |
| 274 if (!base::KillProcessById((*entry).th32ProcessID, 0, true)) { | 274 if (!base::KillProcessById((*entry).th32ProcessID, 0, true)) { |
| 275 DLOG(ERROR) << "Failed to kill process " << (*entry).th32ProcessID; | 275 DLOG(ERROR) << "Failed to kill process " << (*entry).th32ProcessID; |
| 276 result = false; | 276 result = false; |
| 277 } | 277 } |
| 278 } | 278 } |
| 279 | 279 |
| 280 return result; | 280 return result; |
| 281 } | 281 } |
| OLD | NEW |