Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(986)

Side by Side Diff: net/socket/fuzzed_socket_factory.h

Issue 2250263003: Move FuzzedDataProvider to //base and expose to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ... also remove PLATFORM_EXPORT Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/fuzzed_socket.cc ('k') | net/socket/fuzzed_socket_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_SOCKET_FUZZED_SOCKET_FACTORY_H_ 5 #ifndef NET_SOCKET_FUZZED_SOCKET_FACTORY_H_
6 #define NET_SOCKET_FUZZED_SOCKET_FACTORY_H_ 6 #define NET_SOCKET_FUZZED_SOCKET_FACTORY_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "net/socket/client_socket_factory.h" 11 #include "net/socket/client_socket_factory.h"
12 12
13 namespace base {
14 class FuzzedDataProvider;
15 }
16
13 namespace net { 17 namespace net {
14 18
15 class FuzzedDataProvider;
16
17 // A socket factory that creates FuzzedSockets that share the same 19 // A socket factory that creates FuzzedSockets that share the same
18 // FuzzedDataProvider. To behave consistently, the read operations on all 20 // FuzzedDataProvider. To behave consistently, the read operations on all
19 // sockets must be the same, and in the same order (both on each socket, and 21 // sockets must be the same, and in the same order (both on each socket, and
20 // between sockets). 22 // between sockets).
21 // 23 //
22 // Currently doesn't support UDP or SSL sockets - just returns sockets that 24 // Currently doesn't support UDP or SSL sockets - just returns sockets that
23 // synchronously fail to connect when trying to create either type of socket. 25 // synchronously fail to connect when trying to create either type of socket.
24 // TODO(mmenke): Add support for both types of socket. 26 // TODO(mmenke): Add support for both types of socket.
25 // TODO(mmenke): add fuzzing for generation of valid cryptographically signed 27 // TODO(mmenke): add fuzzing for generation of valid cryptographically signed
26 // messages. 28 // messages.
27 class FuzzedSocketFactory : public ClientSocketFactory { 29 class FuzzedSocketFactory : public ClientSocketFactory {
28 public: 30 public:
29 // |data_provider| must outlive the FuzzedSocketFactory, and all sockets it 31 // |data_provider| must outlive the FuzzedSocketFactory, and all sockets it
30 // creates. Other objects can also continue to consume |data_provider|, as 32 // creates. Other objects can also continue to consume |data_provider|, as
31 // long as their calls into it are made on the CLientSocketFactory's thread 33 // long as their calls into it are made on the CLientSocketFactory's thread
32 // and the calls are deterministic. 34 // and the calls are deterministic.
33 explicit FuzzedSocketFactory(FuzzedDataProvider* data_provider); 35 explicit FuzzedSocketFactory(base::FuzzedDataProvider* data_provider);
34 ~FuzzedSocketFactory() override; 36 ~FuzzedSocketFactory() override;
35 37
36 std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( 38 std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket(
37 DatagramSocket::BindType bind_type, 39 DatagramSocket::BindType bind_type,
38 const RandIntCallback& rand_int_cb, 40 const RandIntCallback& rand_int_cb,
39 NetLog* net_log, 41 NetLog* net_log,
40 const NetLog::Source& source) override; 42 const NetLog::Source& source) override;
41 43
42 std::unique_ptr<StreamSocket> CreateTransportClientSocket( 44 std::unique_ptr<StreamSocket> CreateTransportClientSocket(
43 const AddressList& addresses, 45 const AddressList& addresses,
44 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, 46 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher,
45 NetLog* net_log, 47 NetLog* net_log,
46 const NetLog::Source& source) override; 48 const NetLog::Source& source) override;
47 49
48 std::unique_ptr<SSLClientSocket> CreateSSLClientSocket( 50 std::unique_ptr<SSLClientSocket> CreateSSLClientSocket(
49 std::unique_ptr<ClientSocketHandle> transport_socket, 51 std::unique_ptr<ClientSocketHandle> transport_socket,
50 const HostPortPair& host_and_port, 52 const HostPortPair& host_and_port,
51 const SSLConfig& ssl_config, 53 const SSLConfig& ssl_config,
52 const SSLClientSocketContext& context) override; 54 const SSLClientSocketContext& context) override;
53 55
54 void ClearSSLSessionCache() override; 56 void ClearSSLSessionCache() override;
55 57
56 private: 58 private:
57 FuzzedDataProvider* data_provider_; 59 base::FuzzedDataProvider* data_provider_;
58 60
59 DISALLOW_COPY_AND_ASSIGN(FuzzedSocketFactory); 61 DISALLOW_COPY_AND_ASSIGN(FuzzedSocketFactory);
60 }; 62 };
61 63
62 } // namespace net 64 } // namespace net
63 65
64 #endif // NET_SOCKET_FUZZED_SOCKET_FACTORY_H_ 66 #endif // NET_SOCKET_FUZZED_SOCKET_FACTORY_H_
OLDNEW
« no previous file with comments | « net/socket/fuzzed_socket.cc ('k') | net/socket/fuzzed_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698