Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "base/macros.h" | |
| 9 #include "net/base/completion_callback.h" | |
| 10 #include "net/filter/source_stream.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class FuzzedDataProvider; | |
| 14 } // namespace base | |
| 15 | |
| 16 namespace net { | |
| 17 | |
| 18 class IOBuffer; | |
| 19 | |
| 20 // A SourceStream implementation used in tests. This allows tests to specify | |
| 21 // what data to return for each Read() call. | |
| 22 class FuzzedSourceStream : public SourceStream { | |
| 23 public: | |
| 24 // |data_provider| is used as to determine behavior of the FuzzedSourceStream. | |
|
mmenke
2016/10/27 19:31:11
nit: -as
xunjieli
2016/10/28 15:21:47
Done.
| |
| 25 // It must remain valid until after the FuzzedSocket is destroyed. | |
| 26 FuzzedSourceStream(base::FuzzedDataProvider* data_provider); | |
|
mmenke
2016/10/27 19:31:11
nit: Explicit
xunjieli
2016/10/28 15:21:47
Done.
| |
| 27 ~FuzzedSourceStream() override; | |
| 28 | |
| 29 // SourceStream implementation | |
| 30 int Read(IOBuffer* dest_buffer, | |
|
mmenke
2016/10/27 19:31:11
nit: Forward declare IOBuffer
xunjieli
2016/10/28 15:21:47
It's forward declared.
| |
| 31 int buffer_size, | |
| 32 const CompletionCallback& callback) override; | |
| 33 std::string Description() const override; | |
| 34 | |
| 35 private: | |
| 36 void OnReadComplete(const CompletionCallback& callback, int result); | |
| 37 | |
| 38 base::FuzzedDataProvider* data_provider_; | |
| 39 bool read_pending_; | |
| 40 | |
| 41 DISALLOW_COPY_AND_ASSIGN(FuzzedSourceStream); | |
| 42 }; | |
| 43 | |
| 44 } // namespace net | |
| 45 | |
| 46 #endif // NET_FILTER_FUZZED_SOURCE_STREAM_H_ | |
| OLD | NEW |