| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 listen_port_ = local_address.port(); | 110 listen_port_ = local_address.port(); |
| 111 listen_sock_->Accept(&connected_sock_, | 111 listen_sock_->Accept(&connected_sock_, |
| 112 base::Bind(&TransportClientSocketTest::AcceptCallback, | 112 base::Bind(&TransportClientSocketTest::AcceptCallback, |
| 113 base::Unretained(this))); | 113 base::Unretained(this))); |
| 114 | 114 |
| 115 AddressList addr; | 115 AddressList addr; |
| 116 // MockHostResolver resolves everything to 127.0.0.1. | 116 // MockHostResolver resolves everything to 127.0.0.1. |
| 117 std::unique_ptr<HostResolver> resolver(new MockHostResolver()); | 117 std::unique_ptr<HostResolver> resolver(new MockHostResolver()); |
| 118 HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_)); | 118 HostResolver::RequestInfo info(HostPortPair("localhost", listen_port_)); |
| 119 TestCompletionCallback callback; | 119 TestCompletionCallback callback; |
| 120 std::unique_ptr<HostResolver::Request> request; |
| 120 int rv = resolver->Resolve(info, DEFAULT_PRIORITY, &addr, callback.callback(), | 121 int rv = resolver->Resolve(info, DEFAULT_PRIORITY, &addr, callback.callback(), |
| 121 NULL, BoundNetLog()); | 122 &request, BoundNetLog()); |
| 122 CHECK_EQ(ERR_IO_PENDING, rv); | 123 CHECK_EQ(ERR_IO_PENDING, rv); |
| 123 rv = callback.WaitForResult(); | 124 rv = callback.WaitForResult(); |
| 124 CHECK_EQ(rv, OK); | 125 CHECK_EQ(rv, OK); |
| 125 sock_ = socket_factory_->CreateTransportClientSocket(addr, NULL, &net_log_, | 126 sock_ = socket_factory_->CreateTransportClientSocket(addr, NULL, &net_log_, |
| 126 NetLog::Source()); | 127 NetLog::Source()); |
| 127 } | 128 } |
| 128 | 129 |
| 129 int TransportClientSocketTest::DrainClientSocket( | 130 int TransportClientSocketTest::DrainClientSocket( |
| 130 IOBuffer* buf, | 131 IOBuffer* buf, |
| 131 uint32_t buf_len, | 132 uint32_t buf_len, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 | 469 |
| 469 // It's possible the read is blocked because it's already read all the data. | 470 // It's possible the read is blocked because it's already read all the data. |
| 470 // Close the server socket, so there will at least be a 0-byte read. | 471 // Close the server socket, so there will at least be a 0-byte read. |
| 471 CloseServerSocket(); | 472 CloseServerSocket(); |
| 472 | 473 |
| 473 rv = callback.WaitForResult(); | 474 rv = callback.WaitForResult(); |
| 474 EXPECT_GE(rv, 0); | 475 EXPECT_GE(rv, 0); |
| 475 } | 476 } |
| 476 | 477 |
| 477 } // namespace net | 478 } // namespace net |
| OLD | NEW |