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

Side by Side Diff: trunk/src/ipc/ipc_send_fds_test.cc

Issue 304153005: Revert 273575 "Introduce IPC::Channel::Create*() to ensure it be..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/ipc/ipc_perftests.cc ('k') | trunk/src/ipc/ipc_test_base.cc » ('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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 Init("SendFdsClient"); 127 Init("SendFdsClient");
128 RunServer(); 128 RunServer();
129 } 129 }
130 130
131 int SendFdsClientCommon(const std::string& test_client_name, 131 int SendFdsClientCommon(const std::string& test_client_name,
132 ino_t expected_inode_num) { 132 ino_t expected_inode_num) {
133 base::MessageLoopForIO main_message_loop; 133 base::MessageLoopForIO main_message_loop;
134 MyChannelDescriptorListener listener(expected_inode_num); 134 MyChannelDescriptorListener listener(expected_inode_num);
135 135
136 // Set up IPC channel. 136 // Set up IPC channel.
137 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( 137 IPC::Channel channel(IPCTestBase::GetChannelName(test_client_name),
138 IPCTestBase::GetChannelName(test_client_name), 138 IPC::Channel::MODE_CLIENT,
139 &listener)); 139 &listener);
140 CHECK(channel->Connect()); 140 CHECK(channel.Connect());
141 141
142 // Run message loop. 142 // Run message loop.
143 base::MessageLoop::current()->Run(); 143 base::MessageLoop::current()->Run();
144 144
145 // Verify that the message loop was exited due to getting the correct number 145 // Verify that the message loop was exited due to getting the correct number
146 // of descriptors, and not because of the channel closing unexpectedly. 146 // of descriptors, and not because of the channel closing unexpectedly.
147 CHECK(listener.GotExpectedNumberOfDescriptors()); 147 CHECK(listener.GotExpectedNumberOfDescriptors());
148 148
149 return 0; 149 return 0;
150 } 150 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 base::Callback<void(int)> cb, 226 base::Callback<void(int)> cb,
227 int fds_to_send) : 227 int fds_to_send) :
228 in_thread_(in_thread), 228 in_thread_(in_thread),
229 out_thread_(out_thread), 229 out_thread_(out_thread),
230 cb_listener_(cb, fds_to_send), 230 cb_listener_(cb, fds_to_send),
231 null_listener_(base::Bind(&null_cb), 0) { 231 null_listener_(base::Bind(&null_cb), 0) {
232 } 232 }
233 233
234 void Init() { 234 void Init() {
235 IPC::ChannelHandle in_handle("IN"); 235 IPC::ChannelHandle in_handle("IN");
236 in = IPC::Channel::CreateServer(in_handle, &null_listener_); 236 in.reset(new IPC::Channel(in_handle,
237 IPC::Channel::MODE_SERVER,
238 &null_listener_));
237 base::FileDescriptor out_fd(in->TakeClientFileDescriptor(), false); 239 base::FileDescriptor out_fd(in->TakeClientFileDescriptor(), false);
238 IPC::ChannelHandle out_handle("OUT", out_fd); 240 IPC::ChannelHandle out_handle("OUT", out_fd);
239 out = IPC::Channel::CreateClient(out_handle, &cb_listener_); 241 out.reset(new IPC::Channel(out_handle,
242 IPC::Channel::MODE_CLIENT,
243 &cb_listener_));
240 // PostTask the connect calls to make sure the callbacks happens 244 // PostTask the connect calls to make sure the callbacks happens
241 // on the right threads. 245 // on the right threads.
242 in_thread_->message_loop()->PostTask( 246 in_thread_->message_loop()->PostTask(
243 FROM_HERE, 247 FROM_HERE,
244 base::Bind(&PipeChannelHelper::Connect, in.get())); 248 base::Bind(&PipeChannelHelper::Connect, in.get()));
245 out_thread_->message_loop()->PostTask( 249 out_thread_->message_loop()->PostTask(
246 FROM_HERE, 250 FROM_HERE,
247 base::Bind(&PipeChannelHelper::Connect, out.get())); 251 base::Bind(&PipeChannelHelper::Connect, out.get()));
248 } 252 }
249 253
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 base::WaitableEvent received_; 371 base::WaitableEvent received_;
368 }; 372 };
369 373
370 TEST_F(IPCMultiSendingFdsTest, StressTest) { 374 TEST_F(IPCMultiSendingFdsTest, StressTest) {
371 Run(); 375 Run();
372 } 376 }
373 377
374 } // namespace 378 } // namespace
375 379
376 #endif // defined(OS_POSIX) 380 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « trunk/src/ipc/ipc_perftests.cc ('k') | trunk/src/ipc/ipc_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698