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 BoundNetLog; | 64 class BoundNetLog; |
64 class IOBuffer; | 65 class IOBuffer; |
65 class URLRequestContext; | 66 class URLRequestContext; |
66 | 67 |
67 //------------------------------------------------------------------------------ | 68 //------------------------------------------------------------------------------ |
68 // Define an interface class that allows access to contextual information | 69 // Define an interface class that allows access to contextual information |
69 // supplied by the owner of this filter. In the case where there are a chain of | 70 // supplied by the owner of this filter. In the case where there are a chain of |
70 // filters, there is only one owner of all the chained filters, and that context | 71 // filters, there is only one owner of all the chained filters, and that context |
71 // is passed to the constructor of all those filters. To be clear, the context | 72 // is passed to the constructor of all those filters. To be clear, the context |
72 // does NOT reflect the position in a chain, or the fact that there are prior | 73 // does NOT reflect the position in a chain, or the fact that there are prior |
73 // or later filters in a chain. | 74 // or later filters in a chain. |
| 75 // |
| 76 // TODO(rdsmith): FilterContext is a grab-bag of methods which may or may |
| 77 // not be relevant for any particular filter, and it's getting worse over |
| 78 // time. In addition, it only supports two filters, SDCH and gzip. |
| 79 // It would make more sense to implement FilterContext as a |
| 80 // base::SupportsUserData structure to which filter-specific information |
| 81 // could be added by whatever the ultimate consumer of the filter chain is, |
| 82 // and a particular filter (if included) could access that information. |
74 class NET_EXPORT_PRIVATE FilterContext { | 83 class NET_EXPORT_PRIVATE FilterContext { |
75 public: | 84 public: |
76 // Enum to control what histograms are emitted near end-of-life of this | 85 // Enum to control what histograms are emitted near end-of-life of this |
77 // instance. | 86 // instance. |
78 enum StatisticSelector { | 87 enum StatisticSelector { |
79 SDCH_DECODE, | 88 SDCH_DECODE, |
80 SDCH_PASSTHROUGH, | 89 SDCH_PASSTHROUGH, |
81 SDCH_EXPERIMENT_DECODE, | 90 SDCH_EXPERIMENT_DECODE, |
82 SDCH_EXPERIMENT_HOLDBACK, | 91 SDCH_EXPERIMENT_HOLDBACK, |
83 }; | 92 }; |
(...skipping 16 matching lines...) Expand all Loading... |
100 // When was this data requested from a server? | 109 // When was this data requested from a server? |
101 virtual base::Time GetRequestTime() const = 0; | 110 virtual base::Time GetRequestTime() const = 0; |
102 | 111 |
103 // Is data supplied from cache, or fresh across the net? | 112 // Is data supplied from cache, or fresh across the net? |
104 virtual bool IsCachedContent() const = 0; | 113 virtual bool IsCachedContent() const = 0; |
105 | 114 |
106 // Is this a download? | 115 // Is this a download? |
107 virtual bool IsDownload() const = 0; | 116 virtual bool IsDownload() const = 0; |
108 | 117 |
109 // Was this data flagged as a response to a request with an SDCH dictionary? | 118 // Was this data flagged as a response to a request with an SDCH dictionary? |
110 virtual bool SdchResponseExpected() const = 0; | 119 virtual SdchManager::DictionarySet* SdchDictionariesAdvertised() const = 0; |
111 | 120 |
112 // 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 |
113 // pushed into a filter for processing)? | 122 // pushed into a filter for processing)? |
114 virtual int64 GetByteReadCount() const = 0; | 123 virtual int64 GetByteReadCount() const = 0; |
115 | 124 |
116 // What response code was received with the associated network transaction? | 125 // What response code was received with the associated network transaction? |
117 // For example: 200 is ok. 4xx are error codes. etc. | 126 // For example: 200 is ok. 4xx are error codes. etc. |
118 virtual int GetResponseCode() const = 0; | 127 virtual int GetResponseCode() const = 0; |
119 | 128 |
120 // The URLRequestContext associated with the request. | 129 // The URLRequestContext associated with the request. |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // Remember what status or local filter last returned so we can better handle | 306 // Remember what status or local filter last returned so we can better handle |
298 // chained filters. | 307 // chained filters. |
299 FilterStatus last_status_; | 308 FilterStatus last_status_; |
300 | 309 |
301 DISALLOW_COPY_AND_ASSIGN(Filter); | 310 DISALLOW_COPY_AND_ASSIGN(Filter); |
302 }; | 311 }; |
303 | 312 |
304 } // namespace net | 313 } // namespace net |
305 | 314 |
306 #endif // NET_FILTER_FILTER_H__ | 315 #endif // NET_FILTER_FILTER_H__ |
OLD | NEW |