OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 MockFilterContext* filter_context() { return filter_context_.get(); } | 79 MockFilterContext* filter_context() { return filter_context_.get(); } |
80 | 80 |
81 // Sets both the GURL and the SDCH response for a filter context. | 81 // Sets both the GURL and the SDCH response for a filter context. |
82 void SetupFilterContextWithGURL(GURL url) { | 82 void SetupFilterContextWithGURL(GURL url) { |
83 filter_context_->SetURL(url); | 83 filter_context_->SetURL(url); |
84 filter_context_->SetSdchResponse( | 84 filter_context_->SetSdchResponse( |
85 sdch_manager_->GetDictionarySet(url).Pass()); | 85 sdch_manager_->GetDictionarySet(url).Pass()); |
86 } | 86 } |
87 | 87 |
88 std::string NewSdchCompressedData(const std::string dictionary) { | 88 std::string NewSdchCompressedData(const std::string& dictionary) { |
89 std::string client_hash; | 89 std::string client_hash; |
90 std::string server_hash; | 90 std::string server_hash; |
91 SdchManager::GenerateHash(dictionary, &client_hash, &server_hash); | 91 SdchManager::GenerateHash(dictionary, &client_hash, &server_hash); |
92 | 92 |
93 // Build compressed data that refers to our dictionary. | 93 // Build compressed data that refers to our dictionary. |
94 std::string compressed(server_hash); | 94 std::string compressed(server_hash); |
95 compressed.append("\0", 1); | 95 compressed.append("\0", 1); |
96 compressed.append(vcdiff_compressed_data_); | 96 compressed.append(vcdiff_compressed_data_); |
97 return compressed; | 97 return compressed; |
98 } | 98 } |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 | 1292 |
1293 filter.reset(nullptr); | 1293 filter.reset(nullptr); |
1294 | 1294 |
1295 // Confirm that we got a "DictionaryUsed" signal from the SdchManager | 1295 // Confirm that we got a "DictionaryUsed" signal from the SdchManager |
1296 // for our dictionary. | 1296 // for our dictionary. |
1297 EXPECT_EQ(1, observer.dictionary_used_calls()); | 1297 EXPECT_EQ(1, observer.dictionary_used_calls()); |
1298 EXPECT_EQ(server_hash, observer.last_server_hash()); | 1298 EXPECT_EQ(server_hash, observer.last_server_hash()); |
1299 } | 1299 } |
1300 | 1300 |
1301 } // namespace net | 1301 } // namespace net |
OLD | NEW |