| OLD | NEW |
| 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/process.h" | 12 #include "base/process/process.h" |
| 13 #include "base/process/process_iterator.h" | 13 #include "base/process/process_iterator.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 16 #include "chrome/test/base/test_switches.h" | 16 #include "chrome/test/base/test_switches.h" |
| 17 #include "content/public/common/result_codes.h" | 17 #include "content/public/common/result_codes.h" |
| 18 | 18 |
| 19 using base::TimeDelta; | 19 using base::TimeDelta; |
| 20 using base::TimeTicks; | 20 using base::TimeTicks; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 #if defined(OS_POSIX) |
| 24 // Returns the executable name of the current Chrome helper process. | 25 // Returns the executable name of the current Chrome helper process. |
| 25 std::vector<base::FilePath::StringType> GetRunningHelperExecutableNames() { | 26 std::vector<base::FilePath::StringType> GetRunningHelperExecutableNames() { |
| 26 base::FilePath::StringType name = chrome::kHelperProcessExecutableName; | 27 base::FilePath::StringType name = chrome::kHelperProcessExecutableName; |
| 27 | 28 |
| 28 std::vector<base::FilePath::StringType> names; | 29 std::vector<base::FilePath::StringType> names; |
| 29 names.push_back(name); | 30 names.push_back(name); |
| 30 | 31 |
| 31 #if defined(OS_MACOSX) | 32 #if defined(OS_MACOSX) |
| 32 // The helper might show up as these different flavors depending on the | 33 // The helper might show up as these different flavors depending on the |
| 33 // executable flags required. | 34 // executable flags required. |
| 34 for (const char* const* suffix = chrome::kHelperFlavorSuffixes; | 35 for (const char* const* suffix = chrome::kHelperFlavorSuffixes; |
| 35 *suffix; | 36 *suffix; |
| 36 ++suffix) { | 37 ++suffix) { |
| 37 std::string flavor_name(name); | 38 std::string flavor_name(name); |
| 38 flavor_name.append(1, ' '); | 39 flavor_name.append(1, ' '); |
| 39 flavor_name.append(*suffix); | 40 flavor_name.append(*suffix); |
| 40 names.push_back(flavor_name); | 41 names.push_back(flavor_name); |
| 41 } | 42 } |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 return names; | 45 return names; |
| 45 } | 46 } |
| 47 #endif // defined(OS_POSIX) |
| 46 | 48 |
| 47 } // namespace | 49 } // namespace |
| 48 | 50 |
| 49 void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) { | 51 void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) { |
| 50 ChromeProcessList::const_iterator it; | 52 ChromeProcessList::const_iterator it; |
| 51 for (it = process_pids.begin(); it != process_pids.end(); ++it) { | 53 for (it = process_pids.begin(); it != process_pids.end(); ++it) { |
| 52 base::Process process = base::Process::Open(*it); | 54 base::Process process = base::Process::Open(*it); |
| 53 if (process.IsValid()) { | 55 if (process.IsValid()) { |
| 54 // Ignore processes for which we can't open the handle. We don't | 56 // Ignore processes for which we can't open the handle. We don't |
| 55 // guarantee that all processes will terminate, only try to do so. | 57 // guarantee that all processes will terminate, only try to do so. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 base::ProcessHandle process) { | 143 base::ProcessHandle process) { |
| 142 #if !defined(OS_MACOSX) | 144 #if !defined(OS_MACOSX) |
| 143 process_metrics_.reset( | 145 process_metrics_.reset( |
| 144 base::ProcessMetrics::CreateProcessMetrics(process)); | 146 base::ProcessMetrics::CreateProcessMetrics(process)); |
| 145 #else | 147 #else |
| 146 process_metrics_.reset( | 148 process_metrics_.reset( |
| 147 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); | 149 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); |
| 148 #endif | 150 #endif |
| 149 process_handle_ = process; | 151 process_handle_ = process; |
| 150 } | 152 } |
| OLD | NEW |