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

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

Issue 2540233002: Instrument SourceStream using MemoryDumpProvider
Patch Set: Rebased Created 4 years 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
« no previous file with comments | « net/filter/brotli_source_stream.cc ('k') | net/filter/filter_source_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_FILTER_FILTER_SOURCE_STREAM_H_ 5 #ifndef NET_FILTER_FILTER_SOURCE_STREAM_H_
6 #define NET_FILTER_FILTER_SOURCE_STREAM_H_ 6 #define NET_FILTER_FILTER_SOURCE_STREAM_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/filter/source_stream.h" 16 #include "net/filter/source_stream.h"
17 17
18 namespace base {
19 namespace trace_event {
20 class ProcessMemoryDump;
21 }
22 }
23
18 namespace net { 24 namespace net {
19 25
20 class DrainableIOBuffer; 26 class DrainableIOBuffer;
21 class IOBuffer; 27 class IOBuffer;
22 28
23 // FilterSourceStream represents SourceStreams that always have an upstream 29 // FilterSourceStream represents SourceStreams that always have an upstream
24 // from which undecoded input can be read. Except the ultimate upstream in 30 // from which undecoded input can be read. Except the ultimate upstream in
25 // the filter chain, all other streams should implement FilterSourceStream 31 // the filter chain, all other streams should implement FilterSourceStream
26 // instead of SourceStream. 32 // instead of SourceStream.
27 class NET_EXPORT_PRIVATE FilterSourceStream : public SourceStream { 33 class NET_EXPORT_PRIVATE FilterSourceStream : public SourceStream {
28 public: 34 public:
29 // |upstream| is the SourceStream from which |this| will read data. 35 // |upstream| is the SourceStream from which |this| will read data.
30 // |upstream| cannot be null. 36 // |upstream| cannot be null.
31 FilterSourceStream(SourceType type, std::unique_ptr<SourceStream> upstream); 37 FilterSourceStream(SourceType type, std::unique_ptr<SourceStream> upstream);
32 38
33 ~FilterSourceStream() override; 39 ~FilterSourceStream() override;
34 40
35 int Read(IOBuffer* read_buffer, 41 int Read(IOBuffer* read_buffer,
36 int read_buffer_size, 42 int read_buffer_size,
37 const CompletionCallback& callback) override; 43 const CompletionCallback& callback) override;
38 44
39 std::string Description() const override; 45 std::string Description() const override;
40 46
47 void DumpMemoryStats(
48 base::trace_event::ProcessMemoryDump* dump,
49 const std::string& parent_dump_absolute_name) const override;
50
41 private: 51 private:
42 enum State { 52 enum State {
43 STATE_NONE, 53 STATE_NONE,
44 // Reading data from |upstream_| into |input_buffer_|. 54 // Reading data from |upstream_| into |input_buffer_|.
45 STATE_READ_DATA, 55 STATE_READ_DATA,
46 // Reading data from |upstream_| completed. 56 // Reading data from |upstream_| completed.
47 STATE_READ_DATA_COMPLETE, 57 STATE_READ_DATA_COMPLETE,
48 // Filtering data contained in |input_buffer_|. 58 // Filtering data contained in |input_buffer_|.
49 STATE_FILTER_DATA, 59 STATE_FILTER_DATA,
50 // Filtering data contained in |input_buffer_| completed. 60 // Filtering data contained in |input_buffer_| completed.
(...skipping 20 matching lines...) Expand all
71 // with |upstream_eof_reached| = true. 81 // with |upstream_eof_reached| = true.
72 // TODO(xunjieli): consider allowing asynchronous response via callback 82 // TODO(xunjieli): consider allowing asynchronous response via callback
73 // to support off-thread decompression. 83 // to support off-thread decompression.
74 virtual int FilterData(IOBuffer* output_buffer, 84 virtual int FilterData(IOBuffer* output_buffer,
75 int output_buffer_size, 85 int output_buffer_size,
76 IOBuffer* input_buffer, 86 IOBuffer* input_buffer,
77 int input_buffer_size, 87 int input_buffer_size,
78 int* consumed_bytes, 88 int* consumed_bytes,
79 bool upstream_eof_reached) = 0; 89 bool upstream_eof_reached) = 0;
80 90
91 // Subclasses can implement this method to dump memory allocation stats.
92 // Subclasses should override this method instead of DumpMemoryStats
93 // so the whole chain of FilterSourceStream can be accounted for.
94 virtual void DumpMemoryStatsImpl(
95 base::trace_event::ProcessMemoryDump* dump,
96 const std::string& parent_dump_absolute_name) const;
97
81 // Returns a string representation of the type of this FilterSourceStream. 98 // Returns a string representation of the type of this FilterSourceStream.
82 // This is for UMA logging. 99 // This is for UMA logging.
83 virtual std::string GetTypeAsString() const = 0; 100 virtual std::string GetTypeAsString() const = 0;
84 101
85 // Returns whether |this| still needs more input data from |upstream_|. 102 // Returns whether |this| still needs more input data from |upstream_|.
86 // By default, |this| will continue reading until |upstream_| returns an error 103 // By default, |this| will continue reading until |upstream_| returns an error
87 // or EOF. Subclass can override this to return false to skip reading all the 104 // or EOF. Subclass can override this to return false to skip reading all the
88 // input from |upstream_|. 105 // input from |upstream_|.
89 virtual bool NeedMoreData() const; 106 virtual bool NeedMoreData() const;
90 107
(...skipping 19 matching lines...) Expand all
110 127
111 // Reading from |upstream_| has returned 0 byte or an error code. 128 // Reading from |upstream_| has returned 0 byte or an error code.
112 bool upstream_end_reached_; 129 bool upstream_end_reached_;
113 130
114 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream); 131 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream);
115 }; 132 };
116 133
117 } // namespace net 134 } // namespace net
118 135
119 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_ 136 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_
OLDNEW
« no previous file with comments | « net/filter/brotli_source_stream.cc ('k') | net/filter/filter_source_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698