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 #include "net/filter/filter.h" | 5 #include "net/filter/filter.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/filename_util.h" | 9 #include "net/base/filename_util.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
11 #include "net/base/mime_util.h" | 11 #include "net/base/mime_util.h" |
12 #include "net/filter/gzip_filter.h" | 12 #include "net/filter/gzip_filter.h" |
13 #include "net/filter/sdch_filter.h" | 13 #include "net/filter/sdch_filter.h" |
| 14 #include "net/url_request/url_request_context.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // Filter types (using canonical lower case only): | 19 // Filter types (using canonical lower case only): |
19 const char kDeflate[] = "deflate"; | 20 const char kDeflate[] = "deflate"; |
20 const char kGZip[] = "gzip"; | 21 const char kGZip[] = "gzip"; |
21 const char kXGZip[] = "x-gzip"; | 22 const char kXGZip[] = "x-gzip"; |
22 const char kSdch[] = "sdch"; | 23 const char kSdch[] = "sdch"; |
23 // compress and x-compress are currently not supported. If we decide to support | 24 // compress and x-compress are currently not supported. If we decide to support |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Filter* filter_list) { | 368 Filter* filter_list) { |
368 scoped_ptr<Filter> first_filter; // Soon to be start of chain. | 369 scoped_ptr<Filter> first_filter; // Soon to be start of chain. |
369 switch (type_id) { | 370 switch (type_id) { |
370 case FILTER_TYPE_GZIP_HELPING_SDCH: | 371 case FILTER_TYPE_GZIP_HELPING_SDCH: |
371 case FILTER_TYPE_DEFLATE: | 372 case FILTER_TYPE_DEFLATE: |
372 case FILTER_TYPE_GZIP: | 373 case FILTER_TYPE_GZIP: |
373 first_filter.reset(InitGZipFilter(type_id, buffer_size)); | 374 first_filter.reset(InitGZipFilter(type_id, buffer_size)); |
374 break; | 375 break; |
375 case FILTER_TYPE_SDCH: | 376 case FILTER_TYPE_SDCH: |
376 case FILTER_TYPE_SDCH_POSSIBLE: | 377 case FILTER_TYPE_SDCH_POSSIBLE: |
377 if (SdchManager::Global() && SdchManager::sdch_enabled()) { | 378 if (filter_context.GetURLRequestContext()->sdch_manager() && |
| 379 SdchManager::sdch_enabled()) { |
378 first_filter.reset( | 380 first_filter.reset( |
379 InitSdchFilter(type_id, filter_context, buffer_size)); | 381 InitSdchFilter(type_id, filter_context, buffer_size)); |
380 } | 382 } |
381 break; | 383 break; |
382 default: | 384 default: |
383 break; | 385 break; |
384 } | 386 } |
385 | 387 |
386 if (!first_filter.get()) | 388 if (!first_filter.get()) |
387 return NULL; | 389 return NULL; |
(...skipping 11 matching lines...) Expand all Loading... |
399 | 401 |
400 void Filter::PushDataIntoNextFilter() { | 402 void Filter::PushDataIntoNextFilter() { |
401 IOBuffer* next_buffer = next_filter_->stream_buffer(); | 403 IOBuffer* next_buffer = next_filter_->stream_buffer(); |
402 int next_size = next_filter_->stream_buffer_size(); | 404 int next_size = next_filter_->stream_buffer_size(); |
403 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); | 405 last_status_ = ReadFilteredData(next_buffer->data(), &next_size); |
404 if (FILTER_ERROR != last_status_) | 406 if (FILTER_ERROR != last_status_) |
405 next_filter_->FlushStreamBuffer(next_size); | 407 next_filter_->FlushStreamBuffer(next_size); |
406 } | 408 } |
407 | 409 |
408 } // namespace net | 410 } // namespace net |
OLD | NEW |