| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This test validates that the ProcessSingleton class properly makes sure | 5 // This test validates that the ProcessSingleton class properly makes sure |
| 6 // that there is only one main browser process. | 6 // that there is only one main browser process. |
| 7 // | 7 // |
| 8 // It is currently compiled and run on Windows and Posix(non-Mac) platforms. | 8 // It is currently compiled and run on Windows and Posix(non-Mac) platforms. |
| 9 // Mac uses system services and ProcessSingletonMac is a noop. (Maybe it still | 9 // Mac uses system services and ProcessSingletonMac is a noop. (Maybe it still |
| 10 // makes sense to test that the system services are giving the behavior we | 10 // makes sense to test that the system services are giving the behavior we |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // amount of time, we are OK... So we introduced this method to avoid a | 162 // amount of time, we are OK... So we introduced this method to avoid a |
| 163 // flaky wait. Instead, we kill all descendants of the main process after we | 163 // flaky wait. Instead, we kill all descendants of the main process after we |
| 164 // killed it, relying on the fact that we can still get the parent id of a | 164 // killed it, relying on the fact that we can still get the parent id of a |
| 165 // child process, even when the parent dies. | 165 // child process, even when the parent dies. |
| 166 void KillProcessTree(base::ProcessHandle process_handle) { | 166 void KillProcessTree(base::ProcessHandle process_handle) { |
| 167 class ProcessTreeFilter : public base::ProcessFilter { | 167 class ProcessTreeFilter : public base::ProcessFilter { |
| 168 public: | 168 public: |
| 169 explicit ProcessTreeFilter(base::ProcessId parent_pid) { | 169 explicit ProcessTreeFilter(base::ProcessId parent_pid) { |
| 170 ancestor_pids_.insert(parent_pid); | 170 ancestor_pids_.insert(parent_pid); |
| 171 } | 171 } |
| 172 virtual bool Includes(const base::ProcessEntry & entry) const OVERRIDE { | 172 virtual bool Includes(const base::ProcessEntry & entry) const override { |
| 173 if (ancestor_pids_.find(entry.parent_pid()) != ancestor_pids_.end()) { | 173 if (ancestor_pids_.find(entry.parent_pid()) != ancestor_pids_.end()) { |
| 174 ancestor_pids_.insert(entry.pid()); | 174 ancestor_pids_.insert(entry.pid()); |
| 175 return true; | 175 return true; |
| 176 } else { | 176 } else { |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 private: | 180 private: |
| 181 mutable std::set<base::ProcessId> ancestor_pids_; | 181 mutable std::set<base::ProcessId> ancestor_pids_; |
| 182 } process_tree_filter(base::GetProcId(process_handle)); | 182 } process_tree_filter(base::GetProcId(process_handle)); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); | 317 ASSERT_EQ(static_cast<size_t>(1), pending_starters.size()); |
| 318 size_t last_index = pending_starters.front(); | 318 size_t last_index = pending_starters.front(); |
| 319 pending_starters.clear(); | 319 pending_starters.clear(); |
| 320 if (chrome_starters_[last_index]->process_handle_ != | 320 if (chrome_starters_[last_index]->process_handle_ != |
| 321 base::kNullProcessHandle) { | 321 base::kNullProcessHandle) { |
| 322 KillProcessTree(chrome_starters_[last_index]->process_handle_); | 322 KillProcessTree(chrome_starters_[last_index]->process_handle_); |
| 323 chrome_starters_[last_index]->done_event_.Wait(); | 323 chrome_starters_[last_index]->done_event_.Wait(); |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 } | 326 } |
| OLD | NEW |