OLD | NEW |
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 "base/sync_socket.h" | 5 #include "base/sync_socket.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string> | 8 #include <string> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 IPC::Channel* chan_; | 101 IPC::Channel* chan_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(SyncSocketServerListener); | 103 DISALLOW_COPY_AND_ASSIGN(SyncSocketServerListener); |
104 }; | 104 }; |
105 | 105 |
106 // Runs the fuzzing server child mode. Returns when the preset number of | 106 // Runs the fuzzing server child mode. Returns when the preset number of |
107 // messages have been received. | 107 // messages have been received. |
108 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) { | 108 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) { |
109 base::MessageLoopForIO main_message_loop; | 109 base::MessageLoopForIO main_message_loop; |
110 SyncSocketServerListener listener; | 110 SyncSocketServerListener listener; |
111 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( | 111 IPC::Channel channel(IPCTestBase::GetChannelName("SyncSocketServerClient"), |
112 IPCTestBase::GetChannelName("SyncSocketServerClient"), | 112 IPC::Channel::MODE_CLIENT, |
113 &listener)); | 113 &listener); |
114 EXPECT_TRUE(channel->Connect()); | 114 EXPECT_TRUE(channel.Connect()); |
115 listener.Init(channel.get()); | 115 listener.Init(&channel); |
116 base::MessageLoop::current()->Run(); | 116 base::MessageLoop::current()->Run(); |
117 return 0; | 117 return 0; |
118 } | 118 } |
119 | 119 |
120 // The SyncSocket client listener only processes one sort of message, | 120 // The SyncSocket client listener only processes one sort of message, |
121 // a response from the server. | 121 // a response from the server. |
122 class SyncSocketClientListener : public IPC::Listener { | 122 class SyncSocketClientListener : public IPC::Listener { |
123 public: | 123 public: |
124 SyncSocketClientListener() { | 124 SyncSocketClientListener() { |
125 } | 125 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 // Read from another socket to free some space for a new write. | 300 // Read from another socket to free some space for a new write. |
301 char hello[kHelloStringLength] = {0}; | 301 char hello[kHelloStringLength] = {0}; |
302 pair[1].Receive(&hello[0], sizeof(hello)); | 302 pair[1].Receive(&hello[0], sizeof(hello)); |
303 | 303 |
304 // Should be able to write more data to the buffer now. | 304 // Should be able to write more data to the buffer now. |
305 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); | 305 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); |
306 } | 306 } |
307 | 307 |
308 } // namespace | 308 } // namespace |
OLD | NEW |