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

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

Issue 5204: Get open-vcdiff building on Linux and Mac (in SCons) using... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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/SConscript ('k') | sdch/SConscript » ('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/string_util.h" 7 #include "base/string_util.h"
8 #include "net/base/gzip_filter.h" 8 #include "net/base/gzip_filter.h"
9 #include "net/base/bzip2_filter.h" 9 #include "net/base/bzip2_filter.h"
10 #if defined(OS_WIN) || defined(OS_MACOSX)
11 // TODO(port): remove #ifdef when sdch works on all platforms.
12 #include "net/base/sdch_filter.h" 10 #include "net/base/sdch_filter.h"
13 #endif
14 11
15 namespace { 12 namespace {
16 13
17 // Filter types: 14 // Filter types:
18 const char kDeflate[] = "deflate"; 15 const char kDeflate[] = "deflate";
19 const char kGZip[] = "gzip"; 16 const char kGZip[] = "gzip";
20 const char kXGZip[] = "x-gzip"; 17 const char kXGZip[] = "x-gzip";
21 const char kBZip2[] = "bzip2"; 18 const char kBZip2[] = "bzip2";
22 const char kXBZip2[] = "x-bzip2"; 19 const char kXBZip2[] = "x-bzip2";
23 const char kSdch[] = "sdch"; 20 const char kSdch[] = "sdch";
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // content encoding. Sadly, Apache mistakenly sets these headers for all 75 // content encoding. Sadly, Apache mistakenly sets these headers for all
79 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore 76 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore
80 // the Content-Encoding here. 77 // the Content-Encoding here.
81 type_id = FILTER_TYPE_UNSUPPORTED; 78 type_id = FILTER_TYPE_UNSUPPORTED;
82 } else { 79 } else {
83 type_id = FILTER_TYPE_GZIP; 80 type_id = FILTER_TYPE_GZIP;
84 } 81 }
85 } else if (LowerCaseEqualsASCII(filter_type, kBZip2) || 82 } else if (LowerCaseEqualsASCII(filter_type, kBZip2) ||
86 LowerCaseEqualsASCII(filter_type, kXBZip2)) { 83 LowerCaseEqualsASCII(filter_type, kXBZip2)) {
87 type_id = FILTER_TYPE_BZIP2; 84 type_id = FILTER_TYPE_BZIP2;
88 #if defined(OS_WIN) || defined(OS_MACOSX)
89 // TODO(port): remove #ifdef when sdch works on all platforms.
90 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) { 85 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) {
91 type_id = FILTER_TYPE_SDCH; 86 type_id = FILTER_TYPE_SDCH;
92 #endif
93 } else { 87 } else {
94 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as 88 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as
95 // filter should be disabled in such cases. 89 // filter should be disabled in such cases.
96 type_id = FILTER_TYPE_UNSUPPORTED; 90 type_id = FILTER_TYPE_UNSUPPORTED;
97 } 91 }
98 92
99 switch (type_id) { 93 switch (type_id) {
100 case FILTER_TYPE_DEFLATE: 94 case FILTER_TYPE_DEFLATE:
101 case FILTER_TYPE_GZIP: { 95 case FILTER_TYPE_GZIP: {
102 scoped_ptr<GZipFilter> gz_filter(new GZipFilter()); 96 scoped_ptr<GZipFilter> gz_filter(new GZipFilter());
103 if (gz_filter->InitBuffer(buffer_size)) { 97 if (gz_filter->InitBuffer(buffer_size)) {
104 if (gz_filter->InitDecoding(type_id)) { 98 if (gz_filter->InitDecoding(type_id)) {
105 return gz_filter.release(); 99 return gz_filter.release();
106 } 100 }
107 } 101 }
108 break; 102 break;
109 } 103 }
110 case FILTER_TYPE_BZIP2: { 104 case FILTER_TYPE_BZIP2: {
111 scoped_ptr<BZip2Filter> bzip2_filter(new BZip2Filter()); 105 scoped_ptr<BZip2Filter> bzip2_filter(new BZip2Filter());
112 if (bzip2_filter->InitBuffer(buffer_size)) { 106 if (bzip2_filter->InitBuffer(buffer_size)) {
113 if (bzip2_filter->InitDecoding(false)) { 107 if (bzip2_filter->InitDecoding(false)) {
114 return bzip2_filter.release(); 108 return bzip2_filter.release();
115 } 109 }
116 } 110 }
117 break; 111 break;
118 } 112 }
119 #if defined(OS_WIN) || defined(OS_MACOSX)
120 // TODO(port): remove #ifdef when sdch works on all platforms.
121 case FILTER_TYPE_SDCH: { 113 case FILTER_TYPE_SDCH: {
122 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter()); 114 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter());
123 if (sdch_filter->InitBuffer(buffer_size)) { 115 if (sdch_filter->InitBuffer(buffer_size)) {
124 if (sdch_filter->InitDecoding()) { 116 if (sdch_filter->InitDecoding()) {
125 return sdch_filter.release(); 117 return sdch_filter.release();
126 } 118 }
127 } 119 }
128 break; 120 break;
129 } 121 }
130 #endif
131 default: { 122 default: {
132 break; 123 break;
133 } 124 }
134 } 125 }
135 126
136 return NULL; 127 return NULL;
137 } 128 }
138 129
139 Filter::Filter() 130 Filter::Filter()
140 : stream_buffer_(NULL), 131 : stream_buffer_(NULL),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 next_stream_data_ = stream_buffer(); 223 next_stream_data_ = stream_buffer();
233 stream_data_len_ = stream_data_len; 224 stream_data_len_ = stream_data_len;
234 return true; 225 return true;
235 } 226 }
236 227
237 void Filter::SetURL(const GURL& url) { 228 void Filter::SetURL(const GURL& url) {
238 url_ = url; 229 url_ = url;
239 if (next_filter_.get()) 230 if (next_filter_.get())
240 next_filter_->SetURL(url); 231 next_filter_->SetURL(url);
241 } 232 }
OLDNEW
« no previous file with comments | « net/SConscript ('k') | sdch/SConscript » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698