OLD | NEW |
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 "base/histogram.h" | 5 #include "base/histogram.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/sha2.h" | 7 #include "base/sha2.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "net/base/base64.h" | 9 #include "net/base/base64.h" |
10 #include "net/base/registry_controlled_domain.h" | 10 #include "net/base/registry_controlled_domain.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (!list->empty()) | 159 if (!list->empty()) |
160 list->append(","); | 160 list->append(","); |
161 list->append(it->second->client_hash()); | 161 list->append(it->second->client_hash()); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 SdchManager::Dictionary::Dictionary(const std::string& dictionary_text, | 165 SdchManager::Dictionary::Dictionary(const std::string& dictionary_text, |
166 size_t offset, const std::string& client_hash, const GURL& gurl, | 166 size_t offset, const std::string& client_hash, const GURL& gurl, |
167 const std::string& domain, const std::string& path, const Time& expiration, | 167 const std::string& domain, const std::string& path, const Time& expiration, |
168 const std::set<int> ports) | 168 const std::set<int> ports) |
169 : text_(dictionary_text, offset), | 169 : ports_(ports), |
| 170 text_(dictionary_text, offset), |
170 client_hash_(client_hash), | 171 client_hash_(client_hash), |
171 url_(gurl), | 172 url_(gurl), |
172 domain_(domain), | 173 domain_(domain), |
173 path_(path), | 174 path_(path), |
174 expiration_(expiration), | 175 expiration_(expiration) { |
175 ports_(ports) { | |
176 } | 176 } |
177 | 177 |
178 // static | 178 // static |
179 void SdchManager::GenerateHash(const std::string& dictionary_text, | 179 void SdchManager::GenerateHash(const std::string& dictionary_text, |
180 std::string* client_hash, std::string* server_hash) { | 180 std::string* client_hash, std::string* server_hash) { |
181 char binary_hash[32]; | 181 char binary_hash[32]; |
182 base::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); | 182 base::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); |
183 | 183 |
184 std::string first_48_bits(&binary_hash[0], 6); | 184 std::string first_48_bits(&binary_hash[0], 6); |
185 std::string second_48_bits(&binary_hash[6], 6); | 185 std::string second_48_bits(&binary_hash[6], 6); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 return false; | 327 return false; |
328 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; | 328 return restriction[prefix_length - 1] == '/' || path[prefix_length] == '/'; |
329 } | 329 } |
330 | 330 |
331 // static | 331 // static |
332 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, | 332 bool SdchManager::Dictionary::DomainMatch(const GURL& gurl, |
333 const std::string& restriction) { | 333 const std::string& restriction) { |
334 // TODO(jar): This is not precisely a domain match definition. | 334 // TODO(jar): This is not precisely a domain match definition. |
335 return gurl.DomainIs(restriction.data(), restriction.size()); | 335 return gurl.DomainIs(restriction.data(), restriction.size()); |
336 } | 336 } |
OLD | NEW |