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

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

Issue 6529006: Don't call the zlib functions with the MOZ_Z_ prefix... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 10 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/base/gzip_filter.cc ('k') | remoting/base/compressor_zlib.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 <fstream> 5 #include <fstream>
6 #include <iostream> 6 #include <iostream>
7 7
8 #if defined(USE_SYSTEM_ZLIB) 8 #if defined(USE_SYSTEM_ZLIB)
9 // The code below uses the MOZ_Z_ forms of these functions in order that things
10 // should work on Windows. In order to make this code cross platform, we map
11 // back to the normal functions here in the case that we are using the system
12 // zlib.
13 #define MOZ_Z_deflate deflate
14 #define MOZ_Z_deflateEnd deflateEnd
15 #include <zlib.h> 9 #include <zlib.h>
16 #else 10 #else
17 #include "third_party/zlib/zlib.h" 11 #include "third_party/zlib/zlib.h"
18 #endif 12 #endif
19 13
20 #include "base/file_util.h" 14 #include "base/file_util.h"
21 #include "base/path_service.h" 15 #include "base/path_service.h"
22 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
23 #include "net/base/gzip_filter.h" 17 #include "net/base/gzip_filter.h"
24 #include "net/base/mock_filter_context.h" 18 #include "net/base/mock_filter_context.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Write header if needed 139 // Write header if needed
146 if (mode == ENCODE_GZIP) { 140 if (mode == ENCODE_GZIP) {
147 if (zlib_stream.avail_out < sizeof(kGZipHeader)) 141 if (zlib_stream.avail_out < sizeof(kGZipHeader))
148 return Z_BUF_ERROR; 142 return Z_BUF_ERROR;
149 memcpy(zlib_stream.next_out, kGZipHeader, sizeof(kGZipHeader)); 143 memcpy(zlib_stream.next_out, kGZipHeader, sizeof(kGZipHeader));
150 zlib_stream.next_out += sizeof(kGZipHeader); 144 zlib_stream.next_out += sizeof(kGZipHeader);
151 zlib_stream.avail_out -= sizeof(kGZipHeader); 145 zlib_stream.avail_out -= sizeof(kGZipHeader);
152 } 146 }
153 147
154 // Do deflate 148 // Do deflate
155 code = MOZ_Z_deflate(&zlib_stream, Z_FINISH); 149 code = deflate(&zlib_stream, Z_FINISH);
156 *dest_len = *dest_len - zlib_stream.avail_out; 150 *dest_len = *dest_len - zlib_stream.avail_out;
157 151
158 MOZ_Z_deflateEnd(&zlib_stream); 152 deflateEnd(&zlib_stream);
159 return code; 153 return code;
160 } 154 }
161 155
162 // Use filter to decode compressed data, and compare the decoding result with 156 // Use filter to decode compressed data, and compare the decoding result with
163 // the orginal Data. 157 // the orginal Data.
164 // Parameters: Source and source_len are original data and its size. 158 // Parameters: Source and source_len are original data and its size.
165 // Encoded_source and encoded_source_len are compressed data and its size. 159 // Encoded_source and encoded_source_len are compressed data and its size.
166 // Output_buffer_size specifies the size of buffer to read out data from 160 // Output_buffer_size specifies the size of buffer to read out data from
167 // filter. 161 // filter.
168 void DecodeAndCompareWithFilter(Filter* filter, 162 void DecodeAndCompareWithFilter(Filter* filter,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 int corrupt_decode_size = kDefaultBufferSize; 397 int corrupt_decode_size = kDefaultBufferSize;
404 398
405 int code = DecodeAllWithFilter(filter.get(), corrupt_data, corrupt_data_len, 399 int code = DecodeAllWithFilter(filter.get(), corrupt_data, corrupt_data_len,
406 corrupt_decode_buffer, &corrupt_decode_size); 400 corrupt_decode_buffer, &corrupt_decode_size);
407 401
408 // Expect failures 402 // Expect failures
409 EXPECT_TRUE(code == Filter::FILTER_ERROR); 403 EXPECT_TRUE(code == Filter::FILTER_ERROR);
410 } 404 }
411 405
412 } // namespace 406 } // namespace
OLDNEW
« no previous file with comments | « net/base/gzip_filter.cc ('k') | remoting/base/compressor_zlib.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698