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

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

Issue 2525743002: Make URLRequestContext a MemoryDumpProvider (Abandoned) (Closed)
Patch Set: rebased to 7f3d142161b15869f6bea58ac43c5f52ce5834ac 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
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 MemoryAllocatorDump;
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::MemoryAllocatorDump* dump) const override;
49
41 private: 50 private:
42 enum State { 51 enum State {
43 STATE_NONE, 52 STATE_NONE,
44 // Reading data from |upstream_| into |input_buffer_|. 53 // Reading data from |upstream_| into |input_buffer_|.
45 STATE_READ_DATA, 54 STATE_READ_DATA,
46 // Reading data from |upstream_| completed. 55 // Reading data from |upstream_| completed.
47 STATE_READ_DATA_COMPLETE, 56 STATE_READ_DATA_COMPLETE,
48 // Filtering data contained in |input_buffer_|. 57 // Filtering data contained in |input_buffer_|.
49 STATE_FILTER_DATA, 58 STATE_FILTER_DATA,
50 // Filtering data contained in |input_buffer_| completed. 59 // Filtering data contained in |input_buffer_| completed.
(...skipping 20 matching lines...) Expand all
71 // with |upstream_eof_reached| = true. 80 // with |upstream_eof_reached| = true.
72 // TODO(xunjieli): consider allowing asynchronous response via callback 81 // TODO(xunjieli): consider allowing asynchronous response via callback
73 // to support off-thread decompression. 82 // to support off-thread decompression.
74 virtual int FilterData(IOBuffer* output_buffer, 83 virtual int FilterData(IOBuffer* output_buffer,
75 int output_buffer_size, 84 int output_buffer_size,
76 IOBuffer* input_buffer, 85 IOBuffer* input_buffer,
77 int input_buffer_size, 86 int input_buffer_size,
78 int* consumed_bytes, 87 int* consumed_bytes,
79 bool upstream_eof_reached) = 0; 88 bool upstream_eof_reached) = 0;
80 89
90 // Subclasses can implement this method to dump memory allocation stats.
91 // |dump| is the memory allocator dump of the URLRequestJob.
92 virtual void DumpMemoryStatsImpl(
93 base::trace_event::MemoryAllocatorDump* dump) const = 0;
eroman 2016/11/29 22:22:50 What is the relation between this and DumpMemorySt
xunjieli 2016/11/30 16:02:03 Done. I've added a comment. The main reason is tha
94
81 // Returns a string representation of the type of this FilterSourceStream. 95 // Returns a string representation of the type of this FilterSourceStream.
82 // This is for UMA logging. 96 // This is for UMA logging.
83 virtual std::string GetTypeAsString() const = 0; 97 virtual std::string GetTypeAsString() const = 0;
84 98
85 // Returns whether |this| still needs more input data from |upstream_|. 99 // Returns whether |this| still needs more input data from |upstream_|.
86 // By default, |this| will continue reading until |upstream_| returns an error 100 // 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 101 // or EOF. Subclass can override this to return false to skip reading all the
88 // input from |upstream_|. 102 // input from |upstream_|.
89 virtual bool NeedMoreData() const; 103 virtual bool NeedMoreData() const;
90 104
(...skipping 19 matching lines...) Expand all
110 124
111 // Reading from |upstream_| has returned 0 byte or an error code. 125 // Reading from |upstream_| has returned 0 byte or an error code.
112 bool upstream_end_reached_; 126 bool upstream_end_reached_;
113 127
114 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream); 128 DISALLOW_COPY_AND_ASSIGN(FilterSourceStream);
115 }; 129 };
116 130
117 } // namespace net 131 } // namespace net
118 132
119 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_ 133 #endif // NET_FILTER_FILTER_SOURCE_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698