| 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_STREAM_SOURCE_H |
| 6 #define NET_FILTER_STREAM_SOURCE_H |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "net/base/completion_callback.h" |
| 12 #include "net/base/net_errors.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 class IOBuffer; |
| 17 class SdchStreamSourceDelegate; |
| 18 |
| 19 // The StreamSource class implements a producer of bytes. Sources often |
| 20 // incorporate a previous source from which they read undecoded input. Those |
| 21 // which incorporate a previous source take ownership of the previous source |
| 22 // when they are created. |
| 23 class NET_EXPORT_PRIVATE StreamSource { |
| 24 public: |
| 25 enum SourceType { |
| 26 #define STREAM_SOURCE_TYPE(label) TYPE_##label, |
| 27 #include "net/filter/stream_source_type_list.h" |
| 28 #undef STREAM_SOURCE_TYPE |
| 29 // Used for UMA. |
| 30 TYPE_MAX, |
| 31 }; |
| 32 |
| 33 // |type| is the type of the StreamSource. |
| 34 StreamSource(SourceType type); |
| 35 |
| 36 virtual ~StreamSource(); |
| 37 |
| 38 // Initiaties a read from the filter chain starting at this stream source. |
| 39 // If it completes synchronously, it: |
| 40 // - Returns an int representing the number of bytes read. If 0, EOF has |
| 41 // been reached |
| 42 // - Bytes will be written into |*dest_buffer| |
| 43 // - Does not call |callback| |
| 44 // If it completes asynchronously, it: |
| 45 // - Returns ERR_IO_PENDING |
| 46 // - Calls |callback| when it does complete, with an error code and a count |
| 47 // of bytes read and written into |*dest_buffer|. |
| 48 // This method takes a reference to |*dest_buffer| if it completes |
| 49 // asynchronously to ensure it does not get freed mid-read. |
| 50 virtual int Read(IOBuffer* dest_buffer, |
| 51 size_t buffer_size, |
| 52 const CompletionCallback& callback) = 0; |
| 53 |
| 54 // Returns a string that represents the filter chain that starts at and |
| 55 // includes |this|. This is for UMA logging. |
| 56 virtual std::string OrderedTypeStringList() const; |
| 57 |
| 58 SourceType type() const { return type_; } |
| 59 |
| 60 private: |
| 61 SourceType type_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(StreamSource); |
| 64 }; |
| 65 |
| 66 } // namespace net |
| 67 |
| 68 #endif // NET_FILTER_STREAM_SOURCE_H |
| OLD | NEW |