Chromium Code Reviews| Index: net/filter/filter_stream_source.h |
| diff --git a/net/filter/filter_stream_source.h b/net/filter/filter_stream_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ccaebbaf087401fbec07934470586ef7bd1e8e6e |
| --- /dev/null |
| +++ b/net/filter/filter_stream_source.h |
| @@ -0,0 +1,52 @@ |
| +// 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_FILTER_STREAM_SOURCE_H |
| +#define NET_FILTER_FILTER_STREAM_SOURCE_H |
| + |
| +#include <memory> |
| + |
| +#include "net/base/net_errors.h" |
| +#include "net/filter/stream_source.h" |
| + |
| +namespace net { |
| + |
| +class IOBuffer; |
| + |
| +class FilterStreamSource : public StreamSource { |
|
Randy Smith (Not in Mondays)
2016/04/26 21:54:01
nit: comment as to use.
xunjieli
2016/07/20 21:00:47
Done.
|
| + public: |
| + FilterStreamSource(SourceType type, std::unique_ptr<StreamSource> previous); |
|
mmenke
2016/04/29 19:10:54
Hrm...Wonder about "next" vs "previous".
We could
xunjieli
2016/07/20 21:00:47
Done. I have added a comment. I think |previous| i
|
| + |
| + ~FilterStreamSource() override; |
| + |
| + net::Error Read(IOBuffer* dest_buffer, |
| + size_t buffer_size, |
| + size_t* bytes_read, |
| + const OnReadCompleteCallback& callback) override; |
| + |
| + // Subclass override this method to perform any initialization that needs to |
| + // be completed before Read() can be called. Returns whether initialization |
| + // has succeeded. If failed, filter chain will not be used. |
| + virtual bool Init(); |
| + |
| + private: |
| + // Asynchronous callback used in previous_->Read(). |
| + void OnReadComplete(const OnReadCompleteCallback& callback, |
| + IOBuffer* dest_buffer, |
| + size_t dest_buffer_size, |
| + Error error, |
| + size_t bytes_read); |
| + |
| + // Also see Read(). Subclasses should implement this method to read data into |
| + // |dest_buffer| until more input is needed from |previous_|. |
| + // This method must complete synchronously (i.e. It cannot return |
| + // ERR_IO_PENDING). |
| + virtual net::Error ReadInternal(IOBuffer* dest_buffer, |
|
Randy Smith (Not in Mondays)
2016/04/26 21:54:01
I think this would be cleaner if it took an input
xunjieli
2016/07/20 21:00:47
Done.
|
| + size_t buffer_size, |
| + size_t* bytes_read) = 0; |
|
mmenke
2016/04/29 19:10:54
DISALLOW_COPY_AND_ASSIGN
xunjieli
2016/07/20 21:00:47
Done.
|
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_FILTER_FILTER_STREAM_SOURCE_H |