Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1090)

Side by Side Diff: chrome/test/base/chrome_process_util.cc

Issue 999033003: Remove uses of KillProcess() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/test/base/chrome_process_util.h" 5 #include "chrome/test/base/chrome_process_util.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/process/kill.h"
13 #include "base/process/process.h" 12 #include "base/process/process.h"
14 #include "base/process/process_iterator.h" 13 #include "base/process/process_iterator.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
17 #include "chrome/test/base/test_switches.h" 16 #include "chrome/test/base/test_switches.h"
18 #include "content/public/common/result_codes.h" 17 #include "content/public/common/result_codes.h"
19 18
20 using base::TimeDelta; 19 using base::TimeDelta;
21 using base::TimeTicks; 20 using base::TimeTicks;
22 21
(...skipping 24 matching lines...) Expand all
47 46
48 } // namespace 47 } // namespace
49 48
50 void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) { 49 void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) {
51 ChromeProcessList::const_iterator it; 50 ChromeProcessList::const_iterator it;
52 for (it = process_pids.begin(); it != process_pids.end(); ++it) { 51 for (it = process_pids.begin(); it != process_pids.end(); ++it) {
53 base::Process process = base::Process::Open(*it); 52 base::Process process = base::Process::Open(*it);
54 if (process.IsValid()) { 53 if (process.IsValid()) {
55 // Ignore processes for which we can't open the handle. We don't 54 // Ignore processes for which we can't open the handle. We don't
56 // guarantee that all processes will terminate, only try to do so. 55 // guarantee that all processes will terminate, only try to do so.
57 base::KillProcess(process.Handle(), content::RESULT_CODE_KILLED, true); 56 process.Terminate(content::RESULT_CODE_KILLED, true);
58 } 57 }
59 } 58 }
60 } 59 }
61 60
62 class ChildProcessFilter : public base::ProcessFilter { 61 class ChildProcessFilter : public base::ProcessFilter {
63 public: 62 public:
64 explicit ChildProcessFilter(base::ProcessId parent_pid) 63 explicit ChildProcessFilter(base::ProcessId parent_pid)
65 : parent_pids_(&parent_pid, (&parent_pid) + 1) {} 64 : parent_pids_(&parent_pid, (&parent_pid) + 1) {}
66 65
67 explicit ChildProcessFilter(const std::vector<base::ProcessId>& parent_pids) 66 explicit ChildProcessFilter(const std::vector<base::ProcessId>& parent_pids)
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::ProcessHandle process) { 141 base::ProcessHandle process) {
143 #if !defined(OS_MACOSX) 142 #if !defined(OS_MACOSX)
144 process_metrics_.reset( 143 process_metrics_.reset(
145 base::ProcessMetrics::CreateProcessMetrics(process)); 144 base::ProcessMetrics::CreateProcessMetrics(process));
146 #else 145 #else
147 process_metrics_.reset( 146 process_metrics_.reset(
148 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); 147 base::ProcessMetrics::CreateProcessMetrics(process, NULL));
149 #endif 148 #endif
150 process_handle_ = process; 149 process_handle_ = process;
151 } 150 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698