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 <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(SyncSocketServerListener); | 104 DISALLOW_COPY_AND_ASSIGN(SyncSocketServerListener); |
105 }; | 105 }; |
106 | 106 |
107 // Runs the fuzzing server child mode. Returns when the preset number of | 107 // Runs the fuzzing server child mode. Returns when the preset number of |
108 // messages have been received. | 108 // messages have been received. |
109 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) { | 109 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(SyncSocketServerClient) { |
110 base::MessageLoopForIO main_message_loop; | 110 base::MessageLoopForIO main_message_loop; |
111 SyncSocketServerListener listener; | 111 SyncSocketServerListener listener; |
112 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( | 112 scoped_ptr<IPC::Channel> channel(IPC::Channel::CreateClient( |
113 IPCTestBase::GetChannelName("SyncSocketServerClient"), &listener, | 113 IPCTestBase::GetChannelName("SyncSocketServerClient"), &listener)); |
114 nullptr)); | |
115 EXPECT_TRUE(channel->Connect()); | 114 EXPECT_TRUE(channel->Connect()); |
116 listener.Init(channel.get()); | 115 listener.Init(channel.get()); |
117 base::MessageLoop::current()->Run(); | 116 base::MessageLoop::current()->Run(); |
118 return 0; | 117 return 0; |
119 } | 118 } |
120 | 119 |
121 // The SyncSocket client listener only processes one sort of message, | 120 // The SyncSocket client listener only processes one sort of message, |
122 // a response from the server. | 121 // a response from the server. |
123 class SyncSocketClientListener : public IPC::Listener { | 122 class SyncSocketClientListener : public IPC::Listener { |
124 public: | 123 public: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 310 |
312 // Read from another socket to free some space for a new write. | 311 // Read from another socket to free some space for a new write. |
313 char hello[kHelloStringLength] = {0}; | 312 char hello[kHelloStringLength] = {0}; |
314 pair[1].Receive(&hello[0], sizeof(hello)); | 313 pair[1].Receive(&hello[0], sizeof(hello)); |
315 | 314 |
316 // Should be able to write more data to the buffer now. | 315 // Should be able to write more data to the buffer now. |
317 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); | 316 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); |
318 } | 317 } |
319 | 318 |
320 } // namespace | 319 } // namespace |
OLD | NEW |