| 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 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 // Implements a thread to launch the ChromeWatcherClient and block on | 124 // Implements a thread to launch the ChromeWatcherClient and block on |
| 125 // EnsureInitialized. Provides various helpers to interact with the | 125 // EnsureInitialized. Provides various helpers to interact with the |
| 126 // ChromeWatcherClient. | 126 // ChromeWatcherClient. |
| 127 class ChromeWatcherClientThread : public base::SimpleThread { | 127 class ChromeWatcherClientThread : public base::SimpleThread { |
| 128 public: | 128 public: |
| 129 ChromeWatcherClientThread() | 129 ChromeWatcherClientThread() |
| 130 : SimpleThread("ChromeWatcherClientTest thread"), | 130 : SimpleThread("ChromeWatcherClientTest thread"), |
| 131 client_(base::Bind(&ChromeWatcherClientThread::GenerateCommandLine, | 131 client_(base::Bind(&ChromeWatcherClientThread::GenerateCommandLine, |
| 132 base::Unretained(this))), | 132 base::Unretained(this))), |
| 133 complete_(false, false), | 133 complete_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 134 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 134 result_(false) {} | 135 result_(false) {} |
| 135 | 136 |
| 136 // Waits up to |timeout| for the call to EnsureInitialized to complete. If it | 137 // Waits up to |timeout| for the call to EnsureInitialized to complete. If it |
| 137 // does, sets |result| to the return value of EnsureInitialized and returns | 138 // does, sets |result| to the return value of EnsureInitialized and returns |
| 138 // true. Otherwise returns false. | 139 // true. Otherwise returns false. |
| 139 bool WaitForResultWithTimeout(base::TimeDelta timeout, bool* result) { | 140 bool WaitForResultWithTimeout(base::TimeDelta timeout, bool* result) { |
| 140 if (!complete_.TimedWait(timeout)) | 141 if (!complete_.TimedWait(timeout)) |
| 141 return false; | 142 return false; |
| 142 *result = result_; | 143 *result = result_; |
| 143 return true; | 144 return true; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Give a broken implementation a chance to exit unexpectedly. | 270 // Give a broken implementation a chance to exit unexpectedly. |
| 270 ASSERT_FALSE(thread().WaitForResultWithTimeout( | 271 ASSERT_FALSE(thread().WaitForResultWithTimeout( |
| 271 base::TimeDelta::FromMilliseconds(100), &result)); | 272 base::TimeDelta::FromMilliseconds(100), &result)); |
| 272 ASSERT_TRUE(SignalExit()); | 273 ASSERT_TRUE(SignalExit()); |
| 273 ASSERT_FALSE(thread().WaitForResult()); | 274 ASSERT_FALSE(thread().WaitForResult()); |
| 274 int exit_code = 0; | 275 int exit_code = 0; |
| 275 ASSERT_TRUE( | 276 ASSERT_TRUE( |
| 276 thread().client().WaitForExitWithTimeout(base::TimeDelta(), &exit_code)); | 277 thread().client().WaitForExitWithTimeout(base::TimeDelta(), &exit_code)); |
| 277 ASSERT_EQ(0, exit_code); | 278 ASSERT_EQ(0, exit_code); |
| 278 } | 279 } |
| OLD | NEW |