| Index: net/socket/fuzzed_socket_factory.h
|
| diff --git a/net/socket/fuzzed_socket_factory.h b/net/socket/fuzzed_socket_factory.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6b102ff8b8f1c2c3611fe120b5cb9ff0ee559a22
|
| --- /dev/null
|
| +++ b/net/socket/fuzzed_socket_factory.h
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_SOCKET_FUZZED_SOCKET_FACTORY_H
|
| +#define NET_SOCKET_FUZZED_SOCKET_FACTORY_H
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/macros.h"
|
| +#include "net/socket/client_socket_factory.h"
|
| +
|
| +namespace net {
|
| +
|
| +class FuzzedDataProvider;
|
| +
|
| +// A socket factory that creates FuzzedSockets that share the same
|
| +// FuzzedDataProvider. To behave consistently, the read operations on all
|
| +// sockets must be the same, and in the same order (both on each socket, and
|
| +// between sockets).
|
| +//
|
| +// Currently doesn't support UDP or SSL sockets - just returns sockets that
|
| +// synchronously fail to connect when trying to create either type of socket.
|
| +// TODO(mmenke): Add support for both types of socket.
|
| +// TODO(mmenke): add fuzzing for generation of valid cryptographically signed
|
| +// messages.
|
| +class FuzzedSocketFactory : public ClientSocketFactory {
|
| + public:
|
| + // |data_provider| must outlive the FuzzedSocketFactory, and all sockets it
|
| + // creates. Other objects can also continue to consume |data_provider|, as
|
| + // long as their calls into it are made on the CLientSocketFactory's thread
|
| + // and the calls are deterministic.
|
| + explicit FuzzedSocketFactory(FuzzedDataProvider* data_provider);
|
| + ~FuzzedSocketFactory() override;
|
| +
|
| + std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket(
|
| + DatagramSocket::BindType bind_type,
|
| + const RandIntCallback& rand_int_cb,
|
| + NetLog* net_log,
|
| + const NetLog::Source& source) override;
|
| +
|
| + std::unique_ptr<StreamSocket> CreateTransportClientSocket(
|
| + const AddressList& addresses,
|
| + std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
|
| + NetLog* net_log,
|
| + const NetLog::Source& source) override;
|
| +
|
| + std::unique_ptr<SSLClientSocket> CreateSSLClientSocket(
|
| + std::unique_ptr<ClientSocketHandle> transport_socket,
|
| + const HostPortPair& host_and_port,
|
| + const SSLConfig& ssl_config,
|
| + const SSLClientSocketContext& context) override;
|
| +
|
| + void ClearSSLSessionCache() override;
|
| +
|
| + private:
|
| + FuzzedDataProvider* data_provider_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(FuzzedSocketFactory);
|
| +};
|
| +
|
| +} // namespace net
|
| +
|
| +#endif // NET_SOCKET_FUZZED_SOCKET_FACTORY_H
|
|
|