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 #include "remoting/host/desktop_process.h" | 5 #include "remoting/host/desktop_process.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 void DesktopProcessTest::ConnectNetworkChannel( | 169 void DesktopProcessTest::ConnectNetworkChannel( |
170 IPC::PlatformFileForTransit desktop_process) { | 170 IPC::PlatformFileForTransit desktop_process) { |
171 | 171 |
172 #if defined(OS_POSIX) | 172 #if defined(OS_POSIX) |
173 IPC::ChannelHandle channel_handle(std::string(), desktop_process); | 173 IPC::ChannelHandle channel_handle(std::string(), desktop_process); |
174 #elif defined(OS_WIN) | 174 #elif defined(OS_WIN) |
175 IPC::ChannelHandle channel_handle(desktop_process); | 175 IPC::ChannelHandle channel_handle(desktop_process); |
176 #endif // defined(OS_WIN) | 176 #endif // defined(OS_WIN) |
177 | 177 |
178 network_channel_ = IPC::ChannelProxy::Create(channel_handle, | 178 network_channel_ = |
179 IPC::Channel::MODE_CLIENT, | 179 IPC::ChannelProxy::Create(channel_handle, IPC::Channel::MODE_CLIENT, |
180 &network_listener_, | 180 &network_listener_, io_task_runner_.get()); |
181 io_task_runner_.get(), | |
182 nullptr); | |
183 } | 181 } |
184 | 182 |
185 void DesktopProcessTest::OnDesktopAttached( | 183 void DesktopProcessTest::OnDesktopAttached( |
186 IPC::PlatformFileForTransit desktop_process) { | 184 IPC::PlatformFileForTransit desktop_process) { |
187 #if defined(OS_POSIX) | 185 #if defined(OS_POSIX) |
188 DCHECK(desktop_process.auto_close); | 186 DCHECK(desktop_process.auto_close); |
189 | 187 |
190 base::File closer(IPC::PlatformFileForTransitToFile(desktop_process)); | 188 base::File closer(IPC::PlatformFileForTransitToFile(desktop_process)); |
191 #endif // defined(OS_POSIX) | 189 #endif // defined(OS_POSIX) |
192 } | 190 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), | 238 base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), |
241 message_loop_.task_runner(), | 239 message_loop_.task_runner(), |
242 FROM_HERE, run_loop.QuitClosure()); | 240 FROM_HERE, run_loop.QuitClosure()); |
243 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = new AutoThreadTaskRunner( | 241 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = new AutoThreadTaskRunner( |
244 message_loop_.task_runner(), quit_ui_task_runner); | 242 message_loop_.task_runner(), quit_ui_task_runner); |
245 | 243 |
246 io_task_runner_ = AutoThread::CreateWithType( | 244 io_task_runner_ = AutoThread::CreateWithType( |
247 "IPC thread", ui_task_runner, base::MessageLoop::TYPE_IO); | 245 "IPC thread", ui_task_runner, base::MessageLoop::TYPE_IO); |
248 | 246 |
249 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); | 247 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); |
250 daemon_channel_ = IPC::ChannelProxy::Create(IPC::ChannelHandle(channel_name), | 248 daemon_channel_ = IPC::ChannelProxy::Create( |
251 IPC::Channel::MODE_SERVER, | 249 IPC::ChannelHandle(channel_name), IPC::Channel::MODE_SERVER, |
252 &daemon_listener_, | 250 &daemon_listener_, io_task_runner_.get()); |
253 io_task_runner_.get(), | |
254 nullptr); | |
255 | 251 |
256 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( | 252 scoped_ptr<MockDesktopEnvironmentFactory> desktop_environment_factory( |
257 new MockDesktopEnvironmentFactory()); | 253 new MockDesktopEnvironmentFactory()); |
258 EXPECT_CALL(*desktop_environment_factory, CreatePtr()) | 254 EXPECT_CALL(*desktop_environment_factory, CreatePtr()) |
259 .Times(AnyNumber()) | 255 .Times(AnyNumber()) |
260 .WillRepeatedly(Invoke(this, | 256 .WillRepeatedly(Invoke(this, |
261 &DesktopProcessTest::CreateDesktopEnvironment)); | 257 &DesktopProcessTest::CreateDesktopEnvironment)); |
262 EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) | 258 EXPECT_CALL(*desktop_environment_factory, SupportsAudioCapture()) |
263 .Times(AnyNumber()) | 259 .Times(AnyNumber()) |
264 .WillRepeatedly(Return(false)); | 260 .WillRepeatedly(Return(false)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 334 } |
339 | 335 |
340 // Run the desktop process and ask it to crash. | 336 // Run the desktop process and ask it to crash. |
341 TEST_F(DesktopProcessTest, DeathTest) { | 337 TEST_F(DesktopProcessTest, DeathTest) { |
342 testing::GTEST_FLAG(death_test_style) = "threadsafe"; | 338 testing::GTEST_FLAG(death_test_style) = "threadsafe"; |
343 | 339 |
344 EXPECT_DEATH(RunDeathTest(), ""); | 340 EXPECT_DEATH(RunDeathTest(), ""); |
345 } | 341 } |
346 | 342 |
347 } // namespace remoting | 343 } // namespace remoting |
OLD | NEW |