OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ipc/mojo/ipc_channel_mojo.h" | 5 #include "ipc/mojo/ipc_channel_mojo.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const IPC::ChannelHandle& handle, | 82 const IPC::ChannelHandle& handle, |
83 base::TaskRunner* runner) override { | 83 base::TaskRunner* runner) override { |
84 host_.reset(new IPC::ChannelMojoHost(task_runner())); | 84 host_.reset(new IPC::ChannelMojoHost(task_runner())); |
85 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 85 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), |
86 handle); | 86 handle); |
87 } | 87 } |
88 | 88 |
89 bool DidStartClient() override { | 89 bool DidStartClient() override { |
90 bool ok = IPCTestBase::DidStartClient(); | 90 bool ok = IPCTestBase::DidStartClient(); |
91 DCHECK(ok); | 91 DCHECK(ok); |
92 host_->OnClientLaunched(client_process()); | 92 host_->OnClientLaunched(client_process().Handle()); |
93 return ok; | 93 return ok; |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 scoped_ptr<IPC::ChannelMojoHost> host_; | 97 scoped_ptr<IPC::ChannelMojoHost> host_; |
98 }; | 98 }; |
99 | 99 |
100 | 100 |
101 class TestChannelListenerWithExtraExpectations | 101 class TestChannelListenerWithExtraExpectations |
102 : public IPC::TestChannelListener { | 102 : public IPC::TestChannelListener { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 const IPC::ChannelHandle& handle, | 188 const IPC::ChannelHandle& handle, |
189 base::TaskRunner* runner) override { | 189 base::TaskRunner* runner) override { |
190 host_.reset(new IPC::ChannelMojoHost(task_runner())); | 190 host_.reset(new IPC::ChannelMojoHost(task_runner())); |
191 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 191 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), |
192 handle); | 192 handle); |
193 } | 193 } |
194 | 194 |
195 bool DidStartClient() override { | 195 bool DidStartClient() override { |
196 bool ok = IPCTestBase::DidStartClient(); | 196 bool ok = IPCTestBase::DidStartClient(); |
197 DCHECK(ok); | 197 DCHECK(ok); |
198 host_->OnClientLaunched(client_process()); | 198 host_->OnClientLaunched(client_process().Handle()); |
199 return ok; | 199 return ok; |
200 } | 200 } |
201 | 201 |
202 private: | 202 private: |
203 scoped_ptr<IPC::ChannelMojoHost> host_; | 203 scoped_ptr<IPC::ChannelMojoHost> host_; |
204 }; | 204 }; |
205 | 205 |
206 class ListenerThatQuits : public IPC::Listener { | 206 class ListenerThatQuits : public IPC::Listener { |
207 public: | 207 public: |
208 ListenerThatQuits() { | 208 ListenerThatQuits() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 262 virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
263 const IPC::ChannelHandle& handle, | 263 const IPC::ChannelHandle& handle, |
264 base::TaskRunner* runner) override { | 264 base::TaskRunner* runner) override { |
265 host_.reset(new IPC::ChannelMojoHost(task_runner())); | 265 host_.reset(new IPC::ChannelMojoHost(task_runner())); |
266 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 266 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), |
267 handle); | 267 handle); |
268 } | 268 } |
269 | 269 |
270 virtual bool DidStartClient() override { | 270 virtual bool DidStartClient() override { |
271 IPCTestBase::DidStartClient(); | 271 IPCTestBase::DidStartClient(); |
272 base::ProcessHandle client = client_process(); | 272 const base::ProcessHandle client = client_process().Handle(); |
273 // Forces GetFileHandleForProcess() fail. It happens occasionally | 273 // Forces GetFileHandleForProcess() fail. It happens occasionally |
274 // in production, so we should exercise it somehow. | 274 // in production, so we should exercise it somehow. |
275 ::CloseHandle(client); | 275 // TODO(morrita): figure out how to safely test this. |
| 276 // ::CloseHandle(client); |
276 host_->OnClientLaunched(client); | 277 host_->OnClientLaunched(client); |
277 return true; | 278 return true; |
278 } | 279 } |
279 | 280 |
280 private: | 281 private: |
281 scoped_ptr<IPC::ChannelMojoHost> host_; | 282 scoped_ptr<IPC::ChannelMojoHost> host_; |
282 }; | 283 }; |
283 | 284 |
284 TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) { | 285 TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) { |
285 // Any client type is fine as it is going to be killed anyway. | 286 // Any client type is fine as it is going to be killed anyway. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 client.Connect(); | 397 client.Connect(); |
397 listener.set_sender(client.channel()); | 398 listener.set_sender(client.channel()); |
398 | 399 |
399 base::MessageLoop::current()->Run(); | 400 base::MessageLoop::current()->Run(); |
400 | 401 |
401 return 0; | 402 return 0; |
402 } | 403 } |
403 #endif | 404 #endif |
404 | 405 |
405 } // namespace | 406 } // namespace |
OLD | NEW |