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

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

Issue 466038: Remove bzip2 decoding support completely. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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/filter.h ('k') | net/base/filter_unittest.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 #include "net/base/filter.h" 5 #include "net/base/filter.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/gzip_filter.h" 9 #include "net/base/gzip_filter.h"
10 #include "net/base/bzip2_filter.h"
11 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
12 #include "net/base/mime_util.h" 11 #include "net/base/mime_util.h"
13 #include "net/base/sdch_filter.h" 12 #include "net/base/sdch_filter.h"
14 13
15 namespace { 14 namespace {
16 15
17 // Filter types (using canonical lower case only): 16 // Filter types (using canonical lower case only):
18 const char kDeflate[] = "deflate"; 17 const char kDeflate[] = "deflate";
19 const char kGZip[] = "gzip"; 18 const char kGZip[] = "gzip";
20 const char kXGZip[] = "x-gzip"; 19 const char kXGZip[] = "x-gzip";
21 const char kBZip2[] = "bzip2";
22 const char kXBZip2[] = "x-bzip2";
23 const char kSdch[] = "sdch"; 20 const char kSdch[] = "sdch";
24 // compress and x-compress are currently not supported. If we decide to support 21 // compress and x-compress are currently not supported. If we decide to support
25 // them, we'll need the same mime type compatibility hack we have for gzip. For 22 // them, we'll need the same mime type compatibility hack we have for gzip. For
26 // more information, see Firefox's nsHttpChannel::ProcessNormal. 23 // more information, see Firefox's nsHttpChannel::ProcessNormal.
27 const char kCompress[] = "compress"; 24 const char kCompress[] = "compress";
28 const char kXCompress[] = "x-compress"; 25 const char kXCompress[] = "x-compress";
29 const char kIdentity[] = "identity"; 26 const char kIdentity[] = "identity";
30 const char kUncompressed[] = "uncompressed"; 27 const char kUncompressed[] = "uncompressed";
31 28
32 // Mime types: 29 // Mime types:
(...skipping 25 matching lines...) Expand all
58 55
59 // static 56 // static
60 Filter::FilterType Filter::ConvertEncodingToType( 57 Filter::FilterType Filter::ConvertEncodingToType(
61 const std::string& filter_type) { 58 const std::string& filter_type) {
62 FilterType type_id; 59 FilterType type_id;
63 if (LowerCaseEqualsASCII(filter_type, kDeflate)) { 60 if (LowerCaseEqualsASCII(filter_type, kDeflate)) {
64 type_id = FILTER_TYPE_DEFLATE; 61 type_id = FILTER_TYPE_DEFLATE;
65 } else if (LowerCaseEqualsASCII(filter_type, kGZip) || 62 } else if (LowerCaseEqualsASCII(filter_type, kGZip) ||
66 LowerCaseEqualsASCII(filter_type, kXGZip)) { 63 LowerCaseEqualsASCII(filter_type, kXGZip)) {
67 type_id = FILTER_TYPE_GZIP; 64 type_id = FILTER_TYPE_GZIP;
68 } else if (LowerCaseEqualsASCII(filter_type, kBZip2) ||
69 LowerCaseEqualsASCII(filter_type, kXBZip2)) {
70 type_id = FILTER_TYPE_BZIP2;
71 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) { 65 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) {
72 type_id = FILTER_TYPE_SDCH; 66 type_id = FILTER_TYPE_SDCH;
73 } else { 67 } else {
74 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as 68 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as
75 // filter should be disabled in such cases. 69 // filter should be disabled in such cases.
76 type_id = FILTER_TYPE_UNSUPPORTED; 70 type_id = FILTER_TYPE_UNSUPPORTED;
77 } 71 }
78 return type_id; 72 return type_id;
79 } 73 }
80 74
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 case FILTER_TYPE_DEFLATE: 239 case FILTER_TYPE_DEFLATE:
246 case FILTER_TYPE_GZIP: { 240 case FILTER_TYPE_GZIP: {
247 scoped_ptr<GZipFilter> gz_filter(new GZipFilter(filter_context)); 241 scoped_ptr<GZipFilter> gz_filter(new GZipFilter(filter_context));
248 if (gz_filter->InitBuffer()) { 242 if (gz_filter->InitBuffer()) {
249 if (gz_filter->InitDecoding(type_id)) { 243 if (gz_filter->InitDecoding(type_id)) {
250 first_filter = gz_filter.release(); 244 first_filter = gz_filter.release();
251 } 245 }
252 } 246 }
253 break; 247 break;
254 } 248 }
255 case FILTER_TYPE_BZIP2: {
256 scoped_ptr<BZip2Filter> bzip2_filter(new BZip2Filter(filter_context));
257 if (bzip2_filter->InitBuffer()) {
258 if (bzip2_filter->InitDecoding(false)) {
259 first_filter = bzip2_filter.release();
260 }
261 }
262 break;
263 }
264 case FILTER_TYPE_SDCH: 249 case FILTER_TYPE_SDCH:
265 case FILTER_TYPE_SDCH_POSSIBLE: { 250 case FILTER_TYPE_SDCH_POSSIBLE: {
266 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter(filter_context)); 251 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter(filter_context));
267 if (sdch_filter->InitBuffer()) { 252 if (sdch_filter->InitBuffer()) {
268 if (sdch_filter->InitDecoding(type_id)) { 253 if (sdch_filter->InitDecoding(type_id)) {
269 first_filter = sdch_filter.release(); 254 first_filter = sdch_filter.release();
270 } 255 }
271 } 256 }
272 break; 257 break;
273 } 258 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 381
397 DCHECK(stream_buffer()); 382 DCHECK(stream_buffer());
398 // Bail out if there is more data in the stream buffer to be filtered. 383 // Bail out if there is more data in the stream buffer to be filtered.
399 if (!stream_buffer() || stream_data_len_) 384 if (!stream_buffer() || stream_data_len_)
400 return false; 385 return false;
401 386
402 next_stream_data_ = stream_buffer()->data(); 387 next_stream_data_ = stream_buffer()->data();
403 stream_data_len_ = stream_data_len; 388 stream_data_len_ = stream_data_len;
404 return true; 389 return true;
405 } 390 }
OLDNEW
« no previous file with comments | « net/base/filter.h ('k') | net/base/filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698