| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/fuzzed_socket_factory.h" | 5 #include "net/socket/fuzzed_socket_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/test/fuzzed_data_provider.h" | 9 #include "base/test/fuzzed_data_provider.h" |
| 10 #include "net/base/address_list.h" | 10 #include "net/base/address_list.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 private: | 122 private: |
| 123 NetLogWithSource net_log_; | 123 NetLogWithSource net_log_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(FailingSSLClientSocket); | 125 DISALLOW_COPY_AND_ASSIGN(FailingSSLClientSocket); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 FuzzedSocketFactory::FuzzedSocketFactory( | 130 FuzzedSocketFactory::FuzzedSocketFactory( |
| 131 base::FuzzedDataProvider* data_provider) | 131 base::FuzzedDataProvider* data_provider) |
| 132 : data_provider_(data_provider) {} | 132 : data_provider_(data_provider), fuzz_connect_result_(true) {} |
| 133 | 133 |
| 134 FuzzedSocketFactory::~FuzzedSocketFactory() {} | 134 FuzzedSocketFactory::~FuzzedSocketFactory() {} |
| 135 | 135 |
| 136 std::unique_ptr<DatagramClientSocket> | 136 std::unique_ptr<DatagramClientSocket> |
| 137 FuzzedSocketFactory::CreateDatagramClientSocket( | 137 FuzzedSocketFactory::CreateDatagramClientSocket( |
| 138 DatagramSocket::BindType bind_type, | 138 DatagramSocket::BindType bind_type, |
| 139 const RandIntCallback& rand_int_cb, | 139 const RandIntCallback& rand_int_cb, |
| 140 NetLog* net_log, | 140 NetLog* net_log, |
| 141 const NetLogSource& source) { | 141 const NetLogSource& source) { |
| 142 return base::MakeUnique<FuzzedDatagramClientSocket>(data_provider_); | 142 return base::MakeUnique<FuzzedDatagramClientSocket>(data_provider_); |
| 143 } | 143 } |
| 144 | 144 |
| 145 std::unique_ptr<StreamSocket> FuzzedSocketFactory::CreateTransportClientSocket( | 145 std::unique_ptr<StreamSocket> FuzzedSocketFactory::CreateTransportClientSocket( |
| 146 const AddressList& addresses, | 146 const AddressList& addresses, |
| 147 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, | 147 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
| 148 NetLog* net_log, | 148 NetLog* net_log, |
| 149 const NetLogSource& source) { | 149 const NetLogSource& source) { |
| 150 std::unique_ptr<FuzzedSocket> socket( | 150 std::unique_ptr<FuzzedSocket> socket( |
| 151 new FuzzedSocket(data_provider_, net_log)); | 151 new FuzzedSocket(data_provider_, net_log)); |
| 152 socket->set_fuzz_connect_result(true); | 152 socket->set_fuzz_connect_result(fuzz_connect_result_); |
| 153 // Just use the first address. | 153 // Just use the first address. |
| 154 socket->set_remote_address(*addresses.begin()); | 154 socket->set_remote_address(*addresses.begin()); |
| 155 return std::move(socket); | 155 return std::move(socket); |
| 156 } | 156 } |
| 157 | 157 |
| 158 std::unique_ptr<SSLClientSocket> FuzzedSocketFactory::CreateSSLClientSocket( | 158 std::unique_ptr<SSLClientSocket> FuzzedSocketFactory::CreateSSLClientSocket( |
| 159 std::unique_ptr<ClientSocketHandle> transport_socket, | 159 std::unique_ptr<ClientSocketHandle> transport_socket, |
| 160 const HostPortPair& host_and_port, | 160 const HostPortPair& host_and_port, |
| 161 const SSLConfig& ssl_config, | 161 const SSLConfig& ssl_config, |
| 162 const SSLClientSocketContext& context) { | 162 const SSLClientSocketContext& context) { |
| 163 return base::MakeUnique<FailingSSLClientSocket>(); | 163 return base::MakeUnique<FailingSSLClientSocket>(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void FuzzedSocketFactory::ClearSSLSessionCache() {} | 166 void FuzzedSocketFactory::ClearSSLSessionCache() {} |
| 167 | 167 |
| 168 } // namespace net | 168 } // namespace net |
| OLD | NEW |