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

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, 8 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 "base/callback.h"
9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h"
11 #include "net/filter/block_buffer.h"
12
13 namespace net {
14
15 class SdchStreamSourceDelegate;
16
17 // The StreamSource class implements a producer of bytes. Sources often
18 // incorporate a previous source from which they read undecoded input. Those
19 // which incorporate a previous source take ownership of the previous source
20 // when they are created.
21 class StreamSource {
22 public:
23 enum SourceType {
24 #define STREAM_SOURCE_TYPE(label) TYPE_##label,
25 #include "net/filter/stream_source_type_list.h"
26 #undef STREAM_SOURCE_TYPE
27 // Used for UMA.
28 TYPE_MAX,
29 };
30
31 // |type| is the type of the StreamSource. |previous| is the previous
32 // StreamSource in the chain. If |previous| is null, |this| is the start of
33 // the StreamSource chain.
34 StreamSource(SourceType type, std::unique_ptr<StreamSource> previous);
35
36 virtual ~StreamSource();
37
38 typedef base::Callback<void(net::Error, size_t)> OnReadCompleteCallback;
39
40 // Initiaties a read from the filter chain starting at this stream source.
41 // If it completes synchronously, it:
42 // - Returns an Error other than ERR_IO_PENDING
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit: or OK.
xunjieli 2016/07/20 21:00:47 Done.
43 // - Writes |*bytes_read| with the count of bytes read
44 // - Writes bytes into |*dest_buffer|
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit: Presumably only if it did return OK for both
xunjieli 2016/07/20 21:00:47 Done.
45 // - Does not call |callback|
46 // If it completes asynchronously, it:
47 // - Returns ERR_IO_PENDING
48 // - Does not write |*bytes_read|
49 // - Calls |callback| when it does complete, with an error code and a count
50 // of bytes read, which are them placed into |*dest_buffer|.
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit, typo: "them" -> "then". Presuming that's wha
xunjieli 2016/07/20 21:00:48 Done.
51 // This method takes a reference to |*dest_buffer| if it completes
52 // asynchronously to ensure it does not get freed mid-read.
53 virtual net::Error Read(IOBuffer* dest_buffer,
54 size_t buffer_size,
55 size_t* bytes_read,
56 const OnReadCompleteCallback& callback) = 0;
57
58 SourceType type() const { return type_; }
59
60 StreamSource* previous() const { return previous_.get(); }
61
62 protected:
mmenke 2016/04/29 19:10:54 protected fields aren't allowed.
xunjieli 2016/07/20 21:00:48 Done.
63 SourceType type_;
64 // Previous StreamSource in the chain.
65 std::unique_ptr<StreamSource> previous_;
66 // Non-null when there is a read outstanding.
67 // scoped_refptr<IOBuffer> pending_read_buffer_;
Randy Smith (Not in Mondays) 2016/04/26 21:54:01 nit: Should these lines be removed?
xunjieli 2016/07/20 21:00:47 Done.
68 // Buffer for reading data out of |previous_| and then for use by |this|
69 // before the filtered data is returned through Read().
70 std::unique_ptr<BlockBuffer> buffer_;
71
72 private:
mmenke 2016/04/29 19:10:54 DISALLOW_COPY_AND_ASSIGN
xunjieli 2016/07/20 21:00:47 Done.
73 };
74
75 } // namespace net
76
77 #endif // NET_FILTER_STREAM_SOURCE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698