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

Side by Side Diff: net/filter/source_stream.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: add filter_source_stream_unittest.cc and address other 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_SOURCE_STREAM_H_
6 #define NET_FILTER_SOURCE_STREAM_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 SourceStream class implements a producer of bytes.
21 class NET_EXPORT_PRIVATE SourceStream {
22 public:
23 enum SourceType {
24 #define SOURCE_STREAM_TYPE(label) TYPE_##label,
25 #include "net/filter/source_stream_type_list.h"
26 #undef SOURCE_STREAM_TYPE
27 // Used for UMA.
28 TYPE_MAX,
29 };
30
31 // |type| is the type of the SourceStream.
32 explicit SourceStream(SourceType type);
33
34 virtual ~SourceStream();
35
36 // Initiaties a read from the stream.
37 // If it completes synchronously, it:
38 // - Returns an int representing the number of bytes read. If 0, EOF has
39 // been reached
40 // - Bytes will be written into |*dest_buffer|
41 // - Does not call |callback|
42 // If it completes asynchronously, it:
43 // - Returns ERR_IO_PENDING
44 // - Calls |callback| when it does complete, with an error code and a count
Randy Smith (Not in Mondays) 2016/08/09 20:28:30 nit, suggestion "an error code *or* a count"?
xunjieli 2016/08/15 15:19:08 Done.
45 // of bytes read and written into |*dest_buffer|.
46 // This method takes a reference to |*dest_buffer| if it completes
47 // asynchronously to ensure it does not get freed mid-read.
48 virtual int Read(IOBuffer* dest_buffer,
49 size_t buffer_size,
50 const CompletionCallback& callback) = 0;
51
52 // Returns a string that represents stream. This is for UMA logging.
53 virtual std::string OrderedTypeStringList() const;
Randy Smith (Not in Mondays) 2016/08/09 20:28:30 Why is this named OrderedTypeStringList()? I'm no
Randy Smith (Not in Mondays) 2016/08/09 20:28:30 Suggestion: If I'm reading the code correctly, the
xunjieli 2016/08/15 15:19:07 Done.
xunjieli 2016/08/15 15:19:08 This is moved over from the original code. The ori
Randy Smith (Not in Mondays) 2016/08/22 22:04:32 Yeah, but that code was more explicit about filter
54
55 SourceType type() const { return type_; }
56
57 private:
58 SourceType type_;
59
60 DISALLOW_COPY_AND_ASSIGN(SourceStream);
61 };
62
63 } // namespace net
64
65 #endif // NET_FILTER_SOURCE_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698