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

Side by Side Diff: chrome/common/ipc_send_fds_test.cc

Issue 21208: POSIX: Transfer network data using shared memory (Closed)
Patch Set: ... Created 11 years, 10 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 | « chrome/common/ipc_message_utils.h ('k') | chrome/common/ipc_tests.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/common/ipc_tests.h" 7 #include "chrome/common/ipc_tests.h"
8 8
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 extern "C" { 10 extern "C" {
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 41
42 class MyChannelDescriptorListener : public IPC::Channel::Listener { 42 class MyChannelDescriptorListener : public IPC::Channel::Listener {
43 public: 43 public:
44 MyChannelDescriptorListener(ino_t expected_inode_num) 44 MyChannelDescriptorListener(ino_t expected_inode_num)
45 : expected_inode_num_(expected_inode_num) {} 45 : expected_inode_num_(expected_inode_num) {}
46 46
47 virtual void OnMessageReceived(const IPC::Message& message) { 47 virtual void OnMessageReceived(const IPC::Message& message) {
48 void* iter = NULL; 48 void* iter = NULL;
49 49
50 FileDescriptor descriptor; 50 base::FileDescriptor descriptor;
51 51
52 ASSERT_TRUE( 52 ASSERT_TRUE(
53 IPC::ParamTraits<FileDescriptor>::Read(&message, &iter, &descriptor)); 53 IPC::ParamTraits<base::FileDescriptor>::Read(
54 &message, &iter, &descriptor));
54 55
55 VerifyAndCloseDescriptor(descriptor.fd, expected_inode_num_); 56 VerifyAndCloseDescriptor(descriptor.fd, expected_inode_num_);
56 MessageLoop::current()->Quit(); 57 MessageLoop::current()->Quit();
57 } 58 }
58 59
59 virtual void OnChannelError() { 60 virtual void OnChannelError() {
60 MessageLoop::current()->Quit(); 61 MessageLoop::current()->Quit();
61 } 62 }
62 private: 63 private:
63 ino_t expected_inode_num_; 64 ino_t expected_inode_num_;
64 }; 65 };
65 66
66 void TestDescriptorServer(IPC::Channel &chan, 67 void TestDescriptorServer(IPC::Channel &chan,
67 base::ProcessHandle process_handle) { 68 base::ProcessHandle process_handle) {
68 ASSERT_TRUE(process_handle); 69 ASSERT_TRUE(process_handle);
69 70
70 FileDescriptor descriptor; 71 base::FileDescriptor descriptor;
71 const int fd = open(kDevRandomPath, O_RDONLY); 72 const int fd = open(kDevRandomPath, O_RDONLY);
72 ASSERT_GE(fd, 0); 73 ASSERT_GE(fd, 0);
73 descriptor.auto_close = true; 74 descriptor.auto_close = true;
74 descriptor.fd = fd; 75 descriptor.fd = fd;
75 76
76 IPC::Message* message = new IPC::Message(0, // routing_id 77 IPC::Message* message = new IPC::Message(0, // routing_id
77 3, // message type 78 3, // message type
78 IPC::Message::PRIORITY_NORMAL); 79 IPC::Message::PRIORITY_NORMAL);
79 IPC::ParamTraits<FileDescriptor>::Write(message, descriptor); 80 IPC::ParamTraits<base::FileDescriptor>::Write(message, descriptor);
80 chan.Send(message); 81 chan.Send(message);
81 82
82 // Run message loop. 83 // Run message loop.
83 MessageLoop::current()->Run(); 84 MessageLoop::current()->Run();
84 85
85 // Close Channel so client gets its OnChannelError() callback fired. 86 // Close Channel so client gets its OnChannelError() callback fired.
86 chan.Close(); 87 chan.Close();
87 88
88 // Cleanup child process. 89 // Cleanup child process.
89 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); 90 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER, 167 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER,
167 &listener); 168 &listener);
168 chan.Connect(); 169 chan.Connect();
169 170
170 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT, 171 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT,
171 &chan); 172 &chan);
172 TestDescriptorServer(chan, process_handle); 173 TestDescriptorServer(chan, process_handle);
173 } 174 }
174 175
175 #endif // defined(OS_POSIX) 176 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « chrome/common/ipc_message_utils.h ('k') | chrome/common/ipc_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698