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

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

Issue 18390: Change URLRequest to use a ref-counted buffer for actual IO.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/base/completion_callback.h ('k') | net/base/filter.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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 17 matching lines...) Expand all
28 28
29 #ifndef NET_BASE_FILTER_H__ 29 #ifndef NET_BASE_FILTER_H__
30 #define NET_BASE_FILTER_H__ 30 #define NET_BASE_FILTER_H__
31 31
32 #include <string> 32 #include <string>
33 #include <vector> 33 #include <vector>
34 34
35 #include "base/basictypes.h" 35 #include "base/basictypes.h"
36 #include "base/scoped_ptr.h" 36 #include "base/scoped_ptr.h"
37 #include "base/time.h" 37 #include "base/time.h"
38 #include "net/base/io_buffer.h"
38 #include "googleurl/src/gurl.h" 39 #include "googleurl/src/gurl.h"
39 #include "testing/gtest/include/gtest/gtest_prod.h" 40 #include "testing/gtest/include/gtest/gtest_prod.h"
40 41
41 class Filter { 42 class Filter {
42 public: 43 public:
43 // Return values of function ReadFilteredData. 44 // Return values of function ReadFilteredData.
44 enum FilterStatus { 45 enum FilterStatus {
45 // Read filtered data successfully 46 // Read filtered data successfully
46 FILTER_OK, 47 FILTER_OK,
47 // Read filtered data successfully, and the data in the buffer has been 48 // Read filtered data successfully, and the data in the buffer has been
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // (decoding) order. For example, types[0] = "sdch", types[1] = "gzip" will 85 // (decoding) order. For example, types[0] = "sdch", types[1] = "gzip" will
85 // cause data to first be gunizip filtered, and the resulting output from that 86 // cause data to first be gunizip filtered, and the resulting output from that
86 // filter will be sdch decoded. 87 // filter will be sdch decoded.
87 static Filter* Factory(const std::vector<FilterType>& filter_types, 88 static Filter* Factory(const std::vector<FilterType>& filter_types,
88 int buffer_size); 89 int buffer_size);
89 90
90 // External call to obtain data from this filter chain. If ther is no 91 // External call to obtain data from this filter chain. If ther is no
91 // next_filter_, then it obtains data from this specific filter. 92 // next_filter_, then it obtains data from this specific filter.
92 FilterStatus ReadData(char* dest_buffer, int* dest_len); 93 FilterStatus ReadData(char* dest_buffer, int* dest_len);
93 94
94 // Returns a pointer to the beginning of stream_buffer_. 95 // Returns a pointer to the stream_buffer_.
95 char* stream_buffer() const { return stream_buffer_.get(); } 96 net::IOBuffer* stream_buffer() const { return stream_buffer_.get(); }
96 97
97 // Returns the maximum size of stream_buffer_ in number of chars. 98 // Returns the maximum size of stream_buffer_ in number of chars.
98 int stream_buffer_size() const { return stream_buffer_size_; } 99 int stream_buffer_size() const { return stream_buffer_size_; }
99 100
100 // Returns the total number of chars remaining in stream_buffer_ to be 101 // Returns the total number of chars remaining in stream_buffer_ to be
101 // filtered. 102 // filtered.
102 // 103 //
103 // If the function returns 0 then all data have been filtered and the caller 104 // If the function returns 0 then all data have been filtered and the caller
104 // is safe to copy new data into stream_buffer_. 105 // is safe to copy new data into stream_buffer_.
105 int stream_data_len() const { return stream_data_len_; } 106 int stream_data_len() const { return stream_data_len_; }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 static Filter* PrependNewFilter(FilterType type_id, int buffer_size, 171 static Filter* PrependNewFilter(FilterType type_id, int buffer_size,
171 Filter* filter_list); 172 Filter* filter_list);
172 173
173 FilterStatus last_status() const { return last_status_; } 174 FilterStatus last_status() const { return last_status_; }
174 175
175 base::Time connect_time() const { return connect_time_; } 176 base::Time connect_time() const { return connect_time_; }
176 177
177 bool was_cached() const { return was_cached_; } 178 bool was_cached() const { return was_cached_; }
178 179
179 // Buffer to hold the data to be filtered. 180 // Buffer to hold the data to be filtered.
180 scoped_array<char> stream_buffer_; 181 scoped_refptr<net::IOBuffer> stream_buffer_;
181 182
182 // Maximum size of stream_buffer_ in number of chars. 183 // Maximum size of stream_buffer_ in number of chars.
183 int stream_buffer_size_; 184 int stream_buffer_size_;
184 185
185 // Pointer to the next data in stream_buffer_ to be filtered. 186 // Pointer to the next data in stream_buffer_ to be filtered.
186 char* next_stream_data_; 187 char* next_stream_data_;
187 188
188 // Total number of remaining chars in stream_buffer_ to be filtered. 189 // Total number of remaining chars in stream_buffer_ to be filtered.
189 int stream_data_len_; 190 int stream_data_len_;
190 191
(...skipping 17 matching lines...) Expand all
208 scoped_ptr<Filter> next_filter_; 209 scoped_ptr<Filter> next_filter_;
209 // Remember what status or local filter last returned so we can better handle 210 // Remember what status or local filter last returned so we can better handle
210 // chained filters. 211 // chained filters.
211 FilterStatus last_status_; 212 FilterStatus last_status_;
212 213
213 DISALLOW_COPY_AND_ASSIGN(Filter); 214 DISALLOW_COPY_AND_ASSIGN(Filter);
214 }; 215 };
215 216
216 #endif // NET_BASE_FILTER_H__ 217 #endif // NET_BASE_FILTER_H__
217 218
OLDNEW
« no previous file with comments | « net/base/completion_callback.h ('k') | net/base/filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698