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

Side by Side Diff: net/filter/fuzzed_source_stream.h

Issue 2460633002: Add a fuzzer for GzipSourceStream (Closed)
Patch Set: Address comments Created 4 years, 1 month 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/BUILD.gn ('k') | net/filter/fuzzed_source_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef NET_FILTER_FUZZED_SOURCE_STREAM_H_
6 #define NET_FILTER_FUZZED_SOURCE_STREAM_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "net/base/completion_callback.h"
13 #include "net/filter/source_stream.h"
14
15 namespace base {
16 class FuzzedDataProvider;
17 } // namespace base
18
19 namespace net {
20
21 class IOBuffer;
22
23 // A SourceStream implementation used in tests. This allows tests to specify
24 // what data to return for each Read() call.
25 class FuzzedSourceStream : public SourceStream {
26 public:
27 // |data_provider| is used to determine behavior of the FuzzedSourceStream.
28 // It must remain valid until after the FuzzedSocket is destroyed.
29 explicit FuzzedSourceStream(base::FuzzedDataProvider* data_provider);
30 ~FuzzedSourceStream() override;
31
32 // SourceStream implementation
33 int Read(IOBuffer* dest_buffer,
34 int buffer_size,
35 const CompletionCallback& callback) override;
36 std::string Description() const override;
37
38 private:
39 void OnReadComplete(const CompletionCallback& callback,
40 const std::string& fuzzed_data,
41 scoped_refptr<IOBuffer> read_buf,
42 int result);
43
44 base::FuzzedDataProvider* data_provider_;
45
46 // Whether there is a pending Read().
47 bool read_pending_;
48
49 // Last result returned by Read() is an error or 0.
50 bool end_returned_;
51
52 DISALLOW_COPY_AND_ASSIGN(FuzzedSourceStream);
53 };
54
55 } // namespace net
56
57 #endif // NET_FILTER_FUZZED_SOURCE_STREAM_H_
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/filter/fuzzed_source_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698