Chromium Code Reviews| Index: net/filter/fuzzed_source_stream.h |
| diff --git a/net/filter/fuzzed_source_stream.h b/net/filter/fuzzed_source_stream.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9f62ca76ad91f369a5ad9869c11c93beadb1c158 |
| --- /dev/null |
| +++ b/net/filter/fuzzed_source_stream.h |
| @@ -0,0 +1,46 @@ |
| +// 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_FILTER_FUZZED_SOURCE_STREAM_H_ |
| +#define NET_FILTER_FUZZED_SOURCE_STREAM_H_ |
| + |
| +#include "base/macros.h" |
| +#include "net/base/completion_callback.h" |
| +#include "net/filter/source_stream.h" |
| + |
| +namespace base { |
| +class FuzzedDataProvider; |
| +} // namespace base |
| + |
| +namespace net { |
| + |
| +class IOBuffer; |
| + |
| +// A SourceStream implementation used in tests. This allows tests to specify |
| +// what data to return for each Read() call. |
| +class FuzzedSourceStream : public SourceStream { |
| + public: |
| + // |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.
|
| + // It must remain valid until after the FuzzedSocket is destroyed. |
| + FuzzedSourceStream(base::FuzzedDataProvider* data_provider); |
|
mmenke
2016/10/27 19:31:11
nit: Explicit
xunjieli
2016/10/28 15:21:47
Done.
|
| + ~FuzzedSourceStream() override; |
| + |
| + // SourceStream implementation |
| + 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.
|
| + int buffer_size, |
| + const CompletionCallback& callback) override; |
| + std::string Description() const override; |
| + |
| + private: |
| + void OnReadComplete(const CompletionCallback& callback, int result); |
| + |
| + base::FuzzedDataProvider* data_provider_; |
| + bool read_pending_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FuzzedSourceStream); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_FILTER_FUZZED_SOURCE_STREAM_H_ |