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

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

Issue 4096: Use open-vcdiff for sdch compression on the Mac (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 | « build/all.xcodeproj/project.pbxproj ('k') | net/base/sdch_filter_unitest.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/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) 10 #if defined(OS_WIN) || defined(OS_MACOSX)
11 // TODO(port): restore when sdch works on non-Windows. 11 // TODO(port): remove #ifdef when sdch works on all platforms.
12 #include "net/base/sdch_filter.h" 12 #include "net/base/sdch_filter.h"
13 #endif 13 #endif
14 14
15 namespace { 15 namespace {
16 16
17 // Filter types: 17 // Filter types:
18 const char kDeflate[] = "deflate"; 18 const char kDeflate[] = "deflate";
19 const char kGZip[] = "gzip"; 19 const char kGZip[] = "gzip";
20 const char kXGZip[] = "x-gzip"; 20 const char kXGZip[] = "x-gzip";
21 const char kBZip2[] = "bzip2"; 21 const char kBZip2[] = "bzip2";
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // content encoding. Sadly, Apache mistakenly sets these headers for all 78 // content encoding. Sadly, Apache mistakenly sets these headers for all
79 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore 79 // .gz files. We match Firefox's nsHttpChannel::ProcessNormal and ignore
80 // the Content-Encoding here. 80 // the Content-Encoding here.
81 type_id = FILTER_TYPE_UNSUPPORTED; 81 type_id = FILTER_TYPE_UNSUPPORTED;
82 } else { 82 } else {
83 type_id = FILTER_TYPE_GZIP; 83 type_id = FILTER_TYPE_GZIP;
84 } 84 }
85 } else if (LowerCaseEqualsASCII(filter_type, kBZip2) || 85 } else if (LowerCaseEqualsASCII(filter_type, kBZip2) ||
86 LowerCaseEqualsASCII(filter_type, kXBZip2)) { 86 LowerCaseEqualsASCII(filter_type, kXBZip2)) {
87 type_id = FILTER_TYPE_BZIP2; 87 type_id = FILTER_TYPE_BZIP2;
88 #if defined(OS_WIN) 88 #if defined(OS_WIN) || defined(OS_MACOSX)
89 // TODO(port): restore when sdch works on non-Windows. 89 // TODO(port): remove #ifdef when sdch works on all platforms.
90 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) { 90 } else if (LowerCaseEqualsASCII(filter_type, kSdch)) {
91 type_id = FILTER_TYPE_SDCH; 91 type_id = FILTER_TYPE_SDCH;
92 #endif 92 #endif
93 } else { 93 } else {
94 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as 94 // Note we also consider "identity" and "uncompressed" UNSUPPORTED as
95 // filter should be disabled in such cases. 95 // filter should be disabled in such cases.
96 type_id = FILTER_TYPE_UNSUPPORTED; 96 type_id = FILTER_TYPE_UNSUPPORTED;
97 } 97 }
98 98
99 switch (type_id) { 99 switch (type_id) {
100 case FILTER_TYPE_DEFLATE: 100 case FILTER_TYPE_DEFLATE:
101 case FILTER_TYPE_GZIP: { 101 case FILTER_TYPE_GZIP: {
102 scoped_ptr<GZipFilter> gz_filter(new GZipFilter()); 102 scoped_ptr<GZipFilter> gz_filter(new GZipFilter());
103 if (gz_filter->InitBuffer(buffer_size)) { 103 if (gz_filter->InitBuffer(buffer_size)) {
104 if (gz_filter->InitDecoding(type_id)) { 104 if (gz_filter->InitDecoding(type_id)) {
105 return gz_filter.release(); 105 return gz_filter.release();
106 } 106 }
107 } 107 }
108 break; 108 break;
109 } 109 }
110 case FILTER_TYPE_BZIP2: { 110 case FILTER_TYPE_BZIP2: {
111 scoped_ptr<BZip2Filter> bzip2_filter(new BZip2Filter()); 111 scoped_ptr<BZip2Filter> bzip2_filter(new BZip2Filter());
112 if (bzip2_filter->InitBuffer(buffer_size)) { 112 if (bzip2_filter->InitBuffer(buffer_size)) {
113 if (bzip2_filter->InitDecoding(false)) { 113 if (bzip2_filter->InitDecoding(false)) {
114 return bzip2_filter.release(); 114 return bzip2_filter.release();
115 } 115 }
116 } 116 }
117 break; 117 break;
118 } 118 }
119 #if defined(OS_WIN) 119 #if defined(OS_WIN) || defined(OS_MACOSX)
120 // TODO(port): restore when sdch works on non-Windows. 120 // TODO(port): remove #ifdef when sdch works on all platforms.
121 case FILTER_TYPE_SDCH: { 121 case FILTER_TYPE_SDCH: {
122 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter()); 122 scoped_ptr<SdchFilter> sdch_filter(new SdchFilter());
123 if (sdch_filter->InitBuffer(buffer_size)) { 123 if (sdch_filter->InitBuffer(buffer_size)) {
124 if (sdch_filter->InitDecoding()) { 124 if (sdch_filter->InitDecoding()) {
125 return sdch_filter.release(); 125 return sdch_filter.release();
126 } 126 }
127 } 127 }
128 break; 128 break;
129 } 129 }
130 #endif 130 #endif
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 next_stream_data_ = stream_buffer(); 232 next_stream_data_ = stream_buffer();
233 stream_data_len_ = stream_data_len; 233 stream_data_len_ = stream_data_len;
234 return true; 234 return true;
235 } 235 }
236 236
237 void Filter::SetURL(const GURL& url) { 237 void Filter::SetURL(const GURL& url) {
238 url_ = url; 238 url_ = url;
239 if (next_filter_.get()) 239 if (next_filter_.get())
240 next_filter_->SetURL(url); 240 next_filter_->SetURL(url);
241 } 241 }
OLDNEW
« no previous file with comments | « build/all.xcodeproj/project.pbxproj ('k') | net/base/sdch_filter_unitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698