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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 ASSERT_TRUE(sender->Send(message)); | 62 ASSERT_TRUE(sender->Send(message)); |
63 } | 63 } |
64 | 64 |
65 private: | 65 private: |
66 bool received_ok_; | 66 bool received_ok_; |
67 }; | 67 }; |
68 | 68 |
69 class ChannelClient { | 69 class ChannelClient { |
70 public: | 70 public: |
71 explicit ChannelClient(IPC::Listener* listener, const char* name) { | 71 explicit ChannelClient(IPC::Listener* listener, const char* name) { |
72 channel_ = IPC::ChannelMojo::Create( | 72 channel_ = IPC::ChannelMojo::Create(main_message_loop_.task_runner(), |
73 main_message_loop_.task_runner(), IPCTestBase::GetChannelName(name), | 73 IPCTestBase::GetChannelName(name), |
74 IPC::Channel::MODE_CLIENT, listener, nullptr); | 74 IPC::Channel::MODE_CLIENT, listener); |
75 } | 75 } |
76 | 76 |
77 void Connect() { | 77 void Connect() { |
78 CHECK(channel_->Connect()); | 78 CHECK(channel_->Connect()); |
79 } | 79 } |
80 | 80 |
81 void Close() { | 81 void Close() { |
82 channel_->Close(); | 82 channel_->Close(); |
83 | 83 |
84 base::RunLoop run_loop; | 84 base::RunLoop run_loop; |
(...skipping 24 matching lines...) Expand all Loading... |
109 | 109 |
110 IPCTestBase::TearDown(); | 110 IPCTestBase::TearDown(); |
111 } | 111 } |
112 }; | 112 }; |
113 | 113 |
114 class IPCChannelMojoTest : public IPCChannelMojoTestBase { | 114 class IPCChannelMojoTest : public IPCChannelMojoTestBase { |
115 protected: | 115 protected: |
116 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 116 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
117 const IPC::ChannelHandle& handle, | 117 const IPC::ChannelHandle& handle, |
118 base::SequencedTaskRunner* runner) override { | 118 base::SequencedTaskRunner* runner) override { |
119 return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle, | 119 return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle); |
120 nullptr); | |
121 } | 120 } |
122 | 121 |
123 bool DidStartClient() override { | 122 bool DidStartClient() override { |
124 bool ok = IPCTestBase::DidStartClient(); | 123 bool ok = IPCTestBase::DidStartClient(); |
125 DCHECK(ok); | 124 DCHECK(ok); |
126 return ok; | 125 return ok; |
127 } | 126 } |
128 }; | 127 }; |
129 | 128 |
130 | 129 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 private: | 217 private: |
219 bool has_error_; | 218 bool has_error_; |
220 }; | 219 }; |
221 | 220 |
222 | 221 |
223 class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase { | 222 class IPCChannelMojoErrorTest : public IPCChannelMojoTestBase { |
224 protected: | 223 protected: |
225 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 224 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
226 const IPC::ChannelHandle& handle, | 225 const IPC::ChannelHandle& handle, |
227 base::SequencedTaskRunner* runner) override { | 226 base::SequencedTaskRunner* runner) override { |
228 return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle, | 227 return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle); |
229 nullptr); | |
230 } | 228 } |
231 | 229 |
232 bool DidStartClient() override { | 230 bool DidStartClient() override { |
233 bool ok = IPCTestBase::DidStartClient(); | 231 bool ok = IPCTestBase::DidStartClient(); |
234 DCHECK(ok); | 232 DCHECK(ok); |
235 return ok; | 233 return ok; |
236 } | 234 } |
237 }; | 235 }; |
238 | 236 |
239 class ListenerThatQuits : public IPC::Listener { | 237 class ListenerThatQuits : public IPC::Listener { |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 618 |
621 return 0; | 619 return 0; |
622 } | 620 } |
623 | 621 |
624 #if defined(OS_WIN) | 622 #if defined(OS_WIN) |
625 class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { | 623 class IPCChannelMojoDeadHandleTest : public IPCChannelMojoTestBase { |
626 protected: | 624 protected: |
627 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( | 625 scoped_ptr<IPC::ChannelFactory> CreateChannelFactory( |
628 const IPC::ChannelHandle& handle, | 626 const IPC::ChannelHandle& handle, |
629 base::SequencedTaskRunner* runner) override { | 627 base::SequencedTaskRunner* runner) override { |
630 return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle, | 628 return IPC::ChannelMojo::CreateServerFactory(task_runner(), handle); |
631 nullptr); | |
632 } | 629 } |
633 | 630 |
634 bool DidStartClient() override { | 631 bool DidStartClient() override { |
635 IPCTestBase::DidStartClient(); | 632 IPCTestBase::DidStartClient(); |
636 // const base::ProcessHandle client = client_process().Handle(); | 633 // const base::ProcessHandle client = client_process().Handle(); |
637 // Forces GetFileHandleForProcess() fail. It happens occasionally | 634 // Forces GetFileHandleForProcess() fail. It happens occasionally |
638 // in production, so we should exercise it somehow. | 635 // in production, so we should exercise it somehow. |
639 // TODO(morrita): figure out how to safely test this. See crbug.com/464109. | 636 // TODO(morrita): figure out how to safely test this. See crbug.com/464109. |
640 // ::CloseHandle(client); | 637 // ::CloseHandle(client); |
641 return true; | 638 return true; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 base::MessageLoop::current()->Run(); | 850 base::MessageLoop::current()->Run(); |
854 | 851 |
855 client.Close(); | 852 client.Close(); |
856 | 853 |
857 return 0; | 854 return 0; |
858 } | 855 } |
859 | 856 |
860 #endif // OS_LINUX | 857 #endif // OS_LINUX |
861 | 858 |
862 } // namespace | 859 } // namespace |
OLD | NEW |