Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: net/filter/stream_source.h

Issue 1662763002: [ON HOLD] Implement pull-based design for content decoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <string>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "net/base/completion_callback.h"
14 #include "net/base/net_errors.h"
15
16 namespace net {
17
18 class IOBuffer;
19
20 // The StreamSource class implements a producer of bytes. Sources often
21 // incorporate a previous source from which they read undecoded input. Those
22 // which incorporate a previous source take ownership of the previous source
23 // when they are created.
24 class NET_EXPORT_PRIVATE StreamSource {
25 public:
26 enum SourceType {
27 #define STREAM_SOURCE_TYPE(label) TYPE_##label,
28 #include "net/filter/stream_source_type_list.h"
29 #undef STREAM_SOURCE_TYPE
30 // Used for UMA.
31 TYPE_MAX,
32 };
33
34 // |type| is the type of the StreamSource.
35 explicit StreamSource(SourceType type);
36
37 virtual ~StreamSource();
38
39 // Initiaties a read from the filter chain starting at this stream source.
40 // If it completes synchronously, it:
41 // - Returns an int representing the number of bytes read. If 0, EOF has
42 // been reached
43 // - Bytes will be written into |*dest_buffer|
44 // - Does not call |callback|
45 // If it completes asynchronously, it:
46 // - Returns ERR_IO_PENDING
47 // - Calls |callback| when it does complete, with an error code and a count
48 // of bytes read and written into |*dest_buffer|.
49 // This method takes a reference to |*dest_buffer| if it completes
50 // asynchronously to ensure it does not get freed mid-read.
51 virtual int Read(IOBuffer* dest_buffer,
52 size_t buffer_size,
53 const CompletionCallback& callback) = 0;
54
55 // Returns a string that represents the filter chain that starts at and
56 // includes |this|. This is for UMA logging.
57 virtual std::string OrderedTypeStringList() const;
58
59 SourceType type() const { return type_; }
60
61 private:
62 SourceType type_;
63
64 DISALLOW_COPY_AND_ASSIGN(StreamSource);
65 };
66
67 } // namespace net
68
69 #endif // NET_FILTER_STREAM_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698