OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Filter performs filtering on data streams. Sample usage: | 5 // Filter performs filtering on data streams. Sample usage: |
6 // | 6 // |
7 // IStream* pre_filter_source; | 7 // IStream* pre_filter_source; |
8 // ... | 8 // ... |
9 // Filter* filter = Filter::Factory(filter_type, size); | 9 // Filter* filter = Filter::Factory(filter_type, size); |
10 // int pre_filter_data_len = filter->stream_buffer_size(); | 10 // int pre_filter_data_len = filter->stream_buffer_size(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 | 48 |
49 #include <string> | 49 #include <string> |
50 #include <vector> | 50 #include <vector> |
51 | 51 |
52 #include "base/basictypes.h" | 52 #include "base/basictypes.h" |
53 #include "base/gtest_prod_util.h" | 53 #include "base/gtest_prod_util.h" |
54 #include "base/memory/ref_counted.h" | 54 #include "base/memory/ref_counted.h" |
55 #include "base/memory/scoped_ptr.h" | 55 #include "base/memory/scoped_ptr.h" |
56 #include "base/time/time.h" | 56 #include "base/time/time.h" |
57 #include "net/base/net_export.h" | 57 #include "net/base/net_export.h" |
58 #include "net/base/sdch_manager.h" | |
58 | 59 |
59 class GURL; | 60 class GURL; |
60 | 61 |
61 namespace net { | 62 namespace net { |
62 | 63 |
63 class URLRequestContext; | 64 class URLRequestContext; |
64 class IOBuffer; | 65 class IOBuffer; |
65 | 66 |
66 //------------------------------------------------------------------------------ | 67 //------------------------------------------------------------------------------ |
67 // Define an interface class that allows access to contextual information | 68 // Define an interface class that allows access to contextual information |
68 // supplied by the owner of this filter. In the case where there are a chain of | 69 // supplied by the owner of this filter. In the case where there are a chain of |
69 // filters, there is only one owner of all the chained filters, and that context | 70 // filters, there is only one owner of all the chained filters, and that context |
70 // is passed to the constructor of all those filters. To be clear, the context | 71 // is passed to the constructor of all those filters. To be clear, the context |
71 // does NOT reflect the position in a chain, or the fact that there are prior | 72 // does NOT reflect the position in a chain, or the fact that there are prior |
72 // or later filters in a chain. | 73 // or later filters in a chain. |
74 // | |
75 // TODO(rdsmith): FilterContext is a grab-bag of methods which may or may | |
76 // not be relevant for any particular filter, and it's getting worse over | |
77 // time. In addition, it only supports two filters, sdch and gzip. | |
78 // It would make more sense to implement FilterContext as a | |
79 // base::SupportsUserData structure to which filter-specific information | |
80 // could be added by whatever the ultimate consumer of the filter chain is, | |
81 // and a particular filter (if included) could access that information. | |
73 class NET_EXPORT_PRIVATE FilterContext { | 82 class NET_EXPORT_PRIVATE FilterContext { |
74 public: | 83 public: |
75 // Enum to control what histograms are emitted near end-of-life of this | 84 // Enum to control what histograms are emitted near end-of-life of this |
76 // instance. | 85 // instance. |
77 enum StatisticSelector { | 86 enum StatisticSelector { |
78 SDCH_DECODE, | 87 SDCH_DECODE, |
79 SDCH_PASSTHROUGH, | 88 SDCH_PASSTHROUGH, |
80 SDCH_EXPERIMENT_DECODE, | 89 SDCH_EXPERIMENT_DECODE, |
81 SDCH_EXPERIMENT_HOLDBACK, | 90 SDCH_EXPERIMENT_HOLDBACK, |
82 }; | 91 }; |
(...skipping 16 matching lines...) Expand all Loading... | |
99 // When was this data requested from a server? | 108 // When was this data requested from a server? |
100 virtual base::Time GetRequestTime() const = 0; | 109 virtual base::Time GetRequestTime() const = 0; |
101 | 110 |
102 // Is data supplied from cache, or fresh across the net? | 111 // Is data supplied from cache, or fresh across the net? |
103 virtual bool IsCachedContent() const = 0; | 112 virtual bool IsCachedContent() const = 0; |
104 | 113 |
105 // Is this a download? | 114 // Is this a download? |
106 virtual bool IsDownload() const = 0; | 115 virtual bool IsDownload() const = 0; |
107 | 116 |
108 // Was this data flagged as a response to a request with an SDCH dictionary? | 117 // Was this data flagged as a response to a request with an SDCH dictionary? |
109 virtual bool SdchResponseExpected() const = 0; | 118 virtual SdchManager::DictionarySet* |
119 SdchDictionariesAdvertised() const = 0; | |
Bence
2014/11/12 21:46:26
From the Google C++ style guide: "If you break af
Randy Smith (Not in Mondays)
2014/11/13 22:11:02
Moot; fits on one line anyway :-}. Fixed.
| |
110 | 120 |
111 // How many bytes were read from the net or cache so far (and potentially | 121 // How many bytes were read from the net or cache so far (and potentially |
112 // pushed into a filter for processing)? | 122 // pushed into a filter for processing)? |
113 virtual int64 GetByteReadCount() const = 0; | 123 virtual int64 GetByteReadCount() const = 0; |
114 | 124 |
115 // What response code was received with the associated network transaction? | 125 // What response code was received with the associated network transaction? |
116 // For example: 200 is ok. 4xx are error codes. etc. | 126 // For example: 200 is ok. 4xx are error codes. etc. |
117 virtual int GetResponseCode() const = 0; | 127 virtual int GetResponseCode() const = 0; |
118 | 128 |
119 // The URLRequestContext associated with the request. | 129 // The URLRequestContext associated with the request. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 // Remember what status or local filter last returned so we can better handle | 303 // Remember what status or local filter last returned so we can better handle |
294 // chained filters. | 304 // chained filters. |
295 FilterStatus last_status_; | 305 FilterStatus last_status_; |
296 | 306 |
297 DISALLOW_COPY_AND_ASSIGN(Filter); | 307 DISALLOW_COPY_AND_ASSIGN(Filter); |
298 }; | 308 }; |
299 | 309 |
300 } // namespace net | 310 } // namespace net |
301 | 311 |
302 #endif // NET_FILTER_FILTER_H__ | 312 #endif // NET_FILTER_FILTER_H__ |
OLD | NEW |