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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 | 164 |
165 private: | 165 private: |
166 // Returns a command line to launch back into ChromeWatcherClientTestProcess. | 166 // Returns a command line to launch back into ChromeWatcherClientTestProcess. |
167 base::CommandLine GenerateCommandLine(HANDLE parent_handle, | 167 base::CommandLine GenerateCommandLine(HANDLE parent_handle, |
168 DWORD main_thread_id, | 168 DWORD main_thread_id, |
169 HANDLE on_initialized_event) { | 169 HANDLE on_initialized_event) { |
170 base::CommandLine ret = base::GetMultiProcessTestChildBaseCommandLine(); | 170 base::CommandLine ret = base::GetMultiProcessTestChildBaseCommandLine(); |
171 ret.AppendSwitchASCII(switches::kTestChildProcess, | 171 ret.AppendSwitchASCII(switches::kTestChildProcess, |
172 "ChromeWatcherClientTestProcess"); | 172 "ChromeWatcherClientTestProcess"); |
173 ret.AppendSwitchASCII(kEventHandle, | 173 // Cast through uintptr_t and then unsigned int to make the truncation |
174 base::UintToString(reinterpret_cast<unsigned int>( | 174 // explicit. Handles are size-of-pointer but are always 32-bit values. |
175 on_initialized_event))); | |
176 ret.AppendSwitchASCII( | 175 ret.AppendSwitchASCII( |
177 kParentHandle, | 176 kEventHandle, base::UintToString(static_cast<unsigned int>( |
178 base::UintToString(reinterpret_cast<unsigned int>(parent_handle))); | 177 reinterpret_cast<uintptr_t>(on_initialized_event)))); |
| 178 ret.AppendSwitchASCII(kParentHandle, |
| 179 base::UintToString(static_cast<unsigned int>( |
| 180 reinterpret_cast<uintptr_t>(parent_handle)))); |
179 | 181 |
180 // Our child does not actually need the main thread ID, but we verify here | 182 // Our child does not actually need the main thread ID, but we verify here |
181 // that the correct ID is being passed from the client. | 183 // that the correct ID is being passed from the client. |
182 EXPECT_EQ(::GetCurrentThreadId(), main_thread_id); | 184 EXPECT_EQ(::GetCurrentThreadId(), main_thread_id); |
183 | 185 |
184 ret.AppendSwitchASCII(kNamedEventSuffix, | 186 ret.AppendSwitchASCII(kNamedEventSuffix, |
185 base::UTF16ToASCII(NamedEventSuffix())); | 187 base::UTF16ToASCII(NamedEventSuffix())); |
186 return ret; | 188 return ret; |
187 } | 189 } |
188 | 190 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Give a broken implementation a chance to exit unexpectedly. | 269 // Give a broken implementation a chance to exit unexpectedly. |
268 ASSERT_FALSE(thread().WaitForResultWithTimeout( | 270 ASSERT_FALSE(thread().WaitForResultWithTimeout( |
269 base::TimeDelta::FromMilliseconds(100), &result)); | 271 base::TimeDelta::FromMilliseconds(100), &result)); |
270 ASSERT_TRUE(SignalExit()); | 272 ASSERT_TRUE(SignalExit()); |
271 ASSERT_FALSE(thread().WaitForResult()); | 273 ASSERT_FALSE(thread().WaitForResult()); |
272 int exit_code = 0; | 274 int exit_code = 0; |
273 ASSERT_TRUE( | 275 ASSERT_TRUE( |
274 thread().client().WaitForExitWithTimeout(base::TimeDelta(), &exit_code)); | 276 thread().client().WaitForExitWithTimeout(base::TimeDelta(), &exit_code)); |
275 ASSERT_EQ(0, exit_code); | 277 ASSERT_EQ(0, exit_code); |
276 } | 278 } |
OLD | NEW |