Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 1185133006: IPC: Make ChannelReader inherit from SupportsAttachmentBrokering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from tsepez. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_perftest_support.cc ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #if defined(OS_MACOSX) 8 #if defined(OS_MACOSX)
9 extern "C" { 9 extern "C" {
10 #include <sandbox.h> 10 #include <sandbox.h>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 RunServer(); 142 RunServer();
143 } 143 }
144 144
145 int SendFdsClientCommon(const std::string& test_client_name, 145 int SendFdsClientCommon(const std::string& test_client_name,
146 ino_t expected_inode_num) { 146 ino_t expected_inode_num) {
147 base::MessageLoopForIO main_message_loop; 147 base::MessageLoopForIO main_message_loop;
148 MyChannelDescriptorListener listener(expected_inode_num); 148 MyChannelDescriptorListener listener(expected_inode_num);
149 149
150 // Set up IPC channel. 150 // Set up IPC channel.
151 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 151 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient(
152 IPCTestBase::GetChannelName(test_client_name), 152 IPCTestBase::GetChannelName(test_client_name), &listener, nullptr));
153 &listener));
154 CHECK(channel->Connect()); 153 CHECK(channel->Connect());
155 154
156 // Run message loop. 155 // Run message loop.
157 base::MessageLoop::current()->Run(); 156 base::MessageLoop::current()->Run();
158 157
159 // Verify that the message loop was exited due to getting the correct number 158 // Verify that the message loop was exited due to getting the correct number
160 // of descriptors, and not because of the channel closing unexpectedly. 159 // of descriptors, and not because of the channel closing unexpectedly.
161 CHECK(listener.GotExpectedNumberOfDescriptors()); 160 CHECK(listener.GotExpectedNumberOfDescriptors());
162 161
163 return 0; 162 return 0;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 base::Callback<void(int)> cb, 237 base::Callback<void(int)> cb,
239 int fds_to_send) : 238 int fds_to_send) :
240 in_thread_(in_thread), 239 in_thread_(in_thread),
241 out_thread_(out_thread), 240 out_thread_(out_thread),
242 cb_listener_(cb, fds_to_send), 241 cb_listener_(cb, fds_to_send),
243 null_listener_(base::Bind(&null_cb), 0) { 242 null_listener_(base::Bind(&null_cb), 0) {
244 } 243 }
245 244
246 void Init() { 245 void Init() {
247 IPC::ChannelHandle in_handle("IN"); 246 IPC::ChannelHandle in_handle("IN");
248 in = IPC::Channel::CreateServer(in_handle, &null_listener_); 247 in = IPC::Channel::CreateServer(in_handle, &null_listener_, nullptr);
249 IPC::ChannelHandle out_handle( 248 IPC::ChannelHandle out_handle(
250 "OUT", base::FileDescriptor(in->TakeClientFileDescriptor())); 249 "OUT", base::FileDescriptor(in->TakeClientFileDescriptor()));
251 out = IPC::Channel::CreateClient(out_handle, &cb_listener_); 250 out = IPC::Channel::CreateClient(out_handle, &cb_listener_, nullptr);
252 // PostTask the connect calls to make sure the callbacks happens 251 // PostTask the connect calls to make sure the callbacks happens
253 // on the right threads. 252 // on the right threads.
254 in_thread_->task_runner()->PostTask( 253 in_thread_->task_runner()->PostTask(
255 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, in.get())); 254 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, in.get()));
256 out_thread_->task_runner()->PostTask( 255 out_thread_->task_runner()->PostTask(
257 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, out.get())); 256 FROM_HERE, base::Bind(&PipeChannelHelper::Connect, out.get()));
258 } 257 }
259 258
260 static void DestroyChannel(scoped_ptr<IPC::Channel> *c, 259 static void DestroyChannel(scoped_ptr<IPC::Channel> *c,
261 base::WaitableEvent *event) { 260 base::WaitableEvent *event) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 base::WaitableEvent received_; 372 base::WaitableEvent received_;
374 }; 373 };
375 374
376 TEST_F(IPCMultiSendingFdsTest, StressTest) { 375 TEST_F(IPCMultiSendingFdsTest, StressTest) {
377 Run(); 376 Run();
378 } 377 }
379 378
380 } // namespace 379 } // namespace
381 380
382 #endif // defined(OS_POSIX) 381 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_perftest_support.cc ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698