| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/socket/tcp_socket.h" | 5 #include "net/socket/tcp_socket.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 15 #include "net/base/address_list.h" | 14 #include "net/base/address_list.h" |
| 16 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
| 17 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 18 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 19 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 20 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
| 21 #include "net/socket/tcp_client_socket.h" | 20 #include "net/socket/tcp_client_socket.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 socket_.Listen(kListenBacklog) != OK) { | 51 socket_.Listen(kListenBacklog) != OK) { |
| 53 LOG(ERROR) << "Failed to listen on ::1 - probably because IPv6 is " | 52 LOG(ERROR) << "Failed to listen on ::1 - probably because IPv6 is " |
| 54 "disabled. Skipping the test"; | 53 "disabled. Skipping the test"; |
| 55 return; | 54 return; |
| 56 } | 55 } |
| 57 ASSERT_EQ(OK, socket_.GetLocalAddress(&local_address_)); | 56 ASSERT_EQ(OK, socket_.GetLocalAddress(&local_address_)); |
| 58 *success = true; | 57 *success = true; |
| 59 } | 58 } |
| 60 | 59 |
| 61 void ParseAddress(const std::string& ip_str, | 60 void ParseAddress(const std::string& ip_str, |
| 62 uint16 port, | 61 uint16_t port, |
| 63 IPEndPoint* address) { | 62 IPEndPoint* address) { |
| 64 IPAddressNumber ip_number; | 63 IPAddressNumber ip_number; |
| 65 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); | 64 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); |
| 66 if (!rv) | 65 if (!rv) |
| 67 return; | 66 return; |
| 68 *address = IPEndPoint(ip_number, port); | 67 *address = IPEndPoint(ip_number, port); |
| 69 } | 68 } |
| 70 | 69 |
| 71 void TestAcceptAsync() { | 70 void TestAcceptAsync() { |
| 72 TestCompletionCallback accept_callback; | 71 TestCompletionCallback accept_callback; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 memmove(&buffer[bytes_read], read_buffer->data(), read_result); | 280 memmove(&buffer[bytes_read], read_buffer->data(), read_result); |
| 282 bytes_read += read_result; | 281 bytes_read += read_result; |
| 283 } | 282 } |
| 284 | 283 |
| 285 std::string received_message(buffer.begin(), buffer.end()); | 284 std::string received_message(buffer.begin(), buffer.end()); |
| 286 ASSERT_EQ(message, received_message); | 285 ASSERT_EQ(message, received_message); |
| 287 } | 286 } |
| 288 | 287 |
| 289 } // namespace | 288 } // namespace |
| 290 } // namespace net | 289 } // namespace net |
| OLD | NEW |