| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/app/chrome_watcher_client_win.h" | 5 #include "chrome/app/chrome_watcher_client_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 ASSERT_TRUE(exit_event_.IsValid()); | 214 ASSERT_TRUE(exit_event_.IsValid()); |
| 215 initialize_event_.Set(::CreateEvent( | 215 initialize_event_.Set(::CreateEvent( |
| 216 NULL, FALSE, FALSE, | 216 NULL, FALSE, FALSE, |
| 217 (kInitializeEventBaseName + thread_.NamedEventSuffix()).c_str())); | 217 (kInitializeEventBaseName + thread_.NamedEventSuffix()).c_str())); |
| 218 ASSERT_TRUE(initialize_event_.IsValid()); | 218 ASSERT_TRUE(initialize_event_.IsValid()); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void TearDown() override { | 221 void TearDown() override { |
| 222 // Even if we never launched, the following is harmless. | 222 // Even if we never launched, the following is harmless. |
| 223 SignalExit(); | 223 SignalExit(); |
| 224 int exit_code = 0; | 224 thread_.client().WaitForExit(nullptr); |
| 225 thread_.client().WaitForExit(&exit_code); | |
| 226 thread_.Join(); | 225 thread_.Join(); |
| 227 } | 226 } |
| 228 | 227 |
| 229 private: | 228 private: |
| 230 // Used to launch and block on the Chrome watcher process in a background | 229 // Used to launch and block on the Chrome watcher process in a background |
| 231 // thread. | 230 // thread. |
| 232 ChromeWatcherClientThread thread_; | 231 ChromeWatcherClientThread thread_; |
| 233 // Used to signal the Chrome watcher process to exit. | 232 // Used to signal the Chrome watcher process to exit. |
| 234 base::win::ScopedHandle exit_event_; | 233 base::win::ScopedHandle exit_event_; |
| 235 // Used to signal the Chrome watcher process to signal its own | 234 // Used to signal the Chrome watcher process to signal its own |
| (...skipping 25 matching lines...) Expand all Loading... |
| 261 // Give a broken implementation a chance to exit unexpectedly. | 260 // Give a broken implementation a chance to exit unexpectedly. |
| 262 ASSERT_FALSE(thread().WaitForResultWithTimeout( | 261 ASSERT_FALSE(thread().WaitForResultWithTimeout( |
| 263 base::TimeDelta::FromMilliseconds(100), &result)); | 262 base::TimeDelta::FromMilliseconds(100), &result)); |
| 264 ASSERT_TRUE(SignalExit()); | 263 ASSERT_TRUE(SignalExit()); |
| 265 ASSERT_FALSE(thread().WaitForResult()); | 264 ASSERT_FALSE(thread().WaitForResult()); |
| 266 int exit_code = 0; | 265 int exit_code = 0; |
| 267 ASSERT_TRUE( | 266 ASSERT_TRUE( |
| 268 thread().client().WaitForExitWithTimeout(base::TimeDelta(), &exit_code)); | 267 thread().client().WaitForExitWithTimeout(base::TimeDelta(), &exit_code)); |
| 269 ASSERT_EQ(0, exit_code); | 268 ASSERT_EQ(0, exit_code); |
| 270 } | 269 } |
| OLD | NEW |