Chromium Code Reviews| Index: net/filter/stream_source.h |
| diff --git a/net/filter/stream_source.h b/net/filter/stream_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..623f996e7d477d4f9ab0afae791df7fef78ce378 |
| --- /dev/null |
| +++ b/net/filter/stream_source.h |
| @@ -0,0 +1,68 @@ |
| +// 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_STREAM_SOURCE_H |
| +#define NET_FILTER_STREAM_SOURCE_H |
|
mmenke
2016/07/21 18:14:09
+_ (x3)
xunjieli
2016/07/27 20:32:03
Done.
|
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "net/base/completion_callback.h" |
| +#include "net/base/net_errors.h" |
| + |
| +namespace net { |
| + |
| +class IOBuffer; |
| +class SdchStreamSourceDelegate; |
| + |
| +// The StreamSource class implements a producer of bytes. Sources often |
| +// incorporate a previous source from which they read undecoded input. Those |
| +// which incorporate a previous source take ownership of the previous source |
| +// when they are created. |
| +class NET_EXPORT_PRIVATE StreamSource { |
| + public: |
| + enum SourceType { |
| +#define STREAM_SOURCE_TYPE(label) TYPE_##label, |
| +#include "net/filter/stream_source_type_list.h" |
| +#undef STREAM_SOURCE_TYPE |
| + // Used for UMA. |
| + TYPE_MAX, |
| + }; |
| + |
| + // |type| is the type of the StreamSource. |
| + StreamSource(SourceType type); |
|
mmenke
2016/07/21 18:14:09
explicit
xunjieli
2016/07/27 20:32:03
Done.
|
| + |
| + virtual ~StreamSource(); |
| + |
| + // Initiaties a read from the filter chain starting at this stream source. |
| + // If it completes synchronously, it: |
| + // - Returns an int representing the number of bytes read. If 0, EOF has |
| + // been reached |
| + // - Bytes will be written into |*dest_buffer| |
| + // - Does not call |callback| |
| + // If it completes asynchronously, it: |
| + // - Returns ERR_IO_PENDING |
| + // - Calls |callback| when it does complete, with an error code and a count |
| + // of bytes read and written into |*dest_buffer|. |
| + // This method takes a reference to |*dest_buffer| if it completes |
| + // asynchronously to ensure it does not get freed mid-read. |
| + virtual int Read(IOBuffer* dest_buffer, |
| + size_t buffer_size, |
| + const CompletionCallback& callback) = 0; |
| + |
| + // Returns a string that represents the filter chain that starts at and |
| + // includes |this|. This is for UMA logging. |
| + virtual std::string OrderedTypeStringList() const; |
|
mmenke
2016/07/21 18:14:09
include <string>
xunjieli
2016/07/27 20:32:03
Done.
|
| + |
| + SourceType type() const { return type_; } |
| + |
| + private: |
| + SourceType type_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(StreamSource); |
| +}; |
| + |
| +} // namespace net |
| + |
| +#endif // NET_FILTER_STREAM_SOURCE_H |