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/location.h" | 9 #include "base/location.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 ASSERT_TRUE(sender->Send(message)); | 61 ASSERT_TRUE(sender->Send(message)); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 bool received_ok_; | 65 bool received_ok_; |
66 }; | 66 }; |
67 | 67 |
68 class ChannelClient { | 68 class ChannelClient { |
69 public: | 69 public: |
70 explicit ChannelClient(IPC::Listener* listener, const char* name) { | 70 explicit ChannelClient(IPC::Listener* listener, const char* name) { |
71 channel_ = IPC::ChannelMojo::Create(NULL, main_message_loop_.task_runner(), | 71 channel_ = |
72 IPCTestBase::GetChannelName(name), | 72 IPC::ChannelMojo::Create(NULL, main_message_loop_.task_runner(), |
73 IPC::Channel::MODE_CLIENT, listener); | 73 IPCTestBase::GetChannelName(name), |
| 74 IPC::Channel::MODE_CLIENT, listener, nullptr); |
74 } | 75 } |
75 | 76 |
76 void Connect() { | 77 void Connect() { |
77 CHECK(channel_->Connect()); | 78 CHECK(channel_->Connect()); |
78 } | 79 } |
79 | 80 |
80 void Close() { | 81 void Close() { |
81 channel_->Close(); | 82 channel_->Close(); |
82 | 83 |
83 base::RunLoop run_loop; | 84 base::RunLoop run_loop; |
(...skipping 25 matching lines...) Expand all Loading... |
109 IPCTestBase::TearDown(); | 110 IPCTestBase::TearDown(); |
110 } | 111 } |
111 }; | 112 }; |
112 | 113 |
113 class IPCChannelMojoTest : public IPCChannelMojoTestBase { | 114 class IPCChannelMojoTest : public IPCChannelMojoTestBase { |
114 protected: | 115 protected: |
115 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 116 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
116 const IPC::ChannelHandle& handle, | 117 const IPC::ChannelHandle& handle, |
117 base::SequencedTaskRunner* runner) override { | 118 base::SequencedTaskRunner* runner) override { |
118 host_.reset(new IPC::ChannelMojoHost(task_runner())); | 119 host_.reset(new IPC::ChannelMojoHost(task_runner())); |
119 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 120 return IPC::ChannelMojo::CreateServerFactory( |
120 task_runner(), handle); | 121 host_->channel_delegate(), task_runner(), handle, nullptr); |
121 } | 122 } |
122 | 123 |
123 bool DidStartClient() override { | 124 bool DidStartClient() override { |
124 bool ok = IPCTestBase::DidStartClient(); | 125 bool ok = IPCTestBase::DidStartClient(); |
125 DCHECK(ok); | 126 DCHECK(ok); |
126 host_->OnClientLaunched(client_process().Handle()); | 127 host_->OnClientLaunched(client_process().Handle()); |
127 return ok; | 128 return ok; |
128 } | 129 } |
129 | 130 |
130 private: | 131 private: |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 bool has_error_; | 218 bool has_error_; |
218 }; | 219 }; |
219 | 220 |
220 | 221 |
221 class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase { | 222 class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase { |
222 protected: | 223 protected: |
223 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 224 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
224 const IPC::ChannelHandle& handle, | 225 const IPC::ChannelHandle& handle, |
225 base::SequencedTaskRunner* runner) override { | 226 base::SequencedTaskRunner* runner) override { |
226 host_.reset(new IPC::ChannelMojoHost(task_runner())); | 227 host_.reset(new IPC::ChannelMojoHost(task_runner())); |
227 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 228 return IPC::ChannelMojo::CreateServerFactory( |
228 task_runner(), handle); | 229 host_->channel_delegate(), task_runner(), handle, nullptr); |
229 } | 230 } |
230 | 231 |
231 bool DidStartClient() override { | 232 bool DidStartClient() override { |
232 bool ok = IPCTestBase::DidStartClient(); | 233 bool ok = IPCTestBase::DidStartClient(); |
233 DCHECK(ok); | 234 DCHECK(ok); |
234 host_->OnClientLaunched(client_process().Handle()); | 235 host_->OnClientLaunched(client_process().Handle()); |
235 return ok; | 236 return ok; |
236 } | 237 } |
237 | 238 |
238 private: | 239 private: |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 return 0; | 552 return 0; |
552 } | 553 } |
553 | 554 |
554 #if defined(OS_WIN) | 555 #if defined(OS_WIN) |
555 class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { | 556 class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { |
556 protected: | 557 protected: |
557 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 558 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
558 const IPC::ChannelHandle& handle, | 559 const IPC::ChannelHandle& handle, |
559 base::SequencedTaskRunner* runner) override { | 560 base::SequencedTaskRunner* runner) override { |
560 host_.reset(new IPC::ChannelMojoHost(task_runner())); | 561 host_.reset(new IPC::ChannelMojoHost(task_runner())); |
561 return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(), | 562 return IPC::ChannelMojo::CreateServerFactory( |
562 task_runner(), handle); | 563 host_->channel_delegate(), task_runner(), handle, nullptr); |
563 } | 564 } |
564 | 565 |
565 bool DidStartClient() override { | 566 bool DidStartClient() override { |
566 IPCTestBase::DidStartClient(); | 567 IPCTestBase::DidStartClient(); |
567 const base::ProcessHandle client = client_process().Handle(); | 568 const base::ProcessHandle client = client_process().Handle(); |
568 // Forces GetFileHandleForProcess() fail. It happens occasionally | 569 // Forces GetFileHandleForProcess() fail. It happens occasionally |
569 // in production, so we should exercise it somehow. | 570 // in production, so we should exercise it somehow. |
570 // TODO(morrita): figure out how to safely test this. See crbug.com/464109. | 571 // TODO(morrita): figure out how to safely test this. See crbug.com/464109. |
571 // ::CloseHandle(client); | 572 // ::CloseHandle(client); |
572 host_->OnClientLaunched(client); | 573 host_->OnClientLaunched(client); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 base::MessageLoop::current()->Run(); | 778 base::MessageLoop::current()->Run(); |
778 | 779 |
779 client.Close(); | 780 client.Close(); |
780 | 781 |
781 return 0; | 782 return 0; |
782 } | 783 } |
783 | 784 |
784 #endif // OS_LINUX | 785 #endif // OS_LINUX |
785 | 786 |
786 } // namespace | 787 } // namespace |
OLD | NEW |