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 // 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 next_stream_data_ = NULL; | 352 next_stream_data_ = NULL; |
353 return Filter::FILTER_NEED_MORE_DATA; | 353 return Filter::FILTER_NEED_MORE_DATA; |
354 } else { | 354 } else { |
355 next_stream_data_ += out_len; | 355 next_stream_data_ += out_len; |
356 return Filter::FILTER_OK; | 356 return Filter::FILTER_OK; |
357 } | 357 } |
358 } | 358 } |
359 | 359 |
360 // static | 360 // static |
361 Filter* Filter::InitBrotliFilter(FilterType type_id, int buffer_size) { | 361 Filter* Filter::InitBrotliFilter(FilterType type_id, int buffer_size) { |
362 scoped_ptr<Filter> brotli_filter(CreateBrotliFilter(type_id)); | 362 std::unique_ptr<Filter> brotli_filter(CreateBrotliFilter(type_id)); |
363 if (!brotli_filter.get()) | 363 if (!brotli_filter.get()) |
364 return nullptr; | 364 return nullptr; |
365 | 365 |
366 brotli_filter->InitBuffer(buffer_size); | 366 brotli_filter->InitBuffer(buffer_size); |
367 return brotli_filter.release(); | 367 return brotli_filter.release(); |
368 } | 368 } |
369 | 369 |
370 // static | 370 // static |
371 Filter* Filter::InitGZipFilter(FilterType type_id, int buffer_size) { | 371 Filter* Filter::InitGZipFilter(FilterType type_id, int buffer_size) { |
372 scoped_ptr<GZipFilter> gz_filter(new GZipFilter(type_id)); | 372 std::unique_ptr<GZipFilter> gz_filter(new GZipFilter(type_id)); |
373 gz_filter->InitBuffer(buffer_size); | 373 gz_filter->InitBuffer(buffer_size); |
374 return gz_filter->InitDecoding(type_id) ? gz_filter.release() : NULL; | 374 return gz_filter->InitDecoding(type_id) ? gz_filter.release() : NULL; |
375 } | 375 } |
376 | 376 |
377 // static | 377 // static |
378 Filter* Filter::InitSdchFilter(FilterType type_id, | 378 Filter* Filter::InitSdchFilter(FilterType type_id, |
379 const FilterContext& filter_context, | 379 const FilterContext& filter_context, |
380 int buffer_size) { | 380 int buffer_size) { |
381 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter(type_id, filter_context)); | 381 std::unique_ptr<SdchFilter> sdch_filter( |
| 382 new SdchFilter(type_id, filter_context)); |
382 sdch_filter->InitBuffer(buffer_size); | 383 sdch_filter->InitBuffer(buffer_size); |
383 return sdch_filter->InitDecoding(type_id) ? sdch_filter.release() : NULL; | 384 return sdch_filter->InitDecoding(type_id) ? sdch_filter.release() : NULL; |
384 } | 385 } |
385 | 386 |
386 // static | 387 // static |
387 Filter* Filter::PrependNewFilter(FilterType type_id, | 388 Filter* Filter::PrependNewFilter(FilterType type_id, |
388 const FilterContext& filter_context, | 389 const FilterContext& filter_context, |
389 int buffer_size, | 390 int buffer_size, |
390 Filter* filter_list) { | 391 Filter* filter_list) { |
391 scoped_ptr<Filter> first_filter; // Soon to be start of chain. | 392 std::unique_ptr<Filter> first_filter; // Soon to be start of chain. |
392 switch (type_id) { | 393 switch (type_id) { |
393 case FILTER_TYPE_BROTLI: | 394 case FILTER_TYPE_BROTLI: |
394 first_filter.reset(InitBrotliFilter(type_id, buffer_size)); | 395 first_filter.reset(InitBrotliFilter(type_id, buffer_size)); |
395 break; | 396 break; |
396 case FILTER_TYPE_GZIP_HELPING_SDCH: | 397 case FILTER_TYPE_GZIP_HELPING_SDCH: |
397 case FILTER_TYPE_DEFLATE: | 398 case FILTER_TYPE_DEFLATE: |
398 case FILTER_TYPE_GZIP: | 399 case FILTER_TYPE_GZIP: |
399 first_filter.reset(InitGZipFilter(type_id, buffer_size)); | 400 first_filter.reset(InitGZipFilter(type_id, buffer_size)); |
400 break; | 401 break; |
401 case FILTER_TYPE_SDCH: | 402 case FILTER_TYPE_SDCH: |
(...skipping 23 matching lines...) Expand all Loading... |
425 | 426 |
426 void Filter::PushDataIntoNextFilter() { | 427 void Filter::PushDataIntoNextFilter() { |
427 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 428 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
428 int next_size = next_filter_->stream_buffer_size(); | 429 int next_size = next_filter_->stream_buffer_size(); |
429 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 430 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
430 if (FILTER_ERROR != last_status_) | 431 if (FILTER_ERROR != last_status_) |
431 next_filter_->FlushStreamBuffer(next_size); | 432 next_filter_->FlushStreamBuffer(next_size); |
432 } | 433 } |
433 | 434 |
434 } // namespace net | 435 } // namespace net |
OLD | NEW |