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

Side by Side Diff: net/filter/filter.cc

Issue 2266693002: Implement "streaming" $i18n{} replacer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compress-webui2
Patch Set: Created 4 years, 4 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
« no previous file with comments | « net/filter/filter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // The basic usage of the Filter interface is described in the comment at 5 // The basic usage of the Filter interface is described in the comment at
6 // the beginning of filter.h. If Filter::Factory is passed a vector of 6 // the beginning of filter.h. If Filter::Factory is passed a vector of
7 // size greater than 1, that interface is implemented by a series of filters 7 // size greater than 1, that interface is implemented by a series of filters
8 // connected in a chain. In such a case the first filter 8 // connected in a chain. In such a case the first filter
9 // in the chain proxies calls to ReadData() so that its return values 9 // in the chain proxies calls to ReadData() so that its return values
10 // apply to the entire chain. 10 // apply to the entire chain.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 std::string Filter::OrderedFilterList() const { 335 std::string Filter::OrderedFilterList() const {
336 if (next_filter_) { 336 if (next_filter_) {
337 return FilterTypeAsString(type_id_) + "," + 337 return FilterTypeAsString(type_id_) + "," +
338 next_filter_->OrderedFilterList(); 338 next_filter_->OrderedFilterList();
339 } else { 339 } else {
340 return FilterTypeAsString(type_id_); 340 return FilterTypeAsString(type_id_);
341 } 341 }
342 } 342 }
343 343
344 void Filter::TakeNextFilter(std::unique_ptr<Filter> next_filter) {
345 next_filter_ = std::move(next_filter);
346 }
347
344 Filter::Filter(FilterType type_id) 348 Filter::Filter(FilterType type_id)
345 : stream_buffer_(nullptr), 349 : stream_buffer_(nullptr),
346 stream_buffer_size_(0), 350 stream_buffer_size_(0),
347 next_stream_data_(nullptr), 351 next_stream_data_(nullptr),
348 stream_data_len_(0), 352 stream_data_len_(0),
349 last_status_(FILTER_NEED_MORE_DATA), 353 last_status_(FILTER_NEED_MORE_DATA),
350 type_id_(type_id) {} 354 type_id_(type_id) {}
351 355
352 Filter::FilterStatus Filter::CopyOut(char* dest_buffer, int* dest_len) { 356 Filter::FilterStatus Filter::CopyOut(char* dest_buffer, int* dest_len) {
353 int out_len; 357 int out_len;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 446
443 void Filter::PushDataIntoNextFilter() { 447 void Filter::PushDataIntoNextFilter() {
444 IOBuffer* next_buffer = next_filter_->stream_buffer(); 448 IOBuffer* next_buffer = next_filter_->stream_buffer();
445 int next_size = next_filter_->stream_buffer_size(); 449 int next_size = next_filter_->stream_buffer_size();
446 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); 450 last_status_ = ReadFilteredData(next_buffer->data(), &next_size);
447 if (FILTER_ERROR != last_status_) 451 if (FILTER_ERROR != last_status_)
448 next_filter_->FlushStreamBuffer(next_size); 452 next_filter_->FlushStreamBuffer(next_size);
449 } 453 }
450 454
451 } // namespace net 455 } // namespace net
OLDNEW
« no previous file with comments | « net/filter/filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698