| 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 "net/dns/dns_session.h" | 5 #include "net/dns/dns_session.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class TestClientSocketFactory : public ClientSocketFactory { | 25 class TestClientSocketFactory : public ClientSocketFactory { |
| 26 public: | 26 public: |
| 27 virtual ~TestClientSocketFactory(); | 27 virtual ~TestClientSocketFactory(); |
| 28 | 28 |
| 29 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( | 29 virtual scoped_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
| 30 DatagramSocket::BindType bind_type, | 30 DatagramSocket::BindType bind_type, |
| 31 const RandIntCallback& rand_int_cb, | 31 const RandIntCallback& rand_int_cb, |
| 32 net::NetLog* net_log, | 32 net::NetLog* net_log, |
| 33 const net::NetLog::Source& source) OVERRIDE; | 33 const net::NetLog::Source& source) override; |
| 34 | 34 |
| 35 virtual scoped_ptr<StreamSocket> CreateTransportClientSocket( | 35 virtual scoped_ptr<StreamSocket> CreateTransportClientSocket( |
| 36 const AddressList& addresses, | 36 const AddressList& addresses, |
| 37 NetLog*, const NetLog::Source&) OVERRIDE { | 37 NetLog*, const NetLog::Source&) override { |
| 38 NOTIMPLEMENTED(); | 38 NOTIMPLEMENTED(); |
| 39 return scoped_ptr<StreamSocket>(); | 39 return scoped_ptr<StreamSocket>(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket( | 42 virtual scoped_ptr<SSLClientSocket> CreateSSLClientSocket( |
| 43 scoped_ptr<ClientSocketHandle> transport_socket, | 43 scoped_ptr<ClientSocketHandle> transport_socket, |
| 44 const HostPortPair& host_and_port, | 44 const HostPortPair& host_and_port, |
| 45 const SSLConfig& ssl_config, | 45 const SSLConfig& ssl_config, |
| 46 const SSLClientSocketContext& context) OVERRIDE { | 46 const SSLClientSocketContext& context) override { |
| 47 NOTIMPLEMENTED(); | 47 NOTIMPLEMENTED(); |
| 48 return scoped_ptr<SSLClientSocket>(); | 48 return scoped_ptr<SSLClientSocket>(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual void ClearSSLSessionCache() OVERRIDE { | 51 virtual void ClearSSLSessionCache() override { |
| 52 NOTIMPLEMENTED(); | 52 NOTIMPLEMENTED(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 std::list<SocketDataProvider*> data_providers_; | 56 std::list<SocketDataProvider*> data_providers_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 struct PoolEvent { | 59 struct PoolEvent { |
| 60 enum { ALLOCATE, FREE } action; | 60 enum { ALLOCATE, FREE } action; |
| 61 unsigned server_index; | 61 unsigned server_index; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 85 | 85 |
| 86 class MockDnsSocketPool : public DnsSocketPool { | 86 class MockDnsSocketPool : public DnsSocketPool { |
| 87 public: | 87 public: |
| 88 MockDnsSocketPool(ClientSocketFactory* factory, DnsSessionTest* test) | 88 MockDnsSocketPool(ClientSocketFactory* factory, DnsSessionTest* test) |
| 89 : DnsSocketPool(factory), test_(test) { } | 89 : DnsSocketPool(factory), test_(test) { } |
| 90 | 90 |
| 91 virtual ~MockDnsSocketPool() { } | 91 virtual ~MockDnsSocketPool() { } |
| 92 | 92 |
| 93 virtual void Initialize( | 93 virtual void Initialize( |
| 94 const std::vector<IPEndPoint>* nameservers, | 94 const std::vector<IPEndPoint>* nameservers, |
| 95 NetLog* net_log) OVERRIDE { | 95 NetLog* net_log) override { |
| 96 InitializeInternal(nameservers, net_log); | 96 InitializeInternal(nameservers, net_log); |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual scoped_ptr<DatagramClientSocket> AllocateSocket( | 99 virtual scoped_ptr<DatagramClientSocket> AllocateSocket( |
| 100 unsigned server_index) OVERRIDE { | 100 unsigned server_index) override { |
| 101 test_->OnSocketAllocated(server_index); | 101 test_->OnSocketAllocated(server_index); |
| 102 return CreateConnectedSocket(server_index); | 102 return CreateConnectedSocket(server_index); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void FreeSocket( | 105 virtual void FreeSocket( |
| 106 unsigned server_index, | 106 unsigned server_index, |
| 107 scoped_ptr<DatagramClientSocket> socket) OVERRIDE { | 107 scoped_ptr<DatagramClientSocket> socket) override { |
| 108 test_->OnSocketFreed(server_index); | 108 test_->OnSocketFreed(server_index); |
| 109 } | 109 } |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 DnsSessionTest* test_; | 112 DnsSessionTest* test_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 void DnsSessionTest::Initialize(unsigned num_servers) { | 115 void DnsSessionTest::Initialize(unsigned num_servers) { |
| 116 CHECK(num_servers < 256u); | 116 CHECK(num_servers < 256u); |
| 117 config_.nameservers.clear(); | 117 config_.nameservers.clear(); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 TEST_F(DnsSessionTest, HistogramTimeoutLong) { | 243 TEST_F(DnsSessionTest, HistogramTimeoutLong) { |
| 244 config_.timeout = base::TimeDelta::FromSeconds(15); | 244 config_.timeout = base::TimeDelta::FromSeconds(15); |
| 245 Initialize(2); | 245 Initialize(2); |
| 246 base::TimeDelta timeout = session_->NextTimeout(0, 0); | 246 base::TimeDelta timeout = session_->NextTimeout(0, 0); |
| 247 EXPECT_EQ(config_.timeout.InMilliseconds(), timeout.InMilliseconds()); | 247 EXPECT_EQ(config_.timeout.InMilliseconds(), timeout.InMilliseconds()); |
| 248 } | 248 } |
| 249 | 249 |
| 250 } // namespace | 250 } // namespace |
| 251 | 251 |
| 252 } // namespace net | 252 } // namespace net |
| OLD | NEW |