OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <limits.h> | 5 #include <limits.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 // | 820 // |
821 // Header value we generate: | 821 // Header value we generate: |
822 const char kGZipHeader[] = { '\037', '\213', '\010', '\000', '\000', | 822 const char kGZipHeader[] = { '\037', '\213', '\010', '\000', '\000', |
823 '\000', '\000', '\000', '\002', '\377' }; | 823 '\000', '\000', '\000', '\002', '\377' }; |
824 CHECK_GT(zlib_stream.avail_out, sizeof(kGZipHeader)); | 824 CHECK_GT(zlib_stream.avail_out, sizeof(kGZipHeader)); |
825 memcpy(zlib_stream.next_out, kGZipHeader, sizeof(kGZipHeader)); | 825 memcpy(zlib_stream.next_out, kGZipHeader, sizeof(kGZipHeader)); |
826 zlib_stream.next_out += sizeof(kGZipHeader); | 826 zlib_stream.next_out += sizeof(kGZipHeader); |
827 zlib_stream.avail_out -= sizeof(kGZipHeader); | 827 zlib_stream.avail_out -= sizeof(kGZipHeader); |
828 | 828 |
829 // Do deflate | 829 // Do deflate |
830 code = MOZ_Z_deflate(&zlib_stream, Z_FINISH); | 830 code = deflate(&zlib_stream, Z_FINISH); |
831 gzip_compressed_length -= zlib_stream.avail_out; | 831 gzip_compressed_length -= zlib_stream.avail_out; |
832 std::string compressed(gzip_compressed.get(), gzip_compressed_length); | 832 std::string compressed(gzip_compressed.get(), gzip_compressed_length); |
833 MOZ_Z_deflateEnd(&zlib_stream); | 833 deflateEnd(&zlib_stream); |
834 return compressed; | 834 return compressed; |
835 } | 835 } |
836 | 836 |
837 //------------------------------------------------------------------------------ | 837 //------------------------------------------------------------------------------ |
838 | 838 |
839 // Test that filters can be cascaded (chained) so that the output of one filter | 839 // Test that filters can be cascaded (chained) so that the output of one filter |
840 // is processed by the next one. This is most critical for SDCH, which is | 840 // is processed by the next one. This is most critical for SDCH, which is |
841 // routinely followed by gzip (during encoding). The filter we'll test for will | 841 // routinely followed by gzip (during encoding). The filter we'll test for will |
842 // do the gzip decoding first, and then decode the SDCH content. | 842 // do the gzip decoding first, and then decode the SDCH content. |
843 TEST_F(SdchFilterTest, FilterChaining) { | 843 TEST_F(SdchFilterTest, FilterChaining) { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 sdch_manager_->SetAllowLatencyExperiment(url, false); | 1401 sdch_manager_->SetAllowLatencyExperiment(url, false); |
1402 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); | 1402 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); |
1403 EXPECT_TRUE(sdch_manager_->AllowLatencyExperiment(url2)); | 1403 EXPECT_TRUE(sdch_manager_->AllowLatencyExperiment(url2)); |
1404 | 1404 |
1405 sdch_manager_->SetAllowLatencyExperiment(url2, false); | 1405 sdch_manager_->SetAllowLatencyExperiment(url2, false); |
1406 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); | 1406 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url)); |
1407 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url2)); | 1407 EXPECT_FALSE(sdch_manager_->AllowLatencyExperiment(url2)); |
1408 } | 1408 } |
1409 | 1409 |
1410 } // namespace net | 1410 } // namespace net |
OLD | NEW |