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_FILTER_STREAM_SOURCE_H | |
| 6 #define NET_FILTER_FILTER_STREAM_SOURCE_H | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "net/base/net_errors.h" | |
| 11 #include "net/filter/stream_source.h" | |
| 12 | |
| 13 namespace net { | |
| 14 | |
| 15 class IOBuffer; | |
| 16 | |
| 17 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.
| |
| 18 public: | |
| 19 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
| |
| 20 | |
| 21 ~FilterStreamSource() override; | |
| 22 | |
| 23 net::Error Read(IOBuffer* dest_buffer, | |
| 24 size_t buffer_size, | |
| 25 size_t* bytes_read, | |
| 26 const OnReadCompleteCallback& callback) override; | |
| 27 | |
| 28 // Subclass override this method to perform any initialization that needs to | |
| 29 // be completed before Read() can be called. Returns whether initialization | |
| 30 // has succeeded. If failed, filter chain will not be used. | |
| 31 virtual bool Init(); | |
| 32 | |
| 33 private: | |
| 34 // Asynchronous callback used in previous_->Read(). | |
| 35 void OnReadComplete(const OnReadCompleteCallback& callback, | |
| 36 IOBuffer* dest_buffer, | |
| 37 size_t dest_buffer_size, | |
| 38 Error error, | |
| 39 size_t bytes_read); | |
| 40 | |
| 41 // Also see Read(). Subclasses should implement this method to read data into | |
| 42 // |dest_buffer| until more input is needed from |previous_|. | |
| 43 // This method must complete synchronously (i.e. It cannot return | |
| 44 // ERR_IO_PENDING). | |
| 45 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.
| |
| 46 size_t buffer_size, | |
| 47 size_t* bytes_read) = 0; | |
|
mmenke
2016/04/29 19:10:54
DISALLOW_COPY_AND_ASSIGN
xunjieli
2016/07/20 21:00:47
Done.
| |
| 48 }; | |
| 49 | |
| 50 } // namespace net | |
| 51 | |
| 52 #endif // NET_FILTER_FILTER_STREAM_SOURCE_H | |
| OLD | NEW |